Skip to content

Commit

Permalink
further tidyups
Browse files Browse the repository at this point in the history
  • Loading branch information
David Haywood committed Nov 27, 2024
1 parent 3e9d6c8 commit a595f03
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 221 deletions.
32 changes: 6 additions & 26 deletions src/mame/toaplan/batsugun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "speaker.h"
#include "tilemap.h"

#include "toaplan_coincounter.h"
#include "toaplipt.h"
#include "gp9001.h"

Expand All @@ -28,6 +29,7 @@ class batsugun_state : public driver_device
, m_shared_ram(*this, "shared_ram")
, m_audiocpu(*this, "audiocpu")
, m_screen(*this, "screen")
, m_coincounter(*this, "coincounter")
{ }

void batsugun(machine_config &config);
Expand All @@ -53,12 +55,12 @@ class batsugun_state : public driver_device
void screen_vblank(int state);

void sound_reset_w(u8 data);
void coin_w(u8 data);
void reset(int state);

optional_shared_ptr<u8> m_shared_ram; // 8 bit RAM shared between 68K and sound CPU
optional_device<cpu_device> m_audiocpu;
required_device<screen_device> m_screen;
required_device<toaplan_coincounter_device> m_coincounter;
bitmap_ind8 m_custom_priority_bitmap;
bitmap_ind16 m_secondary_render_bitmap;
};
Expand Down Expand Up @@ -168,28 +170,6 @@ void batsugun_state::screen_vblank(int state)
}
}

void batsugun_state::coin_w(u8 data) // MOVE TO DEVICE!
{
/* +----------------+------ Bits 7-5 not used ------+--------------+ */
/* | Coin Lockout 2 | Coin Lockout 1 | Coin Count 2 | Coin Count 1 | */
/* | Bit 3 | Bit 2 | Bit 1 | Bit 0 | */

if (data & 0x0f)
{
machine().bookkeeping().coin_lockout_w(0, BIT(~data, 2));
machine().bookkeeping().coin_lockout_w(1, BIT(~data, 3));
machine().bookkeeping().coin_counter_w(0, BIT( data, 0));
machine().bookkeeping().coin_counter_w(1, BIT( data, 1));
}
else
{
machine().bookkeeping().coin_lockout_global_w(1); // Lock all coin slots
}
if (data & 0xf0)
{
logerror("Writing unknown upper bits (%02x) to coin control\n",data);
}
}

void batsugun_state::reset(int state)
{
Expand Down Expand Up @@ -220,9 +200,7 @@ void batsugun_bootleg_state::fixeightbl_oki(address_map &map)

void batsugun_state::coin_sound_reset_w(u8 data)
{
logerror("coin_sound_reset_w %02x\n",data);

coin_w(data & ~0x20);
m_coincounter->coin_w(data & ~0x20);
sound_reset_w(data & 0x20);
}

Expand Down Expand Up @@ -400,6 +378,8 @@ void batsugun_state::batsugun(machine_config &config)
audiocpu.p1_in_cb().set_ioport("JMPR").exor(0xff);
audiocpu.p2_out_cb().set_nop(); // bit 0 is FAULT according to kbash schematic

TOAPLAN_COINCOUNTER(config, m_coincounter, 0);

/* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_video_attributes(VIDEO_UPDATE_BEFORE_VBLANK);
Expand Down
34 changes: 7 additions & 27 deletions src/mame/toaplan/dogyuun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "speaker.h"
#include "tilemap.h"

#include "toaplan_coincounter.h"
#include "toaplan_v25_tables.h"
#include "toaplipt.h"
#include "gp9001.h"
Expand All @@ -31,6 +32,7 @@ class dogyuun_base_state : public driver_device
, m_vdp(*this, "gp9001_%u", 0U)
, m_oki(*this, "oki")
, m_palette(*this, "palette")
, m_coincounter(*this, "coincounter")
, m_screen(*this, "screen")
{ }

Expand All @@ -44,7 +46,7 @@ class dogyuun_base_state : public driver_device

void coin_sound_reset_w(u8 data);

u8 m_sound_reset_bit = 0; /* 0x20 for dogyuun/batsugun, 0x10 for vfive, 0x08 for fixeight */
u8 m_sound_reset_bit = 0;

required_device<m68000_base_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
Expand All @@ -59,9 +61,9 @@ class dogyuun_base_state : public driver_device
void screen_vblank(int state);

void sound_reset_w(u8 data);
void coin_w(u8 data);
void reset(int state);

required_device<toaplan_coincounter_device> m_coincounter;
required_device<screen_device> m_screen;
bitmap_ind8 m_custom_priority_bitmap;
bitmap_ind16 m_secondary_render_bitmap;
Expand Down Expand Up @@ -105,30 +107,6 @@ void dogyuun_base_state::reset(int state)
m_audiocpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero);
}

