From d1513de7cf75f1f5f3763f001258e735ee75dbb2 Mon Sep 17 00:00:00 2001 From: hap Date: Tue, 24 Dec 2024 13:25:31 +0100 Subject: tamag1: change to a hh_ collection driver --- src/mame/bandai/tamag1.cpp | 261 ++++++++++++++++++++++++----------- src/mame/handheld/hh_ht11xx.cpp | 4 +- src/mame/layout/hh_e0c6x_lcd.lay | 15 ++ src/mame/layout/hh_ht11xx_lcd.lay | 15 ++ src/mame/layout/hh_ht11xx_single.lay | 15 -- 5 files changed, 213 insertions(+), 97 deletions(-) create mode 100644 src/mame/layout/hh_e0c6x_lcd.lay create mode 100644 src/mame/layout/hh_ht11xx_lcd.lay delete mode 100644 src/mame/layout/hh_ht11xx_single.lay diff --git a/src/mame/bandai/tamag1.cpp b/src/mame/bandai/tamag1.cpp index 65cca8c3829..ef73da5e8c9 100644 --- a/src/mame/bandai/tamag1.cpp +++ b/src/mame/bandai/tamag1.cpp @@ -3,16 +3,19 @@ // thanks-to:digshadow, Segher, azya /******************************************************************************* -Bandai Tamagotchi generation 1 hardware +Seiko Epson E0C6S46 / E0C6S48 handhelds, mostly electronic keychain toys from +the late-1990s. The first Tamagotchi games are on this MCU. -Hardware notes: -- PCB label: TMG-M1 -- Seiko Epson E0C6S46 MCU under epoxy -- 32*16 LCD screen + 8 custom segments -- 1-bit sound +These were meant to stay on 24/7, so make sure to use save states if you want +to play the games for a longer time. For the drivers that don't have an SVG +screen, use -prescale or -nofilter to disable bilinear filtering. TODO: -- add the Mothra version that was recently dumped (has a E0C6S48) +- add the Mothra Tamagotchi version that was recently dumped (has a E0C6S48) +- SVGs could be more accurate? it seems they're handmade instead of a 1:1 scan +- alienfev unmapped reads/writes, or are they harmless? +- add LCD deflicker like hh_sm510? see venusdm for example +- hook up LCD contrast, does any game use it? (eg. for fade-out) *******************************************************************************/ @@ -25,36 +28,33 @@ TODO: #include "screen.h" #include "speaker.h" +// internal artwork +#include "hh_e0c6x_lcd.lh" + namespace { -class tamag1_state : public driver_device +class hh_e0c6x_state : public driver_device { public: - tamag1_state(const machine_config &mconfig, device_type type, const char *tag) : + hh_e0c6x_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_out_x(*this, "%u.%u", 0U, 0U) { } - void tama(machine_config &config); - void alienfev(machine_config &config); - void venusdm(machine_config &config); - DECLARE_INPUT_CHANGED_MEMBER(input_changed); protected: virtual void machine_start() override ATTR_COLD; -private: void lcd_segment_w(offs_t offset, u8 data) { m_out_x[offset & 0xf][offset >> 4] = data; } - void pixel_callback(int &dx, int &dy) { int x = dx; dx = dy | (dx / 20) << 4; dy = x % 20; } required_device m_maincpu; output_finder<16, 40> m_out_x; }; -void tamag1_state::machine_start() +void hh_e0c6x_state::machine_start() { m_out_x.resolve(); } @@ -62,51 +62,69 @@ void tamag1_state::machine_start() /******************************************************************************* - Input Ports + + Helper Functions + *******************************************************************************/ -INPUT_CHANGED_MEMBER(tamag1_state::input_changed) +// generic input handlers + +#define PORT_CHANGED_CB(x) \ + PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(hh_e0c6x_state::input_changed), E0C6S46_LINE_K00 + x) + +INPUT_CHANGED_MEMBER(hh_e0c6x_state::input_changed) { // inputs are hooked up backwards here, because MCU input ports are all tied to its interrupt controller m_maincpu->set_input_line(param, newval ? ASSERT_LINE : CLEAR_LINE); } -static INPUT_PORTS_START( tama ) - PORT_START("K0") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K00) - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K01) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K02) - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) -INPUT_PORTS_END -static INPUT_PORTS_START( alienfev ) - PORT_START("K0") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K00) // mode - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K01) // select - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K02) // sound - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K03) // handle -INPUT_PORTS_END -static INPUT_PORTS_START( venusdm ) - PORT_START("K1") - PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K10) - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K11) - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, FUNC(tamag1_state::input_changed), E0C6S46_LINE_K12) - PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) -INPUT_PORTS_END +/******************************************************************************* + Minidrivers (subclass, I/O, Inputs, Machine Config, ROM Defs) +*******************************************************************************/ /******************************************************************************* - Machine Configs + + Bandai Tamagotchi (Generation 1) + * PCB label: TMG-M1 + * Seiko Epson E0C6S46 MCU under epoxy + * 32*16 LCD screen + 8 custom segments, 1-bit sound + + Generation 2 is on the exact same hardware + *******************************************************************************/ -void tamag1_state::tama(machine_config &config) +class tama_state : public hh_e0c6x_state +{ +public: + tama_state(const machine_config &mconfig, device_type type, const char *tag) : + hh_e0c6x_state(mconfig, type, tag) + { } + + void tama(machine_config &config); +}; + +// inputs + +static INPUT_PORTS_START( tama ) + PORT_START("K0") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_CB(0) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_CB(1) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_CB(2) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) +INPUT_PORTS_END + +// config + +void tama_state::tama(machine_config &config) { // basic machine hardware E0C6S46(config, m_maincpu, 32.768_kHz_XTAL); m_maincpu->write_r<4>().set("speaker", FUNC(speaker_sound_device::level_w)).bit(3); - m_maincpu->write_segs().set(FUNC(tamag1_state::lcd_segment_w)); + m_maincpu->write_segs().set(FUNC(tama_state::lcd_segment_w)); // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_SVG)); @@ -114,12 +132,71 @@ void tamag1_state::tama(machine_config &config) screen.set_size(1119, 1080); screen.set_visarea_full(); + config.set_default_layout(layout_hh_e0c6x_lcd); + // sound hardware SPEAKER(config, "mono").front_center(); SPEAKER_SOUND(config, "speaker").add_route(ALL_OUTPUTS, "mono", 0.25); } -void tamag1_state::alienfev(machine_config &config) +// roms + +ROM_START( tama ) + ROM_REGION( 0x3000, "maincpu", 0 ) + ROM_LOAD( "tama.bin", 0x0000, 0x3000, CRC(5c864cb1) SHA1(4b4979cf92dc9d2fb6d7295a38f209f3da144f72) ) + + ROM_REGION( 0x3000, "maincpu:test", 0 ) + ROM_LOAD( "test.bin", 0x0000, 0x3000, CRC(4372220e) SHA1(6e13d015113e16198c0059b9d0c38d7027ae7324) ) // this rom is on the die too, test pin enables it? + + ROM_REGION( 139072, "screen", 0) + ROM_LOAD( "tama.svg", 0, 139072, CRC(9468b964) SHA1(ab49471db21a00a3b3a68da39c40da69da5d7e1b) ) +ROM_END + +ROM_START( tamag2 ) + ROM_REGION( 0x3000, "maincpu", 0 ) + ROM_LOAD( "tamag2.bin", 0x0000, 0x3000, CRC(9f97539e) SHA1(09e5101b37636a314fc599d5d69b4846721b3c88) ) + + ROM_REGION( 139072, "screen", 0) + ROM_LOAD( "tama.svg", 0, 139072, CRC(9468b964) SHA1(ab49471db21a00a3b3a68da39c40da69da5d7e1b) ) +ROM_END + + + + + +/******************************************************************************* + + Epoch Chibi Pachi: Alien Fever + * Seiko Epson E0C6S46 MCU + * 39*16 LCD screen, 1-bit sound + + It's a Pachislot keychain game, the MCU runs on the higher-speed OSC3. + +*******************************************************************************/ + +class alienfev_state : public hh_e0c6x_state +{ +public: + alienfev_state(const machine_config &mconfig, device_type type, const char *tag) : + hh_e0c6x_state(mconfig, type, tag) + { } + + void alienfev(machine_config &config); +}; + +// inputs + +static INPUT_PORTS_START( alienfev ) + PORT_START("K0") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_CB(0) PORT_NAME("Mode") + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_CB(1) PORT_NAME("Select") + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_CHANGED_CB(2) PORT_NAME("Sound") + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_CB(3) PORT_NAME("Handle") +INPUT_PORTS_END + +// config + +void alienfev_state::alienfev(machine_config &config) { // basic machine hardware E0C6S46(config, m_maincpu, 32.768_kHz_XTAL); @@ -137,17 +214,63 @@ void tamag1_state::alienfev(machine_config &config) PALETTE(config, "palette", palette_device::MONOCHROME_INVERTED); + config.set_default_layout(layout_hh_e0c6x_lcd); + // sound hardware SPEAKER(config, "mono").front_center(); SPEAKER_SOUND(config, "speaker").add_route(ALL_OUTPUTS, "mono", 0.25); } -void tamag1_state::venusdm(machine_config &config) +// roms + +ROM_START( alienfev ) + ROM_REGION( 0x3000, "maincpu", 0 ) + ROM_LOAD( "alienfev.bin", 0x0000, 0x3000, CRC(e561599c) SHA1(7927e198f8989861ba057150e59d1f4ad403c1d2) ) +ROM_END + + + + + +/******************************************************************************* + + Nikko Beans Collection: Venus Diet Monogatari + * Seiko Epson E0C6S46 MCU + * 32*20 LCD screen, 1-bit sound + +*******************************************************************************/ + +class venusdm_state : public hh_e0c6x_state +{ +public: + venusdm_state(const machine_config &mconfig, device_type type, const char *tag) : + hh_e0c6x_state(mconfig, type, tag) + { } + + void venusdm(machine_config &config); + +private: + void pixel_callback(int &dx, int &dy) { int x = dx; dx = dy | (dx / 20) << 4; dy = x % 20; } +}; + +// inputs + +static INPUT_PORTS_START( venusdm ) + PORT_START("K1") + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_CHANGED_CB(4) + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_CB(5) + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_CB(6) + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNUSED ) +INPUT_PORTS_END + +// config + +void venusdm_state::venusdm(machine_config &config) { // basic machine hardware E0C6S46(config, m_maincpu, 32.768_kHz_XTAL); m_maincpu->write_r<4>().set("speaker", FUNC(speaker_sound_device::level_w)).bit(3); - m_maincpu->set_pixel_callback(FUNC(tamag1_state::pixel_callback)); + m_maincpu->set_pixel_callback(FUNC(venusdm_state::pixel_callback)); // video hardware screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_LCD)); @@ -160,40 +283,14 @@ void tamag1_state::venusdm(machine_config &config) PALETTE(config, "palette", palette_device::MONOCHROME_INVERTED); + config.set_default_layout(layout_hh_e0c6x_lcd); + // sound hardware SPEAKER(config, "mono").front_center(); SPEAKER_SOUND(config, "speaker").add_route(ALL_OUTPUTS, "mono", 0.25); } - - -/******************************************************************************* - ROM Definitions -*******************************************************************************/ - -ROM_START( tama ) - ROM_REGION( 0x3000, "maincpu", 0 ) - ROM_LOAD( "tama.bin", 0x0000, 0x3000, CRC(5c864cb1) SHA1(4b4979cf92dc9d2fb6d7295a38f209f3da144f72) ) - - ROM_REGION( 0x3000, "maincpu:test", 0 ) - ROM_LOAD( "test.bin", 0x0000, 0x3000, CRC(4372220e) SHA1(6e13d015113e16198c0059b9d0c38d7027ae7324) ) // this rom is on the die too, test pin enables it? - - ROM_REGION( 139072, "screen", 0) - ROM_LOAD( "tama.svg", 0, 139072, CRC(9468b964) SHA1(ab49471db21a00a3b3a68da39c40da69da5d7e1b) ) -ROM_END - -ROM_START( tamag2 ) - ROM_REGION( 0x3000, "maincpu", 0 ) - ROM_LOAD( "tamag2.bin", 0x0000, 0x3000, CRC(9f97539e) SHA1(09e5101b37636a314fc599d5d69b4846721b3c88) ) - - ROM_REGION( 139072, "screen", 0) - ROM_LOAD( "tama.svg", 0, 139072, CRC(9468b964) SHA1(ab49471db21a00a3b3a68da39c40da69da5d7e1b) ) -ROM_END - -ROM_START( alienfev ) - ROM_REGION( 0x3000, "maincpu", 0 ) - ROM_LOAD( "alienfev.bin", 0x0000, 0x3000, CRC(e561599c) SHA1(7927e198f8989861ba057150e59d1f4ad403c1d2) ) -ROM_END +// roms ROM_START( venusdm ) ROM_REGION( 0x3000, "maincpu", 0 ) @@ -205,11 +302,15 @@ ROM_END /******************************************************************************* - Drivers + + Game driver(s) + *******************************************************************************/ -// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY, FULLNAME, FLAGS -SYST( 1997, tama, 0, 0, tama, tama, tamag1_state, empty_init, "Bandai", "Tamagotchi (Gen. 1, World)", MACHINE_SUPPORTS_SAVE | MACHINE_REQUIRES_ARTWORK ) -SYST( 1997, tamag2, 0, 0, tama, tama, tamag1_state, empty_init, "Bandai", "Tamagotchi (Gen. 2, Japan)", MACHINE_SUPPORTS_SAVE | MACHINE_REQUIRES_ARTWORK ) -SYST( 1997, alienfev, 0, 0, alienfev, alienfev, tamag1_state, empty_init, "Epoch", "Chibi Pachi: Alien Fever", MACHINE_SUPPORTS_SAVE ) -SYST( 1997, venusdm, 0, 0, venusdm, venusdm, tamag1_state, empty_init, "Nikko", "Beans Collection: Venus Diet Monogatari", MACHINE_SUPPORTS_SAVE ) +// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY, FULLNAME, FLAGS +SYST( 1997, tama, 0, 0, tama, tama, tama_state, empty_init, "Bandai", "Tamagotchi (Gen. 1, World)", MACHINE_SUPPORTS_SAVE | MACHINE_REQUIRES_ARTWORK ) +SYST( 1997, tamag2, 0, 0, tama, tama, tama_state, empty_init, "Bandai", "Tamagotchi (Gen. 2, Japan)", MACHINE_SUPPORTS_SAVE | MACHINE_REQUIRES_ARTWORK ) + +SYST( 1997, alienfev, 0, 0, alienfev, alienfev, alienfev_state, empty_init, "Epoch", "Chibi Pachi: Alien Fever", MACHINE_SUPPORTS_SAVE ) + +SYST( 1997, venusdm, 0, 0, venusdm, venusdm, venusdm_state, empty_init, "Nikko", "Beans Collection: Venus Diet Monogatari", MACHINE_SUPPORTS_SAVE ) diff --git a/src/mame/handheld/hh_ht11xx.cpp b/src/mame/handheld/hh_ht11xx.cpp index bfae4bb60dc..16ff0ab967c 100644 --- a/src/mame/handheld/hh_ht11xx.cpp +++ b/src/mame/handheld/hh_ht11xx.cpp @@ -32,7 +32,7 @@ TODO: #include "speaker.h" // internal artwork -#include "hh_ht11xx_single.lh" +#include "hh_ht11xx_lcd.lh" namespace { @@ -67,7 +67,7 @@ void hh_ht11xx_state::mcfg_svg_screen(machine_config &config, u16 width, u16 hei screen.set_size(width, height); screen.set_visarea_full(); - config.set_default_layout(layout_hh_ht11xx_single); + config.set_default_layout(layout_hh_ht11xx_lcd); } diff --git a/src/mame/layout/hh_e0c6x_lcd.lay b/src/mame/layout/hh_e0c6x_lcd.lay new file mode 100644 index 00000000000..1e847d9b611 --- /dev/null +++ b/src/mame/layout/hh_e0c6x_lcd.lay @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/src/mame/layout/hh_ht11xx_lcd.lay b/src/mame/layout/hh_ht11xx_lcd.lay new file mode 100644 index 00000000000..1e847d9b611 --- /dev/null +++ b/src/mame/layout/hh_ht11xx_lcd.lay @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/src/mame/layout/hh_ht11xx_single.lay b/src/mame/layout/hh_ht11xx_single.lay deleted file mode 100644 index 1e847d9b611..00000000000 --- a/src/mame/layout/hh_ht11xx_single.lay +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - -- cgit v1.2.3