Drop several per-mapper OSD force options and unify Zemina-family handling.
- Update SMS.sv config string to label the mapper selection as "Zemina/MSX".
- Remove individual force wires for MSX, Nemesis1, Nemesis2, 4-PAK, Castle and Wonderkid; map Zemina to cover MSX/Nemesis II+/Zemina.
- Simplify system instantiation to remove now-unused mapper force signals.
- Update rtl/system.vhd: remove corresponding entity ports, simplify mapper_manual_force and use_zem logic, adjust boot/init paths and detection conditions (nemesis/zemina/wonderkid handling), and update a process sensitivity list to reflect removed signals.
These changes simplify mapper override handling by consolidating identical mappers and removing obsolete OSD override signals and related special-case logic.
Co-authored-by: Fabricio Breve <7475908+fbreve@users.noreply.github.com>
* Add all mappers to the OSD option.
Add all mappers to the 'Mapper' OSD menu. This allows users to manually select a mapper for unknown ROMs that are not automatically detected via CRC or heuristics.
Expose additional mapper choices in the OSD and wire them through to the system logic. SMS.sv: expand CONF_STR mapper entry, extract status[48:45] into mapper_sel and generate individual mapper_force signals; pass those signals into the system instance. rtl/system.vhd: add new mapper_*_force ports, introduce mapper_manual_force (OR of all manual-force signals), and update reset/initialization and write-detection logic to respect manual forcing (affects nem_bank0 init, 4-PAK detection, codies clearing, and mapper selection). Also update mapper detection assignments (castle, wonderkid, linear, dahjee, use_zem) to allow OSD-forced behavior while preserving CRC/auto-detection fallbacks.
* Fix Codemasters regression introduced by Super Boy I/II VDP fix
Remove unused xmode_M2/smode_M2 signals from the vdp->vdp_main->vdp_background
port chain. The signal was added in commit 3e39e1a but never consumed inside
vdp_background, causing a Quartus synthesis artifact that broke Codemasters
games (Micro Machines, Fantastic Dizzy) while other Mode 4 games remained fine.
Also restore correct legacy TMS9918 data pipeline timing in vdp_background:
- datac captured at x=011 (pattern byte), render at x=100 (color byte)
- Matches the pre-3e39e1a behavior, fixing Super Boy I/II as well
- Preserves SC-3000 text mode and Graphics I/II address pipeline
Connect smode_M2 to the video module in SMS.sv so that 224-line and
240-line mode games get correct vertical counter wrapping.
* Mapper heuristics: auto-detect Castle/Dahjee-A/Nemesis/Zemina
Add heuristic detection for mappers that were previously only selectable via OSD or detected by CRC:
- Castle (32KB ROM heuristic based on mirroring)
- Dahjee Type A (preamble detection)
- Nemesis/Korean 1 and 2 (page-0 / last-page blank test)
- Zemina 16KB (header byte detection)
* Remove mappers used by single games from the OSD option
Remove rarely-used mapper options from the OSD config string (drop 4-PAK, Castle, Nemesis I, Wonder Kid) and compact remaining mapper IDs. Reassign mapper force signals to match the new indices (Codies→2, Dahjee A→3, Linear→4, MSX→5, Nemesis II+→6, Zemina→7).
* Bugfix: Wonder Kid would not load when BIOS is in use
Apply Wonder Kid initialization on BIOS→cartridge handoff when the mapper is auto‑detected.
Ensures correct startup for Wonder Kid ROMs when a BIOS is enabled (including Japanese BIOS). No change to other mappers or OSD options.
---------
Co-authored-by: Fabricio Breve <7475908+fbreve@users.noreply.github.com>
* Clear bk_pending when download starts
Add explicit check to clear bk_pending on the transition into downloading (~old_downloading & downloading). This prevents a lingering backup-pending flag when a new download begins while preserving the existing logic that sets bk_pending on bk_ena && ~OSD_STATUS && bk_save_write and clears it when bk_state is active. Change applied in SMS.sv.
* Add Meka mapper 11 and Dahjee Type A expansion
Introduce support for MEKA mapper 11 and Dahjee Type A expansion.
New Master System games supported:
- FA Tetris (Korea) (Unl)
- Flashpoint (Korea) (Unl)
New SG-1000 games supported:
- Rally-X (Taiwan) (Chinese Logo) (Unl)
- Rally-X (Taiwan) (English Logo) (Unl)
- Road Fighter (Taiwan) (Chinese Logo) (Unl)
- Road Fighter (Taiwan) (English Logo) (Unl)
Also add CRC-based for 4 PAK All Action (Australia) (Unl).
Changes include:
- Added signals: mapper_4pak_crc, mapper_linear, mapper_sega_locked, mapper_dahjee_a.
- Implemented CRC matches for several carts (linear/MEKA type 11 and Dahjee Type A), and set mapper_4pak via CRC (0x73ED) at reset instead of purely write-based auto-detect.
- Added mapper_linear branch: linear ROM addressing for specific 32KB games.
- Added mapper_sega_locked mode to keep Sega mapper path but block bank writes for 48KB dahjee_typeb games (works around FPGA boot/logo issues).
- Added mapper_dahjee_a: supports linear ROM with 8KB RAM at 0x2000-0x3FFF; adjusted nvram addressing and read paths so that that area reads/writes use the nvram block.
- Updated rom_RD gating and I/O/data mux logic to account for Dahjee Type A and linear mapper cases.
- Updated rom_a_i generation to include sc3000_en, mapper_linear, and mapper_dahjee_a linear-addressing behavior.
- Minor comment and formatting clarifications around mapper selection and OSD mapper lock/force behavior.
These changes enable proper behavior for several regional/unlabeled cartridges and fix boot issues on physical FPGA targets by selecting the correct mapping path and protecting bank registers when required.
* 3 new SG-1000 games supported; Restrict Survivors auto-detect; add ROM CRCs
3 new SG-1000 games supported:
- Castle, The (Taiwan) (Unl)
- Magical Kid Wiz (Taiwan) (Unl)
- Bomberman Special (Taiwan) (Chinese Logo)
Limit Survivors multicart/megacart auto-detection to explicit .sc loads (prevent .sg palette-only downloads from enabling paging) and update related comments. Add CRC entries for Taiwanese releases to improve mapper detection: The Castle (0xF6EE) and Magical Kid Wiz (0xD935) to mapper_linear, and Bomberman Special (0x683D) to mapper_dahjee_a.
---------
Co-authored-by: Fabricio Breve <7475908+fbreve@users.noreply.github.com>
* Clear bk_pending when download starts
Add explicit check to clear bk_pending on the transition into downloading (~old_downloading & downloading). This prevents a lingering backup-pending flag when a new download begins while preserving the existing logic that sets bk_pending on bk_ena && ~OSD_STATUS && bk_save_write and clears it when bk_state is active. Change applied in SMS.sv.
* Add Meka mapper 11 and Dahjee Type A expansion
Introduce support for MEKA mapper 11 and Dahjee Type A expansion.
New Master System games supported:
- FA Tetris (Korea) (Unl)
- Flashpoint (Korea) (Unl)
New SG-1000 games supported:
- Rally-X (Taiwan) (Chinese Logo) (Unl)
- Rally-X (Taiwan) (English Logo) (Unl)
- Road Fighter (Taiwan) (Chinese Logo) (Unl)
- Road Fighter (Taiwan) (English Logo) (Unl)
Also add CRC-based for 4 PAK All Action (Australia) (Unl).
Changes include:
- Added signals: mapper_4pak_crc, mapper_linear, mapper_sega_locked, mapper_dahjee_a.
- Implemented CRC matches for several carts (linear/MEKA type 11 and Dahjee Type A), and set mapper_4pak via CRC (0x73ED) at reset instead of purely write-based auto-detect.
- Added mapper_linear branch: linear ROM addressing for specific 32KB games.
- Added mapper_sega_locked mode to keep Sega mapper path but block bank writes for 48KB dahjee_typeb games (works around FPGA boot/logo issues).
- Added mapper_dahjee_a: supports linear ROM with 8KB RAM at 0x2000-0x3FFF; adjusted nvram addressing and read paths so that that area reads/writes use the nvram block.
- Updated rom_RD gating and I/O/data mux logic to account for Dahjee Type A and linear mapper cases.
- Updated rom_a_i generation to include sc3000_en, mapper_linear, and mapper_dahjee_a linear-addressing behavior.
- Minor comment and formatting clarifications around mapper selection and OSD mapper lock/force behavior.
These changes enable proper behavior for several regional/unlabeled cartridges and fix boot issues on physical FPGA targets by selecting the correct mapping path and protecting bank registers when required.
---------
Co-authored-by: Fabricio Breve <7475908+fbreve@users.noreply.github.com>
rtl/system.vhd: add support for the Wonder Kid [Proto] mapper (Codemasters-style 16KB). Introduces signal mapper_wonderkid and CRC detection (0x8613). Prevents MSX mapper selection when Wonder Kid is detected, and on RESET_n rising initializes banks to page 0 and pre-locks mapper B to avoid 4-PAK misdetection. Includes explanatory comments for the new mapper behavior.
Introduce mapper_castle signal and CRC detection (CRC16-CCITT 0xEF38) for The Castle (Japan) SG-1000 cartridge. Treat The Castle as a 32KB cart with 32KB RAM at 0x8000-0xFFFF by updating sc_cart_ram_32k/sc_cart_ram_low, nvram addressing, and ROM read gating (prevent ROM reads when Castle RAM is mapped into the upper half). Also exclude the Castle mapper from System E / SC-3000 mapper handling and add explanatory comments.
* Added support for loading Master System BIOS files.
Master System BIOS files can now be used to boot games and play built-in titles.
* Fix lightgun position calculation for vertical aim
The Master System core exhibited a vertical aim deviation with the lightgun, even when properly calibrated.
The offset was zero at the top of the screen but increased progressively toward the bottom.
This commit corrects the lightgun position calculation logic, ensuring accurate aiming across the full vertical range of the screen.
* Implement Soft Reset (Console Reset Button) via OSD and Controller
- Added a "Soft Reset" option to the OSD menu.
- Implemented falling-edge triggering for the OSD reset to ensure the pulse fires after the menu closes.
- Added a ~37ms pulse stretcher to guarantee the Z80 CPU polling loop detects the reset press.
- Mapped the controller 'Select' button to trigger the Soft Reset signal.
- Routed the signal to I/O port $DD bit 4 (active-low), matching the physical reset button behavior on original SMS hardware.
- Improves compatibility and usability for games that utilize the reset button to return to the title screen or menu.
* VDP: Fix legacy modes (Super Boy I/II) while maintaining Mode 4 compatibility
vdp_background.vhd: Refactor legacy mode (Graphics I, II, Text) rendering logic to fix Super Boy I and II.
Correct VRAM addressing for Graphics II (Mode 2) to properly handle banked pattern and color tables.
vdp_main.vhd: Ensure vertical scroll wrapping remains correct for Mode 4. This prevents graphical regressions in titles like After Burner (SMS) and Fray (GG).
vdp.vhd: Add smode_M2 signal to propagate mode bits for proper legacy mode decoding.
video.vhd: Refine high-resolution (224/240 line) timing detection logic.
* add 4-Pak All Action + Zemina mapper support
Implemented 4-Pak All Action (mapper 14) and Zemina (SMS Korean MSX-type 8KB banks, mapper 12) mappers.
The following games are now properly supported:
- 4 PAK All Action (Australia) (Unl)
- F-1 Spirit - The Way to Formula-1
- Knightmare II: The Maze of Galious
- Nemesis
- Nemesis II
- Penguin Adventure
Mapper 12 had partial support before, but only ROMs starting with bytes "41 42" were detected. The newly supported ROMs (except Nemesis) start with "F3 C3". This pattern cannot be used for detection because it is also present in some games that use the Sega mapper.
To improve detection, a CRC16-CCITT is computed over the last 8KB block during ROM loading. Since this method may fail for translations, hacks, or modified ROMs, an OSD option is available to manually force the Zemina mapper.
The new "Mapper" option replaces the previous "Disable Mappers" setting. It defaults to "Auto" (equivalent to the previous "Off"). The other options are "Sega" (previous "On") and "Zemina" (new).
Nemesis is a special case: it uses the Zemina mapper but initially reads from the last 8KB page. The CRC16-CCITT is also used to detect and handle this case.
---------
Co-authored-by: Fabricio Breve <7475908+fbreve@users.noreply.github.com>
* Added support for loading Master System BIOS files.
Master System BIOS files can now be used to boot games and play built-in titles.
* Fix lightgun position calculation for vertical aim
The Master System core exhibited a vertical aim deviation with the lightgun, even when properly calibrated.
The offset was zero at the top of the screen but increased progressively toward the bottom.
This commit corrects the lightgun position calculation logic, ensuring accurate aiming across the full vertical range of the screen.
* Implement Soft Reset (Console Reset Button) via OSD and Controller
- Added a "Soft Reset" option to the OSD menu.
- Implemented falling-edge triggering for the OSD reset to ensure the pulse fires after the menu closes.
- Added a ~37ms pulse stretcher to guarantee the Z80 CPU polling loop detects the reset press.
- Mapped the controller 'Select' button to trigger the Soft Reset signal.
- Routed the signal to I/O port $DD bit 4 (active-low), matching the physical reset button behavior on original SMS hardware.
- Improves compatibility and usability for games that utilize the reset button to return to the title screen or menu.
* VDP: Fix legacy modes (Super Boy I/II) while maintaining Mode 4 compatibility
vdp_background.vhd: Refactor legacy mode (Graphics I, II, Text) rendering logic to fix Super Boy I and II.
Correct VRAM addressing for Graphics II (Mode 2) to properly handle banked pattern and color tables.
vdp_main.vhd: Ensure vertical scroll wrapping remains correct for Mode 4. This prevents graphical regressions in titles like After Burner (SMS) and Fray (GG).
vdp.vhd: Add smode_M2 signal to propagate mode bits for proper legacy mode decoding.
video.vhd: Refine high-resolution (224/240 line) timing detection logic.
---------
Co-authored-by: Fabricio Breve <7475908+fbreve@users.noreply.github.com>
* Added support for loading Master System BIOS files.
Master System BIOS files can now be used to boot games and play built-in titles.
* Fix lightgun position calculation for vertical aim
The Master System core exhibited a vertical aim deviation with the lightgun, even when properly calibrated.
The offset was zero at the top of the screen but increased progressively toward the bottom.
This commit corrects the lightgun position calculation logic, ensuring accurate aiming across the full vertical range of the screen.
* Implement Soft Reset (Console Reset Button) via OSD and Controller
- Added a "Soft Reset" option to the OSD menu.
- Implemented falling-edge triggering for the OSD reset to ensure the pulse fires after the menu closes.
- Added a ~37ms pulse stretcher to guarantee the Z80 CPU polling loop detects the reset press.
- Mapped the controller 'Select' button to trigger the Soft Reset signal.
- Routed the signal to I/O port $DD bit 4 (active-low), matching the physical reset button behavior on original SMS hardware.
- Improves compatibility and usability for games that utilize the reset button to return to the title screen or menu.
---------
Co-authored-by: Fabricio Breve <7475908+fbreve@users.noreply.github.com>
* Added support for loading Master System BIOS files.
Master System BIOS files can now be used to boot games and play built-in titles.
* Fix lightgun position calculation for vertical aim
The Master System core exhibited a vertical aim deviation with the lightgun, even when properly calibrated.
The offset was zero at the top of the screen but increased progressively toward the bottom.
This commit corrects the lightgun position calculation logic, ensuring accurate aiming across the full vertical range of the screen.
Also reworked aspect ratio because the nested ternaries were getting pretty long. This is easier to read for most people with the new combinatorial block instead.
* Made Autosave function the same as NES core (but left the toggle default state the same).
* Made it so people can enable Autosave even if the game does not support saving, just like NES and other cores.
* Column masking shouldn't be disabled, ran into issues with some SMS and GG games.
* Removed trailing whitespaces in emu module
* Fixed my mistaken indentation of the gg wire assignment on, I didn't notice that it was a single line concurrent assignment above.
* In system.vhd the signal vdp_y1 is unused, already talked to greyrogue about it. Gets rid of a warning message.
There are 256x240 resolution games, the forced cropping prevented the full resolution of these 4 games from being shown:
Cosmic Spacehead
The Excellent Dizzy Collection
Fantastic Dizzy
Micro Machines
https://www.smspower.org/Tags/Extra-Height
Technically, `Clk’event and clk = ‘1’` can result in non-`0` triggers (e.g. `1`, `U`, `H`, `X`, `Z`, `W`, etc...), whereas `rising_edge(clk)` does not.
When Game Gear is active the border and the column mask don't do anything anyways, and the inverse is true when an SMS or Sega System E game is loaded regarding the game gear resolution option.