void dogyuun_base_state::coin_w(u8 data) // MOVE TO DEVICE!
{
/* +----------------+------ Bits 7-5 not used ------+--------------+ */
/* | Coin Lockout 2 | Coin Lockout 1 | Coin Count 2 | Coin Count 1 | */
/* | Bit 3 | Bit 2 | Bit 1 | Bit 0 | */

if (data & 0x0f)
{
machine().bookkeeping().coin_lockout_w(0, BIT(~data, 2));
machine().bookkeeping().coin_lockout_w(1, BIT(~data, 3));
machine().bookkeeping().coin_counter_w(0, BIT( data, 0));
machine().bookkeeping().coin_counter_w(1, BIT( data, 1));
}
else
{
machine().bookkeeping().coin_lockout_global_w(1); // Lock all coin slots
}
if (data & 0xf0)
{
logerror("Writing unknown upper bits (%02x) to coin control\n",data);
}
}


void dogyuun_base_state::sound_reset_w(u8 data)
{
m_audiocpu->set_input_line(INPUT_LINE_RESET, (data & m_sound_reset_bit) ? CLEAR_LINE : ASSERT_LINE);
Expand Down Expand Up @@ -296,7 +274,7 @@ INPUT_PORTS_END

void dogyuun_base_state::coin_sound_reset_w(u8 data)
{
coin_w(data & ~m_sound_reset_bit);
m_coincounter->coin_w(data & ~m_sound_reset_bit);
sound_reset_w(data & m_sound_reset_bit);
}

Expand Down Expand Up @@ -354,6 +332,8 @@ void dogyuun_base_state::dogyuun_base(machine_config &config)
M68000(config, m_maincpu, 25_MHz_XTAL/2); /* verified on pcb */
m_maincpu->reset_cb().set(FUNC(dogyuun_base_state::reset));

TOAPLAN_COINCOUNTER(config, m_coincounter, 0);

/* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_video_attributes(VIDEO_UPDATE_BEFORE_VBLANK);
Expand Down
31 changes: 4 additions & 27 deletions src/mame/toaplan/kbash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "speaker.h"
#include "tilemap.h"

#include "toaplan_coincounter.h"
#include "toaplan_v25_tables.h"
#include "toaplipt.h"
#include "gp9001.h"
Expand Down Expand Up @@ -45,7 +46,6 @@ class kbash_state : public driver_device

u8 shared_ram_r(offs_t offset) { return m_shared_ram[offset]; }
void shared_ram_w(offs_t offset, u8 data) { m_shared_ram[offset] = data; }
void coin_w(u8 data);
void reset(int state);

optional_shared_ptr<u8> m_shared_ram; // 8 bit RAM shared between 68K and sound CPU
Expand Down Expand Up @@ -83,31 +83,6 @@ void kbash_state::reset(int state)
m_audiocpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero);
}

void kbash_state::coin_w(u8 data) // MOVE TO DEVICE!
{
/* +----------------+------ Bits 7-5 not used ------+--------------+ */
/* | Coin Lockout 2 | Coin Lockout 1 | Coin Count 2 | Coin Count 1 | */
/* | Bit 3 | Bit 2 | Bit 1 | Bit 0 | */

if (data & 0x0f)
{
machine().bookkeeping().coin_lockout_w(0, BIT(~data, 2));
machine().bookkeeping().coin_lockout_w(1, BIT(~data, 3));
machine().bookkeeping().coin_counter_w(0, BIT( data, 0));
machine().bookkeeping().coin_counter_w(1, BIT( data, 1));
}
else
{
machine().bookkeeping().coin_lockout_global_w(1); // Lock all coin slots
}
if (data & 0xf0)
{
logerror("Writing unknown upper bits (%02x) to coin control\n",data);
}
}



void kbash_state::video_start()
{
m_screen->register_screen_bitmap(m_custom_priority_bitmap);
Expand Down Expand Up @@ -276,7 +251,7 @@ void kbash_state::kbash_68k_mem(address_map &map)
map(0x208010, 0x208011).portr("IN1");
map(0x208014, 0x208015).portr("IN2");
map(0x208018, 0x208019).portr("SYS");
map(0x20801d, 0x20801d).w(FUNC(kbash_state::coin_w));
map(0x20801d, 0x20801d).w("coincounter", FUNC(toaplan_coincounter_device::coin_w));
map(0x300000, 0x30000d).rw(m_vdp, FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write));
map(0x400000, 0x400fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x700000, 0x700001).r(m_vdp, FUNC(gp9001vdp_device::vdpcount_r)); // test bit 8
Expand Down Expand Up @@ -329,6 +304,8 @@ void kbash_state::kbash(machine_config &config)
audiocpu.p1_in_cb().set_ioport("JMPR").exor(0xff);
audiocpu.p2_out_cb().set_nop(); // bit 0 is FAULT according to kbash schematic

