naomi2: FFB support for Club Kart and King of Route 66

This commit is contained in:
Flyinghead 2023-03-04 17:45:53 +01:00
parent 192bbb715e
commit c4d24254db
7 changed files with 72 additions and 10 deletions

View File

@ -450,6 +450,12 @@ void CheatManager::reset(const std::string& gameId)
cheats.emplace_back(Cheat::Type::setValue, "fix boot", true, 32, 0x00010000, 0x9302d202);
cheats.back().builtIn = true;
}
else if (gameId == "THE KING OF ROUTE66")
{
setActive(true);
cheats.emplace_back(Cheat::Type::setValue, "ignore drive error", true, 32, 0x00023ee0, 0x0009000B); // rts, nop
cheats.back().builtIn = true;
}
}
if (config::WidescreenGameHacks)
{

View File

@ -538,7 +538,8 @@ static u8 aw_maple_devs;
static u64 coin_chute_time[4];
static u8 awDigitalOuput;
u32 libExtDevice_ReadMem_A0_006(u32 addr,u32 size) {
u32 libExtDevice_ReadMem_A0_006(u32 addr, u32 size)
{
addr &= 0x7ff;
//printf("libExtDevice_ReadMem_A0_006 %d@%08x: %x\n", size, addr, mem600[addr]);
switch (addr)
@ -600,7 +601,8 @@ u32 libExtDevice_ReadMem_A0_006(u32 addr,u32 size) {
return 0xFF;
}
void libExtDevice_WriteMem_A0_006(u32 addr,u32 data,u32 size) {
void libExtDevice_WriteMem_A0_006(u32 addr, u32 data, u32 size)
{
addr &= 0x7ff;
//printf("libExtDevice_WriteMem_A0_006 %d@%08x: %x\n", size, addr, data);
switch (addr)
@ -640,6 +642,8 @@ void libExtDevice_WriteMem_A0_006(u32 addr,u32 data,u32 size) {
INFO_LOG(NAOMI, "Unhandled write @ %x (%d): %x", addr, size, data);
}
static bool ffbCalibrating;
void naomi_Serialize(Serializer& ser)
{
ser << GSerialBuffer;
@ -671,6 +675,7 @@ void naomi_Serialize(Serializer& ser)
ser << midiTxBuf;
ser << midiTxBufIndex;
// TODO serialize m3comm?
ser << ffbCalibrating;
}
void naomi_Deserialize(Deserializer& deser)
{
@ -715,6 +720,10 @@ void naomi_Deserialize(Deserializer& deser)
{
midiTxBufIndex = 0;
}
if (deser.version() >= Deserializer::V34)
deser >> ffbCalibrating;
else
ffbCalibrating = false;
}
static void midiSend(u8 b1, u8 b2, u8 b3)
@ -738,16 +747,18 @@ static void forceFeedbackMidiReceiver(u8 data)
if (midiTxBuf[0] == 0x84)
torque = ((midiTxBuf[1] << 7) | midiTxBuf[2]) - 0x80;
else if (midiTxBuf[0] == 0xff)
{
torque = 0;
position = 8192;
}
ffbCalibrating = true;
else if (midiTxBuf[0] == 0xf0)
ffbCalibrating = false;
if (!ffbCalibrating)
position = std::clamp(-mapleInputState[0].fullAxes[0] * 64.f + 8192.f, 0.f, 16383.f);
// required: b1 & 0x1f == 0x10 && b1 & 0x40 == 0
midiSend(0x90, ((int)position >> 7) & 0x7f, (int)position & 0x7f);
// decoding from FFB Arcade Plugin (by Boomslangnz)
// https://github.com/Boomslangnz/FFBArcadePlugin/blob/master/Game%20Files/Demul.cpp
if (midiTxBuf[0] == 0x85 && midiTxBuf[1] == 0x3f)
if (midiTxBuf[0] == 0x85)
MapleConfigMap::UpdateVibration(0, std::max(0.f, (float)(midiTxBuf[2] - 1) / 24.f), 0.f, 5);
if (midiTxBuf[0] != 0xfd)
networkOutput.output("midiffb", (midiTxBuf[0] << 16) | (midiTxBuf[1]) << 8 | midiTxBuf[2]);

View File

@ -614,7 +614,9 @@ void naomi_cart_LoadRom(const char* file, LoadProgress *progress)
{
atomiswaveForceFeedback = true;
}
else if (gameId == "SAMPLE GAME MAX LONG NAME-") // Driving Simulator
else if (gameId == "THE KING OF ROUTE66"
|| gameId == "CLUB KART IN JAPAN"
|| gameId == "SAMPLE GAME MAX LONG NAME-") // Driving Simulator
{
initMidiForceFeedback();
}

View File

@ -6709,6 +6709,7 @@ const Game Games[] =
},
nullptr,
&kingrt66_inputs,
kingrt66_eeprom_dump,
},
{
"kingrt66p",
@ -6830,6 +6831,7 @@ const Game Games[] =
},
nullptr,
&clubkart_inputs,
clubkrt_eeprom_dump,
},
{
"clubkrta",
@ -6856,6 +6858,7 @@ const Game Games[] =
},
nullptr,
&clubkart_inputs,
clubkrt_eeprom_dump,
},
{
"clubkrtc",
@ -6882,6 +6885,7 @@ const Game Games[] =
},
nullptr,
&clubkart_inputs,
clubkrt_eeprom_dump,
},
{
"clubkrt",
@ -6908,6 +6912,7 @@ const Game Games[] =
},
nullptr,
&clubkart_inputs,
clubkrt_eeprom_dump,
},
{
"clubkprz",
@ -7006,6 +7011,7 @@ const Game Games[] =
},
nullptr,
&clubkart_inputs,
clubk2k3_eeprom_dump,
},
{
"clubk2kp",

View File

@ -618,4 +618,40 @@ static u8 tduno2_eeprom_dump[] {
0x63, 0x46,
};
// card reader disabled
static u8 clubkrt_eeprom_dump[] {
0x95, 0x95, 0x10, 0x42, 0x44, 0x42, 0x31, 0x09, 0x00, 0x1A, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x95, 0x95, 0x10, 0x42, 0x44, 0x42, 0x31, 0x09, 0x00, 0x1A, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x0C, 0xBA, 0x20, 0x20, 0x0C, 0xBA, 0x20, 0x20, 0x25, 0x52, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0xC0, 0x30, 0xC0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x02, 0x00, 0x00, 0x25, 0x52, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x30,
0xC0, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
// card reader disabled
static u8 clubk2k3_eeprom_dump[] {
0x73, 0x25, 0x10, 0x42, 0x48, 0x4C, 0x30, 0x09, 0x00, 0x1A, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x73, 0x25, 0x10, 0x42, 0x48, 0x4C, 0x30, 0x09, 0x00, 0x1A, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x13, 0x67, 0x20, 0x20, 0x13, 0x67, 0x20, 0x20, 0x25, 0x52, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x30, 0xC0, 0x30, 0xC0, 0xC8, 0x40, 0x00, 0x92, 0x01, 0x1E, 0x0A, 0xD0, 0x07, 0x00, 0x00, 0x00, 0x00,
0xC0, 0xA8, 0x01, 0x01, 0x25, 0x52, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xC0, 0x30,
0xC0, 0xC8, 0x40, 0x00, 0x92, 0x01, 0x1E, 0x0A, 0xD0, 0x07, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xA8, 0x01, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
// cb-mic disabled
static u8 kingrt66_eeprom_dump[] {
0x15, 0xF8, 0x10, 0x42, 0x45, 0x45, 0x30, 0x09, 0x00, 0x1A, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x15, 0xF8, 0x10, 0x42, 0x45, 0x45, 0x30, 0x09, 0x00, 0x1A, 0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x11,
0x38, 0xA2, 0x24, 0x24, 0x38, 0xA2, 0x24, 0x24, 0x17, 0x05, 0x01, 0x00, 0x4B, 0x4F, 0x52, 0x36, 0x36, 0x00,
0x76, 0x98, 0x32, 0x54, 0x98, 0x10, 0x12, 0x45, 0x01, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80,
0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x17, 0x05, 0x01, 0x00, 0x4B, 0x4F, 0x52, 0x36, 0x36, 0x00,
0x76, 0x98, 0x32, 0x54, 0x98, 0x10, 0x12, 0x45, 0x01, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80,
0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00,
};
#endif /* CORE_HW_NAOMI_NAOMI_ROMS_EEPROM_H_ */

View File

@ -58,7 +58,8 @@ public:
V31,
V32,
V33,
Current = V33,
V34,
Current = V34,
Next = Current + 1,
};

View File

@ -32,7 +32,7 @@ TEST_F(SerializeTest, SizeTest)
std::vector<char> data(30000000);
Serializer ser(data.data(), data.size());
dc_serialize(ser);
ASSERT_EQ(28191555u, ser.size());
ASSERT_EQ(28191556u, ser.size());
}