trunk/src/mess/drivers/tc4.c
| r243610 | r243611 | |
| 18 | 18 | |
| 19 | 19 | #include "tc4.lh" |
| 20 | 20 | |
| 21 | | // The master clock is a single stage RC oscillator: R=27.3K, C=100pf, |
| 22 | | //.. |
| 21 | // The master clock is a single stage RC oscillator: R=27.3K, C=100pf. |
| 22 | // TMS1400 RC curve is unknown, so let's do an approximation until it is. |
| 23 | 23 | #define MASTER_CLOCK (475000) |
| 24 | 24 | |
| 25 | 25 | |
| r243610 | r243611 | |
| 29 | 29 | tc4_state(const machine_config &mconfig, device_type type, const char *tag) |
| 30 | 30 | : driver_device(mconfig, type, tag), |
| 31 | 31 | m_maincpu(*this, "maincpu"), |
| 32 | | // m_button_matrix(*this, "IN"), |
| 32 | m_button_matrix(*this, "IN"), |
| 33 | 33 | m_speaker(*this, "speaker") |
| 34 | 34 | { } |
| 35 | 35 | |
| 36 | 36 | required_device<cpu_device> m_maincpu; |
| 37 | | // required_ioport_array<2> m_button_matrix; |
| 37 | required_ioport_array<6> m_button_matrix; |
| 38 | 38 | required_device<speaker_sound_device> m_speaker; |
| 39 | 39 | |
| 40 | 40 | UINT16 m_r; |
| r243610 | r243611 | |
| 49 | 49 | DECLARE_WRITE16_MEMBER(write_r); |
| 50 | 50 | |
| 51 | 51 | TIMER_DEVICE_CALLBACK_MEMBER(display_decay_tick); |
| 52 | bool index_is_7segled(int index); |
| 52 | 53 | void display_update(); |
| 53 | 54 | |
| 54 | 55 | virtual void machine_start(); |
| r243610 | r243611 | |
| 68 | 69 | // decay time, in steps of 1ms |
| 69 | 70 | #define DISPLAY_DECAY_TIME 40 |
| 70 | 71 | |
| 72 | inline bool tc4_state::index_is_7segled(int index) |
| 73 | { |
| 74 | // R5,7,8,9 are 7segs |
| 75 | return (index >= 5 && index <= 9 && index != 6); |
| 76 | } |
| 71 | 77 | |
| 78 | |
| 72 | 79 | void tc4_state::display_update() |
| 73 | 80 | { |
| 74 | 81 | UINT16 active_state[0x10]; |
| r243610 | r243611 | |
| 98 | 105 | for (int i = 0; i < 0x10; i++) |
| 99 | 106 | if (m_display_cache[i] != active_state[i]) |
| 100 | 107 | { |
| 101 | | // if (index_is_7segled(i)) |
| 102 | | // output_set_digit_value(i, BITSWAP8(active_state[i],7,0,1,2,3,4,5,6) & 0x7f); |
| 108 | if (index_is_7segled(i)) |
| 109 | output_set_digit_value(i, active_state[i] & 0x7f); |
| 103 | 110 | |
| 104 | 111 | for (int j = 0; j < 9; j++) |
| 105 | 112 | output_set_lamp_value(i*10 + j, active_state[i] >> j & 1); |
| r243610 | r243611 | |
| 130 | 137 | { |
| 131 | 138 | UINT8 k = 0; |
| 132 | 139 | |
| 140 | // read selected button rows |
| 141 | for (int i = 0; i < 6; i++) |
| 142 | if (m_r >> i & 1) |
| 143 | k |= m_button_matrix[i]->read(); |
| 144 | |
| 145 | // read from cartridge |
| 146 | if (m_r & 0x200) |
| 147 | k |= ioport("CART")->read(); |
| 148 | |
| 133 | 149 | return k; |
| 134 | 150 | } |
| 135 | 151 | |
| 136 | 152 | WRITE16_MEMBER(tc4_state::write_o) |
| 137 | 153 | { |
| 154 | // O0-O7: leds/7segment |
| 155 | m_o = data; |
| 156 | display_update(); |
| 138 | 157 | } |
| 139 | 158 | |
| 140 | 159 | WRITE16_MEMBER(tc4_state::write_r) |
| 141 | 160 | { |
| 161 | // R10: speaker out |
| 162 | m_speaker->level_w(data >> 10 & 1); |
| 163 | |
| 164 | // R0-R5: input mux |
| 165 | // R6: led column 8 |
| 166 | // R9: to cartridge slot |
| 167 | // +other: select leds |
| 168 | m_r = data & 0x3ff; |
| 169 | display_update(); |
| 142 | 170 | } |
| 143 | 171 | |
| 144 | 172 | |
| r243610 | r243611 | |
| 151 | 179 | ***************************************************************************/ |
| 152 | 180 | |
| 153 | 181 | static INPUT_PORTS_START( tc4 ) |
| 182 | PORT_START("IN.0") // R0 |
| 183 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) |
| 184 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) |
| 185 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) |
| 186 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) |
| 187 | |
| 188 | PORT_START("IN.1") // R1 |
| 189 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) |
| 190 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) |
| 191 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) |
| 192 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) |
| 193 | |
| 194 | PORT_START("IN.2") // R2 |
| 195 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) |
| 196 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) |
| 197 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) |
| 198 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) |
| 199 | |
| 200 | PORT_START("IN.3") // R3 |
| 201 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_PLAYER(2) |
| 202 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_PLAYER(2) |
| 203 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_PLAYER(2) |
| 204 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_PLAYER(2) |
| 205 | |
| 206 | PORT_START("IN.4") // R4 |
| 207 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_PLAYER(2) |
| 208 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_PLAYER(2) |
| 209 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_PLAYER(2) |
| 210 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_PLAYER(2) |
| 211 | |
| 212 | PORT_START("IN.5") // R5 |
| 213 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) |
| 214 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) |
| 215 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(2) |
| 216 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(2) |
| 217 | |
| 218 | PORT_START("CART") |
| 219 | PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x00, "R9:1" ) |
| 220 | PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x00, "R9:2" ) |
| 221 | PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x00, "R9:3" ) |
| 222 | PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x00, "R9:4" ) |
| 154 | 223 | INPUT_PORTS_END |
| 155 | 224 | |
| 156 | 225 | |
trunk/src/mess/layout/tc4.lay
| r243610 | r243611 | |
| 3 | 3 | |
| 4 | 4 | <!-- define elements --> |
| 5 | 5 | |
| 6 | <element name="digit" defstate="0"> |
| 7 | <led7seg><color red="1.0" green="0.25" blue="0.28" /></led7seg> |
| 8 | </element> |
| 9 | |
| 6 | 10 | <element name="led" defstate="0"> |
| 7 | | <disk state="0"><color red="0.15" green="0.03" blue="0.03" /></disk> |
| 8 | | <disk state="1"><color red="1.0" green="0.3" blue="0.3" /></disk> |
| 11 | <disk state="0"><color red="0.1" green="0.025" blue="0.028" /></disk> |
| 12 | <disk state="1"><color red="1.0" green="0.25" blue="0.28" /></disk> |
| 9 | 13 | </element> |
| 10 | 14 | |
| 11 | 15 | |
| r243610 | r243611 | |
| 15 | 19 | <view name="Internal Layout"> |
| 16 | 20 | <bounds left="0" right="100" top="0" bottom="100" /> |
| 17 | 21 | |
| 22 | <bezel name="digit5" element="digit"><bounds x="0" y="0" width="10" height="15" /></bezel> |
| 23 | <bezel name="digit9" element="digit"><bounds x="10" y="0" width="10" height="15" /></bezel> |
| 24 | <bezel name="digit8" element="digit"><bounds x="20" y="0" width="10" height="15" /></bezel> |
| 25 | <bezel name="digit7" element="digit"><bounds x="20" y="0" width="10" height="15" /></bezel> |
| 18 | 26 | |
| 27 | <bezel name="lamp77" element="led"><bounds x="0" y="20" width="1" height="1" /></bezel> |
| 28 | <bezel name="lamp87" element="led"><bounds x="2" y="20" width="1" height="1" /></bezel> |
| 29 | <bezel name="lamp97" element="led"><bounds x="4" y="20" width="1" height="1" /></bezel> |
| 30 | <bezel name="lamp57" element="led"><bounds x="6" y="20" width="1" height="1" /></bezel> |
| 31 | |
| 32 | <bezel name="lamp0" element="led"><bounds x="2" y="30" width="1" height="1" /></bezel> |
| 33 | <bezel name="lamp1" element="led"><bounds x="4" y="30" width="1" height="1" /></bezel> |
| 34 | <bezel name="lamp2" element="led"><bounds x="6" y="30" width="1" height="1" /></bezel> |
| 35 | <bezel name="lamp3" element="led"><bounds x="8" y="30" width="1" height="1" /></bezel> |
| 36 | <bezel name="lamp4" element="led"><bounds x="10" y="30" width="1" height="1" /></bezel> |
| 37 | <bezel name="lamp5" element="led"><bounds x="12" y="30" width="1" height="1" /></bezel> |
| 38 | <bezel name="lamp6" element="led"><bounds x="14" y="30" width="1" height="1" /></bezel> |
| 39 | <bezel name="lamp7" element="led"><bounds x="16" y="30" width="1" height="1" /></bezel> |
| 40 | <bezel name="lamp8" element="led"><bounds x="18" y="30" width="1" height="1" /></bezel> |
| 41 | |
| 42 | <bezel name="lamp10" element="led"><bounds x="2" y="32" width="1" height="1" /></bezel> |
| 43 | <bezel name="lamp11" element="led"><bounds x="4" y="32" width="1" height="1" /></bezel> |
| 44 | <bezel name="lamp12" element="led"><bounds x="6" y="32" width="1" height="1" /></bezel> |
| 45 | <bezel name="lamp13" element="led"><bounds x="8" y="32" width="1" height="1" /></bezel> |
| 46 | <bezel name="lamp14" element="led"><bounds x="10" y="32" width="1" height="1" /></bezel> |
| 47 | <bezel name="lamp15" element="led"><bounds x="12" y="32" width="1" height="1" /></bezel> |
| 48 | <bezel name="lamp16" element="led"><bounds x="14" y="32" width="1" height="1" /></bezel> |
| 49 | <bezel name="lamp17" element="led"><bounds x="16" y="32" width="1" height="1" /></bezel> |
| 50 | <bezel name="lamp18" element="led"><bounds x="18" y="32" width="1" height="1" /></bezel> |
| 51 | |
| 52 | <bezel name="lamp88" element="led"><bounds x="0" y="34" width="1" height="1" /></bezel> |
| 53 | <bezel name="lamp20" element="led"><bounds x="2" y="34" width="1" height="1" /></bezel> |
| 54 | <bezel name="lamp21" element="led"><bounds x="4" y="34" width="1" height="1" /></bezel> |
| 55 | <bezel name="lamp22" element="led"><bounds x="6" y="34" width="1" height="1" /></bezel> |
| 56 | <bezel name="lamp23" element="led"><bounds x="8" y="34" width="1" height="1" /></bezel> |
| 57 | <bezel name="lamp24" element="led"><bounds x="10" y="34" width="1" height="1" /></bezel> |
| 58 | <bezel name="lamp25" element="led"><bounds x="12" y="34" width="1" height="1" /></bezel> |
| 59 | <bezel name="lamp26" element="led"><bounds x="14" y="34" width="1" height="1" /></bezel> |
| 60 | <bezel name="lamp27" element="led"><bounds x="16" y="34" width="1" height="1" /></bezel> |
| 61 | <bezel name="lamp28" element="led"><bounds x="18" y="34" width="1" height="1" /></bezel> |
| 62 | <bezel name="lamp78" element="led"><bounds x="20" y="34" width="1" height="1" /></bezel> |
| 63 | |
| 64 | <bezel name="lamp30" element="led"><bounds x="2" y="36" width="1" height="1" /></bezel> |
| 65 | <bezel name="lamp31" element="led"><bounds x="4" y="36" width="1" height="1" /></bezel> |
| 66 | <bezel name="lamp32" element="led"><bounds x="6" y="36" width="1" height="1" /></bezel> |
| 67 | <bezel name="lamp33" element="led"><bounds x="8" y="36" width="1" height="1" /></bezel> |
| 68 | <bezel name="lamp34" element="led"><bounds x="10" y="36" width="1" height="1" /></bezel> |
| 69 | <bezel name="lamp35" element="led"><bounds x="12" y="36" width="1" height="1" /></bezel> |
| 70 | <bezel name="lamp36" element="led"><bounds x="14" y="36" width="1" height="1" /></bezel> |
| 71 | <bezel name="lamp37" element="led"><bounds x="16" y="36" width="1" height="1" /></bezel> |
| 72 | <bezel name="lamp38" element="led"><bounds x="18" y="36" width="1" height="1" /></bezel> |
| 73 | |
| 74 | <bezel name="lamp40" element="led"><bounds x="2" y="38" width="1" height="1" /></bezel> |
| 75 | <bezel name="lamp41" element="led"><bounds x="4" y="38" width="1" height="1" /></bezel> |
| 76 | <bezel name="lamp42" element="led"><bounds x="6" y="38" width="1" height="1" /></bezel> |
| 77 | <bezel name="lamp43" element="led"><bounds x="8" y="38" width="1" height="1" /></bezel> |
| 78 | <bezel name="lamp44" element="led"><bounds x="10" y="38" width="1" height="1" /></bezel> |
| 79 | <bezel name="lamp45" element="led"><bounds x="12" y="38" width="1" height="1" /></bezel> |
| 80 | <bezel name="lamp46" element="led"><bounds x="14" y="38" width="1" height="1" /></bezel> |
| 81 | <bezel name="lamp47" element="led"><bounds x="16" y="38" width="1" height="1" /></bezel> |
| 82 | <bezel name="lamp48" element="led"><bounds x="18" y="38" width="1" height="1" /></bezel> |
| 83 | |
| 84 | |
| 19 | 85 | </view> |
| 20 | 86 | </mamelayout> |