diff options
Diffstat (limited to 'src/mame/drivers/konamigx.c')
-rw-r--r-- | src/mame/drivers/konamigx.c | 215 |
1 files changed, 96 insertions, 119 deletions
diff --git a/src/mame/drivers/konamigx.c b/src/mame/drivers/konamigx.c index 3d443af61d5..01903dae7eb 100644 --- a/src/mame/drivers/konamigx.c +++ b/src/mame/drivers/konamigx.c @@ -106,14 +106,6 @@ - -static int konamigx_cfgport; - -static int gx_rdport1_3, gx_syncen; - -static emu_timer *dmadelay_timer; -static emu_timer *boothack_timer; - /**********************************************************************************/ /* Konami ESC (E Security Chip) protection chip found on: @@ -179,13 +171,10 @@ static struct sprite_entry { static void generate_sprites(address_space &space, UINT32 src, UINT32 spr, int count) { - int i; - int scount; - int ecount; - scount = 0; - ecount = 0; + int scount = 0; + int ecount = 0; - for(i=0; i<count; i++) { + for(int i=0; i<count; i++) { UINT32 adr = src + 0x100*i; int pri; if(!space.read_word(adr+2)) @@ -200,7 +189,7 @@ static void generate_sprites(address_space &space, UINT32 src, UINT32 spr, int c } //qsort(sprites, ecount, sizeof(struct sprite_entry), pri_comp); - for(i=0; i<ecount; i++) { + for(int i=0; i<ecount; i++) { UINT32 adr = sprites[i].adr; if(adr) { UINT32 set =(space.read_word(adr) << 16)|space.read_word(adr+2); @@ -315,43 +304,37 @@ static void generate_sprites(address_space &space, UINT32 src, UINT32 spr, int c } } -static void tkmmpzdm_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) +void konamigx_state::tkmmpzdm_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) { - konamigx_state* state = space.machine().driver_data<konamigx_state>(); - state->konamigx_esc_alert(space.machine().driver_data<konamigx_state>()->m_workram, 0x0142, 0x100, 0); + konamigx_esc_alert(m_workram, 0x0142, 0x100, 0); } -static void dragoonj_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) +void konamigx_state::dragoonj_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) { - konamigx_state* state = space.machine().driver_data<konamigx_state>(); - state->konamigx_esc_alert(space.machine().driver_data<konamigx_state>()->m_workram, 0x5c00, 0x100, 0); + konamigx_esc_alert(m_workram, 0x5c00, 0x100, 0); } -static void sal2_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) +void konamigx_state::sal2_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) { - konamigx_state* state = space.machine().driver_data<konamigx_state>(); - state->konamigx_esc_alert(space.machine().driver_data<konamigx_state>()->m_workram, 0x1c8c, 0x172, 1); + konamigx_esc_alert(m_workram, 0x1c8c, 0x172, 1); } -static void sexyparo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) +void konamigx_state::sexyparo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) { // The d20000 should probably be p3 generate_sprites(space, 0xc00604, 0xd20000, 0xfc); } -static void tbyahhoo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) +void konamigx_state::tbyahhoo_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) { generate_sprites(space, 0xc00000, 0xd20000, 0x100); } -static void daiskiss_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) +void konamigx_state::daiskiss_esc(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4) { generate_sprites(space, 0xc00000, 0xd20000, 0x100); } -static UINT8 esc_program[4096]; -static void (*esc_cb)(address_space &space, UINT32 p1, UINT32 p2, UINT32 p3, UINT32 p4); - WRITE32_MEMBER(konamigx_state::esc_w) { UINT32 opcode; @@ -386,7 +369,7 @@ WRITE32_MEMBER(konamigx_state::esc_w) break; case 2: // Load program for(i=0; i<4096; i++) - esc_program[i] = space.read_byte(params+i); + m_esc_program[i] = space.read_byte(params+i); /* { FILE *f; @@ -400,12 +383,12 @@ WRITE32_MEMBER(konamigx_state::esc_w) */ break; case 1: // Run program - if(esc_cb) { + if(m_esc_cb) { UINT32 p1 = (space.read_word(params+0)<<16) | space.read_word(params+2); UINT32 p2 = (space.read_word(params+4)<<16) | space.read_word(params+6); UINT32 p3 = (space.read_word(params+8)<<16) | space.read_word(params+10); UINT32 p4 = (space.read_word(params+12)<<16) | space.read_word(params+14); - esc_cb(space, p1, p2, p3, p4); + (this->*m_esc_cb)(space, p1, p2, p3, p4); } break; default: @@ -414,9 +397,9 @@ WRITE32_MEMBER(konamigx_state::esc_w) } space.write_byte(data+9, ESTATE_END); - if (konamigx_wrport1_1 & 0x10) + if (m_gx_wrport1_1 & 0x10) { - gx_rdport1_3 &= ~8; + m_gx_rdport1_3 &= ~8; m_maincpu->set_input_line(4, HOLD_LINE); } } @@ -439,7 +422,7 @@ WRITE32_MEMBER(konamigx_state::esc_w) CUSTOM_INPUT_MEMBER(konamigx_state::gx_rdport1_3_r) { - return (gx_rdport1_3 >> 1); + return (m_gx_rdport1_3 >> 1); } WRITE32_MEMBER(konamigx_state::eeprom_w) @@ -462,7 +445,7 @@ WRITE32_MEMBER(konamigx_state::eeprom_w) m_eepromout->write(odata, 0xff); - konamigx_wrport1_0 = odata; + m_gx_wrport1_0 = odata; } if (ACCESSING_BITS_16_23) @@ -478,12 +461,12 @@ WRITE32_MEMBER(konamigx_state::eeprom_w) bit 0 = CCU1-INT1 enable */ - konamigx_wrport1_1 = (data>>16)&0xff; -// logerror("write %x to IRQ register (PC=%x)\n", konamigx_wrport1_1, space.device().safe_pc()); + m_gx_wrport1_1 = (data>>16)&0xff; +// logerror("write %x to IRQ register (PC=%x)\n", m_gx_wrport1_1, space.device().safe_pc()); - // gx_syncen is to ensure each IRQ is trigger at least once after being enabled - if (konamigx_wrport1_1 & 0x80) - gx_syncen |= konamigx_wrport1_1 & 0x1f; + // m_gx_syncen is to ensure each IRQ is triggered at least once after being enabled + if (m_gx_wrport1_1 & 0x80) + m_gx_syncen |= m_gx_wrport1_1 & 0x1f; } } @@ -526,7 +509,7 @@ WRITE32_MEMBER(konamigx_state::control_w) m_k055673->k053246_set_objcha_line((data&0x100000) ? ASSERT_LINE : CLEAR_LINE); - konamigx_wrport2 = (data>>16)&0xff; + m_gx_wrport2 = (data>>16)&0xff; } } @@ -534,8 +517,6 @@ WRITE32_MEMBER(konamigx_state::control_w) /**********************************************************************************/ /* IRQ controllers */ -static int suspension_active, resume_trigger; - READ32_MEMBER(konamigx_state::ccu_r) { // the routine at 204abe in opengolf polls to see if we're in vblank (it wants values between 0x111 and 0x1df) @@ -559,14 +540,14 @@ WRITE32_MEMBER(konamigx_state::ccu_w) if (ACCESSING_BITS_24_31) { m_maincpu->set_input_line(1, CLEAR_LINE); - gx_syncen |= 0x20; + m_gx_syncen |= 0x20; } // hblank interrupt ACK if (ACCESSING_BITS_8_15) { m_maincpu->set_input_line(2, CLEAR_LINE); - gx_syncen |= 0x40; + m_gx_syncen |= 0x40; } } } @@ -588,22 +569,22 @@ TIMER_CALLBACK_MEMBER(konamigx_state::boothack_callback) TIMER_CALLBACK_MEMBER(konamigx_state::dmaend_callback) { // foul-proof (CPU0 could be deactivated while we wait) - if (resume_trigger && suspension_active) + if (m_resume_trigger && m_suspension_active) { - suspension_active = 0; - machine().scheduler().trigger(resume_trigger); + m_suspension_active = 0; + machine().scheduler().trigger(m_resume_trigger); } // DMA busy flag must be cleared before triggering IRQ 3 - gx_rdport1_3 &= ~2; + m_gx_rdport1_3 &= ~2; // IRQ 3 is the "object DMA end" IRQ also happens during vblank - if ((konamigx_wrport1_1 & 0x84) == 0x84 || (gx_syncen & 4)) + if ((m_gx_wrport1_1 & 0x84) == 0x84 || (m_gx_syncen & 4)) { - gx_syncen &= ~4; + m_gx_syncen &= ~4; // lower OBJINT-REQ flag and trigger interrupt - gx_rdport1_3 &= ~0x80; + m_gx_rdport1_3 &= ~0x80; m_maincpu->set_input_line(3, HOLD_LINE); } } @@ -611,7 +592,7 @@ TIMER_CALLBACK_MEMBER(konamigx_state::dmaend_callback) void konamigx_state::dmastart_callback(int data) { // raise the DMA busy flag - gx_rdport1_3 |= 2; + m_gx_rdport1_3 |= 2; // begin transfer if DMAEN(bit4 of OBJSET1) is set (see p.48) if (m_k055673->k053246_read_register(5) & 0x10) @@ -621,27 +602,27 @@ void konamigx_state::dmastart_callback(int data) } // simulate DMA delay - dmadelay_timer->adjust(attotime::from_usec(120)); + m_dmadelay_timer->adjust(attotime::from_usec(120)); } INTERRUPT_GEN_MEMBER(konamigx_state::konamigx_vbinterrupt) { // lift idle suspension - if (resume_trigger && suspension_active) + if (m_resume_trigger && m_suspension_active) { - suspension_active = 0; - machine().scheduler().trigger(resume_trigger); + m_suspension_active = 0; + machine().scheduler().trigger(m_resume_trigger); } // IRQ 1 is the main 60hz vblank interrupt - if (gx_syncen & 0x20) + if (m_gx_syncen & 0x20) { - gx_syncen &= ~0x20; + m_gx_syncen &= ~0x20; - if ((konamigx_wrport1_1 & 0x81) == 0x81 || (gx_syncen & 1)) + if ((m_gx_wrport1_1 & 0x81) == 0x81 || (m_gx_syncen & 1)) { - gx_syncen &= ~1; + m_gx_syncen &= ~1; device.execute().set_input_line(1, HOLD_LINE); } } @@ -656,26 +637,26 @@ TIMER_DEVICE_CALLBACK_MEMBER(konamigx_state::konamigx_hbinterrupt) if (scanline == 240) { // lift idle suspension - if (resume_trigger && suspension_active) + if (m_resume_trigger && m_suspension_active) { - suspension_active = 0; - machine().scheduler().trigger(resume_trigger); + m_suspension_active = 0; + machine().scheduler().trigger(m_resume_trigger); } // IRQ 1 is the main 60hz vblank interrupt - // the gx_syncen & 0x20 test doesn't work on type 3 or 4 ROM boards, likely because the ROM board + // the m_gx_syncen & 0x20 test doesn't work on type 3 or 4 ROM boards, likely because the ROM board // generates the timing in those cases. With this change, rushing heroes and rng2 boot :) // maybe this interrupt should only be every 30fps, or maybe there are flags to prevent the game running too fast // the real hardware should output the display for each screen on alternate frames // if(device->m_screen->frame_number() & 1) - if (1) // gx_syncen & 0x20) + if (1) // m_gx_syncen & 0x20) { - gx_syncen &= ~0x20; + m_gx_syncen &= ~0x20; - if ((konamigx_wrport1_1 & 0x81) == 0x81 || (gx_syncen & 1)) + if ((m_gx_wrport1_1 & 0x81) == 0x81 || (m_gx_syncen & 1)) { - gx_syncen &= ~1; + m_gx_syncen &= ~1; m_maincpu->set_input_line(1, HOLD_LINE); } @@ -686,13 +667,13 @@ TIMER_DEVICE_CALLBACK_MEMBER(konamigx_state::konamigx_hbinterrupt) else if(scanline < 240) // hblank { // IRQ 2 is a programmable interrupt with scanline resolution - if (gx_syncen & 0x40) + if (m_gx_syncen & 0x40) { - gx_syncen &= ~0x40; + m_gx_syncen &= ~0x40; - if ((konamigx_wrport1_1 & 0x82) == 0x82 || (gx_syncen & 2)) + if ((m_gx_wrport1_1 & 0x82) == 0x82 || (m_gx_syncen & 2)) { - gx_syncen &= ~2; + m_gx_syncen &= ~2; m_maincpu->set_input_line(2, HOLD_LINE); } } @@ -759,8 +740,6 @@ READ32_MEMBER(konamigx_state::type1_roz_r2) return ROM[offset]; } -//static int sync_frame = 0; - READ32_MEMBER(konamigx_state::type3_sync_r) { if(m_konamigx_current_frame==0) @@ -768,7 +747,7 @@ READ32_MEMBER(konamigx_state::type3_sync_r) else return 0;// return 0xfffffffe | 0; } -static int last_prot_op, last_prot_clk; + /* Run and Gun 2, Rushing Heroes, Winning Spike, and Vs. Net Soccer contain a XILINX FPGA that serves as security. @@ -844,8 +823,6 @@ static int last_prot_op, last_prot_clk; move.l #$C10400,($C102EC).l move.l #$C10400,($C102EC).l */ -//static int cc=0; - WRITE32_MEMBER(konamigx_state::type4_prot_w) { int clk; @@ -853,18 +830,18 @@ WRITE32_MEMBER(konamigx_state::type4_prot_w) if (offset == 1) { - last_prot_op = data>>16; + m_last_prot_op = data>>16; } else { data >>= 16; clk = data & 0x200; - if ((clk == 0) && (last_prot_clk != 0)) + if ((clk == 0) && (m_last_prot_clk != 0)) { - if (last_prot_op != -1) + if (m_last_prot_op != -1) { -// osd_printf_debug("type 4 prot command: %x\n", last_prot_op); +// osd_printf_debug("type 4 prot command: %x\n", m_last_prot_op); /* known commands: rng2 rushhero vsnet winspike what @@ -874,7 +851,7 @@ WRITE32_MEMBER(konamigx_state::type4_prot_w) 0d97 0515 parse big DMA list at c10200 57a copy 4 bytes from c00f10 to c10f00 and 4 bytes from c00f30 to c0fe00 */ - if ((last_prot_op == 0xa56) || (last_prot_op == 0xd96) || (last_prot_op == 0xd14) || (last_prot_op == 0xd1c)) + if ((m_last_prot_op == 0xa56) || (m_last_prot_op == 0xd96) || (m_last_prot_op == 0xd14) || (m_last_prot_op == 0xd1c)) { // memcpy from c01000 to c01400 for 0x400 bytes (startup check for type 4 games) for (i = 0; i < 0x400; i += 2) @@ -882,7 +859,7 @@ WRITE32_MEMBER(konamigx_state::type4_prot_w) space.write_word(0xc01400+i, space.read_word(0xc01000+i)); } } - else if(last_prot_op == 0x57a) // winspike + else if(m_last_prot_op == 0x57a) // winspike { /* player 1 input buffer protection */ space.write_dword(0xc10f00, space.read_dword(0xc00f10)); @@ -894,7 +871,7 @@ WRITE32_MEMBER(konamigx_state::type4_prot_w) space.write_dword(0xc0fe00, space.read_dword(0xc00f30)); space.write_dword(0xc0fe04, space.read_dword(0xc00f34)); } - else if(last_prot_op == 0xd97) // rushhero + else if(m_last_prot_op == 0xd97) // rushhero { int src = 0xc09ff0; int dst = 0xd20000; @@ -917,7 +894,7 @@ WRITE32_MEMBER(konamigx_state::type4_prot_w) space.write_byte(0xc01cc4, ~space.read_byte(0xc00547)); space.write_byte(0xc01cc5, ~space.read_byte(0xc00567)); } - else if(last_prot_op == 0xb16) // slamdnk2 + else if(m_last_prot_op == 0xb16) // slamdnk2 { int src = 0xc01000; int dst = 0xd20000; @@ -932,36 +909,36 @@ WRITE32_MEMBER(konamigx_state::type4_prot_w) //maybe here there's a [$d8001f] <- 0x31 write too? } - else if(last_prot_op == 0x515) // vsnetscr screen 1 + else if(m_last_prot_op == 0x515) // vsnetscr screen 1 { int adr; - //printf("GXT4: command %x %d (PC=%x)\n", last_prot_op, cc++, space.device().safe_pc()); + //printf("GXT4: command %x %d (PC=%x)\n", m_last_prot_op, cc++, space.device().safe_pc()); for (adr = 0; adr < 0x400; adr += 2) space.write_word(0xc01c00+adr, space.read_word(0xc01800+adr)); } - else if(last_prot_op == 0x115d) // vsnetscr screen 2 + else if(m_last_prot_op == 0x115d) // vsnetscr screen 2 { int adr; - //printf("GXT4: command %x %d (PC=%x)\n", last_prot_op, cc++, space.device().safe_pc()); + //printf("GXT4: command %x %d (PC=%x)\n", m_last_prot_op, cc++, space.device().safe_pc()); for (adr = 0; adr < 0x400; adr += 2) space.write_word(0xc18c00+adr, space.read_word(0xc18800+adr)); } else { - printf("GXT4: unknown protection command %x (PC=%x)\n", last_prot_op, space.device().safe_pc()); + printf("GXT4: unknown protection command %x (PC=%x)\n", m_last_prot_op, space.device().safe_pc()); } - if (konamigx_wrport1_1 & 0x10) + if (m_gx_wrport1_1 & 0x10) { - gx_rdport1_3 &= ~8; + m_gx_rdport1_3 &= ~8; m_maincpu->set_input_line(4, HOLD_LINE); } // don't accidentally do a phony command - last_prot_op = -1; + m_last_prot_op = -1; } } - last_prot_clk = clk; + m_last_prot_clk = clk; } } @@ -1180,7 +1157,7 @@ static INPUT_PORTS_START( common ) // note: racin' force expects bit 1 of the eeprom port to toggle PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_serial_93cxx_device, do_read) - PORT_BIT( 0x000000fe, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, konamigx_state,gx_rdport1_3_r, NULL) + PORT_BIT( 0x000000fe, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, konamigx_state, gx_rdport1_3_r, NULL) PORT_BIT( 0x00000100, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x00000200, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x00000400, IP_ACTIVE_LOW, IPT_UNKNOWN ) @@ -3578,22 +3555,22 @@ ROM_END MACHINE_START_MEMBER(konamigx_state,konamigx) { - save_item(NAME(konamigx_wrport1_1)); + save_item(NAME(m_gx_wrport1_1)); } MACHINE_RESET_MEMBER(konamigx_state,konamigx) { - konamigx_wrport1_0 = konamigx_wrport1_1 = 0; - konamigx_wrport2 = 0; + m_gx_wrport1_0 = m_gx_wrport1_1 = 0; + m_gx_wrport2 = 0; /* bit0 : EEPROM data(don't care) bit1 : DMA busy (cleared) bit2-7: IRQ ready (all set) */ - gx_rdport1_3 = 0xfc; - gx_syncen = 0; - suspension_active = 0; + m_gx_rdport1_3 = 0xfc; + m_gx_syncen = 0; + m_suspension_active = 0; // Hold sound CPUs in reset m_soundcpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); @@ -3633,7 +3610,7 @@ MACHINE_RESET_MEMBER(konamigx_state,konamigx) // To hack around this, we underclock the 68020 for 10 seconds during POST m_maincpu->set_clock_scale(0.66f); - boothack_timer->adjust(attotime::from_seconds(10)); + m_boothack_timer->adjust(attotime::from_seconds(10)); } if (!strcmp(setname, "le2") || @@ -3708,15 +3685,15 @@ DRIVER_INIT_MEMBER(konamigx_state,konamigx) int i, match; int readback = 0; - konamigx_cfgport = -1; - last_prot_op = -1; - last_prot_clk = 0; + m_gx_cfgport = -1; + m_last_prot_op = -1; + m_last_prot_clk = 0; - esc_cb = 0; - resume_trigger = 0; + m_esc_cb = NULL; + m_resume_trigger = 0; - dmadelay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(konamigx_state::dmaend_callback),this)); - boothack_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(konamigx_state::boothack_callback),this)); + m_dmadelay_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(konamigx_state::dmaend_callback),this)); + m_boothack_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(konamigx_state::boothack_callback),this)); i = match = 0; while ((gameDefs[i].cfgport != -1) && (!match)) @@ -3724,7 +3701,7 @@ DRIVER_INIT_MEMBER(konamigx_state,konamigx) if (!strcmp(machine().system().name, gameDefs[i].romname)) { match = 1; - konamigx_cfgport = gameDefs[i].cfgport; + m_gx_cfgport = gameDefs[i].cfgport; readback = gameDefs[i].readback; switch (gameDefs[i].special) @@ -3745,24 +3722,24 @@ DRIVER_INIT_MEMBER(konamigx_state,konamigx) rom[0x810f1] &= ~1; // fix checksum rom[0x872ea] |= 0xe0000; // enable plane B,C,D - esc_cb = tkmmpzdm_esc; + m_esc_cb = &konamigx_state::tkmmpzdm_esc; break; } case 3: // dragoon might - esc_cb = dragoonj_esc; + m_esc_cb = &konamigx_state::dragoonj_esc; break; case 4: // sexyparo - esc_cb = sexyparo_esc; + m_esc_cb = &konamigx_state::sexyparo_esc; break; case 5: // daiskiss - esc_cb = daiskiss_esc; + m_esc_cb = &konamigx_state::daiskiss_esc; break; case 6: // salamander 2 - esc_cb = sal2_esc; + m_esc_cb = &konamigx_state::sal2_esc; break; case 7: // install type 4 Xilinx protection for non-type 3/4 games @@ -3770,7 +3747,7 @@ DRIVER_INIT_MEMBER(konamigx_state,konamigx) break; case 8: // tbyahhoo - esc_cb = tbyahhoo_esc; + m_esc_cb = &konamigx_state::tbyahhoo_esc; break; case 9: // fantjour |