TOAPLAN_COINCOUNTER(config, "coincounter", 0);

/* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_video_attributes(VIDEO_UPDATE_BEFORE_VBLANK);
Expand Down
34 changes: 7 additions & 27 deletions src/mame/toaplan/pipibibi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "speaker.h"
#include "tilemap.h"

#include "toaplan_coincounter.h"
#include "toaplipt.h"
#include "gp9001.h"

Expand Down Expand Up @@ -42,7 +43,6 @@ class pipibibi_state : public driver_device

void pipibibs_68k_mem(address_map &map) ATTR_COLD;
void pipibibs_sound_z80_mem(address_map &map) ATTR_COLD;
void coin_w(u8 data);
void reset(int state);

optional_shared_ptr<u8> m_shared_ram; // 8 bit RAM shared between 68K and sound CPU
Expand Down Expand Up @@ -77,30 +77,6 @@ void pipibibi_state::reset(int state)
m_audiocpu->pulse_input_line(INPUT_LINE_RESET, attotime::zero);
}

void pipibibi_state::coin_w(u8 data) // MOVE TO DEVICE!
{
/* +----------------+------ Bits 7-5 not used ------+--------------+ */
/* | Coin Lockout 2 | Coin Lockout 1 | Coin Count 2 | Coin Count 1 | */
/* | Bit 3 | Bit 2 | Bit 1 | Bit 0 | */

if (data & 0x0f)
{
machine().bookkeeping().coin_lockout_w(0, BIT(~data, 2));
machine().bookkeeping().coin_lockout_w(1, BIT(~data, 3));
machine().bookkeeping().coin_counter_w(0, BIT( data, 0));
machine().bookkeeping().coin_counter_w(1, BIT( data, 1));
}
else
{
machine().bookkeeping().coin_lockout_global_w(1); // Lock all coin slots
}
if (data & 0xf0)
{
logerror("Writing unknown upper bits (%02x) to coin control\n",data);
}
}


void pipibibi_state::video_start()
{
m_screen->register_screen_bitmap(m_custom_priority_bitmap);
Expand Down Expand Up @@ -243,7 +219,7 @@ void pipibibi_state::pipibibs_68k_mem(address_map &map)
map(0x0c0000, 0x0c0fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x140000, 0x14000d).rw(m_vdp, FUNC(gp9001vdp_device::read), FUNC(gp9001vdp_device::write));
map(0x190000, 0x190fff).rw(FUNC(pipibibi_state::shared_ram_r), FUNC(pipibibi_state::shared_ram_w)).umask16(0x00ff);
map(0x19c01d, 0x19c01d).w(FUNC(pipibibi_state::coin_w));
map(0x19c01d, 0x19c01d).w("coincounter", FUNC(toaplan_coincounter_device::coin_w));
map(0x19c020, 0x19c021).portr("DSWA");
map(0x19c024, 0x19c025).portr("DSWB");
map(0x19c028, 0x19c029).portr("JMPR");
Expand All @@ -266,7 +242,7 @@ void pipibibi_bootleg_state::pipibibi_bootleg_68k_mem(address_map &map)
map(0x188000, 0x18800f).w(m_vdp, FUNC(gp9001vdp_device::bootleg_scroll_w));
map(0x190003, 0x190003).r(FUNC(pipibibi_state::shared_ram_r)); // Z80 ready ?
map(0x190011, 0x190011).w(FUNC(pipibibi_state::shared_ram_w)); // Z80 task to perform
map(0x19c01d, 0x19c01d).w(FUNC(pipibibi_state::coin_w));
map(0x19c01d, 0x19c01d).w("coincounter", FUNC(toaplan_coincounter_device::coin_w));
map(0x19c020, 0x19c021).portr("DSWA");
map(0x19c024, 0x19c025).portr("DSWB");
map(0x19c028, 0x19c029).portr("JMPR");
Expand Down Expand Up @@ -299,6 +275,8 @@ void pipibibi_state::pipibibs(machine_config &config)
Z80(config, m_audiocpu, 27_MHz_XTAL/8); // verified on PCB
m_audiocpu->set_addrmap(AS_PROGRAM, &pipibibi_state::pipibibs_sound_z80_mem);

TOAPLAN_COINCOUNTER(config, "coincounter", 0);

config.set_maximum_quantum(attotime::from_hz(600));

/* video hardware */
Expand Down Expand Up @@ -335,6 +313,8 @@ void pipibibi_bootleg_state::pipibibsbl(machine_config &config)
Z80(config, m_audiocpu, 12_MHz_XTAL / 2); // GoldStar Z8400B; clock source and divider unknown
m_audiocpu->set_addrmap(AS_PROGRAM, &pipibibi_bootleg_state::pipibibs_sound_z80_mem);

TOAPLAN_COINCOUNTER(config, "coincounter", 0);

config.set_maximum_quantum(attotime::from_hz(600));

/* video hardware */
Expand Down
31 changes: 5 additions & 26 deletions src/mame/toaplan/snowbro2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "speaker.h"
#include "tilemap.h"

#include "toaplan_coincounter.h"
#include "toaplipt.h"
#include "gp9001.h"

Expand Down Expand Up @@ -40,7 +41,6 @@ class snowbro2_state : public driver_device
void screen_vblank(int state);
void sb2_oki_bankswitch_w(u8 data);
private:
void coin_w(u8 data);

required_device<m68000_base_device> m_maincpu;
required_device<gp9001vdp_device> m_vdp;
Expand Down Expand Up @@ -73,29 +73,6 @@ void snowbro2_state::screen_vblank(int state)
}
}

