Programming UOROM: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
No edit summary
(Merged to Programming UNROM. The ONLY difference is the number of available banks, and apparently 64 KB UNROM exists too, so we have to cover that there anyway.)
 
Line 1: Line 1:
The [[Programming UOROM|UOROM]] mapper has 256kb PRG-ROM (divided into 16 16k banks) and CHR-RAM.  It is very easy to use.
#REDIRECT [[Programming UNROM]]
 
== iNES Header ==
 
Here is an iNES header for the [[Programming UOROM|UOROM]] mapper.
 
  .segment "HEADER"
    .byte "NES", $1A
    .byte $10      ;UOROM has 16 16k banks
    .byte $00      ;UOROM uses CHR RAM, so no CHR ROM
    .byte $20, $00  ;UOROM is Mapper 2
    .byte $00      ;UOROM has no PRG RAM
 
== Bankswitching ==
 
[[Programming UOROM|UOROM]] has 16 16k banks.  One of these banks is fixed at $C000-$FFFF.  The other fifteen (numbered 0-15, or $00-$0E) are switchable at $8000-$BFFF.
 
Switching banks requires a write to $8000-$FFFF.  Bits 0-3 of the byte written to $8000-$FFFF will select the bank.  When writing to $8000-$FFFF, the value you are writing must match the value located at the destination address in ROM (see [[Bus conflict]]).  One way to ensure this is to have a bankswitch lookup table.  You can read from this table and then immediately write that value back to the table.
 
  .segment "BANKTABLE"
  banktable:
      .byte $00, $01, $02, $03, $04, $05, $06, $07  ;write to this table to switch banks.
      .byte $08, $09, $0A, $0B, $0C, $0D, $0E
 
  .segment "ZP": zeropage
  current_bank: .res 1
 
  .segment "CODE"
  bankswitch:
      lda banktable, y        ;read a byte from the banktable
      sta banktable, y        ;and write it back, switching banks
      sta current_bank        ;store the current bank in RAM
      rts
 
The lookup table and the bankswitching subroutine should be located in the fixed bank, so that they are always available.  It is common to stick the lookup table at $FFEB-$FFF9, immediately before the nmi/reset/irq vectors (at $FFFA-FFFF).
 
With the lookup table and bankswitching subroutine in place, switching banks is as easy as this:
 
      ldy #$02
      jsr bankswitch    ;switch to bank 2
 
== Related articles ==
 
* [[UxROM|UxROM technical reference]]
* [[Programming UNROM]] - UOROM's little brother

Latest revision as of 22:56, 27 July 2009

Redirect to: