Skip to content

Commit

Permalink
USIO: Added support for Tekken Tag Tournament 2 Live Monitor edition
Browse files Browse the repository at this point in the history
  • Loading branch information
brian218 authored and Megamouse committed Jul 24, 2023
1 parent 7cb2d3f commit c9f91ec
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions rpcs3/Emu/Io/usio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ void usb_device_usio::translate_input_tekken()

std::vector<u8> input_buf(256);
le_t<u64> digital_input = 0;
le_t<u16> digital_input_lm = 0;

auto translate_from_pad = [&](usz pad_number, usz player)
{
Expand All @@ -301,14 +302,14 @@ void usb_device_usio::translate_input_tekken()
case usio_btn::test:
if (player != 0)
break;
if (pressed && !test_key_pressed) // Solve the need to hold the Test key
if (pressed && !test_key_pressed) // Solve the need to hold the Test button
test_on = !test_on;
test_key_pressed = pressed;
break;
case usio_btn::coin:
if (player != 0)
break;
if (pressed && !coin_key_pressed) // Ensure only one coin is inserted each time the Coin key is pressed
if (pressed && !coin_key_pressed) // Ensure only one coin is inserted each time the Coin button is pressed
coin_counter++;
coin_key_pressed = pressed;
break;
Expand All @@ -318,27 +319,51 @@ void usb_device_usio::translate_input_tekken()
break;
case usio_btn::enter:
if (pressed)
{
digital_input |= 0x800000ULL << shift;
if (player == 0)
digital_input_lm |= 0x800;
}
break;
case usio_btn::up:
if (pressed)
{
digital_input |= 0x200000ULL << shift;
if (player == 0)
digital_input_lm |= 0x200;
}
break;
case usio_btn::down:
if ( pressed)
{
digital_input |= 0x100000ULL << shift;
if (player == 0)
digital_input_lm |= 0x400;
}
break;
case usio_btn::left:
if (pressed)
{
digital_input |= 0x80000ULL << shift;
if (player == 0)
digital_input_lm |= 0x2000;
}
break;
case usio_btn::right:
if (pressed)
{
digital_input |= 0x40000ULL << shift;
if (player == 0)
digital_input_lm |= 0x4000;
}
break;
case usio_btn::tekken_button1:
if (pressed)
{
digital_input |= 0x20000ULL << shift;
if (player == 0)
digital_input_lm |= 0x100;
}
break;
case usio_btn::tekken_button2:
if (pressed)
Expand All @@ -365,9 +390,15 @@ void usb_device_usio::translate_input_tekken()
for (usz i = 0; i < g_cfg_usio.players.size(); i++)
translate_from_pad(i, i);

digital_input |= test_on ? 0x80 : 0x00;
if (test_on)
{
digital_input |= 0x80;
digital_input_lm |= 0x1000;
}

std::memcpy(input_buf.data() + 128, &digital_input, sizeof(u64));
std::memcpy(input_buf.data() + 128 + 16, &coin_counter, sizeof(u16));
std::memcpy(input_buf.data(), &digital_input_lm, sizeof(u16));

input_buf[2] = 0b00010000; // DIP Switches, 8 in total

Expand Down Expand Up @@ -486,18 +517,13 @@ void usb_device_usio::usio_read(u8 channel, u16 reg, u16 size)
break;
}
case 0x1800:
{
// Firmware
// "NBGI.;USIO01;Ver1.00;JPN,Multipurpose with PPG."
response = {0x4E, 0x42, 0x47, 0x49, 0x2E, 0x3B, 0x55, 0x53, 0x49, 0x4F, 0x30, 0x31, 0x3B, 0x56, 0x65, 0x72, 0x31, 0x2E, 0x30, 0x30, 0x3B, 0x4A, 0x50, 0x4E, 0x2C, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x75, 0x72, 0x70, 0x6F, 0x73, 0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x50, 0x50, 0x47, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x42, 0x47, 0x49, 0x2E, 0x3B, 0x55, 0x53, 0x49, 0x4F, 0x30, 0x31, 0x3B, 0x56, 0x65, 0x72, 0x31, 0x2E, 0x30, 0x30, 0x3B, 0x4A, 0x50, 0x4E, 0x2C, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x75, 0x72, 0x70, 0x6F, 0x73, 0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x50, 0x50, 0x47, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x13, 0x00, 0x30, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x75, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
break;
}
case 0x1880:
{
// Seems to contain a few extra bytes of info in addition to the firmware string
// Firmware
// "NBGI.;USIO01;Ver1.00;JPN,Multipurpose with PPG."
response = {0x4E, 0x42, 0x47, 0x49, 0x2E, 0x3B, 0x55, 0x53, 0x49, 0x4F, 0x30, 0x31, 0x3B, 0x56, 0x65, 0x72, 0x31, 0x2E, 0x30, 0x30, 0x3B, 0x4A, 0x50, 0x4E, 0x2C, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x75, 0x72, 0x70, 0x6F, 0x73, 0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x50, 0x50, 0x47, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x13, 0x00, 0x30, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x75, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
constexpr std::array<u8, 0x100> info {0x4E, 0x42, 0x47, 0x49, 0x2E, 0x3B, 0x55, 0x53, 0x49, 0x4F, 0x30, 0x31, 0x3B, 0x56, 0x65, 0x72, 0x31, 0x2E, 0x30, 0x30, 0x3B, 0x4A, 0x50, 0x4E, 0x2C, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x75, 0x72, 0x70, 0x6F, 0x73, 0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x50, 0x50, 0x47, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x42, 0x47, 0x49, 0x2E, 0x3B, 0x55, 0x53, 0x49, 0x4F, 0x30, 0x31, 0x3B, 0x56, 0x65, 0x72, 0x31, 0x2E, 0x30, 0x30, 0x3B, 0x4A, 0x50, 0x4E, 0x2C, 0x4D, 0x75, 0x6C, 0x74, 0x69, 0x70, 0x75, 0x72, 0x70, 0x6F, 0x73, 0x65, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x50, 0x50, 0x47, 0x2E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x13, 0x00, 0x30, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x02, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x75, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
response = {info.begin() + (reg - 0x1800), info.end()};
break;
}
default:
Expand Down

0 comments on commit c9f91ec

Please sign in to comment.