summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Ivan Vangelista <mesgnet@yahoo.it>2022-01-15 10:15:20 +0100
committer Ivan Vangelista <mesgnet@yahoo.it>2022-01-15 10:15:20 +0100
commit30cc2579062b9e5727e2c22db223f42fcc30b6ba (patch)
treed4adec85813de67eb6d1ebbc522436fe90f05411 /src
parentcc1363322c80c0bbcfa99987cf9850152b3d77fc (diff)
go2000.cpp: used finder for the memory bank, derived clocks from XTAL value and other very minor cleanups
Diffstat (limited to 'src')
-rw-r--r--src/mame/drivers/go2000.cpp153
1 files changed, 71 insertions, 82 deletions
diff --git a/src/mame/drivers/go2000.cpp b/src/mame/drivers/go2000.cpp
index 7e732905504..4f3a35f37cc 100644
--- a/src/mame/drivers/go2000.cpp
+++ b/src/mame/drivers/go2000.cpp
@@ -41,85 +41,81 @@ Notes:
#include "speaker.h"
+namespace {
+
class go2000_state : public driver_device
{
public:
go2000_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
- m_videoram(*this, "videoram"),
- m_videoram2(*this, "videoram2"),
+ m_videoram(*this, "videoram%u", 0U),
m_maincpu(*this, "maincpu"),
m_soundcpu(*this, "soundcpu"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_palette(*this, "palette"),
- m_soundlatch(*this, "soundlatch")
+ m_soundbank(*this, "soundbank")
{ }
void go2000(machine_config &config);
+protected:
+ virtual void machine_start() override;
+
private:
- /* memory pointers */
- required_shared_ptr<uint16_t> m_videoram;
- required_shared_ptr<uint16_t> m_videoram2;
+ // memory pointers
+ required_shared_ptr_array<uint16_t, 2> m_videoram;
- /* devices */
+ // devices
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_soundcpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
required_device<palette_device> m_palette;
- required_device<generic_latch_8_device> m_soundlatch;
- void sound_cmd_w(uint16_t data);
- void go2000_pcm_1_bankswitch_w(uint8_t data);
- virtual void machine_start() override;
- virtual void video_start() override;
- uint32_t screen_update_go2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
- void go2000_map(address_map &map);
- void go2000_sound_io(address_map &map);
- void go2000_sound_map(address_map &map);
-};
+ required_memory_bank m_soundbank;
+ void pcm_1_bankswitch_w(uint8_t data);
+
+ uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
+ void main_map(address_map &map);
+ void sound_io(address_map &map);
+ void sound_map(address_map &map);
+};
-void go2000_state::sound_cmd_w(uint16_t data)
-{
- m_soundlatch->write(data & 0xff);
- m_soundcpu->set_input_line(0, HOLD_LINE);
-}
-void go2000_state::go2000_map(address_map &map)
+void go2000_state::main_map(address_map &map)
{
map(0x000000, 0x03ffff).rom();
map(0x200000, 0x203fff).ram();
- map(0x600000, 0x60ffff).ram().share("videoram");
- map(0x610000, 0x61ffff).ram().share("videoram2");
+ map(0x600000, 0x60ffff).ram().share(m_videoram[0]);
+ map(0x610000, 0x61ffff).ram().share(m_videoram[1]);
map(0x800000, 0x800fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0xa00000, 0xa00001).portr("INPUTS");
map(0xa00002, 0xa00003).portr("DSW");
- map(0x620002, 0x620003).w(FUNC(go2000_state::sound_cmd_w));
+ map(0x620003, 0x620003).w("soundlatch", FUNC(generic_latch_8_device::write));
// map(0xe00000, 0xe00001).nopw();
// map(0xe00010, 0xe00011).nopw();
// map(0xe00020, 0xe00021).nopw();
}
-void go2000_state::go2000_pcm_1_bankswitch_w(uint8_t data)
+void go2000_state::pcm_1_bankswitch_w(uint8_t data)
{
- membank("bank1")->set_entry(data & 0x07);
+ m_soundbank->set_entry(data & 0x07);
}
-void go2000_state::go2000_sound_map(address_map &map)
+void go2000_state::sound_map(address_map &map)
{
map(0x0000, 0x03ff).rom();
- map(0x0400, 0xffff).bankr("bank1");
+ map(0x0400, 0xffff).bankr(m_soundbank);
}
-void go2000_state::go2000_sound_io(address_map &map)
+void go2000_state::sound_io(address_map &map)
{
map.global_mask(0xff);
- map(0x00, 0x00).r(m_soundlatch, FUNC(generic_latch_8_device::read));
+ map(0x00, 0x00).r("soundlatch", FUNC(generic_latch_8_device::read));
map(0x00, 0x00).w("dac", FUNC(dac_byte_interface::data_w));
- map(0x03, 0x03).w(FUNC(go2000_state::go2000_pcm_1_bankswitch_w));
+ map(0x03, 0x03).w(FUNC(go2000_state::pcm_1_bankswitch_w));
}
@@ -127,7 +123,7 @@ static INPUT_PORTS_START( go2000 )
PORT_START("INPUTS")
PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON1 ) // continue
PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_START1 )
- PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 ) // korean symbol
+ PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON2 ) // Korean symbol
PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_BUTTON3 ) // out
PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) // high
PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) // low
@@ -196,62 +192,57 @@ static const gfx_layout go2000_layout =
};
static GFXDECODE_START( gfx_go2000 )
- GFXDECODE_ENTRY( "gfx1", 0, go2000_layout, 0x0, 0x80 ) /* tiles */
+ GFXDECODE_ENTRY( "tiles", 0, go2000_layout, 0x0, 0x80 )
GFXDECODE_END
-void go2000_state::video_start()
-{
-}
-uint32_t go2000_state::screen_update_go2000(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
+uint32_t go2000_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
int count = 0;
- /* 0x600000 - 0x601fff / 0x610000 - 0x611fff */
+ // 0x600000 - 0x601fff / 0x610000 - 0x611fff
for (int x = 0; x < 64; x++)
{
for (int y = 0; y < 32; y++)
{
- int tile = m_videoram[count];
- int attr = m_videoram2[count];
+ int tile = m_videoram[0][count];
+ int attr = m_videoram[1][count];
m_gfxdecode->gfx(0)->opaque(bitmap,cliprect, tile, attr, 0, 0, x * 8, y * 8);
count++;
}
}
- /* 0x602000 - 0x603fff / 0x612000 - 0x613fff */
+ // 0x602000 - 0x603fff / 0x612000 - 0x613fff
for (int x = 0; x < 64; x++)
{
for (int y = 0; y < 32; y++)
{
- int tile = m_videoram[count];
- int attr = m_videoram2[count];
+ int tile = m_videoram[0][count];
+ int attr = m_videoram[1][count];
m_gfxdecode->gfx(0)->transpen(bitmap,cliprect, tile, attr, 0, 0, x * 8, y * 8, 0xf);
count++;
}
}
- /*Sprite RAM code actually copied from video/suna16.c with minor modifications.*/
+ // Sprite RAM code actually copied from video/suna16.cpp with minor modifications.
int max_x = m_screen->width() - 8;
int max_y = m_screen->height() - 8;
for (int offs = 0xf800 / 2; offs < 0x10000 / 2 ; offs += 4/2)
{
- int srcpg, srcx, srcy, dimx, dimy;
- int tile_x, tile_xinc, tile_xstart;
- int tile_y, tile_yinc;
- int dx, dy;
+ int dimx, dimy;
+ int tile_xinc, tile_xstart;
int flipx, y0;
- int y = m_videoram[offs + 0 + 0x00000 / 2];
- int x = m_videoram[offs + 1 + 0x00000 / 2];
- int dim = m_videoram2[offs + 0 + 0x00000 / 2];
+ int y = m_videoram[0][offs + 0 + 0x00000 / 2];
+ int x = m_videoram[0][offs + 1 + 0x00000 / 2];
+ int dim = m_videoram[1][offs + 0 + 0x00000 / 2];
int bank = (x >> 12) & 0xf;
- srcpg = ((y & 0xf000) >> 12) + ((x & 0x0200) >> 5); // src page
- srcx = ((y >> 8) & 0xf) * 2; // src col
- srcy = ((dim >> 0) & 0xf) * 2; // src row
+ int srcpg = ((y & 0xf000) >> 12) + ((x & 0x0200) >> 5); // src page
+ int srcx = ((y >> 8) & 0xf) * 2; // src col
+ int srcy = ((dim >> 0) & 0xf) * 2; // src row
switch ((dim >> 4) & 0xc)
{
@@ -284,18 +275,18 @@ uint32_t go2000_state::screen_update_go2000(screen_device &screen, bitmap_ind16
tile_xinc = +1;
}
- tile_y = 0;
- tile_yinc = +1;
+ int tile_y = 0;
+ int tile_yinc = +1;
- for (dy = 0; dy < dimy * 8; dy += 8)
+ for (int dy = 0; dy < dimy * 8; dy += 8)
{
- tile_x = tile_xstart;
+ int tile_x = tile_xstart;
- for (dx = 0; dx < dimx * 8; dx += 8)
+ for (int dx = 0; dx < dimx * 8; dx += 8)
{
int addr = (srcpg * 0x20 * 0x20) + ((srcx + tile_x) & 0x1f) * 0x20 + ((srcy + tile_y) & 0x1f);
- int tile = m_videoram[addr + 0x00000 / 2];
- int attr = m_videoram2[addr + 0x00000 / 2];
+ int tile = m_videoram[0][addr + 0x00000 / 2];
+ int attr = m_videoram[1][addr + 0x00000 / 2];
int sx = x + dx;
int sy = (y + dy) & 0xff;
@@ -315,10 +306,10 @@ uint32_t go2000_state::screen_update_go2000(screen_device &screen, bitmap_ind16
}
m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
- (tile & 0x1fff) + bank*0x4000,
+ (tile & 0x1fff) + bank * 0x4000,
attr,
tile_flipx, tile_flipy,
- sx, sy,15 );
+ sx, sy, 15 );
tile_x += tile_xinc;
}
@@ -333,25 +324,21 @@ uint32_t go2000_state::screen_update_go2000(screen_device &screen, bitmap_ind16
void go2000_state::machine_start()
{
- uint8_t *SOUND = memregion("soundcpu")->base();
- int i;
-
- for (i = 0; i < 8; i++)
- membank("bank1")->configure_entry(i, &SOUND[0x00400 + i * 0x10000]);
-
- membank("bank1")->set_entry(0);
+ uint8_t *rom = memregion("soundcpu")->base();
+ m_soundbank->configure_entries(0, 8, &rom[0x00400], 0x10000);
+ m_soundbank->set_entry(0);
}
void go2000_state::go2000(machine_config &config)
{
- M68000(config, m_maincpu, 10000000);
- m_maincpu->set_addrmap(AS_PROGRAM, &go2000_state::go2000_map);
+ M68000(config, m_maincpu, 32_MHz_XTAL / 4); // divider not verified
+ m_maincpu->set_addrmap(AS_PROGRAM, &go2000_state::main_map);
m_maincpu->set_vblank_int("screen", FUNC(go2000_state::irq1_line_hold));
- Z80(config, m_soundcpu, 4000000);
- m_soundcpu->set_addrmap(AS_PROGRAM, &go2000_state::go2000_sound_map);
- m_soundcpu->set_addrmap(AS_IO, &go2000_state::go2000_sound_io);
+ Z80(config, m_soundcpu, 32_MHz_XTAL / 8); // divider not verified
+ m_soundcpu->set_addrmap(AS_PROGRAM, &go2000_state::sound_map);
+ m_soundcpu->set_addrmap(AS_IO, &go2000_state::sound_io);
GFXDECODE(config, m_gfxdecode, m_palette, gfx_go2000);
@@ -361,30 +348,32 @@ void go2000_state::go2000(machine_config &config)
m_screen->set_vblank_time(ATTOSECONDS_IN_USEC(0));
m_screen->set_size(64*8, 32*8);
m_screen->set_visarea(0*8, 48*8-1, 2*8, 30*8-1);
- m_screen->set_screen_update(FUNC(go2000_state::screen_update_go2000));
+ m_screen->set_screen_update(FUNC(go2000_state::screen_update));
m_screen->set_palette(m_palette);
PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 0x800);
- GENERIC_LATCH_8(config, m_soundlatch);
+ GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_soundcpu, 0);;
SPEAKER(config, "speaker").front_center();
DAC_8BIT_R2R(config, "dac", 0).add_route(0, "speaker", 0.25); // unknown DAC
}
ROM_START( go2000 )
- ROM_REGION( 0x80000, "maincpu", 0 ) /* 68000 Code */
+ ROM_REGION( 0x80000, "maincpu", 0 ) // 68000 Code
ROM_LOAD16_BYTE( "3.bin", 0x00000, 0x20000, CRC(fe1fb269) SHA1(266b8acddfcfd960b8e44f8606bf0873da42b9f8) )
ROM_LOAD16_BYTE( "4.bin", 0x00001, 0x20000, CRC(d6246ae3) SHA1(f2618dcabaa0c0a6e377e4acd1cdec8bea90bea8) )
- ROM_REGION( 0x080000, "soundcpu", 0 ) /* Z80? */
+ ROM_REGION( 0x080000, "soundcpu", 0 ) // Z80
ROM_LOAD( "5.bin", 0x00000, 0x80000, CRC(a32676ee) SHA1(2dab73497c0818fce479be21ed589985db51560b) )
- ROM_REGION( 0x40000, "gfx1", ROMREGION_INVERT )
+ ROM_REGION( 0x40000, "tiles", ROMREGION_INVERT )
ROM_LOAD16_BYTE( "1.bin", 0x00000, 0x20000, CRC(96e50aba) SHA1(caa1aadab855c3a758378dc8c48eec859e8110a4) )
ROM_LOAD16_BYTE( "2.bin", 0x00001, 0x20000, CRC(b0adf1cb) SHA1(2afb30691182dbf46be709f0d5b03b0f8ff52790) )
ROM_END
+} // Anonymous namespace
+
GAME( 2000, go2000, 0, go2000, go2000, go2000_state, empty_init, ROT0, "SunA?", "Go 2000", MACHINE_SUPPORTS_SAVE )