src/mess/drivers/d6800.c
| r15446 | r15447 | |
| 5 | 5 | in May 1979. It has 1k of ROM and 1k of RAM. The video consists of 64x32 |
| 6 | 6 | pixels. The keyboard is a hexcode 4x4 matrix, plus a Function key. |
| 7 | 7 | |
| 8 | Designed by Michael Bauer, of the Division of Computing and Mathematics |
| 9 | at Deakin University, Australia. |
| 10 | |
| 11 | NOTE that the display only updates after each 4 digits is entered, and |
| 12 | you can't see what you type as you change bytes. This is by design. |
| 13 | The speaker is supposed to bleep on each keystroke, but it only gets |
| 14 | one pulse - which is almost inaudible. |
| 15 | |
| 8 | 16 | Function keys: |
| 9 | 17 | FN 0 - Modify memory - firstly enter a 4-digit address, then 2-digit data |
| 10 | 18 | the address will increment by itself, enter the next byte. |
| r15446 | r15447 | |
| 12 | 20 | |
| 13 | 21 | FN 1 - Tape load |
| 14 | 22 | |
| 15 | | FN 2 - Tape save |
| 23 | FN 2 - Tape save. You must have entered the start address at 0002, and |
| 24 | the end address+1 at 0004 (big-endian). |
| 16 | 25 | |
| 17 | | FN 3 - Run. Enter the 4-digit go address, then it starts executing. |
| 26 | FN 3 - Run. You must have entered the 4-digit go address first. |
| 18 | 27 | |
| 28 | All CHIP-8 programs load at 0x200 (max size 4k), and exec address |
| 29 | is C000. |
| 19 | 30 | |
| 20 | 31 | Information and programs can be found at http://chip8.com/?page=78 |
| 21 | 32 | |
| 22 | 33 | |
| 23 | | To change the large numbers at the bottom, start in debug mode, enter |
| 24 | | some data at memory 6 and 7, then G to run. |
| 25 | | |
| 26 | | |
| 27 | 34 | TODO: |
| 28 | 35 | - Cassette |
| 29 | | - CPU should freeze while screen is being drawn |
| 30 | | - Keyboard (should work but it doesn't, due to inadequate PIA emulation) |
| 31 | 36 | |
| 32 | | Current situation: |
| 33 | | - It starts, displays initial screen |
| 34 | | - It checks the status bits looking for a keypress |
| 35 | | - When a key is pressed, it gets into a loop at C2E8-C2EB, waiting for |
| 36 | | a memory location to change. This means it needs an interrupt to kick |
| 37 | | in, from a keypress. |
| 38 | | - The pia only looks for an interrupt when it gets polled, which is |
| 39 | | not the case here, so the emulation hangs. |
| 40 | 37 | */ |
| 41 | 38 | |
| 42 | 39 | |
| r15446 | r15447 | |
| 45 | 42 | #include "sound/beep.h" |
| 46 | 43 | #include "imagedev/cassette.h" |
| 47 | 44 | #include "sound/wave.h" |
| 48 | | #include "sound/speaker.h" |
| 45 | #include "sound/dac.h" |
| 49 | 46 | #include "machine/6821pia.h" |
| 50 | 47 | |
| 51 | 48 | |
| r15446 | r15447 | |
| 57 | 54 | m_maincpu(*this, "maincpu"), |
| 58 | 55 | m_cass(*this, CASSETTE_TAG), |
| 59 | 56 | m_pia(*this, "pia"), |
| 60 | | m_speaker(*this, SPEAKER_TAG), |
| 57 | m_dac(*this, "dac"), |
| 61 | 58 | m_videoram(*this, "videoram") { } |
| 62 | 59 | |
| 63 | | required_device<cpu_device> m_maincpu; |
| 64 | | required_device<cassette_image_device> m_cass; |
| 65 | | required_device<device_t> m_pia; |
| 66 | | required_device<device_t> m_speaker; |
| 67 | 60 | DECLARE_READ8_MEMBER( d6800_cassette_r ); |
| 68 | 61 | DECLARE_WRITE8_MEMBER( d6800_cassette_w ); |
| 69 | 62 | DECLARE_READ8_MEMBER( d6800_keyboard_r ); |
| r15446 | r15447 | |
| 72 | 65 | DECLARE_READ_LINE_MEMBER( d6800_keydown_r ); |
| 73 | 66 | DECLARE_READ_LINE_MEMBER( d6800_rtc_pulse ); |
| 74 | 67 | DECLARE_WRITE_LINE_MEMBER( d6800_screen_w ); |
| 75 | | UINT8 m_keylatch; |
| 76 | | UINT8 m_screen_on; |
| 77 | 68 | UINT8 m_rtc; |
| 69 | bool m_screen_on; |
| 70 | required_device<cpu_device> m_maincpu; |
| 71 | required_device<cassette_image_device> m_cass; |
| 72 | required_device<device_t> m_pia; |
| 73 | required_device<device_t> m_dac; |
| 78 | 74 | required_shared_ptr<UINT8> m_videoram; |
| 75 | private: |
| 76 | UINT8 m_kbd_s; |
| 77 | UINT8 m_portb; |
| 79 | 78 | }; |
| 80 | 79 | |
| 81 | 80 | |
| r15446 | r15447 | |
| 92 | 91 | /* Input Ports */ |
| 93 | 92 | |
| 94 | 93 | static INPUT_PORTS_START( d6800 ) |
| 95 | | PORT_START("LINE0") |
| 94 | PORT_START("X0") |
| 96 | 95 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 97 | 96 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 98 | 97 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') |
| 99 | 98 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 100 | | PORT_BIT( 0xf0, 0xf0, IPT_UNUSED ) |
| 101 | 99 | |
| 102 | | PORT_START("LINE1") |
| 100 | PORT_START("X1") |
| 103 | 101 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') |
| 104 | 102 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 105 | 103 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 106 | 104 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') |
| 107 | | PORT_BIT( 0xf0, 0xf0, IPT_UNUSED ) |
| 108 | 105 | |
| 109 | | PORT_START("LINE2") |
| 106 | PORT_START("X2") |
| 110 | 107 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') |
| 111 | 108 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 112 | 109 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 113 | 110 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 114 | | PORT_BIT( 0xf0, 0xf0, IPT_UNUSED ) |
| 115 | 111 | |
| 116 | | PORT_START("LINE3") |
| 112 | PORT_START("X3") |
| 117 | 113 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 118 | 114 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 119 | 115 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 120 | 116 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 121 | | PORT_BIT( 0xf0, 0xf0, IPT_UNUSED ) |
| 122 | 117 | |
| 123 | | PORT_START("SPECIAL") |
| 118 | PORT_START("Y0") |
| 119 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 120 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') |
| 121 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') |
| 122 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 123 | |
| 124 | PORT_START("Y1") |
| 125 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 126 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 127 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 128 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 129 | |
| 130 | PORT_START("Y2") |
| 131 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') |
| 132 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 133 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 134 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 135 | |
| 136 | PORT_START("Y3") |
| 137 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 138 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') |
| 139 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 140 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 141 | |
| 142 | PORT_START("SHIFT") |
| 124 | 143 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("FN") PORT_CODE(KEYCODE_LSHIFT) |
| 144 | |
| 145 | PORT_START("VS") |
| 146 | /* vblank */ |
| 147 | PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_VBLANK("screen") |
| 125 | 148 | INPUT_PORTS_END |
| 126 | 149 | |
| 127 | 150 | /* Video */ |
| r15446 | r15447 | |
| 129 | 152 | static SCREEN_UPDATE_IND16( d6800 ) |
| 130 | 153 | { |
| 131 | 154 | d6800_state *state = screen.machine().driver_data<d6800_state>(); |
| 132 | | UINT8 x,y,gfx=0,i; |
| 155 | UINT8 x,y,gfx=0; |
| 133 | 156 | |
| 134 | 157 | for (y = 0; y < 32; y++) |
| 135 | 158 | { |
| r15446 | r15447 | |
| 140 | 163 | if (state->m_screen_on) |
| 141 | 164 | gfx = state->m_videoram[ x | (y<<3)]; |
| 142 | 165 | |
| 143 | | for (i = 0; i < 8; i++) |
| 144 | | *p++ = BIT(gfx, 7-i); |
| 166 | *p++ = BIT(gfx, 7); |
| 167 | *p++ = BIT(gfx, 6); |
| 168 | *p++ = BIT(gfx, 5); |
| 169 | *p++ = BIT(gfx, 4); |
| 170 | *p++ = BIT(gfx, 3); |
| 171 | *p++ = BIT(gfx, 2); |
| 172 | *p++ = BIT(gfx, 1); |
| 173 | *p++ = BIT(gfx, 0); |
| 145 | 174 | } |
| 146 | 175 | } |
| 147 | 176 | return 0; |
| r15446 | r15447 | |
| 149 | 178 | |
| 150 | 179 | /* PIA6821 Interface */ |
| 151 | 180 | |
| 152 | | static INTERRUPT_GEN( d6800_interrupt ) |
| 181 | static TIMER_DEVICE_CALLBACK( d6800_p ) |
| 153 | 182 | { |
| 154 | | d6800_state *state = device->machine().driver_data<d6800_state>(); |
| 155 | | state->m_rtc = 1; |
| 183 | d6800_state *state = timer.machine().driver_data<d6800_state>(); |
| 184 | state->m_rtc++; |
| 185 | device_set_input_line(state->m_maincpu, M6800_IRQ_LINE, (state->m_rtc > 0xf8) ? ASSERT_LINE : CLEAR_LINE); |
| 156 | 186 | } |
| 157 | 187 | |
| 188 | |
| 189 | // not used |
| 158 | 190 | READ_LINE_MEMBER( d6800_state::d6800_rtc_pulse ) |
| 159 | 191 | { |
| 160 | | UINT8 res = m_rtc; |
| 161 | | m_rtc = 0; |
| 162 | | return res; |
| 192 | return 1; |
| 163 | 193 | } |
| 164 | 194 | |
| 165 | 195 | READ_LINE_MEMBER( d6800_state::d6800_keydown_r ) |
| 166 | 196 | { |
| 167 | | UINT8 data = ioport("LINE0")->read() |
| 168 | | & ioport("LINE1")->read() |
| 169 | | & ioport("LINE2")->read() |
| 170 | | & ioport("LINE3")->read(); |
| 197 | UINT8 data = ioport("X0")->read() |
| 198 | & ioport("X1")->read() |
| 199 | & ioport("X2")->read() |
| 200 | & ioport("X3")->read(); |
| 171 | 201 | |
| 172 | | return (data==0xff) ? 0 : 1; |
| 202 | m_kbd_s = (data == 15) ? 0 : 1; |
| 203 | |
| 204 | return m_kbd_s; |
| 173 | 205 | } |
| 174 | 206 | |
| 175 | 207 | READ_LINE_MEMBER( d6800_state::d6800_fn_key_r ) |
| 176 | 208 | { |
| 177 | | return ioport("SPECIAL")->read(); |
| 209 | return ioport("SHIFT")->read(); |
| 178 | 210 | } |
| 179 | 211 | |
| 180 | 212 | WRITE_LINE_MEMBER( d6800_state::d6800_screen_w ) |
| r15446 | r15447 | |
| 191 | 223 | knows if the tone is 1200 or 2400 Hz. Input to PIA is bit 7. |
| 192 | 224 | */ |
| 193 | 225 | |
| 194 | | return 0xff; |
| 226 | return ((m_cass->input() > 0.03) ? 1 : 0) | m_portb; |
| 195 | 227 | } |
| 196 | 228 | |
| 197 | 229 | WRITE8_MEMBER( d6800_state::d6800_cassette_w ) |
| r15446 | r15447 | |
| 202 | 234 | bit 0 of the PIA. Bit 6 drives the speaker. |
| 203 | 235 | */ |
| 204 | 236 | |
| 205 | | speaker_level_w(m_speaker, BIT(data, 6)); |
| 237 | m_cass->output(BIT(data, 0) ? -1.0 : +1.0); |
| 238 | |
| 239 | dac_data_w(m_dac, data); |
| 240 | m_portb = data; |
| 206 | 241 | } |
| 207 | 242 | |
| 208 | 243 | READ8_MEMBER( d6800_state::d6800_keyboard_r ) |
| 209 | 244 | { |
| 210 | | UINT8 data = 15; |
| 245 | /* |
| 246 | This system reads the key matrix one way, then swaps the input and output |
| 247 | lines around and reads it another way. This isolates the key that was pressed. |
| 248 | */ |
| 211 | 249 | |
| 212 | | if (!BIT(m_keylatch, 4)) data &= ioport("LINE0")->read(); |
| 213 | | if (!BIT(m_keylatch, 5)) data &= ioport("LINE1")->read(); |
| 214 | | if (!BIT(m_keylatch, 6)) data &= ioport("LINE2")->read(); |
| 215 | | if (!BIT(m_keylatch, 7)) data &= ioport("LINE3")->read(); |
| 250 | m_kbd_s++; |
| 216 | 251 | |
| 217 | | return data | m_keylatch; |
| 252 | if (m_kbd_s == 3) |
| 253 | return 0x0f & ioport("X0")->read() & ioport("X1")->read() & ioport("X2")->read() & ioport("X3")->read(); |
| 254 | else |
| 255 | if (m_kbd_s == 6) |
| 256 | return 0xf0 & ioport("Y0")->read() & ioport("Y1")->read() & ioport("Y2")->read() & ioport("Y3")->read(); |
| 257 | else |
| 258 | return 0xff; |
| 218 | 259 | } |
| 219 | 260 | |
| 220 | 261 | WRITE8_MEMBER( d6800_state::d6800_keyboard_w ) |
| r15446 | r15447 | |
| 234 | 275 | |
| 235 | 276 | */ |
| 236 | 277 | |
| 237 | | |
| 238 | | m_keylatch = data & 0xf0; |
| 239 | 278 | } |
| 240 | 279 | |
| 241 | 280 | static const pia6821_interface d6800_mc6821_intf = |
| r15446 | r15447 | |
| 279 | 318 | /* basic machine hardware */ |
| 280 | 319 | MCFG_CPU_ADD("maincpu",M6800, XTAL_4MHz/4) |
| 281 | 320 | MCFG_CPU_PROGRAM_MAP(d6800_map) |
| 282 | | MCFG_CPU_VBLANK_INT("screen", d6800_interrupt) |
| 283 | 321 | |
| 284 | 322 | MCFG_MACHINE_START(d6800) |
| 285 | 323 | MCFG_MACHINE_RESET(d6800) |
| r15446 | r15447 | |
| 297 | 335 | /* sound hardware */ |
| 298 | 336 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 299 | 337 | MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG) |
| 300 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 301 | | MCFG_SOUND_ADD(SPEAKER_TAG, SPEAKER_SOUND, 0) |
| 302 | 338 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 339 | MCFG_SOUND_ADD("dac", DAC, 0) |
| 340 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 303 | 341 | |
| 304 | 342 | /* devices */ |
| 305 | 343 | MCFG_PIA6821_ADD("pia", d6800_mc6821_intf) |
| 306 | 344 | MCFG_CASSETTE_ADD(CASSETTE_TAG, d6800_cassette_interface) |
| 345 | MCFG_TIMER_ADD_PERIODIC("d6800_p", d6800_p, attotime::from_hz(40000) ) |
| 307 | 346 | MACHINE_CONFIG_END |
| 308 | 347 | |
| 309 | 348 | /* ROMs */ |
| r15446 | r15447 | |
| 313 | 352 | ROM_LOAD( "d6800.bin", 0xc000, 0x0400, CRC(3f97ca2e) SHA1(60f26e57a058262b30befceceab4363a5d65d877) ) |
| 314 | 353 | ROM_END |
| 315 | 354 | |
| 316 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 317 | | COMP( 1979, d6800, 0, 0, d6800, d6800, 0, "Electronics Australia", "Dream 6800", GAME_NOT_WORKING | GAME_NO_SOUND ) |
| 355 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 356 | COMP( 1979, d6800, 0, 0, d6800, d6800, 0, "Electronics Australia", "Dream 6800", GAME_NOT_WORKING ) |