Code: Select all
MOVECURSORY:
;d0 how many pixels to move (8 pixels for one row) = 0x08
;d1 sprite ID, = 0x00
;d2 sprite 2 ID, = 0x01
;d3 0x00 for up, 0x01 for down
mulu.w #0x8, d1
swap d1 ;d1 0x00000000
mulu.w #0x8, d2
swap d2 ;d2 0x00080000
add.l #VDPWRITESPRITE, d1 ;0x60000003
add.l #VDPWRITESPRITE, d2 ;0x60080003
move.l d1, CURSORATTRIBUTERAM ;This is for the VDP control port during vblank
move.l d2, CURSORATTRIBUTERAM2 ;This is for the VDP control port during vblank
move.l #0x00FFFFB2, a2 ;Ready ram address for y position
move.w (a2), d4 ; move old y value to d4
cmp.b #0x01, d3
bne @SUBTRACTY
add.w d0, d4 ;add old y value and 8 pixels to get new y value
move.w d4, 0x00FFFFB2
move.w d4, CURSORPOSITIONRAM ;This is for VDP Data port
jmp @END
@SUBTRACTY:
sub.w d0, d4 ;sub old y value and 8 pixels to get new y value
move.w d4, 0x00FFFFB2
move.w d4, CURSORPOSITIONRAM ;This is for VDP Data port
@END:
rts
EDIT: Yeah using jsr to jump back into the main loop is bad news here. Eventually, my ram is filled with junk stack data from the jsr being used too much and this results in the rom crashing. I was hoping to keep my y positioning all in one subroutine without having to separate it out. Is there any way this can be achieved, am I missing something important?
EDIT:
Code: Select all
cmp.b #0x01, d3
bne SUBTRACTY
cmp.b #0x01, d3
beq ADDY
rts
ADDY:
add.w d0, d4 ;add old y value and 8 pixels to get new y value
move.w d4, 0x00FFFFB2
move.w d4, CURSORPOSITIONRAM ;This is for VDP Data port
rts
SUBTRACTY:
sub.w d0, d4 ;add old y value and 8 pixels to get new y value
move.w d4, 0x00FFFFB2
move.w d4, CURSORPOSITIONRAM ;This is for VDP Data port
rts