Advertisement
Guest User

Zelda 2 Redux - Play FDS or NES Battle Themes at Random

a guest
Oct 28th, 2020
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //***********************************************************
  2. //   Random FDS Battle Theme in East Hyrule (by IcePenguin)
  3. //***********************************************************
  4.  
  5. // Make the FDS Battle Theme to play randomly alongside the original NES Battle Theme
  6.  
  7. bank 0;
  8. org $85F0   // 0x00600
  9.     jsr $A8F0   // Hijack
  10.  
  11. org $A8F0   // 0x02900
  12.     inc.w $0726 // Original hijacked code
  13.     lda.b $12   // Load Frame Counter address
  14.     sta.b $F2   // Store Frame value in specific address when entering battle
  15.     rts
  16.  
  17. org $A8D0   // 0x028E0
  18.     ldx.b $F2   // Load stored random value from Frame counter
  19.     cpx.b #$80  // Compare against $80 from RAM $F2
  20.     bmi l_A8DA  // Branch if it's less than $80
  21.     sta.w $075F // If not, then store normal NES Battle Theme at Music to Play RAM address
  22.     rts
  23. l_A8DA:
  24.     lda.b #$08  // Load FDS Battle Theme ($08)
  25.     sta.w $075F // Store song at $075F (Music to play?)
  26.     rts
  27.     db $FF      // Leftover
  28.  
  29. bank 6;
  30. org $9DC0   // 0x19DD0
  31.     lda.b $F2   // Load stored random value from Frame counter
  32.     cmp.b #$80  // Compare against $80 from RAM $F2
  33.     bmi l_9DCB  // Branch if it's less than $80
  34.     lda.b #$04  // Load NES Battle Theme ($04)
  35.     sta.b $EB   // Store song at $EB (Music)
  36.     rts
  37. l_9DCB:
  38.     lda.b #$08  // Load FDS Battle Theme ($08)
  39.     sta.b $EB   // Store song at $EB (Music)
  40.     lda.b #$00  // Load value $00
  41.     sta.w $0702 // Store at unknown RAM address
  42.     rts
  43.     db $FF      // Leftover
  44.  
  45. bank 7;
  46. org $FEB4   // 0x1FEC4
  47.     lda.b $F2   // Load stored random value from Frame counter
  48.     cmp.b #$80  // Compare against $80 from RAM $F2
  49.     bmi l_FEC0  // Branch if it's less than $80
  50.     lda.b #$04  // Load NES Battle Theme ($04)
  51.     sta.w $075F // Store song at $075F (Music to play?)
  52.     rts
  53. l_FEC0:
  54.     lda.b #$08  // Load FDS Battle Theme ($08)
  55.     sta.w $075F // Store song at $075F (Music to play?)
  56.     lda.b #$00  // Load value $00
  57.     sta.w $0702 // Store at unknown RAM address
  58.     rts
  59.  
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement