From 63726631c87b9d0609990bebe3946328d87b47da Mon Sep 17 00:00:00 2001 From: hap Date: Mon, 2 Mar 2015 20:50:31 +0100 Subject: hh_pic16 fleshed out --- src/mess/drivers/hh_pic16.c | 171 ++++++++++++++++++++++++++++++++++++++++++-- src/mess/drivers/hh_tms1k.c | 38 +++++----- src/mess/drivers/hh_ucom4.c | 15 ++-- src/mess/layout/maniac.lay | 12 +++- 4 files changed, 203 insertions(+), 33 deletions(-) diff --git a/src/mess/drivers/hh_pic16.c b/src/mess/drivers/hh_pic16.c index cdca00249d6..315db7ffc64 100644 --- a/src/mess/drivers/hh_pic16.c +++ b/src/mess/drivers/hh_pic16.c @@ -5,6 +5,10 @@ Collection of PIC16xx/16Cxx-driven dedicated handhelds or other simple devices + TODO: + - it doesn't work, emu/cpu/pic16c5x needs some love (dev note: hack to make it + playable: remove the TRIS masks) + ***************************************************************************/ #include "emu.h" @@ -20,25 +24,137 @@ public: hh_pic16_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), -// m_inp_matrix(*this, "IN"), - m_speaker(*this, "speaker") + m_inp_matrix(*this, "IN"), + m_speaker(*this, "speaker"), + m_display_wait(33), + m_display_maxy(1), + m_display_maxx(0) { } // devices required_device m_maincpu; -// optional_ioport_array<3> m_inp_matrix; // max 3 + optional_ioport_array<2> m_inp_matrix; // max 2 optional_device m_speaker; + // misc common + UINT8 m_b; + UINT8 m_c; + virtual void machine_start(); + + // display common + int m_display_wait; + int m_display_maxy; + int m_display_maxx; + + UINT32 m_display_state[0x20]; + UINT32 m_display_cache[0x20]; + UINT8 m_display_decay[0x20][0x20]; + UINT16 m_7seg_mask[0x20]; + + TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); + void display_update(); + void display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety); + + // game-specific handlers + DECLARE_WRITE8_MEMBER(maniac_output_w); }; void hh_pic16_state::machine_start() { + // zerofill + memset(m_display_state, 0, sizeof(m_display_state)); + memset(m_display_cache, 0, sizeof(m_display_cache)); + memset(m_display_decay, 0, sizeof(m_display_decay)); + memset(m_7seg_mask, 0, sizeof(m_7seg_mask)); + + m_b = 0; + m_c = 0; + + // register for savestates + save_item(NAME(m_display_maxy)); + save_item(NAME(m_display_maxx)); + save_item(NAME(m_display_wait)); + + save_item(NAME(m_display_state)); + save_item(NAME(m_display_cache)); + save_item(NAME(m_display_decay)); + save_item(NAME(m_7seg_mask)); + + save_item(NAME(m_b)); + save_item(NAME(m_c)); } +/*************************************************************************** + + Helper Functions + +***************************************************************************/ + +// The device may strobe the outputs very fast, it is unnoticeable to the user. +// To prevent flickering here, we need to simulate a decay. + +void hh_pic16_state::display_update() +{ + UINT32 active_state[0x20]; + + for (int y = 0; y < m_display_maxy; y++) + { + active_state[y] = 0; + + for (int x = 0; x < m_display_maxx; x++) + { + // turn on powered segments + if (m_display_state[y] >> x & 1) + m_display_decay[y][x] = m_display_wait; + + // determine active state + int ds = (m_display_decay[y][x] != 0) ? 1 : 0; + active_state[y] |= (ds << x); + } + } + + // on difference, send to output + for (int y = 0; y < m_display_maxy; y++) + if (m_display_cache[y] != active_state[y]) + { + if (m_7seg_mask[y] != 0) + output_set_digit_value(y, active_state[y] & m_7seg_mask[y]); + + const int mul = (m_display_maxx <= 10) ? 10 : 100; + for (int x = 0; x < m_display_maxx; x++) + output_set_lamp_value(y * mul + x, active_state[y] >> x & 1); + } + + memcpy(m_display_cache, active_state, sizeof(m_display_cache)); +} + +TIMER_DEVICE_CALLBACK_MEMBER(hh_pic16_state::display_decay_tick) +{ + // slowly turn off unpowered segments + for (int y = 0; y < m_display_maxy; y++) + for (int x = 0; x < m_display_maxx; x++) + if (!(m_display_state[y] >> x & 1) && m_display_decay[y][x] != 0) + m_display_decay[y][x]--; + + display_update(); +} + +void hh_pic16_state::display_matrix(int maxx, int maxy, UINT32 setx, UINT32 sety) +{ + m_display_maxx = maxx; + m_display_maxy = maxy; + + // update current state + UINT32 mask = (1 << maxx) - 1; + for (int y = 0; y < maxy; y++) + m_display_state[y] = (sety >> y & 1) ? (setx & mask) : 0; + + display_update(); +} @@ -51,21 +167,52 @@ void hh_pic16_state::machine_start() /*************************************************************************** Ideal Maniac, by Ralph Baer - * PIC1655-036 + * PIC1655A-036 ***************************************************************************/ +WRITE8_MEMBER(hh_pic16_state::maniac_output_w) +{ + // B,C: outputs + offset -= PIC16C5x_PORTB; + if (offset) + m_c = data; + else + m_b = data; + + // d7: speaker out/enable + m_speaker->level_w((m_b & m_c) >> 7 & 1); + + // d0-d6: 7seg + m_display_maxx = 7; + m_display_maxy = 2; + + m_7seg_mask[offset] = 0x7f; + m_display_state[offset] = ~data & 0x7f; + display_update(); +} + static INPUT_PORTS_START( maniac ) + PORT_START("IN.0") // port A + PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // bottom-right + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) // upper-right + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) // bottom-left + PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) // upper-left INPUT_PORTS_END static MACHINE_CONFIG_START( maniac, hh_pic16_state ) /* basic machine hardware */ - MCFG_CPU_ADD("maincpu", PIC16C55, 500000) + MCFG_CPU_ADD("maincpu", PIC16C55, 850000) // RC osc. R=13.4K, C=470pf, but unknown RC curve - measured 800-890kHz + MCFG_PIC16C5x_READ_A_CB(IOPORT("IN.0")) + MCFG_PIC16C5x_WRITE_B_CB(WRITE8(hh_pic16_state, maniac_output_w)) + MCFG_PIC16C5x_WRITE_C_CB(WRITE8(hh_pic16_state, maniac_output_w)) + MCFG_PIC16C5x_SET_CONFIG(0) // ? + MCFG_TIMER_DRIVER_ADD_PERIODIC("display_decay", hh_pic16_state, display_decay_tick, attotime::from_msec(1)) MCFG_DEFAULT_LAYOUT(layout_maniac) /* no video! */ @@ -78,10 +225,20 @@ MACHINE_CONFIG_END + + +/*************************************************************************** + + Game driver(s) + +***************************************************************************/ + ROM_START( maniac ) ROM_REGION( 0x0800, "maincpu", 0 ) - ROM_LOAD( "1655-036", 0x0000, 0x0400, CRC(a96f7011) SHA1(e97ae44d3c1e74c7e1024bb0bdab03eecdc9f827) ) + ROM_LOAD( "pic1655a-036", 0x0000, 0x0400, CRC(a96f7011) SHA1(e97ae44d3c1e74c7e1024bb0bdab03eecdc9f827) ) ROM_END -CONS( 1979, maniac, 0, 0, maniac, maniac, driver_device, 0, "Ideal", "Maniac", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) + +/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY, FULLNAME, FLAGS */ +CONS( 1979, maniac, 0, 0, maniac, maniac, driver_device, 0, "Ideal", "Maniac", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) diff --git a/src/mess/drivers/hh_tms1k.c b/src/mess/drivers/hh_tms1k.c index cf5a659150f..b14290ee12a 100644 --- a/src/mess/drivers/hh_tms1k.c +++ b/src/mess/drivers/hh_tms1k.c @@ -50,7 +50,8 @@ TODO: - verify output PLA and microinstructions PLA for MCUs that have been dumped electronically (mpla is usually the default, opla is often custom) - - unknown MCU clocks for some + - unknown MCU clocks for some: TMS1000 and TMS1100 RC curve is documented in + the data manual, but for TMS1400 it's unknown. TMS0970/0980 osc. is on-die. - some of the games rely on the fact that faster(longer) strobed leds appear brighter: tc4(offensive players), bankshot(cue ball) - add softwarelist for tc4 cartridges? @@ -250,7 +251,7 @@ enum lDP = 0x80 }; -// The device strobes the outputs very fast, it is unnoticeable to the user. +// The device may strobe the outputs very fast, it is unnoticeable to the user. // To prevent flickering here, we need to simulate a decay. void hh_tms1k_state::display_update() @@ -2261,28 +2262,29 @@ ROM_END -CONS( 1980, mathmagi, 0, 0, mathmagi, mathmagi, driver_device, 0, "APF Electronics Inc.", "Mathemagician", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW ) +/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY, FULLNAME, FLAGS */ +CONS( 1980, mathmagi, 0, 0, mathmagi, mathmagi, driver_device, 0, "APF Electronics Inc.", "Mathemagician", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW ) -CONS( 1979, amaztron, 0, 0, amaztron, amaztron, driver_device, 0, "Coleco", "Amaze-A-Tron", GAME_SUPPORTS_SAVE ) -CONS( 1981, tc4, 0, 0, tc4, tc4, driver_device, 0, "Coleco", "Total Control 4", GAME_SUPPORTS_SAVE ) +CONS( 1979, amaztron, 0, 0, amaztron, amaztron, driver_device, 0, "Coleco", "Amaze-A-Tron", GAME_SUPPORTS_SAVE ) +CONS( 1981, tc4, 0, 0, tc4, tc4, driver_device, 0, "Coleco", "Total Control 4", GAME_SUPPORTS_SAVE ) -CONS( 1978, ebball, 0, 0, ebball, ebball, driver_device, 0, "Entex", "Electronic Baseball (Entex)", GAME_SUPPORTS_SAVE ) +CONS( 1978, ebball, 0, 0, ebball, ebball, driver_device, 0, "Entex", "Electronic Baseball (Entex)", GAME_SUPPORTS_SAVE ) // or 1979? -CONS( 1979, elecdet, 0, 0, elecdet, elecdet, driver_device, 0, "Ideal", "Electronic Detective", GAME_SUPPORTS_SAVE ) +CONS( 1979, elecdet, 0, 0, elecdet, elecdet, driver_device, 0, "Ideal", "Electronic Detective", GAME_SUPPORTS_SAVE ) // unplayable without game cards -CONS( 1979, starwbc, 0, 0, starwbc, starwbc, driver_device, 0, "Kenner", "Star Wars - Electronic Battle Command", GAME_SUPPORTS_SAVE ) -CONS( 1979, starwbcp, starwbc, 0, starwbc, starwbc, driver_device, 0, "Kenner", "Star Wars - Electronic Battle Command (prototype)", GAME_SUPPORTS_SAVE ) +CONS( 1979, starwbc, 0, 0, starwbc, starwbc, driver_device, 0, "Kenner", "Star Wars - Electronic Battle Command", GAME_SUPPORTS_SAVE ) +CONS( 1979, starwbcp, starwbc, 0, starwbc, starwbc, driver_device, 0, "Kenner", "Star Wars - Electronic Battle Command (prototype)", GAME_SUPPORTS_SAVE ) -CONS( 1977, comp4, 0, 0, comp4, comp4, driver_device, 0, "Milton Bradley", "Comp IV", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW ) -CONS( 1978, simon, 0, 0, simon, simon, driver_device, 0, "Milton Bradley", "Simon (Rev. A)", GAME_SUPPORTS_SAVE ) +CONS( 1977, comp4, 0, 0, comp4, comp4, driver_device, 0, "Milton Bradley", "Comp IV", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW ) +CONS( 1978, simon, 0, 0, simon, simon, driver_device, 0, "Milton Bradley", "Simon (Rev. A)", GAME_SUPPORTS_SAVE ) -CONS( 1977, cnsector, 0, 0, cnsector, cnsector, driver_device, 0, "Parker Brothers", "Code Name: Sector", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW ) -CONS( 1978, merlin, 0, 0, merlin, merlin, driver_device, 0, "Parker Brothers", "Merlin", GAME_SUPPORTS_SAVE ) -CONS( 1979, stopthie, 0, 0, stopthief, stopthief, driver_device, 0, "Parker Brothers", "Stop Thief (Electronic Crime Scanner)", GAME_SUPPORTS_SAVE ) +CONS( 1977, cnsector, 0, 0, cnsector, cnsector, driver_device, 0, "Parker Brothers", "Code Name: Sector", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW ) // unplayable without writing board +CONS( 1978, merlin, 0, 0, merlin, merlin, driver_device, 0, "Parker Brothers", "Merlin", GAME_SUPPORTS_SAVE ) +CONS( 1979, stopthie, 0, 0, stopthief, stopthief, driver_device, 0, "Parker Brothers", "Stop Thief (Electronic Crime Scanner)", GAME_SUPPORTS_SAVE ) // unplayable without game board CONS( 1979, stopthiep, stopthie, 0, stopthief, stopthief, driver_device, 0, "Parker Brothers", "Stop Thief (Electronic Crime Scanner) (prototype)", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) -CONS( 1980, bankshot, 0, 0, bankshot, bankshot, driver_device, 0, "Parker Brothers", "Bank Shot - Electronic Pool", GAME_SUPPORTS_SAVE ) -CONS( 1980, splitsec, 0, 0, splitsec, splitsec, driver_device, 0, "Parker Brothers", "Split Second", GAME_SUPPORTS_SAVE ) +CONS( 1980, bankshot, 0, 0, bankshot, bankshot, driver_device, 0, "Parker Brothers", "Bank Shot - Electronic Pool", GAME_SUPPORTS_SAVE ) +CONS( 1980, splitsec, 0, 0, splitsec, splitsec, driver_device, 0, "Parker Brothers", "Split Second", GAME_SUPPORTS_SAVE ) -CONS( 1981, tandy12, 0, 0, tandy12, tandy12, driver_device, 0, "Tandy Radio Shack", "Tandy-12: Computerized Arcade", GAME_SUPPORTS_SAVE ) +CONS( 1981, tandy12, 0, 0, tandy12, tandy12, driver_device, 0, "Tandy Radio Shack", "Tandy-12: Computerized Arcade", GAME_SUPPORTS_SAVE ) // partially unplayable without cards/dice/.. -CONS( 1978, unk3403, 0, 0, unk3403, unk3403, driver_device, 0, "", "unknown TMS1100 electronic game", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) +CONS( 1978, unk3403, 0, 0, unk3403, unk3403, driver_device, 0, "", "unknown TMS1100 electronic game", GAME_SUPPORTS_SAVE | GAME_NOT_WORKING ) diff --git a/src/mess/drivers/hh_ucom4.c b/src/mess/drivers/hh_ucom4.c index ef800acc5eb..26847716faf 100644 --- a/src/mess/drivers/hh_ucom4.c +++ b/src/mess/drivers/hh_ucom4.c @@ -134,7 +134,7 @@ void hh_ucom4_state::machine_start() ***************************************************************************/ -// The device strobes the outputs very fast, it is unnoticeable to the user. +// The device may strobe the outputs very fast, it is unnoticeable to the user. // To prevent flickering here, we need to simulate a decay. void hh_ucom4_state::display_update() @@ -231,7 +231,6 @@ UINT8 hh_ucom4_state::read_inputs(int columns) NOTE!: MESS external artwork is recommended - ***************************************************************************/ WRITE8_MEMBER(hh_ucom4_state::edracula_grid_w) @@ -456,6 +455,9 @@ MACHINE_CONFIG_END - USA: Pac Man - UK: Puckman (Tomy), and also published by Grandstand as Munchman - Australia: Pac Man-1, published by Futuretronics + + The game will start automatically after turning it on. This Pac Man refuses + to eat dots with his butt, you can only eat them going right-to-left. NOTE!: MESS external artwork is recommended @@ -694,8 +696,9 @@ ROM_END -CONS( 1982, edracula, 0, 0, edracula, edracula, driver_device, 0, "Epoch", "Dracula (Epoch)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK ) +/* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY, FULLNAME, FLAGS */ +CONS( 1982, edracula, 0, 0, edracula, edracula, driver_device, 0, "Epoch", "Dracula (Epoch)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK ) -CONS( 1980, tmtennis, 0, 0, tmtennis, tmtennis, driver_device, 0, "Tomy", "Tennis (Tomy)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK ) -CONS( 1982, tmpacman, 0, 0, tmpacman, tmpacman, driver_device, 0, "Tomy", "Pac Man (Tomy)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK ) -CONS( 1984, alnchase, 0, 0, alnchase, alnchase, driver_device, 0, "Tomy", "Alien Chase", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK ) +CONS( 1980, tmtennis, 0, 0, tmtennis, tmtennis, driver_device, 0, "Tomy", "Tennis (Tomy)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK ) +CONS( 1982, tmpacman, 0, 0, tmpacman, tmpacman, driver_device, 0, "Tomy", "Pac Man (Tomy)", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK ) +CONS( 1984, alnchase, 0, 0, alnchase, alnchase, driver_device, 0, "Tomy", "Alien Chase", GAME_SUPPORTS_SAVE | GAME_REQUIRES_ARTWORK ) diff --git a/src/mess/layout/maniac.lay b/src/mess/layout/maniac.lay index 940ef1a955e..a0376cfca75 100644 --- a/src/mess/layout/maniac.lay +++ b/src/mess/layout/maniac.lay @@ -5,15 +5,23 @@ + + + + + - + - + + + + -- cgit v1.2.3