chihiro.c: simple way to add per-game patches (nw)

This commit is contained in:
yz70s 2015-05-19 21:39:22 +02:00
parent 111f5dc710
commit c80782eec9

View File

@ -384,6 +384,11 @@ public:
driver_device(mconfig, type, tag),
nvidia_nv2a(NULL),
debug_irq_active(false),
debug_irq_number(0),
dimm_board_memory(NULL),
dimm_board_memory_size(0),
usbhack_index(-1),
usbhack_counter(0),
m_maincpu(*this, "maincpu") { }
DECLARE_READ32_MEMBER(geforce_r);
@ -469,6 +474,7 @@ public:
int debug_irq_number;
UINT8 *dimm_board_memory;
UINT32 dimm_board_memory_size;
int usbhack_index;
int usbhack_counter;
required_device<cpu_device> m_maincpu;
};
@ -1046,36 +1052,32 @@ static const char *const usbregnames[] = {
};
#endif
static const struct {
char *game_name;
struct {
UINT32 address;
UINT8 write_byte;
} modify[16];
} hacks[2] = { { "chihiro", { { 0x6a79f, 0x01 }, { 0x6a7a0, 0x00 }, { 0x6b575, 0x00 }, { 0x6b576, 0x00 }, { 0x6b5af, 0x75 }, { 0x6b78a, 0x75 }, { 0x6b7ca, 0x00 }, { 0x6b7b8, 0x00 }, { 0x8f5b2, 0x75 }, { 0x79a9e, 0x74 }, { 0x79b80, 0x74 }, { 0x79b97, 0x74 }, { 0, 0 } } },
{ "outr2", { { 0x12e4cf, 0x01 }, { 0x12e4d0, 0x00 }, { 0x4793e, 0x01 }, { 0x4793f, 0x00 }, { 0x47aa3, 0x01 }, { 0x47aa4, 0x00 }, { 0x14f2b6, 0x84 }, { 0x14f2d1, 0x75 }, { 0x8732f, 0x7d }, { 0x87384, 0x7d }, { 0x87388, 0xeb }, { 0, 0 } } } };
READ32_MEMBER(chihiro_state::usbctrl_r)
{
if (offset == 0) { /* hack needed until usb (and jvs) is implemented */
if (usbhack_counter == 0) {
m_maincpu->space(0).write_byte(0x6a79f, 0x01);
m_maincpu->space(0).write_byte(0x6a7a0, 0x00);
m_maincpu->space(0).write_byte(0x6b575, 0x00);
m_maincpu->space(0).write_byte(0x6b576, 0x00);
m_maincpu->space(0).write_byte(0x6b5af, 0x75);
m_maincpu->space(0).write_byte(0x6b78a, 0x75);
m_maincpu->space(0).write_byte(0x6b7ca, 0x00);
m_maincpu->space(0).write_byte(0x6b7b8, 0x00);
m_maincpu->space(0).write_byte(0x8f5b2, 0x75);
m_maincpu->space(0).write_byte(0x79a9e, 0x74);
m_maincpu->space(0).write_byte(0x79b80, 0x74);
m_maincpu->space(0).write_byte(0x79b97, 0x74);
}
// after game loaded
if (usbhack_counter == 1) {
m_maincpu->space(0).write_byte(0x12e4cf, 0x01);
m_maincpu->space(0).write_byte(0x12e4d0, 0x00);
m_maincpu->space(0).write_byte(0x4793e, 0x01);
m_maincpu->space(0).write_byte(0x4793f, 0x00);
m_maincpu->space(0).write_byte(0x47aa3, 0x01);
m_maincpu->space(0).write_byte(0x47aa4, 0x00);
m_maincpu->space(0).write_byte(0x14f2b6, 0x84);
m_maincpu->space(0).write_byte(0x14f2d1, 0x75);
m_maincpu->space(0).write_byte(0x8732f, 0x7d);
m_maincpu->space(0).write_byte(0x87384, 0x7d);
m_maincpu->space(0).write_byte(0x87388, 0xeb);
int a, p;
if (offset == 0) { /* hacks needed until usb (and jvs) is implemented */
if (usbhack_counter == 0)
p = 0;
else if (usbhack_counter == 1) // after game loaded
p = usbhack_index;
else
p = -1;
if (p >= 0) {
for (a = 0; a < 16; a++) {
if (hacks[p].modify[a].address == 0)
break;
m_maincpu->space(0).write_byte(hacks[p].modify[a].address, hacks[p].modify[a].write_byte);
}
}
usbhack_counter++;
}
@ -1790,6 +1792,12 @@ void chihiro_state::machine_start()
apust.timer->enable(false);
if (machine().debug_flags & DEBUG_FLAG_ENABLED)
debug_console_register_command(machine(), "chihiro", CMDFLAG_NONE, 0, 1, 4, chihiro_debug_commands);
usbhack_index = -1;
for (int a = 1; a < 2; a++)
if (strcmp(machine().basename(), hacks[a].game_name) == 0) {
usbhack_index = a;
break;
}
usbhack_counter = 0;
// savestates
save_item(NAME(debug_irq_active));