src/mess/drivers/super80.c
| r4341 | r4342 | |
| 19 | 19 | |
| 20 | 20 | static UINT8 current_palette; /* for super80m and super80v */ |
| 21 | 21 | static UINT8 current_charset; /* for super80m */ |
| 22 | static UINT8 irq_counter; |
| 22 | 23 | |
| 23 | 24 | static const device_config *super80_z80pio; |
| 25 | static const device_config *super80_speaker; |
| 26 | static const device_config *super80_cassette; |
| 27 | static const device_config *super80_printer; |
| 24 | 28 | |
| 25 | 29 | /* the rest are for super80v */ |
| 26 | 30 | static UINT8 *pcgram; |
| r4341 | r4342 | |
| 348 | 352 | |
| 349 | 353 | static UINT8 keylatch; |
| 350 | 354 | |
| 355 | /* Due to pio bug since 128u7, need to eat first interrupt after boot. |
| 356 | Only works for super80m and super80v. The irq doesn't work at all for the others at this time. */ |
| 351 | 357 | static void super80_pio_interrupt(const device_config *device, int state) |
| 352 | 358 | { |
| 353 | | //128u7 cputag_set_input_line(device->machine, "main", 0, state ); |
| 359 | if ((state) && (!irq_counter)) |
| 360 | irq_counter++; |
| 361 | else |
| 362 | { |
| 363 | cputag_set_input_line(device->machine, "main", 0, state ); |
| 364 | if (state) irq_counter=0; |
| 365 | } |
| 354 | 366 | } |
| 355 | 367 | |
| 356 | 368 | static WRITE8_DEVICE_HANDLER( pio_port_a_w ) |
| r4341 | r4342 | |
| 393 | 405 | |
| 394 | 406 | /**************************** CASSETTE ROUTINES *****************************************************************/ |
| 395 | 407 | |
| 396 | | static const device_config *cassette_device_image(running_machine *machine) |
| 408 | static void super80_cassette_motor( running_machine *machine, UINT8 data ) |
| 397 | 409 | { |
| 398 | | return devtag_get_device(machine, CASSETTE, "cassette"); |
| 399 | | } |
| 400 | | |
| 401 | | static void cassette_motor( running_machine *machine, UINT8 data ) |
| 402 | | { |
| 403 | 410 | if (data) |
| 404 | | cassette_change_state(cassette_device_image(machine), CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 411 | cassette_change_state(super80_cassette, CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 405 | 412 | else |
| 406 | | cassette_change_state(cassette_device_image(machine), CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 413 | cassette_change_state(super80_cassette, CASSETTE_MOTOR_ENABLED, CASSETTE_MASK_MOTOR); |
| 407 | 414 | |
| 408 | 415 | /* does user want to hear the sound? */ |
| 409 | 416 | if (input_port_read(machine, "CONFIG") & 8) |
| 410 | | cassette_change_state(cassette_device_image(machine), CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER); |
| 417 | cassette_change_state(super80_cassette, CASSETTE_SPEAKER_ENABLED, CASSETTE_MASK_SPEAKER); |
| 411 | 418 | else |
| 412 | | cassette_change_state(cassette_device_image(machine), CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER); |
| 419 | cassette_change_state(super80_cassette, CASSETTE_SPEAKER_MUTED, CASSETTE_MASK_SPEAKER); |
| 413 | 420 | } |
| 414 | 421 | |
| 415 | 422 | /********************************************* TIMER ************************************************/ |
| r4341 | r4342 | |
| 432 | 439 | UINT8 cass_ws=0; |
| 433 | 440 | |
| 434 | 441 | cass_data[1]++; |
| 435 | | cass_ws = (cassette_input(cassette_device_image(machine)) > +0.03) ? 4 : 0; |
| 442 | cass_ws = (cassette_input(super80_cassette) > +0.03) ? 4 : 0; |
| 436 | 443 | |
| 437 | 444 | if (cass_ws != cass_data[0]) |
| 438 | 445 | { |
| r4341 | r4342 | |
| 466 | 473 | |
| 467 | 474 | static READ8_HANDLER( super80_dc_r ) |
| 468 | 475 | { |
| 469 | | const device_config *printer = devtag_get_device(space->machine, CENTRONICS, "centronics"); |
| 470 | 476 | UINT8 data=0x7f; |
| 471 | 477 | |
| 472 | 478 | /* bit 7 = printer busy |
| 473 | 479 | 0 = printer is not busy */ |
| 474 | 480 | |
| 475 | | data |= centronics_busy_r(printer) << 7; |
| 481 | data |= centronics_busy_r(super80_printer) << 7; |
| 476 | 482 | |
| 477 | 483 | return data; |
| 478 | 484 | } |
| r4341 | r4342 | |
| 500 | 506 | static WRITE8_HANDLER( super80_dc_w ) |
| 501 | 507 | { |
| 502 | 508 | /* hardware strobe driven from port select, bit 7..0 = data */ |
| 503 | | const device_config *printer = devtag_get_device(space->machine, CENTRONICS, "centronics"); |
| 504 | | centronics_strobe_w(printer, 1); |
| 505 | | centronics_data_w(printer, 0, data); |
| 506 | | centronics_strobe_w(printer, 0); |
| 509 | centronics_strobe_w(super80_printer, 1); |
| 510 | centronics_data_w(super80_printer, 0, data); |
| 511 | centronics_strobe_w(super80_printer, 0); |
| 507 | 512 | } |
| 508 | 513 | |
| 509 | 514 | static UINT8 last_data; |
| 510 | 515 | |
| 511 | 516 | static WRITE8_HANDLER( super80_f0_w ) |
| 512 | 517 | { |
| 513 | | const device_config *speaker = devtag_get_device(space->machine, SOUND, "speaker"); |
| 514 | 518 | UINT8 bits = data ^ last_data; |
| 515 | 519 | |
| 516 | 520 | if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1); /* bit 5 - LED - scroll lock led is used */ |
| 517 | | speaker_level_w(speaker, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 521 | speaker_level_w(super80_speaker, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 518 | 522 | super80_mhz = (data & 4) ? 1 : 2; /* bit 2 - video on/off */ |
| 519 | | if (bits & 2) cassette_motor( space->machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 520 | | if (bits & 1) cassette_output(cassette_device_image(space->machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 523 | if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 524 | if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 521 | 525 | |
| 522 | 526 | last_data = data; |
| 523 | 527 | } |
| 524 | 528 | |
| 525 | 529 | static WRITE8_HANDLER( super80r_f0_w ) |
| 526 | 530 | { |
| 527 | | const device_config *speaker = devtag_get_device(space->machine, SOUND, "speaker"); |
| 528 | 531 | UINT8 bits = data ^ last_data; |
| 529 | 532 | |
| 530 | 533 | if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1); /* bit 5 - LED - scroll lock led is used */ |
| 531 | | speaker_level_w(speaker, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 532 | | if (bits & 2) cassette_motor( space->machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 533 | | if (bits & 1) cassette_output(cassette_device_image(space->machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 534 | speaker_level_w(super80_speaker, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 535 | if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 536 | if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 534 | 537 | |
| 535 | 538 | last_data = data; |
| 536 | 539 | } |
| 537 | 540 | |
| 538 | 541 | static WRITE8_HANDLER( super80v_f0_w ) |
| 539 | 542 | { |
| 540 | | const device_config *speaker = devtag_get_device(space->machine, SOUND, "speaker"); |
| 541 | 543 | UINT8 bits = data ^ last_data; |
| 542 | 544 | |
| 543 | 545 | if (bits & 0x20) set_led_status(2,(data & 32) ? 0 : 1); /* bit 5 - LED - scroll lock led is used */ |
| 544 | 546 | super80v_rom_pcg = data & 0x10; /* bit 4 - bankswitch gfx rom or pcg */ |
| 545 | | speaker_level_w(speaker, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 547 | speaker_level_w(super80_speaker, (data & 8) ? 0 : 1); /* bit 3 - speaker */ |
| 546 | 548 | super80v_vid_col = data & 4; /* bit 2 - bankswitch video or colour ram */ |
| 547 | | if (bits & 2) cassette_motor( space->machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 548 | | if (bits & 1) cassette_output(cassette_device_image(space->machine), (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 549 | if (bits & 2) super80_cassette_motor(space->machine, data & 2 ? 1 : 0); /* bit 1 - cassette motor */ |
| 550 | if (bits & 1) cassette_output(super80_cassette, (data & 1) ? -1.0 : +1.0); /* bit 0 - cass out */ |
| 549 | 551 | |
| 550 | 552 | last_data = data; |
| 551 | 553 | } |
| r4341 | r4342 | |
| 979 | 981 | |
| 980 | 982 | static MACHINE_RESET( super80 ) |
| 981 | 983 | { |
| 982 | | super80_z80pio = devtag_get_device(machine, Z80PIO, "z80pio"); |
| 983 | 984 | timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, super80_reset); |
| 984 | 985 | memory_set_bank(machine, 1, 1); |
| 986 | super80_z80pio = devtag_get_device(machine, Z80PIO, "z80pio"); |
| 987 | super80_speaker = devtag_get_device(machine, SOUND, "speaker"); |
| 988 | super80_cassette = devtag_get_device(machine, CASSETTE, "cassette"); |
| 989 | super80_printer = devtag_get_device(machine, CENTRONICS, "centronics"); |
| 985 | 990 | } |
| 986 | 991 | |
| 987 | 992 | static const cassette_config super80_cassette_config = |