trunk/src/mess/drivers/cnsector.c
| r242171 | r242172 | |
| 14 | 14 | #include "cnsector.lh" |
| 15 | 15 | |
| 16 | 16 | |
| 17 | // master clock is cpu internal, the value below is an approximation |
| 18 | #define MASTER_CLOCK (250000) |
| 19 | |
| 20 | |
| 17 | 21 | class cnsector_state : public driver_device |
| 18 | 22 | { |
| 19 | 23 | public: |
| 20 | 24 | cnsector_state(const machine_config &mconfig, device_type type, const char *tag) |
| 21 | 25 | : driver_device(mconfig, type, tag), |
| 22 | | m_maincpu(*this, "maincpu") |
| 26 | m_maincpu(*this, "maincpu"), |
| 27 | m_button_matrix(*this, "IN") |
| 23 | 28 | { } |
| 24 | 29 | |
| 25 | 30 | required_device<cpu_device> m_maincpu; |
| 31 | required_ioport_array<5> m_button_matrix; |
| 26 | 32 | |
| 27 | | UINT16 m_r; |
| 28 | 33 | UINT16 m_o; |
| 29 | 34 | |
| 30 | 35 | DECLARE_READ8_MEMBER(read_k); |
| r242171 | r242172 | |
| 44 | 49 | |
| 45 | 50 | READ8_MEMBER(cnsector_state::read_k) |
| 46 | 51 | { |
| 47 | | return 0; |
| 52 | UINT8 k = 0; |
| 53 | |
| 54 | // read selected button rows |
| 55 | for (int i = 0; i < 5; i++) |
| 56 | if (m_o & (1 << i)) |
| 57 | k |= m_button_matrix[i]->read(); |
| 58 | |
| 59 | return k; |
| 48 | 60 | } |
| 49 | 61 | |
| 50 | 62 | WRITE16_MEMBER(cnsector_state::write_r) |
| 51 | 63 | { |
| 52 | | m_r = data; |
| 64 | // R0-R5: select digit |
| 65 | for (int i = 0; i < 6; i++) |
| 66 | output_set_digit_value(i, (data >> i & 1) ? m_o : 0); |
| 67 | |
| 68 | // R6-R9: direction leds |
| 69 | for (int i = 6; i < 10; i++) |
| 70 | output_set_lamp_value(i - 6, data >> i & 1); |
| 53 | 71 | } |
| 54 | 72 | |
| 55 | 73 | WRITE16_MEMBER(cnsector_state::write_o) |
| 56 | 74 | { |
| 75 | // O0-O4: input mux |
| 76 | // O0-O7: digit segments |
| 57 | 77 | m_o = data; |
| 58 | 78 | } |
| 59 | 79 | |
| r242171 | r242172 | |
| 66 | 86 | ***************************************************************************/ |
| 67 | 87 | |
| 68 | 88 | static INPUT_PORTS_START( cnsector ) |
| 89 | PORT_START("IN.0") // O0 |
| 90 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) // ? next |
| 91 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) // ? left |
| 92 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) // nc? |
| 93 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) // ? range |
| 94 | |
| 95 | PORT_START("IN.1") // O1 |
| 96 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) // ? aim |
| 97 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) // ? right |
| 98 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) // nc? |
| 99 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) // ?nc |
| 100 | |
| 101 | PORT_START("IN.2") // O2 |
| 102 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) // ? fire |
| 103 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) // ? evasive |
| 104 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) // nc? |
| 105 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) // ? recall |
| 106 | |
| 107 | PORT_START("IN.3") // O3 |
| 108 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) // ? finder |
| 109 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) // ? slow |
| 110 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) // nc? |
| 111 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) // ?nc |
| 112 | |
| 113 | PORT_START("IN.4") // O4 |
| 114 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) // ? teach |
| 115 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) // ? fast |
| 116 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) // nc? |
| 117 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) // ? move |
| 69 | 118 | INPUT_PORTS_END |
| 70 | 119 | |
| 71 | 120 | |
| r242171 | r242172 | |
| 78 | 127 | |
| 79 | 128 | void cnsector_state::machine_start() |
| 80 | 129 | { |
| 81 | | m_r = 0; |
| 82 | 130 | m_o = 0; |
| 83 | 131 | |
| 84 | | save_item(NAME(m_r)); |
| 85 | 132 | save_item(NAME(m_o)); |
| 86 | 133 | } |
| 87 | 134 | |
| r242171 | r242172 | |
| 89 | 136 | static MACHINE_CONFIG_START( cnsector, cnsector_state ) |
| 90 | 137 | |
| 91 | 138 | /* basic machine hardware */ |
| 92 | | MCFG_CPU_ADD("maincpu", TMS0970, 250000) |
| 139 | MCFG_CPU_ADD("maincpu", TMS0970, MASTER_CLOCK) |
| 93 | 140 | MCFG_TMS1XXX_READ_K_CB(READ8(cnsector_state, read_k)) |
| 94 | 141 | MCFG_TMS1XXX_WRITE_O_CB(WRITE16(cnsector_state, write_o)) |
| 95 | 142 | MCFG_TMS1XXX_WRITE_R_CB(WRITE16(cnsector_state, write_r)) |
trunk/src/mess/layout/cnsector.lay
| r242171 | r242172 | |
| 1 | 1 | <?xml version="1.0"?> |
| 2 | 2 | <mamelayout version="2"> |
| 3 | 3 | |
| 4 | <!-- define elements --> |
| 5 | |
| 6 | <element name="digit" defstate="0"> |
| 7 | <led7seg><color red="1.0" green="0.25" blue="0.20" /></led7seg> |
| 8 | </element> |
| 9 | |
| 10 | <element name="lamp" defstate="0"> |
| 11 | <disk state="1"><color red="1.0" green="0.25" blue="0.20" /></disk> |
| 12 | <disk state="0"><color red="0.2" green="0.0" blue="0.0" /></disk> |
| 13 | </element> |
| 14 | |
| 15 | |
| 16 | <!-- build screen --> |
| 17 | |
| 4 | 18 | <view name="Internal Layout"> |
| 5 | 19 | <bounds left="0" right="200" top="0" bottom="200" /> |
| 6 | 20 | |
| 21 | <bezel name="digit0" element="digit"> |
| 22 | <bounds x="0" y="0" width="10" height="15" /> |
| 23 | </bezel> |
| 24 | <bezel name="digit1" element="digit"> |
| 25 | <bounds x="10" y="0" width="10" height="15" /> |
| 26 | </bezel> |
| 27 | <bezel name="digit2" element="digit"> |
| 28 | <bounds x="20" y="0" width="10" height="15" /> |
| 29 | </bezel> |
| 30 | <bezel name="digit3" element="digit"> |
| 31 | <bounds x="30" y="0" width="10" height="15" /> |
| 32 | </bezel> |
| 33 | <bezel name="digit4" element="digit"> |
| 34 | <bounds x="40" y="0" width="10" height="15" /> |
| 35 | </bezel> |
| 36 | <bezel name="digit5" element="digit"> |
| 37 | <bounds x="50" y="0" width="10" height="15" /> |
| 38 | </bezel> |
| 39 | |
| 40 | <bezel name="lamp0" element="lamp"> |
| 41 | <bounds x="20" y="20" width="5" height="5" /> |
| 42 | </bezel> |
| 43 | <bezel name="lamp1" element="lamp"> |
| 44 | <bounds x="20" y="30" width="5" height="5" /> |
| 45 | </bezel> |
| 46 | <bezel name="lamp2" element="lamp"> |
| 47 | <bounds x="30" y="25" width="5" height="5" /> |
| 48 | </bezel> |
| 49 | <bezel name="lamp3" element="lamp"> |
| 50 | <bounds x="10" y="25" width="5" height="5" /> |
| 51 | </bezel> |
| 52 | |
| 7 | 53 | </view> |
| 8 | 54 | </mamelayout> |