src/mess/drivers/d6800.c
| r0 | r9493 | |
| 1 | /* |
| 2 | |
| 3 | The Dream 6800 is a CHIP-8 computer roughly modelled on the Cosmac VIP. |
| 4 | It was decribed in Electronics Australia magazine in 4 articles starting |
| 5 | in May 1979. It has 1k of ROM and 1k of RAM. The video consists of 64x32 |
| 6 | pixels. The keyboard is a hexcode 4x4 matrix, plus a Function key. |
| 7 | |
| 8 | Function keys: |
| 9 | FN 0 - Modify memory - firstly enter a 4-digit address, then 2-digit data |
| 10 | the address will increment by itself, enter the next byte. |
| 11 | FN by itself will step to the next address. |
| 12 | |
| 13 | FN 1 - Tape load |
| 14 | |
| 15 | FN 2 - Tape save |
| 16 | |
| 17 | FN 3 - Run. Enter the 4-digit go address, then it starts executing. |
| 18 | |
| 19 | |
| 20 | Information and programs can be found at http://chip8.com/?page=78 |
| 21 | |
| 22 | |
| 23 | |
| 24 | TODO: |
| 25 | - It doesn't boot up |
| 26 | - Find correct address of pia |
| 27 | - Cassette |
| 28 | - RTC (vertical pulse) |
| 29 | - CPU should freeze while screen is being drawn |
| 30 | - Confirm if screen is being drawn the right way |
| 31 | - Confirm keyboard configuration |
| 32 | */ |
| 33 | |
| 34 | #include "emu.h" |
| 35 | #include "cpu/m6800/m6800.h" |
| 36 | #include "sound/beep.h" |
| 37 | #include "devices/cassette.h" |
| 38 | #include "sound/wave.h" |
| 39 | #include "sound/speaker.h" |
| 40 | #include "machine/6821pia.h" |
| 41 | #include "machine/rescap.h" |
| 42 | |
| 43 | static UINT8 d6800_keylatch; |
| 44 | static UINT8 d6800_keydown; |
| 45 | static UINT8 d6800_screen; |
| 46 | static running_device *d6800_cassette; |
| 47 | static running_device *d6800_speaker; |
| 48 | |
| 49 | class d6800_state : public driver_device |
| 50 | { |
| 51 | public: |
| 52 | d6800_state(running_machine &machine, const driver_device_config_base &config) |
| 53 | : driver_device(machine, config) { } |
| 54 | |
| 55 | UINT8 dummy; |
| 56 | }; |
| 57 | |
| 58 | |
| 59 | /* Memory Maps */ |
| 60 | |
| 61 | static ADDRESS_MAP_START( d6800_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 62 | AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x7c00) AM_RAM AM_REGION("maincpu", 0x0000) |
| 63 | AM_RANGE(0x8010, 0x8013) AM_MIRROR(0x3cec) AM_DEVREADWRITE("pia", pia6821_r, pia6821_w) |
| 64 | AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3c00) AM_ROM |
| 65 | ADDRESS_MAP_END |
| 66 | |
| 67 | /* Input Ports */ |
| 68 | |
| 69 | static INPUT_PORTS_START( d6800 ) |
| 70 | PORT_START("LINE0") |
| 71 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 72 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 73 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') |
| 74 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 75 | |
| 76 | PORT_START("LINE1") |
| 77 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') |
| 78 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 79 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 80 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') |
| 81 | |
| 82 | PORT_START("LINE2") |
| 83 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') |
| 84 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 85 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 86 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 87 | |
| 88 | PORT_START("LINE3") |
| 89 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 90 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 91 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 92 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 93 | |
| 94 | PORT_START("SPECIAL") |
| 95 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYPAD ) PORT_NAME("FN") PORT_CODE(KEYCODE_LSHIFT) |
| 96 | INPUT_PORTS_END |
| 97 | |
| 98 | /* Video */ |
| 99 | |
| 100 | static VIDEO_UPDATE( d6800 ) |
| 101 | { |
| 102 | UINT8 x,y,gfx=0; |
| 103 | UINT8 *RAM = memory_region(screen->machine, "maincpu"); |
| 104 | |
| 105 | for (y = 0; y < 32; y++) |
| 106 | { |
| 107 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 108 | |
| 109 | for (x = 0; x < 8; x++) |
| 110 | { |
| 111 | if (d6800_screen) |
| 112 | gfx = RAM[0x100 | x | (y<<3)]; |
| 113 | |
| 114 | *p++ = ( gfx & 0x80 ) ? 1 : 0; |
| 115 | *p++ = ( gfx & 0x40 ) ? 1 : 0; |
| 116 | *p++ = ( gfx & 0x20 ) ? 1 : 0; |
| 117 | *p++ = ( gfx & 0x10 ) ? 1 : 0; |
| 118 | *p++ = ( gfx & 0x08 ) ? 1 : 0; |
| 119 | *p++ = ( gfx & 0x04 ) ? 1 : 0; |
| 120 | *p++ = ( gfx & 0x02 ) ? 1 : 0; |
| 121 | *p++ = ( gfx & 0x01 ) ? 1 : 0; |
| 122 | } |
| 123 | } |
| 124 | return 0; |
| 125 | } |
| 126 | |
| 127 | /* PIA6821 Interface */ |
| 128 | |
| 129 | static READ_LINE_DEVICE_HANDLER( d6800_rtc_pulse ) |
| 130 | { |
| 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | static READ_LINE_DEVICE_HANDLER( d6800_keydown_r ) |
| 135 | { |
| 136 | return d6800_keydown; |
| 137 | } |
| 138 | |
| 139 | static READ_LINE_DEVICE_HANDLER( d6800_fn_key_r ) |
| 140 | { |
| 141 | return input_port_read(device->machine, "SPECIAL"); |
| 142 | } |
| 143 | |
| 144 | static WRITE_LINE_DEVICE_HANDLER( d6800_screen_w ) |
| 145 | { |
| 146 | d6800_screen = state; |
| 147 | } |
| 148 | |
| 149 | static READ8_DEVICE_HANDLER( d6800_cassette_r ) |
| 150 | { |
| 151 | /* |
| 152 | Cassette circuit consists of a 741 op-amp, a 74121 oneshot, and a 74LS74. |
| 153 | When a pulse arrives, the oneshot is set. After a preset time, it triggers |
| 154 | and the 74LS74 compares this pulse to the output of the 741. Therefore it |
| 155 | knows if the tone is 1200 or 2400 Hz. Input to PIA is bit 7. |
| 156 | */ |
| 157 | |
| 158 | return 0; |
| 159 | } |
| 160 | |
| 161 | static WRITE8_DEVICE_HANDLER( d6800_cassette_w ) |
| 162 | { |
| 163 | /* |
| 164 | Cassette circuit consists of a 566 and a transistor. The 556 runs at 2400 |
| 165 | or 1200 Hz depending on the state of the transistor. This is controlled by |
| 166 | bit 0 of the PIA. Bit 6 controls the speaker. |
| 167 | */ |
| 168 | |
| 169 | speaker_level_w(d6800_speaker, (data & 0x40) ? 0 : 1); |
| 170 | } |
| 171 | |
| 172 | static READ8_DEVICE_HANDLER( d6800_keyboard_r ) |
| 173 | { |
| 174 | UINT8 data = 0x0f; |
| 175 | |
| 176 | if (!BIT(d6800_keylatch, 4)) data &= input_port_read(device->machine, "LINE0"); |
| 177 | if (!BIT(d6800_keylatch, 5)) data &= input_port_read(device->machine, "LINE1"); |
| 178 | if (!BIT(d6800_keylatch, 6)) data &= input_port_read(device->machine, "LINE2"); |
| 179 | if (!BIT(d6800_keylatch, 7)) data &= input_port_read(device->machine, "LINE3"); |
| 180 | |
| 181 | d6800_keydown = (data==0x0f) ? 0 : 1; |
| 182 | |
| 183 | return d6800_keylatch | data; |
| 184 | } |
| 185 | |
| 186 | static WRITE8_DEVICE_HANDLER( d6800_keyboard_w ) |
| 187 | { |
| 188 | /* |
| 189 | |
| 190 | bit description |
| 191 | |
| 192 | PA0 keyboard column 0 |
| 193 | PA1 keyboard column 1 |
| 194 | PA2 keyboard column 2 |
| 195 | PA3 keyboard column 3 |
| 196 | PA4 keyboard row 0 |
| 197 | PA5 keyboard row 1 |
| 198 | PA6 keyboard row 2 |
| 199 | PA7 keyboard row 3 |
| 200 | |
| 201 | */ |
| 202 | |
| 203 | |
| 204 | d6800_keylatch = data & 0xf0; |
| 205 | } |
| 206 | |
| 207 | static const pia6821_interface d6800_mc6821_intf = |
| 208 | { |
| 209 | DEVCB_HANDLER(d6800_keyboard_r), /* port A input */ |
| 210 | DEVCB_HANDLER(d6800_cassette_r), /* port B input */ |
| 211 | DEVCB_LINE(d6800_keydown_r), /* CA1 input */ |
| 212 | DEVCB_LINE(d6800_rtc_pulse), /* CB1 input */ |
| 213 | DEVCB_LINE(d6800_fn_key_r), /* CA2 input */ |
| 214 | DEVCB_NULL, /* CB2 input */ |
| 215 | DEVCB_HANDLER(d6800_keyboard_w), /* port A output */ |
| 216 | DEVCB_HANDLER(d6800_cassette_w), /* port B output */ |
| 217 | DEVCB_NULL, /* CA2 output */ |
| 218 | DEVCB_LINE(d6800_screen_w), /* CB2 output */ |
| 219 | DEVCB_CPU_INPUT_LINE("maincpu", M6800_IRQ_LINE), /* IRQA output */ |
| 220 | DEVCB_CPU_INPUT_LINE("maincpu", M6800_IRQ_LINE) /* IRQB output */ |
| 221 | }; |
| 222 | |
| 223 | /* Machine Initialization */ |
| 224 | |
| 225 | static MACHINE_START( d6800 ) |
| 226 | { |
| 227 | d6800_speaker = machine->device("speaker"); |
| 228 | d6800_cassette = machine->device("cassette"); |
| 229 | } |
| 230 | |
| 231 | static MACHINE_RESET( d6800 ) |
| 232 | { |
| 233 | cpu_set_reg(machine->device("maincpu"), M6800_PC, 0xc000); |
| 234 | cpu_set_reg(machine->device("maincpu"), M6800_S, 0xff); |
| 235 | } |
| 236 | |
| 237 | /* Machine Drivers */ |
| 238 | |
| 239 | static const cassette_config d6800_cassette_config = |
| 240 | { |
| 241 | cassette_default_formats, |
| 242 | NULL, |
| 243 | (cassette_state)(CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_MUTED), |
| 244 | NULL |
| 245 | }; |
| 246 | |
| 247 | static MACHINE_CONFIG_START( d6800, d6800_state ) |
| 248 | /* basic machine hardware */ |
| 249 | MDRV_CPU_ADD("maincpu",M6800, XTAL_4MHz/4) |
| 250 | MDRV_CPU_PROGRAM_MAP(d6800_map) |
| 251 | |
| 252 | MDRV_MACHINE_START(d6800) |
| 253 | MDRV_MACHINE_RESET(d6800) |
| 254 | |
| 255 | /* video hardware */ |
| 256 | MDRV_SCREEN_ADD("screen", RASTER) |
| 257 | MDRV_SCREEN_REFRESH_RATE(50) |
| 258 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 259 | MDRV_SCREEN_SIZE(64, 32) |
| 260 | MDRV_SCREEN_VISIBLE_AREA(0, 63, 0, 31) |
| 261 | MDRV_PALETTE_LENGTH(2) |
| 262 | MDRV_PALETTE_INIT(black_and_white) |
| 263 | MDRV_VIDEO_UPDATE(d6800) |
| 264 | |
| 265 | /* sound hardware */ |
| 266 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 267 | MDRV_SOUND_WAVE_ADD("wave", "cassette") |
| 268 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 269 | MDRV_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 270 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 271 | |
| 272 | /* devices */ |
| 273 | MDRV_PIA6821_ADD("pia", d6800_mc6821_intf) |
| 274 | MDRV_CASSETTE_ADD("cassette", d6800_cassette_config) |
| 275 | MACHINE_CONFIG_END |
| 276 | |
| 277 | /* ROMs */ |
| 278 | |
| 279 | ROM_START( d6800 ) |
| 280 | ROM_REGION( 0x10000, "maincpu", 0 ) |
| 281 | ROM_LOAD( "d6800.bin", 0xc000, 0x0400, CRC(3f97ca2e) SHA1(60f26e57a058262b30befceceab4363a5d65d877) ) |
| 282 | ROM_END |
| 283 | |
| 284 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 285 | COMP( 1979, d6800, 0, 0, d6800, d6800, 0, "Electronics Australia", "Dream 6800", GAME_NOT_WORKING | GAME_NO_SOUND ) |