1. Why FlashROM saving is confusing
During normal gameplay, a Flash cartridge behaves just like mask ROM: the Z80 reads instructions, graphics, and music tables from 4000h–BFFFh at full bus speed. Underneath, however, compatible parallel NOR Flash chips continuously watch write cycles on the bus. When the CPU performs a specific sequence of unlock writes, the Flash chip switches out of normal read-array mode and enters an embedded command state—autoselect ID query, byte program, or sector erase.
The same underlying AMD/JEDEC command set is used by the 8 MB (64 Mbit) Flash chips found in ASCII16-X, MegaFlashROM SCC+ SD, and Carnivore2 (typically Spansion/Cypress S29GL064S or ST/Numonyx/Micron M29W640GB operating in 8-bit byte mode). In practice, the difficult part is almost never the four-cycle byte program command itself. Nearly every real-world bug comes from one of five places:
- Confusing MSX 16 KB CPU pages, mapper banks, and physical Flash erase sectors.
- Writing into a CPU window that overlaps mirrored mapper registers (especially on
ASCII16-X). - Leaving interrupts enabled or failing to restore read-array mode (
F0h) while banked ISRs expect normal ROM bytes. - Polling
DQ7/DQ5without a timeout or full-byte read-back check—causing hangs or silent false-positive “saves” on write-protected cartridges. - Cartridge-level write protection (
OPFXSDwithout/Won MegaFlashROM, missingRnMultwrite bits or overwritten RAM settings in a Carnivore2.RCP, or launching from cartridge RAM instead of Flash).
The routines, memory maps, and defensive checks in this guide come directly from production Z80 drivers built and verified across Illusion City ROM 0.5, Xak III, Eggerland 4, and Digger.
2. The most important hardware rule: Flash changes 1 → 0
A freshly erased NOR Flash byte always contains FFh (11111111b). Byte programming can clear individual 1 bits down to 0, one byte at a time, in a few tens of microseconds. Programming cannot turn a 0 bit back into a 1. Restoring any 0 → 1 bit requires erasing the entire physical Flash sector (8 KB or 64 KB) that holds that byte.
FFh → F0h → C0h → 00h ; valid byte-program sequence without erasing
FFh → F0h → F8h ; INVALID: bit 3 is already 0 and cannot become 1
Before attempting an in-place byte update without erasing, verify:
(old_byte AND new_byte) = new_byte
If that condition holds for every byte being updated, all transitions are 1 → 0 and can be programmed directly. If even one bit needs 0 → 1, you must either write into a fresh erased slot (an append-only journal) or erase a sector first.
FFh ("unwritten / uncommitted") and clear bits toward 0 as records are committed. Writing 00h consumes all eight 1-bits in that byte until the next sector erase. Conversely, if a byte in your source buffer is already FFh and you are writing into a freshly erased region, your programmer loop can skip that byte completely.
3. Execute from RAM, disable interrupts, and restore state cleanly
While a Flash chip is in autoselect (90h), byte-program (A0h), or sector-erase (80h/30h) mode, reads from the chip do not return normal ROM bytes—they return chip IDs or live status bits (DQ7–DQ0). That creates four strict rules for MSX software:
- Run the Flash routine from MSX RAM (
C000h–FFFFh): Never execute unlock, program, erase, or polling instructions out of the FlashROM being written. Copy a small self-contained driver into Page 3 RAM (or temporarily borrow a rebuildable terrain/collision buffer in RAM, as Digger and Eggerland 4 do) and call it there. - Disable interrupts (
DI) for the entire chip transaction: Copying the writer to RAM is not enough ifEIremains active. A64 KBsector erase takes roughly0.5to1.5 secondsonM29W640GB/S29GL064S. If the MSX VBlank interrupt (0038h) or a customIM 1/IM 2music/sprite handler fires mid-erase and reads banked cartridge ROM in4000h–BFFFh, it will read toggling status bits instead of code or audio tables and crash immediately. - Keep
SPand the source data buffer in RAM: All bytes being programmed—and the CPU stack—must already sit in RAM before the first unlock write, because switching mapper banks or entering command mode makes ROM data unreadable until completion. - Always issue
F0hand restore mapper banks on exit: Every exit path (success, timeout, ID mismatch, or verification error) should writeF0hto return the Flash state machine to normal read-array mode, restore the game’s expected Page 1 / Page 2 mapper banks, and only then re-enable interrupts if appropriate.
4. Command sequences and unlock addresses (ASCII16 vs. ASCII8)
On the 8 MB x8/x16 NOR Flash chips used in modern MSX cartridges (M29W640GB, S29GL064S) strapped in 8-bit byte mode (BYTE# = VIL), the hardware command decoder checks low chip address bits A11..A-1 for 0AAAh (unlock cycle 1 & command cycle 3) and 0555h (unlock cycle 2).
Standard bus command sequences (byte mode)
; Autoselect (read Manufacturer / Device ID, non-destructive)
AAh → chip offset 0AAAh
55h → chip offset 0555h
90h → chip offset 0AAAh
read (sector_base + 00h) = Manufacturer ID (01h AMD/Spansion, 20h ST/Micron)
read (sector_base + 02h) = Device ID byte 1 (7Eh on S29GL064S / M29W640GB)
F0h → any mapped Flash address (exit back to normal read-array mode!)
; Byte program (1 → 0 only)
AAh → chip offset 0AAAh
55h → chip offset 0555h
A0h → chip offset 0AAAh
data → target Flash byte address
; Sector erase (restores entire 8 KB or 64 KB sector to FFh)
AAh → chip offset 0AAAh
55h → chip offset 0555h
80h → chip offset 0AAAh
AAh → chip offset 0AAAh
55h → chip offset 0555h
30h → any address inside the target Flash sector
How 4AAAh and 4555h work across both ASCII16 and ASCII8
Because 0AAAh and 0555h both lie inside the first 4 KB (0000h–0FFFh) of logical ROM bank 0, mapping Bank 0 at 4000h places those two chip offsets at the exact same Z80 addresses on both ASCII16 (16 KB banks) and ASCII8 (8 KB banks)—without colliding with any mapper register:
| Mapper | Bank 0 setup (Page 1) | CPU unlock addresses | Recommended save-bank window (Page 2) |
|---|---|---|---|
| ASCII16 / ASCII16-X ( 16 KB banks) | LD A,00h → (6000h)Maps 16 KB bank 0 at 4000h–7FFFh | Unlock 1: 4AAAhUnlock 2: 4555h | LD A,save_bank_16k → (7000h)Write save bytes in 8000h–9FFFh (avoids A000h–BFFFh mirrors on ASCII16-X). |
| ASCII8 ( 8 KB banks) | LD A,00h → (6000h)Maps 8 KB bank 0 at 4000h–5FFFh | Unlock 1: 4AAAhUnlock 2: 4555h | LD A,save_bank_8k → (7000h)Maps 8 KB save bank at 8000h–9FFFh (6000h–7FFFh are mapper registers). |
512 KB 8-bit Flash chips (Am29F040B / SST39SF040): Dedicated 8-bit 512 KB chips do not shift word addresses by one bit, so they decode 0555h/02AAh (Am29F040B) or full 15-bit 5555h/2AAAh (SST39SF040, where 5555h falls at offset 1555h of 8 KB bank 2 and 2AAAh at offset 0AAAh of 8 KB bank 1). On ASCII16-X, MegaFlashROM, and Carnivore2, the 8 MB x8/x16 chips use byte-mode 0AAAh/0555h (4AAAh/4555h with bank 0 at 4000h).
5. Non-destructive Flash & cartridge detection (90h Autoselect)
A cartridge game should never erase or program blindly to “test” whether Flash saving works. A player may launch the exact same ROM on a read-only ASCII16 cartridge, in an emulator configured as plain ASCII16, on MegaFlashROM without /W, or in Carnivore2 RAM mode. Using window comparison plus the Autoselect (90h) command lets your game detect both the sector layout and write capability at startup without modifying a single bit of Flash.
In Digger and Eggerland 4, startup detection runs from RAM under DI and performs two clean checks:
- Distinguish
ASCII16-Xfrom standardASCII16/ MFR / Carnivore2: Set(6000h) = 0and(7000h) = 1(confirming4000hand8000hnow show different banks), then write00htoB000h. OnASCII16-X,B000hmirrors the Page 2 bank register (7000h), so8000hswitches back to bank0. On standardASCII16(MegaFlashROM and Carnivore2),B000his not a mapper register, so8000hremains on bank1. - Verify a real writable Flash chip in the save window: Map the reserved
FFh-filled save bank into8000h, issueAAh → 4AAAh,55h → 4555h,90h → 4AAAh, and read(8000h)/(8002h). Checking inside the blank8000hsave sector guarantees a read-only ROM simply returnsFFhrather than accidentally matching game bytes in bank0—and immediately catches a Carnivore2 configuration where Page 2 was mistakenly left read-only or pointed at RAM. Always writeF0hto(8000h)before returning.
; ------------------------------------------------------------
; FLASH DETECT (execute from RAM with DI)
;
; Probes ASCII16-X vs. ASCII16 and checks S29GL064S / M29W640GB
; Autoselect IDs in the mapped save sector at 8000h.
;
; Output:
; Z = 1 (A = 00h): supported writable Flash detected
; (_FLASH_MODE) = 01h ASCII16-X, 02h ASCII16 / MFR / C2
; NZ = 1 (A = 01h): read-only or unsupported (safe fallback)
; ------------------------------------------------------------
_flash_detect:
XOR A
LD (6000h),A ; Page 1 = bank 0
LD (7000h),A ; Page 2 = bank 0
CALL _compare_windows
JR NZ,.unsupported
LD A,01h
LD (7000h),A ; Page 2 = bank 1
CALL _compare_windows
JR Z,.unsupported ; Mapper did not switch Page 2
XOR A
LD (B000h),A ; Probe ASCII16-X mirrored Page 2 register
CALL _compare_windows
LD A,01h ; 01h = ASCII16-X (B000h switched Page 2)
JR Z,.have_mode
INC A ; 02h = ASCII16 / MFR / Carnivore2
.have_mode:
LD (_FLASH_MODE),A
LD A,(SAVE_BANK) ; Map reserved FFh save bank at 8000h
LD (7000h),A
LD A,AAh ; Autoselect command (non-destructive)
LD (4AAAh),A
LD A,55h
LD (4555h),A
LD A,90h
LD (4AAAh),A
LD A,(8000h) ; Manufacturer ID: 01h (AMD/Spansion) or 20h (ST/Micron)
CP 01h
JR Z,.check_dev
CP 20h
JR NZ,.reset_unsupported
.check_dev:
LD A,(8002h) ; Device ID byte 1: 7Eh (S29GL064S / M29W640GB)
CP 7Eh
JR NZ,.reset_unsupported
LD A,F0h ; Return Flash to normal read-array mode
LD (8000h),A
XOR A ; Z = 1, A = 00h (supported)
RET
.reset_unsupported:
LD A,F0h ; Always exit command mode just in case
LD (8000h),A
.unsupported:
XOR A
LD (_FLASH_MODE),A
INC A ; NZ, A = 01h (read-only / unsupported)
RET
_compare_windows:
LD HL,4000h
LD DE,8000h
LD B,20h
.cmp_loop:
LD A,(DE)
CP (HL)
RET NZ
INC HL
INC DE
DJNZ .cmp_loop
RET
When _flash_detect returns NZ, the game continues normally with session-only scores or passwords and can display a clear status line (just as Digger’s F5 settings screen and Eggerland 4’s Continue screen do) instead of freezing or reporting bogus save confirmations.
6. Production-hardened Z80 erase, program, and polling routines
Early minimal Flash snippets often omit three safeguards that turn out to be essential on real MSX hardware and emulators: skipping FFh source bytes, bounding the DQ7/DQ5 poll loop with a timeout, and verifying the actual stored bytes after the chip returns to read-array mode.
The routines below execute from MSX RAM under DI, with Bank 0 mapped in Page 1 (4000h–7FFFh) and the target save bank mapped in Page 2 (8000h–9FFFh):
; ------------------------------------------------------------
; FLASH PROGRAM (execute from RAM with DI)
;
; HL = source buffer in RAM (C000h–FFFFh)
; DE = destination in mapped Flash (recommended: 8000h–9FFFh)
; BC = byte count (> 0)
;
; Return:
; Cy = 0: all bytes programmed and read-back verified
; Cy = 1: timeout, DQ5 error, or read-back mismatch
; ------------------------------------------------------------
_flash_program:
LD A,(HL)
INC A
JR Z,.skip ; Source byte is FFh: nothing to clear in erased slot
LD A,AAh ; Cycle 1: unlock 1
LD (4AAAh),A
LD A,55h ; Cycle 2: unlock 2
LD (4555h),A
LD A,A0h ; Cycle 3: byte-program setup
LD (4AAAh),A
LD A,(HL)
LD (DE),A ; Cycle 4: program byte at target address
CALL _check_flash_status
RET C ; Timeout or DQ5 failure (already reset with F0h)
LD A,(DE) ; Full-byte read-back in normal read-array mode
CP (HL) ; Catches read-only false positives on 80h–FEh!
JR NZ,.verify_fail
.skip:
INC HL
INC DE
DEC BC
LD A,B
OR C
JR NZ,_flash_program
OR A ; Cy = 0: success
RET
.verify_fail:
LD A,F0h
LD (DE),A
SCF
RET
; ------------------------------------------------------------
; FLASH SECTOR ERASE + BLANK VERIFY (execute from RAM with DI)
;
; DE = base address inside target sector (e.g. 8000h)
; BC = byte count to verify blank afterward (e.g. 2000h for 8 KB)
;
; Return:
; Cy = 0: sector erased and verified FFh across BC bytes
; Cy = 1: erase failed or cartridge ignored command
; ------------------------------------------------------------
_flash_erase:
PUSH DE
PUSH BC
LD HL,4AAAh
LD BC,4555h
LD (HL),L ; AAh -> 4AAAh
LD A,C ; 55h
LD (BC),A ; 55h -> 4555h
LD (HL),80h ; 80h -> 4AAAh (erase setup)
LD (HL),L ; AAh -> 4AAAh
LD (BC),A ; 55h -> 4555h
LD A,30h
LD (DE),A ; 30h -> target sector address (confirm erase)
LD A,FFh ; Expected byte value after erase
CALL _check_flash_status
POP BC
POP HL
RET C ; Timeout or DQ5 failure
_flash_is_blank:
LD A,(HL)
INC A ; FFh + 1 -> 00h (Z = 1)
JR NZ,.not_blank
INC HL
DEC BC
LD A,B
OR C
JR NZ,_flash_is_blank
OR A ; Cy = 0: verified erased
RET
.not_blank:
SCF ; Cy = 1: non-FFh byte remained
RET
; ------------------------------------------------------------
; BOUNDED FLASH STATUS POLL (execute from RAM with DI)
;
; A = expected final byte (or FFh for sector erase)
; DE = target Flash address being polled
;
; Return:
; Cy = 0: DQ7 matched expected value before timeout
; Cy = 1: DQ5 error or timeout; writes F0h to reset array
; ------------------------------------------------------------
_check_flash_status:
PUSH BC
PUSH HL
LD C,A ; C = expected byte (bit 7 = expected DQ7)
LD B,20h ; Outer timeout (~2M iterations: > 2s at 3.58–7 MHz)
LD HL,0000h ; Inner 65,536-iteration counter
.loop:
LD A,(DE) ; Read Flash status register while busy
XOR C
JP P,.done ; Sign bit 0 => DQ7 matches expected bit 7!
XOR C ; Restore raw status byte
AND 20h ; DQ5 = 1 (exceeded internal timing limits)?
JR NZ,.recheck
DEC HL
LD A,H
OR L
JR NZ,.loop
DJNZ .loop
JR .error ; Bounded timeout expired (command ignored / stuck)
.recheck:
; DQ5 set: re-read once because completion can coincide with DQ5!
LD A,(DE)
XOR C
JP P,.done
.error:
LD A,F0h ; Reset Flash state machine to read-array mode
LD (DE),A
SCF ; Cy = 1: failure
POP HL
POP BC
RET
.done:
OR A ; Ensure Cy = 0
POP HL
POP BC
RET
Compact code-size tip (BC = 8030h)
When targeting a fixed sector base at 8000h inside a tight overlay, you can also load BC = 8030h: 8030h is a valid address inside the 8000h sector, while B = 80h supplies the erase-setup byte and C = 30h supplies the sector-confirm byte (LD (BC),A). Writing 30h to any offset inside the target physical sector erases that entire sector.
7. Why bounded DQ7 / DQ5 polling and read-back both matter
While an embedded program or erase operation is active, reading (DE) returns live hardware status rather than normal stored data:
| Status Bit | Behavior during an active Flash operation |
|---|---|
| DQ7 (Data# Polling) | Outputs the complement of the target byte’s bit 7 while busy (0 during sector erase, since erased bytes end at FFh). Flips to match the expected bit 7 once finished. |
| DQ6 (Toggle Bit) | Toggles 0 ↔ 1 on consecutive reads from any address while busy; stops toggling when complete. |
| DQ5 (Exceeded Timing Limits) | Becomes 1 if an internal voltage/pulse error occurs—such as attempting to program a 0 bit back to 1 without erasing. |
Understanding how DQ7 and DQ5 behave when a write command was ignored (because a cartridge is read-only or mis-mapped) explains why naive routines fail in two opposite ways:
Trap 1 — Silent false-positive “success” without read-back: Suppose a sector contains erased FFh on a read-only cartridge (such as MegaFlashROM launched without /W) and your code tries to program 80h (or any byte from 80h to FEh whose bit 7 is 1). The write is ignored, (DE) still returns FFh, and FFh XOR 80h = 7Fh has sign bit 0 (JP P,.done)! A routine that checks only DQ7 reports success (Cy = 0) without writing a single bit. Comparing LD A,(DE) / CP (HL) immediately catches the mismatch.
Trap 2 — Permanent freeze without a timeout counter: Suppose your code attempts a sector erase (expected = FFh) on a read-only cartridge where (DE) happens to contain 00h (or any byte 00h–1Fh / 40h–5Fh with bit 7 = 0 and bit 5 = 0). Because the erase command was ignored, (DE) never changes: DQ7 never becomes 1, and DQ5 (20h) is 0 forever. Without the B/HL timeout counter, JR Z,.loop locks up the MSX permanently.
Note also why .recheck reads (DE) one final time after DQ5 sets: on real AMD/ST silicon, internal completion and DQ5 assertion can race on the final microsecond of an operation, so the datasheet requires re-checking DQ7 once before declaring an error and issuing F0h.
8. Flash sector geometry: bottom-boot, top-boot, and uniform
A Flash sector (or erase block) is the smallest physical region inside the Flash chip that 80h/30h can erase independently. Physical Flash sectors are hardware subdivisions of the 8 MB chip—they are not MSX 16 KB CPU pages and not 8 KB/16 KB mapper banks.
The three physical geometries
| Chip geometry | Boot sector region | Remainder of chip | Typical MSX hardware |
|---|---|---|---|
| Bottom-boot | Lowest physical 64 KB (000000h–00FFFFh) split into eight 8 KB sectors. | Uniform 64 KB sectors (010000h+). | M29W640GB (Carnivore2), ASCII16-X reference design. |
| Uniform | None. | Every erase sector is 64 KB throughout the chip. | S29GL064S (model 04/03 variants), MegaFlashROM user slots. |
| Top-boot | Highest physical 64 KB split into eight 8 KB sectors. | Uniform 64 KB sectors below the top block. | M29W640GT / FT variants. |
8 MB NOR Flash layouts. “Bottom” means physical chip offset 000000h, not MSX Page 0. Multi-ROM cartridges reserve those low physical blocks for their own boot menu and BIOS firmware.Why physical block zero on a multi-ROM cartridge is off-limits
On a dedicated single-game ASCII16-X board, physical chip offset 000000h is also the start of your game ROM, so its first 64 KB sits directly over the chip’s eight 8 KB bottom-boot sectors (for example, offsets 0C000h and 0E000h in Digger’s 128 KB ASCII16-X build).
On a multi-function cartridge, physical 000000h belongs to the cartridge itself:
- Carnivore2: Physical
000000h–00FFFFh(the eight8 KBbottom-boot sectors) holds the Boot Menu code and directory entries, followed by IDE BIOS and FMPAC BIOS blocks. User-installed games are placed higher in Flash inside64 KBuniform sectors. - MegaFlashROM SCC+ SD: Physical system blocks hold the SD kernel, Nextor/disk ROM, optional ROM disk, and recovery utility;
OPFXSDplaces installed games into aligned64 KBuser blocks.
FFh-filled at build time) and address them through normal ROM-relative mapper banks.
Relocation: constant logical banks, movable physical Flash
When a user installs, deletes, or reorders games on MegaFlashROM or Carnivore2, the loader assigns a 64 KB-aligned physical image base in Flash and configures the cartridge’s bank offset hardware automatically:
save_bank = 08h, 3Ch, etc.). The cartridge loader translates those banks to whichever physical 64 KB block currently holds the game.physical Flash address = cartridge-assigned image base
+ logical offset inside your ROM image
64 KB boundaries inside your ROM image (multiples of four 16 KB ASCII16 banks or eight 8 KB ASCII8 banks) and pad the entire 64 KB sector with FFh in the distributed ROM file. Never pack code, graphics, or another ROM into the unused tail of a 64 KB save sector—erasing that sector wipes all 64 KB.
9. One address space, four MSX pages — keeping terminology straight
Keeping three distinct terms separate eliminates 90% of mapper bugs:
- MSX CPU Page (
16 KB): One of the four fixed Z80 address quarters (Page 0:0000h–3FFFh,Page 1:4000h–7FFFh,Page 2:8000h–BFFFh,Page 3:C000h–FFFFh). - Mapper Bank (
8 KBor16 KB): A logical slice of your ROM image selected into an MSX CPU page by writing a mapper register (6000h,7000h, etc.). - Flash Sector (
8 KBor64 KB): The physical erase block inside the NOR Flash IC (four16 KBASCII16banks equalone64 KBFlash sector).
| Aspect | MegaFlashROM SCC+ SD | Carnivore2 | ASCII16-X |
|---|---|---|---|
| Normal game windows | MSX Page 1 (4000h–7FFFh) & Page 2 (8000h–BFFFh). | MSX Page 1 & Page 2 (Carnivore2 Banks 1 & 2 in standard ASCII16 RCP). | MSX Page 1 & Page 2. |
| How Flash writes are enabled | Flash into cartridge with OPFXSD /W (self-writing mode), not RAM mode. | Program into Flash with C2MAN using an .RCP where bit 4 (10h) of RnMult is set on every CPU window used for Flash writes. | Always enabled in hardware; avoid mirrored register ranges 6000h–6FFFh and A000h–BFFFh when writing Flash data. |
| Universal safe write layout | Map Bank 0 at 4000h–7FFFh (for 4AAAh/4555h unlock commands) and map your target save bank into Page 2, performing all data/erase writes inside 8000h–9FFFh. | ||
Carnivore2 numbering trap: “Carnivore2 Bank 4” is MSX Page 0!
Carnivore2’s configuration registers define four independent hardware Banks 1–4, placed anywhere in Z80 memory by each bank’s BnAdrD byte. In the standard Carnivore2 ASCII16 preset, those four banks map as follows:
| MSX CPU Page | Z80 Address Range | Carnivore2 ASCII16 Bank | Typical Flash-Save Setting |
|---|---|---|---|
| MSX Page 0 | 0000h–3FFFh | Carnivore2 Bank 4 | Leave protected (85h) |
| MSX Page 1 | 4000h–7FFFh | Carnivore2 Bank 1 | Enable writes (95h) — needed for 4AAAh / 4555h commands |
| MSX Page 2 | 8000h–BFFFh | Carnivore2 Bank 2 | Enable writes (95h) — needed for 8000h–9FFFh save data & 30h erase |
| MSX Page 3 | C000h–FFFFh | Carnivore2 Bank 3 | Leave protected (85h) |
8000h–9FFFh), the AAh/55h/A0h unlock cycles are written through Page 1 (4AAAh/4555h). If Page 1 is protected, the Flash chip never sees the unlock handshake!
10. MegaFlashROM SCC+ SD setup (OPFXSD /W)
By default, OPFXSD installs ROM images with Flash write protection enabled so stray game writes cannot corrupt stored cartridges. For any game that saves directly to its own FlashROM sectors, flash and launch it from Flash with the /W switch:
OPFXSD GAME.ROM /A16 /W
- Do not launch into cartridge RAM for persistent saves: Loading a ROM into MegaFlashROM’s volatile RAM mapper cannot write back to non-volatile Flash sectors across power cycles.
- Ship the full untrimmed ROM image: If a
128 KBgame ships as a256 KBimage whose upper128 KBholds its reserved64 KBsave sectors (as in Digger), flash the complete256 KBfile soOPFXSDreserves those sectors exclusively for the game. - Known-checksum auto-detection: As confirmed by Manuel Pazos,
OPFXSDcan also whitelist released game checksums to apply/Wautomatically, so documenting both/Wand exact SHA-1/SHA-256 hashes helps players and tool authors alike.
11. Carnivore2 setup, the IC.RCP RAM lesson, and the live .RCP editor
On Carnivore2, persistent Flash saving requires two things:
- Program the ROM into Carnivore2 Flash via
C2MAN(never launch via RAM-load mode if you want non-volatile Flash saves). - Supply a
.RCPregister preset besideGAME.ROM(for example,DIGGER.RCPalongsideDIGGER.ROM) with bit 4 (10h) ofRnMultset on every Carnivore2 bank whose CPU window receives Flash unlock or data writes.
RnMult = RnMult OR 10h ; bit 4 = 1: allow CPU writes to reach Flash
RnMult = RnMult AND EFh ; bit 4 = 0: write-protect this bank window
Real-world lesson from Illusion City 1.0.6 (IC.RCP): never replace a game’s custom .RCP with a bare generic preset!
In Illusion City ROM 0.5, the game runs from a 4 MB FlashROM and relies on Carnivore2’s internal memory-mapper RAM (256 KB+) and FM-PAC support, controlled by the global configuration tail at offsets 19h–1Ch (Mconf, CardMDR, PosSiz, RstRun). Generating a fresh standalone ASCII16 preset from scratch disabled Carnivore2’s cartridge RAM at boot, breaking startup until update 1.0.6 restored the original IC.RCP bytes and toggled only the RnMult write-enable bits (04h and 0Ah). Whenever a game already has a working .RCP, drop that exact .RCP into the editor below so every RAM, sound, and reset bit stays intact.
Interactive Carnivore2 .RCP Editor & Generator
Drop an existing .RCP file below to inspect and edit it safely, or start from a standard Carnivore2 mapper preset (ASCII16, ASCII8, Konami5 / SCC, Konami4, or MiniROM). Imported files keep every original byte untouched—including Mconf, CardMDR, PosSiz, RstRun, and any extended bytes—modifying only bit 4 (10h) at offsets 04h, 0Ah, 10h, and 16h.
.RCP file hereor click to browse. Leave empty to build a new 30-byte preset from the mapper list below.
Advanced: inspect all 30 RCP bytes & preserved CardMDR tail
Highlighted green values indicate RnMult bytes modified from the loaded/initial baseline. Global cartridge flags (19h–1Dh) are always preserved verbatim when editing an imported .RCP.
30-byte Carnivore2 .RCP structure: 00h = mapper type ASCII code; 01h–18h = four 6-byte bank descriptors (RnMask, RnAddr, RnReg, RnMult, BnMaskR, BnAdrD, with RnMult at 04h, 0Ah, 10h, 16h); 19h–1Ch = Mconf, CardMDR, PosSiz, RstRun; 1Dh = reserved (FFh).
12. ASCII16-X mirror rules and MSX emulator gotchas
ASCII16-X (designed by Laurens Holst / Grauw) is built specifically for self-writing FlashROM games, with no external /W flag or .RCP preset needed. However, its mapper register decoding has one critical hardware difference from classic ASCII16:
Full-quadrant mapper mirroring on ASCII16-X
- Page 1 bank register (
6000h–6FFFh) is mirrored across all four quadrants at2000h–2FFFh,6000h–6FFFh,A000h–AFFFh, andE000h–EFFFh. - Page 2 bank register (
7000h–7FFFh) is mirrored across all four quadrants at3000h–3FFFh,7000h–7FFFh,B000h–BFFFh, andF000h–FFFFh.
If your save bank is mapped into Page 2 (8000h–BFFFh) and you try to program Flash bytes at A000h–AFFFh, ASCII16-X simultaneously interprets that write as a Page 1 bank switch—knocking Bank 0 out of 4000h–7FFFh so the very next 4AAAh/4555h unlock sequence fails! Writing to B000h–BFFFh is even worse: it switches Page 2’s own bank mid-write.
8000h–9FFFh): Keep Bank 0 mapped at 4000h–7FFFh for 4AAAh/4555h commands, map your target 16 KB save bank at 8000h–BFFFh via (7000h), and restrict all Flash data writes to the lower 8 KB half—8000h–9FFFh. If a save spans more than 8 KB inside a 64 KB sector, advance (7000h) through each of the four 16 KB banks (bank + 0..3), using each bank’s 8000h–9FFFh half (yielding 32 KB of completely mirror-free storage per 64 KB sector!).
Testing in openMSX and WebMSX
- Select
ASCII16-X(ASCII16X), never plainASCII16: InopenMSX, passing-romtype ASCII16mounts a pure read-only ROM mapper, causing every unlock sequence to be silently ignored. Always pass-romtype ASCII16-X(orASCII16X) when testing Flash saves. - Watch out for stock
openMSX’s full-chip.SRAMtrap during development: Once a Flash sector is modified, stockopenMSXpersists the entire cartridge Flash image inside itspersistent/folder. When you reassemble your game code and launch the updated.romagain, stockopenMSXoverlays the old full-chip save file—silently running yesterday’s code while hiding your new build! Either clear the persistent image on code rebuilds or use Max Iwamoto’s custom openMSX build, whose sparse.flashpersistence overlays only sectors touched by in-game saves while always loading fresh code and graphics from your current ROM. - The
F0hpayload/CRC byte quirk in incomplete emulators: On real AMD/ST silicon andopenMSX, onceA0h(byte program) is latched in cycle 3, cycle 4 treats any byte value00h–FFh—includingF0h—strictly as data to program. During Eggerland 4 testing (whereCRC-16bytes legitimately equalF0hroughly once every 256 saves), we found that some browser emulator Flash state machines (WebMSX) prematurely treated a cycle-4 data byte ofF0has a read-array reset command. Always include a test vector containingF0hin your automated save suite!
13. Proven save architectures & ROM packaging patterns
Because erasing a 64 KB NOR Flash sector takes roughly a full second and wears the oxide slightly (100,000 typical erase cycles), a good MSX save system minimizes erases, validates every record with a checksum, and survives unexpected power-off cleanly. Two designs cover nearly every MSX game:
Pattern A — Single-sector append-only journal (High scores, settings & passwords)
Used in Digger (16 × 256-byte Top-10 score tables in 4 KB) and Eggerland 4 (254 × 32-byte password records in 8 KB with a 32-byte 1 → 0 commit bitmap):
- Reserve one
64 KBsector (FFh-filled in the distributed ROM) and divide its safe8000h–9FFFhwindow into fixed-size records (32,64, or256bytes). - Include a
4-bytemagic tag, format version,16-bitsequence number (or commit bitmap), payload bytes,CRC-16/CCITT-FALSE(poly 1021h,init FFFFh), and a finalA5hcommit byte at the end of the record. - Skip unchanged saves: Compare the new state in RAM against the latest valid record first; if nothing changed, return success immediately without writing Flash.
- Program the payload & CRC first (
00h..FEh), and program theA5hcommit byte LAST (FFh): If power is cut mid-save, the incomplete record lacksA5h(or failsCRC-16) and the loader automatically falls back to the previous intact record! - Refuse to erase foreign data: Before erasing a full journal at rollover, verify that every non-record byte in the sector tail is
FFhand every used slot either carries your magic header or is a tornFFh-suffixed prefix. If another tool packed unrelated data into that64 KBblock, abort cleanly rather than erasing foreign bytes.
Pattern B — Dual-sector A/B ping-pong (Multi-kilobyte RPG state saves)
Used when a single save slot is several kilobytes (Illusion City, Xak III) and erasing a single sector at rollover would risk losing the player’s entire progress on power loss:
- Reserve two
64 KBsectors (Sector AandSector B) near the end of the ROM image. - Keep the active save(s) in
Sector AwhileSector Bremains erased (FFh). - When updating or compacting, write and read-back-verify the complete new image in
Sector Bfirst, then programSector B’s commit marker/sequence number last. - Only after
Sector Bis 100% verified and committed, erase oldSector Aso roles swap cleanly on the next save. At least one valid committed copy exists on Flash at every microsecond.
Packaging compact 128 KB games (ASCII16-X vs. 256 KB MFR / Carnivore2) & boot-skip keys
Large games (256 KB to 4 MB) can reserve 64 KB sectors inside one unified ROM image. For a compact 128 KB game like Digger, shipping two matched files from the exact same assembled payload gives the best of both worlds:
128 KBASCII16-Ximage: Uses two internal8 KBbottom-boot sectors (0C000hand0E000h, mapped individually into8000h–8FFFh/A000h–AFFFhwith6000hrestored on exit) so hardwareASCII16-Xbuilders only flash128 KB.256 KBASCII16 / MegaFlashROM / Carnivore2image: The exact same128 KBgame followed by two erased64 KBsectors (20000h–3FFFFh) plus a ready-made.RCPfile—detected automatically at runtime by_flash_detect!- Include a startup bypass key (such as holding
Sat reset): On a physicalASCII16-Xcartridge, the game boots immediately on power-up. Checking the keyboard matrix for a held bypass key (S) before initializing the game letsASCII16-Xowners boot straight through to MSX-DOS so they can re-flash updates withasciixf.comwithout hot-plugging cartridges!
14. Troubleshooting checklist
| Symptom | Root Cause & Fix |
|---|---|
| Game reports “Save OK,” yet nothing persists after reset | Classic DQ7 false positive on bytes 80h–FEh over erased FFh on a read-only cart! Add LD A,(DE) / CP (HL) read-back verification and _flash_detect (90h Autoselect). |
| MSX freezes solid during save or sector erase | Either interrupts (EI) were left enabled while banked ROM returned status bits, the writer ran from ROM instead of RAM, or _check_flash_status lacked a timeout on an ignored erase over 00h. |
| Saves fail on MegaFlashROM SCC+ SD | Flash the ROM with OPFXSD GAME.ROM /A16 /W (not RAM mode, and not without /W). Make sure the untrimmed ROM file includes its FFh save sectors. |
| Saves fail on Carnivore2—or break game startup | Program into Flash via C2MAN (not RAM mode), enable RnMult bit 4 (10h) on both Page 1 (4000h–7FFFh) and Page 2 (8000h–BFFFh), and edit the game’s *existing* .RCP so CardMDR mapper-RAM flags are preserved. |
Works on MFR / Carnivore2, fails or corrupts banks on ASCII16-X | Writes hit 6000h–6FFFh or mirrored A000h–BFFFh, switching Page 1 or Page 2 banks mid-command. Restrict Page 2 Flash writes to 8000h–9FFFh. |
Rebuilt ROM changes do not appear in openMSX | Stock openMSX’s full-chip .SRAM file in persistent/ is masking your newly built ROM. Delete the stale .SRAM file or use sparse .flash persistence. |
DQ5 error (Cy = 1) partway through programming | Attempted a 0 → 1 bit transition without erasing, or power/slot contact glitched. Check (old AND new) = new or append to a fresh FFh journal slot. |
| Saves fail in a browser emulator roughly 1 in 256 times | Check whether a payload or CRC-16 byte equalled F0h and triggered an emulator state-machine reset bug during byte-program cycle 4. |
References and further reading
- MSX Resource Center: ASCII-X FlashROM cartridge discussion — community debugging thread with Z80 routines and hardware notes by Max Iwamoto and Laurens Holst.
- ASCII16-X specification (Grauw) — full-quadrant register mirroring, Flash wiring, and
asciixf.comprogramming tool. - M29W640GB / M29W640GT datasheet —
8-bitbyte-mode0AAAh/0555hcommand bus cycles,DQ7/DQ5flowcharts, and bottom/top-boot sector maps. - MegaFlashROM SCC+ SD user manual —
OPFXSD /W, Flash block allocation, Nextor kernel, and recovery setup. - Carnivore2 technical specification — physical Flash block map,
RnMult/BnAdrDbank descriptors, andCardMDRregisters. - openMSX — Max Iwamoto rom-dev build — sparse
.flashdirty-sector persistence for active ROM development.
Originally published September 3, 2026 · Expanded and completed November 21, 2026 with production routines and hardware findings from Illusion City ROM 0.5, Xak III, Eggerland 4, and Digger, alongside contributions from Laurens Holst (Grauw), Manuel Pazos, and Carnivore2 documentation. Always test Flash-writing code against isolated emulator images before programming physical multi-ROM cartridges.