From c8dec417ff5d0a2336dcc0962ed261d195b11dce Mon Sep 17 00:00:00 2001 From: Brendan Saricks Date: Thu, 14 May 2026 14:30:54 -0500 Subject: [PATCH] Experimental fix for Treasure Island and Star Trek --- docs/format.md | 2 ++ docs/mister_migration.md | 6 +++++ docs/rom_generator.md | 2 +- rom generator/extraction/src/mame/inputs.ts | 27 +++++++++++++++++---- rom generator/extraction/src/mame/types.ts | 2 ++ rom generator/src/encode_format.rs | 2 ++ rom generator/src/manifest.rs | 2 ++ rtl/input_config.sv | 5 ++++ 8 files changed, 42 insertions(+), 6 deletions(-) diff --git a/docs/format.md b/docs/format.md index 9f49270..d2e4efe 100644 --- a/docs/format.md +++ b/docs/format.md @@ -93,6 +93,8 @@ The grounded input port is 0 when unset, and the 1-based index otherwise (so `"g | PowerOff | 27 | | Keypad | 28 | | Custom | 29 | +| CustomUpDown | 30 | +| CustomButtonHour | 31 | | Mark Unused | `0x7F` | ### Images diff --git a/docs/mister_migration.md b/docs/mister_migration.md index a767c29..b003d49 100644 --- a/docs/mister_migration.md +++ b/docs/mister_migration.md @@ -369,3 +369,9 @@ No `sys/` framework files were changed. - Added `tripleHorizontal` screen metadata so `sm511_tripleh(...)` titles such as Tronica Treasure Island can be represented by the ROM generator manifest. - Taught the extractor to handle Konami `ktmnt2`-derived constructors that call `ktmnt2(config)` and then replace the SVG screen size with `mcfg_svg_screen(...)`, covering `kst25` and `ktopgun2`. - Documented format value `0x3` for triple-horizontal packages. Konami external sample/ADPCM audio and MAME `IPT_CUSTOM` shared-button behavior remain separate core/input-scope issues; these changes make the titles representable in the manifest and generator. + +### 2026-05-14 non-keypad IPT_CUSTOM input mappings +- Split known non-keypad MAME `IPT_CUSTOM` lines into explicit package actions instead of treating every custom condition as one generic input. +- Added `CustomUpDown` for Konami Star Trek's shared Up/Down input and `CustomButtonHour` for Tronica Treasure Island's shared Start/Jump/Pick or Hour line. +- Updated `rtl/input_config.sv` so `CustomUpDown` maps to D-pad Up or Down and `CustomButtonHour` maps to Button1 on the existing controller layout. Generic `Custom` and keypad-derived custom inputs remain intentionally unhandled. +- Updated the local ignored `rom generator/manifest.json`; existing `.gnw` packages for affected games must be regenerated to carry the new action IDs. diff --git a/docs/rom_generator.md b/docs/rom_generator.md index 1a7c7b2..6b9b17c 100644 --- a/docs/rom_generator.md +++ b/docs/rom_generator.md @@ -44,7 +44,7 @@ cargo run --manifest-path "rom generator/Cargo.toml" --release --locked -- \ Make sure to replace the brackets with the actual paths to your files. The MAME path should be the folder that contains the `artwork` and `roms` folders. The output path must already exist. -The `supported` filter includes SM510, SM511, SM512, SM510 Tiger, and SM5a titles. For SM511/SM512 titles the generator pads the program ROM area to `0x1000` bytes and appends the 256 byte melody ROM automatically, matching the package layout documented in [Format](format.md). +The `supported` filter includes SM510, SM511, SM512, SM510 Tiger, and SM5a titles. Known non-keypad MAME `IPT_CUSTOM` shared inputs are converted into explicit `CustomUpDown` or `CustomButtonHour` actions when they fit the core controller layout. For SM511/SM512 titles the generator pads the program ROM area to `0x1000` bytes and appends the 256 byte melody ROM automatically, matching the package layout documented in [Format](format.md). You can also generate a single game, all of the games for a certain CPU, and more. diff --git a/rom generator/extraction/src/mame/inputs.ts b/rom generator/extraction/src/mame/inputs.ts index a1029dd..f55dcf3 100644 --- a/rom generator/extraction/src/mame/inputs.ts +++ b/rom generator/extraction/src/mame/inputs.ts @@ -89,8 +89,7 @@ export const parseInputs = ( ); const index = indexFromBit(bit); - const activeHigh = unparsedActive === "IP_ACTIVE_HIGH"; - const button = parseButton(unparsedButton); + const button = parseButton(unparsedButton, line); if (!button) { console.log( @@ -99,6 +98,9 @@ export const parseInputs = ( continue; } + const activeHigh = + unparsedActive === "IP_ACTIVE_HIGH" || button.startsWith("custom"); + if (!currentPort) { console.log( `Attempted to add button ${line} without port to device ${deviceName}` @@ -312,7 +314,7 @@ const nameInnerPort = (port: Port): string => { return port.type; }; -const parseButton = (button: string): Action | undefined => { +const parseButton = (button: string, line = ""): Action | undefined => { switch (button) { case "IPT_JOYSTICK_UP": return "joyUp"; @@ -383,9 +385,8 @@ const parseButton = (button: string): Action | undefined => { case "IPT_KEYPAD": return "keypad"; - // Custom cannot be handled in an automated way case "IPT_CUSTOM": - return "custom"; + return parseCustomButton(line); case "IPT_UNUSED": return "unused"; @@ -394,6 +395,22 @@ const parseButton = (button: string): Action | undefined => { return undefined; }; +const parseCustomButton = (line: string): Action => { + const normalizedLine = line.toLowerCase(); + + if (normalizedLine.includes("up/down")) { + return "customUpDown"; + } + + if (normalizedLine.includes("button/hour")) { + return "customButtonHour"; + } + + // Keypad and other game-specific custom inputs are intentionally left + // generic until the core has a preservation-friendly mapping for them. + return "custom"; +}; + const parsePortName = ( name: string, deviceName: string diff --git a/rom generator/extraction/src/mame/types.ts b/rom generator/extraction/src/mame/types.ts index dda61d4..1726acd 100644 --- a/rom generator/extraction/src/mame/types.ts +++ b/rom generator/extraction/src/mame/types.ts @@ -121,6 +121,8 @@ export type Action = // Keypad is not supported | "keypad" | "custom" + | "customUpDown" + | "customButtonHour" | "unused"; export interface NamedAction { diff --git a/rom generator/src/encode_format.rs b/rom generator/src/encode_format.rs index 357cfd4..ec43870 100644 --- a/rom generator/src/encode_format.rs +++ b/rom generator/src/encode_format.rs @@ -378,6 +378,8 @@ fn input_value_for_port(action: NamedAction) -> u8 { Action::PowerOff => 27, Action::Keypad => 28, Action::Custom => 29, + Action::CustomUpDown => 30, + Action::CustomButtonHour => 31, Action::Unused => 0x7F, }; diff --git a/rom generator/src/manifest.rs b/rom generator/src/manifest.rs index d88ccc9..ddd8909 100644 --- a/rom generator/src/manifest.rs +++ b/rom generator/src/manifest.rs @@ -156,5 +156,7 @@ pub enum Action { PowerOff, Keypad, Custom, + CustomUpDown, + CustomButtonHour, Unused, } diff --git a/rtl/input_config.sv b/rtl/input_config.sv index ca05d90..0c28eac 100644 --- a/rtl/input_config.sv +++ b/rtl/input_config.sv @@ -104,6 +104,11 @@ module input_config ( 23: out = button_y; 24: out = button_a; + // Explicit MAME IPT_CUSTOM mappings that fit the existing controller + // layout. Generic custom/keypad wiring remains unhandled. + 30: out = dpad_up || dpad_down; + 31: out = button_b; + // This input is unused 7'h7F: out = 0; // Other values unhandled