src/mess/drivers/tandy2k.c
| r7428 | r7429 | |
| 6 | 6 | |
| 7 | 7 | ****************************************************************************/
|
| 8 | 8 | |
| 9 | /*
|
| 10 |
|
| 11 | TODO:
|
| 12 | |
| 13 | - 80186
|
| 14 | - keyboard ROM
|
| 15 | - CRT9007
|
| 16 | - video
|
| 17 | - hires graphics board
|
| 18 | - floppy
|
| 19 | - DMA
|
| 20 | - WD1010
|
| 21 | - hard disk
|
| 22 | - save state
|
| 23 | |
| 24 | */
|
| 25 | |
| 9 | 26 | #include "emu.h"
|
| 27 | #include "includes/tandy2k.h"
|
| 10 | 28 | #include "cpu/i86/i86.h"
|
| 29 | #include "cpu/mcs48/mcs48.h"
|
| 30 | #include "devices/flopdrv.h"
|
| 31 | #include "devices/messram.h"
|
| 32 | #include "machine/ctronics.h"
|
| 33 | #include "machine/i8255a.h"
|
| 34 | #include "machine/msm8251.h"
|
| 35 | #include "machine/pit8253.h"
|
| 36 | #include "machine/pic8259.h"
|
| 37 | #include "machine/upd765.h"
|
| 38 | #include "sound/speaker.h"
|
| 11 | 39 | |
| 12 | | static ADDRESS_MAP_START(tandy2k_mem, ADDRESS_SPACE_PROGRAM, 16)
|
| 13 | | // AM_RANGE(0x00000, 0x00001) speaker/clock control
|
| 14 | | // AM_RANGE(0x00002, 0x00003) dma mux control
|
| 15 | | // AM_RANGE(0x00004, 0x00005) fdc terminal count
|
| 16 | | // AM_RANGE(0x00010, 0x0001f) 8251
|
| 17 | | // AM_RANGE(0x00030, 0x0003f) 8727
|
| 18 | | // AM_RANGE(0x00040, 0x0004f) 8253
|
| 19 | | // AM_RANGE(0x00050, 0x0005f) 8255
|
| 20 | | // AM_RANGE(0x00060, 0x0006f) 8259 0
|
| 21 | | // AM_RANGE(0x00070, 0x0007f) 8259 1
|
| 22 | | // AM_RANGE(0x00080, 0x0009f) fdc dma ack
|
| 23 | | // AM_RANGE(0x000e0, 0x000ff) hdc dma ack
|
| 24 | | AM_RANGE(0x00000, 0x7ffff) AM_RAM
|
| 25 | | AM_RANGE(0xf0000, 0xfffff) AM_ROM
|
| 40 | /* Read/Write Handlers */
|
| 41 | |
| 42 | static void speaker_update(tandy2k_state *state)
|
| 43 | {
|
| 44 | int level = !(state->spkrdata & state->outspkr);
|
| 45 | |
| 46 | speaker_level_w(state->speaker, level);
|
| 47 | }
|
| 48 | |
| 49 | static WRITE8_HANDLER( enable_w )
|
| 50 | {
|
| 51 | /*
|
| 52 | |
| 53 | bit signal description
|
| 54 | |
| 55 | 0 KBEN keyboard enable
|
| 56 | 1 EXTCLK external baud rate clock
|
| 57 | 2 SPKRGATE enable periodic speaker output
|
| 58 | 3 SPKRDATA direct output to speaker
|
| 59 | 4 RFRQGATE enable refresh and baud rate clocks
|
| 60 | 5 _FDCRESET reset 8272
|
| 61 | 6 TMRIN0 enable 80186 timer 0
|
| 62 | 7 TMRIN1 enable 80186 timer 1
|
| 63 | |
| 64 | */
|
| 65 | |
| 66 | tandy2k_state *state = (tandy2k_state *)space->machine->driver_data;
|
| 67 | |
| 68 | /* keyboard enable */
|
| 69 | state->kben = BIT(data, 0);
|
| 70 | |
| 71 | /* external baud rate clock */
|
| 72 | state->extclk = BIT(data, 1);
|
| 73 | |
| 74 | /* speaker gate */
|
| 75 | pit8253_gate_w(state->pit, 0, BIT(data, 2));
|
| 76 | |
| 77 | /* speaker data */
|
| 78 | state->spkrdata = BIT(data, 3);
|
| 79 | speaker_update(state);
|
| 80 | |
| 81 | /* refresh and baud rate clocks */
|
| 82 | pit8253_gate_w(state->pit, 1, BIT(data, 4));
|
| 83 | pit8253_gate_w(state->pit, 2, BIT(data, 4));
|
| 84 | |
| 85 | /* FDC reset */
|
| 86 | upd765_reset_w(state->fdc, BIT(data, 5));
|
| 87 | |
| 88 | /* TODO timer 0 enable */
|
| 89 | |
| 90 | /* TODO timer 1 enable */
|
| 91 | }
|
| 92 | |
| 93 | static WRITE8_HANDLER( dma_mux_w )
|
| 94 | {
|
| 95 | /*
|
| 96 | |
| 97 | bit description
|
| 98 | |
| 99 | 0 DMA channel 0 enable
|
| 100 | 1 DMA channel 1 enable
|
| 101 | 2 DMA channel 2 enable
|
| 102 | 3 DMA channel 3 enable
|
| 103 | 4 DMA channel 0 select
|
| 104 | 5 DMA channel 1 select
|
| 105 | 6 DMA channel 2 select
|
| 106 | 7 DMA channel 3 select
|
| 107 | |
| 108 | */
|
| 109 | }
|
| 110 | |
| 111 | static READ8_DEVICE_HANDLER( fldtc_r )
|
| 112 | {
|
| 113 | upd765_tc_w(device, 1);
|
| 114 | upd765_tc_w(device, 0);
|
| 115 | |
| 116 | return 0;
|
| 117 | }
|
| 118 | |
| 119 | static WRITE8_DEVICE_HANDLER( fldtc_w )
|
| 120 | {
|
| 121 | upd765_tc_w(device, 1);
|
| 122 | upd765_tc_w(device, 0);
|
| 123 | }
|
| 124 | |
| 125 | static READ8_HANDLER( keyboard_x0_r )
|
| 126 | {
|
| 127 | /*
|
| 128 | |
| 129 | bit description
|
| 130 | |
| 131 | 0 X0
|
| 132 | 1 X1
|
| 133 | 2 X2
|
| 134 | 3 X3
|
| 135 | 4 X4
|
| 136 | 5 X5
|
| 137 | 6 X6
|
| 138 | 7 X7
|
| 139 | |
| 140 | */
|
| 141 | |
| 142 | tandy2k_state *state = (tandy2k_state *)space->machine->driver_data;
|
| 143 | |
| 144 | UINT8 data = 0xff;
|
| 145 | |
| 146 | if (!BIT(state->keylatch, 0)) data &= input_port_read(space->machine, "Y0");
|
| 147 | if (!BIT(state->keylatch, 1)) data &= input_port_read(space->machine, "Y1");
|
| 148 | if (!BIT(state->keylatch, 2)) data &= input_port_read(space->machine, "Y2");
|
| 149 | if (!BIT(state->keylatch, 3)) data &= input_port_read(space->machine, "Y3");
|
| 150 | if (!BIT(state->keylatch, 4)) data &= input_port_read(space->machine, "Y4");
|
| 151 | if (!BIT(state->keylatch, 5)) data &= input_port_read(space->machine, "Y5");
|
| 152 | if (!BIT(state->keylatch, 6)) data &= input_port_read(space->machine, "Y6");
|
| 153 | if (!BIT(state->keylatch, 7)) data &= input_port_read(space->machine, "Y7");
|
| 154 | if (!BIT(state->keylatch, 8)) data &= input_port_read(space->machine, "Y8");
|
| 155 | if (!BIT(state->keylatch, 9)) data &= input_port_read(space->machine, "Y9");
|
| 156 | if (!BIT(state->keylatch, 10)) data &= input_port_read(space->machine, "Y10");
|
| 157 | if (!BIT(state->keylatch, 11)) data &= input_port_read(space->machine, "Y11");
|
| 158 | |
| 159 | return ~data;
|
| 160 | }
|
| 161 | |
| 162 | static WRITE8_HANDLER( keyboard_y0_w )
|
| 163 | {
|
| 164 | /*
|
| 165 | |
| 166 | bit description
|
| 167 | |
| 168 | 0 Y0
|
| 169 | 1 Y1
|
| 170 | 2 Y2
|
| 171 | 3 Y3
|
| 172 | 4 Y4
|
| 173 | 5 Y5
|
| 174 | 6 Y6
|
| 175 | 7 Y7
|
| 176 | |
| 177 | */
|
| 178 | |
| 179 | tandy2k_state *state = (tandy2k_state *)space->machine->driver_data;
|
| 180 | |
| 181 | /* keyboard row select */
|
| 182 | state->keylatch = (state->keylatch & 0xff00) | data;
|
| 183 | }
|
| 184 | |
| 185 | static WRITE8_HANDLER( keyboard_y8_w )
|
| 186 | {
|
| 187 | /*
|
| 188 | |
| 189 | bit description
|
| 190 | |
| 191 | 0 Y8
|
| 192 | 1 Y9
|
| 193 | 2 Y10
|
| 194 | 3 Y11
|
| 195 | 4 LED 2
|
| 196 | 5 LED 1
|
| 197 | 6 |
| 198 | 7 |
| 199 | |
| 200 | */
|
| 201 | |
| 202 | tandy2k_state *state = (tandy2k_state *)space->machine->driver_data;
|
| 203 | |
| 204 | /* keyboard row select */
|
| 205 | state->keylatch = ((data & 0x0f) << 8) | (state->keylatch & 0xff);
|
| 206 | }
|
| 207 | |
| 208 | /* Memory Maps */
|
| 209 | |
| 210 | static ADDRESS_MAP_START( tandy2k_mem, ADDRESS_SPACE_PROGRAM, 16 )
|
| 211 | AM_RANGE(0x00000, 0x1ffff) AM_RAM
|
| 212 | AM_RANGE(0xf8000, 0xfbfff) AM_RAM // char ram
|
| 213 | AM_RANGE(0xfc000, 0xfdfff) AM_MIRROR(0x2000) AM_ROM
|
| 26 | 214 | ADDRESS_MAP_END
|
| 27 | 215 | |
| 28 | | static ADDRESS_MAP_START( tandy2k_io , ADDRESS_SPACE_IO, 16)
|
| 216 | static ADDRESS_MAP_START( tandy2k_io, ADDRESS_SPACE_IO, 16 )
|
| 217 | AM_RANGE(0x00000, 0x00001) AM_WRITE8(enable_w, 0xff00)
|
| 218 | AM_RANGE(0x00002, 0x00003) AM_WRITE8(dma_mux_w, 0xff00)
|
| 219 | AM_RANGE(0x00004, 0x00005) AM_DEVREADWRITE8(I8272A_TAG, fldtc_r, fldtc_w, 0xff00)
|
| 220 | AM_RANGE(0x00010, 0x0001f) AM_DEVREADWRITE8(I8251A_TAG, msm8251_data_r, msm8251_data_w, 0xff00)
|
| 221 | AM_RANGE(0x00030, 0x00031) AM_DEVREAD8(I8272A_TAG, upd765_status_r, 0xff00)
|
| 222 | AM_RANGE(0x00032, 0x00033) AM_DEVREADWRITE8(I8272A_TAG, upd765_data_r, upd765_data_w, 0xff00)
|
| 223 | AM_RANGE(0x00040, 0x0004f) AM_DEVREADWRITE8(I8253_TAG, pit8253_r, pit8253_w, 0xff00)
|
| 224 | AM_RANGE(0x00050, 0x00057) AM_DEVREADWRITE8(I8255A_TAG, i8255a_r, i8255a_w, 0xff00)
|
| 225 | AM_RANGE(0x00060, 0x0006f) AM_DEVREADWRITE8(I8259A_0_TAG, pic8259_r, pic8259_w, 0xff00)
|
| 226 | AM_RANGE(0x00070, 0x0007f) AM_DEVREADWRITE8(I8259A_1_TAG, pic8259_r, pic8259_w, 0xff00)
|
| 227 | AM_RANGE(0x00080, 0x0009f) AM_DEVREADWRITE8(I8272A_TAG, upd765_dack_r, upd765_dack_w, 0xff00)
|
| 29 | 228 | ADDRESS_MAP_END
|
| 30 | 229 | |
| 31 | | /* Input ports */
|
| 230 | static ADDRESS_MAP_START( tandy2k_hd_io, ADDRESS_SPACE_IO, 16 )
|
| 231 | AM_IMPORT_FROM(tandy2k_io)
|
| 232 | // AM_RANGE(0x000e0, 0x000ff) AM_WRITE8(hdc_dack_w, 0xff00)
|
| 233 | // AM_RANGE(0x0026c, 0x0026d) AM_DEVREADWRITE8(WD1010_TAG, hdc_reset_r, hdc_reset_w, 0xff00)
|
| 234 | // AM_RANGE(0x0026e, 0x0027f) AM_DEVREADWRITE8(WD1010_TAG, wd1010_r, wd1010_w, 0xff00)
|
| 235 | ADDRESS_MAP_END
|
| 236 | |
| 237 | static ADDRESS_MAP_START( keyboard_io, ADDRESS_SPACE_IO, 8 )
|
| 238 | AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_y0_w)
|
| 239 | AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_y8_w)
|
| 240 | AM_RANGE(MCS48_PORT_BUS, MCS48_PORT_BUS) AM_READ(keyboard_x0_r)
|
| 241 | ADDRESS_MAP_END
|
| 242 | |
| 243 | /* Input Ports */
|
| 244 | |
| 32 | 245 | static INPUT_PORTS_START( tandy2k )
|
| 246 | PORT_START("ROW0")
|
| 247 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 248 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 249 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 250 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 251 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 252 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 253 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 254 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 255 | |
| 256 | PORT_START("ROW1")
|
| 257 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 258 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 259 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 260 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 261 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 262 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 263 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 264 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 265 | |
| 266 | PORT_START("ROW2")
|
| 267 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 268 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 269 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 270 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 271 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 272 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 273 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 274 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 275 | |
| 276 | PORT_START("ROW3")
|
| 277 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 278 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 279 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 280 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 281 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 282 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 283 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 284 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 285 | |
| 286 | PORT_START("ROW4")
|
| 287 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 288 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 289 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 290 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 291 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 292 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 293 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 294 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 295 | |
| 296 | PORT_START("ROW5")
|
| 297 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 298 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 299 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 300 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 301 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 302 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 303 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 304 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 305 | |
| 306 | PORT_START("ROW6")
|
| 307 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 308 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 309 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 310 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 311 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 312 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 313 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 314 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 315 | |
| 316 | PORT_START("ROW7")
|
| 317 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 318 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 319 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 320 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 321 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 322 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 323 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 324 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 325 | |
| 326 | PORT_START("ROW8")
|
| 327 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 328 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 329 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 330 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 331 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 332 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 333 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 334 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 335 | |
| 336 | PORT_START("ROW9")
|
| 337 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 338 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 339 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 340 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 341 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 342 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 343 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 344 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 345 | |
| 346 | PORT_START("ROW10")
|
| 347 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 348 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 349 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 350 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 351 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 352 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 353 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 354 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 355 | |
| 356 | PORT_START("ROW11")
|
| 357 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 358 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 359 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 360 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 361 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 362 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 363 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 364 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD )
|
| 33 | 365 | INPUT_PORTS_END
|
| 34 | 366 | |
| 367 | /* Video */
|
| 35 | 368 | |
| 36 | | static MACHINE_RESET(tandy2k)
|
| 37 | | {
|
| 38 | | }
|
| 39 | | |
| 40 | 369 | static VIDEO_START( tandy2k )
|
| 41 | 370 | {
|
| 42 | 371 | }
|
| r7428 | r7429 | |
| 46 | 375 | return 0;
|
| 47 | 376 | }
|
| 48 | 377 | |
| 378 | /* Intel 8251A Interface */
|
| 379 | |
| 380 | static WRITE_LINE_DEVICE_HANDLER( rxrdy_w )
|
| 381 | {
|
| 382 | tandy2k_state *driver_state = (tandy2k_state *)device->machine->driver_data;
|
| 383 |
|
| 384 | driver_state->rxrdy = state;
|
| 385 | pic8259_set_irq_line(driver_state->pic0, 2, driver_state->rxrdy | driver_state->txrdy);
|
| 386 | }
|
| 387 | |
| 388 | static WRITE_LINE_DEVICE_HANDLER( txrdy_w )
|
| 389 | {
|
| 390 | tandy2k_state *driver_state = (tandy2k_state *)device->machine->driver_data;
|
| 391 | |
| 392 | driver_state->txrdy = state;
|
| 393 | pic8259_set_irq_line(driver_state->pic0, 2, driver_state->rxrdy | driver_state->txrdy);
|
| 394 | }
|
| 395 | |
| 396 | static const msm8251_interface i8251_intf =
|
| 397 | {
|
| 398 | txrdy_w,
|
| 399 | NULL,
|
| 400 | rxrdy_w
|
| 401 | };
|
| 402 | |
| 403 | /* Intel 8253 Interface */
|
| 404 | |
| 405 | static PIT8253_OUTPUT_CHANGED( outspkr_w )
|
| 406 | {
|
| 407 | tandy2k_state *driver_state = (tandy2k_state *)device->machine->driver_data;
|
| 408 | |
| 409 | driver_state->outspkr = state;
|
| 410 | speaker_update(driver_state);
|
| 411 | }
|
| 412 | |
| 413 | static PIT8253_OUTPUT_CHANGED( intbrclk_w )
|
| 414 | {
|
| 415 | tandy2k_state *driver_state = (tandy2k_state *)device->machine->driver_data;
|
| 416 | |
| 417 | if (!driver_state->extclk && state)
|
| 418 | {
|
| 419 | msm8251_transmit_clock(driver_state->uart);
|
| 420 | msm8251_receive_clock(driver_state->uart);
|
| 421 | }
|
| 422 | }
|
| 423 | |
| 424 | static PIT8253_OUTPUT_CHANGED( rfrqpulse_w )
|
| 425 | {
|
| 426 | }
|
| 427 | |
| 428 | static const struct pit8253_config i8253_intf =
|
| 429 | {
|
| 430 | {
|
| 431 | {
|
| 432 | XTAL_16MHz/16,
|
| 433 | outspkr_w
|
| 434 | }, {
|
| 435 | XTAL_16MHz/8,
|
| 436 | intbrclk_w
|
| 437 | }, {
|
| 438 | XTAL_16MHz/8,
|
| 439 | rfrqpulse_w
|
| 440 | }
|
| 441 | }
|
| 442 | };
|
| 443 | |
| 444 | /* Intel 8255A Interface */
|
| 445 | |
| 446 | enum
|
| 447 | {
|
| 448 | LPINEN = 0,
|
| 449 | KBDINEN,
|
| 450 | PORTINEN
|
| 451 | };
|
| 452 | |
| 453 | static READ8_DEVICE_HANDLER( ppi_pb_r )
|
| 454 | {
|
| 455 | /*
|
| 456 | |
| 457 | bit signal description
|
| 458 | |
| 459 | 0 LPRIN0 auxiliary input 0
|
| 460 | 1 LPRIN1 auxiliary input 1
|
| 461 | 2 LPRIN2 auxiliary input 2
|
| 462 | 3 _LPRACK acknowledge
|
| 463 | 4 _LPRFLT fault
|
| 464 | 5 _LPRSEL select
|
| 465 | 6 LPRPAEM paper empty
|
| 466 | 7 LPRBSY busy
|
| 467 | |
| 468 | */
|
| 469 | |
| 470 | tandy2k_state *state = (tandy2k_state *)device->machine->driver_data;
|
| 471 | |
| 472 | UINT8 data = 0;
|
| 473 | |
| 474 | switch (state->pb_sel)
|
| 475 | {
|
| 476 | case LPINEN:
|
| 477 | /* printer acknowledge */
|
| 478 | data |= centronics_ack_r(state->centronics) << 3;
|
| 479 | |
| 480 | /* printer fault */
|
| 481 | data |= centronics_fault_r(state->centronics) << 4;
|
| 482 | |
| 483 | /* printer select */
|
| 484 | data |= centronics_vcc_r(state->centronics) << 5;
|
| 485 | |
| 486 | /* paper empty */
|
| 487 | data |= centronics_pe_r(state->centronics) << 6;
|
| 488 | |
| 489 | /* printer busy */
|
| 490 | data |= centronics_busy_r(state->centronics) << 7;
|
| 491 | break;
|
| 492 | |
| 493 | case KBDINEN:
|
| 494 | /* keyboard data */
|
| 495 | break;
|
| 496 | |
| 497 | case PORTINEN:
|
| 498 | /* PCB revision */
|
| 499 | data = 0x03;
|
| 500 | break;
|
| 501 | }
|
| 502 | |
| 503 | return data;
|
| 504 | }
|
| 505 | |
| 506 | static WRITE8_DEVICE_HANDLER( ppi_pc_w )
|
| 507 | {
|
| 508 | /*
|
| 509 | |
| 510 | bit signal description
|
| 511 | |
| 512 | 0 port A direction
|
| 513 | 1 port B input select bit 0
|
| 514 | 2 port B input select bit 1
|
| 515 | 3 LPRINT13 interrupt
|
| 516 | 4 STROBE IN
|
| 517 | 5 INBUFFULL
|
| 518 | 6 _LPRACK
|
| 519 | 7 _LPRDATSTB
|
| 520 | |
| 521 | */
|
| 522 | |
| 523 | tandy2k_state *state = (tandy2k_state *)device->machine->driver_data;
|
| 524 | |
| 525 | /* input select */
|
| 526 | state->pb_sel = (data >> 1) & 0x03;
|
| 527 | |
| 528 | /* interrupt */
|
| 529 | pic8259_set_irq_line(state->pic1, 3, BIT(data, 3));
|
| 530 | |
| 531 | /* printer strobe */
|
| 532 | centronics_strobe_w(state->centronics, BIT(data, 7));
|
| 533 | }
|
| 534 | |
| 535 | static I8255A_INTERFACE( i8255_intf )
|
| 536 | {
|
| 537 | DEVCB_NULL, // Port A read
|
| 538 | DEVCB_HANDLER(ppi_pb_r), // Port B write
|
| 539 | DEVCB_NULL, // Port C read
|
| 540 | DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w), /* port A write callback */
|
| 541 | DEVCB_NULL, // Port B write
|
| 542 | DEVCB_HANDLER(ppi_pc_w) // Port C write
|
| 543 | };
|
| 544 | |
| 545 | /* Intel 8259 Interfaces */
|
| 546 | |
| 547 | /*
|
| 548 | |
| 549 | IR0 MEMINT00
|
| 550 | IR1 TMOINT01
|
| 551 | IR2 SERINT02
|
| 552 | IR3 BUSINT03
|
| 553 | IR4 FLDINT04
|
| 554 | IR5 BUSINT05
|
| 555 | IR6 HDCINT06
|
| 556 | IR7 BUSINT07
|
| 557 | |
| 558 | */
|
| 559 | |
| 560 | static WRITE_LINE_DEVICE_HANDLER( int0_w )
|
| 561 | {
|
| 562 | cputag_set_input_line(device->machine, I80186_TAG, 0, state);
|
| 563 | }
|
| 564 | |
| 565 | static const struct pic8259_interface i8259_0_intf =
|
| 566 | {
|
| 567 | int0_w
|
| 568 | };
|
| 569 | |
| 570 | /*
|
| 571 | |
| 572 | IR0 KBDINT10
|
| 573 | IR1 VIDINT11
|
| 574 | IR2 RATINT12
|
| 575 | IR3 LPRINT13
|
| 576 | IR4 MCPINT14
|
| 577 | IR5 MEMINT15
|
| 578 | IR6 DMEINT16
|
| 579 | IR7 BUSINT17
|
| 580 | |
| 581 | */
|
| 582 | |
| 583 | static WRITE_LINE_DEVICE_HANDLER( int1_w )
|
| 584 | {
|
| 585 | /* TODO: INT1 is not implemented in the 80186 core */
|
| 586 | cputag_set_input_line(device->machine, I80186_TAG, 1, state);
|
| 587 | }
|
| 588 | |
| 589 | static const struct pic8259_interface i8259_1_intf =
|
| 590 | {
|
| 591 | int1_w
|
| 592 | };
|
| 593 | |
| 594 | /* Floppy Configuration */
|
| 595 | |
| 596 | static const floppy_config tandy2k_floppy_config =
|
| 597 | {
|
| 598 | DEVCB_NULL,
|
| 599 | DEVCB_NULL,
|
| 600 | DEVCB_NULL,
|
| 601 | DEVCB_NULL,
|
| 602 | DEVCB_NULL,
|
| 603 | FLOPPY_DRIVE_DS_80,
|
| 604 | FLOPPY_OPTIONS_NAME(default),
|
| 605 | DO_NOT_KEEP_GEOMETRY
|
| 606 | };
|
| 607 | |
| 608 | /* Intel 8272 Interface */
|
| 609 | |
| 610 | static WRITE_LINE_DEVICE_HANDLER( fldint04_w )
|
| 611 | {
|
| 612 | tandy2k_state *driver_state = (tandy2k_state *)device->machine->driver_data;
|
| 613 | |
| 614 | pic8259_set_irq_line(driver_state->pic0, 4, state);
|
| 615 | }
|
| 616 | |
| 617 | static UPD765_DMA_REQUEST( busdmarq0_w )
|
| 618 | {
|
| 619 | }
|
| 620 | |
| 621 | static const struct upd765_interface i8272_intf =
|
| 622 | {
|
| 623 | DEVCB_LINE(fldint04_w),
|
| 624 | busdmarq0_w,
|
| 625 | NULL,
|
| 626 | UPD765_RDY_PIN_CONNECTED,
|
| 627 | { FLOPPY_0, FLOPPY_1, NULL, NULL }
|
| 628 | };
|
| 629 | |
| 630 | /* Centronics Interface */
|
| 631 | |
| 632 | static const centronics_interface centronics_intf =
|
| 633 | {
|
| 634 | 0, /* is IBM PC? */
|
| 635 | DEVCB_DEVICE_LINE(I8255A_TAG, i8255a_pc6_w), /* ACK output */
|
| 636 | DEVCB_NULL, /* BUSY output */
|
| 637 | DEVCB_NULL /* NOT BUSY output */
|
| 638 | };
|
| 639 | |
| 640 | /* Machine Initialization */
|
| 641 | |
| 642 | static MACHINE_START( tandy2k )
|
| 643 | {
|
| 644 | tandy2k_state *state = (tandy2k_state *)machine->driver_data;
|
| 645 | |
| 646 | /* find devices */
|
| 647 | state->uart = devtag_get_device(machine, I8251A_TAG);
|
| 648 | state->pit = devtag_get_device(machine, I8253_TAG);
|
| 649 | state->pic0 = devtag_get_device(machine, I8259A_0_TAG);
|
| 650 | state->pic1 = devtag_get_device(machine, I8259A_1_TAG);
|
| 651 | state->fdc = devtag_get_device(machine, I8272A_TAG);
|
| 652 | state->speaker = devtag_get_device(machine, SPEAKER_TAG);
|
| 653 | state->centronics = devtag_get_device(machine, CENTRONICS_TAG);
|
| 654 | |
| 655 | /* register for state saving */
|
| 656 | // state_save_register_global(machine, state->);
|
| 657 | }
|
| 658 | |
| 659 | static MACHINE_RESET( tandy2k )
|
| 660 | {
|
| 661 | }
|
| 662 | |
| 663 | /* Machine Driver */
|
| 664 | |
| 49 | 665 | static MACHINE_DRIVER_START( tandy2k )
|
| 666 | MDRV_DRIVER_DATA(tandy2k_state)
|
| 667 | |
| 50 | 668 | /* basic machine hardware */
|
| 51 | | MDRV_CPU_ADD("maincpu", I80186, 8000000)
|
| 669 | MDRV_CPU_ADD(I80186_TAG, I80186, XTAL_16MHz)
|
| 52 | 670 | MDRV_CPU_PROGRAM_MAP(tandy2k_mem)
|
| 53 | 671 | MDRV_CPU_IO_MAP(tandy2k_io)
|
| 54 | 672 | |
| 673 | MDRV_CPU_ADD(I8048_TAG, I8048, 1000000) // ?
|
| 674 | MDRV_CPU_IO_MAP(keyboard_io)
|
| 675 | |
| 676 | MDRV_MACHINE_START(tandy2k)
|
| 55 | 677 | MDRV_MACHINE_RESET(tandy2k)
|
| 56 | 678 | |
| 57 | 679 | /* video hardware */
|
| 58 | | MDRV_SCREEN_ADD("screen", RASTER)
|
| 680 | MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
|
| 59 | 681 | MDRV_SCREEN_REFRESH_RATE(50)
|
| 60 | 682 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
|
| 61 | 683 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
|
| 62 | 684 | MDRV_SCREEN_SIZE(640, 480)
|
| 63 | 685 | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
|
| 64 | | MDRV_PALETTE_LENGTH(2)
|
| 686 | |
| 687 | MDRV_PALETTE_LENGTH(2)
|
| 65 | 688 | MDRV_PALETTE_INIT(black_and_white)
|
| 689 | MDRV_VIDEO_START(tandy2k)
|
| 690 | MDRV_VIDEO_UPDATE(tandy2k)
|
| 66 | 691 | |
| 67 | | MDRV_VIDEO_START(tandy2k)
|
| 68 | | MDRV_VIDEO_UPDATE(tandy2k)
|
| 692 | /* sound hardware */
|
| 693 | MDRV_SPEAKER_STANDARD_MONO("mono")
|
| 694 | MDRV_SOUND_ADD(SPEAKER_TAG, SPEAKER, 0)
|
| 695 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
|
| 696 | |
| 697 | /* devices */
|
| 698 | MDRV_I8255A_ADD(I8255A_TAG, i8255_intf)
|
| 699 | MDRV_MSM8251_ADD(I8251A_TAG, i8251_intf)
|
| 700 | MDRV_PIT8253_ADD(I8253_TAG, i8253_intf)
|
| 701 | MDRV_PIC8259_ADD(I8259A_0_TAG, i8259_0_intf)
|
| 702 | MDRV_PIC8259_ADD(I8259A_1_TAG, i8259_1_intf)
|
| 703 | MDRV_UPD765A_ADD(I8272A_TAG, i8272_intf)
|
| 704 | MDRV_FLOPPY_2_DRIVES_ADD(tandy2k_floppy_config)
|
| 705 | MDRV_CENTRONICS_ADD(CENTRONICS_TAG, standard_centronics)
|
| 706 | |
| 707 | /* internal ram */
|
| 708 | MDRV_RAM_ADD("messram")
|
| 709 | MDRV_RAM_DEFAULT_SIZE("128K,256K")
|
| 69 | 710 | MACHINE_DRIVER_END
|
| 70 | 711 | |
| 71 | | /* ROM definition */
|
| 712 | static MACHINE_DRIVER_START( tandy2k_hd )
|
| 713 | MDRV_IMPORT_FROM(tandy2k)
|
| 714 | |
| 715 | /* basic machine hardware */
|
| 716 | MDRV_CPU_MODIFY(I80186_TAG)
|
| 717 | MDRV_CPU_IO_MAP(tandy2k_hd_io)
|
| 718 | |
| 719 | /* Tandom TM502 hard disk */
|
| 720 | //MDRV_WD1010_ADD(WD1010_TAG, wd1010_intf)
|
| 721 | MACHINE_DRIVER_END
|
| 722 | |
| 723 | /* ROMs */
|
| 724 | |
| 72 | 725 | ROM_START( tandy2k )
|
| 73 | | ROM_REGION( 0x100000, "maincpu", 0 )
|
| 726 | ROM_REGION( 0x100000, I80186_TAG, 0 )
|
| 74 | 727 | ROM_LOAD16_BYTE( "u48_even.bin", 0xfe000, 0x1000, CRC(a5ee3e90) SHA1(4b1f404a4337c67065dd272d62ff88dcdee5e34b))
|
| 75 | 728 | ROM_LOAD16_BYTE( "u47_odd.bin", 0xfe001, 0x1000, CRC(345701c5) SHA1(a775cbfa110b7a88f32834aaa2a9b868cbeed25b))
|
| 729 | |
| 730 | ROM_REGION( 0x400, I8048_TAG, 0 )
|
| 731 | ROM_LOAD( "keyboard.m1", 0x0000, 0x0400, NO_DUMP )
|
| 76 | 732 | ROM_END
|
| 77 | 733 | |
| 78 | | /* Driver */
|
| 734 | #define rom_tandy2khd rom_tandy2k
|
| 79 | 735 | |
| 80 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */
|
| 81 | | COMP( 1983, tandy2k, 0, 0, tandy2k, tandy2k, 0, "Tandy Radio Shack", "Tandy 2000", GAME_NOT_WORKING | GAME_NO_SOUND)
|
| 736 | /* System Drivers */
|
| 737 | |
| 738 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */
|
| 739 | COMP( 1983, tandy2k, 0, 0, tandy2k, tandy2k, 0, "Tandy Radio Shack", "Tandy 2000 (26-5103)", GAME_NOT_WORKING)
|
| 740 | COMP( 1983, tandy2khd, tandy2k, 0, tandy2k_hd, tandy2k, 0, "Tandy Radio Shack", "Tandy 2000 (26-5104)", GAME_NOT_WORKING)
|