trunk/src/mess/drivers/comp4.c
r0 | r241784 | |
| 1 | // license:BSD-3-Clause |
| 2 | // copyright-holders:hap |
| 3 | /*************************************************************************** |
| 4 | |
| 5 | Milton Bradley Comp IV |
| 6 | * TMC0904NL CP0904A (die labeled 4A0970D-04A) |
| 7 | |
| 8 | This is a handheld Mastermind game; a code-breaking game where the player |
| 9 | needs to find out the correct sequence of colours (numbers in our case). |
| 10 | It is known as Logic 5 in Europe, and as Pythaugoras in Japan. |
| 11 | |
| 12 | Press the R key to start, followed by a set of unique numbers and E. |
| 13 | Refer to the official manual for more information. |
| 14 | |
| 15 | |
| 16 | TODO: |
| 17 | - write_r doesn't look right, maybe something missing in cpu emulation |
| 18 | |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #include "emu.h" |
| 22 | #include "cpu/tms0980/tms0980.h" |
| 23 | #include "sound/speaker.h" |
| 24 | |
| 25 | // master clock is cpu internal, the value below is an approximation |
| 26 | #define COMP4_CLOCK (250000) |
| 27 | |
| 28 | |
| 29 | class comp4_state : public driver_device |
| 30 | { |
| 31 | public: |
| 32 | comp4_state(const machine_config &mconfig, device_type type, const char *tag) |
| 33 | : driver_device(mconfig, type, tag), |
| 34 | m_maincpu(*this, "maincpu"), |
| 35 | m_button_matrix(*this, "IN") |
| 36 | { } |
| 37 | |
| 38 | required_device<cpu_device> m_maincpu; |
| 39 | required_ioport_array<3> m_button_matrix; |
| 40 | |
| 41 | UINT16 m_o; |
| 42 | |
| 43 | DECLARE_READ8_MEMBER(read_k); |
| 44 | DECLARE_WRITE16_MEMBER(write_o); |
| 45 | DECLARE_WRITE16_MEMBER(write_r); |
| 46 | |
| 47 | virtual void machine_start(); |
| 48 | }; |
| 49 | |
| 50 | |
| 51 | /*************************************************************************** |
| 52 | |
| 53 | I/O |
| 54 | |
| 55 | ***************************************************************************/ |
| 56 | |
| 57 | READ8_MEMBER(comp4_state::read_k) |
| 58 | { |
| 59 | UINT8 k = 0; |
| 60 | |
| 61 | if (m_o == 0) |
| 62 | k |= m_button_matrix[0]->read(); |
| 63 | else if (m_o == 1) |
| 64 | k |= m_button_matrix[1]->read(); |
| 65 | else if (m_o == 2) |
| 66 | k |= m_button_matrix[2]->read(); |
| 67 | |
| 68 | return k; |
| 69 | } |
| 70 | |
| 71 | WRITE16_MEMBER(comp4_state::write_r) |
| 72 | { |
| 73 | // LEDs? |
| 74 | } |
| 75 | |
| 76 | WRITE16_MEMBER(comp4_state::write_o) |
| 77 | { |
| 78 | // O0-O2: input mux |
| 79 | // other bits: some LEDs? |
| 80 | m_o = data; |
| 81 | } |
| 82 | |
| 83 | |
| 84 | |
| 85 | /*************************************************************************** |
| 86 | |
| 87 | Inputs |
| 88 | |
| 89 | ***************************************************************************/ |
| 90 | |
| 91 | static INPUT_PORTS_START( comp4 ) |
| 92 | PORT_START("IN.0") |
| 93 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_CODE(KEYCODE_R) PORT_CODE(KEYCODE_DEL_PAD) PORT_NAME("R") |
| 94 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_CODE(KEYCODE_4) PORT_CODE(KEYCODE_4_PAD) PORT_NAME("4") |
| 95 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_CODE(KEYCODE_1) PORT_CODE(KEYCODE_1_PAD) PORT_NAME("1") |
| 96 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_CODE(KEYCODE_7) PORT_CODE(KEYCODE_7_PAD) PORT_NAME("7") |
| 97 | |
| 98 | PORT_START("IN.1") |
| 99 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_CODE(KEYCODE_0) PORT_CODE(KEYCODE_0_PAD) PORT_NAME("0") |
| 100 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_CODE(KEYCODE_5) PORT_CODE(KEYCODE_5_PAD) PORT_NAME("5") |
| 101 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_CODE(KEYCODE_2) PORT_CODE(KEYCODE_2_PAD) PORT_NAME("2") |
| 102 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_CODE(KEYCODE_8) PORT_CODE(KEYCODE_8_PAD) PORT_NAME("8") |
| 103 | |
| 104 | PORT_START("IN.2") |
| 105 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_CODE(KEYCODE_E) PORT_CODE(KEYCODE_ENTER_PAD) PORT_NAME("E") |
| 106 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_CODE(KEYCODE_6) PORT_CODE(KEYCODE_6_PAD) PORT_NAME("6") |
| 107 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON11 ) PORT_CODE(KEYCODE_3) PORT_CODE(KEYCODE_3_PAD) PORT_NAME("3") |
| 108 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_CODE(KEYCODE_9) PORT_CODE(KEYCODE_9_PAD) PORT_NAME("9") |
| 109 | INPUT_PORTS_END |
| 110 | |
| 111 | |
| 112 | |
| 113 | /*************************************************************************** |
| 114 | |
| 115 | Machine Config |
| 116 | |
| 117 | ***************************************************************************/ |
| 118 | |
| 119 | void comp4_state::machine_start() |
| 120 | { |
| 121 | m_o = 0; |
| 122 | save_item(NAME(m_o)); |
| 123 | } |
| 124 | |
| 125 | |
| 126 | static const UINT16 comp4_output_pla[0x20] = |
| 127 | { |
| 128 | /* O output PLA configuration currently unknown */ |
| 129 | 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, |
| 130 | 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, |
| 131 | 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, |
| 132 | 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f |
| 133 | }; |
| 134 | |
| 135 | |
| 136 | static MACHINE_CONFIG_START( comp4, comp4_state ) |
| 137 | |
| 138 | /* basic machine hardware */ |
| 139 | MCFG_CPU_ADD("maincpu", TMS0970, COMP4_CLOCK) |
| 140 | MCFG_TMS1XXX_OUTPUT_PLA(comp4_output_pla) |
| 141 | MCFG_TMS1XXX_READ_K(READ8(comp4_state, read_k)) |
| 142 | MCFG_TMS1XXX_WRITE_O(WRITE16(comp4_state, write_o)) |
| 143 | MCFG_TMS1XXX_WRITE_R(WRITE16(comp4_state, write_r)) |
| 144 | |
| 145 | /* no video! */ |
| 146 | |
| 147 | /* no sound! */ |
| 148 | MACHINE_CONFIG_END |
| 149 | |
| 150 | |
| 151 | |
| 152 | /*************************************************************************** |
| 153 | |
| 154 | Game driver(s) |
| 155 | |
| 156 | ***************************************************************************/ |
| 157 | |
| 158 | ROM_START( comp4 ) |
| 159 | ROM_REGION( 0x0800, "maincpu", ROMREGION_ERASE00 ) |
| 160 | ROM_LOAD( "cp0904a", 0x0000, 0x0400, CRC(c502c8a1) SHA1(f82ff1a85c4849621d32344964d8b2233fc978d0) ) |
| 161 | ROM_END |
| 162 | |
| 163 | |
| 164 | CONS( 1977, comp4, 0, 0, comp4, comp4, driver_device, 0, "Milton Bradley", "Comp IV", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW ) |