naomi: JVS IO response CRC byte, JVS Self Test command/response

Adds JVS IO response CRC byte, Add JVS Self Test command/response
backport https://github.com/libretro/flycast/pull/972
This commit is contained in:
Flyinghead 2020-10-24 15:10:55 +02:00
parent 170ae3477c
commit 99bfbeb3bc
1 changed files with 18 additions and 1 deletions

View File

@ -65,6 +65,7 @@ enum MapleDeviceCommand
MDC_JVSUploadFirmware = 0x80, // JVS bridge firmware
MDC_JVSGetId = 0x82,
MDC_JVSSelfTest = 0x84, // JVS Self Test
MDC_JVSCommand = 0x86, // JVS I/O
};
@ -83,6 +84,7 @@ enum MapleDeviceRV
MDRE_FileError = 0xFB, //1 word, bitfield
MDRE_LCDError = 0xFA, //1 word, bitfield
MDRE_ARGunError = 0xF9, //1 word, bitfield
MDRS_JVSSelfTestReply= 0x85, // JVS I/O SelfTest
MDRS_JVSReply = 0x87, // JVS I/O
};
@ -2446,6 +2448,14 @@ struct maple_naomi_jamma : maple_sega_controller
u32 cmd = *(u8*)buffer_in;
switch (cmd)
{
case MDC_JVSSelfTest:
w8(MDRS_JVSSelfTestReply);
w8(0x00);
w8(0x20);
w8(0x01);
w8(0x00);
break;
case MDC_JVSCommand:
handle_86_subcommand();
break;
@ -2988,7 +2998,14 @@ u32 jvs_io_board::handle_jvs_message(u8 *buffer_in, u32 length_in, u8 *buffer_ou
}
break;
}
jvs_length = length - 3;
jvs_length = length - 2;
u8 calc_crc = 0;
for (int i = 1; i < length; i++)
calc_crc = ((calc_crc + buffer_out[i]) & 0xFF);
JVS_OUT(calc_crc);
LOGJVS("CRC %x", calc_crc);
return length;
}