Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- InitSpriteRAM:
- lea SpriteRAM,a2
- move.w #255,d0
- InitSpriteRAM_:
- move.w #0,(a2)+
- dbra d0,InitSpriteRAM_
- ; now add in the player so you can do stuff
- move.w #1, SpriteRAM ; type
- move.w #240, SpriteRAM+2 ; X
- move.w #240, SpriteRAM+4 ; Y
- rts
- FindFreeSpriteSlot:
- moveq #SpriteRAMLast, d0
- move.w #SpriteRAMLast*16, d1
- move.l #SpriteRAM,a3
- FindFreeSpriteSlot_Loop:
- tst.w 0(a3,d1)
- beq FindFreeSpriteSlot_Exit
- sub.w #16,d1
- subq.w #1,d0
- tst.w d0 ; might be able to take out?
- beq FindFreeSpriteSlot_Loop
- FindFreeSpriteSlot_Exit:
- rts
- ; ---------------------------------------------------------------
- RunAllSprites:
- move.w #31, CurSpriteRAM1
- RunAllSprites_Loop:
- moveq #0,d0 ; clear out all of d0
- move d0,d1 ; clear out all of d1
- move.w CurSpriteRAM1, d0 ; load it with the sprite number
- lsl #4, d0 ; multiply by 16 to get offset into SpriteRAM
- move.l #SpriteRAM, a0 ; start with SpriteRAM base
- adda d0, a0 ; add offset
- move.w (a0), d1 ; fetch the sprite flags
- and #%111111111, d1 ; trim off sprite number
- beq RunAllSprites_Skip
- move.l CurSpriteOAM, a1 ; preload a1 with the OAM pointer so the sprite can use it
- lsl #3, d1 ; multiply by 8 to get offset into SpriteROM
- move.l #SpriteROM, a2 ; start with SpriteROM base
- adda d1, a2 ; add offset
- move.l (a2), a3 ; get routine address
- jsr (a3) ; a0 = SpriteRAM entry, a1 = OAM pointer, a2 = SpriteROM entry
- RunAllSprites_Skip:
- move.w CurSpriteRAM1, d0
- tst d0 ; are we on the last sprite?
- beq RunAllSprites_Exit
- subq #1, d0
- move.w d0, CurSpriteRAM1
- bra RunAllSprites_Loop
- RunAllSprites_Exit:
- rts
- ; ---------------------------------------------------------------
- RunSprEmpty:
- rts
- NovaGfxStart equ 128 ; tail is 4, walk1 is 6, walk2 is 8
- RunSprPlayer:
- ;------------------------------
- move.w KeyDown, d3
- move.w PlayerX,d1
- move.w PlayerY,d2
- lsr.w #1,d3
- bcc NotPressedUp
- subq #2,d2
- NotPressedUp:
- lsr.w #1,d3
- bcc NotPressedDown
- addq #2,d2
- NotPressedDown:
- lsr.w #1,d3
- bcc NotPressedLeft
- subq #2,d1
- andi #~SPR_FACING_RIGHT, PlayerFlags
- NotPressedLeft:
- lsr.w #1,d3
- bcc NotPressedRight
- addq #2,d1
- ori #SPR_FACING_RIGHT, PlayerFlags
- NotPressedRight:
- move.w d1,PlayerX
- move.w d2,PlayerY
- ;-----------------------------
- move.w #0, d1 ;attribute OR mask
- move.w PlayerFlags, d0
- andi #SPR_FACING_RIGHT, d0
- beq PlayerNotFacingRight
- move.w #OAM_XFLIP, d1
- PlayerNotFacingRight:
- move.w #NovaGfxStart+6, d2
- move.w KeyDown, d0
- andi #BUTTON_LEFT|BUTTON_RIGHT,d0
- beq PlayerNotMovingSide
- move.w retraces,d0
- andi #8,d0
- beq PlayerNotMovingSide
- move.w #NovaGfxStart+8, d2
- PlayerNotMovingSide:
- ;torso and head
- move.w PlayerY,(a1) ; Y position
- move.b #$05,2(a1) ; 2x2
- move.w #NovaGfxStart,4(a1)
- or d1,4(a1)
- move.w PlayerX,6(a1) ; X position
- addq #8, a1
- ;legs
- move.w PlayerY,(a1) ; Y position
- add #16,(a1)
- move.b #$04,2(a1) ; 2x1
- move.w d2,4(a1)
- or d1,4(a1)
- move.w PlayerX,6(a1) ; X position
- addq #8, a1
- ;tail
- move.w PlayerY,(a1) ; Y position
- add #6,(a1)
- move.b #$01,2(a1) ; 1x2
- move.w #NovaGfxStart+4,4(a1)
- or d1,4(a1)
- move.w PlayerX,6(a1) ; X position
- subq #4,6(a1)
- move.w PlayerFlags, d0
- andi #SPR_FACING_RIGHT, d0
- bne DontMoveTailRight
- add #16,6(a1)
- DontMoveTailRight:
- addq #8, a1
- move.l a1, CurSpriteOAM
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement