src/mess/drivers/x1.c
| r5567 | r5568 | |
| 147 | 147 | #include "sound/ay8910.h" |
| 148 | 148 | #include "video/mc6845.h" |
| 149 | 149 | #include "sound/2151intf.h" |
| 150 | #include "sound/wave.h" |
| 150 | 151 | |
| 151 | 152 | #include "machine/wd17xx.h" |
| 152 | 153 | #include "devices/basicdsk.h" |
| 154 | #include "devices/cassette.h" |
| 153 | 155 | #include "includes/d88.h" |
| 154 | 156 | #include <ctype.h> |
| 155 | 157 | |
| r5567 | r5568 | |
| 366 | 368 | } |
| 367 | 369 | |
| 368 | 370 | static UINT8 key_irq_vector; |
| 371 | static UINT8 cmt_current_cmd; |
| 369 | 372 | |
| 373 | static void cmt_command( running_machine* machine, UINT8 cmd ) |
| 374 | { |
| 375 | // CMT deck control command (E9 xx) |
| 376 | // E9 00 - Eject |
| 377 | // E9 01 - Stop |
| 378 | // E9 02 - Play |
| 379 | // E9 03 - Fast Forward |
| 380 | // E9 04 - Rewind |
| 381 | // E9 05 - APSS(?) Fast Forward |
| 382 | // E9 06 - APSS(?) Rewind |
| 383 | // E9 0A - Record |
| 384 | cmt_current_cmd = cmd; |
| 385 | |
| 386 | switch(cmd) |
| 387 | { |
| 388 | case 0x01: // Stop |
| 389 | cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 390 | break; |
| 391 | case 0x02: // Play |
| 392 | cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); |
| 393 | break; |
| 394 | default: |
| 395 | logerror("Unimplemented or invalid CMT command (0x%02x)\n",cmd); |
| 396 | } |
| 397 | logerror("CMT: Command 0xe9-0x%02x received.\n",cmd); |
| 398 | } |
| 399 | |
| 370 | 400 | static WRITE8_HANDLER( sub_io_w ) |
| 371 | 401 | { |
| 372 | 402 | /* TODO: check sub-routine at $10e */ |
| r5567 | r5568 | |
| 379 | 409 | if(sub_cmd == 0xe4) |
| 380 | 410 | key_irq_vector = data; |
| 381 | 411 | |
| 412 | if(sub_cmd == 0xe9) |
| 413 | cmt_command(space->machine,data); |
| 414 | |
| 382 | 415 | switch(data) |
| 383 | 416 | { |
| 384 | 417 | case 0xe3: |
| r5567 | r5568 | |
| 392 | 425 | sub_val = sub_cmd; |
| 393 | 426 | sub_cmd_length = 1; |
| 394 | 427 | break; |
| 395 | | case 0xea: |
| 428 | case 0xea: // CMT Control status |
| 429 | sub_val = cmt_current_cmd; |
| 396 | 430 | sub_cmd_length = 1; |
| 431 | logerror("CMT: Command 0xEA received, returning 0x%02x.\n",sub_val); |
| 397 | 432 | break; |
| 398 | | case 0xeb: |
| 433 | case 0xeb: // CMT Tape status |
| 434 | // bit 0 = tape end |
| 435 | // bit 1 = tape inserted |
| 436 | // bit 2 = ??? |
| 437 | sub_val = 0x02; // assume a tape is inserted for now |
| 399 | 438 | sub_cmd_length = 1; |
| 439 | logerror("CMT: Command 0xEB received, returning 0x%02x.\n",sub_val); |
| 400 | 440 | break; |
| 401 | 441 | case 0xed: |
| 402 | 442 | sub_cmd_length = 3; |
| r5567 | r5568 | |
| 419 | 459 | sub_cmd = data; |
| 420 | 460 | |
| 421 | 461 | sub_obf = (sub_cmd_length) ? 0x00 : 0x20; |
| 462 | logerror("SUB: Command byte 0x%02x\n",data); |
| 422 | 463 | } |
| 423 | 464 | |
| 424 | 465 | /************************************* |
| r5567 | r5568 | |
| 910 | 951 | ---- --x- "cmt read" |
| 911 | 952 | ---- ---x "cmt test" (active low) |
| 912 | 953 | */ |
| 913 | | return (input_port_read(device->machine, "SYSTEM") & ~0x60) | sub_obf; |
| 954 | UINT8 dat = 0; |
| 955 | dat = (input_port_read(device->machine, "SYSTEM") & ~0x68) | sub_obf; |
| 956 | |
| 957 | if((dat & 0x80) == 0) |
| 958 | dat |= 0x04; // VSync (todo: proper implementation of vsync) |
| 959 | |
| 960 | if(cassette_input(devtag_get_device(device->machine,"cass")) > 0.03) |
| 961 | dat |= 0x02; |
| 962 | |
| 963 | if(cassette_get_state(devtag_get_device(device->machine,"cass")) & CASSETTE_MOTOR_DISABLED) |
| 964 | dat |= 0x02; |
| 965 | |
| 966 | return dat; |
| 914 | 967 | } |
| 915 | 968 | |
| 916 | 969 | /* I/O system port */ |
| r5567 | r5568 | |
| 944 | 997 | |
| 945 | 998 | io_switch = data & 0x20; |
| 946 | 999 | io_sys = data & 0xff; |
| 1000 | |
| 1001 | cassette_output(devtag_get_device(device->machine,"cass"),(data & 0x01) ? +1.0 : -1.0); |
| 947 | 1002 | } |
| 948 | 1003 | |
| 949 | 1004 | static const ppi8255_interface ppi8255_intf = |
| r5567 | r5568 | |
| 1434 | 1489 | |
| 1435 | 1490 | cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), x1_irq_callback); |
| 1436 | 1491 | timer_pulse(machine, ATTOTIME_IN_HZ(240), NULL, 0, keyboard_callback); |
| 1492 | |
| 1493 | cmt_current_cmd = 0; |
| 1494 | cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 1437 | 1495 | } |
| 1438 | 1496 | |
| 1439 | 1497 | static PALETTE_INIT(x1) |
| r5567 | r5568 | |
| 1506 | 1564 | MDRV_SOUND_ADD("ay", AY8910, XTAL_4MHz/4) //unknown clock / divider |
| 1507 | 1565 | MDRV_SOUND_CONFIG(ay8910_config) |
| 1508 | 1566 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 1567 | MDRV_SOUND_WAVE_ADD("wave","cass") |
| 1568 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20) |
| 1569 | |
| 1570 | MDRV_CASSETTE_ADD("cass",default_cassette_config) |
| 1509 | 1571 | MACHINE_DRIVER_END |
| 1510 | 1572 | |
| 1511 | 1573 | static MACHINE_DRIVER_START( x1turbo ) |