Skip to content

Commit dcdde1f

Browse files
authored
-konami/konppc.cpp, konami/gticlub.cpp, konami/hornet.cpp, konami/nwk-tr.cpp, konami/zr107.cpp: Cleaned up code: (#13300)
* Removed hard-coded tags and reduced code duplication. * Improved save state support, suppress side effects for debugger reads. * Increased size of CG board ROM regions to avoid out-of-bounds errors if higher banks are selected. * Use bitfield extraction helpers, reduced literal tag usage, use logmacro.h for logging, made some variables const. * Reduced preprocessor macros, updated comments. -konami/gticlub.cpp: Removed unnecessary code. -konami/hornet.cpp: Split driver state class for different configurations, moved bank configuration into machine_start(). -konami/nwk-tr.cpp: Split palette per CG boards (K001604 also has palette RAM interface?).
1 parent 3b67f9a commit dcdde1f

File tree

6 files changed

+739
-751
lines changed

6 files changed

+739
-751
lines changed

src/mame/konami/gticlub.cpp

Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ Check zr107.cpp for details on the top board.
124124
125125
Operation Thunder Hurricane uses an additional top board gun/analog controls. Analog inputs are controlled by two CCD
126126
cameras, one from each gun. This specific variation uses a K056230 for networking between the cpu board to receive
127-
the analog values that way. Teraburst uses a different variation of this I/O board replacing the K056230 with a K056800 (see hornet.cpp).
127+
the analog values that way. Teraburst uses a different variation of this I/O board replacing the K056230 with a K056800 (see konami/hornet.cpp).
128128
129129
GN680 PWB(E)403381B
130130
|------------------------------------------|
@@ -245,6 +245,16 @@ Hang Pilot (uses an unknown but similar video board) 12W
245245
#include "speaker.h"
246246

247247

248+
#define LOG_SYSREG (1 << 1)
249+
250+
#define LOG_ALL (LOG_SYSREG)
251+
252+
#define VERBOSE (0)
253+
254+
#include "logmacro.h"
255+
256+
#define LOGSYSREG(...) LOGMASKED(LOG_SYSREG, __VA_ARGS__)
257+
248258
namespace {
249259

250260
#define DEBUG_GTI (0)
@@ -256,7 +266,7 @@ class gticlub_base_state : public driver_device
256266
: driver_device(mconfig, type, tag)
257267
, m_maincpu(*this, "maincpu")
258268
, m_audiocpu(*this, "audiocpu")
259-
, m_dsp(*this, {"dsp", "dsp2"}) // TODO: hardcoded tags in machine/konpc.cpp
269+
, m_dsp(*this, "dsp%u", 1U)
260270
, m_k056800(*this, "k056800")
261271
, m_adc1038(*this, "adc1038")
262272
, m_eeprom(*this, "eeprom")
@@ -266,6 +276,7 @@ class gticlub_base_state : public driver_device
266276
, m_k001604(*this, "k001604%u", 1U)
267277
, m_work_ram(*this, "work_ram")
268278
, m_sharc_dataram(*this, "sharc%u_dataram", 0U)
279+
, m_cgboard_bank(*this, "cgboard_%u_bank", 0U)
269280
, m_analog(*this, "AN%u", 0U)
270281
, m_ports(*this, "IN%u", 0)
271282
, m_pcb_digit(*this, "pcbdigit%u", 0U)
@@ -290,12 +301,14 @@ class gticlub_base_state : public driver_device
290301
optional_device_array<k001604_device, 2> m_k001604;
291302
required_shared_ptr<uint32_t> m_work_ram;
292303
optional_shared_ptr_array<uint32_t, 2> m_sharc_dataram;
304+
optional_memory_bank_array<2> m_cgboard_bank;
293305
optional_ioport_array<4> m_analog;
294306
required_ioport_array<4> m_ports;
295307
output_finder<2> m_pcb_digit;
296308
memory_view m_cg_view;
297309

298-
static rgb_t gticlub_XR5G5B5(uint32_t raw);
310+
emu_timer *m_sound_irq_timer = nullptr;
311+
299312
uint8_t sysreg_r(offs_t offset);
300313
void sysreg_w(offs_t offset, uint8_t data);
301314
void soundtimer_en_w(uint16_t data);
@@ -306,8 +319,6 @@ class gticlub_base_state : public driver_device
306319
int adc1038_input_callback(int input);
307320

308321
void sound_memmap(address_map &map) ATTR_COLD;
309-
310-
emu_timer *m_sound_irq_timer = nullptr;
311322
};
312323

313324
// with GN678 Video board
@@ -361,7 +372,6 @@ class thunderh_state : public gticlub_state
361372
};
362373

