Code: Select all
.inesprg 2 ; 1x 16KB PRG code .ineschr 1 ; 1x 8KB CHR data .inesmap 85 ; mapper 85 = Konami VRC7 .inesmir 1 ; background mirroring .include "NESmacros.asm" BUTTON_A EQU $80 BUTTON_B EQU $40 BUTTON_SELECT EQU $20 BUTTON_START EQU $10 BUTTON_UP EQU $08 BUTTON_DOWN EQU $04 BUTTON_LEFT EQU $02 BUTTON_RIGHT EQU $01 SPRITE_YPOS EQU $0200 SPRITE_TILENO EQU $0201 SPRITE_ATTR EQU $0202 SPRITE_XPOS EQU $0203 IRQ_LATCH EQU $E010 IRQ_CTRL EQU $F000 IRQ_ACK EQU $F010 .rsset $0000 ;ZERO PAGE RAM joypad1 .rs 1 ;button states for the current frame joypad1_old .rs 1 ;last frame's button states joypad1_pressed .rs 1 ;current frame's off_to_on transitions sleeping .rs 1 ;main program sets this and waits for the NMI to clear it. Ensures the main program is run only once per frame. ; for more information, see Disch's document: http://nesdevhandbook.googlepages.com/theframe.html needdraw .rs 1 ;drawing flag. dbuffer_index .rs 1 ;current position in the drawing buffer temp_dbuffer_index .rs 1 dbuffer_index_4x .rs 1 ptr1 .rs 2 ;a pointer soft2001 .rs 1 ;$2001 (PPUMASK) buffer. Unlike PPUMASK can load this into a register. tempX .rs 1 tempY .rs 1 playerPosX .rs 1 playerPosY .rs 1 ;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;; .bank 0 .org $6000 ;8 KB PRG-RAM bank, fixed .bank 1 .org $8000 ;8 KB switchable PRG-ROM bank .bank 2 .org $A000 ;8 KB switchable PRG-ROM bank .bank 3 .org $C000 ;8 KB switchable PRG-ROM bank .bank 4 .org $E000 ;8 KB fixed PRG-ROM bank .org $E011 ;placed after $e010 to avoid corruption of IRQ controls mapped to $E008 and $E010 nmihandler: pha txa pha tya pha ;your code goes here pla tay pla tax pla rti irqhandler: rti reset: SEI ; disable IRQs CLD ; disable decimal mode LDX #$40 STX $4017 ; disable APU frame IRQ LDX #$FF TXS ; Set up stack INX ; now X = 0 STX $2000 ; disable NMI STX $2001 ; disable rendering STX $4010 ; disable DMC IRQs vblankwait1: ; First wait for vblank to make sure PPU is ready BIT $2002 BPL vblankwait1 clrmem: LDA #$00 STA $0000, x STA $0100, x STA $0300, x STA $0400, x STA $0500, x STA $0600, x STA $0700, x LDA #$FE STA $0200, x ;move all sprites off screen INX BNE clrmem vblankwait2: ; Second wait for vblank, PPU is ready after this BIT $2002 BPL vblankwait2 finalprep: cli ;enable IRQs LDA #%10000000 ; enable NMI, sprites from Pattern Table 0 STA $2000 LDA #%00010100 ; enable sprites STA $2001 .org $FFFA dw nmihandler dw reset dw irqhandler .bank 5 ;ppu CHR-ROM bank 0 .org $0000 incbin "RawNES.RAW" .bank 6 ;ppu CHR-ROM bank 1 .org $0400 .bank 7 ;ppu CHR-ROM bank 2 .org $0800 .bank 8 ;ppu CHR-ROM bank 3 .org $0C00 .bank 9 ;ppu CHR-ROM bank 4 .org $1000 .bank 10 ;ppu CHR-ROM bank 5 .org $1400 .bank 11 ;ppu CHR-ROM bank 6 .org $1800 .bank 12 ;ppu CHR-ROM bank 7 .org $1c00
Now that being said, I have a few questions.
1. Did I set up my banks and header correctly?
2. I opened my ROM using YY-CHR to view the game's graphics. I would expect to only see the graphic mentioned above. It is there, but not where I thought it should be. YY-CHR says the graphic is at address $A000, despite it being stored in the PPU's bank 0. Below is a link to a screenshot of YY-CHR with my test ROM loaded.
3. A lot of these mappers seem to have audio registers and IRQ handlers in places that are inconvenient. For example the address $9000 in this mapper is used to select which 8 KB PRG ROM bank is loaded into the area from $C000 to $DFFF. Suppose I had some code that started at $8000 and it took up $1200 bytes, would whatever instruction that happens to be at address $9000 corrupt the bank loaded into $C000? If so, what's the best way to prevent "clobbering" these registers?