A89: Can anyone help? (ON topic =)
[Prev][Next][Index][Thread]
A89: Can anyone help? (ON topic =)
I'm having a problem with my program. It's supposed to draw something on
the screen that resembles a cube, but some of the corners get messed up for
some reason. Can anyone find the problem?
Thanks
-John
include "doorsos.h"
include "graphlib.h"
include "userlib.h"
xdef _main
xdef _ti89
_main:
jsr graphlib::clr_scr ;clears the screen
lea obj_test_cube_xy_coords(pc),a6 ;get the location of the point
coordinate table
lea obj_test_cube_lines(pc),a5 ;get the location of the line table
move.l #12,d7 ;number of lines in the line table
bsr draw_object_to_screen_start
jsr userlib::idle_loop ;wait for keypress
rts ;back to os or shell
;input: a6=xy coord table location, a5=line table location, d7=number of
lines,
draw_object_to_screen_start
move.l a6,a4 ;save location of coordinate table
draw_object_to_screen
clr.l d0 ;get rid of garbage in registers
clr.l d1
clr.l d2
clr.l d3
clr.l d4
clr.l d5
clr.l d6
move.b (a5)+,d4 ;get first endpoint of the line, point to next line
move.b (a5)+,d5 ;get the second endpoint of the line, point to next
line
muls.w #3,d4 ;number of bytes in each entry of point table
add.l a4,d4 ;add the start of the table
move.l d4,a6 ;put it in an address register
move.b (a6)+,d0 ;get x1 of the line, point to next byte
move.b (a6)+,d1 ;get y1 of the line, point to next byte
move.b (a6)+,d6 ;byte to check if line can be drawn, piont to next
byte
cmpi.b #0,d6 ;make sure that the line can be drawn
bgt draw_object_to_screen_skip_line ;if not, skip line draw
muls.w #3,d5 ;number of bytes per entry in point table
add.l a4,d5 ;add the start of table
move.l d5,a6 ;put it in address register
move.b (a6)+,d2 ;get x2 of the line, point to next byte
move.b (a6)+,d3 ;get y2 of the line, point to next byte
move.b (a6)+,d6 ;byte to check to see if line can be drawn
cmpi.b #0,d6 ;make sure that the line can be drawn
bgt draw_object_to_screen_skip_line ;if not, skip line draw
move.l #$4C00,A0 ;screen location
jsr graphlib::line ;draw line
draw_object_to_screen_skip_line
subq #1,d7 ;decrement d7
cmpi.b #0,d7 ;see if we're done drawing lines
bgt draw_object_to_screen ;if not, start again
rts ;otherwise we're done
;object data
obj_test_cube_lines:
dc.b 1,2 ;pt1 connects to pt 2
dc.b 2,3
dc.b 3,4
dc.b 4,1
dc.b 5,6
dc.b 6,7
dc.b 7,8
dc.b 8,5
dc.b 1,5
dc.b 2,6
dc.b 3,7
dc.b 4,8
obj_test_cube_xy_coords: ;screen x,y coords, last num- 0 off screen, 1 on
screen
dc.b 96,34,0
dc.b 64,34,0
dc.b 69,39,0
dc.b 91,39,0
dc.b 96,66,0
dc.b 64,66,0
dc.b 69,61,0
dc.b 91,61,0
end
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com