SforzandoCF

snes apu code

Dec 15th, 2025 (edited)
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. #define _A_SONG0 $6000
  2. #define _A_SONG1 $7000
  3.  
  4. #define _A_SAMPLE0 $8000
  5. #define _A_SAMPLE1 $9000
  6. #define _A_SAMPLE2 $A000
  7. #define _A_SAMPLE3 $B000
  8. #define _A_SAMPLE4 $C000
  9. #define _A_SAMPLE5 $D000
  10. #define _A_SAMPLE6 $E000
  11. #define _A_SAMPLE7 $F000
  12.  
  13. #define _A_PITCH_TABLE $0300
  14.  
  15. .org $0000
  16. .dw 1024
  17. .dw 1085
  18. .dw 1149
  19. .dw 1218
  20. .dw 1290
  21. .dw 1367
  22. .dw 1448
  23. .dw 1534
  24. .dw 1625
  25. .dw 1722
  26. .dw 1825
  27. .dw 1933
  28. .dw 2048
  29. .dw 2170
  30. .dw 2299
  31. .dw 2435
  32. .dw 2580
  33. .dw 2734
  34. .dw 2896
  35. .dw 3069
  36. .dw 3251
  37. .dw 3444
  38. .dw 3649
  39. .dw 3866
  40. .dw 4096
  41. .dw 4340
  42. .dw 4598
  43. .dw 4871
  44. .dw 5160
  45. .dw 5467
  46. .dw 5793
  47. .dw 6137
  48. .dw 6507
  49. .dw 6889
  50. .dw 7298
  51. .dw 7732
  52. .dw 8192
  53. .dw 8679
  54. .dw 9195
  55. .dw 9742
  56. .dw 10321
  57. .dw 10935
  58. .dw 11585
  59. .dw 12274
  60. .dw 13003
  61. .dw 13777
  62. .dw 14596
  63. .dw 15464
  64. .dw 16383
  65.  
  66. main:
  67. mov y, #$00
  68. mov CONTROL, y
  69. mov a, #$0C
  70. movw DSPADDR, ya
  71. mov a, #$1C
  72. movw DSPADDR, ya
  73. mov a, #$2C
  74. movw DSPADDR, ya
  75. mov a, #$3C
  76. movw DSPADDR, ya
  77. mov a, #$3C
  78. movw DSPADDR, ya
  79. mov a, #$2D
  80. movw DSPADDR, ya
  81. mov a, #$3D
  82. movw DSPADDR, ya
  83. mov a, #$4D
  84. movw DSPADDR, ya
  85. mov a, #$6C
  86. mov y, #$20
  87. movw DSPADDR, ya
  88. mov a, #$5D
  89. mov y, #$02
  90. movw DSPADDR, ya
  91. mov a, #$00
  92. mov y, #$03
  93. movw $00, ya
  94. main_loop:
  95. mov a, CPUIO0
  96. or a, CPUIO1
  97. beq main_loop
  98. mov a, CPUIO1
  99. bne push_song
  100. mov a, CPUIO0
  101. bra handle_command
  102. bra main_loop
  103. push_song:
  104. mov a, $80
  105. call !push_song0_channel
  106. mov a, $90
  107. call !push_song0_channel
  108. mov a, $A0
  109. call !push_song0_channel
  110. mov a, $B0
  111. call !push_song0_channel
  112. mov a, $C0
  113. call !push_song1_channel
  114. mov a, $D0
  115. call !push_song1_channel
  116. mov a, $E0
  117. call !push_song1_channel
  118. mov a, $F0
  119. call !push_song1_channel
  120. jmp !main_loop
  121. handle_command:
  122. mov a, CPUIO0
  123. and a, #$E0
  124. cmp a, #$20
  125. beq handle_load_sample_command
  126. cmp a, #$40
  127. beq handle_load_song_command
  128. cmp a, #$60
  129. beq handle_play_song_command
  130. mov a, CPUIO0
  131. cmp a, #$01
  132. beq kill_command
  133. jmp !main_loop
  134. kill_command
  135. stop
  136. handle_load_sample_command:
  137. mov a, CPUIO0
  138. and a, #$07
  139. call !load_sample
  140. jmp !main_loop
  141. handle_load_song_command:
  142. mov a, CPUIO0
  143. and #$01
  144. call !load_song
  145. jmp !main_loop
  146. handle_play_song_command:
  147. mov a, CPUIO0
  148. and a, #$02
  149. beq handle_play_song_command0
  150. mov a
  151. jmp !main_loop
Advertisement
Add Comment
Please, Sign In to add comment