Module cards

Module cards 

Source
Expand description

HuCards: the standard ROM card, Street Fighter II’, Populous and Tennokoe (cards.py).

A card is on the CPU’s physical bus: PA20 is its chip enable, so it answers banks $00-$7F (the 1 MiB window = pages 0x0000-0x0FFF); there is no header (docs/cartridge.md). Mirroring of smaller images:

  • 384 KiB: the first 256 KiB fills banks $00-$3F twice, the last 128 KiB fills $40-$7F four times [emu: MAME pce_slot.cpp rom_map_setup 0 1 0 1 2 2 2 2; Mednafen huc.cpp].
  • 512 KiB: $00-$3F straight, $40-$7F the upper 256 KiB twice [emu: Mednafen; MAME generic].
  • other power-of-two sizes: mirrored to fill the window.
  • anything else (768 KiB, odd homebrew sizes): U18, provisional: banks repeat modulo the image.

All tier 3-4; confirmed only by games running.

Differences forced by Rust: the mapper cards hold a RomCard where the reference subclasses it; a card’s identity in a save state is the SHA-1 and length of its image, computed once when it is built (the reference hashes the bytes each time it saves); from_path is left to the caller (std::fs::read).

Structs§

PopulousCard
Populous: 32 KiB of battery RAM in banks $40-$43 (four 8 KiB banks, not mirrored); the rest as a plain card. [emu: Mednafen: detected by “POPULOUS” at $1F26; MAME pce_populous at $80000-$87FFF.] Power-up contents are Mednafen’s $FF (U7: arbitrary for a battery RAM).
RomCard
The standard HuCard: ROM only, mirrored to fill the window.
Sf2Card
Street Fighter II’ Champion Edition (2.5 MiB) and the larger homebrew form.
TennokoeCard
Tennokoe Bank: a 512 KiB HuCard with 8 KiB of backup RAM (four 2 KiB banks) at $80000-$81FFF of the card’s space (banks $40, mirrored through the 64 KiB up to $8FFFF), locked at power-up (reads $FF, writes ignored); a write of a non-zero value anywhere in $F0000-$FFFFF unlocks it, a zero locks it. [emu: MAME pce_tennokoe, whose own comment calls the lock “a complete guess” (U29, tier 5); none in the library, so only unit-tested.]

Constants§

BANK
COPIER_HEADER
SF2_FIXED
SF2_THRESHOLD
[emu: Mednafen huc.cpp sf2_threshold] an image this big has the mapper
WINDOW_BANKS

Functions§

bank_map
For each of the 128 banks of the window, which 8 KiB bank of the image answers.
make_card
The card an image is: SF2 from 2 MiB up (Mednafen’s threshold), Populous by its title string at $1F26, else a plain ROM. Tennokoe has no detection (no header): build it explicitly.
strip_copier_header
A 512-byte copier header is the only thing to strip (size mod 8192 = 512).