Drawing basic line
This commit is contained in:
parent
24e67d34da
commit
835123f94a
|
@ -63,7 +63,6 @@ pushbyte(Uint8 b, int lit)
|
|||
void
|
||||
pushshort(Uint16 s, int lit)
|
||||
{
|
||||
printf("%04x[%d]\n", s, lit);
|
||||
if(lit) {
|
||||
pushbyte(0x03, 0);
|
||||
pushbyte(0x02, 0);
|
||||
|
|
|
@ -4,20 +4,24 @@
|
|||
:dev/w fff9 ( std write port )
|
||||
|
||||
;x_ 2 ;y_ 2 ;x0 2 ;y0 2 ;x1 2 ;y1 2 ;color 1
|
||||
|
||||
;dx 2 ;dy 2 ;err 2 ;err2 2
|
||||
|
||||
|0100 @RESET
|
||||
|
||||
( set dev/write to screen )
|
||||
,01 ,dev/w STR
|
||||
|
||||
,01 ,color STR
|
||||
+0030 ,x0 STR^ +0040 ,y0 STR^
|
||||
+0050 ,x1 STR^ +0060 ,y1 STR^
|
||||
|
||||
( init positions )
|
||||
,0020 ,x0 STR^ ,0018 ,y0 STR^
|
||||
,0060 ,x1 STR^ ,0048 ,y1 STR^
|
||||
,x0 LDR^ ,x_ STR^ ,y0 LDR^ ,y_ STR^
|
||||
,line JSR
|
||||
|
||||
,02 ,color STR
|
||||
+0020 ,x0 STR^ +0010 ,y0 STR^
|
||||
+0060 ,x1 STR^ +0070 ,y1 STR^
|
||||
|
||||
,line JSR
|
||||
|
||||
( draw control points )
|
||||
,02 ,color STR
|
||||
|
@ -28,6 +32,25 @@
|
|||
|
||||
BRK
|
||||
|
||||
@line
|
||||
,x0 LDR^ ,x_ STR^ ,y0 LDR^ ,y_ STR^ ( start at x0,y0 )
|
||||
,x1 LDR^ ,x0 LDR^ ,diff16sub JSR ,dx STR^ ( int dx = abs[x1 - x0] )
|
||||
,y1 LDR^ ,y0 LDR^ ,diff16sub JSR -0001 MUL!^ ,dy STR^ ( int dy = -abs[y1 - y0] )
|
||||
,dx LDR^ ,dy LDR^ ADD!^ ,err STR^ ( int err = dx + dy, e2; )
|
||||
@loop
|
||||
,x_ LDR^ ,y_ LDR^ ,putpixel JSR ( draw )
|
||||
,err LDR^ +0002 MUL!^ ,err2 STR^ ( e2 = 2 * err; )
|
||||
,err2 LDR^ ,dy LDR^ LTH!^ ,continue1 ROT JMP? POP^ ( e2 >= dy )
|
||||
,err LDR^ ,dy LDR^ ADD!^ ,err STR^ ( err += dy; )
|
||||
,x_ LDR^ +0001 ADD!^ ,x_ STR^ ( y0 += y0 < y1 ? 1 : -1; )
|
||||
@continue1
|
||||
,err2 LDR^ ,dx LDR^ GTH!^ ,continue2 ROT JMP? POP^ ( e2 <= dx )
|
||||
,err LDR^ ,dx LDR^ ADD!^ ,err STR^ ( err += dx; )
|
||||
,y_ LDR^ +0001 ADD!^ ,y_ STR^ ( y0 += y0 < y1 ? 1 : -1; )
|
||||
@continue2
|
||||
,x_ LDR^ ,x1 LDR^ LTH!^ ,loop ROT JMP? POP^ ( loop )
|
||||
RTS
|
||||
|
||||
@redraw
|
||||
,0000 IOW^
|
||||
,0000 IOW^
|
||||
|
|
Loading…
Reference in New Issue