A89: Need help with buggy code
[Prev][Next][Index][Thread]
A89: Need help with buggy code
Attached is my latest attempt at a game. What I am trying to do right now is
create a routine to read a level map. My level map looks something like this:
level1:
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0,1,0,1,0,1,0,1,0,1,0,1,0,0
dc.......
.......
If there is a 1, my program "should" draw a block on the screen according to
where the 1 is in the map. My problem is that I suck at programming and
can't figure out what is wrong with my code. Whenever I run it (in VTI68k),
it displays a few blocks in seemingly random locations and even displays part
of the TI-89's graphing screen. If anyone can take a look at my code and
find what's wrong (besides sloppy coding), I would appreciate it a lot.
Thanks guys.
include "tios.h"
include "util.h"
include "graphlib.h"
xdef _main
xdef _comment
xdef _ti89
;***********************************MAIN
_main:
ini_vars:
move.l #0,currentlvl
bsr ini_level
prog_loop:
jsr util::idle_loop
rts
;***********************************INITIALIZE EACH LEVEL
ini_level:
jsr graphlib::clr_scr
move.l #level1,a0
move.l currentlvl,d0
mulu.w #126,d0
add.l d0,a0
move.l a0,levelptr
move.w #0,var1
ini_level_loop1:
move.w #0,var2
ini_level_loop2:
move.l #levelptr,a0
move.w var1,d1
move.w var2,d0
move.w #14,d2
bsr look_up
cmp.b #1,d0
bne no_block
move.w var1,d1
move.w var2,d0
mulu.w #8,d1
mulu.w #8,d0
move.l #sprite_block,a0
jsr graphlib::put_sprite
no_block:
add.w #1,var1
cmp.w #9,var1
bne ini_level_loop2
add.w #1,var2
cmp.w #14,var2
bne ini_level_loop1
rts
look_up: ;d0=column
add.w d0,a0 ;d1=row
mulu.w d2,d1 ;d2=row width
add.w d1,a0 ;a0=pointer
move.b (a0),d0
rts
level1:
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0,1,0,1,0,1,0,1,0,1,0,1,0,0
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0,1,0,1,0,1,0,1,0,1,0,1,0,0
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0,1,0,1,0,1,0,1,0,1,0,1,0,0
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.b 0,1,0,1,0,1,0,1,0,1,0,1,0,0
dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0
sprite_block:
dc.w 8
dc.w 1
dc.b %01111110
dc.b %10000001
dc.b %10111001
dc.b %10100001
dc.b %10100001
dc.b %10000001
dc.b %10000001
dc.b %01111110
mask_block:
dc.b %11111111
dc.b %11111111
dc.b %11111111
dc.b %11111111
dc.b %11111111
dc.b %11111111
dc.b %11111111
dc.b %11111111
currentlvl dc.l 0
levelptr dc.l 0
var1 dc.w 0
var2 dc.w 0
_comment dc.b "bricks",0
end