galaspark

KONAMI VRC6 NES ROM TEMPLATE NESASM3

Aug 29th, 2021 (edited)
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. KONAMI VRC6 NESASM3 TEMPLATE
  2.  
  3. ;THIS DOCUMENT IS VALID NESASM3 ASSEMBLY CODE AND SHOULD WORK AS LONG AS YOU FILL IN THE GAPS WITH YOUR OWN CODE!
  4.  
  5. .inesprg 4 ; 1x 16KB PRG code
  6. .ineschr 2 ; 2x 8KB CHR data
  7. .inesmap 24 ; Konami VRC6 Version 1 (Akumajou Densetsu)
  8. .inesmir 1 ; background mirroring (Vertical mirroring for Horizontal Scrolling)
  9. ;nesasm3 doesn't seem to support save battery functionality. If you know how to do this please tell me.
  10.  
  11.  
  12.  
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. ;PUT YOUR MACROS, ZERO PAGE DEFINITIONS, AND RAM DEFINITIONS HERE!
  16.  
  17. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  18. ; HOW BANKING WORKS ON THE VRC6
  19.  
  20. ; THE VRC6 HAS A 16K SWITCHABLE SECTION AND AN 8K SWITCHABLE SECTION. ALL PRG-ROM BANKS ON THE VRC6 ARE 8K.
  21. ; MAKE SURE YOU UNDERSTAND THIS, SINCE IT'S NOT WRITTEN DOWN ANYWHERE ON THE NESDEV WIKI!
  22. ; IF A BANK IS LOADED INTO THE 16K SECTION, IT IS LOADED INTO THE FIRST 8K OF THAT SECTION, AND THE BANK AFTER THAT IS LOADED INTO
  23. ; THE SECOND 8K OF THAT SECTION.
  24.  
  25. ; BANK NUMBERS GO UP, WITH STARTING LOCATIONS OF $8000, $A000, $C000, AND BACK TO $8000 AGAIN.
  26. ; EACH BANK CAN BE LOADED IN A 16K OR 8K SECTION DURING RUNTIME BY WRITING THE DESIRED BANK NUMBER TO $8000 FOR THE 16K SECTION
  27. ; OR TO $C000 FOR THE 8K SECTION.
  28.  
  29. ;EDIT: IT SEEMS THAT A BANK WITH .ORG $C000 IS THE ONLY TYPE OF BANK THAT CAN BE PROPERLY LOADED AT $C000. TESTING WITH BANKS THAT WEREN'T LISTED WITH .ORG $C000 SHOWED THAT THE BANKSWITCH WORKED BUT THE DATA COULDN'T BE READ PROPERLY.
  30.  
  31.  
  32. ;ANY NUMBER YOU SUPPLY TO THE VRC6 AS THE BANK NUMBER WHEN SWITCHING THE 16K SECTION GETS DOUBLED AUTOMATICALLY.
  33. ;THE 8K SECTION REGISTER, ON THE OTHER HAND, TAKES THE GIVEN VALUE AS-IS AND SWITCHES THE 8K SECTION TO THAT BANK.
  34.  
  35. ; 16KB BANK EXAMPLE:
  36. ; LDA #$02
  37. ; STA $8000
  38. ; THE CARTRIDGE WILL LOAD BANK 4 AT $8000 AND BANK 5 AT $A000.
  39.  
  40. ; 8KB BANK EXAMPLE:
  41. ; LDA #$02
  42. ; STA $C000
  43. ; THE CARTRIDGE WILL LOAD BANK 2 AT $C000.
  44.  
  45. ; THE FIXED BANK IS ALWAYS AT $E000. YOUR RESET CODE MUST BE IN THE FIXED BANK OR THE PROGRAM WILL NOT WORK PROPERLY.
  46. ; NMI AND IRQ SHOULD ALSO BE IN THE FIXED BANK SINCE YOU CAN'T RELIABLY PREDICT WHEN THEY WILL EXECUTE.
  47.  
  48.  
  49. ; THE .inesprg NUMBER MUST BE EVEN OR THE EMULATOR WILL REFUSE TO RUN THE GAME.
  50. ; A VALID VRC6 CARTRIDGE MUST HAVE PRG-ROM DATA IN EXACT MULTIPLES OF 16K.
  51. ; YOU CAN ACHIEVE THIS BY ENSURING THAT THE NESASM BANK NUMBER OF THE FIXED BANK IS CONGRUENT TO 3 MOD 4.
  52. ; IF THAT'S TOO CONFUSING, CONSULT THE FOLLOWING CHART:
  53.  
  54. ; .inesprg 2 = fixed bank is bank 3
  55. ; .inesprg 4 = fixed bank is bank 7
  56. ; etc.
  57.  
  58. ;BANK SWITCHING
  59.  
  60.  
  61. .bank 0
  62. .org $8000
  63. bank0start:
  64. ;YOUR CODE OR DATA GOES HERE
  65. bank0end:
  66. .ds 8192-(bank0end-bank0start) ;THIS IS USED TO CREATE THE CORRECT AMOUNT OF PADDING.
  67.  
  68. .bank 1
  69. .org $A000
  70. bank1start:
  71. ;YOUR CODE OR DATA GOES HERE
  72. bank1end:
  73. .ds 8192-(bank1end-bank1start)
  74.  
  75. .bank 2
  76. .org $C000
  77. bank2start:
  78. ;YOUR CODE OR DATA GOES HERE
  79. bank2end:
  80. .ds 8192-(bank2end-bank2start)
  81.  
  82. ;if .inesprg = 2, stop here and bank 3 is set to .org $E000. otherwise continue.
  83.  
  84. .bank 3
  85. .org $8000
  86. bank3start:
  87. ;YOUR CODE OR DATA GOES HERE
  88. bank3end:
  89. .ds 8192-(bank3end-bank3start)
  90. .bank 4
  91. .org $A000
  92. bank4start:
  93. ;YOUR CODE OR DATA GOES HERE
  94. bank4end:
  95. .ds 8192-(bank4end-bank4start)
  96.  
  97. .bank 5
  98. .org $C000
  99. bank5start:
  100. ;YOUR CODE OR DATA GOES HERE
  101. bank5end:
  102. .ds 8192-(bank5end-bank5start)
  103.  
  104. .bank 6
  105. .org $8000
  106. bank6start:
  107. ;YOUR CODE OR DATA GOES HERE
  108. bank6end:
  109. .ds 8192-(bank6end-bank6start)
  110.  
  111. .bank 7 ;this number will be different depending on how many switchable banks you have.
  112. .org $e000
  113. reset:
  114. ;your reset code goes here
  115. ;the following VRC6-specific code will get you started with a "normal" PRG-ROM and CHR-ROM setup:
  116. ;this will work even if you have the minimum .inesprg and .ineschr
  117. LDA #$00
  118. STA $8000 ;load bank 0 at $8000 and bank 1 at $A000
  119.  
  120. LDA #$02
  121. STA $C000 ;load bank 2 at $C000
  122.  
  123. LDA #$20
  124. STA $B003 ;"normal" mode as used by Castlevania 3
  125.  
  126. LDX #$00
  127. STX $D000
  128.  
  129. INX
  130. STX $D001
  131.  
  132. INX
  133. STX $D002
  134.  
  135. INX
  136. STX $D003
  137.  
  138. INX
  139. STX $E000
  140.  
  141. INX
  142. STX $E001
  143.  
  144. INX
  145. STX $E002
  146.  
  147. INX
  148. STX $E003
  149. nmi:
  150. ;your nmi code goes here
  151. irq:
  152. ;your irq code goes here
  153.  
  154. .org $fffa
  155. ;these MUST be in the order below.
  156. ;their actual locations in the program don't matter as long as they are in the fixed bank.
  157. dw nmi
  158. dw reset
  159. dw irq
  160. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  161. ; CHR-ROM BANKS
  162.  
  163. ; These bank numbers pick up where the PRG-ROM bank numbers left off.
  164. ; These bank numbers are not actually used by the cartridge's banking system.
  165. ; Bank switching on CHR-ROM works differently, it depends on the value at memory-mapped register $B003 among other things.
  166. ; I won't go into too much detail here.
  167.  
  168. .bank 8 ;this number will be different depending on how many switchable banks you have.
  169. ;use the '.incbin' directive to insert your graphics data here.
  170. .bank 9 ;this number will be different depending on how many switchable banks you have.
  171. ;use the '.incbin' directive to insert your graphics data here.
  172.  
  173.  
  174.  
  175.  
Add Comment
Please, Sign In to add comment