From aac8b30bcee90a3dd4e08af7e2175e4c55c63617 Mon Sep 17 00:00:00 2001 From: Flyinghead Date: Sun, 26 Apr 2020 11:32:15 +0200 Subject: [PATCH] naomi: fake wrungp drive board. marine fishing inputs set jvs board for dog walking and touch de uno force region to japan for the same --- core/hw/maple/maple_devs.cpp | 86 +++++++++++++++++++++++++++++++- core/hw/naomi/naomi_roms.h | 8 +-- core/hw/naomi/naomi_roms_input.h | 17 +++++++ core/nullDC.cpp | 28 ++++++++--- core/types.h | 1 + 5 files changed, 129 insertions(+), 11 deletions(-) diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index 699c45ca7..40e3d4d3d 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -1504,6 +1504,7 @@ protected: } return buttons; } + virtual void write_digital_out(int count, u8 *data) { } u32 player_count = 0; u32 digital_in_count = 0; @@ -1580,7 +1581,7 @@ protected: }; -// Sega Marine Fishing +// Sega Marine Fishing, 18 Wheeler (TODO) class jvs_837_13844 : public jvs_io_board { public: @@ -1591,7 +1592,7 @@ public: coin_input_count = 2; digital_in_count = 12; analog_count = 8; - output_count = 16; + output_count = 22; } protected: virtual const char *get_id() override { return "SEGA ENTERPRISES,LTD.;837-13844-01 I/O CNTL BD2 ;Ver1.00;99/07"; } @@ -1619,6 +1620,82 @@ public: } }; +// Wave Runner GP: fake the drive board +class jvs_837_13844_wrungp : public jvs_837_13844 +{ +public: + jvs_837_13844_wrungp(u8 node_id, maple_naomi_jamma *parent, int first_player = 0) + : jvs_837_13844(node_id, parent, first_player) + { + } +protected: + virtual u32 read_digital_in(int player_num) override { + u32 rv = jvs_837_13844::read_digital_in(player_num); + + // The drive board RX0-7 is connected to the following player inputs + if (player_num == 0) + { + rv |= NAOMI_BTN2_KEY | NAOMI_BTN3_KEY | NAOMI_BTN4_KEY | NAOMI_BTN5_KEY; + if (drive_board & 16) + rv &= ~NAOMI_BTN5_KEY; + if (drive_board & 32) + rv &= ~NAOMI_BTN4_KEY; + if (drive_board & 64) + rv &= ~NAOMI_BTN3_KEY; + if (drive_board & 128) + rv &= ~NAOMI_BTN2_KEY; + } + else if (player_num == 1) + { + rv |= NAOMI_BTN2_KEY | NAOMI_BTN3_KEY | NAOMI_BTN4_KEY | NAOMI_BTN5_KEY; + if (drive_board & 1) + rv &= ~NAOMI_BTN5_KEY; + if (drive_board & 2) + rv &= ~NAOMI_BTN4_KEY; + if (drive_board & 4) + rv &= ~NAOMI_BTN3_KEY; + if (drive_board & 8) + rv &= ~NAOMI_BTN2_KEY; + } + return rv; + } + + virtual void write_digital_out(int count, u8 *data) override { + if (count != 3) + return; + + // The drive board TX0-7 is connected to outputs 15-22 + // shifting right by 2 to get the last 8 bits of the output + u16 out = (data[1] << 6) | (data[2] >> 2); + // reverse + out = (out & 0xF0) >> 4 | (out & 0x0F) << 4; + out = (out & 0xCC) >> 2 | (out & 0x33) << 2; + out = (out & 0xAA) >> 1 | (out & 0x55) << 1; + + if (out == 0xff) + drive_board = 0xff; + else if ((out & 0xf) == 0xf) + { + out >>= 4; + if (out > 7) + drive_board = 0xff & ~(1 << (14 - out)); + else + drive_board = 0xff & ~(1 << out); + } + else if ((out & 0xf0) == 0xf0) + { + out &= 0xf; + if (out > 7) + drive_board = 0xff & ~(1 << (out - 7)); + else + drive_board = 0xff & ~(1 << (7 - out)); + } + } + +private: + u8 drive_board = 0; +}; + // Ninja assault class jvs_namco_jyu : public jvs_io_board { @@ -1896,6 +1973,9 @@ struct maple_naomi_jamma : maple_sega_controller case JVS::WorldKicksPCB: io_boards.emplace_back(new jvs_namco_v226_pcb(1, this)); break; + case JVS::WaveRunnerGP: + io_boards.emplace_back(new jvs_837_13844_wrungp(1, this)); + break; } } virtual ~maple_naomi_jamma() @@ -2796,6 +2876,8 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou case 0x32: // switched outputs case 0x33: + LOGJVS("output(%d) %x", buffer_in[cmdi + 1], buffer_in[cmdi + 2]); + write_digital_out(buffer_in[cmdi + 1], &buffer_in[cmdi + 2]); JVS_STATUS1(); // report byte cmdi += buffer_in[cmdi + 1] + 2; break; diff --git a/core/hw/naomi/naomi_roms.h b/core/hw/naomi/naomi_roms.h index f3db5e3dd..33830caa8 100644 --- a/core/hw/naomi/naomi_roms.h +++ b/core/hw/naomi/naomi_roms.h @@ -2202,7 +2202,7 @@ Games[] = 0x294bc3e3, NULL, M2, - REGION_AUSTRALIA, + REGION_JAPAN, ROT0, { { "epr-22294a.ic22", 0x0000000, 0x400000 }, @@ -3322,7 +3322,9 @@ Games[] = { "mpr-22218.ic11", 0x5800000, 0x0800000 }, { "mpr-22219.ic12s", 0x6000000, 0x0800000 }, { NULL, 0, 0 }, - } + }, + NULL, + &marine_fishing_inputs, }, // Spawn In the Demon's Hand (JPN, USA, EUR, ASI, AUS) (Rev B) { @@ -3465,7 +3467,7 @@ Games[] = 0x28028ea5, NULL, M2, - REGION_AUSTRALIA, + REGION_JAPAN, ROT0, { //ROM_REGION16_BE( 0x80, "main_eeprom", 0 ) diff --git a/core/hw/naomi/naomi_roms_input.h b/core/hw/naomi/naomi_roms_input.h index 9ef77600e..a8373edd4 100644 --- a/core/hw/naomi/naomi_roms_input.h +++ b/core/hw/naomi/naomi_roms_input.h @@ -379,6 +379,23 @@ static InputDescriptors wrungp_inputs = { }, }; +static InputDescriptors marine_fishing_inputs = { + { + { NAOMI_START_KEY, "CAST" }, + { NAOMI_UP_KEY, "LURE" }, + NAO_BASE_BTN_DESC + { 0 }, + }, + { + { "ROD Y", Full, 1 }, + { "ROD X", Full, 0 }, + { "STICK X", Full, 2 }, + { "STICK Y", Full, 3 }, + { "REEL SPEED", Half, 0 }, + { NULL }, + }, +}; + // // AtomisWave games // diff --git a/core/nullDC.cpp b/core/nullDC.cpp index 7ee95b6dd..0ff8ed631 100755 --- a/core/nullDC.cpp +++ b/core/nullDC.cpp @@ -323,6 +323,13 @@ static void LoadSpecialSettings() settings.rend.ExtraDepthScale = 1e26; extra_depth_game = true; } + if (!strcmp("COSMIC SMASH IN JAPAN", naomi_game_id)) + { + INFO_LOG(BOOT, "Enabling translucent depth multipass for game %s", naomi_game_id); + settings.rend.TranslucentPolygonDepthMask = true; + tr_poly_depth_mask_game = true; + } + // Input configuration if (!strcmp("DYNAMIC GOLF", naomi_game_id) || !strcmp("SHOOTOUT POOL", naomi_game_id) || !strcmp("SHOOTOUT POOL MEDAL", naomi_game_id) @@ -392,12 +399,6 @@ static void LoadSpecialSettings() INFO_LOG(BOOT, "Enabling JVS rotary encoders for game %s", naomi_game_id); settings.input.JammaSetup = JVS::OutTrigger; } - else if (!strcmp("COSMIC SMASH IN JAPAN", naomi_game_id)) - { - INFO_LOG(BOOT, "Enabling translucent depth multipass for game %s", naomi_game_id); - settings.rend.TranslucentPolygonDepthMask = true; - tr_poly_depth_mask_game = true; - } else if (!strcmp(naomi_game_id, "THE MAZE OF THE KINGS") || !strcmp(naomi_game_id, " CONFIDENTIAL MISSION ---------") || !strcmp(naomi_game_id, "DEATH CRIMSON OX") @@ -406,6 +407,21 @@ static void LoadSpecialSettings() INFO_LOG(BOOT, "Enabling lightgun as analog setup for game %s", naomi_game_id); settings.input.JammaSetup = JVS::LightGunAsAnalog; } + else if (!strcmp("WAVE RUNNER GP", naomi_game_id)) + { + INFO_LOG(BOOT, "Enabling specific JVS setup for game %s", naomi_game_id); + settings.input.JammaSetup = JVS::WaveRunnerGP; + } + else if (!strcmp("INU NO OSANPO", naomi_game_id)) // Dog Walking + { + INFO_LOG(BOOT, "Enabling specific JVS setup for game %s", naomi_game_id); + settings.input.JammaSetup = JVS::DogWalking; + } + else if (!strcmp(" TOUCH DE UNOH -------------", naomi_game_id)) + { + INFO_LOG(BOOT, "Enabling specific JVS setup for game %s", naomi_game_id); + settings.input.JammaSetup = JVS::TouchDeUno; + } settings.rend.Rotate90 = naomi_rotate_screen; } } diff --git a/core/types.h b/core/types.h index bb3495d99..cb8a363d4 100644 --- a/core/types.h +++ b/core/types.h @@ -346,6 +346,7 @@ enum class JVS { Keyboard, OutTrigger, LightGunAsAnalog, + WaveRunnerGP, }; struct settings_t