diff options
author | 2023-03-07 16:44:22 +0100 | |
---|---|---|
committer | 2023-03-07 16:44:22 +0100 | |
commit | 3f99355acc73398b663f33f50f47df65895fc9f9 (patch) | |
tree | 80dceeb020157a34ec950674c6ae5ba9d0c71ca0 | |
parent | 27fc20067867039d185d99db754ee0dc9af47b40 (diff) |
- misc/gameace.cpp: enabled save state support
- misc/truco.cpp, misc/trucocl.cpp: consolidated drivers in single files
-rw-r--r-- | src/mame/misc/gameace.cpp | 94 | ||||
-rw-r--r-- | src/mame/misc/truco.cpp | 154 | ||||
-rw-r--r-- | src/mame/misc/truco.h | 57 | ||||
-rw-r--r-- | src/mame/misc/truco_v.cpp | 51 | ||||
-rw-r--r-- | src/mame/misc/trucocl.cpp | 177 | ||||
-rw-r--r-- | src/mame/misc/trucocl.h | 61 | ||||
-rw-r--r-- | src/mame/misc/trucocl_v.cpp | 84 |
7 files changed, 331 insertions, 347 deletions
diff --git a/src/mame/misc/gameace.cpp b/src/mame/misc/gameace.cpp index 96af4357728..eca928be3b1 100644 --- a/src/mame/misc/gameace.cpp +++ b/src/mame/misc/gameace.cpp @@ -42,7 +42,7 @@ basically the hardware is a cost reduced clone of mitchell.cpp with some bits mo TODO: is sound emulation complete? there's data in audio ROM at 0xe000, and while we map that as ROM space in the CPU, it never appears to read there, so it could be banked - lower. + lower. */ @@ -59,6 +59,20 @@ TODO: is sound emulation complete? there's data in audio ROM at 0xe000, and whil #include "tilemap.h" +// configurable logging +#define LOG_MEMBANK (1U << 1) +#define LOG_PALBANK (1U << 2) +#define LOG_VIDBANK (1U << 3) + +//#define VERBOSE (LOG_GENERAL | LOG_MEMBANK | LOG_PALBANK | LOG_VIDBANK) + +#include "logmacro.h" + +#define LOGMEMBANK(...) LOGMASKED(LOG_MEMBANK, __VA_ARGS__) +#define LOGPALBANK(...) LOGMASKED(LOG_PALBANK, __VA_ARGS__) +#define LOGVIDBANK(...) LOGMASKED(LOG_VIDBANK, __VA_ARGS__) + + namespace { class gameace_state : public driver_device @@ -149,22 +163,22 @@ void gameace_state::draw_sprites(bitmap_ind16& bitmap, const rectangle& cliprect { int code = m_spriteram[offs + 0x10]; int sy = 255 - m_spriteram[offs + 0x11]; - int attr = m_spriteram[offs + 0x13]; - int color = attr & 0x0f; + int const attr = m_spriteram[offs + 0x13]; + int const color = attr & 0x0f; int sx = m_spriteram[offs + 0x12] + ((attr & 0x10) << 4); code += (attr & 0xe0) << 3; /* if (m_flipscreen) { - sx = 496 - sx; - sy = 240 - sy; + sx = 496 - sx; + sy = 240 - sy; } */ m_gfxdecode->gfx(1)->transpen(bitmap, cliprect, code, color, 0, 0, - sx-7, sy-14, 15); + sx - 7, sy - 14, 15); } } @@ -178,15 +192,15 @@ uint32_t gameace_state::screen_update(screen_device &screen, bitmap_ind16 &bitma TILE_GET_INFO_MEMBER(gameace_state::get_fg_tile_info) { - int code = m_fgram[tile_index*2] | (m_fgram[(tile_index*2)+1] << 8); - int col = m_colram[tile_index]; - tileinfo.set(0,code,col,0); + int const code = m_fgram[tile_index * 2] | (m_fgram[(tile_index * 2) + 1] << 8); + int const col = m_colram[tile_index]; + tileinfo.set(0, code, col, 0); } void gameace_state::fgram_w(offs_t offset, uint8_t data) { m_fgram[offset] = data; - m_fg_tilemap->mark_tile_dirty(offset/2); + m_fg_tilemap->mark_tile_dirty(offset / 2); } void gameace_state::colram_w(offs_t offset, uint8_t data) @@ -207,7 +221,7 @@ void gameace_state::video_start() void gameace_state::bank_w(uint8_t data) { if (data & 0xf0) - logerror("bank_w unused bits %02x\n", data & 0xf0); + LOGMEMBANK("bank_w unused bits %02x\n", data & 0xf0); m_membank->set_entry(data & 0xf); } @@ -215,16 +229,16 @@ void gameace_state::bank_w(uint8_t data) void gameace_state::palbank_w(uint8_t data) { if (data & 0xdf) - logerror("palbank_w unused bits %02x\n", data & 0xdf); + LOGPALBANK("palbank_w unused bits %02x\n", data & 0xdf); - m_palview.select((data & 0x20)>>5); + m_palview.select((data & 0x20) >> 5); } void gameace_state::vidbank_w(uint8_t data) { if (data & 0xfe) - logerror("videbank_w unused bits %02x\n", data & 0xfe); + LOGVIDBANK("videbank_w unused bits %02x\n", data & 0xfe); m_videoview.select(data & 1); } @@ -236,7 +250,7 @@ uint8_t gameace_state::pal_low_r(offs_t offset, uint8_t data) uint8_t gameace_state::pal_high_r(offs_t offset, uint8_t data) { - return m_palette->read8(offset+0x800); + return m_palette->read8(offset + 0x800); } void gameace_state::pal_low_w(offs_t offset, uint8_t data) @@ -246,7 +260,7 @@ void gameace_state::pal_low_w(offs_t offset, uint8_t data) void gameace_state::pal_high_w(offs_t offset, uint8_t data) { - m_palette->write8(offset+0x800, data); + m_palette->write8(offset + 0x800, data); } void gameace_state::main_program_map(address_map &map) @@ -279,7 +293,7 @@ void gameace_state::main_port_map(address_map &map) uint8_t gameace_state::unk_sound_r() { - // returning bit 1 set here also causes it to read c00e, then do writes to ROM region, is it a devleopment leftover? + // returning bit 1 set here also causes it to read c00e, then do writes to ROM region, is it a development leftover? return 0x00; } @@ -355,7 +369,7 @@ static const gfx_layout spritelayout = 4, { RGN_FRAC(1,2) + 4, RGN_FRAC(1,2) + 0, 4, 0}, { 0, 1, 2, 3, 8+0, 8+1, 8+2, 8+3, 32*8+0, 32*8+1, 32*8+2, 32*8+3, 33*8+0, 33*8+1, 33*8+2, 33*8+3 }, - { + { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, @@ -380,7 +394,7 @@ void gameace_state::gameace(machine_config &config) GENERIC_LATCH_8(config, "soundlatch").data_pending_callback().set_inputline(m_audiocpu, INPUT_LINE_NMI); - screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER)); // TODO: all wrong + 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(512, 256); @@ -406,7 +420,7 @@ ROM_START( hotbody ) ROM_LOAD( "2.14b", 0x00000, 0x40000, CRC(4eff1b0c) SHA1(d2b443b59f50fa9013f528c18b0d38da7c938d22) ) ROM_REGION( 0x20000, "audiocpu", 0 ) - ROM_LOAD( "1.4b", 0x00000, 0x20000, CRC(87e15d1d) SHA1(648d29dbf35638639bbf2ffbcd594e455cecaed2) ) // + ROM_LOAD( "1.4b", 0x00000, 0x20000, CRC(87e15d1d) SHA1(648d29dbf35638639bbf2ffbcd594e455cecaed2) ) ROM_REGION( 0x40000, "sprites", ROMREGION_INVERT ) ROM_LOAD( "3.1f", 0x00000, 0x20000, CRC(680ad651) SHA1(c1e53e7ab0b39d1ab4b6769f64323759ebb976c2) ) @@ -492,28 +506,28 @@ void gameace_state::decode_sprites() memcpy(&buffer[0], rom, 0x40000); constexpr uint8_t decode_table[0x20] = { - (2<<1)+1, (2<<1), - (7<<1), (7<<1)+1, - (0<<1)+1, (0<<1), - (5<<1), (5<<1)+1, - (6<<1), (6<<1)+1, - (3<<1), (3<<1)+1, - (4<<1), (4<<1)+1, - (1<<1), (1<<1)+1, - - (10<<1)+1,(10<<1), - (15<<1), (15<<1)+1, + (2<<1)+1, (2<<1), + (7<<1), (7<<1)+1, + (0<<1)+1, (0<<1), + (5<<1), (5<<1)+1, + (6<<1), (6<<1)+1, + (3<<1), (3<<1)+1, + (4<<1), (4<<1)+1, + (1<<1), (1<<1)+1, + + (10<<1)+1,(10<<1), + (15<<1), (15<<1)+1, (8<<1)+1, (8<<1), - (13<<1), (13<<1)+1, - (14<<1), (14<<1)+1, - (11<<1), (11<<1)+1, - (12<<1), (12<<1)+1, - (9<<1), (9<<1)+1 - }; + (13<<1), (13<<1)+1, + (14<<1), (14<<1)+1, + (11<<1), (11<<1)+1, + (12<<1), (12<<1)+1, + (9<<1), (9<<1)+1 + }; - for (int i = 0x00000; i < 0x40000; i++) + for (int i = 0x00000; i < 0x40000; i++) { uint8_t col = i & 0x1f; uint32_t addr = decode_table[col]; @@ -532,5 +546,5 @@ void gameace_state::init_hotbody() } // anonymous namespace -GAME( 1995, hotbody, 0, gameace, hotbody, gameace_state, init_hotbody, ROT0, "Gameace", "Hot Body I", 0 ) // both 1994 and 1995 strings in ROM -GAME( 1995, hotbody2, 0, gameace, hotbody, gameace_state, init_hotbody, ROT0, "Gameace", "Hot Body II", MACHINE_NOT_WORKING ) // bad dump, no program ROM +GAME( 1995, hotbody, 0, gameace, hotbody, gameace_state, init_hotbody, ROT0, "Gameace", "Hot Body I", MACHINE_SUPPORTS_SAVE ) // both 1994 and 1995 strings in ROM +GAME( 1995, hotbody2, 0, gameace, hotbody, gameace_state, init_hotbody, ROT0, "Gameace", "Hot Body II", MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) // bad dump, no program ROM diff --git a/src/mame/misc/truco.cpp b/src/mame/misc/truco.cpp index 9d47320cec8..2ddc392c7ff 100644 --- a/src/mame/misc/truco.cpp +++ b/src/mame/misc/truco.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Ernesto Corvi, Roberto Fresca +// copyright-holders: Ernesto Corvi, Roberto Fresca + /****************************************************************************************************** Truco-Tron - (c) 198? Playtronic SRL, Argentina. @@ -194,19 +195,121 @@ #include "emu.h" -#include "truco.h" #include "cpu/m6809/m6809.h" #include "machine/6821pia.h" +#include "machine/watchdog.h" +#include "sound/dac.h" #include "video/mc6845.h" + +#include "emupal.h" #include "screen.h" #include "speaker.h" -#define MASTER_CLOCK XTAL(12'000'000) // confirmed -#define CPU_CLOCK (MASTER_CLOCK/16) // guess -#define CRTC_CLOCK (MASTER_CLOCK/8) // guess +// configurable logging +#define LOG_PIA (1U << 1) + +//#define VERBOSE (LOG_GENERAL | LOG_PIA) + +#include "logmacro.h" + +#define LOGPIA(...) LOGMASKED(LOG_PIA, __VA_ARGS__) + + +namespace { + +class truco_state : public driver_device +{ +public: + truco_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), + m_maincpu(*this, "maincpu"), + m_watchdog(*this, "watchdog"), + m_palette(*this, "palette"), + m_dac(*this, "dac"), + m_videoram(*this, "videoram"), + m_battery_ram(*this, "battery_ram"), + m_coin(*this, "COIN") + { } + + void truco(machine_config &config); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; +private: + required_device<cpu_device> m_maincpu; + required_device<watchdog_timer_device> m_watchdog; + required_device<palette_device> m_palette; + required_device<dac_bit_interface> m_dac; + + required_shared_ptr<uint8_t> m_videoram; + required_shared_ptr<uint8_t> m_battery_ram; + + required_ioport m_coin; + + uint8_t m_trigger = 0; + + void porta_w(uint8_t data); + DECLARE_WRITE_LINE_MEMBER(pia_ca2_w); + void portb_w(uint8_t data); + DECLARE_WRITE_LINE_MEMBER(pia_irqa_w); + DECLARE_WRITE_LINE_MEMBER(pia_irqb_w); + + void palette(palette_device &palette) const; + + uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + + INTERRUPT_GEN_MEMBER(interrupt); + void main_map(address_map &map); +}; + + +// video + +void truco_state::palette(palette_device &palette) const +{ + for (int i = 0; i < palette.entries(); i++) + { + int r = (i & 0x8) ? 0xff : 0x00; + int g = (i & 0x4) ? 0xff : 0x00; + int b = (i & 0x2) ? 0xff : 0x00; + + int const dim = (i & 0x1); + + if (dim) + { + r >>= 1; + g >>= 1; + b >>= 1; + } + + palette.set_pen_color(i, rgb_t(r, g, b)); + } +} + +uint32_t truco_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +{ + uint8_t const *videoram = m_videoram; + + for (int y = 0; y < 192; y++) + { + for (int x = 0; x < 256; x++) + { + int const pixel = (videoram[x >> 1] >> ((x & 1) ? 0 : 4)) & 0x0f; + + bitmap.pix(y, x) = m_palette->pen(pixel); + } + + videoram += 0x80; + } + return 0; +} + + +// machine /******************************************* * Read/Write Handlers * @@ -214,7 +317,7 @@ void truco_state::porta_w(uint8_t data) { - logerror("Port A writes: %2x\n", data); + LOGPIA("Port A writes: %2x\n", data); } WRITE_LINE_MEMBER(truco_state::pia_ca2_w) @@ -235,17 +338,17 @@ void truco_state::portb_w(uint8_t data) m_dac->write(BIT(data, 7)); // Isolated the bit for Delta-Sigma DAC if (data & 0x7f) - logerror("Port B writes: %2x\n", data); + LOGPIA("Port B writes: %2x\n", data); } WRITE_LINE_MEMBER(truco_state::pia_irqa_w) { - logerror("PIA irq A: %2x\n", state); + LOGPIA("PIA irq A: %2x\n", state); } WRITE_LINE_MEMBER(truco_state::pia_irqb_w) { - logerror("PIA irq B: %2x\n", state); + LOGPIA("PIA irq B: %2x\n", state); } @@ -256,8 +359,8 @@ WRITE_LINE_MEMBER(truco_state::pia_irqb_w) void truco_state::main_map(address_map &map) { map(0x0000, 0x17ff).ram(); // General purpose RAM - map(0x1800, 0x7bff).ram().share("videoram"); // Video RAM - map(0x7c00, 0x7fff).ram().share("battery_ram"); // Battery backed RAM + map(0x1800, 0x7bff).ram().share(m_videoram); + map(0x7c00, 0x7fff).ram().share(m_battery_ram); map(0x8000, 0x8003).rw("pia0", FUNC(pia6821_device::read), FUNC(pia6821_device::write)); map(0x8004, 0x8004).w("crtc", FUNC(mc6845_device::address_w)); map(0x8005, 0x8005).rw("crtc", FUNC(mc6845_device::register_r), FUNC(mc6845_device::register_w)); @@ -336,8 +439,6 @@ void truco_state::machine_start() void truco_state::machine_reset() { - int a; - // Setup the data on the battery backed RAM // IRQ check @@ -349,17 +450,17 @@ void truco_state::machine_reset() // mainloop check m_battery_ram[0x005] = 0x04; - m_battery_ram[0x22B] = 0x46; + m_battery_ram[0x22b] = 0x46; m_battery_ram[0x236] = 0xfb; - m_battery_ram[0x2fe] = 0x1D; - m_battery_ram[0x359] = 0x5A; + m_battery_ram[0x2fe] = 0x1d; + m_battery_ram[0x359] = 0x5a; // boot check - a = ( m_battery_ram[0x000] << 8 ) | m_battery_ram[0x001]; + int a = (m_battery_ram[0x000] << 8) | m_battery_ram[0x001]; a += 0x4d2; - m_battery_ram[0x01d] = ( a >> 8 ) & 0xff; + m_battery_ram[0x01d] = (a >> 8) & 0xff; m_battery_ram[0x01e] = a & 0xff; m_battery_ram[0x020] = m_battery_ram[0x011]; } @@ -373,14 +474,15 @@ INTERRUPT_GEN_MEMBER(truco_state::interrupt) { // coinup - if ( ioport("COIN")->read() & 1 ) + if (m_coin->read() & 1) { - if ( m_trigger == 0 ) + if (m_trigger == 0) { device.execute().set_input_line(M6809_IRQ_LINE, HOLD_LINE); m_trigger++; } - } else + } + else m_trigger = 0; } @@ -391,6 +493,10 @@ INTERRUPT_GEN_MEMBER(truco_state::interrupt) void truco_state::truco(machine_config &config) { + constexpr XTAL MASTER_CLOCK = XTAL(12'000'000); // confirmed + constexpr XTAL CPU_CLOCK = MASTER_CLOCK / 16; // guess + constexpr XTAL CRTC_CLOCK = MASTER_CLOCK / 8; // guess + // basic machine hardware M6809(config, m_maincpu, CPU_CLOCK); m_maincpu->set_addrmap(AS_PROGRAM, &truco_state::main_map); @@ -412,10 +518,10 @@ void truco_state::truco(machine_config &config) screen.set_refresh_hz(60); screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); // not accurate screen.set_size(256, 192); - screen.set_visarea(0, 256-1, 0, 192-1); + screen.set_visarea_full(); screen.set_screen_update(FUNC(truco_state::screen_update)); - PALETTE(config, "palette", FUNC(truco_state::truco_palette), 16); + PALETTE(config, "palette", FUNC(truco_state::palette), 16); mc6845_device &crtc(MC6845(config, "crtc", CRTC_CLOCK)); // identified as UM6845 crtc.set_screen("screen"); @@ -440,6 +546,8 @@ ROM_START( truco ) ROM_LOAD( "truco.u2", 0x0c000, 0x4000, CRC(ff355750) SHA1(1538f20b1919928ffca439e4046a104ddfbc756c) ) ROM_END +} // anonymous namespace + // YEAR NAME PARENT MACHINE INPUT STATE INIT ROT COMPANY FULLNAME FLAGS GAME( 198?, truco, 0, truco, truco, truco_state, empty_init, ROT0, "Playtronic SRL", "Truco-Tron", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/misc/truco.h b/src/mame/misc/truco.h deleted file mode 100644 index 2996f259ce7..00000000000 --- a/src/mame/misc/truco.h +++ /dev/null @@ -1,57 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi, Roberto Fresca - -#ifndef MAME_MISC_TRUCO_H -#define MAME_MISC_TRUCO_H - -#pragma once - -#include "machine/watchdog.h" -#include "sound/dac.h" -#include "emupal.h" - -class truco_state : public driver_device -{ -public: - truco_state(const machine_config &mconfig, device_type type, const char *tag) : - driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu"), - m_watchdog(*this, "watchdog"), - m_palette(*this, "palette"), - m_dac(*this, "dac"), - m_videoram(*this, "videoram"), - m_battery_ram(*this, "battery_ram") - { } - - void truco(machine_config &config); - -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - -private: - required_device<cpu_device> m_maincpu; - required_device<watchdog_timer_device> m_watchdog; - required_device<palette_device> m_palette; - required_device<dac_bit_interface> m_dac; - - required_shared_ptr<uint8_t> m_videoram; - required_shared_ptr<uint8_t> m_battery_ram; - - int m_trigger = 0; - - void porta_w(uint8_t data); - DECLARE_WRITE_LINE_MEMBER(pia_ca2_w); - void portb_w(uint8_t data); - DECLARE_WRITE_LINE_MEMBER(pia_irqa_w); - DECLARE_WRITE_LINE_MEMBER(pia_irqb_w); - - void truco_palette(palette_device &palette) const; - - uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); - - INTERRUPT_GEN_MEMBER(interrupt); - void main_map(address_map &map); -}; - -#endif // MAME_MISC_TRUCO_H diff --git a/src/mame/misc/truco_v.cpp b/src/mame/misc/truco_v.cpp deleted file mode 100644 index 09d28e55940..00000000000 --- a/src/mame/misc/truco_v.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi, Roberto Fresca -/*************************************************************************** - - Truco-Tron - - Functions to emulate the video hardware of the machine. - -***************************************************************************/ - -#include "emu.h" -#include "truco.h" - -void truco_state::truco_palette(palette_device &palette) const -{ - for (int i = 0; i < palette.entries(); i++) - { - int r = (i & 0x8) ? 0xff : 0x00; - int g = (i & 0x4) ? 0xff : 0x00; - int b = (i & 0x2) ? 0xff : 0x00; - - int const dim = (i & 0x1); - - if (dim) - { - r >>= 1; - g >>= 1; - b >>= 1; - } - - palette.set_pen_color(i, rgb_t(r, g, b)); - } -} - -uint32_t truco_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) -{ - uint8_t const *videoram = m_videoram; - - for (int y = 0; y < 192; y++) - { - for (int x = 0; x < 256; x++) - { - int const pixel = (videoram[x >> 1] >> ((x & 1) ? 0 : 4)) & 0x0f; - - bitmap.pix(y, x) = m_palette->pen(pixel); - } - - videoram += 0x80; - } - return 0; -} diff --git a/src/mame/misc/trucocl.cpp b/src/mame/misc/trucocl.cpp index cef9666705d..47b6e88e07d 100644 --- a/src/mame/misc/trucocl.cpp +++ b/src/mame/misc/trucocl.cpp @@ -1,5 +1,6 @@ // license:BSD-3-Clause -// copyright-holders:Ernesto Corvi +// copyright-holders: Ernesto Corvi + /*************************************************************************** Truco Clemente (c) 1991 Miky SRL @@ -35,13 +36,121 @@ Daughterboard: Custom made, plugged in the 2 roms and Z80 mainboard sockets. ***************************************************************************/ #include "emu.h" -#include "trucocl.h" #include "cpu/z80/z80.h" #include "machine/watchdog.h" +#include "sound/dac.h" + +#include "emupal.h" #include "screen.h" #include "speaker.h" +#include "tilemap.h" + + +namespace { + +class trucocl_state : public driver_device +{ +public: + trucocl_state(const machine_config &mconfig, device_type type, const char *tag) + : driver_device(mconfig, type, tag), + m_videoram(*this, "videoram"), + m_colorram(*this, "colorram"), + m_maincpu_rom(*this, "maincpu"), + m_maincpu(*this, "maincpu"), + m_dac(*this, "dac"), + m_gfxdecode(*this, "gfxdecode") { } + + void trucocl(machine_config &config); + + void init_trucocl(); + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + virtual void video_start() override; + +private: + required_shared_ptr<uint8_t> m_videoram; + required_shared_ptr<uint8_t> m_colorram; + + required_region_ptr<uint8_t> m_maincpu_rom; + + required_device<cpu_device> m_maincpu; + required_device<dac_byte_interface> m_dac; + required_device<gfxdecode_device> m_gfxdecode; + + tilemap_t *m_bg_tilemap = nullptr; + int32_t m_cur_dac_address = 0; + uint16_t m_cur_dac_address_index = 0; + uint8_t m_irq_mask = 0; + emu_timer *m_dac_irq_timer = nullptr; + + void main_map(address_map &map); + void main_io(address_map &map); + + void irq_enable_w(uint8_t data); + void videoram_w(offs_t offset, uint8_t data); + void colorram_w(offs_t offset, uint8_t data); + void audio_dac_w(uint8_t data); + TILE_GET_INFO_MEMBER(get_bg_tile_info); + void palette(palette_device &palette) const; + uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); + INTERRUPT_GEN_MEMBER(interrupt); + + TIMER_CALLBACK_MEMBER(dac_irq); +}; + + +// video + +void trucocl_state::palette(palette_device &palette) const +{ + uint8_t const *const color_prom = memregion("proms")->base(); + + for (int i = 0; i < 32; i++) + palette.set_pen_color(i, pal4bit(color_prom[i] >> 0), pal4bit(color_prom[i + 32] >> 0), pal4bit(color_prom[i + 32] >> 4)); +} + +void trucocl_state::videoram_w(offs_t offset, uint8_t data) +{ + m_videoram[offset] = data; + m_bg_tilemap->mark_tile_dirty(offset); +} + +void trucocl_state::colorram_w(offs_t offset, uint8_t data) +{ + m_colorram[offset] = data; + m_bg_tilemap->mark_tile_dirty(offset); +} + +TILE_GET_INFO_MEMBER(trucocl_state::get_bg_tile_info) +{ + int const gfxsel = m_colorram[tile_index] & 1; + int const bank = ((m_colorram[tile_index] >> 2) & 0x07); + int code = m_videoram[tile_index]; + int const colour = (m_colorram[tile_index] & 2) >> 1; + + code |= (bank & 1) << 10; + code |= (bank & 2) << 8; + code += (bank & 4) << 6; + tileinfo.set(gfxsel, code, colour, 0); +} + +void trucocl_state::video_start() +{ + m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(trucocl_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32); +} + +uint32_t trucocl_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) +{ + m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); + return 0; +} + + +// machine // TODO: doesn't seem suited to neither irq nor nmi void trucocl_state::irq_enable_w(uint8_t data) @@ -58,11 +167,10 @@ TIMER_CALLBACK_MEMBER(trucocl_state::dac_irq) void trucocl_state::audio_dac_w(uint8_t data) { - uint8_t *rom = memregion("maincpu")->base(); - int dac_address = ( data & 0xf0 ) << 8; - int sel = ( ( (~data) >> 1 ) & 2 ) | ( data & 1 ); + int dac_address = (data & 0xf0) << 8; + int const sel = (((~data) >> 1) & 2) | (data & 1); - if ( m_cur_dac_address != dac_address ) + if (m_cur_dac_address != dac_address) { m_cur_dac_address_index = 0; m_cur_dac_address = dac_address; @@ -72,24 +180,24 @@ void trucocl_state::audio_dac_w(uint8_t data) m_cur_dac_address_index++; } - if ( sel & 1 ) + if (sel & 1) dac_address += 0x10000; - if ( sel & 2 ) + if (sel & 2) dac_address += 0x10000; dac_address += 0x10000; - m_dac->write(rom[dac_address+m_cur_dac_address_index]); + m_dac->write(m_maincpu_rom[dac_address + m_cur_dac_address_index]); - m_dac_irq_timer->adjust(attotime::from_hz( 16000 )); + m_dac_irq_timer->adjust(attotime::from_hz(16'000)); } void trucocl_state::main_map(address_map &map) { map(0x0000, 0x3fff).rom(); - map(0x4000, 0x43ff).ram().w(FUNC(trucocl_state::trucocl_videoram_w)).share("videoram"); - map(0x4400, 0x47ff).ram().w(FUNC(trucocl_state::trucocl_colorram_w)).share("colorram"); + map(0x4000, 0x43ff).ram().w(FUNC(trucocl_state::videoram_w)).share(m_videoram); + map(0x4400, 0x47ff).ram().w(FUNC(trucocl_state::colorram_w)).share(m_colorram); map(0x4800, 0x4fff).ram(); map(0x5000, 0x5000).w(FUNC(trucocl_state::irq_enable_w)); map(0x5000, 0x503f).portr("IN0"); @@ -145,25 +253,29 @@ INPUT_PORTS_END static const gfx_layout tilelayout = { - 8,8, /* 8*8 characters */ - 0x10000/32, /* 2048 characters */ - 4, /* 4 bits per pixel */ + 8,8, // 8*8 characters + 0x10000/32, // 2048 characters + 4, // 4 bits per pixel { 0, 1,2,3 }, { 0, 4, 0x8000*8+0,0x8000*8+4, 8*8+0, 8*8+4, 0x8000*8+8*8+0,0x8000*8+8*8+4 }, { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 }, - 16*8 /* every char takes 16 consecutive bytes */ + 16*8 // every char takes 16 consecutive bytes }; static GFXDECODE_START( gfx_trucocl ) - GFXDECODE_ENTRY( "gfx1", 0, tilelayout, 0, 2 ) - GFXDECODE_ENTRY( "gfx1", 0x10000, tilelayout, 0, 2 ) + GFXDECODE_ENTRY( "tiles", 0, tilelayout, 0, 2 ) + GFXDECODE_ENTRY( "tiles", 0x10000, tilelayout, 0, 2 ) GFXDECODE_END void trucocl_state::machine_start() { m_dac_irq_timer = timer_alloc(FUNC(trucocl_state::dac_irq), this); + + save_item(NAME(m_cur_dac_address)); + save_item(NAME(m_cur_dac_address_index)); + save_item(NAME(m_irq_mask)); } void trucocl_state::machine_reset() @@ -173,7 +285,7 @@ void trucocl_state::machine_reset() m_dac_irq_timer->adjust(attotime::never); } -INTERRUPT_GEN_MEMBER(trucocl_state::trucocl_interrupt) +INTERRUPT_GEN_MEMBER(trucocl_state::interrupt) { // if(m_irq_mask) device.execute().set_input_line(0, HOLD_LINE); @@ -181,27 +293,27 @@ INTERRUPT_GEN_MEMBER(trucocl_state::trucocl_interrupt) void trucocl_state::trucocl(machine_config &config) { - /* basic machine hardware */ - Z80(config, m_maincpu, 18432000/6); + // basic machine hardware + Z80(config, m_maincpu, 18'432'000 / 6); m_maincpu->set_addrmap(AS_PROGRAM, &trucocl_state::main_map); m_maincpu->set_addrmap(AS_IO, &trucocl_state::main_io); - m_maincpu->set_vblank_int("screen", FUNC(trucocl_state::trucocl_interrupt)); + m_maincpu->set_vblank_int("screen", FUNC(trucocl_state::interrupt)); WATCHDOG_TIMER(config, "watchdog"); - /* 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(32*8, 32*8); screen.set_visarea(0*8, 32*8-1, 0*8, 32*8-1); - screen.set_screen_update(FUNC(trucocl_state::screen_update_trucocl)); + screen.set_screen_update(FUNC(trucocl_state::screen_update)); screen.set_palette("palette"); GFXDECODE(config, m_gfxdecode, "palette", gfx_trucocl); - PALETTE(config, "palette", FUNC(trucocl_state::trucocl_palette), 32); + PALETTE(config, "palette", FUNC(trucocl_state::palette), 32); - /* sound hardware */ + // sound hardware SPEAKER(config, "speaker").front_center(); DAC_8BIT_R2R(config, "dac", 0).add_route(ALL_OUTPUTS, "speaker", 0.5); // unknown DAC @@ -214,18 +326,21 @@ void trucocl_state::trucocl(machine_config &config) ***************************************************************************/ ROM_START( trucocl ) - ROM_REGION( 0x40000, "maincpu", 0 ) /* ROMs + space for additional RAM + samples */ + ROM_REGION( 0x40000, "maincpu", 0 ) ROM_LOAD( "trucocl.01", 0x00000, 0x20000, CRC(c9511c37) SHA1(d6a0fa573c8d2faf1a94a2be26fcaafe631d0699) ) - ROM_LOAD( "trucocl.03", 0x20000, 0x20000, CRC(b37ce38c) SHA1(00bd506e9a03cb8ed65b0b599514db6b9b0ee5f3) ) /* samples */ + ROM_LOAD( "trucocl.03", 0x20000, 0x20000, CRC(b37ce38c) SHA1(00bd506e9a03cb8ed65b0b599514db6b9b0ee5f3) ) // samples - ROM_REGION( 0x20000, "gfx1", 0 ) - ROM_LOAD( "trucocl.02", 0x0000, 0x20000, CRC(bda803e5) SHA1(e4fee42f23be4e0dc8926b6294e4b3e4a38ff185) ) /* tiles */ + ROM_REGION( 0x20000, "tiles", 0 ) + ROM_LOAD( "trucocl.02", 0x0000, 0x20000, CRC(bda803e5) SHA1(e4fee42f23be4e0dc8926b6294e4b3e4a38ff185) ) ROM_REGION( 0x0040, "proms", 0 ) ROM_LOAD( "27s19.u2", 0x0000, 0x0020, CRC(75aeff6a) SHA1(fecd117ec9bb8ac2834d422eb507ec78410aff0f) ) ROM_LOAD( "27s19.u1", 0x0020, 0x0020, CRC(f952f823) SHA1(adc6a05827b1bc47d84827808c324d93ee0f32b9) ) ROM_END +} // anonymous namespace + + /************************************* * * Game drivers @@ -233,4 +348,4 @@ ROM_END *************************************/ // YEAR NAME PARENT MACHINE INPUT STATE INIT MONITOR -GAME( 1991, trucocl, 0, trucocl, trucocl, trucocl_state, empty_init, ROT0, "Miky SRL", "Truco Clemente", MACHINE_IMPERFECT_SOUND | MACHINE_NOT_WORKING ) +GAME( 1991, trucocl, 0, trucocl, trucocl, trucocl_state, empty_init, ROT0, "Miky SRL", "Truco Clemente", MACHINE_IMPERFECT_SOUND | MACHINE_NOT_WORKING | MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/misc/trucocl.h b/src/mame/misc/trucocl.h deleted file mode 100644 index 51373748633..00000000000 --- a/src/mame/misc/trucocl.h +++ /dev/null @@ -1,61 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi -#ifndef MAME_MISC_TRUCOCL_H -#define MAME_MISC_TRUCOCL_H - -#pragma once - -#include "sound/dac.h" -#include "emupal.h" -#include "tilemap.h" - -class trucocl_state : public driver_device -{ -public: - trucocl_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), - m_videoram(*this, "videoram"), - m_colorram(*this, "colorram"), - m_maincpu(*this, "maincpu"), - m_dac(*this, "dac"), - m_gfxdecode(*this, "gfxdecode") { } - - void trucocl(machine_config &config); - - void init_trucocl(); - -protected: - virtual void machine_start() override; - virtual void machine_reset() override; - virtual void video_start() override; - - TIMER_CALLBACK_MEMBER(dac_irq); - -private: - void main_map(address_map &map); - void main_io(address_map &map); - - void irq_enable_w(uint8_t data); - void trucocl_videoram_w(offs_t offset, uint8_t data); - void trucocl_colorram_w(offs_t offset, uint8_t data); - void audio_dac_w(uint8_t data); - TILE_GET_INFO_MEMBER(get_bg_tile_info); - void trucocl_palette(palette_device &palette) const; - uint32_t screen_update_trucocl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); - INTERRUPT_GEN_MEMBER(trucocl_interrupt); - - int m_cur_dac_address = 0; - int m_cur_dac_address_index = 0; - required_shared_ptr<uint8_t> m_videoram; - required_shared_ptr<uint8_t> m_colorram; - tilemap_t *m_bg_tilemap = nullptr; - - uint8_t m_irq_mask = 0; - emu_timer *m_dac_irq_timer = nullptr; - - required_device<cpu_device> m_maincpu; - required_device<dac_byte_interface> m_dac; - required_device<gfxdecode_device> m_gfxdecode; -}; - -#endif // MAME_MISC_TRUCOCL_H diff --git a/src/mame/misc/trucocl_v.cpp b/src/mame/misc/trucocl_v.cpp deleted file mode 100644 index 6b08145c213..00000000000 --- a/src/mame/misc/trucocl_v.cpp +++ /dev/null @@ -1,84 +0,0 @@ -// license:BSD-3-Clause -// copyright-holders:Ernesto Corvi -/*************************************************************************** - -Truco Clemente (c) 1991 Miky SRL - -driver by Ernesto Corvi - -Notes: -- Audio is almost there. -- After one game you can't play anymore. -- I think this runs on a heavily modified PacMan type of board. - ----------------------------------- -Additional Notes (Roberto Fresca): ----------------------------------- -Mainboard: Pacman bootleg jamma board. -Daughterboard: Custom made, plugged in the 2 roms and Z80 mainboard sockets. - - - 01 x Z80 - - 03 x 27c010 - - 02 x am27s19 - - 03 x GAL 16v8b (All of them have the same contents... Maybe read protected.) - - 01 x PAL CE 20v8h (The fuse map is suspect too) - - 01 x lm324n - - To not overload the driver, I put the rest of technical info in - http://www.mameworld.net/robbie/trucocl.htm - -- Added 2 "hidden" color proms (am27s19) -- One GAL is connected to the color proms inputs. -- The name of the company is "Miky SRL" instead of "Caloi Miky SRL". - Caloi (Carlos Loiseau), is the Clemente's creator. - -***************************************************************************/ - -#include "emu.h" -#include "trucocl.h" - - -void trucocl_state::trucocl_palette(palette_device &palette) const -{ - uint8_t const *const color_prom = memregion("proms")->base(); - - for (int i = 0; i < 32; i++) - palette.set_pen_color(i, pal4bit(color_prom[i] >> 0), pal4bit(color_prom[i + 32] >> 0), pal4bit(color_prom[i + 32] >> 4)); -} - -void trucocl_state::trucocl_videoram_w(offs_t offset, uint8_t data) -{ - m_videoram[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset); -} - -void trucocl_state::trucocl_colorram_w(offs_t offset, uint8_t data) -{ - m_colorram[offset] = data; - m_bg_tilemap->mark_tile_dirty(offset); -} - -TILE_GET_INFO_MEMBER(trucocl_state::get_bg_tile_info) -{ - int gfxsel = m_colorram[tile_index] & 1; - int bank = ( ( m_colorram[tile_index] >> 2 ) & 0x07 ); - int code = m_videoram[tile_index]; - int colour = (m_colorram[tile_index] & 2) >> 1; - - code |= ( bank & 1 ) << 10; - code |= ( bank & 2 ) << 8; - code += ( bank & 4 ) << 6; - - tileinfo.set(gfxsel,code,colour,0); -} - -void trucocl_state::video_start() -{ - m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(trucocl_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32 ); -} - -uint32_t trucocl_state::screen_update_trucocl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) -{ - m_bg_tilemap->draw(screen, bitmap, cliprect, 0, 0); - return 0; -} |