Advertisement
ZodiacMentor

KAPE 8bit top-down fade-to-black

Dec 23rd, 2021
1,523
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fadeToBlack:
  2.     lda #0
  3.     sta .currentRow
  4.     lda #$B0
  5.     sta .currentSprite
  6.  
  7.     jmp .entry
  8. .currentRow:
  9.     .byte 0
  10. .currentSprite:
  11.     .byte 0
  12.  
  13. .setSpritesRow:
  14.     ldx #0
  15.     lda .currentRow
  16.     asl A
  17.     asl A
  18.     asl A
  19.     tay
  20.  
  21. .setSpritesRowLoop:
  22.     lda #CF_CMD_SET_SPRITE_Y
  23.     sta GPU_CMDQ_ADDRESS
  24.     txa
  25.     sta GPU_CMDQ_ADDRESS
  26.     tya
  27.     sta GPU_CMDQ_ADDRESS
  28.  
  29.     inx
  30.     cpx #32
  31.     bne .setSpritesRowLoop
  32.  
  33.     rts
  34.  
  35. .setTileRow:
  36.     ldx #0
  37.     ldy .currentRow
  38.  
  39. .setTileRowLoop:
  40.     lda #CF_CMD_SET_INDEX
  41.     sta GPU_CMDQ_ADDRESS
  42.     txa
  43.     sta GPU_CMDQ_ADDRESS
  44.     tya
  45.     sta GPU_CMDQ_ADDRESS
  46.     lda #$ff
  47.     sta GPU_CMDQ_ADDRESS
  48.  
  49.     inx
  50.     cpx #32
  51.     bne .setTileRowLoop
  52.  
  53.     rts
  54.  
  55. .setSpritesIndex:
  56.     ldx #0
  57.    
  58. .setSpritesIndexLoop:
  59.     lda #CF_CMD_SET_SPRITE_INDEX
  60.     sta GPU_CMDQ_ADDRESS
  61.     txa
  62.     sta GPU_CMDQ_ADDRESS
  63.     lda .currentSprite
  64.     sta GPU_CMDQ_ADDRESS
  65.  
  66.     inx
  67.     cpx #32
  68.     bne .setSpritesIndexLoop
  69.  
  70.     rts
  71.  
  72. .setupSprites:
  73.     jsr .setSpritesIndex
  74.     ldx #0
  75.    
  76. .setupSpritesLoop:
  77.     lda #CF_CMD_SET_SPRITE_ALPHA_COLOR
  78.     sta GPU_CMDQ_ADDRESS
  79.     txa
  80.     sta GPU_CMDQ_ADDRESS
  81.     lda #$0d
  82.     sta GPU_CMDQ_ADDRESS
  83.  
  84.     lda #CF_CMD_SET_SPRITE_X
  85.     sta GPU_CMDQ_ADDRESS
  86.     txa
  87.     sta GPU_CMDQ_ADDRESS
  88.     asl A
  89.     asl A
  90.     asl A
  91.     sta GPU_CMDQ_ADDRESS
  92.  
  93.     lda #CF_CMD_SET_SPRITE_ACTIVE
  94.     sta GPU_CMDQ_ADDRESS
  95.     txa
  96.     sta GPU_CMDQ_ADDRESS
  97.  
  98.     inx
  99.     cpx #32
  100.     bne .setupSpritesLoop
  101.  
  102.     rts
  103.  
  104. .deactivateSprites:
  105.     ldx #0
  106.    
  107. .deactivateSpritesLoop:
  108.     lda #CF_CMD_SET_SPRITE_NOT_ACTIVE
  109.     sta GPU_CMDQ_ADDRESS
  110.     txa
  111.     sta GPU_CMDQ_ADDRESS
  112.  
  113.     inx
  114.     cpx #32
  115.     bne .deactivateSpritesLoop
  116.     rts
  117.  
  118. .entry
  119.     jsr .setupSprites
  120.    
  121. .rowLoop:
  122.     jsr .setSpritesRow
  123.  
  124. .spriteLoop:    
  125.     jsr .setSpritesIndex
  126.  
  127.     lda #2
  128.     jsr ROM_WaitFrames
  129.     inc .currentSprite
  130.     lda .currentSprite
  131.     cmp #$B4
  132.     bne .spriteLoop
  133.  
  134.     lda #$B0
  135.     sta .currentSprite
  136.     jsr .setTileRow
  137.  
  138.     jsr .setSpritesIndex
  139.    
  140.     inc .currentRow
  141.     lda .currentRow
  142.     cmp #24
  143.     bne .rowLoop
  144.  
  145.     jsr .deactivateSprites
  146.    
  147.     rts
Advertisement
RAW Paste Data Copied
Advertisement