ldx #$FF
stx $8000 ; select last PRG bank
inx
stx $5000 ; mapper 028 address $00 (CHR register)
stx $8000 ; PRG bank 0 on UNROM, CHR bank 0 on 028
inx
stx $5000 ; restore mapper 028 address $01 (PRG register)
ldx $BFFF ; 0 in bank 0, high byte of IRQ vector (>$C0) in last bank
bmi ShowQuitOptionOnTitleScreen
To save others searching through the old threads:
tepples wrote:
thefox wrote:Just let me know what code to execute to reset to the multicart menu.
If a game is running in UNROM or 32K NROM mode, all it has to do is change the outer bank to the last bank. This can be done with the following code copied to RAM:
The easiest way to determine whether the game has been included in one of my multicarts is to compare $FFFC (the reset vector's low byte) to the expected value of the reset vector's low byte.
I've updated the original post with a new revision of my tiny "Neslib for UNROM" package. I've used it successfully to produce the UNROM version of one of my compo entries (Lala the Magical).
;load x with amount of scanlines to wait, should not be zero
Scanline_counter:
ldy #11 ;2 (not included in cycle count till end)
-
nop ; 2
nop ; 2
dey ; 2
;branch not taken requires two machine cycles. Add one if the branch is taken
bne - ;3 (2 on last loop) =9*11-1...98
txa ; 2 = 100
lsr a ; 2 = 102 (set carry half of the time)
bcc + ;2 or 3 (depending if branch taken) = 104/5
+
nop ; 2 = 106/7
dex ; 2 = 108/9
bne Scanline_counter ;3 (2 on last loop) = 111/12
; +2 (ldy at the top)=113/114 (as stated, one less on last loop)
rts ; overhead, not counted...6
; short about 1 cycle every 6 lines, not counting the overhead (113.5 vs 113.667)
; examples
;ldx #6 = 5.98 scanlines
;ldx #60 = 59.90 scanlines
;ldx #240 = 239.64 scanlines
nesdoug.com -- blog/tutorial on programming for the NES
I forgot to mention... this code absolutely can not cross a page boundary. It would be best to place it exactly at the start ($8000) of the ROM, so that any expansion won't accidrntally throw off the cycle count. (By putting half of the code in one page, and the other half in another, causing branches to take an extra cycle).
nesdoug.com -- blog/tutorial on programming for the NES