diff options
Diffstat (limited to 'src/mame/drivers/chihiro.cpp')
-rw-r--r-- | src/mame/drivers/chihiro.cpp | 261 |
1 files changed, 189 insertions, 72 deletions
diff --git a/src/mame/drivers/chihiro.cpp b/src/mame/drivers/chihiro.cpp index e80149d7551..e2af6e09324 100644 --- a/src/mame/drivers/chihiro.cpp +++ b/src/mame/drivers/chihiro.cpp @@ -464,6 +464,8 @@ public: protected: virtual void device_start() override; private: + void process_jvs_packet(); + static const USBStandardDeviceDescriptor devdesc; static const USBStandardConfigurationDescriptor condesc; static const USBStandardInterfaceDescriptor intdesc; @@ -509,6 +511,8 @@ public: protected: virtual void device_start() override; private: + void process_packet(); + static const USBStandardDeviceDescriptor devdesc; static const USBStandardConfigurationDescriptor condesc; static const USBStandardInterfaceDescriptor intdesc; @@ -523,6 +527,10 @@ private: static const uint8_t strdesc2[]; uint8_t *region; uint8_t midi_rs232; + uint8_t response[256]; + uint8_t packet[4]; + int response_size; + int step; }; const device_type OHCI_HLEAN2131SC = device_creator<ohci_hlean2131sc_device>; @@ -729,7 +737,7 @@ static const struct uint8_t write_byte; } modify[16]; } hacks[HACK_ITEMS] = { { "chihiro", false, { { 0x6a79f/*3f79f*/, 0x01 }, { 0x6a7a0/*3f7a0*/, 0x00 }, { 0x6b575/*40575*/, 0x00 }, { 0x6b576/*40576*/, 0x00 }, { 0x6b5af/*405af*/, 0x75 }, { 0x6b78a/*4078a*/, 0x75 }, { 0x6b7ca/*407ca*/, 0x00 }, { 0x6b7b8/*407b8*/, 0x00 }, { 0x8f5b2, 0x75 }, { 0x79a9e/*2ea9e*/, 0x74 }, { 0x79b80/*2eb80*/, 0xeb }, { 0x79b97/*2eb97*/, 0x74 }, { 0, 0 } } }, - { "outr2", true, { { 0x12e4cf, 0x01 }, { 0x12e4d0, 0x00 }, { 0x4793e, 0x01 }, { 0x4793f, 0x00 }, { 0x47aa3, 0x01 }, { 0x47aa4, 0x00 }, { 0x14f2b6, 0x84 }, { 0x14f2d1, 0x75 }, { 0x8732f, 0x7d }, { 0x87384, 0x7d }, { 0x87388, 0xeb }, { 0, 0 } } }, + { "outr2", false, { { 0, 0 } } }, { "crtaxihr", false, { { 0x14ada5/*11fda5*/, 0x90 },{ 0x14ada6/*11fda6*/, 0x90 }, { 0, 0 } } }, { "ghostsqu", false, { { 0x78833/*4d833*/, 0x90 },{ 0x78834/*4d834*/, 0x90 }, { 0, 0 } } }, { "vcop3", false, { { 0x61a23/*36a23*/, 0x90 },{ 0x61a24/*36a24*/, 0x90 }, { 0, 0 } } }, @@ -1013,65 +1021,70 @@ int ohci_hlean2131qc_device::handle_bulk_pid(int endpoint, int pid, uint8_t *buf printf("\n\r"); #endif // extract packets - int numpk = jvs.buffer_in[1]; - int p = 2; - - for (int n = 0;n < numpk;n++) - { - p++; - if (jvs.buffer_in[p] != 0xe0) - break; - p++; - int dest = jvs.buffer_in[p]; - p++; - int len = jvs.buffer_in[p]; - p++; - if ((p + len) > jvs.buffer_in_expected) - break; - int chk = dest + len; - for (int m = len - 1; m > 0; m--) - chk = chk + (int)jvs.buffer_in[p + m - 1]; - chk = chk & 255; - if (chk != (int)jvs.buffer_in[p + len - 1]) - { - p = p + len; - continue; - } - // use data of this packet - jvs.master->send_packet(dest, len, jvs.buffer_in + p); - // generate response - if (dest == 0xff) - dest = 0; - int recv = jvs.master->received_packet(jvs.buffer_out + jvs.buffer_out_used + 5); - // update buffer_out - if (recv > 0) - { - chk = 0; - for (int m = 0; m < recv; m++) - chk = chk + jvs.buffer_out[jvs.buffer_out_used + 5 + m]; - jvs.buffer_out[jvs.buffer_out_used + 5 + recv] = chk & 255; - jvs.buffer_out_packets++; - // jvs node address - jvs.buffer_out[jvs.buffer_out_used] = (uint8_t)dest; - // dummy - jvs.buffer_out[jvs.buffer_out_used + 1] = 0; - // length following - recv += 2; - jvs.buffer_out[jvs.buffer_out_used + 2] = recv & 255; - jvs.buffer_out[jvs.buffer_out_used + 3] = (recv >> 8) & 255; - // body - jvs.buffer_out[jvs.buffer_out_used + 4] = 0xe0; - jvs.buffer_out_used = jvs.buffer_out_used + recv + 5 - 1; - jvs.buffer_out[1] = (uint8_t)jvs.buffer_out_packets; - } - p = p + len; - } + process_jvs_packet(); } } } return size; } +void ohci_hlean2131qc_device::process_jvs_packet() +{ + int numpk = jvs.buffer_in[1]; + int p = 2; + + for (int n = 0; n < numpk; n++) + { + p++; + if (jvs.buffer_in[p] != 0xe0) + break; + p++; + int dest = jvs.buffer_in[p]; + p++; + int len = jvs.buffer_in[p]; + p++; + if ((p + len) > jvs.buffer_in_expected) + break; + int chk = dest + len; + for (int m = len - 1; m > 0; m--) + chk = chk + (int)jvs.buffer_in[p + m - 1]; + chk = chk & 255; + if (chk != (int)jvs.buffer_in[p + len - 1]) + { + p = p + len; + continue; + } + // use data of this packet + jvs.master->send_packet(dest, len, jvs.buffer_in + p); + // generate response + if (dest == 0xff) + dest = 0; + int recv = jvs.master->received_packet(jvs.buffer_out + jvs.buffer_out_used + 5); + // update buffer_out + if (recv > 0) + { + chk = 0; + for (int m = 0; m < recv; m++) + chk = chk + jvs.buffer_out[jvs.buffer_out_used + 5 + m]; + jvs.buffer_out[jvs.buffer_out_used + 5 + recv] = chk & 255; + jvs.buffer_out_packets++; + // jvs node address + jvs.buffer_out[jvs.buffer_out_used] = (uint8_t)dest; + // dummy + jvs.buffer_out[jvs.buffer_out_used + 1] = 0; + // length following + recv += 2; + jvs.buffer_out[jvs.buffer_out_used + 2] = recv & 255; + jvs.buffer_out[jvs.buffer_out_used + 3] = (recv >> 8) & 255; + // body + jvs.buffer_out[jvs.buffer_out_used + 4] = 0xe0; + jvs.buffer_out_used = jvs.buffer_out_used + recv + 5 - 1; + jvs.buffer_out[1] = (uint8_t)jvs.buffer_out_packets; + } + p = p + len; + } +} + void ohci_hlean2131qc_device::device_start() { } @@ -1096,6 +1109,8 @@ ohci_hlean2131sc_device::ohci_hlean2131sc_device(const machine_config &mconfig, { region = nullptr; midi_rs232 = 0; + response_size = 0; + step = 0; } void ohci_hlean2131sc_device::set_region_base(uint8_t *data) @@ -1168,8 +1183,24 @@ int ohci_hlean2131sc_device::handle_nonstandard_request(int endpoint, USBSetupPa // setup->wIndex = number of bytes host would like to retrieve (must be lower than 256, 0 means get all available) endpoints[endpoint].buffer[0] = 0; // endpoints[endpoint].buffer[1] = 0; // bit 0 in buffer overflow bit 1 in parity error - endpoints[endpoint].buffer[4] = 0x40 & 255; // how many bytes to transfer with endpoint 3 - endpoints[endpoint].buffer[5] = (0x40 >> 8) & 255; + if ((setup->wIndex == 0) || (setup->wIndex > response_size)) + { + endpoints[endpoint].buffer[4] = response_size & 255; // how many bytes to transfer with endpoint 3 + endpoints[endpoint].buffer[5] = (response_size >> 8) & 255; + memcpy(endpoints[3].buffer, response, response_size); + response_size = 0; + } + else + { + endpoints[endpoint].buffer[4] = setup->wIndex & 255; + endpoints[endpoint].buffer[5] = (setup->wIndex >> 8) & 255; + memcpy(endpoints[3].buffer, response, setup->wIndex); + for (int n = setup->wIndex; n < response_size; n++) + response[n - setup->wIndex] = response[n]; + response_size = response_size - setup->wIndex; + } + endpoints[3].remain = setup->wIndex; + endpoints[3].position = endpoints[3].buffer; } else if (setup->bRequest == 0x1d) { @@ -1191,21 +1222,25 @@ int ohci_hlean2131sc_device::handle_nonstandard_request(int endpoint, USBSetupPa } else if (setup->bRequest == 0x23) { - // send data to be output from uart1 - endpoints[endpoint].buffer[0] = 0x99; + // this command is used to send data to be output from uart1 + // setup->wIndex = number of bytes to send + // data will be transferred to the host using endpoint 3 (OUT) + endpoints[endpoint].buffer[0] = 0; + endpoints[3].remain = setup->wIndex; + endpoints[3].position = endpoints[3].buffer; } else if (setup->bRequest == 0x25) // { - endpoints[endpoint].buffer[0] = 0x99; + endpoints[endpoint].buffer[0] = 0; } else if (setup->bRequest == 0x26) // { // set uart0 or uart1 mode - endpoints[endpoint].buffer[0] = 0x99; + endpoints[endpoint].buffer[0] = 0; } else if (setup->bRequest == 0x27) // { - endpoints[endpoint].buffer[0] = 0x99; + endpoints[endpoint].buffer[0] = 0; } else if (setup->bRequest == 0x28) { @@ -1274,9 +1309,9 @@ int ohci_hlean2131sc_device::handle_nonstandard_request(int endpoint, USBSetupPa int ohci_hlean2131sc_device::handle_bulk_pid(int endpoint, int pid, uint8_t *buffer, int size) { -//#ifdef VERBOSE_MSG +#ifdef VERBOSE_MSG printf("Bulk request to an2131sc: %x %d %x\n\r", endpoint, pid, size); -//#endif +#endif if (((endpoint == 1) || (endpoint == 2)) && (pid == InPid)) { if (size > endpoints[endpoint].remain) @@ -1285,9 +1320,91 @@ int ohci_hlean2131sc_device::handle_bulk_pid(int endpoint, int pid, uint8_t *buf endpoints[endpoint].position = endpoints[endpoint].position + size; endpoints[endpoint].remain = endpoints[endpoint].remain - size; } + if ((endpoint == 3) && (pid == InPid)) + { + if (size > endpoints[3].remain) + size = endpoints[3].remain; + memcpy(buffer, endpoints[3].position, size); + endpoints[3].position = endpoints[3].position + size; + endpoints[3].remain = endpoints[3].remain - size; + } + if ((endpoint == 3) && (pid == OutPid)) + { + if (size > endpoints[3].remain) + size = endpoints[3].remain; + memcpy(endpoints[3].position, buffer, size); + endpoints[3].position = endpoints[3].position + size; + endpoints[3].remain = endpoints[3].remain - size; + for (int n = 0; n < size; n++) + { + uint8_t byt = buffer[n]; + switch(step) + { + case 0: + if ((byt & 0x80) != 0) + { + packet[0] = byt; + step = 1; + } + break; + case 1: + packet[1] = byt; + step = 2; + break; + case 2: + packet[2] = byt; + step = 3; + break; + case 3: + packet[3] = byt; + step = 0; + process_packet(); + break; + } + } + } return size; } +void ohci_hlean2131sc_device::process_packet() +{ + uint8_t result = 0; +#ifdef VERBOSE_MSG + printf("%02X %02X %02X %02X\n\r", packet[0], packet[1], packet[2], packet[3]); +#endif + if (packet[0] == 0xff) // 00 00 7f + result = 2; + else if (packet[0] == 0x81) // 30 7f 4e + result = 1; // must be 1 + else if (packet[0] == 0xfc) // 00 20 5c + result = 3; + else if (packet[0] == 0xfd) // 00 00 7d + result = 0; + else if (packet[0] == 0xfa) // 00 1f 65 + result = 0; + else if (packet[0] == 0x83) // 40 04 47 + result = 0; + else if (packet[0] == 0x86) // 01 02 05 + result = 0; + else if (packet[0] == 0x88) // 00 04 0c + result = 0; + else if (packet[0] == 0x80) // 01 01 00 + result = 0; + else if (packet[0] == 0x84) // 01 00 05 + result = 0; + else if (packet[0] == 0xf0) // 00 00 70 + result = 0; + else if (packet[0] == 0x9d) + result = 0; + else if (packet[0] == 0x9e) + result = 0; + if (response_size < 256) + { + response[response_size] = result + (result << 4); + response_size++; + } +} + void ohci_hlean2131sc_device::device_start() { } @@ -1575,29 +1692,29 @@ static INPUT_PORTS_START(chihiro) /* Dummy so we can easily get the analog ch # */ PORT_START("A0") - PORT_BIT(0x00ff, IP_ACTIVE_LOW, IPT_UNUSED) + PORT_BIT(0x80ff, IP_ACTIVE_LOW, IPT_UNUSED) PORT_START("A1") - PORT_BIT(0x01ff, IP_ACTIVE_LOW, IPT_UNUSED) + PORT_BIT(0x81ff, IP_ACTIVE_LOW, IPT_UNUSED) PORT_START("A2") - PORT_BIT(0x02ff, IP_ACTIVE_LOW, IPT_UNUSED) + PORT_BIT(0x82ff, IP_ACTIVE_LOW, IPT_UNUSED) PORT_START("A3") - PORT_BIT(0x03ff, IP_ACTIVE_LOW, IPT_UNUSED) + PORT_BIT(0x83ff, IP_ACTIVE_LOW, IPT_UNUSED) PORT_START("A4") - PORT_BIT(0x04ff, IP_ACTIVE_LOW, IPT_UNUSED) + PORT_BIT(0x84ff, IP_ACTIVE_LOW, IPT_UNUSED) PORT_START("A5") - PORT_BIT(0x05ff, IP_ACTIVE_LOW, IPT_UNUSED) + PORT_BIT(0x85ff, IP_ACTIVE_LOW, IPT_UNUSED) PORT_START("A6") - PORT_BIT(0x06ff, IP_ACTIVE_LOW, IPT_UNUSED) + PORT_BIT(0x86ff, IP_ACTIVE_LOW, IPT_UNUSED) PORT_START("A7") - PORT_BIT(0x07ff, IP_ACTIVE_LOW, IPT_UNUSED) -INPUT_PORTS_END + PORT_BIT(0x87ff, IP_ACTIVE_LOW, IPT_UNUSED) + INPUT_PORTS_END void chihiro_state::machine_start() { |