Advertisement
NovaYoshi

genesis game sprites source

Dec 23rd, 2013
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. InitSpriteRAM:
  2.     lea SpriteRAM,a2
  3.     move.w  #255,d0
  4. InitSpriteRAM_:
  5.     move.w  #0,(a2)+
  6.     dbra    d0,InitSpriteRAM_
  7. ; now add in the player so you can do stuff
  8.     move.w  #1, SpriteRAM     ; type
  9.     move.w  #240, SpriteRAM+2 ; X
  10.     move.w  #240, SpriteRAM+4 ; Y
  11.     rts
  12.  
  13. FindFreeSpriteSlot:
  14.     moveq   #SpriteRAMLast, d0
  15.     move.w  #SpriteRAMLast*16, d1
  16.     move.l  #SpriteRAM,a3
  17. FindFreeSpriteSlot_Loop:
  18.     tst.w   0(a3,d1)
  19.     beq FindFreeSpriteSlot_Exit
  20.     sub.w   #16,d1
  21.     subq.w  #1,d0
  22.     tst.w   d0          ; might be able to take out?
  23.     beq FindFreeSpriteSlot_Loop
  24. FindFreeSpriteSlot_Exit:
  25.     rts
  26.  
  27. ; ---------------------------------------------------------------
  28.  
  29. RunAllSprites:
  30.     move.w  #31, CurSpriteRAM1
  31. RunAllSprites_Loop:
  32.     moveq   #0,d0               ; clear out all of d0
  33.     move    d0,d1               ; clear out all of d1
  34.     move.w  CurSpriteRAM1, d0   ; load it with the sprite number
  35.     lsl #4, d0                  ; multiply by 16 to get offset into SpriteRAM
  36.  
  37.     move.l  #SpriteRAM, a0      ; start with SpriteRAM base
  38.     adda    d0, a0              ; add offset
  39.     move.w  (a0), d1            ; fetch the sprite flags
  40.     and #%111111111, d1         ; trim off sprite number
  41.     beq RunAllSprites_Skip
  42.  
  43.     move.l  CurSpriteOAM, a1    ; preload a1 with the OAM pointer so the sprite can use it
  44.  
  45.     lsl #3, d1                  ; multiply by 8 to get offset into SpriteROM
  46.  
  47.     move.l  #SpriteROM, a2      ; start with SpriteROM base
  48.     adda    d1, a2              ; add offset
  49.     move.l (a2), a3             ; get routine address
  50.     jsr (a3)                    ; a0 = SpriteRAM entry, a1 = OAM pointer, a2 = SpriteROM entry
  51.  
  52. RunAllSprites_Skip:
  53.     move.w  CurSpriteRAM1, d0
  54.     tst d0                      ; are we on the last sprite?
  55.     beq RunAllSprites_Exit
  56.     subq #1, d0
  57.     move.w  d0, CurSpriteRAM1
  58.     bra RunAllSprites_Loop
  59. RunAllSprites_Exit:
  60.     rts
  61.  
  62. ; ---------------------------------------------------------------
  63.  
  64. RunSprEmpty:
  65.     rts
  66.  
  67. NovaGfxStart equ 128 ; tail is 4, walk1 is 6, walk2 is 8
  68. RunSprPlayer:
  69. ;------------------------------
  70.     move.w  KeyDown, d3
  71.     move.w  PlayerX,d1
  72.     move.w  PlayerY,d2
  73.     lsr.w   #1,d3
  74.     bcc NotPressedUp
  75.     subq    #2,d2
  76. NotPressedUp:
  77.  
  78.     lsr.w   #1,d3
  79.     bcc NotPressedDown
  80.     addq    #2,d2
  81. NotPressedDown:
  82.  
  83.     lsr.w   #1,d3
  84.     bcc NotPressedLeft
  85.     subq    #2,d1
  86.     andi    #~SPR_FACING_RIGHT, PlayerFlags
  87. NotPressedLeft:
  88.  
  89.     lsr.w   #1,d3
  90.     bcc NotPressedRight
  91.     addq    #2,d1
  92.     ori     #SPR_FACING_RIGHT, PlayerFlags
  93. NotPressedRight:
  94.  
  95.     move.w  d1,PlayerX
  96.     move.w  d2,PlayerY
  97. ;-----------------------------
  98.  
  99.     move.w #0, d1 ;attribute OR mask
  100.  
  101.     move.w PlayerFlags, d0
  102.     andi #SPR_FACING_RIGHT, d0
  103.     beq PlayerNotFacingRight
  104.     move.w #OAM_XFLIP, d1
  105. PlayerNotFacingRight:
  106.  
  107.     move.w  #NovaGfxStart+6, d2
  108.     move.w  KeyDown, d0
  109.     andi    #BUTTON_LEFT|BUTTON_RIGHT,d0
  110.     beq PlayerNotMovingSide
  111.     move.w  retraces,d0
  112.     andi    #8,d0
  113.     beq PlayerNotMovingSide
  114.     move.w  #NovaGfxStart+8, d2
  115. PlayerNotMovingSide:
  116.  
  117.     ;torso and head
  118.     move.w  PlayerY,(a1)    ; Y position
  119.     move.b  #$05,2(a1)      ; 2x2
  120.     move.w  #NovaGfxStart,4(a1)
  121.     or      d1,4(a1)
  122.     move.w  PlayerX,6(a1)   ; X position
  123.     addq    #8, a1
  124.  
  125.     ;legs
  126.     move.w  PlayerY,(a1)    ; Y position
  127.     add     #16,(a1)
  128.     move.b  #$04,2(a1)      ; 2x1
  129.     move.w  d2,4(a1)
  130.     or      d1,4(a1)
  131.     move.w  PlayerX,6(a1)   ; X position
  132.     addq    #8, a1
  133.  
  134.     ;tail
  135.     move.w  PlayerY,(a1)    ; Y position
  136.     add     #6,(a1)
  137.     move.b  #$01,2(a1)      ; 1x2
  138.     move.w  #NovaGfxStart+4,4(a1)
  139.     or      d1,4(a1)
  140.     move.w  PlayerX,6(a1)   ; X position
  141.     subq    #4,6(a1)
  142.     move.w  PlayerFlags, d0
  143.     andi    #SPR_FACING_RIGHT, d0
  144.     bne     DontMoveTailRight
  145.     add     #16,6(a1)
  146. DontMoveTailRight:
  147.     addq    #8, a1
  148.  
  149.     move.l  a1, CurSpriteOAM
  150.     rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement