mirror of
https://github.com/holub/mame
synced 2025-10-07 17:27:06 +03:00
xbox/chihiro: usb devices are now slot devices [Samuele Zannoli]
This commit is contained in:
parent
12bc38285f
commit
53af4c6390
@ -393,7 +393,10 @@ Thanks to Alex, Mr Mudkips, and Philip Burke for this info.
|
|||||||
//#define LOG_BASEBOARD
|
//#define LOG_BASEBOARD
|
||||||
//#define VERBOSE_MSG
|
//#define VERBOSE_MSG
|
||||||
|
|
||||||
/////////////////////////
|
/*
|
||||||
|
* Class declaration for jvs_master
|
||||||
|
*/
|
||||||
|
|
||||||
DECLARE_DEVICE_TYPE(JVS_MASTER, jvs_master)
|
DECLARE_DEVICE_TYPE(JVS_MASTER, jvs_master)
|
||||||
|
|
||||||
class jvs_master : public jvs_host
|
class jvs_master : public jvs_host
|
||||||
@ -447,11 +450,13 @@ int jvs_master::received_packet(uint8_t *buffer)
|
|||||||
return (int)length;
|
return (int)length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////
|
/*
|
||||||
|
* Class declaration for ohci_hlean2131qc_device
|
||||||
|
*/
|
||||||
|
|
||||||
DECLARE_DEVICE_TYPE(OHCI_HLEAN2131QC, ohci_hlean2131qc_device)
|
DECLARE_DEVICE_TYPE(OHCI_HLEAN2131QC, ohci_hlean2131qc_device)
|
||||||
|
|
||||||
class ohci_hlean2131qc_device : public device_t, public ohci_function
|
class ohci_hlean2131qc_device : public device_t, public ohci_function, public device_slot_card_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ohci_hlean2131qc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
ohci_hlean2131qc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||||
@ -459,6 +464,7 @@ public:
|
|||||||
int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) override;
|
int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) override;
|
||||||
int handle_bulk_pid(int endpoint, int pid, uint8_t *buffer, int size) override;
|
int handle_bulk_pid(int endpoint, int pid, uint8_t *buffer, int size) override;
|
||||||
void set_region_base(uint8_t *data);
|
void set_region_base(uint8_t *data);
|
||||||
|
void set_region(const char *_region_tag, int _region_offset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void device_start() override;
|
virtual void device_start() override;
|
||||||
@ -482,6 +488,8 @@ private:
|
|||||||
static const uint8_t strdesc1[];
|
static const uint8_t strdesc1[];
|
||||||
static const uint8_t strdesc2[];
|
static const uint8_t strdesc2[];
|
||||||
int maximum_send;
|
int maximum_send;
|
||||||
|
const char *region_tag;
|
||||||
|
int region_offset;
|
||||||
uint8_t *region;
|
uint8_t *region;
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -494,11 +502,18 @@ private:
|
|||||||
} jvs;
|
} jvs;
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_DEVICE_TYPE(OHCI_HLEAN2131QC, ohci_hlean2131qc_device, "ohci_hlean2131qc", "OHCI Hlean2131qc")
|
DEFINE_DEVICE_TYPE(OHCI_HLEAN2131QC, ohci_hlean2131qc_device, "ohci_hlean2131qc", "OHCI an2131qc HLE")
|
||||||
|
|
||||||
|
#define MCFG_OHCI_HLEAN2131QC_REGION(_region_tag, _region_offset) \
|
||||||
|
downcast<ohci_hlean2131qc_device *>(device)->set_region(_region_tag, _region_offset);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class declaration for ohci_hlean2131sc_device
|
||||||
|
*/
|
||||||
|
|
||||||
DECLARE_DEVICE_TYPE(OHCI_HLEAN2131SC, ohci_hlean2131sc_device)
|
DECLARE_DEVICE_TYPE(OHCI_HLEAN2131SC, ohci_hlean2131sc_device)
|
||||||
|
|
||||||
class ohci_hlean2131sc_device : public device_t, public ohci_function
|
class ohci_hlean2131sc_device : public device_t, public ohci_function, public device_slot_card_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ohci_hlean2131sc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
ohci_hlean2131sc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||||
@ -506,6 +521,7 @@ public:
|
|||||||
int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) override;
|
int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) override;
|
||||||
int handle_bulk_pid(int endpoint, int pid, uint8_t *buffer, int size) override;
|
int handle_bulk_pid(int endpoint, int pid, uint8_t *buffer, int size) override;
|
||||||
void set_region_base(uint8_t *data);
|
void set_region_base(uint8_t *data);
|
||||||
|
void set_region(const char *_region_tag, int _region_offset);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void device_start() override;
|
virtual void device_start() override;
|
||||||
@ -524,6 +540,8 @@ private:
|
|||||||
static const uint8_t strdesc0[];
|
static const uint8_t strdesc0[];
|
||||||
static const uint8_t strdesc1[];
|
static const uint8_t strdesc1[];
|
||||||
static const uint8_t strdesc2[];
|
static const uint8_t strdesc2[];
|
||||||
|
const char *region_tag;
|
||||||
|
int region_offset;
|
||||||
uint8_t *region;
|
uint8_t *region;
|
||||||
uint8_t midi_rs232;
|
uint8_t midi_rs232;
|
||||||
uint8_t response[256];
|
uint8_t response[256];
|
||||||
@ -532,7 +550,14 @@ private:
|
|||||||
int step;
|
int step;
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_DEVICE_TYPE(OHCI_HLEAN2131SC, ohci_hlean2131sc_device, "ohci_hlean2131sc", "OHCI Hlean2131sc")
|
DEFINE_DEVICE_TYPE(OHCI_HLEAN2131SC, ohci_hlean2131sc_device, "ohci_hlean2131sc", "OHCI an2131sc HLE")
|
||||||
|
|
||||||
|
#define MCFG_OHCI_HLEAN2131SC_REGION(_region_tag, _region_offset) \
|
||||||
|
downcast<ohci_hlean2131sc_device *>(device)->set_region(_region_tag, _region_offset);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class declaration for chihiro_state
|
||||||
|
*/
|
||||||
|
|
||||||
class chihiro_state : public xbox_base_state
|
class chihiro_state : public xbox_base_state
|
||||||
{
|
{
|
||||||
@ -783,9 +808,12 @@ const uint8_t ohci_hlean2131qc_device::strdesc2[] = { 0x0E,0x03,0x42,0x00,0x41,0
|
|||||||
|
|
||||||
ohci_hlean2131qc_device::ohci_hlean2131qc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
ohci_hlean2131qc_device::ohci_hlean2131qc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||||
device_t(mconfig, OHCI_HLEAN2131QC, tag, owner, clock),
|
device_t(mconfig, OHCI_HLEAN2131QC, tag, owner, clock),
|
||||||
ohci_function()
|
ohci_function(),
|
||||||
|
device_slot_card_interface(mconfig, *this)
|
||||||
{
|
{
|
||||||
maximum_send = 0;
|
maximum_send = 0;
|
||||||
|
region_tag = nullptr;
|
||||||
|
region_offset = 0;
|
||||||
region = nullptr;
|
region = nullptr;
|
||||||
jvs.buffer_in_expected = 0;
|
jvs.buffer_in_expected = 0;
|
||||||
jvs.buffer_out_used = 0;
|
jvs.buffer_out_used = 0;
|
||||||
@ -821,6 +849,12 @@ void ohci_hlean2131qc_device::set_region_base(uint8_t *data)
|
|||||||
region = data;
|
region = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ohci_hlean2131qc_device::set_region(const char *_region_tag, int _region_offset)
|
||||||
|
{
|
||||||
|
region_tag = _region_tag;
|
||||||
|
region_offset = _region_offset;
|
||||||
|
}
|
||||||
|
|
||||||
int ohci_hlean2131qc_device::handle_nonstandard_request(int endpoint, USBSetupPacket *setup)
|
int ohci_hlean2131qc_device::handle_nonstandard_request(int endpoint, USBSetupPacket *setup)
|
||||||
{
|
{
|
||||||
int sense;
|
int sense;
|
||||||
@ -1083,6 +1117,9 @@ void ohci_hlean2131qc_device::process_jvs_packet()
|
|||||||
|
|
||||||
void ohci_hlean2131qc_device::device_start()
|
void ohci_hlean2131qc_device::device_start()
|
||||||
{
|
{
|
||||||
|
initialize(machine());
|
||||||
|
if (region_tag)
|
||||||
|
set_region_base(memregion(region_tag)->base() + region_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
//pc20
|
//pc20
|
||||||
@ -1101,9 +1138,12 @@ const uint8_t ohci_hlean2131sc_device::strdesc2[] = { 0x0E,0x03,0x42,0x00,0x41,0
|
|||||||
|
|
||||||
ohci_hlean2131sc_device::ohci_hlean2131sc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
ohci_hlean2131sc_device::ohci_hlean2131sc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||||
device_t(mconfig, OHCI_HLEAN2131SC, tag, owner, clock),
|
device_t(mconfig, OHCI_HLEAN2131SC, tag, owner, clock),
|
||||||
ohci_function()
|
ohci_function(),
|
||||||
|
device_slot_card_interface(mconfig, *this)
|
||||||
{
|
{
|
||||||
region = nullptr;
|
region = nullptr;
|
||||||
|
region_tag = nullptr;
|
||||||
|
region_offset = 0;
|
||||||
midi_rs232 = 0;
|
midi_rs232 = 0;
|
||||||
response_size = 0;
|
response_size = 0;
|
||||||
step = 0;
|
step = 0;
|
||||||
@ -1114,6 +1154,12 @@ void ohci_hlean2131sc_device::set_region_base(uint8_t *data)
|
|||||||
region = data;
|
region = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ohci_hlean2131sc_device::set_region(const char *_region_tag, int _region_offset)
|
||||||
|
{
|
||||||
|
region_tag = _region_tag;
|
||||||
|
region_offset = _region_offset;
|
||||||
|
}
|
||||||
|
|
||||||
void ohci_hlean2131sc_device::initialize(running_machine &machine)
|
void ohci_hlean2131sc_device::initialize(running_machine &machine)
|
||||||
{
|
{
|
||||||
ohci_function::initialize(machine);
|
ohci_function::initialize(machine);
|
||||||
@ -1403,6 +1449,9 @@ void ohci_hlean2131sc_device::process_packet()
|
|||||||
|
|
||||||
void ohci_hlean2131sc_device::device_start()
|
void ohci_hlean2131sc_device::device_start()
|
||||||
{
|
{
|
||||||
|
initialize(machine());
|
||||||
|
if (region_tag)
|
||||||
|
set_region_base(memregion(region_tag)->base() + region_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ======================> ide_baseboard_device
|
// ======================> ide_baseboard_device
|
||||||
@ -1716,9 +1765,6 @@ static INPUT_PORTS_START(chihiro)
|
|||||||
|
|
||||||
void chihiro_state::machine_start()
|
void chihiro_state::machine_start()
|
||||||
{
|
{
|
||||||
ohci_hlean2131qc_device *usb_device1;
|
|
||||||
ohci_hlean2131sc_device *usb_device2;
|
|
||||||
|
|
||||||
xbox_base_state::machine_start();
|
xbox_base_state::machine_start();
|
||||||
chihiro_devs.ide = machine().device<bus_master_ide_controller_device>("ide");
|
chihiro_devs.ide = machine().device<bus_master_ide_controller_device>("ide");
|
||||||
chihiro_devs.dimmboard = machine().device<naomi_gdrom_board>("rom_board");
|
chihiro_devs.dimmboard = machine().device<naomi_gdrom_board>("rom_board");
|
||||||
@ -1737,14 +1783,6 @@ void chihiro_state::machine_start()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
hack_counter = 0;
|
hack_counter = 0;
|
||||||
usb_device1 = machine().device<ohci_hlean2131qc_device>("ohci_hlean2131qc");
|
|
||||||
usb_device1->initialize(machine());
|
|
||||||
usb_device1->set_region_base(memregion(":others")->base()); // temporary
|
|
||||||
machine().device<mcpx_ohci_device>(":pci:02.0")->plug_usb_device(1, usb_device1); // connect
|
|
||||||
usb_device2 = machine().device<ohci_hlean2131sc_device>("ohci_hlean2131sc");
|
|
||||||
usb_device2->initialize(machine());
|
|
||||||
usb_device2->set_region_base(memregion(":others")->base() + 0x2080); // temporary
|
|
||||||
machine().device<mcpx_ohci_device>(":pci:02.0")->plug_usb_device(2, usb_device2); // connect
|
|
||||||
// savestates
|
// savestates
|
||||||
save_item(NAME(hack_counter));
|
save_item(NAME(hack_counter));
|
||||||
}
|
}
|
||||||
@ -1753,6 +1791,20 @@ static SLOT_INTERFACE_START(ide_baseboard)
|
|||||||
SLOT_INTERFACE("bb", IDE_BASEBOARD)
|
SLOT_INTERFACE("bb", IDE_BASEBOARD)
|
||||||
SLOT_INTERFACE_END
|
SLOT_INTERFACE_END
|
||||||
|
|
||||||
|
SLOT_INTERFACE_START(usb_baseboard)
|
||||||
|
SLOT_INTERFACE("an2131qc", OHCI_HLEAN2131QC)
|
||||||
|
SLOT_INTERFACE("an2131sc", OHCI_HLEAN2131SC)
|
||||||
|
SLOT_INTERFACE("xbox_controller", OHCI_GAME_CONTROLLER)
|
||||||
|
SLOT_INTERFACE_END
|
||||||
|
|
||||||
|
static MACHINE_CONFIG_FRAGMENT(an2131qc_configuration)
|
||||||
|
MCFG_OHCI_HLEAN2131QC_REGION(":others", 0)
|
||||||
|
MACHINE_CONFIG_END
|
||||||
|
|
||||||
|
static MACHINE_CONFIG_FRAGMENT(an2131sc_configuration)
|
||||||
|
MCFG_OHCI_HLEAN2131SC_REGION(":others", 0x2080)
|
||||||
|
MACHINE_CONFIG_END
|
||||||
|
|
||||||
static MACHINE_CONFIG_DERIVED(chihiro_base, xbox_base)
|
static MACHINE_CONFIG_DERIVED(chihiro_base, xbox_base)
|
||||||
MCFG_CPU_MODIFY("maincpu")
|
MCFG_CPU_MODIFY("maincpu")
|
||||||
MCFG_CPU_PROGRAM_MAP(chihiro_map)
|
MCFG_CPU_PROGRAM_MAP(chihiro_map)
|
||||||
@ -1764,9 +1816,13 @@ static MACHINE_CONFIG_DERIVED(chihiro_base, xbox_base)
|
|||||||
MCFG_DEVICE_MODIFY(":pci:09.0:ide:1")
|
MCFG_DEVICE_MODIFY(":pci:09.0:ide:1")
|
||||||
MCFG_DEVICE_SLOT_INTERFACE(ide_baseboard, "bb", true)
|
MCFG_DEVICE_SLOT_INTERFACE(ide_baseboard, "bb", true)
|
||||||
|
|
||||||
// next lines are temporary
|
MCFG_USB_PORT_ADD(":pci:02.0:port1", usb_baseboard, "an2131qc", true)
|
||||||
MCFG_DEVICE_ADD("ohci_hlean2131qc", OHCI_HLEAN2131QC, 0)
|
MCFG_SLOT_OPTION_MACHINE_CONFIG("an2131qc", an2131qc_configuration)
|
||||||
MCFG_DEVICE_ADD("ohci_hlean2131sc", OHCI_HLEAN2131SC, 0)
|
MCFG_USB_PORT_ADD(":pci:02.0:port2", usb_baseboard, "an2131sc", true)
|
||||||
|
MCFG_SLOT_OPTION_MACHINE_CONFIG("an2131sc", an2131sc_configuration)
|
||||||
|
MCFG_USB_PORT_ADD(":pci:02.0:port3", usb_baseboard, nullptr, false)
|
||||||
|
MCFG_USB_PORT_ADD(":pci:02.0:port4", usb_baseboard, nullptr, false)
|
||||||
|
|
||||||
MCFG_DEVICE_ADD("jvs_master", JVS_MASTER, 0)
|
MCFG_DEVICE_ADD("jvs_master", JVS_MASTER, 0)
|
||||||
MCFG_SEGA_837_13551_DEVICE_ADD("837_13551", "jvs_master", ":TILT", ":P1", ":P2", ":A0", ":A1", ":A2", ":A3", ":A4", ":A5", ":A6", ":A7", ":OUTPUT")
|
MCFG_SEGA_837_13551_DEVICE_ADD("837_13551", "jvs_master", ":TILT", ":P1", ":P2", ":A0", ":A1", ":A2", ":A3", ":A4", ":A5", ":A6", ":A7", ":OUTPUT")
|
||||||
MACHINE_CONFIG_END
|
MACHINE_CONFIG_END
|
||||||
|
@ -130,15 +130,8 @@ void xbox_state::hack_eeprom()
|
|||||||
|
|
||||||
void xbox_state::machine_start()
|
void xbox_state::machine_start()
|
||||||
{
|
{
|
||||||
ohci_game_controller_device *usb_device;
|
|
||||||
|
|
||||||
xbox_base_state::machine_start();
|
xbox_base_state::machine_start();
|
||||||
xbox_devs.ide = machine().device<bus_master_ide_controller_device>("ide");
|
xbox_devs.ide = machine().device<bus_master_ide_controller_device>("ide");
|
||||||
usb_device = machine().device<ohci_game_controller_device>("ohci_gamepad");
|
|
||||||
if (usb_device != nullptr) {
|
|
||||||
usb_device->initialize(machine());
|
|
||||||
machine().device<mcpx_ohci_device>(":pci:02.0")->plug_usb_device(3, usb_device); // connect to root hub port 3, chihiro needs to use 1 and 2
|
|
||||||
}
|
|
||||||
// savestates
|
// savestates
|
||||||
//save_item(NAME(item));
|
//save_item(NAME(item));
|
||||||
}
|
}
|
||||||
@ -160,6 +153,10 @@ void xbox_state::machine_reset()
|
|||||||
id[88] |= (1 << 2); // ultra dma mode 2 supported
|
id[88] |= (1 << 2); // ultra dma mode 2 supported
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SLOT_INTERFACE_START(usb_xbox)
|
||||||
|
SLOT_INTERFACE("xbox_controller", OHCI_GAME_CONTROLLER)
|
||||||
|
SLOT_INTERFACE_END
|
||||||
|
|
||||||
SLOT_INTERFACE_START(xbox_ata_devices)
|
SLOT_INTERFACE_START(xbox_ata_devices)
|
||||||
SLOT_INTERFACE("hdd", IDE_HARDDISK)
|
SLOT_INTERFACE("hdd", IDE_HARDDISK)
|
||||||
SLOT_INTERFACE("cdrom", ATAPI_CDROM)
|
SLOT_INTERFACE("cdrom", ATAPI_CDROM)
|
||||||
@ -175,7 +172,12 @@ static MACHINE_CONFIG_DERIVED(xbox, xbox_base)
|
|||||||
MCFG_DEVICE_MODIFY(":pci:09.0:ide:1")
|
MCFG_DEVICE_MODIFY(":pci:09.0:ide:1")
|
||||||
MCFG_DEVICE_SLOT_INTERFACE(xbox_ata_devices, "cdrom", true)
|
MCFG_DEVICE_SLOT_INTERFACE(xbox_ata_devices, "cdrom", true)
|
||||||
|
|
||||||
/* sound hardware */
|
MCFG_USB_PORT_ADD(":pci:02.0:port1", usb_xbox, nullptr, false)
|
||||||
|
MCFG_USB_PORT_ADD(":pci:02.0:port2", usb_xbox, nullptr, false)
|
||||||
|
MCFG_USB_PORT_ADD(":pci:02.0:port3", usb_xbox, "xbox_controller", false)
|
||||||
|
MCFG_USB_PORT_ADD(":pci:02.0:port4", usb_xbox, nullptr, false)
|
||||||
|
|
||||||
|
/* sound hardware */
|
||||||
MCFG_SPEAKER_STANDARD_MONO("mono")
|
MCFG_SPEAKER_STANDARD_MONO("mono")
|
||||||
// MCFG_SOUND_ADD("aysnd", AY8910, MAIN_CLOCK/4)
|
// MCFG_SOUND_ADD("aysnd", AY8910, MAIN_CLOCK/4)
|
||||||
// MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
|
// MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.30)
|
||||||
|
@ -114,7 +114,7 @@ extern const device_type MCPX_SMBUS;
|
|||||||
/*
|
/*
|
||||||
* OHCI USB Controller
|
* OHCI USB Controller
|
||||||
*/
|
*/
|
||||||
|
class usb_function_device;
|
||||||
class mcpx_ohci_device : public pci_device {
|
class mcpx_ohci_device : public pci_device {
|
||||||
public:
|
public:
|
||||||
mcpx_ohci_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
mcpx_ohci_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||||
@ -129,6 +129,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
virtual void device_start() override;
|
virtual void device_start() override;
|
||||||
virtual void device_reset() override;
|
virtual void device_reset() override;
|
||||||
|
virtual void device_config_complete() override;
|
||||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
|
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -137,6 +138,11 @@ private:
|
|||||||
emu_timer *timer;
|
emu_timer *timer;
|
||||||
std::function<void(void)> hack_callback;
|
std::function<void(void)> hack_callback;
|
||||||
DECLARE_ADDRESS_MAP(ohci_mmio, 32);
|
DECLARE_ADDRESS_MAP(ohci_mmio, 32);
|
||||||
|
struct dev_t {
|
||||||
|
ohci_function *dev;
|
||||||
|
int port;
|
||||||
|
} connecteds[4];
|
||||||
|
int connecteds_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern const device_type MCPX_OHCI;
|
extern const device_type MCPX_OHCI;
|
||||||
|
@ -340,6 +340,10 @@ struct usb_device_configuration
|
|||||||
std::forward_list<usb_device_interfac *> interfaces;
|
std::forward_list<usb_device_interfac *> interfaces;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* OHCI Usb Controller
|
||||||
|
*/
|
||||||
|
|
||||||
class ohci_function; // forward declaration
|
class ohci_function; // forward declaration
|
||||||
|
|
||||||
class ohci_usb_controller
|
class ohci_usb_controller
|
||||||
@ -397,6 +401,10 @@ private:
|
|||||||
} ohcist;
|
} ohcist;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Base class for usb devices
|
||||||
|
*/
|
||||||
|
|
||||||
class ohci_function {
|
class ohci_function {
|
||||||
public:
|
public:
|
||||||
ohci_function();
|
ohci_function();
|
||||||
@ -455,9 +463,35 @@ protected:
|
|||||||
usb_device_configuration *selected_configuration;
|
usb_device_configuration *selected_configuration;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Usb port connector
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ohci_usb_connector : public device_t, public device_slot_interface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ohci_usb_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||||
|
virtual ~ohci_usb_connector();
|
||||||
|
|
||||||
|
ohci_function *get_device();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void device_start() override;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const device_type OHCI_USB_CONNECTOR;
|
||||||
|
|
||||||
|
#define MCFG_USB_PORT_ADD(_tag, _slot_intf, _def_slot, _fixed) \
|
||||||
|
MCFG_DEVICE_ADD(_tag, OHCI_USB_CONNECTOR, 0) \
|
||||||
|
MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _fixed)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Game controller usb device
|
||||||
|
*/
|
||||||
|
|
||||||
DECLARE_DEVICE_TYPE(OHCI_GAME_CONTROLLER, ohci_game_controller_device)
|
DECLARE_DEVICE_TYPE(OHCI_GAME_CONTROLLER, ohci_game_controller_device)
|
||||||
|
|
||||||
class ohci_game_controller_device : public device_t, public ohci_function
|
class ohci_game_controller_device : public device_t, public ohci_function, public device_slot_card_interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ohci_game_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
ohci_game_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
|
||||||
|
@ -229,14 +229,15 @@ mcpx_ohci_device::mcpx_ohci_device(const machine_config &mconfig, const char *ta
|
|||||||
: pci_device(mconfig, MCPX_OHCI, tag, owner, clock),
|
: pci_device(mconfig, MCPX_OHCI, tag, owner, clock),
|
||||||
ohci_usb(nullptr),
|
ohci_usb(nullptr),
|
||||||
m_interrupt_handler(*this),
|
m_interrupt_handler(*this),
|
||||||
timer(nullptr)
|
timer(nullptr),
|
||||||
|
connecteds_count(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void mcpx_ohci_device::plug_usb_device(int port, ohci_function *function)
|
void mcpx_ohci_device::plug_usb_device(int port, ohci_function *function)
|
||||||
{
|
{
|
||||||
function->set_bus_manager(ohci_usb);
|
function->set_bus_manager(ohci_usb);
|
||||||
ohci_usb->usb_ohci_plug(port, function); // connect to root hub port 3, chihiro needs to use 1 and 2
|
ohci_usb->usb_ohci_plug(port, function);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mcpx_ohci_device::device_start()
|
void mcpx_ohci_device::device_start()
|
||||||
@ -256,6 +257,8 @@ void mcpx_ohci_device::device_start()
|
|||||||
timer = timer_alloc(0);
|
timer = timer_alloc(0);
|
||||||
ohci_usb->set_timer(timer);
|
ohci_usb->set_timer(timer);
|
||||||
ohci_usb->start();
|
ohci_usb->start();
|
||||||
|
for (int i=0;i < connecteds_count;i++)
|
||||||
|
plug_usb_device(connecteds[i].port, connecteds[i].dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mcpx_ohci_device::device_reset()
|
void mcpx_ohci_device::device_reset()
|
||||||
@ -265,6 +268,27 @@ void mcpx_ohci_device::device_reset()
|
|||||||
ohci_usb->reset();
|
ohci_usb->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mcpx_ohci_device::device_config_complete()
|
||||||
|
{
|
||||||
|
char id[8];
|
||||||
|
|
||||||
|
for (int i = 1; i<=4; i++)
|
||||||
|
{
|
||||||
|
sprintf(id, "port%d", i);
|
||||||
|
ohci_usb_connector *conn = downcast<ohci_usb_connector *>(subdevice(id));
|
||||||
|
if (conn)
|
||||||
|
{
|
||||||
|
ohci_function *func = conn->get_device();
|
||||||
|
if (func)
|
||||||
|
{
|
||||||
|
connecteds[connecteds_count].dev = func;
|
||||||
|
connecteds[connecteds_count].port = i;
|
||||||
|
connecteds_count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void mcpx_ohci_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
void mcpx_ohci_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||||
{
|
{
|
||||||
if (ohci_usb)
|
if (ohci_usb)
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
//#define LOG_OHCI
|
//#define LOG_OHCI
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ohci usb controller
|
* OHCI usb controller
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef LOG_OHCI
|
#ifdef LOG_OHCI
|
||||||
@ -721,11 +721,9 @@ void ohci_usb_controller::usb_ohci_interrupts()
|
|||||||
{
|
{
|
||||||
if (((ohcist.hc_regs[HcInterruptStatus] & ohcist.hc_regs[HcInterruptEnable]) != 0) && ((ohcist.hc_regs[HcInterruptEnable] & MasterInterruptEnable) != 0))
|
if (((ohcist.hc_regs[HcInterruptStatus] & ohcist.hc_regs[HcInterruptEnable]) != 0) && ((ohcist.hc_regs[HcInterruptEnable] & MasterInterruptEnable) != 0))
|
||||||
{
|
{
|
||||||
//m_interrupt_handler(1);
|
|
||||||
irq_callback(1);
|
irq_callback(1);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
//m_interrupt_handler(0);
|
|
||||||
irq_callback(0);
|
irq_callback(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -849,8 +847,8 @@ void ohci_usb_controller::usb_ohci_device_address_changed(int old_address, int n
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ohci device base class
|
* Base class for usb devices
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ohci_function::ohci_function()
|
ohci_function::ohci_function()
|
||||||
{
|
{
|
||||||
@ -1322,6 +1320,35 @@ int ohci_function::execute_transfer(int endpoint, int pid, uint8_t *buffer, int
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Usb port connector
|
||||||
|
*/
|
||||||
|
|
||||||
|
DEFINE_DEVICE_TYPE(OHCI_USB_CONNECTOR, ohci_usb_connector, "usb_connector", "Usb Connector Abstraction");
|
||||||
|
|
||||||
|
ohci_usb_connector::ohci_usb_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||||
|
device_t(mconfig, OHCI_USB_CONNECTOR, tag, owner, clock),
|
||||||
|
device_slot_interface(mconfig, *this)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ohci_usb_connector::~ohci_usb_connector()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void ohci_usb_connector::device_start()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
ohci_function* ohci_usb_connector::get_device()
|
||||||
|
{
|
||||||
|
return dynamic_cast<ohci_function *>(get_card_device());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Game controller usb device
|
||||||
|
*/
|
||||||
|
|
||||||
INPUT_PORTS_START(xbox_controller)
|
INPUT_PORTS_START(xbox_controller)
|
||||||
PORT_START("ThumbstickLh") // left analog thumbstick horizontal movement
|
PORT_START("ThumbstickLh") // left analog thumbstick horizontal movement
|
||||||
PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_NAME("ThumbstickLh") PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 0xff)
|
PORT_BIT(0xff, 0x80, IPT_AD_STICK_X) PORT_NAME("ThumbstickLh") PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(0, 0xff)
|
||||||
@ -1391,6 +1418,7 @@ DEFINE_DEVICE_TYPE(OHCI_GAME_CONTROLLER, ohci_game_controller_device, "ohci_gc",
|
|||||||
ohci_game_controller_device::ohci_game_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
ohci_game_controller_device::ohci_game_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
|
||||||
device_t(mconfig, OHCI_GAME_CONTROLLER, tag, owner, clock),
|
device_t(mconfig, OHCI_GAME_CONTROLLER, tag, owner, clock),
|
||||||
ohci_function(),
|
ohci_function(),
|
||||||
|
device_slot_card_interface(mconfig, *this),
|
||||||
m_ThumbstickLh(*this, "ThumbstickLh"),
|
m_ThumbstickLh(*this, "ThumbstickLh"),
|
||||||
m_ThumbstickLv(*this, "ThumbstickLv"),
|
m_ThumbstickLv(*this, "ThumbstickLv"),
|
||||||
m_ThumbstickRh(*this, "ThumbstickRh"),
|
m_ThumbstickRh(*this, "ThumbstickRh"),
|
||||||
|
Loading…
Reference in New Issue
Block a user