363374
// with Voodoo based video board
364-
365375
class hangplt_state : public gticlub_base_state
366376
{
367377
public:
@@ -382,16 +392,10 @@ class hangplt_state : public gticlub_base_state
382392
template <uint8_t Which> uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
383393

384394
void hangplt_map(address_map &map) ATTR_COLD;
385-
void hangplt_sharc0_map(address_map &map) ATTR_COLD;
386-
void hangplt_sharc1_map(address_map &map) ATTR_COLD;
395+
template <unsigned Board> void hangplt_sharc_map(address_map &map) ATTR_COLD;
387396
};
388397

389398

390-
rgb_t gticlub_base_state::gticlub_XR5G5B5(uint32_t raw)
391-
{
392-
return rgb_t(pal5bit(raw >> 10), pal5bit(raw >> 5), pal5bit(raw >> 0));
393-
}
394-
395399
/******************************************************************/
396400

397401
uint8_t gticlub_base_state::sysreg_r(offs_t offset)
@@ -420,7 +424,8 @@ uint8_t gticlub_base_state::sysreg_r(offs_t offset)
420424
}
421425

422426
default:
423-
osd_printf_debug("sysreg_r %d\n", offset);
427+
if (!machine().side_effects_disabled())
428+
LOGSYSREG("sysreg_r %d\n", offset);
424429
break;
425430
}
426431
return 0;
@@ -436,20 +441,20 @@ void gticlub_base_state::sysreg_w(offs_t offset, uint8_t data)
436441
break;
437442

438443
case 3:
439-
m_eeprom->di_write((data & 0x01) ? 1 : 0);
440-
m_eeprom->clk_write((data & 0x02) ? ASSERT_LINE : CLEAR_LINE);
441-
m_eeprom->cs_write((data & 0x04) ? ASSERT_LINE : CLEAR_LINE);
444+
m_eeprom->di_write(BIT(data, 0));
445+
m_eeprom->clk_write(BIT(data, 1));
446+
m_eeprom->cs_write(BIT(data, 2));
442447
break;
443448

444449
case 4:
445-
if (data & 0x80) // CG Board 1 IRQ Ack
450+
if (BIT(data, 7)) // CG Board 1 IRQ Ack
446451
m_maincpu->set_input_line(INPUT_LINE_IRQ1, CLEAR_LINE);
447452

448-
if (data & 0x40) // CG Board 0 IRQ Ack
453+
if (BIT(data, 6)) // CG Board 0 IRQ Ack
449454
m_maincpu->set_input_line(INPUT_LINE_IRQ0, CLEAR_LINE);
450455

451-
m_adc1038->di_write((data >> 0) & 1);
452-
m_adc1038->clk_write((data >> 1) & 1);
456+
m_adc1038->di_write(BIT(data, 0));
457+
m_adc1038->clk_write(BIT(data, 1));
453458

454459
m_konppc->set_cgboard_id((data >> 4) & 0x3);
455460
m_cg_view.select(m_konppc->get_cgboard_id() ? 1 : 0);
@@ -470,7 +475,7 @@ TIMER_CALLBACK_MEMBER(gticlub_base_state::sound_irq)
470475

471476
void gticlub_base_state::soundtimer_en_w(uint16_t data)
472477
{
473-
if (data & 1)
478+
if (BIT(data, 0))
474479
{
475480
// Reset and disable timer
476481
m_sound_irq_timer->adjust(attotime::from_usec(m_sound_timer_usec));
@@ -585,34 +590,23 @@ void thunderh_state::gn680_memmap(address_map &map)
585590

586591
void gticlub_state::sharc_map(address_map &map)
587592
{
588-
map(0x400000, 0x41ffff).rw(m_konppc, FUNC(konppc_device::cgboard_0_shared_sharc_r), FUNC(konppc_device::cgboard_0_shared_sharc_w));
593+
map(0x400000, 0x41ffff).rw(m_konppc, FUNC(konppc_device::cgboard_shared_sharc_r<0>), FUNC(konppc_device::cgboard_shared_sharc_w<0>));
589594
map(0x500000, 0x5fffff).ram().share(m_sharc_dataram[0]).lr32(NAME([this](offs_t offset) { return m_sharc_dataram[0][offset] & 0xffff; }));
590595
map(0x600000, 0x6fffff).rw(m_k001005, FUNC(k001005_device::read), FUNC(k001005_device::write));
591-
map(0x700000, 0x7000ff).rw(m_konppc, FUNC(konppc_device::cgboard_0_comm_sharc_r), FUNC(konppc_device::cgboard_0_comm_sharc_w));
592-
}
593-
594-
void hangplt_state::hangplt_sharc0_map(address_map &map)
595-
{
596-
map(0x0400000, 0x041ffff).rw(m_konppc, FUNC(konppc_device::cgboard_0_shared_sharc_r), FUNC(konppc_device::cgboard_0_shared_sharc_w));
597-
map(0x0500000, 0x05fffff).ram().share(m_sharc_dataram[0]).lr32(NAME([this](offs_t offset) { return m_sharc_dataram[0][offset] & 0xffff; }));
598-
map(0x1400000, 0x14fffff).ram();
599-
map(0x2400000, 0x27fffff).r(m_konppc, FUNC(konppc_device::nwk_voodoo_0_r)).w(m_voodoo[0], FUNC(generic_voodoo_device::write));
600-
map(0x3400000, 0x34000ff).rw(m_konppc, FUNC(konppc_device::cgboard_0_comm_sharc_r), FUNC(konppc_device::cgboard_0_comm_sharc_w));
601-
map(0x3401000, 0x34fffff).w(m_konppc, FUNC(konppc_device::nwk_fifo_0_w));
602-
map(0x3500000, 0x3507fff).rw(m_konppc, FUNC(konppc_device::K033906_0_r), FUNC(konppc_device::K033906_0_w));
603-
map(0x3600000, 0x37fffff).bankr("master_cgboard_bank");
596+
map(0x700000, 0x7000ff).rw(m_konppc, FUNC(konppc_device::cgboard_comm_sharc_r<0>), FUNC(konppc_device::cgboard_comm_sharc_w<0>));
604597
}
605598

606-
void hangplt_state::hangplt_sharc1_map(address_map &map)
599+
template <unsigned Board>
600+
void hangplt_state::hangplt_sharc_map(address_map &map)
607601
{
608-
map(0x0400000, 0x041ffff).rw(m_konppc, FUNC(konppc_device::cgboard_1_shared_sharc_r), FUNC(konppc_device::cgboard_1_shared_sharc_w));
609-
map(0x0500000, 0x05fffff).ram().share(m_sharc_dataram[1]).lr32(NAME([this](offs_t offset) { return m_sharc_dataram[1][offset] & 0xffff; }));
602+
map(0x0400000, 0x041ffff).rw(m_konppc, FUNC(konppc_device::cgboard_shared_sharc_r<Board>), FUNC(konppc_device::cgboard_shared_sharc_w<Board>));
603+
map(0x0500000, 0x05fffff).ram().share(m_sharc_dataram[Board]).lr32(NAME([this](offs_t offset) { return m_sharc_dataram[Board][offset] & 0xffff; }));
610604
map(0x1400000, 0x14fffff).ram();
611-
map(0x2400000, 0x27fffff).r(m_konppc, FUNC(konppc_device::nwk_voodoo_1_r)).w(m_voodoo[1], FUNC(generic_voodoo_device::write));
612-
map(0x3400000, 0x34000ff).rw(m_konppc, FUNC(konppc_device::cgboard_1_comm_sharc_r), FUNC(konppc_device::cgboard_1_comm_sharc_w));
613-
map(0x3401000, 0x34fffff).w(m_konppc, FUNC(konppc_device::nwk_fifo_1_w));
614-
map(0x3500000, 0x3507fff).rw(m_konppc, FUNC(konppc_device::K033906_1_r), FUNC(konppc_device::K033906_1_w));
615-
map(0x3600000, 0x37fffff).bankr("slave_cgboard_bank");
605+
map(0x2400000, 0x27fffff).r(m_konppc, FUNC(konppc_device::nwk_voodoo_r<Board>)).w(m_voodoo[Board], FUNC(generic_voodoo_device::write));
606+
map(0x3400000, 0x34000ff).rw(m_konppc, FUNC(konppc_device::cgboard_comm_sharc_r<Board>), FUNC(konppc_device::cgboard_comm_sharc_w<Board>));
607+
map(0x3401000, 0x34fffff).w(m_konppc, FUNC(konppc_device::nwk_voodoo_fifo_w<Board>));
608+
map(0x3500000, 0x3507fff).rw(m_konppc, FUNC(konppc_device::cgboard_k033906_r<Board>), FUNC(konppc_device::cgboard_k033906_w<Board>));
609+
map(0x3600000, 0x37fffff).bankr(m_cgboard_bank[Board]);
616610
}
617611

618612
/*****************************************************************************/
@@ -918,7 +912,7 @@ void gticlub_state::gticlub(machine_config &config)
918912
screen.set_visarea(40, 511+40, 28, 383+28); // needs CRTC emulation
919913
screen.set_screen_update(FUNC(gticlub_state::screen_update));
920914

921-
PALETTE(config, m_palette[0]).set_format(4, &gticlub_state::gticlub_XR5G5B5, 16384);
915+
PALETTE(config, m_palette[0]).set_format(4, raw_to_rgb_converter::standard_rgb_decoder<5,5,5, 10,5,0>, 16384);
922916

923917
K001604(config, m_k001604[0], 0);
924918
m_k001604[0]->set_palette(m_palette[0]);
@@ -944,8 +938,9 @@ void gticlub_state::gticlub(machine_config &config)
944938
rfsnd.add_route(1, "rspeaker", 1.0);
945939

946940
KONPPC(config, m_konppc, 0);
941+
m_konppc->set_dsp_tag(0, m_dsp[0]);
947942
m_konppc->set_num_boards(1);
948-
m_konppc->set_cbboard_type(konppc_device::CGBOARD_TYPE_GTICLUB);
943+
m_konppc->set_cgboard_type(konppc_device::CGBOARD_TYPE_GTICLUB);
949944
}
950945

951946
void thunderh_state::thunderh(machine_config &config)
@@ -978,11 +973,11 @@ void hangplt_state::hangplt(machine_config &config)
978973

979974
ADSP21062(config, m_dsp[0], XTAL(36'000'000));
980975
m_dsp[0]->set_boot_mode(adsp21062_device::BOOT_MODE_EPROM);
981-
m_dsp[0]->set_addrmap(AS_DATA, &hangplt_state::hangplt_sharc0_map);
976+
m_dsp[0]->set_addrmap(AS_DATA, &hangplt_state::hangplt_sharc_map<0>);
982977

983978
ADSP21062(config, m_dsp[1], XTAL(36'000'000));
984979
m_dsp[1]->set_boot_mode(adsp21062_device::BOOT_MODE_EPROM);
985-
m_dsp[1]->set_addrmap(AS_DATA, &hangplt_state::hangplt_sharc1_map);
980+
m_dsp[1]->set_addrmap(AS_DATA, &hangplt_state::hangplt_sharc_map<1>);
986981

987982
config.set_maximum_quantum(attotime::from_hz(6000));
988983

@@ -1016,8 +1011,8 @@ void hangplt_state::hangplt(machine_config &config)
10161011
K033906(config, "k033906_2", 0, m_voodoo[1]);
10171012

10181013
// video hardware
1019-
PALETTE(config, m_palette[0]).set_format(4, &gticlub_state::gticlub_XR5G5B5, 16384);
1020-
PALETTE(config, m_palette[1]).set_format(4, &gticlub_state::gticlub_XR5G5B5, 16384);
1014+
PALETTE(config, m_palette[0]).set_format(4, raw_to_rgb_converter::standard_rgb_decoder<5,5,5, 10,5,0>, 16384);
1015+
PALETTE(config, m_palette[1]).set_format(4, raw_to_rgb_converter::standard_rgb_decoder<5,5,5, 10,5,0>, 16384);
10211016

10221017
screen_device &lscreen(SCREEN(config, "lscreen", SCREEN_TYPE_RASTER));
10231018
lscreen.set_refresh_hz(60);
@@ -1048,8 +1043,16 @@ void hangplt_state::hangplt(machine_config &config)
10481043
rfsnd.add_route(1, "rspeaker", 1.0);
10491044

10501045
KONPPC(config, m_konppc, 0);
1046+
m_konppc->set_dsp_tag(0, m_dsp[0]);
1047+
m_konppc->set_dsp_tag(1, m_dsp[1]);
1048+
m_konppc->set_k033906_tag(0, "k033906_1");
1049+
m_konppc->set_k033906_tag(1, "k033906_2");
1050+
m_konppc->set_voodoo_tag(0, m_voodoo[0]);
1051+
m_konppc->set_voodoo_tag(1, m_voodoo[1]);
1052+
m_konppc->set_texture_bank_tag(0, m_cgboard_bank[0]);
1053+
m_konppc->set_texture_bank_tag(1, m_cgboard_bank[1]);
10511054
m_konppc->set_num_boards(2);
1052-
m_konppc->set_cbboard_type(konppc_device::CGBOARD_TYPE_HANGPLT);
1055+
m_konppc->set_cgboard_type(konppc_device::CGBOARD_TYPE_HANGPLT);
10531056
}
10541057

10551058
/*************************************************************************/
@@ -1348,7 +1351,7 @@ ROM_START( hangplt ) // Japan version JAB
13481351
ROM_LOAD( "685a09.9s", 0x000000, 0x400000, CRC(b8ae40aa) SHA1(eee27a8929e0e805f1045fd9638e661b36a1e3c7) )
13491352
ROM_LOAD( "685a10.7s", 0x400000, 0x400000, CRC(fef3dc36) SHA1(566c7469fc452b5965a31fa42291082ec8e48a24) )
13501353

1351-
ROM_REGION(0x800000, "master_cgboard", 0) // texture roms
1354+
ROM_REGION(0x1000000, "cgboard_0", ROMREGION_ERASE00) // texture roms
13521355
ROM_LOAD32_WORD( "685a13.4w", 0x000002, 0x400000, CRC(06329af4) SHA1(76cad9db604751ce48bb67bfd29e57bac0ee9a16) )
13531356
ROM_LOAD32_WORD( "685a14.12w", 0x000000, 0x400000, CRC(87437739) SHA1(0d45637af40938a54d5efd29c125b0fafd55f9a4) )
13541357

@@ -1374,7 +1377,7 @@ ROM_START( hangpltu ) // USA version UAA
13741377
ROM_LOAD( "685a09.9s", 0x000000, 0x400000, CRC(b8ae40aa) SHA1(eee27a8929e0e805f1045fd9638e661b36a1e3c7) )
13751378
ROM_LOAD( "685a10.7s", 0x400000, 0x400000, CRC(fef3dc36) SHA1(566c7469fc452b5965a31fa42291082ec8e48a24) )
13761379

1377-
ROM_REGION(0x800000, "master_cgboard", 0) // texture roms
1380+
ROM_REGION(0x1000000, "cgboard_0", ROMREGION_ERASE00) // texture roms
13781381
ROM_LOAD32_WORD( "685a13.4w", 0x000002, 0x400000, CRC(06329af4) SHA1(76cad9db604751ce48bb67bfd29e57bac0ee9a16) )
13791382
ROM_LOAD32_WORD( "685a14.12w", 0x000000, 0x400000, CRC(87437739) SHA1(0d45637af40938a54d5efd29c125b0fafd55f9a4) )
13801383

@@ -1390,8 +1393,8 @@ void gticlub_state::init_gticlub()
13901393

13911394
void hangplt_state::init_hangplt_common()
13921395
{
1393-
m_konppc->set_cgboard_texture_bank(0, "master_cgboard_bank", memregion("master_cgboard")->base());
1394-
m_konppc->set_cgboard_texture_bank(1, "slave_cgboard_bank", memregion("master_cgboard")->base());
1396+
m_cgboard_bank[0]->configure_entries(0, 2, memregion("cgboard_0")->base(), 0x800000);
1397+
m_cgboard_bank[1]->configure_entries(0, 2, memregion("cgboard_0")->base(), 0x800000);
13951398
}
13961399

13971400
void hangplt_state::init_hangplt() //fixme: remove hacks and actually emulate the step lock. Possibly similar to Alpine Racer 1/2 and Alpine Surfer?

0 commit comments

Comments
 (0)