void snowbro2_state::coin_w(u8 data) // MOVE TO DEVICE!
{
/* +----------------+------ Bits 7-5 not used ------+--------------+ */
/* | Coin Lockout 2 | Coin Lockout 1 | Coin Count 2 | Coin Count 1 | */
/* | Bit 3 | Bit 2 | Bit 1 | Bit 0 | */

if (data & 0x0f)
{
machine().bookkeeping().coin_lockout_w(0, BIT(~data, 2));
machine().bookkeeping().coin_lockout_w(1, BIT(~data, 3));
machine().bookkeeping().coin_counter_w(0, BIT( data, 0));
machine().bookkeeping().coin_counter_w(1, BIT( data, 1));
}
else
{
machine().bookkeeping().coin_lockout_global_w(1); // Lock all coin slots
}
if (data & 0xf0)
{
logerror("Writing unknown upper bits (%02x) to coin control\n",data);
}
}

void snowbro2_state::sb2_oki_bankswitch_w(u8 data)
{
m_oki->set_rom_bank(data & 1);
Expand Down Expand Up @@ -309,7 +286,7 @@ void snowbro2_state::snowbro2_68k_mem(address_map &map)
map(0x700018, 0x700019).portr("IN4");
map(0x70001c, 0x70001d).portr("SYS");
map(0x700031, 0x700031).w(FUNC(snowbro2_state::sb2_oki_bankswitch_w));
map(0x700035, 0x700035).w(FUNC(snowbro2_state::coin_w));
map(0x700035, 0x700035).w("coincounter", FUNC(toaplan_coincounter_device::coin_w));
}

void snowbro2_state::snowbro2b3_68k_mem(address_map &map)
Expand All @@ -325,7 +302,7 @@ void snowbro2_state::snowbro2b3_68k_mem(address_map &map)
map(0x700010, 0x700011).portr("IN2");
map(0x700014, 0x700015).portr("IN3");
map(0x700018, 0x700019).portr("IN4");
map(0x700035, 0x700035).w(FUNC(snowbro2_state::coin_w));
map(0x700035, 0x700035).w("coincounter", FUNC(toaplan_coincounter_device::coin_w));
map(0x700041, 0x700041).w(FUNC(snowbro2_state::sb2_oki_bankswitch_w));
map(0xff0000, 0xff2fff).rw(m_vdp, FUNC(gp9001vdp_device::bootleg_videoram16_r), FUNC(gp9001vdp_device::bootleg_videoram16_w));
map(0xff3000, 0xff37ff).rw(m_vdp, FUNC(gp9001vdp_device::bootleg_spriteram16_r), FUNC(gp9001vdp_device::bootleg_spriteram16_w));
Expand All @@ -338,6 +315,8 @@ void snowbro2_state::snowbro2(machine_config &config)
M68000(config, m_maincpu, 32_MHz_XTAL/2);
m_maincpu->set_addrmap(AS_PROGRAM, &snowbro2_state::snowbro2_68k_mem);

TOAPLAN_COINCOUNTER(config, "coincounter", 0);

/* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
m_screen->set_video_attributes(VIDEO_UPDATE_BEFORE_VBLANK);
Expand Down
Loading

0 comments on commit a595f03

Please sign in to comment.