| | |
A86 draw shape
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
compile using A86 assembler however you can adapt it for any other one easily... It just draws out a 3D like shape. It was annoying to get the angles right but suggestions on improvement to code is appreciated. 
Adequately commented so it is understandable not fully as it is very repetitive..
NOTE: To use on vista DOSbox is required to enter graphical mode
~Jon~

Adequately commented so it is understandable not fully as it is very repetitive..
NOTE: To use on vista DOSbox is required to enter graphical mode
~Jon~
Last edited by jhouns; Sep 8th, 2009 at 12:54 pm.
; *********************************** ; * * ; * A program that will draw a 3D'ish * ; * shape * ; * * ; *********************************** jmp start ;start command ;================================================ mode db 18 ;Resolution/Graphical mode colour db 1 ;1 = Blue a_x dw 100 ;Point a x coord a_y dw 100 ;Point a y coord b_x dw 100 b_y dw 300 c_x dw 180 c_y dw 380 d_x dw 250 d_y dw 25 e_x dw 332 e_y dw 300 ;================================================ start: mov ah,00 mov al,mode ;set graphic mode int 10h ;enter graphic mode mov ah,0Ch ;set write dot mode mov al,colour ;set the colour mov cx,a_x ;set point a mov dx,a_y draw_a_b: ;draw line ab int 10h inc dx cmp dx,b_y jnz draw_a_b prep_b_c: ;setup line bc mov cx,b_x mov dx,b_y draw_b_c: ;draw line bc int 10h inc cx inc dx cmp cx,c_x jnz draw_b_c cmp dx,c_y jnz draw_b_c prep_c_a: ;setup line ca mov cx,c_x mov dx,c_y draw_c_a: ;draw line ca int 10h sub dx,7 sub cx,2 cmp dx,a_y jnz draw_c_a cmp cx,a_x jnz draw_c_a prep_a_d: ;setup line ad mov cx,a_x mov dx,a_y draw_a_d: ;draw line ad int 10h add cx,2 sub dx,1 cmp cx,d_x jnz draw_a_d prep_c_e: ;setup line de mov cx,c_x mov dx,c_y draw_c_e: ;draw line ce int 10h add cx,2 sub dx,1 cmp cx,e_x jnz draw_c_e prep_d_e: ;setup line dw mov cx,d_x mov dx,d_y draw_d_e: int 10h add dx,7 add cx,2 cmp cx,e_x jnz draw_d_e GetKey: mov ah,00 int 16h end: mov ah,00 mov al,03 int 10h mov ah,04Ch mov al,00 int 21h
0
•
•
•
•
Can you explain exactly what you want? Or what your problem is!
You are precarious, you draw a diagonal line but step +x,+y, check for x reaching the next waypoint axis exactly (zero flag check), but then check y. If y2-y1 is not equal to x2-x1 then you have a runaway. x is now past the axis and will continue until way off the screen and comes around again!
Instead of what you're doing, how about creating a function.
DrawLine( x1,y1, x2,y2 ). You can then create cool algorithms like a DDA
Step on the longest axis and error correct on the sortest axis. Simple Binary math, and no wierd stepping logic.
If you track last x,y then you can also have a
DrawLineTo( x2, y2 )
You are precarious, you draw a diagonal line but step +x,+y, check for x reaching the next waypoint axis exactly (zero flag check), but then check y. If y2-y1 is not equal to x2-x1 then you have a runaway. x is now past the axis and will continue until way off the screen and comes around again!
Instead of what you're doing, how about creating a function.
DrawLine( x1,y1, x2,y2 ). You can then create cool algorithms like a DDA
Assembly Syntax (Toggle Plain Text)
dx = |x2-x1| dy=|y2-y1| if (dx < dy) // step dy else // step dx
If you track last x,y then you can also have a
DrawLineTo( x2, y2 )
Last edited by wildgoose; Sep 8th, 2009 at 2:39 pm.
Similar Threads
- Draw shapes in C++ (C++)
- Draw lines on panel (Java)
- Java Applet: draw graphics based on java.awt.choice (Java)
- Java Paint Program Question (Java)
- MY paint application (Java)
- Skinning C# Windows Applications (C#)
- help me please (C++)
- creating a ellispse at any aspect angle (C)
| Thread Tools | Search this Thread |
3d applet array asm assembler assembly boot bootloader c/c++ cart char class clear compiler compression convergence debug design development division draw embedding event file game graph int10h integer iptv java kernel language lines print program remainder rpg scale shape shopping string television text web wxwidgets x86




