A89: Simple Grid-based Putsprite Routine


[Prev][Next][Index][Thread]

A89: Simple Grid-based Putsprite Routine




Just so that I know what the heck I'm doing, I'm making a simple putsprite
routine that puts a sprite on an 8x8 grid. It's all good and dandy, except for
the part where it actually puts the sprite... (go figure). So... what's wrong
with this picture?

 include "tios.h"
 include "util.h"
 xdef _main
 xdef _comment
 xdef _ti89

_main:
 jsr util::zap_screen
 move.l #Sprite1,a0
 move.l #0,d0         ;set the sprite to display in grid area 0,0
 move.l #0,d1         ;(top-left area of screen)
 bsr _putsprite
 jsr util::idle_loop
 rts

_putsprite:
 move.l LCD_MEM,a1
 add.l d0,a1           ;add the grid column to LCD_MEM
 mulu.l #60,d1         ;Multiply the grid row by 60 to get byte count
 add.l d1,a1           ;add bytes to a1
 move.b (a0),(a1)      ;These 8 lines cause the problems. I believe
 move.b 1(a0),30(a1)   ;that this is because it's doing stuff with
 move.b 2(a0),60(a1)   ;odd addresses... how would I fix that?
 move.b 3(a0),90(a1)
 move.b 4(a0),120(a1)
 move.b 5(a0),150(a1)
 move.b 6(a0),180(a1)
 move.b 7(a0),210(a1)
 rts

_comment: dc.b "Mogsoft PutSprite Experiment",0
Sprite1:          ;if you can't see the sprite, it's a happyface. :)
 dc.b %00111100
 dc.b %01000010
 dc.b %10100101
 dc.b %10000001
 dc.b %10100101
 dc.b %10011001
 dc.b %01000010
 dc.b %00111100

 END

What this is SUPPOSED to do is put a sprite at GRID COORDINATES d0 and d1.
This means that if both of those registers were 1, the sprite's upper-left
corner would at the 9th pixel down and the 9th pixel across. The main point
is, tho... how do I get the part that copies the sprite to the screen to stop
giving me ADRESS ERRORs and MEMORY VIOLATION errors? (Thank goodness for Crash
Protection...)


Follow-Ups: