goal92.cpp: finders and other small cleanups

This commit is contained in:
Ivan Vangelista 2022-03-31 18:04:12 +02:00
parent ab69b13e03
commit 11c85437d5
4 changed files with 311 additions and 356 deletions

View File

@ -3737,8 +3737,6 @@ files {
MAME_DIR .. "src/mame/video/dynduke.cpp",
MAME_DIR .. "src/mame/drivers/feversoc.cpp",
MAME_DIR .. "src/mame/drivers/goal92.cpp",
MAME_DIR .. "src/mame/includes/goal92.h",
MAME_DIR .. "src/mame/video/goal92.cpp",
MAME_DIR .. "src/mame/drivers/goodejan.cpp",
MAME_DIR .. "src/mame/drivers/kncljoe.cpp",
MAME_DIR .. "src/mame/includes/kncljoe.h",

View File

@ -10,72 +10,323 @@
***************************************************************************/
#include "emu.h"
#include "includes/goal92.h"
#include "cpu/z80/z80.h"
#include "cpu/m68000/m68000.h"
#include "cpu/z80/z80.h"
#include "machine/gen_latch.h"
#include "sound/msm5205.h"
#include "sound/okim6295.h"
#include "sound/ymopn.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"
#include "tilemap.h"
void goal92_state::goal92_sound_command_w(offs_t offset, uint16_t data, uint16_t mem_mask)
namespace {
class goal92_state : public driver_device
{
if (ACCESSING_BITS_8_15)
public:
goal92_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_bg_data(*this, "bg_data"),
m_fg_data(*this, "fg_data"),
m_tx_data(*this, "tx_data"),
m_spriteram(*this, "spriteram"),
m_scrollram(*this, "scrollram"),
m_buffered_spriteram(*this, "buffered_spriteram", 0x800, ENDIANNESS_BIG),
m_soundbank(*this, "soundbank"),
m_in(*this, "IN%u", 1U),
m_dsw(*this, "DSW%u", 1U),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_msm(*this, "msm"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette")
{ }
void goal92(machine_config &config);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
private:
// memory pointers
required_shared_ptr<uint16_t> m_bg_data;
required_shared_ptr<uint16_t> m_fg_data;
required_shared_ptr<uint16_t> m_tx_data;
required_shared_ptr<uint16_t> m_spriteram;
required_shared_ptr<uint16_t> m_scrollram;
memory_share_creator<uint16_t> m_buffered_spriteram;
required_memory_bank m_soundbank;
// video-related
tilemap_t *m_bg_layer = nullptr;
tilemap_t *m_fg_layer = nullptr;
tilemap_t *m_tx_layer = nullptr;
uint16_t m_fg_bank = 0U;
// misc
uint8_t m_msm5205next = 0;
uint8_t m_adpcm_toggle = 0;
required_ioport_array<3> m_in;
required_ioport_array<2> m_dsw;
// devices
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<msm5205_device> m_msm;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
uint16_t inputs_r(offs_t offset, uint16_t mem_mask = ~0);
void adpcm_data_w(uint8_t data);
uint16_t fg_bank_r();
void fg_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void text_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void background_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void foreground_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void adpcm_control_w(uint8_t data);
TILE_GET_INFO_MEMBER(get_text_tile_info);
TILE_GET_INFO_MEMBER(get_back_tile_info);
TILE_GET_INFO_MEMBER(get_fore_tile_info);
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(screen_vblank);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri);
DECLARE_WRITE_LINE_MEMBER(irqhandler);
DECLARE_WRITE_LINE_MEMBER(adpcm_int);
void main_map(address_map &map);
void sound_map(address_map &map);
};
// video
uint16_t goal92_state::fg_bank_r()
{
return m_fg_bank;
}
void goal92_state::fg_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA(&m_fg_bank);
if (ACCESSING_BITS_0_7)
{
m_soundlatch->write((data >> 8) & 0xff);
m_audiocpu->set_input_line(0, HOLD_LINE);
m_fg_layer->mark_all_dirty();
}
}
uint16_t goal92_state::goal92_inputs_r(offs_t offset, uint16_t mem_mask)
void goal92_state::text_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA(&m_tx_data[offset]);
m_tx_layer->mark_tile_dirty(offset);
}
void goal92_state::background_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA(&m_bg_data[offset]);
m_bg_layer->mark_tile_dirty(offset);
}
void goal92_state::foreground_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA(&m_fg_data[offset]);
m_fg_layer->mark_tile_dirty(offset);
}
TILE_GET_INFO_MEMBER(goal92_state::get_text_tile_info)
{
int tile = m_tx_data[tile_index];
int color = (tile >> 12) & 0xf;
tile &= 0xfff;
tile |= 0xc000;
tileinfo.set(1, tile, color, 0);
}
TILE_GET_INFO_MEMBER(goal92_state::get_back_tile_info)
{
int tile = m_bg_data[tile_index];
int color = (tile >> 12) & 0xf;
tile &= 0xfff;
tileinfo.set(2, tile, color, 0);
}
TILE_GET_INFO_MEMBER(goal92_state::get_fore_tile_info)
{
int tile = m_fg_data[tile_index];
int color = (tile >> 12) & 0xf;
int region;
tile &= 0xfff;
if(m_fg_bank & 0xff)
{
region = 3;
tile |= 0x1000;
}
else
{
region = 4;
tile |= 0x2000;
}
tileinfo.set(region, tile, color, 0);
}
void goal92_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int pri)
{
for (int offs = 3; offs <= 0x400 - 5; offs += 4)
{
uint16_t data = m_buffered_spriteram[offs + 2];
int y = m_buffered_spriteram[offs + 0];
if (y & 0x8000)
break;
if (!(data & 0x8000))
continue;
int sprite = m_buffered_spriteram[offs + 1];
if ((sprite >> 14) != pri)
continue;
int x = m_buffered_spriteram[offs + 3];
sprite &= 0x1fff;
x &= 0x1ff;
y &= 0x1ff;
int color = (data & 0x3f) + 0x40;
int fx = (data & 0x4000) >> 14;
int fy = 0;
x -= 320 / 4 - 16 - 1;
y = 256 - (y + 7);
m_gfxdecode->gfx(0)->transpen(bitmap, cliprect,
sprite,
color, fx, fy, x, y, 15);
}
}
void goal92_state::video_start()
{
m_bg_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(goal92_state::get_back_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_fg_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(goal92_state::get_fore_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_tx_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(goal92_state::get_text_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
m_bg_layer->set_transparent_pen(15);
m_fg_layer->set_transparent_pen(15);
m_tx_layer->set_transparent_pen(15);
}
uint32_t goal92_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_bg_layer->set_scrollx(0, m_scrollram[0] + 60);
m_bg_layer->set_scrolly(0, m_scrollram[1] + 8);
if (m_fg_bank & 0xff)
{
m_fg_layer->set_scrollx(0, m_scrollram[0] + 60);
m_fg_layer->set_scrolly(0, m_scrollram[1] + 8);
}
else
{
m_fg_layer->set_scrollx(0, m_scrollram[2] + 60);
m_fg_layer->set_scrolly(0, m_scrollram[3] + 8);
}
bitmap.fill(m_palette->black_pen(), cliprect);
m_bg_layer->draw(screen, bitmap, cliprect, 0, 0);
draw_sprites(bitmap, cliprect, 2);
if (!(m_fg_bank & 0xff))
draw_sprites(bitmap, cliprect, 1);
m_fg_layer->draw(screen, bitmap, cliprect, 0, 0);
if(m_fg_bank & 0xff)
draw_sprites(bitmap, cliprect, 1);
draw_sprites(bitmap, cliprect, 0);
draw_sprites(bitmap, cliprect, 3);
m_tx_layer->draw(screen, bitmap, cliprect, 0, 0);
return 0;
}
WRITE_LINE_MEMBER(goal92_state::screen_vblank)
{
// rising edge
if (state)
memcpy(m_buffered_spriteram, m_spriteram, 0x400 * 2);
}
// machine
uint16_t goal92_state::inputs_r(offs_t offset, uint16_t mem_mask)
{
switch(offset)
{
case 0:
return ioport("DSW1")->read();
return m_dsw[0]->read();
case 1:
return ioport("IN1")->read();
return m_in[0]->read();
case 2:
return ioport("IN2")->read();
return m_in[1]->read();
case 3:
return ioport("IN3")->read();
return m_in[2]->read();
case 7:
return ioport("DSW2")->read();
return m_dsw[1]->read();
default:
logerror("reading unhandled goal92 inputs %04X %04X @ PC = %04X\n", offset, mem_mask,m_maincpu->pc());
logerror("reading unhandled goal92 inputs %04X %04X @ PC = %04X\n", offset, mem_mask, m_maincpu->pc());
}
return 0;
}
void goal92_state::goal92_map(address_map &map)
void goal92_state::main_map(address_map &map)
{
map(0x000000, 0x0fffff).rom();
map(0x100000, 0x1007ff).ram();
map(0x100800, 0x100fff).ram().w(FUNC(goal92_state::goal92_background_w)).share("bg_data");
map(0x101000, 0x1017ff).ram().w(FUNC(goal92_state::goal92_foreground_w)).share("fg_data");
map(0x100800, 0x100fff).ram().w(FUNC(goal92_state::background_w)).share(m_bg_data);
map(0x101000, 0x1017ff).ram().w(FUNC(goal92_state::foreground_w)).share(m_fg_data);
map(0x101800, 0x101fff).ram(); // it has tiles for clouds, but they aren't used
map(0x102000, 0x102fff).ram().w(FUNC(goal92_state::goal92_text_w)).share("tx_data");
map(0x102000, 0x102fff).ram().w(FUNC(goal92_state::text_w)).share(m_tx_data);
map(0x103000, 0x103fff).ram().w(m_palette, FUNC(palette_device::write16)).share("palette");
map(0x104000, 0x13ffff).ram();
map(0x140000, 0x1407ff).ram().share("spriteram");
map(0x140000, 0x1407ff).ram().share(m_spriteram);
map(0x140800, 0x140801).nopw();
map(0x140802, 0x140803).nopw();
map(0x180000, 0x18000f).r(FUNC(goal92_state::goal92_inputs_r));
map(0x180008, 0x180009).w(FUNC(goal92_state::goal92_sound_command_w));
map(0x180000, 0x18000f).r(FUNC(goal92_state::inputs_r));
map(0x180008, 0x180008).w("soundlatch", FUNC(generic_latch_8_device::write));
map(0x18000a, 0x18000b).nopw();
map(0x180010, 0x180017).writeonly().share("scrollram");
map(0x18001c, 0x18001d).rw(FUNC(goal92_state::goal92_fg_bank_r), FUNC(goal92_state::goal92_fg_bank_w));
map(0x180010, 0x180017).writeonly().share(m_scrollram);
map(0x18001c, 0x18001d).rw(FUNC(goal92_state::fg_bank_r), FUNC(goal92_state::fg_bank_w));
}
/* Sound CPU */
// Sound CPU
void goal92_state::adpcm_control_w(uint8_t data)
{
membank("bank1")->set_entry(data & 0x01);
m_soundbank->set_entry(data & 0x01);
m_msm->reset_w(data & 0x08);
}
@ -85,16 +336,16 @@ void goal92_state::adpcm_data_w(uint8_t data)
m_msm5205next = data;
}
void goal92_state::sound_cpu(address_map &map)
void goal92_state::sound_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
map(0x8000, 0xbfff).bankr("bank1");
map(0x8000, 0xbfff).bankr(m_soundbank);
map(0xe000, 0xe000).w(FUNC(goal92_state::adpcm_control_w));
map(0xe400, 0xe400).w(FUNC(goal92_state::adpcm_data_w));
map(0xe800, 0xe801).rw("ym1", FUNC(ym2203_device::read), FUNC(ym2203_device::write));
map(0xec00, 0xec01).rw("ym2", FUNC(ym2203_device::read), FUNC(ym2203_device::write));
map(0xf000, 0xf7ff).ram();
map(0xf800, 0xf800).r(m_soundlatch, FUNC(generic_latch_8_device::read));
map(0xf800, 0xf800).r("soundlatch", FUNC(generic_latch_8_device::read));
}
static INPUT_PORTS_START( goal92 )
@ -214,18 +465,18 @@ static INPUT_PORTS_START( goal92 )
PORT_DIPSETTING( 0x0000, DEF_STR( On ) )
INPUT_PORTS_END
/* handler called by the 2203 emulator when the internal timers cause an IRQ */
// handler called by the 2203 emulator when the internal timers cause an IRQ
WRITE_LINE_MEMBER(goal92_state::irqhandler)
{
/* NMI writes to MSM ports *only*! -AS */
// NMI writes to MSM ports *only*! -AS
//m_audiocpu->set_input_line(INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE);
}
WRITE_LINE_MEMBER(goal92_state::goal92_adpcm_int)
WRITE_LINE_MEMBER(goal92_state::adpcm_int)
{
m_msm->data_w(m_msm5205next);
m_msm5205next >>= 4;
m_adpcm_toggle^= 1;
m_adpcm_toggle ^= 1;
if (m_adpcm_toggle)
m_audiocpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero);
@ -242,36 +493,20 @@ static const gfx_layout layout_16x16x4 =
16*16
};
#ifdef UNUSED_FUNCTION
static const gfx_layout layout_16x16x4_2 =
{
16,16,
RGN_FRAC(1,1),
4,
{ 0,1,2,3 },
{ 4,0,12,8,20,16,28,24,
512+4,512+0,512+12,512+8,512+20,512+16,512+28,512+24 },
{ 0*32,1*32,2*32,3*32,4*32,5*32,6*32,7*32,
256+0*32,256+1*32,256+2*32,256+3*32,256+4*32,256+5*32,256+6*32,256+7*32 },
1024
};
#endif
static GFXDECODE_START( gfx_goal92 )
GFXDECODE_ENTRY( "gfx1", 0, layout_16x16x4, 0*16, 8*16 ) // Sprites
GFXDECODE_ENTRY( "gfx2", 0, gfx_8x8x4_planar, 48*16, 16 ) // Text Layer
GFXDECODE_ENTRY( "gfx2", 0, layout_16x16x4, 0*16, 16 ) // BG Layer
GFXDECODE_ENTRY( "gfx2", 0, layout_16x16x4, 16*16, 16 ) // Mid Layer
GFXDECODE_ENTRY( "gfx2", 0, layout_16x16x4, 32*16, 16 ) // FG Layer
GFXDECODE_ENTRY( "sprites", 0, layout_16x16x4, 0*16, 8*16 )
GFXDECODE_ENTRY( "tiles", 0, gfx_8x8x4_planar, 48*16, 16 ) // Text Layer
GFXDECODE_ENTRY( "tiles", 0, layout_16x16x4, 0*16, 16 ) // BG Layer
GFXDECODE_ENTRY( "tiles", 0, layout_16x16x4, 16*16, 16 ) // Mid Layer
GFXDECODE_ENTRY( "tiles", 0 , layout_16x16x4, 32*16, 16 ) // FG Layer
GFXDECODE_END
void goal92_state::machine_start()
{
uint8_t *ROM = memregion("audiocpu")->base();
membank("bank1")->configure_entries(0, 2, &ROM[0x10000], 0x4000);
uint8_t *rom = memregion("audiocpu")->base();
m_soundbank->configure_entries(0, 2, &rom[0x8000], 0x4000);
save_item(NAME(m_fg_bank));
save_item(NAME(m_msm5205next));
@ -287,42 +522,42 @@ void goal92_state::machine_reset()
void goal92_state::goal92(machine_config &config)
{
/* basic machine hardware */
M68000(config, m_maincpu, 12000000);
m_maincpu->set_addrmap(AS_PROGRAM, &goal92_state::goal92_map);
m_maincpu->set_vblank_int("screen", FUNC(goal92_state::irq6_line_hold)); /* VBL */
// basic machine hardware
M68000(config, m_maincpu, 24_MHz_XTAL / 2);
m_maincpu->set_addrmap(AS_PROGRAM, &goal92_state::main_map);
m_maincpu->set_vblank_int("screen", FUNC(goal92_state::irq6_line_hold)); // VBL
Z80(config, m_audiocpu, 2500000);
m_audiocpu->set_addrmap(AS_PROGRAM, &goal92_state::sound_cpu); /* IRQs are triggered by the main CPU */
Z80(config, m_audiocpu, 10_MHz_XTAL / 4);
m_audiocpu->set_addrmap(AS_PROGRAM, &goal92_state::sound_map); // IRQs are triggered by the main CPU
/* video hardware */
// video hardware
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_refresh_hz(60);
screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
screen.set_size(40*8, 32*8);
screen.set_visarea(0*8, 40*8-1, 1*8, 31*8-1); // black border at bottom is a game bug...
screen.set_screen_update(FUNC(goal92_state::screen_update_goal92));
screen.screen_vblank().set(FUNC(goal92_state::screen_vblank_goal92));
screen.set_screen_update(FUNC(goal92_state::screen_update));
screen.screen_vblank().set(FUNC(goal92_state::screen_vblank));
screen.set_palette(m_palette);
GFXDECODE(config, m_gfxdecode, m_palette, gfx_goal92);
PALETTE(config, m_palette).set_format(palette_device::xBGR_555, 128*16);
/* sound hardware */
// sound hardware
SPEAKER(config, "mono").front_center();
GENERIC_LATCH_8(config, m_soundlatch);
GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, 0);
ym2203_device &ym1(YM2203(config, "ym1", 2500000/2));
ym2203_device &ym1(YM2203(config, "ym1", 10_MHz_XTAL / 8));
ym1.irq_handler().set(FUNC(goal92_state::irqhandler));
ym1.add_route(ALL_OUTPUTS, "mono", 0.25);
ym2203_device &ym2(YM2203(config, "ym2", 2500000/2));
ym2203_device &ym2(YM2203(config, "ym2", 10_MHz_XTAL / 8));
ym2.add_route(ALL_OUTPUTS, "mono", 0.25);
MSM5205(config, m_msm, 384000);
m_msm->vck_legacy_callback().set(FUNC(goal92_state::goal92_adpcm_int)); /* interrupt function */
m_msm->set_prescaler_selector(msm5205_device::S96_4B); /* 4KHz 4-bit */
MSM5205(config, m_msm, 400_kHz_XTAL);
m_msm->vck_legacy_callback().set(FUNC(goal92_state::adpcm_int)); // interrupt function
m_msm->set_prescaler_selector(msm5205_device::S96_4B); // 4KHz 4-bit
m_msm->add_route(ALL_OUTPUTS, "mono", 0.60);
}
@ -366,27 +601,27 @@ Z80 clock: 2.51MHz
*/
ROM_START( goal92 )
ROM_REGION( 0x100000, "maincpu", 0 ) /* 68000 Code - first 0x20000 bytes are a heavily patched copy of olysoc92a */
ROM_REGION( 0x100000, "maincpu", 0 ) // 68000 Code - first 0x20000 bytes are a heavily patched copy of olysoc92a
ROM_LOAD16_BYTE( "2.bin", 0x00000, 0x80000, CRC(db0a6c7c) SHA1(b609db7806b99bc921806d8b3e5e515b4651c375) )
ROM_LOAD16_BYTE( "3.bin", 0x00001, 0x80000, CRC(e4c45dee) SHA1(542749bd1ff51220a151fe66acdadac83df8f0ee) )
ROM_REGION( 0x18000, "audiocpu", 0 ) /* Z80 code */
ROM_LOAD( "1.bin", 0x00000, 0x8000, CRC(3d317622) SHA1(ae4e8c5247bc215a2769786cb8639bce2f80db22) )
ROM_CONTINUE( 0x10000, 0x8000 ) /* banked at 8000-bfff */
ROM_REGION( 0x10000, "audiocpu", 0 ) // Z80 code
ROM_LOAD( "1.bin", 0x00000, 0x10000, CRC(3d317622) SHA1(ae4e8c5247bc215a2769786cb8639bce2f80db22) )// second half banked at 8000-bfff
ROM_REGION( 0x100000, "gfx1", 0 )
ROM_REGION( 0x100000, "sprites", 0 )
ROM_LOAD( "6.bin", 0x000000, 0x040000, CRC(83cadc8f) SHA1(1d3309750347c5d6d661f5cf452235e5a83a7483) )
ROM_LOAD( "7.bin", 0x040000, 0x040000, CRC(067e10fc) SHA1(9831b8dc9b8efa6f7797b2946ee5be03fb36de7b) )
ROM_LOAD( "5.bin", 0x080000, 0x040000, CRC(9a390af2) SHA1(8bc46f8cc7823b8caf381866bea016ebfad9d5d3) )
ROM_LOAD( "4.bin", 0x0c0000, 0x040000, CRC(69b118d5) SHA1(80ab6f03e1254ba47c27299ce11559b244a024ad) ) // sldh
ROM_REGION( 0x200000, "gfx2", 0 )
ROM_REGION( 0x200000, "tiles", 0 )
ROM_LOAD( "11.bin", 0x000000, 0x080000, CRC(5701e626) SHA1(e6915714e9ca90be8fa8ab1bf7fd1f23a83fb82c) )
ROM_LOAD( "10.bin", 0x080000, 0x080000, CRC(ebb359cc) SHA1(b2f724ef7a91fca0ff0b7d7abe1c37816464b37d) )
ROM_LOAD( "9.bin", 0x100000, 0x080000, CRC(c9f0dd07) SHA1(d70cdb24b7df521255b5841f01dd9e8344ab7bdb) )
ROM_LOAD( "8.bin", 0x180000, 0x080000, CRC(aeab3534) SHA1(af91238f412bfcff3a52232278d81276584614a7) )
ROM_END
} // anonymous namespace
GAME( 1992, goal92, cupsoc, goal92, goal92, goal92_state, empty_init, ROT0, "bootleg", "Goal! '92", MACHINE_IMPERFECT_SOUND | MACHINE_SUPPORTS_SAVE )

