Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- KONAMI VRC6 NESASM3 TEMPLATE
- ;THIS DOCUMENT IS VALID NESASM3 ASSEMBLY CODE AND SHOULD WORK AS LONG AS YOU FILL IN THE GAPS WITH YOUR OWN CODE!
- .inesprg 4 ; 1x 16KB PRG code
- .ineschr 2 ; 2x 8KB CHR data
- .inesmap 24 ; Konami VRC6 Version 1 (Akumajou Densetsu)
- .inesmir 1 ; background mirroring (Vertical mirroring for Horizontal Scrolling)
- ;nesasm3 doesn't seem to support save battery functionality. If you know how to do this please tell me.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;PUT YOUR MACROS, ZERO PAGE DEFINITIONS, AND RAM DEFINITIONS HERE!
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; HOW BANKING WORKS ON THE VRC6
- ; THE VRC6 HAS A 16K SWITCHABLE SECTION AND AN 8K SWITCHABLE SECTION. ALL PRG-ROM BANKS ON THE VRC6 ARE 8K.
- ; MAKE SURE YOU UNDERSTAND THIS, SINCE IT'S NOT WRITTEN DOWN ANYWHERE ON THE NESDEV WIKI!
- ; 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
- ; THE SECOND 8K OF THAT SECTION.
- ; BANK NUMBERS GO UP, WITH STARTING LOCATIONS OF $8000, $A000, $C000, AND BACK TO $8000 AGAIN.
- ; 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
- ; OR TO $C000 FOR THE 8K SECTION.
- ;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.
- ;ANY NUMBER YOU SUPPLY TO THE VRC6 AS THE BANK NUMBER WHEN SWITCHING THE 16K SECTION GETS DOUBLED AUTOMATICALLY.
- ;THE 8K SECTION REGISTER, ON THE OTHER HAND, TAKES THE GIVEN VALUE AS-IS AND SWITCHES THE 8K SECTION TO THAT BANK.
- ; 16KB BANK EXAMPLE:
- ; LDA #$02
- ; STA $8000
- ; THE CARTRIDGE WILL LOAD BANK 4 AT $8000 AND BANK 5 AT $A000.
- ; 8KB BANK EXAMPLE:
- ; LDA #$02
- ; STA $C000
- ; THE CARTRIDGE WILL LOAD BANK 2 AT $C000.
- ; THE FIXED BANK IS ALWAYS AT $E000. YOUR RESET CODE MUST BE IN THE FIXED BANK OR THE PROGRAM WILL NOT WORK PROPERLY.
- ; NMI AND IRQ SHOULD ALSO BE IN THE FIXED BANK SINCE YOU CAN'T RELIABLY PREDICT WHEN THEY WILL EXECUTE.
- ; THE .inesprg NUMBER MUST BE EVEN OR THE EMULATOR WILL REFUSE TO RUN THE GAME.
- ; A VALID VRC6 CARTRIDGE MUST HAVE PRG-ROM DATA IN EXACT MULTIPLES OF 16K.
- ; YOU CAN ACHIEVE THIS BY ENSURING THAT THE NESASM BANK NUMBER OF THE FIXED BANK IS CONGRUENT TO 3 MOD 4.
- ; IF THAT'S TOO CONFUSING, CONSULT THE FOLLOWING CHART:
- ; .inesprg 2 = fixed bank is bank 3
- ; .inesprg 4 = fixed bank is bank 7
- ; etc.
- ;BANK SWITCHING
- .bank 0
- .org $8000
- bank0start:
- ;YOUR CODE OR DATA GOES HERE
- bank0end:
- .ds 8192-(bank0end-bank0start) ;THIS IS USED TO CREATE THE CORRECT AMOUNT OF PADDING.
- .bank 1
- .org $A000
- bank1start:
- ;YOUR CODE OR DATA GOES HERE
- bank1end:
- .ds 8192-(bank1end-bank1start)
- .bank 2
- .org $C000
- bank2start:
- ;YOUR CODE OR DATA GOES HERE
- bank2end:
- .ds 8192-(bank2end-bank2start)
- ;if .inesprg = 2, stop here and bank 3 is set to .org $E000. otherwise continue.
- .bank 3
- .org $8000
- bank3start:
- ;YOUR CODE OR DATA GOES HERE
- bank3end:
- .ds 8192-(bank3end-bank3start)
- .bank 4
- .org $A000
- bank4start:
- ;YOUR CODE OR DATA GOES HERE
- bank4end:
- .ds 8192-(bank4end-bank4start)
- .bank 5
- .org $C000
- bank5start:
- ;YOUR CODE OR DATA GOES HERE
- bank5end:
- .ds 8192-(bank5end-bank5start)
- .bank 6
- .org $8000
- bank6start:
- ;YOUR CODE OR DATA GOES HERE
- bank6end:
- .ds 8192-(bank6end-bank6start)
- .bank 7 ;this number will be different depending on how many switchable banks you have.
- .org $e000
- reset:
- ;your reset code goes here
- ;the following VRC6-specific code will get you started with a "normal" PRG-ROM and CHR-ROM setup:
- ;this will work even if you have the minimum .inesprg and .ineschr
- LDA #$00
- STA $8000 ;load bank 0 at $8000 and bank 1 at $A000
- LDA #$02
- STA $C000 ;load bank 2 at $C000
- LDA #$20
- STA $B003 ;"normal" mode as used by Castlevania 3
- LDX #$00
- STX $D000
- INX
- STX $D001
- INX
- STX $D002
- INX
- STX $D003
- INX
- STX $E000
- INX
- STX $E001
- INX
- STX $E002
- INX
- STX $E003
- nmi:
- ;your nmi code goes here
- irq:
- ;your irq code goes here
- .org $fffa
- ;these MUST be in the order below.
- ;their actual locations in the program don't matter as long as they are in the fixed bank.
- dw nmi
- dw reset
- dw irq
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ; CHR-ROM BANKS
- ; These bank numbers pick up where the PRG-ROM bank numbers left off.
- ; These bank numbers are not actually used by the cartridge's banking system.
- ; Bank switching on CHR-ROM works differently, it depends on the value at memory-mapped register $B003 among other things.
- ; I won't go into too much detail here.
- .bank 8 ;this number will be different depending on how many switchable banks you have.
- ;use the '.incbin' directive to insert your graphics data here.
- .bank 9 ;this number will be different depending on how many switchable banks you have.
- ;use the '.incbin' directive to insert your graphics data here.
Add Comment
Please, Sign In to add comment