Programming MMC1: Difference between revisions
From NESdev Wiki
Jump to navigationJump to search
(quick setup) |
(Then, to switch banks) |
||
Line 2: | Line 2: | ||
== Quick setup for UNROM style == | == Quick setup for UNROM style == | ||
If you are using SGROM or SNROM to provide an environment similar to [[Programming UNROM|UNROM]], with 8 KB of CHR RAM, a fixed PRG ROM bank at $C000, and a 16 KB switchable PRG ROM bank at $8000, do this in your init code: | |||
<pre> | <pre> | ||
lda #$80 ; reset the mapper | lda #$80 ; reset the mapper | ||
Line 16: | Line 16: | ||
lsr a | lsr a | ||
sta $8000 | sta $8000 | ||
</pre> | |||
Very early revisions of the MMC1 IC might power up in a mode other than fixed-$C000, requiring that the vectors and the start of the [[init code]] be placed in all banks, much as in [[BxROM]] or [[AxROM]] or [[GxROM]]. | |||
Later revisions guarantee that the fixed bank is loaded at power on. | |||
Then to switch banks, load the bank number into A and call this subroutine: | |||
<pre> | |||
mmc1_load_prg_bank: | |||
sta $E000 | |||
lsr a | |||
sta $E000 | |||
lsr a | |||
sta $E000 | |||
lsr a | |||
sta $E000 | |||
lsr a | |||
sta $E000 | |||
rts | |||
</pre> | </pre> |
Revision as of 13:45, 6 June 2010
MMC1 was Nintendo's first ASIC mapper for the NES.
Quick setup for UNROM style
If you are using SGROM or SNROM to provide an environment similar to UNROM, with 8 KB of CHR RAM, a fixed PRG ROM bank at $C000, and a 16 KB switchable PRG ROM bank at $8000, do this in your init code:
lda #$80 ; reset the mapper sta $E000 lda #$0E ; vertical mirroring, fixed $C000, 8 KB CHR pages sta $8000 ; (use $0F instead for horizontal mirroring) lsr a sta $8000 lsr a sta $8000 lsr a sta $8000 lsr a sta $8000
Very early revisions of the MMC1 IC might power up in a mode other than fixed-$C000, requiring that the vectors and the start of the init code be placed in all banks, much as in BxROM or AxROM or GxROM. Later revisions guarantee that the fixed bank is loaded at power on.
Then to switch banks, load the bank number into A and call this subroutine:
mmc1_load_prg_bank: sta $E000 lsr a sta $E000 lsr a sta $E000 lsr a sta $E000 lsr a sta $E000 rts