View File

@ -1,89 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Pierpaolo Prazzoli, David Haywood
/*************************************************************************
Goal! '92
*************************************************************************/
#ifndef MAME_INCLUDES_GOAL92_H
#define MAME_INCLUDES_GOAL92_H
#pragma once
#include "machine/gen_latch.h"
#include "sound/msm5205.h"
#include "emupal.h"
#include "tilemap.h"
class goal92_state : public driver_device
{
public:
goal92_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_bg_data(*this, "bg_data"),
m_fg_data(*this, "fg_data"),
m_tx_data(*this, "tx_data"),
m_spriteram(*this, "spriteram"),
m_scrollram(*this, "scrollram"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_msm(*this, "msm"),
m_gfxdecode(*this, "gfxdecode"),
m_palette(*this, "palette"),
m_soundlatch(*this, "soundlatch")
{ }
void goal92(machine_config &config);
private:
/* memory pointers */
required_shared_ptr<uint16_t> m_bg_data;
required_shared_ptr<uint16_t> m_fg_data;
required_shared_ptr<uint16_t> m_tx_data;
required_shared_ptr<uint16_t> m_spriteram;
required_shared_ptr<uint16_t> m_scrollram;
std::unique_ptr<uint16_t[]> m_buffered_spriteram;
/* video-related */
tilemap_t *m_bg_layer = nullptr;
tilemap_t *m_fg_layer = nullptr;
tilemap_t *m_tx_layer = nullptr;
uint16_t m_fg_bank = 0U;
/* misc */
int m_msm5205next = 0;
int m_adpcm_toggle = 0;
/* devices */
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<msm5205_device> m_msm;
required_device<gfxdecode_device> m_gfxdecode;
required_device<palette_device> m_palette;
required_device<generic_latch_8_device> m_soundlatch;
void goal92_sound_command_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
uint16_t goal92_inputs_r(offs_t offset, uint16_t mem_mask = ~0);
void adpcm_data_w(uint8_t data);
uint16_t goal92_fg_bank_r();
void goal92_fg_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void goal92_text_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void goal92_background_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void goal92_foreground_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
void adpcm_control_w(uint8_t data);
TILE_GET_INFO_MEMBER(get_text_tile_info);
TILE_GET_INFO_MEMBER(get_back_tile_info);
TILE_GET_INFO_MEMBER(get_fore_tile_info);
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
uint32_t screen_update_goal92(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
DECLARE_WRITE_LINE_MEMBER(screen_vblank_goal92);
void draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri );
DECLARE_WRITE_LINE_MEMBER(irqhandler);
DECLARE_WRITE_LINE_MEMBER(goal92_adpcm_int);
void goal92_map(address_map &map);
void sound_cpu(address_map &map);
};
#endif // MAME_INCLUDES_GOAL92_H

View File

@ -1,189 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:Pierpaolo Prazzoli, David Haywood
/***************************************************************************
Goal '92 video hardware
***************************************************************************/
#include "emu.h"
#include "includes/goal92.h"
uint16_t goal92_state::goal92_fg_bank_r()
{
return m_fg_bank;
}
void goal92_state::goal92_fg_bank_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA(&m_fg_bank);
if (ACCESSING_BITS_0_7)
{
m_fg_layer->mark_all_dirty();
}
}
void goal92_state::goal92_text_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA(&m_tx_data[offset]);
m_tx_layer->mark_tile_dirty(offset);
}
void goal92_state::goal92_background_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA(&m_bg_data[offset]);
m_bg_layer->mark_tile_dirty(offset);
}
void goal92_state::goal92_foreground_w(offs_t offset, uint16_t data, uint16_t mem_mask)
{
COMBINE_DATA(&m_fg_data[offset]);
m_fg_layer->mark_tile_dirty(offset);
}
TILE_GET_INFO_MEMBER(goal92_state::get_text_tile_info)
{
int tile = m_tx_data[tile_index];
int color = (tile >> 12) & 0xf;
tile &= 0xfff;
tile |= 0xc000;
tileinfo.set(1, tile, color, 0);
}
TILE_GET_INFO_MEMBER(goal92_state::get_back_tile_info)
{
int tile = m_bg_data[tile_index];
int color = (tile >> 12) & 0xf;
tile &= 0xfff;
tileinfo.set(2, tile, color, 0);
}
TILE_GET_INFO_MEMBER(goal92_state::get_fore_tile_info)
{
int tile = m_fg_data[tile_index];
int color = (tile >> 12) & 0xf;
int region;
tile &= 0xfff;
if(m_fg_bank & 0xff)
{
region = 3;
tile |= 0x1000;
}
else
{
region = 4;
tile |= 0x2000;
}
tileinfo.set(region, tile, color, 0);
}
void goal92_state::draw_sprites( bitmap_ind16 &bitmap, const rectangle &cliprect, int pri )
{
uint16_t *buffered_spriteram16 = m_buffered_spriteram.get();
int offs, fx, fy, x, y, color, sprite;
for (offs = 3; offs <= 0x400 - 5; offs += 4)
{
uint16_t data = buffered_spriteram16[offs + 2];
y = buffered_spriteram16[offs + 0];
if (y & 0x8000)
break;
if (!(data & 0x8000))
continue;
sprite = buffered_spriteram16[offs + 1];
if ((sprite >> 14) != pri)
continue;
x = buffered_spriteram16[offs + 3];
sprite &= 0x1fff;
x &= 0x1ff;
y &= 0x1ff;
color = (data & 0x3f) + 0x40;
fx = (data & 0x4000) >> 14;
fy = 0;
x -= 320 / 4 - 16 - 1;
y = 256 - (y + 7);
m_gfxdecode->gfx(0)->transpen(bitmap,cliprect,
sprite,
color,fx,fy,x,y,15);
}
}
void goal92_state::video_start()
{
m_bg_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(goal92_state::get_back_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_fg_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(goal92_state::get_fore_tile_info)), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
m_tx_layer = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(goal92_state::get_text_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
m_buffered_spriteram = std::make_unique<uint16_t[]>(0x400 * 2);
save_pointer(NAME(m_buffered_spriteram), 0x400 * 2);
m_bg_layer->set_transparent_pen(15);
m_fg_layer->set_transparent_pen(15);
m_tx_layer->set_transparent_pen(15);
}
uint32_t goal92_state::screen_update_goal92(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_bg_layer->set_scrollx(0, m_scrollram[0] + 60);
m_bg_layer->set_scrolly(0, m_scrollram[1] + 8);
if (m_fg_bank & 0xff)
{
m_fg_layer->set_scrollx(0, m_scrollram[0] + 60);
m_fg_layer->set_scrolly(0, m_scrollram[1] + 8);
}
else
{
m_fg_layer->set_scrollx(0, m_scrollram[2] + 60);
m_fg_layer->set_scrolly(0, m_scrollram[3] + 8);
}
bitmap.fill(m_palette->black_pen(), cliprect);
m_bg_layer->draw(screen, bitmap, cliprect, 0, 0);
draw_sprites(bitmap, cliprect, 2);
if (!(m_fg_bank & 0xff))
draw_sprites(bitmap, cliprect, 1);
m_fg_layer->draw(screen, bitmap, cliprect, 0, 0);
if(m_fg_bank & 0xff)
draw_sprites(bitmap, cliprect, 1);
draw_sprites(bitmap, cliprect, 0);
draw_sprites(bitmap, cliprect, 3);
m_tx_layer->draw(screen, bitmap, cliprect, 0, 0);
return 0;
}
WRITE_LINE_MEMBER(goal92_state::screen_vblank_goal92)
{
// rising edge
if (state)
{
memcpy(m_buffered_spriteram.get(), m_spriteram, 0x400 * 2);
}
}