src/mess/machine/mbee.c
| r9674 | r9675 | |
| 13 | 13 | #include "devices/flopdrv.h" |
| 14 | 14 | #include "includes/mbee.h" |
| 15 | 15 | |
| 16 | | static size_t mbee_size; |
| 17 | | static UINT8 mbee_clock_pulse; |
| 18 | | static UINT8 mbee256_key_available; |
| 19 | | static UINT8 fdc_intrq,fdc_drq; |
| 20 | | static UINT8 mbee_0a; |
| 21 | | static running_device *mbee_fdc; |
| 22 | | static mc146818_device *mbee_rtc; |
| 23 | | static running_device *mbee_z80pio; |
| 24 | | static running_device *mbee_speaker; |
| 25 | | static running_device *mbee_cassette; |
| 26 | | static running_device *mbee_printer; |
| 27 | 16 | |
| 28 | 17 | /*********************************************************** |
| 29 | 18 | |
| r9674 | r9675 | |
| 33 | 22 | |
| 34 | 23 | static WRITE8_DEVICE_HANDLER( pio_ardy ) |
| 35 | 24 | { |
| 25 | mbee_state *state = device->machine->driver_data<mbee_state>(); |
| 36 | 26 | /* devices need to be redeclared in this callback for some strange reason */ |
| 37 | | mbee_printer = device->machine->device("centronics"); |
| 38 | | centronics_strobe_w(mbee_printer, (data) ? 0 : 1); |
| 27 | state->printer = device->machine->device("centronics"); |
| 28 | centronics_strobe_w(state->printer, (data) ? 0 : 1); |
| 39 | 29 | } |
| 40 | 30 | |
| 41 | 31 | static WRITE8_DEVICE_HANDLER( pio_port_a_w ) |
| 42 | 32 | { |
| 33 | mbee_state *state = device->machine->driver_data<mbee_state>(); |
| 43 | 34 | /* hardware strobe driven by PIO ARDY, bit 7..0 = data */ |
| 44 | | z80pio_astb_w( mbee_z80pio, 1); /* needed - otherwise nothing prints */ |
| 45 | | centronics_data_w(mbee_printer, 0, data); |
| 35 | z80pio_astb_w( state->z80pio, 1); /* needed - otherwise nothing prints */ |
| 36 | centronics_data_w(state->printer, 0, data); |
| 46 | 37 | }; |
| 47 | 38 | |
| 48 | 39 | static WRITE8_DEVICE_HANDLER( pio_port_b_w ) |
| 49 | 40 | { |
| 41 | mbee_state *state = device->machine->driver_data<mbee_state>(); |
| 50 | 42 | /* PIO port B - d5..d2 not emulated |
| 51 | 43 | d7 network interrupt (microbee network for classrooms) |
| 52 | 44 | d6 speaker |
| r9674 | r9675 | |
| 57 | 49 | d1 cass out and (on 256tc) keyboard irq |
| 58 | 50 | d0 cass in */ |
| 59 | 51 | |
| 60 | | cassette_output(mbee_cassette, (data & 0x02) ? -1.0 : +1.0); |
| 52 | cassette_output(state->cassette, (data & 0x02) ? -1.0 : +1.0); |
| 61 | 53 | |
| 62 | | speaker_level_w(mbee_speaker, (data & 0x40) ? 1 : 0); |
| 54 | speaker_level_w(state->speaker, (data & 0x40) ? 1 : 0); |
| 63 | 55 | }; |
| 64 | 56 | |
| 65 | 57 | static READ8_DEVICE_HANDLER( pio_port_b_r ) |
| 66 | 58 | { |
| 59 | mbee_state *state = device->machine->driver_data<mbee_state>(); |
| 67 | 60 | UINT8 data = 0; |
| 68 | 61 | |
| 69 | | if (cassette_input(mbee_cassette) > 0.03) data |= 1; |
| 62 | if (cassette_input(state->cassette) > 0.03) data |= 1; |
| 70 | 63 | |
| 71 | | data |= mbee_clock_pulse; |
| 72 | | data |= mbee256_key_available; |
| 64 | data |= state->clock_pulse; |
| 65 | data |= state->mbee256_key_available; |
| 73 | 66 | |
| 74 | | mbee_clock_pulse = 0; |
| 67 | state->clock_pulse = 0; |
| 75 | 68 | |
| 76 | 69 | return data; |
| 77 | 70 | }; |
| r9674 | r9675 | |
| 98 | 91 | |
| 99 | 92 | static WRITE_LINE_DEVICE_HANDLER( mbee_fdc_intrq_w ) |
| 100 | 93 | { |
| 101 | | fdc_intrq = state ? 0x80 : 0; |
| 94 | mbee_state *drvstate = device->machine->driver_data<mbee_state>(); |
| 95 | drvstate->fdc_intrq = state ? 0x80 : 0; |
| 102 | 96 | } |
| 103 | 97 | |
| 104 | 98 | static WRITE_LINE_DEVICE_HANDLER( mbee_fdc_drq_w ) |
| 105 | 99 | { |
| 106 | | fdc_drq = state ? 0x80 : 0; |
| 100 | mbee_state *drvstate = device->machine->driver_data<mbee_state>(); |
| 101 | drvstate->fdc_drq = state ? 0x80 : 0; |
| 107 | 102 | } |
| 108 | 103 | |
| 109 | 104 | const wd17xx_interface mbee_wd17xx_interface = |
| r9674 | r9675 | |
| 116 | 111 | |
| 117 | 112 | READ8_HANDLER ( mbee_fdc_status_r ) |
| 118 | 113 | { |
| 114 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 119 | 115 | /* d7 indicate if IRQ or DRQ is occuring (1=happening) |
| 120 | 116 | d6..d0 not used */ |
| 121 | 117 | |
| 122 | | return 0x7f | fdc_intrq | fdc_drq; |
| 118 | return 0x7f | state->fdc_intrq | state->fdc_drq; |
| 123 | 119 | } |
| 124 | 120 | |
| 125 | 121 | WRITE8_HANDLER ( mbee_fdc_motor_w ) |
| 126 | 122 | { |
| 123 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 127 | 124 | /* d7..d4 not used |
| 128 | 125 | d3 density (1=MFM) |
| 129 | 126 | d2 side (1=side 1) |
| 130 | 127 | d1..d0 drive select (0 to 3) */ |
| 131 | 128 | |
| 132 | | wd17xx_set_drive(mbee_fdc, data & 3); |
| 133 | | wd17xx_set_side(mbee_fdc, (data & 4) ? 1 : 0); |
| 134 | | wd17xx_dden_w(mbee_fdc, !BIT(data, 3)); |
| 129 | wd17xx_set_drive(state->fdc, data & 3); |
| 130 | wd17xx_set_side(state->fdc, (data & 4) ? 1 : 0); |
| 131 | wd17xx_dden_w(state->fdc, !BIT(data, 3)); |
| 135 | 132 | /* no idea what turns the motors on & off, guessing it could be drive select |
| 136 | 133 | commented out because it prevents 128k and 256TC from booting up */ |
| 137 | 134 | //floppy_mon_w(floppy_get_device(space->machine, data & 3), CLEAR_LINE); // motor on |
| r9674 | r9675 | |
| 143 | 140 | |
| 144 | 141 | ************************************************************/ |
| 145 | 142 | |
| 146 | | static UINT8 mbee256_was_pressed[15] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; |
| 147 | | static UINT8 mbee256_q[20]; |
| 148 | | static UINT8 mbee256_q_pos; |
| 149 | 143 | |
| 150 | 144 | static TIMER_CALLBACK( mbee256_kbd ) |
| 151 | 145 | { |
| 146 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 152 | 147 | /* Keyboard scanner is a Mostek M3870 chip. Its speed of operation is determined by a 15k resistor on |
| 153 | 148 | pin 2 (XTL2) and is therefore unknown. If a key change is detected (up or down), the /strobe |
| 154 | 149 | line activates, sending a high to bit 1 of port 2 (one of the pio input lines). The next read of |
| r9674 | r9675 | |
| 175 | 170 | /* find what has changed */ |
| 176 | 171 | for (i = 0; i < 15; i++) |
| 177 | 172 | { |
| 178 | | if (pressed[i] != mbee256_was_pressed[i]) |
| 173 | if (pressed[i] != state->mbee256_was_pressed[i]) |
| 179 | 174 | { |
| 180 | 175 | /* get scankey value */ |
| 181 | 176 | for (j = 0; j < 8; j++) |
| 182 | 177 | { |
| 183 | | if (BIT(pressed[i]^mbee256_was_pressed[i], j)) |
| 178 | if (BIT(pressed[i]^state->mbee256_was_pressed[i], j)) |
| 184 | 179 | { |
| 185 | 180 | /* put it in the queue */ |
| 186 | | mbee256_q[mbee256_q_pos] = (i << 3) | j | (BIT(pressed[i], j) ? 0x80 : 0); |
| 187 | | if (mbee256_q_pos < 19) mbee256_q_pos++; |
| 181 | state->mbee256_q[state->mbee256_q_pos] = (i << 3) | j | (BIT(pressed[i], j) ? 0x80 : 0); |
| 182 | if (state->mbee256_q_pos < 19) state->mbee256_q_pos++; |
| 188 | 183 | } |
| 189 | 184 | } |
| 190 | | mbee256_was_pressed[i] = pressed[i]; |
| 185 | state->mbee256_was_pressed[i] = pressed[i]; |
| 191 | 186 | } |
| 192 | 187 | } |
| 193 | 188 | |
| 194 | 189 | /* if anything queued, cause an interrupt */ |
| 195 | | if (mbee256_q_pos) |
| 196 | | mbee256_key_available = 2; // set irq |
| 190 | if (state->mbee256_q_pos) |
| 191 | state->mbee256_key_available = 2; // set irq |
| 197 | 192 | } |
| 198 | 193 | |
| 199 | 194 | READ8_HANDLER( mbee256_18_r ) |
| 200 | 195 | { |
| 201 | | UINT8 i, data = mbee256_q[0]; // get oldest key |
| 196 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 197 | UINT8 i, data = state->mbee256_q[0]; // get oldest key |
| 202 | 198 | |
| 203 | | if (mbee256_q_pos) |
| 199 | if (state->mbee256_q_pos) |
| 204 | 200 | { |
| 205 | | mbee256_q_pos--; |
| 206 | | for (i = 0; i < mbee256_q_pos; i++) mbee256_q[i] = mbee256_q[i+1]; // ripple queue |
| 201 | state->mbee256_q_pos--; |
| 202 | for (i = 0; i < state->mbee256_q_pos; i++) state->mbee256_q[i] = state->mbee256_q[i+1]; // ripple queue |
| 207 | 203 | } |
| 208 | 204 | |
| 209 | | mbee256_key_available = 0; // clear irq |
| 205 | state->mbee256_key_available = 0; // clear irq |
| 210 | 206 | return data; |
| 211 | 207 | } |
| 212 | 208 | |
| r9674 | r9675 | |
| 239 | 235 | |
| 240 | 236 | WRITE8_HANDLER( mbee_04_w ) // address |
| 241 | 237 | { |
| 242 | | mbee_rtc->write(*space, 0, data); |
| 238 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 239 | state->rtc->write(*space, 0, data); |
| 243 | 240 | } |
| 244 | 241 | |
| 245 | 242 | WRITE8_HANDLER( mbee_06_w ) // write |
| 246 | 243 | { |
| 247 | | mbee_rtc->write(*space, 1, data); |
| 244 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 245 | state->rtc->write(*space, 1, data); |
| 248 | 246 | } |
| 249 | 247 | |
| 250 | 248 | READ8_HANDLER( mbee_07_r ) // read |
| 251 | 249 | { |
| 252 | | return mbee_rtc->read(*space, 1); |
| 250 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 251 | return state->rtc->read(*space, 1); |
| 253 | 252 | } |
| 254 | 253 | |
| 255 | 254 | static TIMER_CALLBACK( mbee_rtc_irq ) |
| 256 | 255 | { |
| 256 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 257 | 257 | address_space *mem = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 258 | 258 | mc146818_device *rtc = machine->device<mc146818_device>("rtc"); |
| 259 | 259 | UINT8 data = rtc->read(*mem, 12); |
| 260 | | if (data) mbee_clock_pulse = 0x80; |
| 260 | if (data) state->clock_pulse = 0x80; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | |
| r9674 | r9675 | |
| 472 | 472 | |
| 473 | 473 | READ8_HANDLER ( mbeeic_0a_r ) |
| 474 | 474 | { |
| 475 | | return mbee_0a; |
| 475 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 476 | return state->_0a; |
| 476 | 477 | } |
| 477 | 478 | |
| 478 | 479 | WRITE8_HANDLER ( mbeeic_0a_w ) |
| 479 | 480 | { |
| 480 | | mbee_0a = data; |
| 481 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 482 | state->_0a = data; |
| 481 | 483 | memory_set_bank(space->machine, "pak", data & 15); |
| 482 | 484 | } |
| 483 | 485 | |
| 484 | 486 | READ8_HANDLER ( mbeepc_telcom_low_r ) |
| 485 | 487 | { |
| 488 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 486 | 489 | /* Read of port 0A - set Telcom rom to first half */ |
| 487 | 490 | memory_set_bank(space->machine, "telcom", 0); |
| 488 | | return mbee_0a; |
| 491 | return state->_0a; |
| 489 | 492 | } |
| 490 | 493 | |
| 491 | 494 | READ8_HANDLER ( mbeepc_telcom_high_r ) |
| 492 | 495 | { |
| 496 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 493 | 497 | /* Read of port 10A - set Telcom rom to 2nd half */ |
| 494 | 498 | memory_set_bank(space->machine, "telcom", 1); |
| 495 | | return mbee_0a; |
| 499 | return state->_0a; |
| 496 | 500 | } |
| 497 | 501 | |
| 498 | 502 | |
| r9674 | r9675 | |
| 516 | 520 | |
| 517 | 521 | static void machine_reset_common(running_machine *machine) |
| 518 | 522 | { |
| 519 | | mbee_z80pio = machine->device("z80pio"); |
| 520 | | mbee_speaker = machine->device("speaker"); |
| 521 | | mbee_cassette = machine->device("cassette"); |
| 522 | | mbee_printer = machine->device("centronics"); |
| 523 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 524 | state->z80pio = machine->device("z80pio"); |
| 525 | state->speaker = machine->device("speaker"); |
| 526 | state->cassette = machine->device("cassette"); |
| 527 | state->printer = machine->device("centronics"); |
| 523 | 528 | } |
| 524 | 529 | |
| 525 | 530 | static void machine_reset_common_disk(running_machine *machine) |
| 526 | 531 | { |
| 532 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 527 | 533 | machine_reset_common(machine); |
| 528 | | mbee_fdc = machine->device("fdc"); |
| 534 | state->fdc = machine->device("fdc"); |
| 529 | 535 | /* These values need to be fine tuned or the fdc repaired */ |
| 530 | | wd17xx_set_pause_time(mbee_fdc, 45); /* default is 40 usec if not set */ |
| 531 | | wd17xx_set_complete_command_delay(mbee_fdc, 50); /* default is 12 usec if not set */ |
| 536 | wd17xx_set_pause_time(state->fdc, 45); /* default is 40 usec if not set */ |
| 537 | wd17xx_set_complete_command_delay(state->fdc, 50); /* default is 12 usec if not set */ |
| 532 | 538 | } |
| 533 | 539 | |
| 534 | 540 | MACHINE_RESET( mbee ) |
| r9674 | r9675 | |
| 563 | 569 | |
| 564 | 570 | MACHINE_RESET( mbee256 ) |
| 565 | 571 | { |
| 572 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 566 | 573 | UINT8 i; |
| 567 | 574 | address_space *mem = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 568 | 575 | machine_reset_common_disk(machine); |
| 569 | | mbee_rtc = machine->device<mc146818_device>("rtc"); |
| 570 | | for (i = 0; i < 15; i++) mbee256_was_pressed[i] = 0; |
| 571 | | mbee256_q_pos = 0; |
| 576 | state->rtc = machine->device<mc146818_device>("rtc"); |
| 577 | for (i = 0; i < 15; i++) state->mbee256_was_pressed[i] = 0; |
| 578 | state->mbee256_q_pos = 0; |
| 572 | 579 | mbee256_50_w(mem,0,0); // set banks to default |
| 573 | 580 | memory_set_bank(machine, "boot", 8); // boot time |
| 574 | 581 | timer_set(machine, ATTOTIME_IN_USEC(4), NULL, 0, mbee_reset); |
| r9674 | r9675 | |
| 576 | 583 | |
| 577 | 584 | MACHINE_RESET( mbeett ) |
| 578 | 585 | { |
| 586 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 579 | 587 | UINT8 i; |
| 580 | | mbee_rtc = machine->device<mc146818_device>("rtc"); |
| 581 | | for (i = 0; i < 15; i++) mbee256_was_pressed[i] = 0; |
| 582 | | mbee256_q_pos = 0; |
| 588 | state->rtc = machine->device<mc146818_device>("rtc"); |
| 589 | for (i = 0; i < 15; i++) state->mbee256_was_pressed[i] = 0; |
| 590 | state->mbee256_q_pos = 0; |
| 583 | 591 | machine_reset_common(machine); |
| 584 | 592 | memory_set_bank(machine, "boot", 1); |
| 585 | 593 | timer_set(machine, ATTOTIME_IN_USEC(4), NULL, 0, mbee_reset); |
| r9674 | r9675 | |
| 589 | 597 | { |
| 590 | 598 | // Due to the uncertainly and hackage here, this is commented out for now - Robbbert - 05-Oct-2010 |
| 591 | 599 | #if 0 |
| 600 | mbee_state *state = device->machine->driver_data<mbee_state>(); |
| 592 | 601 | |
| 593 | 602 | //address_space *space = cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 594 | 603 | /* The printer status connects to the pio ASTB pin, and the printer changing to not |
| r9674 | r9675 | |
| 596 | 605 | The line below does what the interrupt should be doing. */ |
| 597 | 606 | /* But it would break any program loaded to that area of memory, such as CP/M programs */ |
| 598 | 607 | |
| 599 | | //z80pio_astb_w( mbee_z80pio, centronics_busy_r(mbee_printer)); /* signal int when not busy (L->H) */ |
| 600 | | //space->write_byte(0x109, centronics_busy_r(mbee_printer)); |
| 608 | //z80pio_astb_w( state->z80pio, centronics_busy_r(state->printer)); /* signal int when not busy (L->H) */ |
| 609 | //space->write_byte(0x109, centronics_busy_r(state->printer)); |
| 601 | 610 | |
| 602 | 611 | |
| 603 | 612 | /* once per frame, pulse the PIO B bit 7 - it is in the schematic as an option, |
| 604 | 613 | but need to find out what it does */ |
| 605 | | mbee_clock_pulse = 0x80; |
| 614 | state->clock_pulse = 0x80; |
| 606 | 615 | irq0_line_hold(device); |
| 607 | 616 | |
| 608 | 617 | #endif |
| r9674 | r9675 | |
| 610 | 619 | |
| 611 | 620 | DRIVER_INIT( mbee ) |
| 612 | 621 | { |
| 622 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 613 | 623 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 614 | 624 | memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0x8000); |
| 615 | | mbee_size = 0x4000; |
| 625 | state->size = 0x4000; |
| 616 | 626 | } |
| 617 | 627 | |
| 618 | 628 | DRIVER_INIT( mbeeic ) |
| 619 | 629 | { |
| 630 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 620 | 631 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 621 | 632 | memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0x8000); |
| 622 | 633 | |
| r9674 | r9675 | |
| 624 | 635 | memory_configure_bank(machine, "pak", 0, 16, &RAM[0x0000], 0x2000); |
| 625 | 636 | |
| 626 | 637 | memory_set_bank(machine, "pak", 0); |
| 627 | | mbee_size = 0x8000; |
| 638 | state->size = 0x8000; |
| 628 | 639 | } |
| 629 | 640 | |
| 630 | 641 | DRIVER_INIT( mbeepc ) |
| 631 | 642 | { |
| 643 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 632 | 644 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 633 | 645 | memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0x8000); |
| 634 | 646 | |
| r9674 | r9675 | |
| 640 | 652 | |
| 641 | 653 | memory_set_bank(machine, "pak", 0); |
| 642 | 654 | memory_set_bank(machine, "telcom", 0); |
| 643 | | mbee_size = 0x8000; |
| 655 | state->size = 0x8000; |
| 644 | 656 | } |
| 645 | 657 | |
| 646 | 658 | DRIVER_INIT( mbeepc85 ) |
| 647 | 659 | { |
| 660 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 648 | 661 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 649 | 662 | memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0x8000); |
| 650 | 663 | |
| r9674 | r9675 | |
| 656 | 669 | |
| 657 | 670 | memory_set_bank(machine, "pak", 5); |
| 658 | 671 | memory_set_bank(machine, "telcom", 0); |
| 659 | | mbee_size = 0x8000; |
| 672 | state->size = 0x8000; |
| 660 | 673 | } |
| 661 | 674 | |
| 662 | 675 | DRIVER_INIT( mbeeppc ) |
| 663 | 676 | { |
| 677 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 664 | 678 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 665 | 679 | memory_configure_bank(machine, "boot", 0, 1, &RAM[0x0000], 0x0000); |
| 666 | 680 | |
| r9674 | r9675 | |
| 677 | 691 | memory_set_bank(machine, "pak", 5); |
| 678 | 692 | memory_set_bank(machine, "telcom", 0); |
| 679 | 693 | memory_set_bank(machine, "basic", 0); |
| 680 | | mbee_size = 0x8000; |
| 694 | state->size = 0x8000; |
| 681 | 695 | } |
| 682 | 696 | |
| 683 | 697 | DRIVER_INIT( mbee56 ) |
| 684 | 698 | { |
| 699 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 685 | 700 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 686 | 701 | memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0xe000); |
| 687 | | mbee_size = 0xe000; |
| 702 | state->size = 0xe000; |
| 688 | 703 | } |
| 689 | 704 | |
| 690 | 705 | DRIVER_INIT( mbee64 ) |
| 691 | 706 | { |
| 707 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 692 | 708 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 693 | 709 | memory_configure_bank(machine, "boot", 0, 1, &RAM[0x0000], 0x0000); |
| 694 | 710 | memory_configure_bank(machine, "bankl", 0, 1, &RAM[0x1000], 0x0000); |
| r9674 | r9675 | |
| 699 | 715 | memory_configure_bank(machine, "bankh", 1, 1, &RAM[0x0000], 0x0000); |
| 700 | 716 | memory_configure_bank(machine, "boot", 1, 1, &RAM[0x0000], 0x0000); |
| 701 | 717 | |
| 702 | | mbee_size = 0xf000; |
| 718 | state->size = 0xf000; |
| 703 | 719 | } |
| 704 | 720 | |
| 705 | 721 | DRIVER_INIT( mbee128 ) |
| 706 | 722 | { |
| 723 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 707 | 724 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 708 | 725 | memory_configure_bank(machine, "boot", 0, 4, &RAM[0x0000], 0x8000); // standard banks 0000 |
| 709 | 726 | memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x1000], 0x8000); // standard banks 1000 |
| r9674 | r9675 | |
| 719 | 736 | memory_configure_bank(machine, "bank8l", 0, 1, &RAM[0x0000], 0x0000); // rom |
| 720 | 737 | memory_configure_bank(machine, "bank8h", 0, 1, &RAM[0x0800], 0x0000); // rom |
| 721 | 738 | |
| 722 | | mbee_size = 0x8000; |
| 739 | state->size = 0x8000; |
| 723 | 740 | } |
| 724 | 741 | |
| 725 | 742 | DRIVER_INIT( mbee256 ) |
| 726 | 743 | { |
| 744 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 727 | 745 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 728 | 746 | memory_configure_bank(machine, "boot", 0, 8, &RAM[0x0000], 0x8000); // standard banks 0000 |
| 729 | 747 | memory_configure_bank(machine, "bank1", 0, 8, &RAM[0x1000], 0x8000); // standard banks 1000 |
| r9674 | r9675 | |
| 742 | 760 | timer_pulse(machine, ATTOTIME_IN_HZ(1),NULL,0,mbee_rtc_irq); /* timer for rtc */ |
| 743 | 761 | timer_pulse(machine, ATTOTIME_IN_HZ(25),NULL,0,mbee256_kbd); /* timer for kbd */ |
| 744 | 762 | |
| 745 | | mbee_size = 0x8000; |
| 763 | state->size = 0x8000; |
| 746 | 764 | } |
| 747 | 765 | |
| 748 | 766 | DRIVER_INIT( mbeett ) |
| 749 | 767 | { |
| 768 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 750 | 769 | UINT8 *RAM = memory_region(machine, "maincpu"); |
| 751 | 770 | memory_configure_bank(machine, "boot", 0, 2, &RAM[0x0000], 0x8000); |
| 752 | 771 | |
| r9674 | r9675 | |
| 762 | 781 | timer_pulse(machine, ATTOTIME_IN_HZ(1),NULL,0,mbee_rtc_irq); /* timer for rtc */ |
| 763 | 782 | timer_pulse(machine, ATTOTIME_IN_HZ(25),NULL,0,mbee256_kbd); /* timer for kbd */ |
| 764 | 783 | |
| 765 | | mbee_size = 0x8000; |
| 784 | state->size = 0x8000; |
| 766 | 785 | } |
| 767 | 786 | |
| 768 | 787 | |
| r9674 | r9675 | |
| 795 | 814 | |
| 796 | 815 | QUICKLOAD_LOAD( mbee ) |
| 797 | 816 | { |
| 817 | mbee_state *state = image.device().machine->driver_data<mbee_state>(); |
| 798 | 818 | running_device *cpu = image.device().machine->device("maincpu"); |
| 799 | 819 | address_space *space = cputag_get_address_space(image.device().machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 800 | 820 | UINT16 i, j; |
| r9674 | r9675 | |
| 813 | 833 | return IMAGE_INIT_FAIL; |
| 814 | 834 | } |
| 815 | 835 | |
| 816 | | if ((j < mbee_size) || (j > 0xefff)) |
| 836 | if ((j < state->size) || (j > 0xefff)) |
| 817 | 837 | space->write_byte(j, data); |
| 818 | 838 | else |
| 819 | 839 | { |
| r9674 | r9675 | |
| 843 | 863 | return IMAGE_INIT_FAIL; |
| 844 | 864 | } |
| 845 | 865 | |
| 846 | | if ((j < mbee_size) || (j > 0xefff)) |
| 866 | if ((j < state->size) || (j > 0xefff)) |
| 847 | 867 | space->write_byte(j, data); |
| 848 | 868 | else |
| 849 | 869 | { |
src/mess/machine/orion.c
| r9674 | r9675 | |
| 23 | 23 | #define SCREEN_WIDTH_480 60 |
| 24 | 24 | #define SCREEN_WIDTH_512 64 |
| 25 | 25 | |
| 26 | | static UINT8 romdisk_lsb,romdisk_msb; |
| 27 | | UINT8 orion128_video_mode; |
| 28 | | UINT8 orion128_video_page; |
| 29 | | static UINT8 orion128_memory_page; |
| 30 | 26 | |
| 31 | | UINT8 orion128_video_width; |
| 32 | 27 | |
| 33 | | static UINT8 orionz80_memory_page; |
| 34 | | static UINT8 orionz80_dispatcher; |
| 35 | 28 | |
| 36 | | UINT8 orion_video_mode_mask; |
| 37 | 29 | |
| 38 | 30 | static READ8_DEVICE_HANDLER (orion_romdisk_porta_r ) |
| 39 | 31 | { |
| 32 | orion_state *state = device->machine->driver_data<orion_state>(); |
| 40 | 33 | UINT8 *romdisk = memory_region(device->machine, "maincpu") + 0x10000; |
| 41 | | return romdisk[romdisk_msb*256+romdisk_lsb]; |
| 34 | return romdisk[state->romdisk_msb*256+state->romdisk_lsb]; |
| 42 | 35 | } |
| 43 | 36 | |
| 44 | 37 | static WRITE8_DEVICE_HANDLER (orion_romdisk_portb_w ) |
| 45 | 38 | { |
| 46 | | romdisk_lsb = data; |
| 39 | orion_state *state = device->machine->driver_data<orion_state>(); |
| 40 | state->romdisk_lsb = data; |
| 47 | 41 | } |
| 48 | 42 | |
| 49 | 43 | static WRITE8_DEVICE_HANDLER (orion_romdisk_portc_w ) |
| 50 | 44 | { |
| 51 | | romdisk_msb = data; |
| 45 | orion_state *state = device->machine->driver_data<orion_state>(); |
| 46 | state->romdisk_msb = data; |
| 52 | 47 | } |
| 53 | 48 | |
| 54 | 49 | I8255A_INTERFACE( orion128_ppi8255_interface_1) |
| r9674 | r9675 | |
| 64 | 59 | |
| 65 | 60 | MACHINE_START( orion128 ) |
| 66 | 61 | { |
| 67 | | orion_video_mode_mask = 7; |
| 62 | orion_state *state = machine->driver_data<orion_state>(); |
| 63 | state->video_mode_mask = 7; |
| 68 | 64 | } |
| 69 | 65 | |
| 70 | 66 | READ8_HANDLER ( orion128_system_r ) |
| r9674 | r9675 | |
| 100 | 96 | |
| 101 | 97 | WRITE8_HANDLER ( orion128_video_mode_w ) |
| 102 | 98 | { |
| 103 | | if ((data & 0x80)!=(orion128_video_mode & 0x80)) |
| 99 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 100 | if ((data & 0x80)!=(state->orion128_video_mode & 0x80)) |
| 104 | 101 | { |
| 105 | 102 | if ((data & 0x80)==0x80) |
| 106 | 103 | { |
| 107 | | if (orion_video_mode_mask == 31) |
| 104 | if (state->video_mode_mask == 31) |
| 108 | 105 | { |
| 109 | | orion128_video_width = SCREEN_WIDTH_512; |
| 106 | state->orion128_video_width = SCREEN_WIDTH_512; |
| 110 | 107 | orion_set_video_mode(space->machine,512); |
| 111 | 108 | } |
| 112 | 109 | else |
| 113 | 110 | { |
| 114 | | orion128_video_width = SCREEN_WIDTH_480; |
| 111 | state->orion128_video_width = SCREEN_WIDTH_480; |
| 115 | 112 | orion_set_video_mode(space->machine,480); |
| 116 | 113 | } |
| 117 | 114 | } |
| 118 | 115 | else |
| 119 | 116 | { |
| 120 | | orion128_video_width = SCREEN_WIDTH_384; |
| 117 | state->orion128_video_width = SCREEN_WIDTH_384; |
| 121 | 118 | orion_set_video_mode(space->machine,384); |
| 122 | 119 | } |
| 123 | 120 | } |
| 124 | 121 | |
| 125 | | orion128_video_mode = data; |
| 122 | state->orion128_video_mode = data; |
| 126 | 123 | } |
| 127 | 124 | |
| 128 | 125 | WRITE8_HANDLER ( orion128_video_page_w ) |
| 129 | 126 | { |
| 130 | | if (orion128_video_page != data) |
| 127 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 128 | if (state->orion128_video_page != data) |
| 131 | 129 | { |
| 132 | | if ((data & 0x80)!=(orion128_video_page & 0x80)) |
| 130 | if ((data & 0x80)!=(state->orion128_video_page & 0x80)) |
| 133 | 131 | { |
| 134 | 132 | if ((data & 0x80)==0x80) |
| 135 | 133 | { |
| 136 | | if (orion_video_mode_mask == 31) |
| 134 | if (state->video_mode_mask == 31) |
| 137 | 135 | { |
| 138 | | orion128_video_width = SCREEN_WIDTH_512; |
| 136 | state->orion128_video_width = SCREEN_WIDTH_512; |
| 139 | 137 | orion_set_video_mode(space->machine,512); |
| 140 | 138 | } |
| 141 | 139 | else |
| 142 | 140 | { |
| 143 | | orion128_video_width = SCREEN_WIDTH_480; |
| 141 | state->orion128_video_width = SCREEN_WIDTH_480; |
| 144 | 142 | orion_set_video_mode(space->machine,480); |
| 145 | 143 | } |
| 146 | 144 | } |
| 147 | 145 | else |
| 148 | 146 | { |
| 149 | | orion128_video_width = SCREEN_WIDTH_384; |
| 147 | state->orion128_video_width = SCREEN_WIDTH_384; |
| 150 | 148 | orion_set_video_mode(space->machine,384); |
| 151 | 149 | } |
| 152 | 150 | } |
| 153 | 151 | } |
| 154 | | orion128_video_page = data; |
| 152 | state->orion128_video_page = data; |
| 155 | 153 | } |
| 156 | 154 | |
| 157 | 155 | |
| 158 | 156 | WRITE8_HANDLER ( orion128_memory_page_w ) |
| 159 | 157 | { |
| 160 | | if (data!=orion128_memory_page ) |
| 158 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 159 | if (data!=state->orion128_memory_page ) |
| 161 | 160 | { |
| 162 | 161 | memory_set_bankptr(space->machine, "bank1", messram_get_ptr(space->machine->device("messram")) + (data & 3) * 0x10000); |
| 163 | | orion128_memory_page = (data & 3); |
| 162 | state->orion128_memory_page = (data & 3); |
| 164 | 163 | } |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | 166 | MACHINE_RESET ( orion128 ) |
| 168 | 167 | { |
| 169 | | orion128_video_page = 0; |
| 170 | | orion128_video_mode = 0; |
| 171 | | orion128_memory_page = -1; |
| 168 | orion_state *state = machine->driver_data<orion_state>(); |
| 169 | state->orion128_video_page = 0; |
| 170 | state->orion128_video_mode = 0; |
| 171 | state->orion128_memory_page = -1; |
| 172 | 172 | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + 0xf800); |
| 173 | 173 | memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0xf000); |
| 174 | | orion128_video_width = SCREEN_WIDTH_384; |
| 174 | state->orion128_video_width = SCREEN_WIDTH_384; |
| 175 | 175 | orion_set_video_mode(machine,384); |
| 176 | 176 | radio86_init_keyboard(); |
| 177 | 177 | } |
| r9674 | r9675 | |
| 248 | 248 | |
| 249 | 249 | MACHINE_START( orionz80 ) |
| 250 | 250 | { |
| 251 | | orion_video_mode_mask = 7; |
| 251 | orion_state *state = machine->driver_data<orion_state>(); |
| 252 | state->video_mode_mask = 7; |
| 252 | 253 | } |
| 253 | 254 | |
| 254 | | static UINT8 orion_speaker; |
| 255 | 255 | WRITE8_HANDLER ( orionz80_sound_w ) |
| 256 | 256 | { |
| 257 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 257 | 258 | running_device *speaker = space->machine->device("speaker"); |
| 258 | | if (orion_speaker == 0) |
| 259 | if (state->speaker == 0) |
| 259 | 260 | { |
| 260 | | orion_speaker = data; |
| 261 | state->speaker = data; |
| 261 | 262 | } |
| 262 | 263 | else |
| 263 | 264 | { |
| 264 | | orion_speaker = 0 ; |
| 265 | state->speaker = 0 ; |
| 265 | 266 | } |
| 266 | | speaker_level_w(speaker,orion_speaker); |
| 267 | speaker_level_w(speaker,state->speaker); |
| 267 | 268 | |
| 268 | 269 | } |
| 269 | 270 | |
| r9674 | r9675 | |
| 276 | 277 | |
| 277 | 278 | static void orionz80_switch_bank(running_machine *machine) |
| 278 | 279 | { |
| 280 | orion_state *state = machine->driver_data<orion_state>(); |
| 279 | 281 | UINT8 bank_select; |
| 280 | 282 | UINT8 segment_select; |
| 281 | 283 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 282 | 284 | |
| 283 | | bank_select = (orionz80_dispatcher & 0x0c) >> 2; |
| 284 | | segment_select = orionz80_dispatcher & 0x03; |
| 285 | bank_select = (state->orionz80_dispatcher & 0x0c) >> 2; |
| 286 | segment_select = state->orionz80_dispatcher & 0x03; |
| 285 | 287 | |
| 286 | 288 | memory_install_write_bank(space, 0x0000, 0x3fff, 0, 0, "bank1"); |
| 287 | | if ((orionz80_dispatcher & 0x80)==0) |
| 289 | if ((state->orionz80_dispatcher & 0x80)==0) |
| 288 | 290 | { // dispatcher on |
| 289 | 291 | memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000 * bank_select + segment_select * 0x4000 ); |
| 290 | 292 | } |
| 291 | 293 | else |
| 292 | 294 | { // dispatcher off |
| 293 | | memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000 * orionz80_memory_page); |
| 295 | memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000 * state->orionz80_memory_page); |
| 294 | 296 | } |
| 295 | 297 | |
| 296 | | memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000 + 0x10000 * orionz80_memory_page); |
| 298 | memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x4000 + 0x10000 * state->orionz80_memory_page); |
| 297 | 299 | |
| 298 | | if ((orionz80_dispatcher & 0x20) == 0) |
| 300 | if ((state->orionz80_dispatcher & 0x20) == 0) |
| 299 | 301 | { |
| 300 | 302 | memory_install_write8_handler(space, 0xf400, 0xf4ff, 0, 0, orion128_system_w); |
| 301 | 303 | memory_install_write8_handler(space, 0xf500, 0xf5ff, 0, 0, orion128_romdisk_w); |
| r9674 | r9675 | |
| 318 | 320 | else |
| 319 | 321 | { |
| 320 | 322 | /* if it is full memory access */ |
| 321 | | memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xf000 + 0x10000 * orionz80_memory_page); |
| 322 | | memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xf400 + 0x10000 * orionz80_memory_page); |
| 323 | | memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xf800 + 0x10000 * orionz80_memory_page); |
| 323 | memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0xf000 + 0x10000 * state->orionz80_memory_page); |
| 324 | memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0xf400 + 0x10000 * state->orionz80_memory_page); |
| 325 | memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0xf800 + 0x10000 * state->orionz80_memory_page); |
| 324 | 326 | } |
| 325 | 327 | } |
| 326 | 328 | |
| 327 | 329 | WRITE8_HANDLER ( orionz80_memory_page_w ) |
| 328 | 330 | { |
| 329 | | orionz80_memory_page = data & 7; |
| 331 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 332 | state->orionz80_memory_page = data & 7; |
| 330 | 333 | orionz80_switch_bank(space->machine); |
| 331 | 334 | } |
| 332 | 335 | |
| 333 | 336 | WRITE8_HANDLER ( orionz80_dispatcher_w ) |
| 334 | 337 | { |
| 335 | | orionz80_dispatcher = data; |
| 338 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 339 | state->orionz80_dispatcher = data; |
| 336 | 340 | orionz80_switch_bank(space->machine); |
| 337 | 341 | } |
| 338 | 342 | |
| 339 | 343 | MACHINE_RESET ( orionz80 ) |
| 340 | 344 | { |
| 345 | orion_state *state = machine->driver_data<orion_state>(); |
| 341 | 346 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 342 | 347 | |
| 343 | 348 | memory_unmap_write(space, 0x0000, 0x3fff, 0, 0); |
| r9674 | r9675 | |
| 365 | 370 | memory_set_bankptr(machine, "bank5", memory_region(machine, "maincpu") + 0xf800); |
| 366 | 371 | |
| 367 | 372 | |
| 368 | | orion128_video_page = 0; |
| 369 | | orion128_video_mode = 0; |
| 370 | | orionz80_memory_page = 0; |
| 371 | | orionz80_dispatcher = 0; |
| 372 | | orion_speaker = 0; |
| 373 | | orion128_video_width = SCREEN_WIDTH_384; |
| 373 | state->orion128_video_page = 0; |
| 374 | state->orion128_video_mode = 0; |
| 375 | state->orionz80_memory_page = 0; |
| 376 | state->orionz80_dispatcher = 0; |
| 377 | state->speaker = 0; |
| 378 | state->orion128_video_width = SCREEN_WIDTH_384; |
| 374 | 379 | orion_set_video_mode(machine,384); |
| 375 | 380 | radio86_init_keyboard(); |
| 376 | 381 | } |
| 377 | 382 | |
| 378 | 383 | INTERRUPT_GEN( orionz80_interrupt ) |
| 379 | 384 | { |
| 380 | | if ((orionz80_dispatcher & 0x40)==0x40) |
| 385 | orion_state *state = device->machine->driver_data<orion_state>(); |
| 386 | if ((state->orionz80_dispatcher & 0x40)==0x40) |
| 381 | 387 | { |
| 382 | 388 | cpu_set_input_line(device, 0, HOLD_LINE); |
| 383 | 389 | } |
| r9674 | r9675 | |
| 413 | 419 | } |
| 414 | 420 | } |
| 415 | 421 | |
| 416 | | static UINT8 orionpro_ram0_segment; |
| 417 | | static UINT8 orionpro_ram1_segment; |
| 418 | | static UINT8 orionpro_ram2_segment; |
| 419 | 422 | |
| 420 | | static UINT8 orionpro_page; |
| 421 | | static UINT8 orionpro_128_page; |
| 422 | | static UINT8 orionpro_rom2_segment; |
| 423 | 423 | |
| 424 | | static UINT8 orionpro_dispatcher; |
| 425 | | UINT8 orionpro_pseudo_color; |
| 426 | 424 | |
| 427 | 425 | |
| 428 | 426 | static WRITE8_HANDLER ( orionpro_memory_page_w ); |
| 429 | 427 | |
| 430 | 428 | static void orionpro_bank_switch(running_machine *machine) |
| 431 | 429 | { |
| 430 | orion_state *state = machine->driver_data<orion_state>(); |
| 432 | 431 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 433 | | int page = orionpro_page & 7; // we have only 8 pages |
| 434 | | int is128 = (orionpro_dispatcher & 0x80) ? 1 : 0; |
| 432 | int page = state->orionpro_page & 7; // we have only 8 pages |
| 433 | int is128 = (state->orionpro_dispatcher & 0x80) ? 1 : 0; |
| 435 | 434 | if (is128==1) |
| 436 | 435 | { |
| 437 | | page = orionpro_128_page & 7; |
| 436 | page = state->orionpro_128_page & 7; |
| 438 | 437 | } |
| 439 | 438 | memory_install_write_bank(space, 0x0000, 0x1fff, 0, 0, "bank1"); |
| 440 | 439 | memory_install_write_bank(space, 0x2000, 0x3fff, 0, 0, "bank2"); |
| r9674 | r9675 | |
| 446 | 445 | memory_install_write_bank(space, 0xf800, 0xffff, 0, 0, "bank8"); |
| 447 | 446 | |
| 448 | 447 | |
| 449 | | if ((orionpro_dispatcher & 0x01)==0x00) |
| 448 | if ((state->orionpro_dispatcher & 0x01)==0x00) |
| 450 | 449 | { // RAM0 segment disabled |
| 451 | 450 | memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + 0x10000 * page); |
| 452 | 451 | memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0x2000); |
| 453 | 452 | } |
| 454 | 453 | else |
| 455 | 454 | { |
| 456 | | memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + (orionpro_ram0_segment & 31) * 0x4000); |
| 457 | | memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + (orionpro_ram0_segment & 31) * 0x4000 + 0x2000); |
| 455 | memory_set_bankptr(machine, "bank1", messram_get_ptr(machine->device("messram")) + (state->orionpro_ram0_segment & 31) * 0x4000); |
| 456 | memory_set_bankptr(machine, "bank2", messram_get_ptr(machine->device("messram")) + (state->orionpro_ram0_segment & 31) * 0x4000 + 0x2000); |
| 458 | 457 | } |
| 459 | | if ((orionpro_dispatcher & 0x10)==0x10) |
| 458 | if ((state->orionpro_dispatcher & 0x10)==0x10) |
| 460 | 459 | { // ROM1 enabled |
| 461 | 460 | memory_unmap_write(space, 0x0000, 0x1fff, 0, 0); |
| 462 | 461 | memory_set_bankptr(machine, "bank1", memory_region(machine, "maincpu") + 0x20000); |
| 463 | 462 | } |
| 464 | | if ((orionpro_dispatcher & 0x08)==0x08) |
| 463 | if ((state->orionpro_dispatcher & 0x08)==0x08) |
| 465 | 464 | { // ROM2 enabled |
| 466 | 465 | memory_unmap_write(space, 0x2000, 0x3fff, 0, 0); |
| 467 | | memory_set_bankptr(machine, "bank2", memory_region(machine, "maincpu") + 0x22000 + (orionpro_rom2_segment & 7) * 0x2000); |
| 466 | memory_set_bankptr(machine, "bank2", memory_region(machine, "maincpu") + 0x22000 + (state->orionpro_rom2_segment & 7) * 0x2000); |
| 468 | 467 | } |
| 469 | 468 | |
| 470 | | if ((orionpro_dispatcher & 0x02)==0x00) |
| 469 | if ((state->orionpro_dispatcher & 0x02)==0x00) |
| 471 | 470 | { // RAM1 segment disabled |
| 472 | 471 | memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0x4000); |
| 473 | 472 | } |
| 474 | 473 | else |
| 475 | 474 | { |
| 476 | | memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + (orionpro_ram1_segment & 31) * 0x4000); |
| 475 | memory_set_bankptr(machine, "bank3", messram_get_ptr(machine->device("messram")) + (state->orionpro_ram1_segment & 31) * 0x4000); |
| 477 | 476 | } |
| 478 | 477 | |
| 479 | | if ((orionpro_dispatcher & 0x04)==0x00) |
| 478 | if ((state->orionpro_dispatcher & 0x04)==0x00) |
| 480 | 479 | { // RAM2 segment disabled |
| 481 | 480 | memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0x8000); |
| 482 | 481 | } |
| 483 | 482 | else |
| 484 | 483 | { |
| 485 | | memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + (orionpro_ram2_segment & 31) * 0x4000); |
| 484 | memory_set_bankptr(machine, "bank4", messram_get_ptr(machine->device("messram")) + (state->orionpro_ram2_segment & 31) * 0x4000); |
| 486 | 485 | } |
| 487 | 486 | |
| 488 | 487 | memory_set_bankptr(machine, "bank5", messram_get_ptr(machine->device("messram")) + 0x10000 * page + 0xc000); |
| r9674 | r9675 | |
| 511 | 510 | } |
| 512 | 511 | else |
| 513 | 512 | { |
| 514 | | if ((orionpro_dispatcher & 0x40)==0x40) |
| 513 | if ((state->orionpro_dispatcher & 0x40)==0x40) |
| 515 | 514 | { // FIX F000 enabled |
| 516 | 515 | memory_set_bankptr(machine, "bank6", messram_get_ptr(machine->device("messram")) + 0x10000 * 0 + 0xf000); |
| 517 | 516 | memory_set_bankptr(machine, "bank7", messram_get_ptr(machine->device("messram")) + 0x10000 * 0 + 0xf400); |
| r9674 | r9675 | |
| 528 | 527 | |
| 529 | 528 | static WRITE8_HANDLER ( orionpro_memory_page_w ) |
| 530 | 529 | { |
| 531 | | orionpro_128_page = data; |
| 530 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 531 | state->orionpro_128_page = data; |
| 532 | 532 | orionpro_bank_switch(space->machine); |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | 535 | MACHINE_RESET ( orionpro ) |
| 536 | 536 | { |
| 537 | orion_state *state = machine->driver_data<orion_state>(); |
| 537 | 538 | radio86_init_keyboard(); |
| 538 | 539 | |
| 539 | | orion128_video_page = 0; |
| 540 | | orion128_video_mode = 0; |
| 541 | | orionpro_ram0_segment = 0; |
| 542 | | orionpro_ram1_segment = 0; |
| 543 | | orionpro_ram2_segment = 0; |
| 540 | state->orion128_video_page = 0; |
| 541 | state->orion128_video_mode = 0; |
| 542 | state->orionpro_ram0_segment = 0; |
| 543 | state->orionpro_ram1_segment = 0; |
| 544 | state->orionpro_ram2_segment = 0; |
| 544 | 545 | |
| 545 | | orionpro_page = 0; |
| 546 | | orionpro_128_page = 0; |
| 547 | | orionpro_rom2_segment = 0; |
| 546 | state->orionpro_page = 0; |
| 547 | state->orionpro_128_page = 0; |
| 548 | state->orionpro_rom2_segment = 0; |
| 548 | 549 | |
| 549 | | orionpro_dispatcher = 0x50; |
| 550 | state->orionpro_dispatcher = 0x50; |
| 550 | 551 | orionpro_bank_switch(machine); |
| 551 | 552 | |
| 552 | | orion_speaker = 0; |
| 553 | | orion128_video_width = SCREEN_WIDTH_384; |
| 553 | state->speaker = 0; |
| 554 | state->orion128_video_width = SCREEN_WIDTH_384; |
| 554 | 555 | orion_set_video_mode(machine,384); |
| 555 | 556 | |
| 556 | | orion_video_mode_mask = 31; |
| 557 | | orionpro_pseudo_color = 0; |
| 557 | state->video_mode_mask = 31; |
| 558 | state->orionpro_pseudo_color = 0; |
| 558 | 559 | } |
| 559 | 560 | |
| 560 | 561 | READ8_HANDLER ( orionpro_io_r ) |
| 561 | 562 | { |
| 563 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 562 | 564 | running_device *fdc = space->machine->device("wd1793"); |
| 563 | 565 | |
| 564 | 566 | switch (offset & 0xff) |
| 565 | 567 | { |
| 566 | 568 | case 0x00 : return 0x56; |
| 567 | | case 0x04 : return orionpro_ram0_segment; |
| 568 | | case 0x05 : return orionpro_ram1_segment; |
| 569 | | case 0x06 : return orionpro_ram2_segment; |
| 570 | | case 0x08 : return orionpro_page; |
| 571 | | case 0x09 : return orionpro_rom2_segment; |
| 572 | | case 0x0a : return orionpro_dispatcher; |
| 569 | case 0x04 : return state->orionpro_ram0_segment; |
| 570 | case 0x05 : return state->orionpro_ram1_segment; |
| 571 | case 0x06 : return state->orionpro_ram2_segment; |
| 572 | case 0x08 : return state->orionpro_page; |
| 573 | case 0x09 : return state->orionpro_rom2_segment; |
| 574 | case 0x0a : return state->orionpro_dispatcher; |
| 573 | 575 | case 0x10 : return wd17xx_status_r(fdc,0); |
| 574 | 576 | case 0x11 : return wd17xx_track_r(fdc,0); |
| 575 | 577 | case 0x12 : return wd17xx_sector_r(fdc,0); |
| r9674 | r9675 | |
| 593 | 595 | |
| 594 | 596 | WRITE8_HANDLER ( orionpro_io_w ) |
| 595 | 597 | { |
| 598 | orion_state *state = space->machine->driver_data<orion_state>(); |
| 596 | 599 | running_device *fdc = space->machine->device("wd1793"); |
| 597 | 600 | |
| 598 | 601 | switch (offset & 0xff) |
| 599 | 602 | { |
| 600 | | case 0x04 : orionpro_ram0_segment = data; orionpro_bank_switch(space->machine); break; |
| 601 | | case 0x05 : orionpro_ram1_segment = data; orionpro_bank_switch(space->machine); break; |
| 602 | | case 0x06 : orionpro_ram2_segment = data; orionpro_bank_switch(space->machine); break; |
| 603 | | case 0x08 : orionpro_page = data; orionpro_bank_switch(space->machine); break; |
| 604 | | case 0x09 : orionpro_rom2_segment = data; orionpro_bank_switch(space->machine); break; |
| 605 | | case 0x0a : orionpro_dispatcher = data; orionpro_bank_switch(space->machine); break; |
| 603 | case 0x04 : state->orionpro_ram0_segment = data; orionpro_bank_switch(space->machine); break; |
| 604 | case 0x05 : state->orionpro_ram1_segment = data; orionpro_bank_switch(space->machine); break; |
| 605 | case 0x06 : state->orionpro_ram2_segment = data; orionpro_bank_switch(space->machine); break; |
| 606 | case 0x08 : state->orionpro_page = data; orionpro_bank_switch(space->machine); break; |
| 607 | case 0x09 : state->orionpro_rom2_segment = data; orionpro_bank_switch(space->machine); break; |
| 608 | case 0x0a : state->orionpro_dispatcher = data; orionpro_bank_switch(space->machine); break; |
| 606 | 609 | case 0x10 : wd17xx_command_w(fdc,0,data); break; |
| 607 | 610 | case 0x11 : wd17xx_track_w(fdc,0,data);break; |
| 608 | 611 | case 0x12 : wd17xx_sector_w(fdc,0,data);break; |
| r9674 | r9675 | |
| 618 | 621 | case 0x2a : orion128_romdisk_w(space,2,data); break; |
| 619 | 622 | case 0x2b : orion128_romdisk_w(space,3,data); break; |
| 620 | 623 | case 0xf8 : orion128_video_mode_w(space,0,data);break; |
| 621 | | case 0xf9 : orionpro_128_page = data; orionpro_bank_switch(space->machine); break; |
| 624 | case 0xf9 : state->orionpro_128_page = data; orionpro_bank_switch(space->machine); break; |
| 622 | 625 | case 0xfa : orion128_video_page_w(space,0,data);break; |
| 623 | | case 0xfc : orionpro_pseudo_color = data;break; |
| 626 | case 0xfc : state->orionpro_pseudo_color = data;break; |
| 624 | 627 | case 0xfe : orionz80_sound_fe_w(space,0,data);break; |
| 625 | 628 | case 0xff : orionz80_sound_w(space,0,data);break; |
| 626 | 629 | } |
src/mess/machine/trs80.c
| r9674 | r9675 | |
| 32 | 32 | #define LOG(x) do { if (VERBOSE) logerror x; } while (0) |
| 33 | 33 | |
| 34 | 34 | |
| 35 | | static UINT8 trs80_irq=0; /* interrupting devices */ |
| 36 | | static UINT8 trs80_mask= 0; /* interrupt mask */ |
| 37 | | static UINT8 trs80_nmi_mask= 0; /* nmi mask */ |
| 38 | | static UINT8 trs80_port_ec=0; /* bit d6..d1 of port EC to be read by port FF */ |
| 39 | | static UINT8 trs80_tape_unit; /* selected cassette unit (trs80l2 and sys80 only) (not implemented yet) */ |
| 40 | | static UINT8 trs80_reg_load; /* Controls what port EA will do */ |
| 41 | | static UINT8 trs80_nmi_data; /* Passes FDC int to NMI handler */ |
| 42 | | UINT8 trs80_mode = 0; /* Control bits passed to video output routine */ |
| 43 | | |
| 44 | 35 | #define IRQ_M1_RTC 0x80 /* RTC on Model I */ |
| 45 | 36 | #define IRQ_M1_FDC 0x40 /* FDC on Model I */ |
| 46 | 37 | #define IRQ_M4_RTC 0x04 /* RTC on Model 4 */ |
| r9674 | r9675 | |
| 51 | 42 | #define MAX_GRANULES 8 /* lumps consisted of granules.. aha */ |
| 52 | 43 | #define MAX_SECTORS 5 /* and granules of sectors */ |
| 53 | 44 | |
| 54 | | #ifdef USE_TRACK |
| 55 | | static UINT8 track[4] = {0, }; /* current track per drive */ |
| 56 | | #endif |
| 57 | | static UINT8 head; /* current head per drive */ |
| 58 | | #ifdef USE_SECTOR |
| 59 | | static UINT8 sector[4] = {0, }; /* current sector per drive */ |
| 60 | | #endif |
| 61 | | |
| 62 | 45 | #define MODEL4_MASTER_CLOCK 20275200 |
| 63 | 46 | |
| 64 | | static UINT8 cassette_data; |
| 65 | | static emu_timer *cassette_data_timer; |
| 66 | | static running_device *trs80_printer; |
| 67 | | static running_device *trs80_ay31015; |
| 68 | | static running_device *trs80_cass; |
| 69 | | static running_device *trs80_speaker; |
| 70 | | static running_device *trs80_fdc; |
| 71 | 47 | |
| 72 | 48 | static TIMER_CALLBACK( cassette_data_callback ) |
| 73 | 49 | { |
| 50 | trs80_state *state = machine->driver_data<trs80_state>(); |
| 74 | 51 | /* This does all baud rates. 250 baud (trs80), and 500 baud (all others) set bit 7 of "cassette_data". |
| 75 | 52 | 1500 baud (trs80m3, trs80m4) is interrupt-driven and uses bit 0 of "cassette_data" */ |
| 76 | 53 | |
| 77 | | static double old_cassette_val; |
| 78 | | double new_val = cassette_input(trs80_cass); |
| 54 | double new_val = cassette_input(state->cass); |
| 79 | 55 | |
| 80 | 56 | /* Check for HI-LO transition */ |
| 81 | | if ( old_cassette_val > -0.2 && new_val < -0.2 ) |
| 57 | if ( state->old_cassette_val > -0.2 && new_val < -0.2 ) |
| 82 | 58 | { |
| 83 | | cassette_data |= 0x80; /* 500 baud */ |
| 84 | | if (trs80_mask & CASS_FALL) /* see if 1500 baud */ |
| 59 | state->cassette_data |= 0x80; /* 500 baud */ |
| 60 | if (state->mask & CASS_FALL) /* see if 1500 baud */ |
| 85 | 61 | { |
| 86 | | cassette_data = 0; |
| 87 | | trs80_irq |= CASS_FALL; |
| 62 | state->cassette_data = 0; |
| 63 | state->irq |= CASS_FALL; |
| 88 | 64 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| 89 | 65 | } |
| 90 | 66 | } |
| 91 | 67 | else |
| 92 | | if ( old_cassette_val < -0.2 && new_val > -0.2 ) |
| 68 | if ( state->old_cassette_val < -0.2 && new_val > -0.2 ) |
| 93 | 69 | { |
| 94 | | if (trs80_mask & CASS_RISE) /* 1500 baud */ |
| 70 | if (state->mask & CASS_RISE) /* 1500 baud */ |
| 95 | 71 | { |
| 96 | | cassette_data = 1; |
| 97 | | trs80_irq |= CASS_RISE; |
| 72 | state->cassette_data = 1; |
| 73 | state->irq |= CASS_RISE; |
| 98 | 74 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| 99 | 75 | } |
| 100 | 76 | } |
| 101 | 77 | |
| 102 | | old_cassette_val = new_val; |
| 78 | state->old_cassette_val = new_val; |
| 103 | 79 | } |
| 104 | 80 | |
| 105 | 81 | |
| r9674 | r9675 | |
| 112 | 88 | |
| 113 | 89 | READ8_HANDLER( trs80m4_e0_r ) |
| 114 | 90 | { |
| 91 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 115 | 92 | /* Indicates which devices are interrupting - d6..d3 not emulated. |
| 116 | 93 | Whenever an interrupt occurs, this port is immediately read |
| 117 | 94 | to find out which device requires service. Lowest-numbered |
| r9674 | r9675 | |
| 127 | 104 | d0 Cass 1500 baud Rising */ |
| 128 | 105 | |
| 129 | 106 | cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); |
| 130 | | return ~(trs80_mask & trs80_irq); |
| 107 | return ~(state->mask & state->irq); |
| 131 | 108 | } |
| 132 | 109 | |
| 133 | 110 | READ8_HANDLER( trs80m4_e4_r ) |
| 134 | 111 | { |
| 112 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 135 | 113 | /* Indicates which devices are interrupting - d6..d5 not emulated. |
| 136 | 114 | Whenever an NMI occurs, this port is immediately read |
| 137 | 115 | to find out which device requires service. Lowest-numbered |
| r9674 | r9675 | |
| 144 | 122 | |
| 145 | 123 | cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE); |
| 146 | 124 | |
| 147 | | return ~(trs80_nmi_mask & trs80_nmi_data); |
| 125 | return ~(state->nmi_mask & state->nmi_data); |
| 148 | 126 | } |
| 149 | 127 | |
| 150 | 128 | READ8_HANDLER( trs80m4_e8_r ) |
| r9674 | r9675 | |
| 162 | 140 | |
| 163 | 141 | READ8_HANDLER( trs80m4_ea_r ) |
| 164 | 142 | { |
| 143 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 165 | 144 | /* UART Status Register |
| 166 | 145 | d7 Data Received ('1'=condition true) |
| 167 | 146 | d6 Transmitter Holding Register empty ('1'=condition true) |
| r9674 | r9675 | |
| 171 | 150 | d2..d0 Not used */ |
| 172 | 151 | |
| 173 | 152 | UINT8 data=7; |
| 174 | | ay31015_set_input_pin( trs80_ay31015, AY31015_SWE, 0 ); |
| 175 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_TBMT ) ? 0x40 : 0; |
| 176 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_DAV ) ? 0x80 : 0; |
| 177 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_OR ) ? 0x20 : 0; |
| 178 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_FE ) ? 0x10 : 0; |
| 179 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_PE ) ? 0x08 : 0; |
| 180 | | ay31015_set_input_pin( trs80_ay31015, AY31015_SWE, 1 ); |
| 153 | ay31015_set_input_pin( state->ay31015, AY31015_SWE, 0 ); |
| 154 | data |= ay31015_get_output_pin( state->ay31015, AY31015_TBMT ) ? 0x40 : 0; |
| 155 | data |= ay31015_get_output_pin( state->ay31015, AY31015_DAV ) ? 0x80 : 0; |
| 156 | data |= ay31015_get_output_pin( state->ay31015, AY31015_OR ) ? 0x20 : 0; |
| 157 | data |= ay31015_get_output_pin( state->ay31015, AY31015_FE ) ? 0x10 : 0; |
| 158 | data |= ay31015_get_output_pin( state->ay31015, AY31015_PE ) ? 0x08 : 0; |
| 159 | ay31015_set_input_pin( state->ay31015, AY31015_SWE, 1 ); |
| 181 | 160 | |
| 182 | 161 | return data; |
| 183 | 162 | } |
| 184 | 163 | |
| 185 | 164 | READ8_HANDLER( trs80m4_eb_r ) |
| 186 | 165 | { |
| 166 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 187 | 167 | /* UART received data */ |
| 188 | | UINT8 data = ay31015_get_received_data( trs80_ay31015 ); |
| 189 | | ay31015_set_input_pin( trs80_ay31015, AY31015_RDAV, 0 ); |
| 190 | | ay31015_set_input_pin( trs80_ay31015, AY31015_RDAV, 1 ); |
| 168 | UINT8 data = ay31015_get_received_data( state->ay31015 ); |
| 169 | ay31015_set_input_pin( state->ay31015, AY31015_RDAV, 0 ); |
| 170 | ay31015_set_input_pin( state->ay31015, AY31015_RDAV, 1 ); |
| 191 | 171 | return data; |
| 192 | 172 | } |
| 193 | 173 | |
| 194 | 174 | READ8_HANDLER( trs80m4_ec_r ) |
| 195 | 175 | { |
| 176 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 196 | 177 | /* Reset the RTC interrupt */ |
| 197 | | trs80_irq &= ~IRQ_M4_RTC; |
| 178 | state->irq &= ~IRQ_M4_RTC; |
| 198 | 179 | return 0; |
| 199 | 180 | } |
| 200 | 181 | |
| 201 | 182 | READ8_HANDLER( sys80_f9_r ) |
| 202 | 183 | { |
| 184 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 203 | 185 | /* UART Status Register - d6..d4 not emulated |
| 204 | 186 | d7 Transmit buffer empty (inverted) |
| 205 | 187 | d6 CTS pin |
| r9674 | r9675 | |
| 211 | 193 | d0 Data Available */ |
| 212 | 194 | |
| 213 | 195 | UINT8 data=70; |
| 214 | | ay31015_set_input_pin( trs80_ay31015, AY31015_SWE, 0 ); |
| 215 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_TBMT ) ? 0 : 0x80; |
| 216 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_DAV ) ? 0x01 : 0; |
| 217 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_OR ) ? 0x02 : 0; |
| 218 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_FE ) ? 0x04 : 0; |
| 219 | | data |= ay31015_get_output_pin( trs80_ay31015, AY31015_PE ) ? 0x08 : 0; |
| 220 | | ay31015_set_input_pin( trs80_ay31015, AY31015_SWE, 1 ); |
| 196 | ay31015_set_input_pin( state->ay31015, AY31015_SWE, 0 ); |
| 197 | data |= ay31015_get_output_pin( state->ay31015, AY31015_TBMT ) ? 0 : 0x80; |
| 198 | data |= ay31015_get_output_pin( state->ay31015, AY31015_DAV ) ? 0x01 : 0; |
| 199 | data |= ay31015_get_output_pin( state->ay31015, AY31015_OR ) ? 0x02 : 0; |
| 200 | data |= ay31015_get_output_pin( state->ay31015, AY31015_FE ) ? 0x04 : 0; |
| 201 | data |= ay31015_get_output_pin( state->ay31015, AY31015_PE ) ? 0x08 : 0; |
| 202 | ay31015_set_input_pin( state->ay31015, AY31015_SWE, 1 ); |
| 221 | 203 | |
| 222 | 204 | return data; |
| 223 | 205 | } |
| 224 | 206 | |
| 225 | 207 | READ8_HANDLER( lnw80_fe_r ) |
| 226 | 208 | { |
| 227 | | return ((trs80_mode & 0x78) >> 3) | 0xf0; |
| 209 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 210 | return ((state->mode & 0x78) >> 3) | 0xf0; |
| 228 | 211 | } |
| 229 | 212 | |
| 230 | 213 | READ8_HANDLER( trs80_ff_r ) |
| 231 | 214 | { |
| 215 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 232 | 216 | /* ModeSel and cassette data |
| 233 | 217 | d7 cassette data from tape |
| 234 | 218 | d2 modesel setting */ |
| 235 | 219 | |
| 236 | | UINT8 data = (~trs80_mode & 1) << 5; |
| 237 | | return data | cassette_data; |
| 220 | UINT8 data = (~state->mode & 1) << 5; |
| 221 | return data | state->cassette_data; |
| 238 | 222 | } |
| 239 | 223 | |
| 240 | 224 | READ8_HANDLER( trs80m4_ff_r ) |
| 241 | 225 | { |
| 226 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 242 | 227 | /* Return of cassette data stream from tape |
| 243 | 228 | d7 Low-speed data |
| 244 | 229 | d6..d1 info from write of port EC |
| 245 | 230 | d0 High-speed data */ |
| 246 | 231 | |
| 247 | | trs80_irq &= 0xfc; /* clear cassette interrupts */ |
| 232 | state->irq &= 0xfc; /* clear cassette interrupts */ |
| 248 | 233 | |
| 249 | | return trs80_port_ec | cassette_data; |
| 234 | return state->port_ec | state->cassette_data; |
| 250 | 235 | } |
| 251 | 236 | |
| 252 | 237 | |
| 253 | 238 | WRITE8_HANDLER( trs80m4_84_w ) |
| 254 | 239 | { |
| 240 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 255 | 241 | /* Hi-res graphics control - d6..d4 not emulated |
| 256 | 242 | d7 Page Control |
| 257 | 243 | d6 Fix upper memory |
| r9674 | r9675 | |
| 265 | 251 | /* get address space instead of io space */ |
| 266 | 252 | address_space *mem = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 267 | 253 | |
| 268 | | trs80_mode = (trs80_mode & 0x73) | (data & 0x8c); |
| 254 | state->mode = (state->mode & 0x73) | (data & 0x8c); |
| 269 | 255 | |
| 270 | | trs80_model4 &= 0xce; |
| 271 | | trs80_model4 |= (data & 3) << 4; |
| 256 | state->model4 &= 0xce; |
| 257 | state->model4 |= (data & 3) << 4; |
| 272 | 258 | |
| 273 | 259 | switch (data & 3) |
| 274 | 260 | { |
| 275 | 261 | case 0: /* normal operation */ |
| 276 | 262 | |
| 277 | | if (trs80_model4 & 4) /* Model 4P gets RAM while Model 4 gets ROM */ |
| 263 | if (state->model4 & 4) /* Model 4P gets RAM while Model 4 gets ROM */ |
| 278 | 264 | { |
| 279 | | if (trs80_model4 & 8) |
| 265 | if (state->model4 & 8) |
| 280 | 266 | memory_set_bankptr(mem->machine, "bank1", memory_region(mem->machine, "maincpu")); |
| 281 | 267 | else |
| 282 | 268 | memory_set_bankptr(mem->machine, "bank1", memory_region(mem->machine, "maincpu") + 0x10000); |
| r9674 | r9675 | |
| 308 | 294 | |
| 309 | 295 | case 1: /* write-only ram backs up the rom */ |
| 310 | 296 | |
| 311 | | if (trs80_model4 & 4) /* Model 4P gets RAM while Model 4 gets ROM */ |
| 297 | if (state->model4 & 4) /* Model 4P gets RAM while Model 4 gets ROM */ |
| 312 | 298 | { |
| 313 | | if (trs80_model4 & 8) |
| 299 | if (state->model4 & 8) |
| 314 | 300 | memory_set_bankptr(mem->machine, "bank1", memory_region(mem->machine, "maincpu")); |
| 315 | 301 | else |
| 316 | 302 | memory_set_bankptr(mem->machine, "bank1", memory_region(mem->machine, "maincpu") + 0x10000); |
| r9674 | r9675 | |
| 360 | 346 | memory_set_bankptr(mem->machine, "bank18", memory_region(mem->machine, "maincpu") + 0x0a000); |
| 361 | 347 | memory_install_read8_handler (mem, 0xf400, 0xf7ff, 0, 0, trs80_keyboard_r); /* 8 */ |
| 362 | 348 | memory_install_readwrite8_handler (mem, 0xf800, 0xffff, 0, 0, trs80_videoram_r, trs80_videoram_w); /* 9 & 19 */ |
| 363 | | trs80_model4++; |
| 349 | state->model4++; |
| 364 | 350 | break; |
| 365 | 351 | |
| 366 | 352 | case 3: /* 64k of ram */ |
| r9674 | r9675 | |
| 388 | 374 | |
| 389 | 375 | WRITE8_HANDLER( trs80m4_90_w ) |
| 390 | 376 | { |
| 391 | | speaker_level_w(trs80_speaker, ~data & 1); |
| 377 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 378 | speaker_level_w(state->speaker, ~data & 1); |
| 392 | 379 | } |
| 393 | 380 | |
| 394 | 381 | WRITE8_HANDLER( trs80m4p_9c_w ) /* model 4P only - swaps the ROM with read-only RAM */ |
| 395 | 382 | { |
| 396 | | /* Meaning of trs80_model4 variable: |
| 383 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 384 | /* Meaning of model4 variable: |
| 397 | 385 | d5..d4 memory mode (as described in section above) |
| 398 | 386 | d3 rom switch (1=enabled) only effective in mode0 and 1 |
| 399 | 387 | d2 this is a Model 4P |
| r9674 | r9675 | |
| 403 | 391 | /* get address space instead of io space */ |
| 404 | 392 | address_space *mem = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 405 | 393 | |
| 406 | | trs80_model4 &= 0xf7; |
| 407 | | trs80_model4 |= (data << 3); |
| 394 | state->model4 &= 0xf7; |
| 395 | state->model4 |= (data << 3); |
| 408 | 396 | |
| 409 | | if ((trs80_model4) && (~trs80_model4 & 0x20)) |
| 397 | if ((state->model4) && (~state->model4 & 0x20)) |
| 410 | 398 | { |
| 411 | | switch (trs80_model4 & 8) |
| 399 | switch (state->model4 & 8) |
| 412 | 400 | { |
| 413 | 401 | case 0: /* Read-only RAM replaces rom */ |
| 414 | 402 | memory_set_bankptr(mem->machine, "bank1", memory_region(mem->machine, "maincpu") + 0x10000); |
| r9674 | r9675 | |
| 422 | 410 | |
| 423 | 411 | WRITE8_HANDLER( trs80m4_e0_w ) |
| 424 | 412 | { |
| 413 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 425 | 414 | /* Interrupt settings - which devices are allowed to interrupt - bits align with read of E0 |
| 426 | 415 | d6 Enable Rec Err |
| 427 | 416 | d5 Enable Rec Data |
| r9674 | r9675 | |
| 431 | 420 | d1 C fall Int |
| 432 | 421 | d0 C Rise Int */ |
| 433 | 422 | |
| 434 | | trs80_mask = data; |
| 423 | state->mask = data; |
| 435 | 424 | } |
| 436 | 425 | |
| 437 | 426 | WRITE8_HANDLER( trs80m4_e4_w ) |
| 438 | 427 | { |
| 428 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 439 | 429 | /* Disk to NMI interface |
| 440 | 430 | d7 1=enable disk INTRQ to generate NMI |
| 441 | 431 | d6 1=enable disk Motor Timeout to generate NMI */ |
| 442 | 432 | |
| 443 | | trs80_nmi_mask = data; |
| 433 | state->nmi_mask = data; |
| 444 | 434 | } |
| 445 | 435 | |
| 446 | 436 | WRITE8_HANDLER( trs80m4_e8_w ) |
| 447 | 437 | { |
| 438 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 448 | 439 | /* d1 when '1' enables control register load (see below) */ |
| 449 | 440 | |
| 450 | | trs80_reg_load = data & 2; |
| 441 | state->reg_load = data & 2; |
| 451 | 442 | } |
| 452 | 443 | |
| 453 | 444 | WRITE8_HANDLER( trs80m4_e9_w ) |
| 454 | 445 | { |
| 446 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 455 | 447 | /* UART set baud rate. Rx = bits 0..3, Tx = bits 4..7 |
| 456 | 448 | 00h 50 |
| 457 | 449 | 11h 75 |
| r9674 | r9675 | |
| 471 | 463 | FFh 19200 */ |
| 472 | 464 | |
| 473 | 465 | int baud_clock[]={ 800, 1200, 1760, 2152, 2400, 4800, 9600, 19200, 28800, 32000, 38400, 57600, 76800, 115200, 153600, 307200 }; |
| 474 | | ay31015_set_receiver_clock( trs80_ay31015, baud_clock[data & 0x0f]); |
| 475 | | ay31015_set_transmitter_clock( trs80_ay31015, baud_clock[data>>4]); |
| 466 | ay31015_set_receiver_clock( state->ay31015, baud_clock[data & 0x0f]); |
| 467 | ay31015_set_transmitter_clock( state->ay31015, baud_clock[data>>4]); |
| 476 | 468 | } |
| 477 | 469 | |
| 478 | 470 | WRITE8_HANDLER( trs80m4_ea_w ) |
| 479 | 471 | { |
| 480 | | if (trs80_reg_load) |
| 472 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 473 | if (state->reg_load) |
| 481 | 474 | |
| 482 | 475 | /* d2..d0 not emulated |
| 483 | 476 | d7 Even Parity Enable ('1'=even, '0'=odd) |
| r9674 | r9675 | |
| 492 | 485 | d0 Data-Terminal-Ready (DTR), pin 20 */ |
| 493 | 486 | |
| 494 | 487 | { |
| 495 | | ay31015_set_input_pin( trs80_ay31015, AY31015_CS, 0 ); |
| 496 | | ay31015_set_input_pin( trs80_ay31015, AY31015_NB1, ( data & 0x40 ) ? 1 : 0 ); |
| 497 | | ay31015_set_input_pin( trs80_ay31015, AY31015_NB2, ( data & 0x20 ) ? 1 : 0 ); |
| 498 | | ay31015_set_input_pin( trs80_ay31015, AY31015_TSB, ( data & 0x10 ) ? 1 : 0 ); |
| 499 | | ay31015_set_input_pin( trs80_ay31015, AY31015_EPS, ( data & 0x80 ) ? 1 : 0 ); |
| 500 | | ay31015_set_input_pin( trs80_ay31015, AY31015_NP, ( data & 0x08 ) ? 1 : 0 ); |
| 501 | | ay31015_set_input_pin( trs80_ay31015, AY31015_CS, 1 ); |
| 488 | ay31015_set_input_pin( state->ay31015, AY31015_CS, 0 ); |
| 489 | ay31015_set_input_pin( state->ay31015, AY31015_NB1, ( data & 0x40 ) ? 1 : 0 ); |
| 490 | ay31015_set_input_pin( state->ay31015, AY31015_NB2, ( data & 0x20 ) ? 1 : 0 ); |
| 491 | ay31015_set_input_pin( state->ay31015, AY31015_TSB, ( data & 0x10 ) ? 1 : 0 ); |
| 492 | ay31015_set_input_pin( state->ay31015, AY31015_EPS, ( data & 0x80 ) ? 1 : 0 ); |
| 493 | ay31015_set_input_pin( state->ay31015, AY31015_NP, ( data & 0x08 ) ? 1 : 0 ); |
| 494 | ay31015_set_input_pin( state->ay31015, AY31015_CS, 1 ); |
| 502 | 495 | } |
| 503 | 496 | else |
| 504 | 497 | { |
| r9674 | r9675 | |
| 517 | 510 | |
| 518 | 511 | WRITE8_HANDLER( trs80m4_eb_w ) |
| 519 | 512 | { |
| 520 | | ay31015_set_transmit_data( trs80_ay31015, data ); |
| 513 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 514 | ay31015_set_transmit_data( state->ay31015, data ); |
| 521 | 515 | } |
| 522 | 516 | |
| 523 | 517 | WRITE8_HANDLER( trs80m4_ec_w ) |
| 524 | 518 | { |
| 519 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 525 | 520 | /* Hardware settings - d5..d4 not emulated |
| 526 | 521 | d6 CPU fast (1=4MHz, 0=2MHz) |
| 527 | 522 | d5 1=Enable Video Wait |
| r9674 | r9675 | |
| 532 | 527 | |
| 533 | 528 | cputag_set_clock(space->machine, "maincpu", data & 0x40 ? MODEL4_MASTER_CLOCK/5 : MODEL4_MASTER_CLOCK/10); |
| 534 | 529 | |
| 535 | | trs80_mode = (trs80_mode & 0xde) | ((data & 4) ? 1 : 0) | ((data & 8) ? 0x20 : 0); |
| 530 | state->mode = (state->mode & 0xde) | ((data & 4) ? 1 : 0) | ((data & 8) ? 0x20 : 0); |
| 536 | 531 | |
| 537 | | cassette_change_state( trs80_cass, ( data & 2 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR ); |
| 532 | cassette_change_state( state->cass, ( data & 2 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR ); |
| 538 | 533 | |
| 539 | | trs80_port_ec = data & 0x7e; |
| 534 | state->port_ec = data & 0x7e; |
| 540 | 535 | } |
| 541 | 536 | |
| 542 | 537 | WRITE8_HANDLER( trs80m4_f4_w ) |
| 543 | 538 | { |
| 539 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 544 | 540 | /* Selection of drive and parameters - d6..d5 not emulated. |
| 545 | 541 | A write also causes the selected drive motor to turn on for about 3 seconds. |
| 546 | 542 | When the motor turns off, the drive is deselected. |
| r9674 | r9675 | |
| 567 | 563 | if (data & 8) |
| 568 | 564 | drive = 3; |
| 569 | 565 | |
| 570 | | head = (data & 16) ? 1 : 0; |
| 566 | state->head = (data & 16) ? 1 : 0; |
| 571 | 567 | |
| 572 | 568 | if (drive < 4) |
| 573 | 569 | { |
| 574 | | wd17xx_set_drive(trs80_fdc,drive); |
| 575 | | wd17xx_set_side(trs80_fdc,head); |
| 570 | wd17xx_set_drive(state->fdc,drive); |
| 571 | wd17xx_set_side(state->fdc,state->head); |
| 576 | 572 | } |
| 577 | 573 | |
| 578 | | wd17xx_dden_w(trs80_fdc, !BIT(data, 7)); |
| 574 | wd17xx_dden_w(state->fdc, !BIT(data, 7)); |
| 579 | 575 | |
| 580 | 576 | /* CLEAR_LINE means to turn motors on */ |
| 581 | 577 | floppy_mon_w(floppy_get_device(space->machine, 0), (data & 0x0f) ? CLEAR_LINE : ASSERT_LINE); |
| r9674 | r9675 | |
| 594 | 590 | |
| 595 | 591 | WRITE8_HANDLER( sys80_fe_w ) |
| 596 | 592 | { |
| 593 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 597 | 594 | /* not emulated |
| 598 | 595 | d4 select internal or external cassette player */ |
| 599 | 596 | |
| 600 | | trs80_tape_unit = (data & 0x10) ? 2 : 1; |
| 597 | state->tape_unit = (data & 0x10) ? 2 : 1; |
| 601 | 598 | } |
| 602 | 599 | |
| 603 | 600 | /* lnw80 can switch out all the devices, roms and video ram to be replaced by graphics ram. */ |
| 604 | 601 | WRITE8_HANDLER( lnw80_fe_w ) |
| 605 | 602 | { |
| 603 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 606 | 604 | /* lnw80 video options |
| 607 | 605 | d3 bankswitch lower 16k between roms and hires ram (1=hires) |
| 608 | 606 | d2 enable colour \ |
| r9674 | r9675 | |
| 612 | 610 | /* get address space instead of io space */ |
| 613 | 611 | address_space *mem = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 614 | 612 | |
| 615 | | trs80_mode = (trs80_mode & 0x87) | ((data & 0x0f) << 3); |
| 613 | state->mode = (state->mode & 0x87) | ((data & 0x0f) << 3); |
| 616 | 614 | |
| 617 | 615 | if (data & 8) |
| 618 | 616 | { |
| r9674 | r9675 | |
| 626 | 624 | memory_set_bankptr(mem->machine, "bank1", memory_region(mem->machine, "maincpu")); |
| 627 | 625 | memory_install_readwrite8_handler (mem, 0x37e0, 0x37e3, 0, 0, trs80_irq_status_r, trs80_motor_w); |
| 628 | 626 | memory_install_readwrite8_handler (mem, 0x37e8, 0x37eb, 0, 0, trs80_printer_r, trs80_printer_w); |
| 629 | | memory_install_readwrite8_device_handler (mem, trs80_fdc, 0x37ec, 0x37ec, 0, 0, trs80_wd179x_r, wd17xx_command_w); |
| 630 | | memory_install_readwrite8_device_handler (mem, trs80_fdc, 0x37ed, 0x37ed, 0, 0, wd17xx_track_r, wd17xx_track_w); |
| 631 | | memory_install_readwrite8_device_handler (mem, trs80_fdc, 0x37ee, 0x37ee, 0, 0, wd17xx_sector_r, wd17xx_sector_w); |
| 632 | | memory_install_readwrite8_device_handler (mem, trs80_fdc, 0x37ef, 0x37ef, 0, 0, wd17xx_data_r, wd17xx_data_w); |
| 627 | memory_install_readwrite8_device_handler (mem, state->fdc, 0x37ec, 0x37ec, 0, 0, trs80_wd179x_r, wd17xx_command_w); |
| 628 | memory_install_readwrite8_device_handler (mem, state->fdc, 0x37ed, 0x37ed, 0, 0, wd17xx_track_r, wd17xx_track_w); |
| 629 | memory_install_readwrite8_device_handler (mem, state->fdc, 0x37ee, 0x37ee, 0, 0, wd17xx_sector_r, wd17xx_sector_w); |
| 630 | memory_install_readwrite8_device_handler (mem, state->fdc, 0x37ef, 0x37ef, 0, 0, wd17xx_data_r, wd17xx_data_w); |
| 633 | 631 | memory_install_read8_handler (mem, 0x3800, 0x38ff, 0, 0x0300, trs80_keyboard_r); |
| 634 | 632 | memory_install_readwrite8_handler (mem, 0x3c00, 0x3fff, 0, 0, trs80_videoram_r, trs80_videoram_w); |
| 635 | 633 | } |
| r9674 | r9675 | |
| 637 | 635 | |
| 638 | 636 | WRITE8_HANDLER( trs80_ff_w ) |
| 639 | 637 | { |
| 638 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 640 | 639 | /* Standard output port of Model I |
| 641 | 640 | d3 ModeSel bit |
| 642 | 641 | d2 Relay |
| r9674 | r9675 | |
| 644 | 643 | |
| 645 | 644 | static const double levels[4] = { 0.0, -1.0, 0.0, 1.0 }; |
| 646 | 645 | |
| 647 | | cassette_change_state( trs80_cass, ( data & 4 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR ); |
| 648 | | cassette_output( trs80_cass, levels[data & 3]); |
| 649 | | cassette_data &= ~0x80; |
| 646 | cassette_change_state( state->cass, ( data & 4 ) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR ); |
| 647 | cassette_output( state->cass, levels[data & 3]); |
| 648 | state->cassette_data &= ~0x80; |
| 650 | 649 | |
| 651 | | trs80_mode = (trs80_mode & 0xfe) | ((data & 8) >> 3); |
| 650 | state->mode = (state->mode & 0xfe) | ((data & 8) >> 3); |
| 652 | 651 | |
| 653 | 652 | /* Speaker for System-80 MK II - only sounds if relay is off */ |
| 654 | 653 | if (~data & 4) |
| 655 | | speaker_level_w(trs80_speaker, data & 3); |
| 654 | speaker_level_w(state->speaker, data & 3); |
| 656 | 655 | } |
| 657 | 656 | |
| 658 | 657 | WRITE8_HANDLER( trs80m4_ff_w ) |
| 659 | 658 | { |
| 659 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 660 | 660 | /* Cassette port |
| 661 | 661 | d1, d0 Cassette output */ |
| 662 | 662 | |
| 663 | 663 | static const double levels[4] = { 0.0, -1.0, 0.0, 1.0 }; |
| 664 | | cassette_output( trs80_cass, levels[data & 3]); |
| 665 | | cassette_data &= ~0x80; |
| 664 | cassette_output( state->cass, levels[data & 3]); |
| 665 | state->cassette_data &= ~0x80; |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | |
| r9674 | r9675 | |
| 674 | 674 | |
| 675 | 675 | INTERRUPT_GEN( trs80_rtc_interrupt ) |
| 676 | 676 | { |
| 677 | trs80_state *state = device->machine->driver_data<trs80_state>(); |
| 677 | 678 | /* This enables the processing of interrupts for the clock and the flashing cursor. |
| 678 | 679 | The OS counts one tick for each interrupt. The Model I has 40 ticks per |
| 679 | 680 | second, while the Model III/4 has 30. */ |
| 680 | 681 | |
| 681 | | if (trs80_model4) // Model 4 |
| 682 | if (state->model4) // Model 4 |
| 682 | 683 | { |
| 683 | | if (trs80_mask & IRQ_M4_RTC) |
| 684 | if (state->mask & IRQ_M4_RTC) |
| 684 | 685 | { |
| 685 | | trs80_irq |= IRQ_M4_RTC; |
| 686 | state->irq |= IRQ_M4_RTC; |
| 686 | 687 | cpu_set_input_line(device, 0, HOLD_LINE); |
| 687 | 688 | } |
| 688 | 689 | } |
| 689 | 690 | else // Model 1 |
| 690 | 691 | { |
| 691 | | trs80_irq |= IRQ_M1_RTC; |
| 692 | state->irq |= IRQ_M1_RTC; |
| 692 | 693 | cpu_set_input_line(device, 0, HOLD_LINE); |
| 693 | 694 | } |
| 694 | 695 | } |
| 695 | 696 | |
| 696 | 697 | static void trs80_fdc_interrupt_internal(running_machine *machine) |
| 697 | 698 | { |
| 698 | | if (trs80_model4) |
| 699 | trs80_state *state = machine->driver_data<trs80_state>(); |
| 700 | if (state->model4) |
| 699 | 701 | { |
| 700 | | if (trs80_nmi_mask & 0x80) // Model 4 does a NMI |
| 702 | if (state->nmi_mask & 0x80) // Model 4 does a NMI |
| 701 | 703 | { |
| 702 | | trs80_nmi_data = 0x80; |
| 704 | state->nmi_data = 0x80; |
| 703 | 705 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); |
| 704 | 706 | } |
| 705 | 707 | } |
| 706 | 708 | else // Model 1 does a IRQ |
| 707 | 709 | { |
| 708 | | trs80_irq |= IRQ_M1_FDC; |
| 710 | state->irq |= IRQ_M1_FDC; |
| 709 | 711 | cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); |
| 710 | 712 | } |
| 711 | 713 | } |
| r9674 | r9675 | |
| 717 | 719 | |
| 718 | 720 | static WRITE_LINE_DEVICE_HANDLER( trs80_fdc_intrq_w ) |
| 719 | 721 | { |
| 722 | trs80_state *drvstate = device->machine->driver_data<trs80_state>(); |
| 720 | 723 | if (state) |
| 721 | 724 | { |
| 722 | 725 | trs80_fdc_interrupt_internal(device->machine); |
| 723 | 726 | } |
| 724 | 727 | else |
| 725 | 728 | { |
| 726 | | if (trs80_model4) |
| 727 | | trs80_nmi_data = 0; |
| 729 | if (drvstate->model4) |
| 730 | drvstate->nmi_data = 0; |
| 728 | 731 | else |
| 729 | | trs80_irq &= ~IRQ_M1_FDC; |
| 732 | drvstate->irq &= ~IRQ_M1_FDC; |
| 730 | 733 | } |
| 731 | 734 | } |
| 732 | 735 | |
| r9674 | r9675 | |
| 755 | 758 | |
| 756 | 759 | READ8_HANDLER ( trs80_printer_r ) |
| 757 | 760 | { |
| 761 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 758 | 762 | /* Bit 7 - 1 = Busy; 0 = Not Busy |
| 759 | 763 | Bit 6 - 1 = Out of Paper; 0 = Paper |
| 760 | 764 | Bit 5 - 1 = Printer selected; 0 = Printer not selected |
| r9674 | r9675 | |
| 762 | 766 | Bits 3..0 - Not used */ |
| 763 | 767 | |
| 764 | 768 | UINT8 data = 0; |
| 765 | | data |= centronics_busy_r(trs80_printer) << 7; |
| 766 | | data |= centronics_pe_r(trs80_printer) << 6; |
| 767 | | data |= centronics_vcc_r(trs80_printer) << 5; |
| 768 | | data |= centronics_fault_r(trs80_printer) << 4; |
| 769 | data |= centronics_busy_r(state->printer) << 7; |
| 770 | data |= centronics_pe_r(state->printer) << 6; |
| 771 | data |= centronics_vcc_r(state->printer) << 5; |
| 772 | data |= centronics_fault_r(state->printer) << 4; |
| 769 | 773 | |
| 770 | 774 | return data; |
| 771 | 775 | } |
| 772 | 776 | |
| 773 | 777 | WRITE8_HANDLER( trs80_printer_w ) |
| 774 | 778 | { |
| 775 | | centronics_strobe_w(trs80_printer, 1); |
| 776 | | centronics_data_w(trs80_printer, 0, data); |
| 777 | | centronics_strobe_w(trs80_printer, 0); |
| 779 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 780 | centronics_strobe_w(state->printer, 1); |
| 781 | centronics_data_w(state->printer, 0, data); |
| 782 | centronics_strobe_w(state->printer, 0); |
| 778 | 783 | } |
| 779 | 784 | |
| 780 | 785 | WRITE8_HANDLER( trs80_cassunit_w ) |
| 781 | 786 | { |
| 787 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 782 | 788 | /* not emulated |
| 783 | 789 | 01 for unit 1 (default |
| 784 | 790 | 02 for unit 2 */ |
| 785 | 791 | |
| 786 | | trs80_tape_unit = data; |
| 792 | state->tape_unit = data; |
| 787 | 793 | } |
| 788 | 794 | |
| 789 | 795 | READ8_HANDLER( trs80_irq_status_r ) |
| 790 | 796 | { |
| 797 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 791 | 798 | /* (trs80l2) Whenever an interrupt occurs, 37E0 is read to see what devices require service. |
| 792 | 799 | d7 = RTC |
| 793 | 800 | d6 = FDC |
| r9674 | r9675 | |
| 795 | 802 | All interrupting devices are serviced in a single interrupt. There is a mask byte, |
| 796 | 803 | which is dealt with by the DOS. We take the opportunity to reset the cpu INT line. */ |
| 797 | 804 | |
| 798 | | int result = trs80_irq; |
| 805 | int result = state->irq; |
| 799 | 806 | cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); |
| 800 | | trs80_irq = 0; |
| 807 | state->irq = 0; |
| 801 | 808 | return result; |
| 802 | 809 | } |
| 803 | 810 | |
| 804 | 811 | |
| 805 | 812 | WRITE8_HANDLER( trs80_motor_w ) |
| 806 | 813 | { |
| 814 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 807 | 815 | UINT8 drive = 255; |
| 808 | 816 | |
| 809 | 817 | LOG(("trs80 motor_w $%02X\n", data)); |
| r9674 | r9675 | |
| 812 | 820 | { |
| 813 | 821 | case 1: |
| 814 | 822 | drive = 0; |
| 815 | | head = 0; |
| 823 | state->head = 0; |
| 816 | 824 | break; |
| 817 | 825 | case 2: |
| 818 | 826 | drive = 1; |
| 819 | | head = 0; |
| 827 | state->head = 0; |
| 820 | 828 | break; |
| 821 | 829 | case 4: |
| 822 | 830 | drive = 2; |
| 823 | | head = 0; |
| 831 | state->head = 0; |
| 824 | 832 | break; |
| 825 | 833 | case 8: |
| 826 | 834 | drive = 3; |
| 827 | | head = 0; |
| 835 | state->head = 0; |
| 828 | 836 | break; |
| 829 | 837 | /* These 3 combinations aren't official. Some manufacturers of double-sided disks |
| 830 | 838 | used drive select 4 to indicate the other side. */ |
| 831 | 839 | case 9: |
| 832 | 840 | drive = 0; |
| 833 | | head = 1; |
| 841 | state->head = 1; |
| 834 | 842 | break; |
| 835 | 843 | case 10: |
| 836 | 844 | drive = 1; |
| 837 | | head = 1; |
| 845 | state->head = 1; |
| 838 | 846 | break; |
| 839 | 847 | case 12: |
| 840 | 848 | drive = 2; |
| 841 | | head = 1; |
| 849 | state->head = 1; |
| 842 | 850 | break; |
| 843 | 851 | } |
| 844 | 852 | |
| r9674 | r9675 | |
| 851 | 859 | return; |
| 852 | 860 | } |
| 853 | 861 | |
| 854 | | wd17xx_set_drive(trs80_fdc,drive); |
| 855 | | wd17xx_set_side(trs80_fdc,head); |
| 862 | wd17xx_set_drive(state->fdc,drive); |
| 863 | wd17xx_set_side(state->fdc,state->head); |
| 856 | 864 | |
| 857 | 865 | /* Turn motors on */ |
| 858 | 866 | floppy_mon_w(floppy_get_device(space->machine, 0), CLEAR_LINE); |
| r9674 | r9675 | |
| 895 | 903 | |
| 896 | 904 | MACHINE_START( trs80 ) |
| 897 | 905 | { |
| 898 | | trs80_tape_unit=1; |
| 899 | | trs80_reg_load=1; |
| 900 | | trs80_nmi_data=0xff; |
| 906 | trs80_state *state = machine->driver_data<trs80_state>(); |
| 907 | state->tape_unit=1; |
| 908 | state->reg_load=1; |
| 909 | state->nmi_data=0xff; |
| 901 | 910 | |
| 902 | | cassette_data_timer = timer_alloc(machine, cassette_data_callback, NULL ); |
| 903 | | timer_adjust_periodic( cassette_data_timer, attotime_zero, 0, ATTOTIME_IN_HZ(11025) ); |
| 904 | | trs80_printer = machine->device("centronics"); |
| 905 | | trs80_ay31015 = machine->device("tr1602"); |
| 906 | | trs80_cass = machine->device("cassette"); |
| 907 | | trs80_speaker = machine->device("speaker"); |
| 908 | | trs80_fdc = machine->device("wd179x"); |
| 911 | state->cassette_data_timer = timer_alloc(machine, cassette_data_callback, NULL ); |
| 912 | timer_adjust_periodic( state->cassette_data_timer, attotime_zero, 0, ATTOTIME_IN_HZ(11025) ); |
| 913 | state->printer = machine->device("centronics"); |
| 914 | state->ay31015 = machine->device("tr1602"); |
| 915 | state->cass = machine->device("cassette"); |
| 916 | state->speaker = machine->device("speaker"); |
| 917 | state->fdc = machine->device("wd179x"); |
| 909 | 918 | } |
| 910 | 919 | |
| 911 | 920 | MACHINE_RESET( trs80 ) |
| 912 | 921 | { |
| 913 | | cassette_data = 0; |
| 922 | trs80_state *state = machine->driver_data<trs80_state>(); |
| 923 | state->cassette_data = 0; |
| 914 | 924 | } |
| 915 | 925 | |
| 916 | 926 | MACHINE_RESET( trs80m4 ) |
| 917 | 927 | { |
| 928 | trs80_state *state = machine->driver_data<trs80_state>(); |
| 918 | 929 | address_space *mem = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 919 | | cassette_data = 0; |
| 930 | state->cassette_data = 0; |
| 920 | 931 | |
| 921 | 932 | memory_install_read_bank (mem, 0x0000, 0x0fff, 0, 0, "bank1"); |
| 922 | 933 | memory_install_read_bank (mem, 0x1000, 0x37e7, 0, 0, "bank2"); |
| r9674 | r9675 | |
| 943 | 954 | |
| 944 | 955 | MACHINE_RESET( lnw80 ) |
| 945 | 956 | { |
| 957 | trs80_state *state = machine->driver_data<trs80_state>(); |
| 946 | 958 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 947 | | cassette_data = 0; |
| 948 | | trs80_reg_load = 1; |
| 959 | state->cassette_data = 0; |
| 960 | state->reg_load = 1; |
| 949 | 961 | lnw80_fe_w(space, 0, 0); |
| 950 | 962 | } |
| 951 | 963 | |
src/mess/video/mbee.c
| r9674 | r9675 | |
| 28 | 28 | #include "emu.h" |
| 29 | 29 | #include "includes/mbee.h" |
| 30 | 30 | |
| 31 | | static UINT8 framecnt = 0; |
| 32 | | static UINT8 *gfxram; |
| 33 | | static UINT8 *colorram; |
| 34 | | static UINT8 *videoram; |
| 35 | | static UINT8 *attribram; |
| 36 | | static UINT8 mbee_08; |
| 37 | | static UINT8 mbee_0b; |
| 38 | | static UINT8 mbee_1c; |
| 39 | | static UINT8 is_premium; |
| 40 | | static UINT8 sy6545_cursor[16]; |
| 41 | | static UINT8 sy6545_status = 0; |
| 42 | | static void sy6545_cursor_configure(void); |
| 43 | | static running_device *mc6845; |
| 44 | | static UINT8 speed,flash; |
| 45 | | static UINT16 cursor; |
| 46 | | static UINT8 sy6545_reg[32]; /* registers */ |
| 47 | | static UINT8 sy6545_ind; /* register index */ |
| 31 | static void sy6545_cursor_configure(mbee_state *state); |
| 48 | 32 | static const UINT8 sy6545_mask[32]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0,0x3f,0xff}; |
| 49 | 33 | |
| 50 | 34 | |
| r9674 | r9675 | |
| 57 | 41 | |
| 58 | 42 | READ8_HANDLER( mbee_low_r ) |
| 59 | 43 | { |
| 60 | | if (mbee_0b & 1) |
| 61 | | return gfxram[offset]; |
| 44 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 45 | if (state->_0b & 1) |
| 46 | return state->gfxram[offset]; |
| 62 | 47 | else |
| 63 | | return videoram[offset]; |
| 48 | return state->videoram[offset]; |
| 64 | 49 | } |
| 65 | 50 | |
| 66 | 51 | WRITE8_HANDLER( mbee_low_w ) |
| 67 | 52 | { |
| 68 | | videoram[offset] = data; |
| 53 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 54 | state->videoram[offset] = data; |
| 69 | 55 | } |
| 70 | 56 | |
| 71 | 57 | READ8_HANDLER( mbee_high_r ) |
| 72 | 58 | { |
| 73 | | return gfxram[0x800 | offset]; |
| 59 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 60 | return state->gfxram[0x800 | offset]; |
| 74 | 61 | } |
| 75 | 62 | |
| 76 | 63 | WRITE8_HANDLER( mbee_high_w ) |
| 77 | 64 | { |
| 78 | | gfxram[0x800 | offset] = data; |
| 65 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 66 | state->gfxram[0x800 | offset] = data; |
| 79 | 67 | } |
| 80 | 68 | |
| 81 | 69 | READ8_HANDLER ( mbee_0b_r ) |
| 82 | 70 | { |
| 83 | | return mbee_0b; |
| 71 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 72 | return state->_0b; |
| 84 | 73 | } |
| 85 | 74 | |
| 86 | 75 | WRITE8_HANDLER ( mbee_0b_w ) |
| 87 | 76 | { |
| 88 | | mbee_0b = data; |
| 77 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 78 | state->_0b = data; |
| 89 | 79 | } |
| 90 | 80 | |
| 91 | 81 | READ8_HANDLER ( mbeeic_08_r ) |
| 92 | 82 | { |
| 93 | | return mbee_08; |
| 83 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 84 | return state->_08; |
| 94 | 85 | } |
| 95 | 86 | |
| 96 | 87 | WRITE8_HANDLER ( mbeeic_08_w ) |
| 97 | 88 | { |
| 98 | | mbee_08 = data; |
| 89 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 90 | state->_08 = data; |
| 99 | 91 | } |
| 100 | 92 | |
| 101 | 93 | READ8_HANDLER( mbeeic_high_r ) |
| 102 | 94 | { |
| 103 | | if (mbee_08 & 0x40) |
| 104 | | return colorram[offset]; |
| 95 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 96 | if (state->_08 & 0x40) |
| 97 | return state->colorram[offset]; |
| 105 | 98 | else |
| 106 | | return gfxram[0x800 | offset]; |
| 99 | return state->gfxram[0x800 | offset]; |
| 107 | 100 | } |
| 108 | 101 | |
| 109 | 102 | WRITE8_HANDLER ( mbeeic_high_w ) |
| 110 | 103 | { |
| 111 | | if ((mbee_08 & 0x40) && (~mbee_0b & 1)) |
| 112 | | colorram[offset] = data; |
| 104 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 105 | if ((state->_08 & 0x40) && (~state->_0b & 1)) |
| 106 | state->colorram[offset] = data; |
| 113 | 107 | else |
| 114 | | gfxram[0x0800 | offset] = data; |
| 108 | state->gfxram[0x0800 | offset] = data; |
| 115 | 109 | } |
| 116 | 110 | |
| 117 | 111 | READ8_HANDLER ( mbeeppc_1c_r ) |
| 118 | 112 | { |
| 119 | | return mbee_1c; |
| 113 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 114 | return state->_1c; |
| 120 | 115 | } |
| 121 | 116 | |
| 122 | 117 | WRITE8_HANDLER( mbeeppc_1c_w ) |
| 123 | 118 | { |
| 119 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 124 | 120 | /* d7 extended graphics (1=allow attributes and pcg banks) |
| 125 | 121 | d5 bankswitch basic rom |
| 126 | 122 | d4 select attribute ram |
| 127 | | d3..d0 select videoram bank */ |
| 123 | d3..d0 select state->videoram bank */ |
| 128 | 124 | |
| 129 | | mbee_1c = data; |
| 125 | state->_1c = data; |
| 130 | 126 | memory_set_bank(space->machine, "basic", (data & 0x20) ? 1 : 0); |
| 131 | 127 | } |
| 132 | 128 | |
| 133 | 129 | WRITE8_HANDLER( mbee256_1c_w ) |
| 134 | 130 | { |
| 131 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 135 | 132 | /* d7 extended graphics (1=allow attributes and pcg banks) |
| 136 | 133 | d5 bankswitch basic rom |
| 137 | 134 | d4 select attribute ram |
| 138 | | d3..d0 select videoram bank */ |
| 135 | d3..d0 select state->videoram bank */ |
| 139 | 136 | |
| 140 | | mbee_1c = data; |
| 137 | state->_1c = data; |
| 141 | 138 | } |
| 142 | 139 | |
| 143 | 140 | READ8_HANDLER( mbeeppc_low_r ) |
| 144 | 141 | { |
| 145 | | if ((mbee_1c & 0x1f) == 0x10) |
| 146 | | return attribram[offset]; |
| 142 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 143 | if ((state->_1c & 0x1f) == 0x10) |
| 144 | return state->attribram[offset]; |
| 147 | 145 | else |
| 148 | | if (mbee_0b & 1) |
| 149 | | return gfxram[offset]; |
| 146 | if (state->_0b & 1) |
| 147 | return state->gfxram[offset]; |
| 150 | 148 | else |
| 151 | | return videoram[offset]; |
| 149 | return state->videoram[offset]; |
| 152 | 150 | } |
| 153 | 151 | |
| 154 | 152 | WRITE8_HANDLER( mbeeppc_low_w ) |
| 155 | 153 | { |
| 156 | | if (mbee_1c & 16) |
| 157 | | attribram[offset] = data; |
| 154 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 155 | if (state->_1c & 16) |
| 156 | state->attribram[offset] = data; |
| 158 | 157 | else |
| 159 | | videoram[offset] = data; |
| 158 | state->videoram[offset] = data; |
| 160 | 159 | } |
| 161 | 160 | |
| 162 | 161 | READ8_HANDLER( mbeeppc_high_r ) |
| 163 | 162 | { |
| 164 | | if (mbee_08 & 0x40) |
| 165 | | return colorram[offset]; |
| 163 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 164 | if (state->_08 & 0x40) |
| 165 | return state->colorram[offset]; |
| 166 | 166 | else |
| 167 | | return gfxram[(((mbee_1c & 15) + 1) << 11) | offset]; |
| 167 | return state->gfxram[(((state->_1c & 15) + 1) << 11) | offset]; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | WRITE8_HANDLER ( mbeeppc_high_w ) |
| 171 | 171 | { |
| 172 | | if ((mbee_08 & 0x40) && (~mbee_0b & 1)) |
| 173 | | colorram[offset] = data; |
| 172 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 173 | if ((state->_08 & 0x40) && (~state->_0b & 1)) |
| 174 | state->colorram[offset] = data; |
| 174 | 175 | else |
| 175 | | gfxram[(((mbee_1c & 15) + 1) << 11) | offset] = data; |
| 176 | state->gfxram[(((state->_1c & 15) + 1) << 11) | offset] = data; |
| 176 | 177 | } |
| 177 | 178 | |
| 178 | 179 | |
| r9674 | r9675 | |
| 187 | 188 | /* The direction keys are used by the pc85 menu. Do not know what uses the "insert" key. */ |
| 188 | 189 | static void keyboard_matrix_r(running_machine *machine, int offs) |
| 189 | 190 | { |
| 191 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 190 | 192 | UINT8 port = (offs >> 7) & 7; |
| 191 | 193 | UINT8 bit = (offs >> 4) & 7; |
| 192 | 194 | UINT8 data = (input_port_read(machine, keynames[port]) >> bit) & 1; |
| 193 | 195 | |
| 194 | | if ((data | is_premium) == 0) |
| 196 | if ((data | state->is_premium) == 0) |
| 195 | 197 | { |
| 196 | 198 | UINT8 extra = input_port_read(machine, "EXTRA"); |
| 197 | 199 | |
| r9674 | r9675 | |
| 231 | 233 | |
| 232 | 234 | if( data ) |
| 233 | 235 | { |
| 234 | | sy6545_reg[17] = offs; |
| 235 | | sy6545_reg[16] = (offs >> 8) & 0x3f; |
| 236 | | sy6545_status |= 0x40; //lpen_strobe |
| 236 | state->sy6545_reg[17] = offs; |
| 237 | state->sy6545_reg[16] = (offs >> 8) & 0x3f; |
| 238 | state->sy6545_status |= 0x40; //lpen_strobe |
| 237 | 239 | } |
| 238 | 240 | } |
| 239 | 241 | |
| 240 | 242 | |
| 241 | 243 | static void mbee_video_kbd_scan( running_machine *machine, int param ) |
| 242 | 244 | { |
| 243 | | if (mbee_0b) return; |
| 245 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 246 | if (state->_0b) return; |
| 244 | 247 | |
| 245 | 248 | keyboard_matrix_r(machine, param); |
| 246 | 249 | } |
| r9674 | r9675 | |
| 254 | 257 | |
| 255 | 258 | READ8_HANDLER ( m6545_status_r ) |
| 256 | 259 | { |
| 260 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 257 | 261 | screen_device *screen = screen_first(*space->machine); |
| 258 | 262 | const rectangle &visarea = screen->visible_area(); |
| 259 | 263 | |
| 260 | | UINT8 data = sy6545_status; // bit 6 = lpen strobe, bit 7 = update strobe |
| 264 | UINT8 data = state->sy6545_status; // bit 6 = lpen strobe, bit 7 = update strobe |
| 261 | 265 | int y = space->machine->primary_screen->vpos(); |
| 262 | 266 | |
| 263 | 267 | if( y < visarea.min_y || y > visarea.max_y ) |
| r9674 | r9675 | |
| 268 | 272 | |
| 269 | 273 | READ8_HANDLER ( m6545_data_r ) |
| 270 | 274 | { |
| 275 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 271 | 276 | UINT16 addr; |
| 272 | | UINT8 data = mc6845_register_r(mc6845, 0); |
| 277 | UINT8 data = mc6845_register_r(state->mc6845, 0); |
| 273 | 278 | |
| 274 | | switch( sy6545_ind ) |
| 279 | switch( state->sy6545_ind ) |
| 275 | 280 | { |
| 276 | 281 | case 16: |
| 277 | 282 | case 17: |
| 278 | | sy6545_status &= 0x80; // turn off lpen_strobe |
| 283 | state->sy6545_status &= 0x80; // turn off lpen_strobe |
| 279 | 284 | break; |
| 280 | 285 | case 31: |
| 281 | 286 | /* This firstly pushes the contents of the transparent registers onto the MA lines, |
| 282 | 287 | then increments the address, then sets update strobe on. */ |
| 283 | | addr = (sy6545_reg[18] << 8) | sy6545_reg[19]; |
| 288 | addr = (state->sy6545_reg[18] << 8) | state->sy6545_reg[19]; |
| 284 | 289 | keyboard_matrix_r(space->machine, addr); |
| 285 | | sy6545_reg[19]++; |
| 286 | | if (!sy6545_reg[19]) sy6545_reg[18]++; |
| 287 | | sy6545_status |= 0x80; // update_strobe |
| 290 | state->sy6545_reg[19]++; |
| 291 | if (!state->sy6545_reg[19]) state->sy6545_reg[18]++; |
| 292 | state->sy6545_status |= 0x80; // update_strobe |
| 288 | 293 | break; |
| 289 | 294 | } |
| 290 | 295 | return data; |
| r9674 | r9675 | |
| 292 | 297 | |
| 293 | 298 | WRITE8_HANDLER ( m6545_index_w ) |
| 294 | 299 | { |
| 300 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 295 | 301 | data &= 0x1f; |
| 296 | | sy6545_ind = data; |
| 297 | | mc6845_address_w( mc6845, 0, data ); |
| 302 | state->sy6545_ind = data; |
| 303 | mc6845_address_w( state->mc6845, 0, data ); |
| 298 | 304 | } |
| 299 | 305 | |
| 300 | 306 | WRITE8_HANDLER ( m6545_data_w ) |
| 301 | 307 | { |
| 308 | mbee_state *state = space->machine->driver_data<mbee_state>(); |
| 302 | 309 | int addr = 0; |
| 303 | 310 | |
| 304 | | switch( sy6545_ind ) |
| 311 | switch( state->sy6545_ind ) |
| 305 | 312 | { |
| 306 | 313 | case 12: |
| 307 | 314 | data &= 0x3f; // select alternate character set |
| 308 | | if( sy6545_reg[12] != data ) |
| 309 | | memcpy(gfxram, memory_region(space->machine, "gfx") + (((data & 0x30) == 0x20) << 11), 0x800); |
| 315 | if( state->sy6545_reg[12] != data ) |
| 316 | memcpy(state->gfxram, memory_region(space->machine, "gfx") + (((data & 0x30) == 0x20) << 11), 0x800); |
| 310 | 317 | break; |
| 311 | 318 | case 31: |
| 312 | 319 | /* This firstly pushes the contents of the transparent registers onto the MA lines, |
| 313 | 320 | then increments the address, then sets update strobe on. */ |
| 314 | | addr = (sy6545_reg[18] << 8) | sy6545_reg[19]; |
| 321 | addr = (state->sy6545_reg[18] << 8) | state->sy6545_reg[19]; |
| 315 | 322 | keyboard_matrix_r(space->machine, addr); |
| 316 | | sy6545_reg[19]++; |
| 317 | | if (!sy6545_reg[19]) sy6545_reg[18]++; |
| 318 | | sy6545_status |= 0x80; // update_strobe |
| 323 | state->sy6545_reg[19]++; |
| 324 | if (!state->sy6545_reg[19]) state->sy6545_reg[18]++; |
| 325 | state->sy6545_status |= 0x80; // update_strobe |
| 319 | 326 | break; |
| 320 | 327 | } |
| 321 | | sy6545_reg[sy6545_ind] = data & sy6545_mask[sy6545_ind]; /* save data in register */ |
| 322 | | mc6845_register_w( mc6845, 0, data ); |
| 323 | | if ((sy6545_ind > 8) && (sy6545_ind < 12)) sy6545_cursor_configure(); /* adjust cursor shape - remove when mame fixed */ |
| 328 | state->sy6545_reg[state->sy6545_ind] = data & sy6545_mask[state->sy6545_ind]; /* save data in register */ |
| 329 | mc6845_register_w( state->mc6845, 0, data ); |
| 330 | if ((state->sy6545_ind > 8) && (state->sy6545_ind < 12)) sy6545_cursor_configure(state); /* adjust cursor shape - remove when mame fixed */ |
| 324 | 331 | } |
| 325 | 332 | |
| 326 | 333 | |
| r9674 | r9675 | |
| 334 | 341 | |
| 335 | 342 | ************************************************************/ |
| 336 | 343 | |
| 337 | | static void sy6545_cursor_configure(void) |
| 344 | static void sy6545_cursor_configure(mbee_state *state) |
| 338 | 345 | { |
| 339 | 346 | UINT8 i,curs_type=0,r9,r10,r11; |
| 340 | 347 | |
| r9674 | r9675 | |
| 344 | 351 | 2 = full cursor |
| 345 | 352 | 3 = two-part cursor (has a part at the top and bottom with the middle blank) */ |
| 346 | 353 | |
| 347 | | for ( i = 0; i < ARRAY_LENGTH(sy6545_cursor); i++) sy6545_cursor[i] = 0; // prepare cursor by erasing old one |
| 354 | for ( i = 0; i < ARRAY_LENGTH(state->sy6545_cursor); i++) state->sy6545_cursor[i] = 0; // prepare cursor by erasing old one |
| 348 | 355 | |
| 349 | | r9 = sy6545_reg[9]; // number of scan lines - 1 |
| 350 | | r10 = sy6545_reg[10] & 0x1f; // cursor start line = last 5 bits |
| 351 | | r11 = sy6545_reg[11]+1; // cursor end line incremented to suit for-loops below |
| 356 | r9 = state->sy6545_reg[9]; // number of scan lines - 1 |
| 357 | r10 = state->sy6545_reg[10] & 0x1f; // cursor start line = last 5 bits |
| 358 | r11 = state->sy6545_reg[11]+1; // cursor end line incremented to suit for-loops below |
| 352 | 359 | |
| 353 | 360 | /* decide the curs_type by examining the registers */ |
| 354 | 361 | if (r10 < r11) curs_type=1; // start less than end, show start to end |
| r9674 | r9675 | |
| 361 | 368 | if (r11 > 16) r11=16; // truncate 5-bit register to fit our 4-bit hardware |
| 362 | 369 | |
| 363 | 370 | /* create the new cursor */ |
| 364 | | if (curs_type > 1) for (i = 0;i < ARRAY_LENGTH(sy6545_cursor);i++) sy6545_cursor[i]=0xff; // turn on full cursor |
| 371 | if (curs_type > 1) for (i = 0;i < ARRAY_LENGTH(state->sy6545_cursor);i++) state->sy6545_cursor[i]=0xff; // turn on full cursor |
| 365 | 372 | |
| 366 | | if (curs_type == 1) for (i = r10;i < r11;i++) sy6545_cursor[i]=0xff; // for each line that should show, turn on that scan line |
| 373 | if (curs_type == 1) for (i = r10;i < r11;i++) state->sy6545_cursor[i]=0xff; // for each line that should show, turn on that scan line |
| 367 | 374 | |
| 368 | | if (curs_type == 3) for (i = r11; i < r10;i++) sy6545_cursor[i]=0; // now take a bite out of the middle |
| 375 | if (curs_type == 3) for (i = r11; i < r10;i++) state->sy6545_cursor[i]=0; // now take a bite out of the middle |
| 369 | 376 | } |
| 370 | 377 | |
| 371 | 378 | |
| r9674 | r9675 | |
| 379 | 386 | |
| 380 | 387 | VIDEO_START( mbee ) |
| 381 | 388 | { |
| 382 | | mc6845 = machine->device("crtc"); |
| 383 | | videoram = memory_region(machine, "videoram"); |
| 384 | | gfxram = memory_region(machine, "gfx")+0x1000; |
| 385 | | is_premium = 0; |
| 389 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 390 | state->mc6845 = machine->device("crtc"); |
| 391 | state->videoram = memory_region(machine, "videoram"); |
| 392 | state->gfxram = memory_region(machine, "gfx")+0x1000; |
| 393 | state->is_premium = 0; |
| 386 | 394 | } |
| 387 | 395 | |
| 388 | 396 | VIDEO_START( mbeeic ) |
| 389 | 397 | { |
| 390 | | mc6845 = machine->device("crtc"); |
| 391 | | videoram = memory_region(machine, "videoram"); |
| 392 | | colorram = memory_region(machine, "colorram"); |
| 393 | | gfxram = memory_region(machine, "gfx")+0x1000; |
| 394 | | is_premium = 0; |
| 398 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 399 | state->mc6845 = machine->device("crtc"); |
| 400 | state->videoram = memory_region(machine, "videoram"); |
| 401 | state->colorram = memory_region(machine, "colorram"); |
| 402 | state->gfxram = memory_region(machine, "gfx")+0x1000; |
| 403 | state->is_premium = 0; |
| 395 | 404 | } |
| 396 | 405 | |
| 397 | 406 | VIDEO_START( mbeeppc ) |
| 398 | 407 | { |
| 399 | | mc6845 = machine->device("crtc"); |
| 400 | | videoram = memory_region(machine, "videoram"); |
| 401 | | colorram = memory_region(machine, "colorram"); |
| 402 | | gfxram = memory_region(machine, "gfx")+0x1000; |
| 403 | | attribram = memory_region(machine, "attrib"); |
| 404 | | is_premium = 1; |
| 408 | mbee_state *state = machine->driver_data<mbee_state>(); |
| 409 | state->mc6845 = machine->device("crtc"); |
| 410 | state->videoram = memory_region(machine, "videoram"); |
| 411 | state->colorram = memory_region(machine, "colorram"); |
| 412 | state->gfxram = memory_region(machine, "gfx")+0x1000; |
| 413 | state->attribram = memory_region(machine, "attrib"); |
| 414 | state->is_premium = 1; |
| 405 | 415 | } |
| 406 | 416 | |
| 407 | 417 | VIDEO_UPDATE( mbee ) |
| 408 | 418 | { |
| 409 | | framecnt++; |
| 410 | | speed = sy6545_reg[10]&0x20, flash = sy6545_reg[10]&0x40; // cursor modes |
| 411 | | cursor = (sy6545_reg[14]<<8) | sy6545_reg[15]; // get cursor position |
| 412 | | mc6845_update(mc6845, bitmap, cliprect); |
| 419 | mbee_state *state = screen->machine->driver_data<mbee_state>(); |
| 420 | state->framecnt++; |
| 421 | state->speed = state->sy6545_reg[10]&0x20, state->flash = state->sy6545_reg[10]&0x40; // cursor modes |
| 422 | state->cursor = (state->sy6545_reg[14]<<8) | state->sy6545_reg[15]; // get cursor position |
| 423 | mc6845_update(state->mc6845, bitmap, cliprect); |
| 413 | 424 | return 0; |
| 414 | 425 | } |
| 415 | 426 | |
| r9674 | r9675 | |
| 428 | 439 | /* monochrome bee */ |
| 429 | 440 | MC6845_UPDATE_ROW( mbee_update_row ) |
| 430 | 441 | { |
| 442 | mbee_state *state = device->machine->driver_data<mbee_state>(); |
| 431 | 443 | UINT8 chr,gfx; |
| 432 | 444 | UINT16 mem,x; |
| 433 | 445 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| r9674 | r9675 | |
| 436 | 448 | { |
| 437 | 449 | UINT8 inv=0; |
| 438 | 450 | mem = (ma + x) & 0x7ff; |
| 439 | | chr = videoram[mem]; |
| 451 | chr = state->videoram[mem]; |
| 440 | 452 | |
| 441 | 453 | mbee_video_kbd_scan(device->machine, x+ma); |
| 442 | 454 | |
| 443 | 455 | /* process cursor */ |
| 444 | | if ((((!flash) && (!speed)) || // (5,6)=(0,0) = cursor on always |
| 445 | | ((flash) && (speed) && (framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| 446 | | ((flash) && (!speed) && (framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames |
| 447 | | (mem == cursor)) // displaying at cursor position? |
| 448 | | inv ^= sy6545_cursor[ra]; // cursor scan row |
| 456 | if ((((!state->flash) && (!state->speed)) || // (5,6)=(0,0) = cursor on always |
| 457 | ((state->flash) && (state->speed) && (state->framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| 458 | ((state->flash) && (!state->speed) && (state->framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames |
| 459 | (mem == state->cursor)) // displaying at cursor position? |
| 460 | inv ^= state->sy6545_cursor[ra]; // cursor scan row |
| 449 | 461 | |
| 450 | 462 | /* get pattern of pixels for that character scanline */ |
| 451 | | gfx = gfxram[(chr<<4) | ra] ^ inv; |
| 463 | gfx = state->gfxram[(chr<<4) | ra] ^ inv; |
| 452 | 464 | |
| 453 | 465 | /* Display a scanline of a character (8 pixels) */ |
| 454 | 466 | *p++ = ( gfx & 0x80 ) ? 1 : 0; |
| r9674 | r9675 | |
| 465 | 477 | /* prom-based colours */ |
| 466 | 478 | MC6845_UPDATE_ROW( mbeeic_update_row ) |
| 467 | 479 | { |
| 480 | mbee_state *state = device->machine->driver_data<mbee_state>(); |
| 468 | 481 | UINT8 chr,gfx,fg,bg; |
| 469 | 482 | UINT16 mem,x,col; |
| 470 | | UINT16 colourm = (mbee_08 & 0x0e) << 7; |
| 483 | UINT16 colourm = (state->_08 & 0x0e) << 7; |
| 471 | 484 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 472 | 485 | |
| 473 | 486 | for (x = 0; x < x_count; x++) // for each character |
| 474 | 487 | { |
| 475 | 488 | UINT8 inv=0; |
| 476 | 489 | mem = (ma + x) & 0x7ff; |
| 477 | | chr = videoram[mem]; |
| 478 | | col = colorram[mem] | colourm; // read a byte of colour |
| 490 | chr = state->videoram[mem]; |
| 491 | col = state->colorram[mem] | colourm; // read a byte of colour |
| 479 | 492 | |
| 480 | 493 | mbee_video_kbd_scan(device->machine, x+ma); |
| 481 | 494 | |
| 482 | 495 | /* process cursor */ |
| 483 | | if ((((!flash) && (!speed)) || // (5,6)=(0,0) = cursor on always |
| 484 | | ((flash) && (speed) && (framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| 485 | | ((flash) && (!speed) && (framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames |
| 486 | | (mem == cursor)) // displaying at cursor position? |
| 487 | | inv ^= sy6545_cursor[ra]; // cursor scan row |
| 496 | if ((((!state->flash) && (!state->speed)) || // (5,6)=(0,0) = cursor on always |
| 497 | ((state->flash) && (state->speed) && (state->framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| 498 | ((state->flash) && (!state->speed) && (state->framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames |
| 499 | (mem == state->cursor)) // displaying at cursor position? |
| 500 | inv ^= state->sy6545_cursor[ra]; // cursor scan row |
| 488 | 501 | |
| 489 | 502 | /* get pattern of pixels for that character scanline */ |
| 490 | | gfx = gfxram[(chr<<4) | ra] ^ inv; |
| 503 | gfx = state->gfxram[(chr<<4) | ra] ^ inv; |
| 491 | 504 | fg = (col & 0x001f) | 64; // map to foreground palette |
| 492 | 505 | bg = (col & 0x07e0) >> 5; // and background palette |
| 493 | 506 | |
| r9674 | r9675 | |
| 507 | 520 | /* new colours & hires2 */ |
| 508 | 521 | MC6845_UPDATE_ROW( mbeeppc_update_row ) |
| 509 | 522 | { |
| 523 | mbee_state *state = device->machine->driver_data<mbee_state>(); |
| 510 | 524 | UINT8 gfx,fg,bg; |
| 511 | 525 | UINT16 mem,x,col,chr; |
| 512 | 526 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| r9674 | r9675 | |
| 515 | 529 | { |
| 516 | 530 | UINT8 inv=0; |
| 517 | 531 | mem = (ma + x) & 0x7ff; |
| 518 | | chr = videoram[mem]; |
| 519 | | col = colorram[mem]; // read a byte of colour |
| 532 | chr = state->videoram[mem]; |
| 533 | col = state->colorram[mem]; // read a byte of colour |
| 520 | 534 | |
| 521 | | if (mbee_1c & 0x80) // are extended features enabled? |
| 535 | if (state->_1c & 0x80) // are extended features enabled? |
| 522 | 536 | { |
| 523 | | UINT8 attr = attribram[mem]; |
| 537 | UINT8 attr = state->attribram[mem]; |
| 524 | 538 | |
| 525 | 539 | if (chr & 0x80) |
| 526 | 540 | chr += ((attr & 15) << 7); // bump chr to its particular pcg definition |
| r9674 | r9675 | |
| 528 | 542 | if (attr & 0x40) |
| 529 | 543 | inv ^= 0xff; // inverse attribute |
| 530 | 544 | |
| 531 | | if ((attr & 0x80) && (framecnt & 0x10)) // flashing attribute |
| 545 | if ((attr & 0x80) && (state->framecnt & 0x10)) // flashing attribute |
| 532 | 546 | chr = 0x20; |
| 533 | 547 | } |
| 534 | 548 | |
| 535 | 549 | mbee_video_kbd_scan(device->machine, x+ma); |
| 536 | 550 | |
| 537 | 551 | /* process cursor */ |
| 538 | | if ((((!flash) && (!speed)) || // (5,6)=(0,0) = cursor on always |
| 539 | | ((flash) && (speed) && (framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| 540 | | ((flash) && (!speed) && (framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames |
| 541 | | (mem == cursor)) // displaying at cursor position? |
| 542 | | inv ^= sy6545_cursor[ra]; // cursor scan row |
| 552 | if ((((!state->flash) && (!state->speed)) || // (5,6)=(0,0) = cursor on always |
| 553 | ((state->flash) && (state->speed) && (state->framecnt & 0x10)) || // (5,6)=(1,1) = cycle per 32 frames |
| 554 | ((state->flash) && (!state->speed) && (state->framecnt & 8))) && // (5,6)=(0,1) = cycle per 16 frames |
| 555 | (mem == state->cursor)) // displaying at cursor position? |
| 556 | inv ^= state->sy6545_cursor[ra]; // cursor scan row |
| 543 | 557 | |
| 544 | 558 | /* get pattern of pixels for that character scanline */ |
| 545 | | gfx = gfxram[(chr<<4) | ra] ^ inv; |
| 559 | gfx = state->gfxram[(chr<<4) | ra] ^ inv; |
| 546 | 560 | fg = col & 15; // map to foreground palette |
| 547 | 561 | bg = (col & 0xf0) >> 4; // and background palette |
| 548 | 562 | |
src/mess/video/trs80.c
| r9674 | r9675 | |
| 18 | 18 | d1 7 or 8 bit video (1=requires 7-bit, 0=don't care) |
| 19 | 19 | d0 80/64 or 40/32 characters per line (1=32) */ |
| 20 | 20 | |
| 21 | | static UINT16 start_address=0; |
| 22 | | static UINT8 crtc_reg; |
| 23 | | static UINT8 trs80_size_store; |
| 24 | 21 | |
| 25 | 22 | WRITE8_HANDLER( trs80m4_88_w ) |
| 26 | 23 | { |
| 24 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 27 | 25 | /* This is for the programming of the CRTC registers. |
| 28 | 26 | However this CRTC is mask-programmed, and only the |
| 29 | 27 | start address register can be used. The cursor and |
| r9674 | r9675 | |
| 32 | 30 | Therefore it is easier to use normal |
| 33 | 31 | coding rather than the mc6845 device. */ |
| 34 | 32 | |
| 35 | | if (!offset) crtc_reg = data & 0x1f; |
| 33 | if (!offset) state->crtc_reg = data & 0x1f; |
| 36 | 34 | |
| 37 | | if (offset) switch (crtc_reg) |
| 35 | if (offset) switch (state->crtc_reg) |
| 38 | 36 | { |
| 39 | 37 | case 12: |
| 40 | | start_address = (start_address & 0x00ff) | (data << 8); |
| 38 | state->start_address = (state->start_address & 0x00ff) | (data << 8); |
| 41 | 39 | break; |
| 42 | 40 | case 13: |
| 43 | | start_address = (start_address & 0xff00) | data; |
| 41 | state->start_address = (state->start_address & 0xff00) | data; |
| 44 | 42 | } |
| 45 | 43 | } |
| 46 | 44 | |
| 47 | 45 | |
| 48 | 46 | VIDEO_START( trs80 ) |
| 49 | 47 | { |
| 50 | | trs80_size_store = 0xff; |
| 51 | | trs80_mode &= 2; |
| 48 | trs80_state *state = machine->driver_data<trs80_state>(); |
| 49 | state->size_store = 0xff; |
| 50 | state->mode &= 2; |
| 52 | 51 | } |
| 53 | 52 | |
| 54 | 53 | |
| r9674 | r9675 | |
| 60 | 59 | UINT8 y,ra,chr,gfx,gfxbit; |
| 61 | 60 | UINT16 sy=0,ma=0,x; |
| 62 | 61 | UINT8 *FNT = memory_region(screen->machine, "gfx1"); |
| 63 | | UINT8 cols = (trs80_mode & 1) ? 32 : 64; |
| 64 | | UINT8 skip = (trs80_mode & 1) ? 2 : 1; |
| 62 | UINT8 cols = (state->mode & 1) ? 32 : 64; |
| 63 | UINT8 skip = (state->mode & 1) ? 2 : 1; |
| 65 | 64 | |
| 66 | | if (trs80_mode != trs80_size_store) |
| 65 | if (state->mode != state->size_store) |
| 67 | 66 | { |
| 68 | | trs80_size_store = trs80_mode & 1; |
| 67 | state->size_store = state->mode & 1; |
| 69 | 68 | screen->set_visible_area(0, cols*FW-1, 0, 16*FH-1); |
| 70 | 69 | } |
| 71 | 70 | |
| r9674 | r9675 | |
| 93 | 92 | } |
| 94 | 93 | else |
| 95 | 94 | { |
| 96 | | if ((trs80_mode & 2) && (chr < 32)) chr+=64; |
| 95 | if ((state->mode & 2) && (chr < 32)) chr+=64; |
| 97 | 96 | |
| 98 | 97 | /* get pattern of pixels for that character scanline */ |
| 99 | 98 | if (ra < 8) |
| r9674 | r9675 | |
| 125 | 124 | UINT16 sy=0,ma=0,x; |
| 126 | 125 | UINT8 *FNT = memory_region(screen->machine, "gfx1"); |
| 127 | 126 | UINT8 skip=1; |
| 128 | | UINT8 cols = (trs80_mode & 4) ? 80 : 64; |
| 129 | | UINT8 rows = (trs80_mode & 4) ? 24 : 16; |
| 130 | | UINT8 lines = (trs80_mode & 4) ? 10 : 12; |
| 127 | UINT8 cols = (state->mode & 4) ? 80 : 64; |
| 128 | UINT8 rows = (state->mode & 4) ? 24 : 16; |
| 129 | UINT8 lines = (state->mode & 4) ? 10 : 12; |
| 131 | 130 | UINT8 s_cols = cols; |
| 132 | | UINT8 mask = (trs80_mode & 0x20) ? 0xff : 0xbf; /* Select Japanese or extended chars */ |
| 131 | UINT8 mask = (state->mode & 0x20) ? 0xff : 0xbf; /* Select Japanese or extended chars */ |
| 133 | 132 | |
| 134 | | if (trs80_mode & 1) |
| 133 | if (state->mode & 1) |
| 135 | 134 | { |
| 136 | 135 | s_cols >>= 1; |
| 137 | 136 | skip = 2; |
| 138 | 137 | } |
| 139 | 138 | |
| 140 | | if ((trs80_mode & 0x7f) != trs80_size_store) |
| 139 | if ((state->mode & 0x7f) != state->size_store) |
| 141 | 140 | { |
| 142 | | trs80_size_store = trs80_mode & 5; |
| 141 | state->size_store = state->mode & 5; |
| 143 | 142 | screen->set_visible_area(0, s_cols*8-1, 0, rows*lines-1); |
| 144 | 143 | } |
| 145 | 144 | |
| r9674 | r9675 | |
| 151 | 150 | |
| 152 | 151 | for (x = ma; x < ma + cols; x+=skip) |
| 153 | 152 | { |
| 154 | | chr = videoram[x+start_address]; |
| 153 | chr = videoram[x+state->start_address]; |
| 155 | 154 | |
| 156 | | if (((chr & 0xc0) == 0xc0) && (~trs80_mode & 8)) |
| 155 | if (((chr & 0xc0) == 0xc0) && (~state->mode & 8)) |
| 157 | 156 | { |
| 158 | 157 | if (ra < 8) |
| 159 | 158 | gfx = FNT[((chr&mask)<<3) | ra ]; |
| r9674 | r9675 | |
| 170 | 169 | *p++ = ( gfx & 0x01 ) ? 1 : 0; |
| 171 | 170 | } |
| 172 | 171 | else |
| 173 | | if ((chr & 0x80) && (~trs80_mode & 8)) |
| 172 | if ((chr & 0x80) && (~state->mode & 8)) |
| 174 | 173 | { |
| 175 | 174 | gfxbit = 1<<((ra & 0x0c)>>1); |
| 176 | 175 | /* Display one line of a lores character */ |
| r9674 | r9675 | |
| 193 | 192 | gfx = 0; |
| 194 | 193 | |
| 195 | 194 | /* if inverse mode, and bit 7 set, invert gfx */ |
| 196 | | if ((trs80_mode & 8) && (chr & 0x80)) |
| 195 | if ((state->mode & 8) && (chr & 0x80)) |
| 197 | 196 | gfx ^= 0xff; |
| 198 | 197 | |
| 199 | 198 | /* Display a scanline of a character */ |
| r9674 | r9675 | |
| 221 | 220 | UINT8 y,ra,chr,gfx,gfxbit; |
| 222 | 221 | UINT16 sy=0,ma=0,x; |
| 223 | 222 | UINT8 *FNT = memory_region(screen->machine, "gfx1"); |
| 224 | | UINT8 cols = (trs80_mode & 1) ? 32 : 64; |
| 225 | | UINT8 skip = (trs80_mode & 1) ? 2 : 1; |
| 223 | UINT8 cols = (state->mode & 1) ? 32 : 64; |
| 224 | UINT8 skip = (state->mode & 1) ? 2 : 1; |
| 226 | 225 | |
| 227 | | if (trs80_mode != trs80_size_store) |
| 226 | if (state->mode != state->size_store) |
| 228 | 227 | { |
| 229 | | trs80_size_store = trs80_mode & 1; |
| 228 | state->size_store = state->mode & 1; |
| 230 | 229 | screen->set_visible_area(0, cols*FW-1, 0, 16*FH-1); |
| 231 | 230 | } |
| 232 | 231 | |
| r9674 | r9675 | |
| 254 | 253 | } |
| 255 | 254 | else |
| 256 | 255 | { |
| 257 | | if ((trs80_mode & 2) && (chr < 32)) chr+=64; |
| 256 | if ((state->mode & 2) && (chr < 32)) chr+=64; |
| 258 | 257 | |
| 259 | 258 | /* get pattern of pixels for that character scanline */ |
| 260 | 259 | gfx = FNT[(chr<<4) | ra ]; |
| r9674 | r9675 | |
| 283 | 282 | UINT8 chr,gfx,gfxbit,bg=7,fg=0; |
| 284 | 283 | UINT16 sy=0,ma=0,x,y,ra; |
| 285 | 284 | UINT8 *FNT = memory_region(screen->machine, "gfx1"); |
| 286 | | UINT8 cols = (trs80_mode & 0x10) ? 80 : 64; |
| 285 | UINT8 cols = (state->mode & 0x10) ? 80 : 64; |
| 287 | 286 | |
| 288 | 287 | /* Although the OS can select 32-character mode, it is not supported by hardware */ |
| 289 | | if (trs80_mode != trs80_size_store) |
| 288 | if (state->mode != state->size_store) |
| 290 | 289 | { |
| 291 | | trs80_size_store = trs80_mode & 0x10; |
| 290 | state->size_store = state->mode & 0x10; |
| 292 | 291 | screen->set_visible_area(0, cols*FW-1, 0, 16*FH-1); |
| 293 | 292 | } |
| 294 | 293 | |
| 295 | | if (trs80_mode & 8) |
| 294 | if (state->mode & 8) |
| 296 | 295 | { |
| 297 | 296 | bg = 0; |
| 298 | 297 | fg = 7; |
| 299 | 298 | } |
| 300 | 299 | |
| 301 | | switch (trs80_mode & 0x30) |
| 300 | switch (state->mode & 0x30) |
| 302 | 301 | { |
| 303 | 302 | case 0: // MODE 0 |
| 304 | 303 | for (y = 0; y < 16; y++) |
| r9674 | r9675 | |
| 354 | 353 | |
| 355 | 354 | for (x = 0; x < 0x40; x++) |
| 356 | 355 | { |
| 357 | | gfx = trs80_gfxram[ y | x | ra]; |
| 356 | gfx = state->gfxram[ y | x | ra]; |
| 358 | 357 | /* Display 6 pixels in normal region */ |
| 359 | 358 | *p++ = ( gfx & 0x01 ) ? fg : bg; |
| 360 | 359 | *p++ = ( gfx & 0x02 ) ? fg : bg; |
| r9674 | r9675 | |
| 366 | 365 | |
| 367 | 366 | for (x = 0; x < 0x10; x++) |
| 368 | 367 | { |
| 369 | | gfx = trs80_gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)]; |
| 368 | gfx = state->gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)]; |
| 370 | 369 | /* Display 6 pixels in extended region */ |
| 371 | 370 | *p++ = ( gfx & 0x01 ) ? fg : bg; |
| 372 | 371 | *p++ = ( gfx & 0x02 ) ? fg : bg; |
| r9674 | r9675 | |
| 390 | 389 | |
| 391 | 390 | for (x = 0; x < 0x40; x++) |
| 392 | 391 | { |
| 393 | | gfx = trs80_gfxram[ y | x | ra]; |
| 392 | gfx = state->gfxram[ y | x | ra]; |
| 394 | 393 | /* Display 6 pixels in normal region */ |
| 395 | 394 | fg = (gfx & 0x38) >> 3; |
| 396 | 395 | *p++ = fg; |
| r9674 | r9675 | |
| 417 | 416 | |
| 418 | 417 | for (x = 0; x < 0x40; x++) |
| 419 | 418 | { |
| 420 | | gfx = trs80_gfxram[ y | x | ra]; |
| 419 | gfx = state->gfxram[ y | x | ra]; |
| 421 | 420 | fg = (videoram[ 0x3c00 | x | y ] & 0x38) >> 3; |
| 422 | 421 | /* Display 6 pixels in normal region */ |
| 423 | 422 | *p++ = ( gfx & 0x01 ) ? fg : bg; |
| r9674 | r9675 | |
| 431 | 430 | |
| 432 | 431 | for (x = 0; x < 0x10; x++) |
| 433 | 432 | { |
| 434 | | gfx = trs80_gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)]; |
| 435 | | fg = (trs80_gfxram[ 0x3c00 | x | y ] & 0x38) >> 3; |
| 433 | gfx = state->gfxram[ 0x3000 | x | (ra & 0xc00) | ((ra & 0x3000) >> 8)]; |
| 434 | fg = (state->gfxram[ 0x3c00 | x | y ] & 0x38) >> 3; |
| 436 | 435 | /* Display 6 pixels in extended region */ |
| 437 | 436 | *p++ = ( gfx & 0x01 ) ? fg : bg; |
| 438 | 437 | *p++ = ( gfx & 0x02 ) ? fg : bg; |
| 439 | 438 | *p++ = ( gfx & 0x04 ) ? fg : bg; |
| 440 | | fg = trs80_gfxram[ 0x3c00 | x | y ] & 0x07; |
| 439 | fg = state->gfxram[ 0x3c00 | x | y ] & 0x07; |
| 441 | 440 | *p++ = ( gfx & 0x08 ) ? fg : bg; |
| 442 | 441 | *p++ = ( gfx & 0x10 ) ? fg : bg; |
| 443 | 442 | *p++ = ( gfx & 0x20 ) ? fg : bg; |
| r9674 | r9675 | |
| 457 | 456 | UINT8 y,ra,chr,gfx; |
| 458 | 457 | UINT16 sy=0,ma=0,x; |
| 459 | 458 | UINT8 *FNT = memory_region(screen->machine, "gfx1"); |
| 460 | | UINT8 cols = (trs80_mode & 1) ? 32 : 64; |
| 461 | | UINT8 skip = (trs80_mode & 1) ? 2 : 1; |
| 459 | UINT8 cols = (state->mode & 1) ? 32 : 64; |
| 460 | UINT8 skip = (state->mode & 1) ? 2 : 1; |
| 462 | 461 | |
| 463 | | if (trs80_mode != trs80_size_store) |
| 462 | if (state->mode != state->size_store) |
| 464 | 463 | { |
| 465 | | trs80_size_store = trs80_mode & 1; |
| 464 | state->size_store = state->mode & 1; |
| 466 | 465 | screen->set_visible_area(0, cols*8-1, 0, 16*16-1); |
| 467 | 466 | } |
| 468 | 467 | |
| r9674 | r9675 | |
| 504 | 503 | { |
| 505 | 504 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 506 | 505 | UINT8 *videoram = state->videoram; |
| 507 | | if ((trs80_mode & 0x80) && (~trs80_model4 & 1)) offset |= 0x400; |
| 506 | if ((state->mode & 0x80) && (~state->model4 & 1)) offset |= 0x400; |
| 508 | 507 | return videoram[offset]; |
| 509 | 508 | } |
| 510 | 509 | |
| r9674 | r9675 | |
| 512 | 511 | { |
| 513 | 512 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 514 | 513 | UINT8 *videoram = state->videoram; |
| 515 | | if ((trs80_mode & 0x80) && (~trs80_model4 & 1)) offset |= 0x400; |
| 514 | if ((state->mode & 0x80) && (~state->model4 & 1)) offset |= 0x400; |
| 516 | 515 | videoram[offset] = data; |
| 517 | 516 | } |
| 518 | 517 | |
| r9674 | r9675 | |
| 523 | 522 | |
| 524 | 523 | READ8_HANDLER( trs80_gfxram_r ) |
| 525 | 524 | { |
| 526 | | return trs80_gfxram[offset]; |
| 525 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 526 | return state->gfxram[offset]; |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | WRITE8_HANDLER( trs80_gfxram_w ) |
| 530 | 530 | { |
| 531 | | trs80_gfxram[offset] = data; |
| 531 | trs80_state *state = space->machine->driver_data<trs80_state>(); |
| 532 | state->gfxram[offset] = data; |
| 532 | 533 | } |
| 533 | 534 | |
| 534 | 535 | |
src/mess/drivers/x1.c
| r9674 | r9675 | |
| 209 | 209 | #define VDP_CLOCK XTAL_42_9545MHz |
| 210 | 210 | #define MCU_CLOCK XTAL_6MHz |
| 211 | 211 | |
| 212 | | static UINT8 hres_320,io_switch,io_sys,vsync,vdisp; |
| 213 | | static UINT8 io_bank_mode; |
| 214 | | static UINT8 *gfx_bitmap_ram; |
| 215 | | static UINT16 pcg_index[3]; |
| 216 | | static UINT8 pcg_reset; |
| 217 | | static UINT16 crtc_start_addr; |
| 218 | | static UINT8 tile_height; |
| 219 | | static UINT8 sub_obf; |
| 220 | | UINT8 x1_key_irq_flag; |
| 221 | | static UINT8 ctc_irq_flag; |
| 222 | | static struct |
| 223 | | { |
| 224 | | UINT8 gfx_bank; |
| 225 | | UINT8 disp_bank; |
| 226 | | UINT8 pcg_mode; |
| 227 | | UINT8 v400_mode; |
| 228 | 212 | |
| 229 | | UINT8 ply; |
| 230 | | UINT8 blackclip; // x1 turbo specific |
| 231 | | }scrn_reg; |
| 232 | 213 | |
| 233 | | static struct |
| 234 | | { |
| 235 | | UINT8 pal; |
| 236 | | UINT8 gfx_pal; |
| 237 | | UINT8 txt_pal[8]; |
| 238 | | UINT8 txt_disp; |
| 239 | | }turbo_reg; |
| 240 | 214 | |
| 241 | | static struct |
| 242 | | { |
| 243 | | UINT8 sec, min, hour, day, wday, month, year; |
| 244 | | }x1_rtc; |
| 245 | 215 | |
| 246 | | static emu_timer *x1_rtc_timer; |
| 247 | 216 | |
| 248 | | static UINT8 pcg_write_addr; |
| 249 | | |
| 250 | 217 | //static DEVICE_START(x1_daisy){} |
| 251 | 218 | |
| 252 | | static UINT8 *x1_colorram; |
| 253 | 219 | /************************************* |
| 254 | 220 | * |
| 255 | 221 | * Video Functions |
| r9674 | r9675 | |
| 259 | 225 | static VIDEO_START( x1 ) |
| 260 | 226 | { |
| 261 | 227 | x1_state *state = machine->driver_data<x1_state>(); |
| 262 | | x1_colorram = auto_alloc_array(machine, UINT8, 0x1000); |
| 228 | state->colorram = auto_alloc_array(machine, UINT8, 0x1000); |
| 263 | 229 | state->videoram = auto_alloc_array(machine, UINT8, 0x1000); |
| 264 | | gfx_bitmap_ram = auto_alloc_array(machine, UINT8, 0xc000*2); |
| 230 | state->gfx_bitmap_ram = auto_alloc_array(machine, UINT8, 0xc000*2); |
| 265 | 231 | } |
| 266 | 232 | |
| 267 | 233 | static void draw_fgtilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int w) |
| r9674 | r9675 | |
| 277 | 243 | { |
| 278 | 244 | for (x=0;x<40*w;x++) |
| 279 | 245 | { |
| 280 | | int tile = videoram[(x+(y*40*w)+crtc_start_addr) & screen_mask]; |
| 281 | | int color = x1_colorram[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x1f; |
| 282 | | int width = (x1_colorram[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x80)>>7; |
| 283 | | int height = (x1_colorram[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x40)>>6; |
| 284 | | int pcg_bank = (x1_colorram[(x+(y*40*w)+crtc_start_addr) & screen_mask] & 0x20)>>5; |
| 246 | int tile = videoram[(x+(y*40*w)+state->crtc_start_addr) & screen_mask]; |
| 247 | int color = state->colorram[(x+(y*40*w)+state->crtc_start_addr) & screen_mask] & 0x1f; |
| 248 | int width = (state->colorram[(x+(y*40*w)+state->crtc_start_addr) & screen_mask] & 0x80)>>7; |
| 249 | int height = (state->colorram[(x+(y*40*w)+state->crtc_start_addr) & screen_mask] & 0x40)>>6; |
| 250 | int pcg_bank = (state->colorram[(x+(y*40*w)+state->crtc_start_addr) & screen_mask] & 0x20)>>5; |
| 285 | 251 | UINT8 *gfx_data = pcg_bank ? memory_region(machine, "pcg") : memory_region(machine, "cgrom"); |
| 286 | 252 | |
| 287 | 253 | /* skip draw if the x/y values are odd and the width/height is active, */ |
| r9674 | r9675 | |
| 290 | 256 | if((y & 1) == 1 && height) continue; |
| 291 | 257 | |
| 292 | 258 | res_x = (x/(width+1))*8*(width+1); |
| 293 | | res_y = (y/(height+1))*(tile_height+1)*(height+1); |
| 259 | res_y = (y/(height+1))*(state->tile_height+1)*(height+1); |
| 294 | 260 | |
| 295 | 261 | { |
| 296 | 262 | int pen[3],pen_mask,pcg_pen,xi,yi; |
| r9674 | r9675 | |
| 298 | 264 | pen_mask = color & 7; |
| 299 | 265 | |
| 300 | 266 | /* We use custom drawing code due of the bitplane disable and the color revert stuff. */ |
| 301 | | for(yi=0;yi<(tile_height+1)*(height+1);yi+=(height+1)) |
| 267 | for(yi=0;yi<(state->tile_height+1)*(height+1);yi+=(height+1)) |
| 302 | 268 | { |
| 303 | 269 | for(xi=0;xi<8*(width+1);xi+=(width+1)) |
| 304 | 270 | { |
| r9674 | r9675 | |
| 317 | 283 | if(color & 8) //revert the used color pen |
| 318 | 284 | pcg_pen^=7; |
| 319 | 285 | |
| 320 | | if((scrn_reg.blackclip & 8) && (color == (scrn_reg.blackclip & 7))) |
| 286 | if((state->scrn_reg.blackclip & 8) && (color == (state->scrn_reg.blackclip & 7))) |
| 321 | 287 | pcg_pen = 0; // clip the pen to black |
| 322 | 288 | |
| 323 | 289 | if((res_x+xi)>machine->primary_screen->visible_area().max_x && (res_y+yi)>machine->primary_screen->visible_area().max_y) |
| 324 | 290 | continue; |
| 325 | 291 | |
| 326 | | if(scrn_reg.v400_mode) |
| 292 | if(state->scrn_reg.v400_mode) |
| 327 | 293 | { |
| 328 | 294 | *BITMAP_ADDR16(bitmap, (res_y+yi)*2+0, res_x+xi) = machine->pens[pcg_pen]; |
| 329 | 295 | *BITMAP_ADDR16(bitmap, (res_y+yi)*2+1, res_x+xi) = machine->pens[pcg_pen]; |
| r9674 | r9675 | |
| 390 | 356 | |
| 391 | 357 | static void draw_gfxbitmap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int w,int plane,int pri) |
| 392 | 358 | { |
| 359 | x1_state *state = machine->driver_data<x1_state>(); |
| 393 | 360 | int xi,yi,x,y; |
| 394 | 361 | int pen_r,pen_g,pen_b,color; |
| 395 | 362 | int pri_mask_val; |
| r9674 | r9675 | |
| 398 | 365 | { |
| 399 | 366 | for(x=0;x<40*w;x++) |
| 400 | 367 | { |
| 401 | | for(yi=0;yi<(tile_height+1);yi++) |
| 368 | for(yi=0;yi<(state->tile_height+1);yi++) |
| 402 | 369 | { |
| 403 | 370 | for(xi=0;xi<8;xi++) |
| 404 | 371 | { |
| 405 | | pen_b = (gfx_bitmap_ram[(((x+(y*40*w)+yi*0x800)+crtc_start_addr) & 0x3fff)+0x0000+plane*0xc000]>>(7-xi)) & 1; |
| 406 | | pen_r = (gfx_bitmap_ram[(((x+(y*40*w)+yi*0x800)+crtc_start_addr) & 0x3fff)+0x4000+plane*0xc000]>>(7-xi)) & 1; |
| 407 | | pen_g = (gfx_bitmap_ram[(((x+(y*40*w)+yi*0x800)+crtc_start_addr) & 0x3fff)+0x8000+plane*0xc000]>>(7-xi)) & 1; |
| 372 | pen_b = (state->gfx_bitmap_ram[(((x+(y*40*w)+yi*0x800)+state->crtc_start_addr) & 0x3fff)+0x0000+plane*0xc000]>>(7-xi)) & 1; |
| 373 | pen_r = (state->gfx_bitmap_ram[(((x+(y*40*w)+yi*0x800)+state->crtc_start_addr) & 0x3fff)+0x4000+plane*0xc000]>>(7-xi)) & 1; |
| 374 | pen_g = (state->gfx_bitmap_ram[(((x+(y*40*w)+yi*0x800)+state->crtc_start_addr) & 0x3fff)+0x8000+plane*0xc000]>>(7-xi)) & 1; |
| 408 | 375 | |
| 409 | 376 | color = pen_g<<2 | pen_r<<1 | pen_b<<0; |
| 410 | 377 | |
| 411 | 378 | pri_mask_val = priority_mixer_ply(machine,color); |
| 412 | 379 | if(pri_mask_val & pri) continue; |
| 413 | 380 | |
| 414 | | if(scrn_reg.v400_mode) |
| 381 | if(state->scrn_reg.v400_mode) |
| 415 | 382 | { |
| 416 | | if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (( y*(tile_height+1)+yi)*2+0)<=machine->primary_screen->visible_area().max_y) |
| 417 | | *BITMAP_ADDR16(bitmap, ( y*(tile_height+1)+yi)*2+0, x*8+xi) = machine->pens[color+0x100]; |
| 418 | | if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (( y*(tile_height+1)+yi)*2+1)<=machine->primary_screen->visible_area().max_y) |
| 419 | | *BITMAP_ADDR16(bitmap, ( y*(tile_height+1)+yi)*2+1, x*8+xi) = machine->pens[color+0x100]; |
| 383 | if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (( y*(state->tile_height+1)+yi)*2+0)<=machine->primary_screen->visible_area().max_y) |
| 384 | *BITMAP_ADDR16(bitmap, ( y*(state->tile_height+1)+yi)*2+0, x*8+xi) = machine->pens[color+0x100]; |
| 385 | if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (( y*(state->tile_height+1)+yi)*2+1)<=machine->primary_screen->visible_area().max_y) |
| 386 | *BITMAP_ADDR16(bitmap, ( y*(state->tile_height+1)+yi)*2+1, x*8+xi) = machine->pens[color+0x100]; |
| 420 | 387 | } |
| 421 | 388 | else |
| 422 | 389 | { |
| 423 | | if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (y*(tile_height+1)+yi)<=machine->primary_screen->visible_area().max_y) |
| 424 | | *BITMAP_ADDR16(bitmap, y*(tile_height+1)+yi, x*8+xi) = machine->pens[color+0x100]; |
| 390 | if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (y*(state->tile_height+1)+yi)<=machine->primary_screen->visible_area().max_y) |
| 391 | *BITMAP_ADDR16(bitmap, y*(state->tile_height+1)+yi, x*8+xi) = machine->pens[color+0x100]; |
| 425 | 392 | } |
| 426 | 393 | } |
| 427 | 394 | } |
| r9674 | r9675 | |
| 433 | 400 | /* Old code for reference, to be removed soon */ |
| 434 | 401 | static void draw_gfxbitmap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int w,int plane,int pri) |
| 435 | 402 | { |
| 403 | x1_state *state = machine->driver_data<x1_state>(); |
| 436 | 404 | int count,xi,yi,x,y; |
| 437 | 405 | int pen_r,pen_g,pen_b,color; |
| 438 | 406 | int yi_size; |
| 439 | 407 | int pri_mask_val; |
| 440 | 408 | |
| 441 | | count = crtc_start_addr; |
| 409 | count = state->crtc_start_addr; |
| 442 | 410 | |
| 443 | 411 | yi_size = (w == 1) ? 16 : 8; |
| 444 | 412 | |
| r9674 | r9675 | |
| 450 | 418 | { |
| 451 | 419 | for(xi=0;xi<8;xi++) |
| 452 | 420 | { |
| 453 | | pen_b = (gfx_bitmap_ram[count+0x0000+plane*0xc000]>>(7-xi)) & 1; |
| 454 | | pen_r = (gfx_bitmap_ram[count+0x4000+plane*0xc000]>>(7-xi)) & 1; |
| 455 | | pen_g = (gfx_bitmap_ram[count+0x8000+plane*0xc000]>>(7-xi)) & 1; |
| 421 | pen_b = (state->gfx_bitmap_ram[count+0x0000+plane*0xc000]>>(7-xi)) & 1; |
| 422 | pen_r = (state->gfx_bitmap_ram[count+0x4000+plane*0xc000]>>(7-xi)) & 1; |
| 423 | pen_g = (state->gfx_bitmap_ram[count+0x8000+plane*0xc000]>>(7-xi)) & 1; |
| 456 | 424 | |
| 457 | 425 | color = pen_g<<2 | pen_r<<1 | pen_b<<0; |
| 458 | 426 | |
| r9674 | r9675 | |
| 464 | 432 | if(yi & 1) |
| 465 | 433 | continue; |
| 466 | 434 | |
| 467 | | if(scrn_reg.v400_mode) |
| 435 | if(state->scrn_reg.v400_mode) |
| 468 | 436 | { |
| 469 | 437 | if((x+xi)<=machine->primary_screen->visible_area().max_x && (y+(yi >> 1)*2+0)<=machine->primary_screen->visible_area().max_y) |
| 470 | 438 | *BITMAP_ADDR16(bitmap, (y+(yi >> 1))*2+0, x+xi) = machine->pens[color+0x100]; |
| r9674 | r9675 | |
| 479 | 447 | } |
| 480 | 448 | else |
| 481 | 449 | { |
| 482 | | if(scrn_reg.v400_mode) |
| 450 | if(state->scrn_reg.v400_mode) |
| 483 | 451 | { |
| 484 | 452 | if((x+xi)<=machine->primary_screen->visible_area().max_x && ((y+yi)*2+0)<=machine->primary_screen->visible_area().max_y) |
| 485 | 453 | *BITMAP_ADDR16(bitmap, (y+yi)*2+0, x+xi) = machine->pens[color+0x100]; |
| r9674 | r9675 | |
| 504 | 472 | |
| 505 | 473 | static VIDEO_UPDATE( x1 ) |
| 506 | 474 | { |
| 475 | x1_state *state = screen->machine->driver_data<x1_state>(); |
| 507 | 476 | int w; |
| 508 | 477 | |
| 509 | 478 | w = (screen->width() < 640) ? 1 : 2; |
| 510 | 479 | |
| 511 | 480 | bitmap_fill(bitmap, cliprect, MAKE_ARGB(0xff,0x00,0x00,0x00)); |
| 512 | 481 | |
| 513 | | draw_gfxbitmap(screen->machine,bitmap,cliprect,w,scrn_reg.disp_bank,scrn_reg.ply); |
| 482 | draw_gfxbitmap(screen->machine,bitmap,cliprect,w,state->scrn_reg.disp_bank,state->scrn_reg.ply); |
| 514 | 483 | draw_fgtilemap(screen->machine,bitmap,cliprect,w); |
| 515 | | draw_gfxbitmap(screen->machine,bitmap,cliprect,w,scrn_reg.disp_bank,scrn_reg.ply^0xff); |
| 484 | draw_gfxbitmap(screen->machine,bitmap,cliprect,w,state->scrn_reg.disp_bank,state->scrn_reg.ply^0xff); |
| 516 | 485 | /* Y's uses the following as a normal buffer/work ram without anything reasonable to draw */ |
| 517 | 486 | // draw_gfxbitmap(screen->machine,bitmap,cliprect,w,1); |
| 518 | 487 | |
| r9674 | r9675 | |
| 529 | 498 | * |
| 530 | 499 | *************************************/ |
| 531 | 500 | |
| 532 | | static UINT8 sub_cmd;//,key_flag; |
| 533 | | static UINT8 sub_cmd_length; |
| 534 | | static UINT8 sub_val[8]; |
| 535 | 501 | |
| 536 | 502 | static UINT8 check_keyboard_press(running_machine *machine) |
| 537 | 503 | { |
| r9674 | r9675 | |
| 658 | 624 | |
| 659 | 625 | static READ8_HANDLER( sub_io_r ) |
| 660 | 626 | { |
| 661 | | static int sub_val_ptr,key_i = 0; |
| 627 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 662 | 628 | UINT8 ret,bus_res; |
| 663 | 629 | |
| 664 | 630 | /* Looks like that the HW retains the latest data putted on the bus here, behaviour confirmed by Rally-X */ |
| 665 | | if(sub_obf) |
| 631 | if(state->sub_obf) |
| 666 | 632 | { |
| 667 | | bus_res = sub_val[key_i]; |
| 633 | bus_res = state->sub_val[state->key_i]; |
| 668 | 634 | /* FIXME: likely to be different here. */ |
| 669 | | key_i++; |
| 670 | | if(key_i >= 2) { key_i = 0; } |
| 635 | state->key_i++; |
| 636 | if(state->key_i >= 2) { state->key_i = 0; } |
| 671 | 637 | |
| 672 | 638 | return bus_res; |
| 673 | 639 | } |
| r9674 | r9675 | |
| 680 | 646 | } |
| 681 | 647 | #endif |
| 682 | 648 | |
| 683 | | sub_cmd_length--; |
| 684 | | sub_obf = (sub_cmd_length) ? 0x00 : 0x20; |
| 649 | state->sub_cmd_length--; |
| 650 | state->sub_obf = (state->sub_cmd_length) ? 0x00 : 0x20; |
| 685 | 651 | |
| 686 | | ret = sub_val[sub_val_ptr]; |
| 652 | ret = state->sub_val[state->sub_val_ptr]; |
| 687 | 653 | |
| 688 | | sub_val_ptr++; |
| 689 | | if(sub_cmd_length <= 0) |
| 690 | | sub_val_ptr = 0; |
| 654 | state->sub_val_ptr++; |
| 655 | if(state->sub_cmd_length <= 0) |
| 656 | state->sub_val_ptr = 0; |
| 691 | 657 | |
| 692 | 658 | return ret; |
| 693 | 659 | } |
| 694 | 660 | |
| 695 | | static UINT8 x1_irq_vector; |
| 696 | 661 | //static UINT8 ctc_irq_vector; //always 0x5e? |
| 697 | | UINT8 x1_key_irq_vector; |
| 698 | | static UINT8 cmt_current_cmd; |
| 699 | | static UINT8 cmt_test; |
| 700 | 662 | |
| 701 | 663 | static void cmt_command( running_machine* machine, UINT8 cmd ) |
| 702 | 664 | { |
| 665 | x1_state *state = machine->driver_data<x1_state>(); |
| 703 | 666 | // CMT deck control command (E9 xx) |
| 704 | 667 | // E9 00 - Eject |
| 705 | 668 | // E9 01 - Stop |
| r9674 | r9675 | |
| 709 | 672 | // E9 05 - APSS(?) Fast Forward |
| 710 | 673 | // E9 06 - APSS(?) Rewind |
| 711 | 674 | // E9 0A - Record |
| 712 | | cmt_current_cmd = cmd; |
| 675 | state->cmt_current_cmd = cmd; |
| 713 | 676 | |
| 714 | 677 | switch(cmd) |
| 715 | 678 | { |
| 716 | 679 | case 0x01: // Stop |
| 717 | 680 | cassette_change_state(machine->device("cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 718 | 681 | cassette_change_state(machine->device("cass" ),CASSETTE_STOPPED,CASSETTE_MASK_UISTATE); |
| 719 | | cmt_test = 1; |
| 682 | state->cmt_test = 1; |
| 720 | 683 | popmessage("CMT: Stop"); |
| 721 | 684 | break; |
| 722 | 685 | case 0x02: // Play |
| r9674 | r9675 | |
| 757 | 720 | |
| 758 | 721 | static TIMER_CALLBACK( cmt_wind_timer ) |
| 759 | 722 | { |
| 723 | x1_state *state = machine->driver_data<x1_state>(); |
| 760 | 724 | running_device* cmt = machine->device("cass"); |
| 761 | | switch(cmt_current_cmd) |
| 725 | switch(state->cmt_current_cmd) |
| 762 | 726 | { |
| 763 | 727 | case 0x03: |
| 764 | 728 | case 0x05: // Fast Forwarding tape |
| r9674 | r9675 | |
| 777 | 741 | |
| 778 | 742 | static WRITE8_HANDLER( sub_io_w ) |
| 779 | 743 | { |
| 744 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 780 | 745 | /* TODO: check sub-routine at $10e */ |
| 781 | 746 | /* $17a -> floppy? */ |
| 782 | 747 | /* $094 -> ROM */ |
| r9674 | r9675 | |
| 784 | 749 | /* $052 -> cmt */ |
| 785 | 750 | /* $0f5 -> reload sub-routine? */ |
| 786 | 751 | |
| 787 | | if(sub_cmd == 0xe4) |
| 752 | if(state->sub_cmd == 0xe4) |
| 788 | 753 | { |
| 789 | | x1_key_irq_vector = data; |
| 754 | state->key_irq_vector = data; |
| 790 | 755 | logerror("Key vector set to 0x%02x\n",data); |
| 791 | 756 | } |
| 792 | 757 | |
| 793 | | if(sub_cmd == 0xe9) |
| 758 | if(state->sub_cmd == 0xe9) |
| 794 | 759 | cmt_command(space->machine,data); |
| 795 | 760 | |
| 796 | 761 | if((data & 0xf0) == 0xd0) //reads here tv recording timer data. |
| 797 | 762 | { |
| 798 | | sub_val[0] = 0; |
| 799 | | sub_val[1] = 0; |
| 800 | | sub_val[2] = 0; |
| 801 | | sub_val[3] = 0; |
| 802 | | sub_val[4] = 0; |
| 803 | | sub_val[5] = 0; |
| 804 | | sub_cmd_length = 6; |
| 763 | state->sub_val[0] = 0; |
| 764 | state->sub_val[1] = 0; |
| 765 | state->sub_val[2] = 0; |
| 766 | state->sub_val[3] = 0; |
| 767 | state->sub_val[4] = 0; |
| 768 | state->sub_val[5] = 0; |
| 769 | state->sub_cmd_length = 6; |
| 805 | 770 | } |
| 806 | 771 | |
| 807 | 772 | switch(data) |
| 808 | 773 | { |
| 809 | 774 | case 0xe3: |
| 810 | | sub_cmd_length = 3; |
| 811 | | sub_val[0] = get_game_key(space->machine,0); |
| 812 | | sub_val[1] = get_game_key(space->machine,1); |
| 813 | | sub_val[2] = get_game_key(space->machine,2); |
| 775 | state->sub_cmd_length = 3; |
| 776 | state->sub_val[0] = get_game_key(space->machine,0); |
| 777 | state->sub_val[1] = get_game_key(space->machine,1); |
| 778 | state->sub_val[2] = get_game_key(space->machine,2); |
| 814 | 779 | break; |
| 815 | 780 | case 0xe6: |
| 816 | | sub_val[0] = check_keyboard_shift(space->machine); |
| 817 | | sub_val[1] = check_keyboard_press(space->machine); |
| 818 | | sub_cmd_length = 2; |
| 781 | state->sub_val[0] = check_keyboard_shift(space->machine); |
| 782 | state->sub_val[1] = check_keyboard_press(space->machine); |
| 783 | state->sub_cmd_length = 2; |
| 819 | 784 | break; |
| 820 | 785 | case 0xe8: |
| 821 | | sub_val[0] = sub_cmd; |
| 822 | | sub_cmd_length = 1; |
| 786 | state->sub_val[0] = state->sub_cmd; |
| 787 | state->sub_cmd_length = 1; |
| 823 | 788 | break; |
| 824 | 789 | case 0xea: // CMT Control status |
| 825 | | sub_val[0] = cmt_current_cmd; |
| 826 | | sub_cmd_length = 1; |
| 827 | | logerror("CMT: Command 0xEA received, returning 0x%02x.\n",sub_val[0]); |
| 790 | state->sub_val[0] = state->cmt_current_cmd; |
| 791 | state->sub_cmd_length = 1; |
| 792 | logerror("CMT: Command 0xEA received, returning 0x%02x.\n",state->sub_val[0]); |
| 828 | 793 | break; |
| 829 | 794 | case 0xeb: // CMT Tape status |
| 830 | 795 | // bit 0 = tape end (0=end of tape) |
| 831 | 796 | // bit 1 = tape inserted |
| 832 | 797 | // bit 2 = record status (1=OK, 0=write protect?) |
| 833 | | sub_val[0] = 0x05; |
| 798 | state->sub_val[0] = 0x05; |
| 834 | 799 | if(cassette_get_image(space->machine->device("cass")) != NULL) |
| 835 | | sub_val[0] |= 0x02; |
| 836 | | sub_cmd_length = 1; |
| 837 | | logerror("CMT: Command 0xEB received, returning 0x%02x.\n",sub_val[0]); |
| 800 | state->sub_val[0] |= 0x02; |
| 801 | state->sub_cmd_length = 1; |
| 802 | logerror("CMT: Command 0xEB received, returning 0x%02x.\n",state->sub_val[0]); |
| 838 | 803 | break; |
| 839 | 804 | case 0xed: //get date |
| 840 | | sub_val[0] = x1_rtc.day; |
| 841 | | sub_val[1] = (x1_rtc.month<<4) | (x1_rtc.wday & 0xf); |
| 842 | | sub_val[2] = x1_rtc.year; |
| 843 | | sub_cmd_length = 3; |
| 805 | state->sub_val[0] = state->rtc.day; |
| 806 | state->sub_val[1] = (state->rtc.month<<4) | (state->rtc.wday & 0xf); |
| 807 | state->sub_val[2] = state->rtc.year; |
| 808 | state->sub_cmd_length = 3; |
| 844 | 809 | break; |
| 845 | 810 | case 0xef: //get time |
| 846 | | sub_val[0] = x1_rtc.hour; |
| 847 | | sub_val[1] = x1_rtc.min; |
| 848 | | sub_val[2] = x1_rtc.sec; |
| 849 | | sub_cmd_length = 3; |
| 811 | state->sub_val[0] = state->rtc.hour; |
| 812 | state->sub_val[1] = state->rtc.min; |
| 813 | state->sub_val[2] = state->rtc.sec; |
| 814 | state->sub_cmd_length = 3; |
| 850 | 815 | break; |
| 851 | 816 | #if 0 |
| 852 | 817 | default: |
| r9674 | r9675 | |
| 857 | 822 | #endif |
| 858 | 823 | } |
| 859 | 824 | |
| 860 | | sub_cmd = data; |
| 825 | state->sub_cmd = data; |
| 861 | 826 | |
| 862 | | sub_obf = (sub_cmd_length) ? 0x00 : 0x20; |
| 827 | state->sub_obf = (state->sub_cmd_length) ? 0x00 : 0x20; |
| 863 | 828 | logerror("SUB: Command byte 0x%02x\n",data); |
| 864 | 829 | } |
| 865 | 830 | |
| r9674 | r9675 | |
| 869 | 834 | * |
| 870 | 835 | *************************************/ |
| 871 | 836 | |
| 872 | | static UINT8 rom_index[3]; |
| 873 | 837 | |
| 874 | 838 | static READ8_HANDLER( x1_rom_r ) |
| 875 | 839 | { |
| 840 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 876 | 841 | UINT8 *rom = memory_region(space->machine, "cart_img"); |
| 877 | 842 | |
| 878 | | // printf("%06x\n",rom_index[0]<<16|rom_index[1]<<8|rom_index[2]<<0); |
| 843 | // printf("%06x\n",state->rom_index[0]<<16|state->rom_index[1]<<8|state->rom_index[2]<<0); |
| 879 | 844 | |
| 880 | | return rom[rom_index[0]<<16|rom_index[1]<<8|rom_index[2]<<0]; |
| 845 | return rom[state->rom_index[0]<<16|state->rom_index[1]<<8|state->rom_index[2]<<0]; |
| 881 | 846 | } |
| 882 | 847 | |
| 883 | 848 | static WRITE8_HANDLER( x1_rom_w ) |
| 884 | 849 | { |
| 885 | | rom_index[offset] = data; |
| 850 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 851 | state->rom_index[offset] = data; |
| 886 | 852 | } |
| 887 | 853 | |
| 888 | 854 | static WRITE8_HANDLER( rom_bank_0_w ) |
| r9674 | r9675 | |
| 1005 | 971 | |
| 1006 | 972 | static UINT16 check_pcg_addr(running_machine *machine) |
| 1007 | 973 | { |
| 1008 | | if(x1_colorram[0x7ff] & 0x20) return 0x7ff; |
| 1009 | | if(x1_colorram[0x3ff] & 0x20) return 0x3ff; |
| 1010 | | if(x1_colorram[0x5ff] & 0x20) return 0x5ff; |
| 1011 | | if(x1_colorram[0x1ff] & 0x20) return 0x1ff; |
| 974 | x1_state *state = machine->driver_data<x1_state>(); |
| 975 | if(state->colorram[0x7ff] & 0x20) return 0x7ff; |
| 976 | if(state->colorram[0x3ff] & 0x20) return 0x3ff; |
| 977 | if(state->colorram[0x5ff] & 0x20) return 0x5ff; |
| 978 | if(state->colorram[0x1ff] & 0x20) return 0x1ff; |
| 1012 | 979 | |
| 1013 | 980 | return 0x3ff; |
| 1014 | 981 | } |
| 1015 | 982 | |
| 1016 | 983 | static UINT16 check_chr_addr(running_machine *machine) |
| 1017 | 984 | { |
| 1018 | | if(!(x1_colorram[0x7ff] & 0x20)) return 0x7ff; |
| 1019 | | if(!(x1_colorram[0x3ff] & 0x20)) return 0x3ff; |
| 1020 | | if(!(x1_colorram[0x5ff] & 0x20)) return 0x5ff; |
| 1021 | | if(!(x1_colorram[0x1ff] & 0x20)) return 0x1ff; |
| 985 | x1_state *state = machine->driver_data<x1_state>(); |
| 986 | if(!(state->colorram[0x7ff] & 0x20)) return 0x7ff; |
| 987 | if(!(state->colorram[0x3ff] & 0x20)) return 0x3ff; |
| 988 | if(!(state->colorram[0x5ff] & 0x20)) return 0x5ff; |
| 989 | if(!(state->colorram[0x1ff] & 0x20)) return 0x1ff; |
| 1022 | 990 | |
| 1023 | 991 | return 0x3ff; |
| 1024 | 992 | } |
| r9674 | r9675 | |
| 1029 | 997 | UINT8 *videoram = state->videoram; |
| 1030 | 998 | int addr; |
| 1031 | 999 | int calc_pcg_offset; |
| 1032 | | static UINT32 kanji_offset; |
| 1033 | | static UINT8 bios_offset,pcg_index_r[3]; |
| 1034 | 1000 | UINT8 res; |
| 1035 | 1001 | UINT8 *gfx_data; |
| 1036 | 1002 | |
| 1037 | 1003 | addr = (offset & 0x300) >> 8; |
| 1038 | 1004 | |
| 1039 | | if(pcg_reset) |
| 1005 | if(state->pcg_reset) |
| 1040 | 1006 | { |
| 1041 | | pcg_index_r[0] = pcg_index_r[1] = pcg_index_r[2] = bios_offset = 0; |
| 1042 | | pcg_reset = 0; |
| 1007 | state->pcg_index_r[0] = state->pcg_index_r[1] = state->pcg_index_r[2] = state->bios_offset = 0; |
| 1008 | state->pcg_reset = 0; |
| 1043 | 1009 | } |
| 1044 | 1010 | |
| 1045 | 1011 | if(addr == 0) |
| 1046 | 1012 | { |
| 1047 | | if(scrn_reg.pcg_mode) |
| 1013 | if(state->scrn_reg.pcg_mode) |
| 1048 | 1014 | { |
| 1049 | 1015 | gfx_data = memory_region(space->machine, "kanji"); |
| 1050 | 1016 | calc_pcg_offset = (videoram[check_chr_addr(space->machine)]+(videoram[check_chr_addr(space->machine)+0x800]<<8)) & 0xfff; |
| 1051 | 1017 | |
| 1052 | | kanji_offset = calc_pcg_offset*0x20; |
| 1018 | state->kanji_offset = calc_pcg_offset*0x20; |
| 1053 | 1019 | |
| 1054 | | res = gfx_data[0x0000+bios_offset+kanji_offset]; |
| 1020 | res = gfx_data[0x0000+state->bios_offset+state->kanji_offset]; |
| 1055 | 1021 | |
| 1056 | | bios_offset++; |
| 1057 | | bios_offset&=0x1f; |
| 1022 | state->bios_offset++; |
| 1023 | state->bios_offset&=0x1f; |
| 1058 | 1024 | } |
| 1059 | 1025 | else |
| 1060 | 1026 | { |
| 1061 | | // printf("%04x %04x %02x\n",pcg_write_addr*4*8,pcg_write_addr,bios_offset); |
| 1027 | // printf("%04x %04x %02x\n",state->pcg_write_addr*4*8,state->pcg_write_addr,state->bios_offset); |
| 1062 | 1028 | gfx_data = memory_region(space->machine, "kanji"); |
| 1063 | | if(bios_offset == 0) |
| 1064 | | kanji_offset = pcg_write_addr*4*8;//TODO: check me |
| 1029 | if(state->bios_offset == 0) |
| 1030 | state->kanji_offset = state->pcg_write_addr*4*8;//TODO: check me |
| 1065 | 1031 | |
| 1066 | | res = gfx_data[0x0000+bios_offset+kanji_offset]; |
| 1032 | res = gfx_data[0x0000+state->bios_offset+state->kanji_offset]; |
| 1067 | 1033 | |
| 1068 | | bios_offset++; |
| 1069 | | bios_offset&=0x1f; |
| 1034 | state->bios_offset++; |
| 1035 | state->bios_offset&=0x1f; |
| 1070 | 1036 | } |
| 1071 | 1037 | return res; |
| 1072 | 1038 | } |
| 1073 | 1039 | else |
| 1074 | 1040 | { |
| 1075 | 1041 | gfx_data = memory_region(space->machine, "pcg"); |
| 1076 | | calc_pcg_offset = (pcg_index_r[addr-1]) | ((addr-1)*0x800); |
| 1077 | | res = gfx_data[0x0000+calc_pcg_offset+(pcg_write_addr*8)]; |
| 1042 | calc_pcg_offset = (state->pcg_index_r[addr-1]) | ((addr-1)*0x800); |
| 1043 | res = gfx_data[0x0000+calc_pcg_offset+(state->pcg_write_addr*8)]; |
| 1078 | 1044 | |
| 1079 | | pcg_index_r[addr-1]++; |
| 1080 | | pcg_index_r[addr-1]&=0x7; |
| 1045 | state->pcg_index_r[addr-1]++; |
| 1046 | state->pcg_index_r[addr-1]&=0x7; |
| 1081 | 1047 | return res; |
| 1082 | 1048 | } |
| 1083 | 1049 | |
| r9674 | r9675 | |
| 1090 | 1056 | UINT8 *videoram = state->videoram; |
| 1091 | 1057 | int addr,pcg_offset; |
| 1092 | 1058 | UINT8 *PCG_RAM = memory_region(space->machine, "pcg"); |
| 1093 | | static UINT16 used_pcg_addr; |
| 1094 | 1059 | |
| 1095 | 1060 | addr = (offset & 0x300) >> 8; |
| 1096 | 1061 | |
| 1097 | | if(pcg_reset) |
| 1062 | if(state->pcg_reset) |
| 1098 | 1063 | { |
| 1099 | | pcg_index[0] = pcg_index[1] = pcg_index[2] = 0; |
| 1100 | | pcg_reset = 0; |
| 1064 | state->pcg_index[0] = state->pcg_index[1] = state->pcg_index[2] = 0; |
| 1065 | state->pcg_reset = 0; |
| 1101 | 1066 | } |
| 1102 | 1067 | |
| 1103 | 1068 | if(addr == 0) |
| r9674 | r9675 | |
| 1107 | 1072 | } |
| 1108 | 1073 | else |
| 1109 | 1074 | { |
| 1110 | | if(scrn_reg.pcg_mode) |
| 1075 | if(state->scrn_reg.pcg_mode) |
| 1111 | 1076 | { |
| 1112 | | used_pcg_addr = videoram[check_pcg_addr(space->machine)]*8; |
| 1113 | | pcg_index[addr-1] = (offset & 0xe) >> 1; |
| 1114 | | pcg_offset = (pcg_index[addr-1]+used_pcg_addr) & 0x7ff; |
| 1077 | state->used_pcg_addr = videoram[check_pcg_addr(space->machine)]*8; |
| 1078 | state->pcg_index[addr-1] = (offset & 0xe) >> 1; |
| 1079 | pcg_offset = (state->pcg_index[addr-1]+state->used_pcg_addr) & 0x7ff; |
| 1115 | 1080 | pcg_offset+=((addr-1)*0x800); |
| 1116 | 1081 | PCG_RAM[pcg_offset] = data; |
| 1117 | 1082 | |
| r9674 | r9675 | |
| 1122 | 1087 | else |
| 1123 | 1088 | { |
| 1124 | 1089 | /* TODO: understand what 1942, Herzog and friends wants there */ |
| 1125 | | used_pcg_addr = pcg_write_addr*8; |
| 1126 | | pcg_offset = (pcg_index[addr-1]+used_pcg_addr) & 0x7ff; |
| 1090 | state->used_pcg_addr = state->pcg_write_addr*8; |
| 1091 | pcg_offset = (state->pcg_index[addr-1]+state->used_pcg_addr) & 0x7ff; |
| 1127 | 1092 | pcg_offset+=((addr-1)*0x800); |
| 1128 | 1093 | PCG_RAM[pcg_offset] = data; |
| 1129 | 1094 | |
| r9674 | r9675 | |
| 1131 | 1096 | |
| 1132 | 1097 | gfx_element_mark_dirty(space->machine->gfx[1], pcg_offset >> 3); |
| 1133 | 1098 | |
| 1134 | | pcg_index[addr-1]++; |
| 1135 | | pcg_index[addr-1]&=7; |
| 1099 | state->pcg_index[addr-1]++; |
| 1100 | state->pcg_index[addr-1]&=7; |
| 1136 | 1101 | } |
| 1137 | 1102 | } |
| 1138 | 1103 | } |
| r9674 | r9675 | |
| 1144 | 1109 | *************************************/ |
| 1145 | 1110 | |
| 1146 | 1111 | /* for bitmap mode */ |
| 1147 | | static UINT8 x_b,x_g,x_r; |
| 1148 | 1112 | |
| 1149 | 1113 | static void set_current_palette(running_machine *machine) |
| 1150 | 1114 | { |
| 1115 | x1_state *state = machine->driver_data<x1_state>(); |
| 1151 | 1116 | UINT8 addr,r,g,b; |
| 1152 | 1117 | |
| 1153 | 1118 | for(addr=0;addr<8;addr++) |
| 1154 | 1119 | { |
| 1155 | | r = ((x_r)>>(addr)) & 1; |
| 1156 | | g = ((x_g)>>(addr)) & 1; |
| 1157 | | b = ((x_b)>>(addr)) & 1; |
| 1120 | r = ((state->x_r)>>(addr)) & 1; |
| 1121 | g = ((state->x_g)>>(addr)) & 1; |
| 1122 | b = ((state->x_b)>>(addr)) & 1; |
| 1158 | 1123 | |
| 1159 | 1124 | palette_set_color_rgb(machine, addr+0x100, pal1bit(r), pal1bit(g), pal1bit(b)); |
| 1160 | 1125 | } |
| 1161 | 1126 | } |
| 1162 | 1127 | |
| 1163 | | static WRITE8_HANDLER( x1_pal_r_w ) { x_r = data; set_current_palette(space->machine); } |
| 1164 | | static WRITE8_HANDLER( x1_pal_g_w ) { x_g = data; set_current_palette(space->machine); } |
| 1165 | | static WRITE8_HANDLER( x1_pal_b_w ) { x_b = data; set_current_palette(space->machine); } |
| 1128 | static WRITE8_HANDLER( x1_pal_r_w ) |
| 1129 | { |
| 1130 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1131 | state->x_r = data; |
| 1132 | set_current_palette(space->machine); |
| 1133 | } |
| 1166 | 1134 | |
| 1135 | static WRITE8_HANDLER( x1_pal_g_w ) |
| 1136 | { |
| 1137 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1138 | state->x_g = data; |
| 1139 | set_current_palette(space->machine); |
| 1140 | } |
| 1141 | |
| 1142 | static WRITE8_HANDLER( x1_pal_b_w ) |
| 1143 | { |
| 1144 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1145 | state->x_b = data; |
| 1146 | set_current_palette(space->machine); |
| 1147 | } |
| 1148 | |
| 1167 | 1149 | static WRITE8_HANDLER( x1_ex_gfxram_w ) |
| 1168 | 1150 | { |
| 1151 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1169 | 1152 | UINT8 ex_mask; |
| 1170 | 1153 | |
| 1171 | 1154 | if (offset >= 0x0000 && offset <= 0x3fff) { ex_mask = 7; } |
| r9674 | r9675 | |
| 1173 | 1156 | else if(offset >= 0x8000 && offset <= 0xbfff) { ex_mask = 5; } |
| 1174 | 1157 | else { ex_mask = 3; } |
| 1175 | 1158 | |
| 1176 | | if(ex_mask & 1) { gfx_bitmap_ram[(offset & 0x3fff)+0x0000+(scrn_reg.gfx_bank*0xc000)] = data; } |
| 1177 | | if(ex_mask & 2) { gfx_bitmap_ram[(offset & 0x3fff)+0x4000+(scrn_reg.gfx_bank*0xc000)] = data; } |
| 1178 | | if(ex_mask & 4) { gfx_bitmap_ram[(offset & 0x3fff)+0x8000+(scrn_reg.gfx_bank*0xc000)] = data; } |
| 1159 | if(ex_mask & 1) { state->gfx_bitmap_ram[(offset & 0x3fff)+0x0000+(state->scrn_reg.gfx_bank*0xc000)] = data; } |
| 1160 | if(ex_mask & 2) { state->gfx_bitmap_ram[(offset & 0x3fff)+0x4000+(state->scrn_reg.gfx_bank*0xc000)] = data; } |
| 1161 | if(ex_mask & 4) { state->gfx_bitmap_ram[(offset & 0x3fff)+0x8000+(state->scrn_reg.gfx_bank*0xc000)] = data; } |
| 1179 | 1162 | } |
| 1180 | 1163 | |
| 1181 | 1164 | /* |
| r9674 | r9675 | |
| 1195 | 1178 | */ |
| 1196 | 1179 | static WRITE8_HANDLER( x1_scrn_w ) |
| 1197 | 1180 | { |
| 1198 | | scrn_reg.pcg_mode = (data & 0x20)>>5; |
| 1199 | | scrn_reg.gfx_bank = (data & 0x10)>>4; |
| 1200 | | scrn_reg.disp_bank = (data & 0x08)>>3; |
| 1201 | | scrn_reg.v400_mode = ((data & 0x03) == 3) ? 1 : 0; |
| 1181 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1182 | state->scrn_reg.pcg_mode = (data & 0x20)>>5; |
| 1183 | state->scrn_reg.gfx_bank = (data & 0x10)>>4; |
| 1184 | state->scrn_reg.disp_bank = (data & 0x08)>>3; |
| 1185 | state->scrn_reg.v400_mode = ((data & 0x03) == 3) ? 1 : 0; |
| 1202 | 1186 | if(data & 0xc4) |
| 1203 | 1187 | printf("SCRN = %02x\n",data & 0xc4); |
| 1204 | 1188 | } |
| 1205 | 1189 | |
| 1206 | 1190 | static WRITE8_HANDLER( x1_ply_w ) |
| 1207 | 1191 | { |
| 1208 | | scrn_reg.ply = data; |
| 1192 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1193 | state->scrn_reg.ply = data; |
| 1209 | 1194 | // printf("PLY = %02x\n",data); |
| 1210 | 1195 | } |
| 1211 | 1196 | |
| 1212 | 1197 | static WRITE8_HANDLER( x1_6845_w ) |
| 1213 | 1198 | { |
| 1214 | | static int addr_latch; |
| 1215 | | |
| 1199 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1216 | 1200 | if(offset == 0) |
| 1217 | 1201 | { |
| 1218 | | addr_latch = data; |
| 1202 | state->addr_latch = data; |
| 1219 | 1203 | mc6845_address_w(space->machine->device("crtc"), 0,data); |
| 1220 | 1204 | } |
| 1221 | 1205 | else |
| 1222 | 1206 | { |
| 1223 | 1207 | /* FIXME: this should be inside the MC6845 core! */ |
| 1224 | | if(addr_latch == 0x09) |
| 1225 | | tile_height = data; |
| 1226 | | if(addr_latch == 0x0c) |
| 1227 | | crtc_start_addr = ((data<<8) & 0x3f00) | (crtc_start_addr & 0xff); |
| 1228 | | else if(addr_latch == 0x0d) |
| 1229 | | crtc_start_addr = (crtc_start_addr & 0x3f00) | (data & 0xff); |
| 1208 | if(state->addr_latch == 0x09) |
| 1209 | state->tile_height = data; |
| 1210 | if(state->addr_latch == 0x0c) |
| 1211 | state->crtc_start_addr = ((data<<8) & 0x3f00) | (state->crtc_start_addr & 0xff); |
| 1212 | else if(state->addr_latch == 0x0d) |
| 1213 | state->crtc_start_addr = (state->crtc_start_addr & 0x3f00) | (data & 0xff); |
| 1230 | 1214 | |
| 1231 | 1215 | mc6845_register_w(space->machine->device("crtc"), 0,data); |
| 1232 | 1216 | |
| r9674 | r9675 | |
| 1237 | 1221 | |
| 1238 | 1222 | static READ8_HANDLER( x1_blackclip_r ) |
| 1239 | 1223 | { |
| 1240 | | return scrn_reg.blackclip; |
| 1224 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1225 | return state->scrn_reg.blackclip; |
| 1241 | 1226 | } |
| 1242 | 1227 | |
| 1243 | 1228 | static WRITE8_HANDLER( x1_blackclip_w ) |
| 1244 | 1229 | { |
| 1245 | | scrn_reg.blackclip = data; |
| 1230 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1231 | state->scrn_reg.blackclip = data; |
| 1246 | 1232 | } |
| 1247 | 1233 | |
| 1248 | | static READ8_HANDLER( x1turbo_pal_r ) { return turbo_reg.pal; } |
| 1249 | | static READ8_HANDLER( x1turbo_txpal_r ) { return turbo_reg.txt_pal[offset]; } |
| 1250 | | static READ8_HANDLER( x1turbo_txdisp_r ) { return turbo_reg.txt_disp; } |
| 1251 | | static READ8_HANDLER( x1turbo_gfxpal_r ) { return turbo_reg.gfx_pal; } |
| 1234 | static READ8_HANDLER( x1turbo_pal_r ) |
| 1235 | { |
| 1236 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1237 | return state->turbo_reg.pal; |
| 1238 | } |
| 1252 | 1239 | |
| 1240 | static READ8_HANDLER( x1turbo_txpal_r ) |
| 1241 | { |
| 1242 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1243 | return state->turbo_reg.txt_pal[offset]; |
| 1244 | } |
| 1245 | |
| 1246 | static READ8_HANDLER( x1turbo_txdisp_r ) |
| 1247 | { |
| 1248 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1249 | return state->turbo_reg.txt_disp; |
| 1250 | } |
| 1251 | |
| 1252 | static READ8_HANDLER( x1turbo_gfxpal_r ) |
| 1253 | { |
| 1254 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1255 | return state->turbo_reg.gfx_pal; |
| 1256 | } |
| 1257 | |
| 1253 | 1258 | static WRITE8_HANDLER( x1turbo_pal_w ) |
| 1254 | 1259 | { |
| 1260 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1255 | 1261 | printf("TURBO PAL %02x\n",data); |
| 1256 | | turbo_reg.pal = data; |
| 1262 | state->turbo_reg.pal = data; |
| 1257 | 1263 | } |
| 1258 | 1264 | |
| 1259 | 1265 | static WRITE8_HANDLER( x1turbo_txpal_w ) |
| 1260 | 1266 | { |
| 1267 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1261 | 1268 | int r,g,b; |
| 1262 | 1269 | |
| 1263 | 1270 | printf("TURBO TEXT PAL %02x %02x\n",data,offset); |
| 1264 | | turbo_reg.txt_pal[offset] = data; |
| 1271 | state->turbo_reg.txt_pal[offset] = data; |
| 1265 | 1272 | |
| 1266 | | if(turbo_reg.pal & 0x80) |
| 1273 | if(state->turbo_reg.pal & 0x80) |
| 1267 | 1274 | { |
| 1268 | 1275 | r = (data & 0x0c) >> 2; |
| 1269 | 1276 | g = (data & 0x30) >> 4; |
| r9674 | r9675 | |
| 1275 | 1282 | |
| 1276 | 1283 | static WRITE8_HANDLER( x1turbo_txdisp_w ) |
| 1277 | 1284 | { |
| 1285 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1278 | 1286 | printf("TURBO TEXT DISPLAY %02x\n",data); |
| 1279 | | turbo_reg.txt_disp = data; |
| 1287 | state->turbo_reg.txt_disp = data; |
| 1280 | 1288 | } |
| 1281 | 1289 | |
| 1282 | 1290 | static WRITE8_HANDLER( x1turbo_gfxpal_w ) |
| 1283 | 1291 | { |
| 1292 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1284 | 1293 | printf("TURBO GFX PAL %02x\n",data); |
| 1285 | | turbo_reg.gfx_pal = data; |
| 1294 | state->turbo_reg.gfx_pal = data; |
| 1286 | 1295 | } |
| 1287 | 1296 | |
| 1288 | | static UINT8 kanji_addr_l,kanji_addr_h,kanji_count; |
| 1289 | | static UINT32 kanji_addr; |
| 1290 | 1297 | |
| 1291 | 1298 | /* |
| 1292 | 1299 | * FIXME: this makes no sense atm, the only game that uses this function so far is Hyper Olympics '84 disk version |
| 1293 | 1300 | */ |
| 1294 | 1301 | static READ8_HANDLER( x1_kanji_r ) |
| 1295 | 1302 | { |
| 1303 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1296 | 1304 | UINT8 *kanji_rom = memory_region(space->machine, "kanji"); |
| 1297 | 1305 | UINT8 res; |
| 1298 | 1306 | |
| 1299 | 1307 | //res = 0; |
| 1300 | 1308 | |
| 1301 | | printf("%08x\n",kanji_addr*0x20+kanji_count); |
| 1309 | printf("%08x\n",state->kanji_addr*0x20+state->kanji_count); |
| 1302 | 1310 | |
| 1303 | | res = kanji_rom[(kanji_addr*0x20)+(kanji_count)]; |
| 1304 | | kanji_count++; |
| 1305 | | kanji_count&=0x1f; |
| 1311 | res = kanji_rom[(state->kanji_addr*0x20)+(state->kanji_count)]; |
| 1312 | state->kanji_count++; |
| 1313 | state->kanji_count&=0x1f; |
| 1306 | 1314 | |
| 1307 | 1315 | //printf("%04x R\n",offset); |
| 1308 | 1316 | |
| r9674 | r9675 | |
| 1311 | 1319 | |
| 1312 | 1320 | static WRITE8_HANDLER( x1_kanji_w ) |
| 1313 | 1321 | { |
| 1322 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1314 | 1323 | // if(offset < 2) |
| 1315 | 1324 | printf("%04x %02x W\n",offset,data); |
| 1316 | 1325 | |
| 1317 | 1326 | switch(offset) |
| 1318 | 1327 | { |
| 1319 | | case 0: kanji_addr_l = (data & 0xff); break; |
| 1320 | | case 1: kanji_addr_h = (data & 0xff); kanji_count = 0; break; |
| 1328 | case 0: state->kanji_addr_l = (data & 0xff); break; |
| 1329 | case 1: state->kanji_addr_h = (data & 0xff); state->kanji_count = 0; break; |
| 1321 | 1330 | case 2: |
| 1322 | 1331 | if(data) |
| 1323 | 1332 | { |
| 1324 | | kanji_addr = (kanji_addr_h<<8) | (kanji_addr_l); |
| 1325 | | //kanji_addr &= 0x3fff; //<- temp kludge until the rom is redumped. |
| 1326 | | //printf("%08x\n",kanji_addr); |
| 1327 | | //kanji_addr+= kanji_count; |
| 1333 | state->kanji_addr = (state->kanji_addr_h<<8) | (state->kanji_addr_l); |
| 1334 | //state->kanji_addr &= 0x3fff; //<- temp kludge until the rom is redumped. |
| 1335 | //printf("%08x\n",state->kanji_addr); |
| 1336 | //state->kanji_addr+= state->kanji_count; |
| 1328 | 1337 | } |
| 1329 | 1338 | break; |
| 1330 | 1339 | } |
| r9674 | r9675 | |
| 1340 | 1349 | { |
| 1341 | 1350 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1342 | 1351 | UINT8 *videoram = state->videoram; |
| 1343 | | io_bank_mode = 0; //any read disables the extended mode. |
| 1352 | state->io_bank_mode = 0; //any read disables the extended mode. |
| 1344 | 1353 | |
| 1345 | 1354 | //if(offset >= 0x0704 && offset <= 0x0707) { return z80ctc_r(space->machine->device("ctc"), offset-0x0704); } |
| 1346 | 1355 | if(offset == 0x0e03) { return x1_rom_r(space, 0); } |
| r9674 | r9675 | |
| 1356 | 1365 | else if(offset >= 0x1fa8 && offset <= 0x1fab) { return z80ctc_r(space->machine->device("ctc"), offset-0x1fa8); } |
| 1357 | 1366 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } |
| 1358 | 1367 | // else if(offset == 0x1fe0) { return x1_blackclip_r(space,0); } |
| 1359 | | else if(offset >= 0x2000 && offset <= 0x2fff) { return x1_colorram[offset-0x2000]; } |
| 1368 | else if(offset >= 0x2000 && offset <= 0x2fff) { return state->colorram[offset-0x2000]; } |
| 1360 | 1369 | else if(offset >= 0x3000 && offset <= 0x3fff) { return videoram[offset-0x3000]; } |
| 1361 | | else if(offset >= 0x4000 && offset <= 0xffff) { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; } |
| 1370 | else if(offset >= 0x4000 && offset <= 0xffff) { return state->gfx_bitmap_ram[offset-0x4000+(state->scrn_reg.gfx_bank*0xc000)]; } |
| 1362 | 1371 | else |
| 1363 | 1372 | { |
| 1364 | 1373 | logerror("(PC=%06x) Read i/o address %04x\n",cpu_get_pc(space->cpu),offset); |
| r9674 | r9675 | |
| 1370 | 1379 | { |
| 1371 | 1380 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1372 | 1381 | UINT8 *videoram = state->videoram; |
| 1373 | | if(io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| 1382 | if(state->io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| 1374 | 1383 | // else if(offset >= 0x0704 && offset <= 0x0707) { z80ctc_w(space->machine->device("ctc"), offset-0x0704,data); } |
| 1375 | 1384 | // else if(offset >= 0x0c00 && offset <= 0x0cff) { x1_rs232c_w(space->machine, 0, data); } |
| 1376 | 1385 | else if(offset >= 0x0e00 && offset <= 0x0e02) { x1_rom_w(space, offset-0xe00,data); } |
| r9674 | r9675 | |
| 1399 | 1408 | // else if(offset == 0x1fc5) { x1turbo_gfxpal_w(space,0,data); } |
| 1400 | 1409 | else if(offset >= 0x1fd0 && offset <= 0x1fdf) { x1_scrn_w(space,0,data); } |
| 1401 | 1410 | // else if(offset == 0x1fe0) { x1_blackclip_w(space,0,data); } |
| 1402 | | else if(offset >= 0x2000 && offset <= 0x2fff) { x1_colorram[offset-0x2000] = data; } |
| 1403 | | else if(offset >= 0x3000 && offset <= 0x3fff) { videoram[offset-0x3000] = pcg_write_addr = data; } |
| 1404 | | else if(offset >= 0x4000 && offset <= 0xffff) { gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)] = data; } |
| 1411 | else if(offset >= 0x2000 && offset <= 0x2fff) { state->colorram[offset-0x2000] = data; } |
| 1412 | else if(offset >= 0x3000 && offset <= 0x3fff) { videoram[offset-0x3000] = state->pcg_write_addr = data; } |
| 1413 | else if(offset >= 0x4000 && offset <= 0xffff) { state->gfx_bitmap_ram[offset-0x4000+(state->scrn_reg.gfx_bank*0xc000)] = data; } |
| 1405 | 1414 | else |
| 1406 | 1415 | { |
| 1407 | 1416 | logerror("(PC=%06x) Write %02x at i/o address %04x\n",cpu_get_pc(space->cpu),data,offset); |
| r9674 | r9675 | |
| 1412 | 1421 | { |
| 1413 | 1422 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1414 | 1423 | UINT8 *videoram = state->videoram; |
| 1415 | | io_bank_mode = 0; //any read disables the extended mode. |
| 1424 | state->io_bank_mode = 0; //any read disables the extended mode. |
| 1416 | 1425 | |
| 1417 | 1426 | if(offset == 0x0700) { return (ym2151_r(space->machine->device("ym"), offset-0x0700) & 0x7f) | (input_port_read(space->machine, "SOUND_SW") & 0x80); } |
| 1418 | 1427 | else if(offset == 0x0701) { return ym2151_r(space->machine->device("ym"), offset-0x0700); } |
| r9674 | r9675 | |
| 1435 | 1444 | else if(offset == 0x1fc5) { return x1turbo_gfxpal_r(space,0); } |
| 1436 | 1445 | // else if(offset >= 0x1fd0 && offset <= 0x1fdf) { return x1_scrn_r(space,offset-0x1fd0); } |
| 1437 | 1446 | else if(offset == 0x1fe0) { return x1_blackclip_r(space,0); } |
| 1438 | | else if(offset >= 0x2000 && offset <= 0x2fff) { return x1_colorram[offset-0x2000]; } |
| 1447 | else if(offset >= 0x2000 && offset <= 0x2fff) { return state->colorram[offset-0x2000]; } |
| 1439 | 1448 | else if(offset >= 0x3000 && offset <= 0x3fff) { return videoram[offset-0x3000]; } |
| 1440 | | else if(offset >= 0x4000 && offset <= 0xffff) { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; } |
| 1449 | else if(offset >= 0x4000 && offset <= 0xffff) { return state->gfx_bitmap_ram[offset-0x4000+(state->scrn_reg.gfx_bank*0xc000)]; } |
| 1441 | 1450 | else |
| 1442 | 1451 | { |
| 1443 | 1452 | //0xfd0-0xfd7: FDC extended area? |
| r9674 | r9675 | |
| 1451 | 1460 | { |
| 1452 | 1461 | x1_state *state = space->machine->driver_data<x1_state>(); |
| 1453 | 1462 | UINT8 *videoram = state->videoram; |
| 1454 | | if(io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| 1463 | if(state->io_bank_mode == 1) { x1_ex_gfxram_w(space, offset, data); } |
| 1455 | 1464 | else if(offset == 0x0700 || offset == 0x0701) { ym2151_w(space->machine->device("ym"), offset-0x0700,data); } |
| 1456 | 1465 | else if(offset >= 0x0704 && offset <= 0x0707) { z80ctc_w(space->machine->device("ctc"), offset-0x0704,data); } |
| 1457 | 1466 | // else if(offset >= 0x0c00 && offset <= 0x0cff) { x1_rs232c_w(space->machine, 0, data); } |
| r9674 | r9675 | |
| 1481 | 1490 | else if(offset == 0x1fc5) { x1turbo_gfxpal_w(space,0,data); } |
| 1482 | 1491 | else if(offset >= 0x1fd0 && offset <= 0x1fdf) { x1_scrn_w(space,0,data); } |
| 1483 | 1492 | else if(offset == 0x1fe0) { x1_blackclip_w(space,0,data); } |
| 1484 | | else if(offset >= 0x2000 && offset <= 0x2fff) { x1_colorram[offset-0x2000] = data; } |
| 1485 | | else if(offset >= 0x3000 && offset <= 0x3fff) { videoram[offset-0x3000] = pcg_write_addr = data; } |
| 1486 | | else if(offset >= 0x4000 && offset <= 0xffff) { gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)] = data; } |
| 1493 | else if(offset >= 0x2000 && offset <= 0x2fff) { state->colorram[offset-0x2000] = data; } |
| 1494 | else if(offset >= 0x3000 && offset <= 0x3fff) { videoram[offset-0x3000] = state->pcg_write_addr = data; } |
| 1495 | else if(offset >= 0x4000 && offset <= 0xffff) { state->gfx_bitmap_ram[offset-0x4000+(state->scrn_reg.gfx_bank*0xc000)] = data; } |
| 1487 | 1496 | else |
| 1488 | 1497 | { |
| 1489 | 1498 | logerror("(PC=%06x) Write %02x at i/o address %04x\n",cpu_get_pc(space->cpu),data,offset); |
| r9674 | r9675 | |
| 1522 | 1531 | /* this port is system related */ |
| 1523 | 1532 | static READ8_DEVICE_HANDLER( x1_portb_r ) |
| 1524 | 1533 | { |
| 1534 | x1_state *state = device->machine->driver_data<x1_state>(); |
| 1525 | 1535 | //printf("PPI Port B read\n"); |
| 1526 | 1536 | /* |
| 1527 | 1537 | x--- ---- "v disp" |
| r9674 | r9675 | |
| 1534 | 1544 | ---- ---x "cmt test" (active low) |
| 1535 | 1545 | */ |
| 1536 | 1546 | UINT8 dat = 0; |
| 1537 | | vdisp = (device->machine->primary_screen->vpos() < 200) ? 0x80 : 0x00; |
| 1538 | | dat = (input_port_read(device->machine, "SYSTEM") & 0x10) | sub_obf | vsync | vdisp; |
| 1547 | state->vdisp = (device->machine->primary_screen->vpos() < 200) ? 0x80 : 0x00; |
| 1548 | dat = (input_port_read(device->machine, "SYSTEM") & 0x10) | state->sub_obf | state->vsync | state->vdisp; |
| 1539 | 1549 | |
| 1540 | 1550 | if(cassette_input(device->machine->device("cass")) > 0.03) |
| 1541 | 1551 | dat |= 0x02; |
| r9674 | r9675 | |
| 1546 | 1556 | // CMT test bit is set low when the CMT Stop command is issued, and becomes |
| 1547 | 1557 | // high again when this bit is read. |
| 1548 | 1558 | dat |= 0x01; |
| 1549 | | if(cmt_test != 0) |
| 1559 | if(state->cmt_test != 0) |
| 1550 | 1560 | { |
| 1551 | | cmt_test = 0; |
| 1561 | state->cmt_test = 0; |
| 1552 | 1562 | dat &= ~0x01; |
| 1553 | 1563 | } |
| 1554 | 1564 | |
| r9674 | r9675 | |
| 1558 | 1568 | /* I/O system port */ |
| 1559 | 1569 | static READ8_DEVICE_HANDLER( x1_portc_r ) |
| 1560 | 1570 | { |
| 1571 | x1_state *state = device->machine->driver_data<x1_state>(); |
| 1561 | 1572 | //printf("PPI Port C read\n"); |
| 1562 | 1573 | /* |
| 1563 | 1574 | x--x xxxx <unknown> |
| 1564 | 1575 | -x-- ---- 320 mode (r/w) |
| 1565 | 1576 | --x- ---- i/o mode (r/w) |
| 1566 | 1577 | */ |
| 1567 | | return (io_sys & 0x9f) | hres_320 | ~io_switch; |
| 1578 | return (state->io_sys & 0x9f) | state->hres_320 | ~state->io_switch; |
| 1568 | 1579 | } |
| 1569 | 1580 | |
| 1570 | 1581 | static WRITE8_DEVICE_HANDLER( x1_porta_w ) |
| r9674 | r9675 | |
| 1579 | 1590 | |
| 1580 | 1591 | static WRITE8_DEVICE_HANDLER( x1_portc_w ) |
| 1581 | 1592 | { |
| 1582 | | hres_320 = data & 0x40; |
| 1593 | x1_state *state = device->machine->driver_data<x1_state>(); |
| 1594 | state->hres_320 = data & 0x40; |
| 1583 | 1595 | |
| 1584 | | if(((data & 0x20) == 0) && (io_switch & 0x20)) |
| 1585 | | io_bank_mode = 1; |
| 1596 | if(((data & 0x20) == 0) && (state->io_switch & 0x20)) |
| 1597 | state->io_bank_mode = 1; |
| 1586 | 1598 | |
| 1587 | | io_switch = data & 0x20; |
| 1588 | | io_sys = data & 0xff; |
| 1599 | state->io_switch = data & 0x20; |
| 1600 | state->io_sys = data & 0xff; |
| 1589 | 1601 | |
| 1590 | 1602 | cassette_output(device->machine->device("cass"),(data & 0x01) ? +1.0 : -1.0); |
| 1591 | 1603 | } |
| r9674 | r9675 | |
| 1602 | 1614 | |
| 1603 | 1615 | static WRITE_LINE_DEVICE_HANDLER(vsync_changed) |
| 1604 | 1616 | { |
| 1605 | | static UINT8 pcg_reset_occurred; |
| 1606 | | |
| 1607 | | vsync = (state & 1) ? 0x04 : 0x00; |
| 1608 | | if(state & 1 && pcg_reset_occurred == 0) { pcg_reset = pcg_reset_occurred = 1; } |
| 1609 | | if(!(state & 1)) { pcg_reset_occurred = 0; } |
| 1610 | | //printf("%d %02x\n",device->machine->primary_screen->vpos(),vsync); |
| 1617 | x1_state *drvstate = device->machine->driver_data<x1_state>(); |
| 1618 | drvstate->vsync = (state & 1) ? 0x04 : 0x00; |
| 1619 | if(state & 1 && drvstate->pcg_reset_occurred == 0) { drvstate->pcg_reset = drvstate->pcg_reset_occurred = 1; } |
| 1620 | if(!(state & 1)) { drvstate->pcg_reset_occurred = 0; } |
| 1621 | //printf("%d %02x\n",device->machine->primary_screen->vpos(),drvstate->vsync); |
| 1611 | 1622 | } |
| 1612 | 1623 | |
| 1613 | 1624 | static const mc6845_interface mc6845_intf = |
| r9674 | r9675 | |
| 2047 | 2058 | #ifdef UNUSED_FUNCTION |
| 2048 | 2059 | static IRQ_CALLBACK(x1_irq_callback) |
| 2049 | 2060 | { |
| 2050 | | if(ctc_irq_flag != 0) |
| 2061 | x1_state *state = device->machine->driver_data<x1_state>(); |
| 2062 | if(state->ctc_irq_flag != 0) |
| 2051 | 2063 | { |
| 2052 | | ctc_irq_flag = 0; |
| 2053 | | if(x1_key_irq_flag == 0) // if no other devices are pulling the IRQ line high |
| 2064 | state->ctc_irq_flag = 0; |
| 2065 | if(state->key_irq_flag == 0) // if no other devices are pulling the IRQ line high |
| 2054 | 2066 | cpu_set_input_line(device, 0, CLEAR_LINE); |
| 2055 | | return x1_irq_vector; |
| 2067 | return state->irq_vector; |
| 2056 | 2068 | } |
| 2057 | | if(x1_key_irq_flag != 0) |
| 2069 | if(state->key_irq_flag != 0) |
| 2058 | 2070 | { |
| 2059 | | x1_key_irq_flag = 0; |
| 2060 | | if(ctc_irq_flag == 0) // if no other devices are pulling the IRQ line high |
| 2071 | state->key_irq_flag = 0; |
| 2072 | if(state->ctc_irq_flag == 0) // if no other devices are pulling the IRQ line high |
| 2061 | 2073 | cpu_set_input_line(device, 0, CLEAR_LINE); |
| 2062 | | return x1_key_irq_vector; |
| 2074 | return state->key_irq_vector; |
| 2063 | 2075 | } |
| 2064 | | return x1_irq_vector; |
| 2076 | return state->irq_vector; |
| 2065 | 2077 | } |
| 2066 | 2078 | #endif |
| 2067 | 2079 | |
| 2068 | 2080 | static TIMER_CALLBACK(keyboard_callback) |
| 2069 | 2081 | { |
| 2082 | x1_state *state = machine->driver_data<x1_state>(); |
| 2070 | 2083 | address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 2071 | 2084 | UINT32 key1 = input_port_read(machine,"key1"); |
| 2072 | 2085 | UINT32 key2 = input_port_read(machine,"key2"); |
| 2073 | 2086 | UINT32 key3 = input_port_read(machine,"key3"); |
| 2074 | 2087 | UINT32 key4 = input_port_read(machine,"tenkey"); |
| 2075 | 2088 | UINT32 f_key = input_port_read(machine, "f_keys"); |
| 2076 | | static UINT32 old_key1,old_key2,old_key3,old_key4,old_fkey; |
| 2077 | 2089 | |
| 2078 | | if(x1_key_irq_vector) |
| 2090 | if(state->key_irq_vector) |
| 2079 | 2091 | { |
| 2080 | | if((key1 != old_key1) || (key2 != old_key2) || (key3 != old_key3) || (key4 != old_key4) || (f_key != old_fkey)) |
| 2092 | if((key1 != state->old_key1) || (key2 != state->old_key2) || (key3 != state->old_key3) || (key4 != state->old_key4) || (f_key != state->old_fkey)) |
| 2081 | 2093 | { |
| 2082 | 2094 | // generate keyboard IRQ |
| 2083 | 2095 | sub_io_w(space,0,0xe6); |
| 2084 | | x1_irq_vector = x1_key_irq_vector; |
| 2085 | | x1_key_irq_flag = 1; |
| 2096 | state->irq_vector = state->key_irq_vector; |
| 2097 | state->key_irq_flag = 1; |
| 2086 | 2098 | cputag_set_input_line(machine,"maincpu",0,ASSERT_LINE); |
| 2087 | | old_key1 = key1; |
| 2088 | | old_key2 = key2; |
| 2089 | | old_key3 = key3; |
| 2090 | | old_key4 = key4; |
| 2091 | | old_fkey = f_key; |
| 2099 | state->old_key1 = key1; |
| 2100 | state->old_key2 = key2; |
| 2101 | state->old_key3 = key3; |
| 2102 | state->old_key4 = key4; |
| 2103 | state->old_fkey = f_key; |
| 2092 | 2104 | } |
| 2093 | 2105 | } |
| 2094 | 2106 | } |
| 2095 | 2107 | |
| 2096 | 2108 | static TIMER_CALLBACK(x1_rtc_increment) |
| 2097 | 2109 | { |
| 2110 | x1_state *state = machine->driver_data<x1_state>(); |
| 2098 | 2111 | static const UINT8 dpm[12] = { 0x31, 0x28, 0x31, 0x30, 0x31, 0x30, 0x31, 0x31, 0x30, 0x31, 0x30, 0x31 }; |
| 2099 | 2112 | |
| 2100 | | x1_rtc.sec++; |
| 2113 | state->rtc.sec++; |
| 2101 | 2114 | |
| 2102 | | if((x1_rtc.sec & 0x0f) >= 0x0a) { x1_rtc.sec+=0x10; x1_rtc.sec&=0xf0; } |
| 2103 | | if((x1_rtc.sec & 0xf0) >= 0x60) { x1_rtc.min++; x1_rtc.sec = 0; } |
| 2104 | | if((x1_rtc.min & 0x0f) >= 0x0a) { x1_rtc.min+=0x10; x1_rtc.min&=0xf0; } |
| 2105 | | if((x1_rtc.min & 0xf0) >= 0x60) { x1_rtc.hour++; x1_rtc.min = 0; } |
| 2106 | | if((x1_rtc.hour & 0x0f) >= 0x0a) { x1_rtc.hour+=0x10; x1_rtc.hour&=0xf0; } |
| 2107 | | if((x1_rtc.hour & 0xff) >= 0x24) { x1_rtc.day++; x1_rtc.wday++; x1_rtc.hour = 0; } |
| 2108 | | if((x1_rtc.wday & 0x0f) >= 0x07) { x1_rtc.wday = 0; } |
| 2109 | | if((x1_rtc.day & 0x0f) >= 0x0a) { x1_rtc.day+=0x10; x1_rtc.day&=0xf0; } |
| 2115 | if((state->rtc.sec & 0x0f) >= 0x0a) { state->rtc.sec+=0x10; state->rtc.sec&=0xf0; } |
| 2116 | if((state->rtc.sec & 0xf0) >= 0x60) { state->rtc.min++; state->rtc.sec = 0; } |
| 2117 | if((state->rtc.min & 0x0f) >= 0x0a) { state->rtc.min+=0x10; state->rtc.min&=0xf0; } |
| 2118 | if((state->rtc.min & 0xf0) >= 0x60) { state->rtc.hour++; state->rtc.min = 0; } |
| 2119 | if((state->rtc.hour & 0x0f) >= 0x0a) { state->rtc.hour+=0x10; state->rtc.hour&=0xf0; } |
| 2120 | if((state->rtc.hour & 0xff) >= 0x24) { state->rtc.day++; state->rtc.wday++; state->rtc.hour = 0; } |
| 2121 | if((state->rtc.wday & 0x0f) >= 0x07) { state->rtc.wday = 0; } |
| 2122 | if((state->rtc.day & 0x0f) >= 0x0a) { state->rtc.day+=0x10; state->rtc.day&=0xf0; } |
| 2110 | 2123 | /* FIXME: very crude leap year support (i.e. it treats the RTC to be with a 2000-2099 timeline), dunno how the real x1 supports this, |
| 2111 | 2124 | maybe it just have a 1980-1999 timeline since year 0x00 shows as a XX on display */ |
| 2112 | | if(((x1_rtc.year % 4) == 0) && x1_rtc.month == 2) |
| 2125 | if(((state->rtc.year % 4) == 0) && state->rtc.month == 2) |
| 2113 | 2126 | { |
| 2114 | | if((x1_rtc.day & 0xff) >= dpm[x1_rtc.month-1]+1+1) |
| 2115 | | { x1_rtc.month++; x1_rtc.day = 0x01; } |
| 2127 | if((state->rtc.day & 0xff) >= dpm[state->rtc.month-1]+1+1) |
| 2128 | { state->rtc.month++; state->rtc.day = 0x01; } |
| 2116 | 2129 | } |
| 2117 | | else if((x1_rtc.day & 0xff) >= dpm[x1_rtc.month-1]+1){ x1_rtc.month++; x1_rtc.day = 0x01; } |
| 2118 | | if(x1_rtc.month > 12) { x1_rtc.year++; x1_rtc.month = 0x01; } |
| 2119 | | if((x1_rtc.year & 0x0f) >= 0x0a) { x1_rtc.year+=0x10; x1_rtc.year&=0xf0; } |
| 2120 | | if((x1_rtc.year & 0xf0) >= 0xa0) { x1_rtc.year = 0; } //roll over |
| 2130 | else if((state->rtc.day & 0xff) >= dpm[state->rtc.month-1]+1){ state->rtc.month++; state->rtc.day = 0x01; } |
| 2131 | if(state->rtc.month > 12) { state->rtc.year++; state->rtc.month = 0x01; } |
| 2132 | if((state->rtc.year & 0x0f) >= 0x0a) { state->rtc.year+=0x10; state->rtc.year&=0xf0; } |
| 2133 | if((state->rtc.year & 0xf0) >= 0xa0) { state->rtc.year = 0; } //roll over |
| 2121 | 2134 | } |
| 2122 | 2135 | |
| 2123 | 2136 | static MACHINE_RESET( x1 ) |
| 2124 | 2137 | { |
| 2138 | x1_state *state = machine->driver_data<x1_state>(); |
| 2125 | 2139 | UINT8 *ROM = memory_region(machine, "maincpu"); |
| 2126 | 2140 | UINT8 *PCG_RAM = memory_region(machine, "pcg"); |
| 2127 | 2141 | int i; |
| 2128 | 2142 | |
| 2129 | 2143 | memory_set_bankptr(machine, "bank1", &ROM[0x00000]); |
| 2130 | 2144 | |
| 2131 | | memset(gfx_bitmap_ram,0x00,0xc000*2); |
| 2145 | memset(state->gfx_bitmap_ram,0x00,0xc000*2); |
| 2132 | 2146 | |
| 2133 | 2147 | for(i=0;i<0x1800;i++) |
| 2134 | 2148 | { |
| r9674 | r9675 | |
| 2141 | 2155 | } |
| 2142 | 2156 | |
| 2143 | 2157 | /* X1 Turbo specific */ |
| 2144 | | scrn_reg.blackclip = 0; |
| 2158 | state->scrn_reg.blackclip = 0; |
| 2145 | 2159 | |
| 2146 | | io_bank_mode = 0; |
| 2147 | | pcg_index[0] = pcg_index[1] = pcg_index[2] = 0; |
| 2160 | state->io_bank_mode = 0; |
| 2161 | state->pcg_index[0] = state->pcg_index[1] = state->pcg_index[2] = 0; |
| 2148 | 2162 | |
| 2149 | 2163 | //cpu_set_irq_callback(machine->device("maincpu"), x1_irq_callback); |
| 2150 | 2164 | |
| 2151 | | cmt_current_cmd = 0; |
| 2152 | | cmt_test = 0; |
| 2165 | state->cmt_current_cmd = 0; |
| 2166 | state->cmt_test = 0; |
| 2153 | 2167 | cassette_change_state(machine->device("cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR); |
| 2154 | 2168 | |
| 2155 | | x1_key_irq_flag = ctc_irq_flag = 0; |
| 2169 | state->key_irq_flag = state->ctc_irq_flag = 0; |
| 2156 | 2170 | |
| 2157 | 2171 | /* Reinitialize palette here if there's a soft reset for the Turbo PAL stuff*/ |
| 2158 | 2172 | for(i=0;i<8;i++) |
| r9674 | r9675 | |
| 2161 | 2175 | palette_set_color_rgb(machine, i+0x100, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0)); |
| 2162 | 2176 | } |
| 2163 | 2177 | |
| 2164 | | timer_adjust_periodic(x1_rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1)); |
| 2178 | timer_adjust_periodic(state->rtc_timer, attotime_zero, 0, ATTOTIME_IN_SEC(1)); |
| 2165 | 2179 | } |
| 2166 | 2180 | |
| 2167 | 2181 | static MACHINE_START( x1 ) |
| 2168 | 2182 | { |
| 2183 | x1_state *state = machine->driver_data<x1_state>(); |
| 2169 | 2184 | timer_pulse(machine, ATTOTIME_IN_HZ(240), NULL, 0, keyboard_callback); |
| 2170 | 2185 | timer_pulse(machine, ATTOTIME_IN_HZ(16), NULL, 0, cmt_wind_timer); |
| 2171 | 2186 | |
| r9674 | r9675 | |
| 2174 | 2189 | system_time systime; |
| 2175 | 2190 | machine->base_datetime(systime); |
| 2176 | 2191 | |
| 2177 | | x1_rtc.day = ((systime.local_time.mday / 10)<<4) | ((systime.local_time.mday % 10) & 0xf); |
| 2178 | | x1_rtc.month = ((systime.local_time.month+1)); |
| 2179 | | x1_rtc.wday = ((systime.local_time.weekday % 10) & 0xf); |
| 2180 | | x1_rtc.year = (((systime.local_time.year % 100)/10)<<4) | ((systime.local_time.year % 10) & 0xf); |
| 2181 | | x1_rtc.hour = ((systime.local_time.hour / 10)<<4) | ((systime.local_time.hour % 10) & 0xf); |
| 2182 | | x1_rtc.min = ((systime.local_time.minute / 10)<<4) | ((systime.local_time.minute % 10) & 0xf); |
| 2183 | | x1_rtc.sec = ((systime.local_time.second / 10)<<4) | ((systime.local_time.second % 10) & 0xf); |
| 2192 | state->rtc.day = ((systime.local_time.mday / 10)<<4) | ((systime.local_time.mday % 10) & 0xf); |
| 2193 | state->rtc.month = ((systime.local_time.month+1)); |
| 2194 | state->rtc.wday = ((systime.local_time.weekday % 10) & 0xf); |
| 2195 | state->rtc.year = (((systime.local_time.year % 100)/10)<<4) | ((systime.local_time.year % 10) & 0xf); |
| 2196 | state->rtc.hour = ((systime.local_time.hour / 10)<<4) | ((systime.local_time.hour % 10) & 0xf); |
| 2197 | state->rtc.min = ((systime.local_time.minute / 10)<<4) | ((systime.local_time.minute % 10) & 0xf); |
| 2198 | state->rtc.sec = ((systime.local_time.second / 10)<<4) | ((systime.local_time.second % 10) & 0xf); |
| 2184 | 2199 | |
| 2185 | | x1_rtc_timer = timer_alloc(machine, x1_rtc_increment, 0); |
| 2200 | state->rtc_timer = timer_alloc(machine, x1_rtc_increment, 0); |
| 2186 | 2201 | } |
| 2187 | 2202 | } |
| 2188 | 2203 | |
src/mess/drivers/socrates.c
| r9674 | r9675 | |
| 75 | 75 | #include "cpu/z80/z80.h" |
| 76 | 76 | #include "audio/socrates.h" |
| 77 | 77 | |
| 78 | |
| 79 | class socrates_state : public driver_device |
| 80 | { |
| 81 | public: |
| 82 | socrates_state(running_machine &machine, const driver_device_config_base &config) |
| 83 | : driver_device(machine, config) { } |
| 84 | |
| 85 | rgb_t palette[256]; |
| 86 | |
| 87 | UINT8 data[8]; |
| 88 | UINT8 rom_bank; |
| 89 | UINT8 ram_bank; |
| 90 | UINT16 scroll_offset; |
| 91 | UINT8* videoram; |
| 92 | UINT8 kb_latch_low[2]; |
| 93 | UINT8 kb_latch_high[2]; |
| 94 | UINT8 kb_latch_mouse; |
| 95 | UINT8 io40_latch; // what was last written to speech reg (for open bus)? |
| 96 | UINT8 hblankstate; // are we in hblank? |
| 97 | UINT8 vblankstate; // are we in vblank? |
| 98 | UINT8 speech_running; // is speech synth talking? |
| 99 | UINT32 speech_address; // address in speech space |
| 100 | UINT8 speech_settings; // speech settings (nybble 0: ? externrom ? ?; nybble 1: ? ? ? ?) |
| 101 | UINT8 speech_dummy_read; // have we done a dummy read yet? |
| 102 | UINT8 speech_load_address_count; // number of times load address has happened |
| 103 | UINT8 speech_load_settings_count; // number of times load settings has happened |
| 104 | }; |
| 105 | |
| 106 | |
| 78 | 107 | /* Defines */ |
| 79 | 108 | |
| 80 | 109 | /* Components */ |
| 81 | 110 | |
| 82 | 111 | /* Devices */ |
| 83 | 112 | |
| 84 | | /* stuff below belongs in machine/socrates.c */ |
| 85 | | static struct |
| 86 | | { |
| 87 | | UINT8 data[8]; |
| 88 | | UINT8 rom_bank; |
| 89 | | UINT8 ram_bank; |
| 90 | | UINT16 scroll_offset; |
| 91 | | UINT8* videoram; |
| 92 | | UINT8 kb_latch_low[2]; |
| 93 | | UINT8 kb_latch_high[2]; |
| 94 | | UINT8 kb_latch_mouse; |
| 95 | | UINT8 io40_latch; // what was last written to speech reg (for open bus)? |
| 96 | | UINT8 hblankstate; // are we in hblank? |
| 97 | | UINT8 vblankstate; // are we in vblank? |
| 98 | | UINT8 speech_running; // is speech synth talking? |
| 99 | | UINT32 speech_address; // address in speech space |
| 100 | | UINT8 speech_settings; // speech settings (nybble 0: ? externrom ? ?; nybble 1: ? ? ? ?) |
| 101 | | UINT8 speech_dummy_read; // have we done a dummy read yet? |
| 102 | | UINT8 speech_load_address_count; // number of times load address has happened |
| 103 | | UINT8 speech_load_settings_count; // number of times load settings has happened |
| 104 | | |
| 105 | | } socrates={ {0}}; |
| 106 | | |
| 107 | 113 | static void socrates_set_rom_bank( running_machine *machine ) |
| 108 | 114 | { |
| 109 | | memory_set_bankptr( machine, "bank1", memory_region(machine, "maincpu") + ( socrates.rom_bank * 0x4000 )); |
| 115 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 116 | memory_set_bankptr( machine, "bank1", memory_region(machine, "maincpu") + ( state->rom_bank * 0x4000 )); |
| 110 | 117 | } |
| 111 | 118 | |
| 112 | 119 | static void socrates_set_ram_bank( running_machine *machine ) |
| 113 | 120 | { |
| 114 | | memory_set_bankptr( machine, "bank2", memory_region(machine, "vram") + ( (socrates.ram_bank&0x3) * 0x4000 )); // window 0 |
| 115 | | memory_set_bankptr( machine, "bank3", memory_region(machine, "vram") + ( ((socrates.ram_bank&0xC)>>2) * 0x4000 )); // window 1 |
| 121 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 122 | memory_set_bankptr( machine, "bank2", memory_region(machine, "vram") + ( (state->ram_bank&0x3) * 0x4000 )); // window 0 |
| 123 | memory_set_bankptr( machine, "bank3", memory_region(machine, "vram") + ( ((state->ram_bank&0xC)>>2) * 0x4000 )); // window 1 |
| 116 | 124 | } |
| 117 | 125 | |
| 118 | 126 | static void socrates_update_kb( running_machine *machine ) |
| 119 | 127 | { |
| 128 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 120 | 129 | static const char *const rownames[] = { "keyboard_40", "keyboard_41", "keyboard_42", "keyboard_43", "keyboard_44" }; |
| 121 | 130 | int row, keyvalue, powerof2; |
| 122 | 131 | int shift = 0; |
| 123 | 132 | // first check that the kb latch[1] is clear; if it isn't, don't touch it! |
| 124 | | if ((socrates.kb_latch_low[1] != 0) || (socrates.kb_latch_high[1] != 1)) return; |
| 133 | if ((state->kb_latch_low[1] != 0) || (state->kb_latch_high[1] != 1)) return; |
| 125 | 134 | // next check for joypad buttons |
| 126 | 135 | keyvalue = input_port_read(machine, "keyboard_jp"); |
| 127 | 136 | if (keyvalue != 0) |
| 128 | 137 | { |
| 129 | | socrates.kb_latch_low[1] = (keyvalue & 0xFF0)>>4; |
| 130 | | socrates.kb_latch_high[1] = 0x80 | (keyvalue & 0xF); |
| 138 | state->kb_latch_low[1] = (keyvalue & 0xFF0)>>4; |
| 139 | state->kb_latch_high[1] = 0x80 | (keyvalue & 0xF); |
| 131 | 140 | return; // get out of this function; due to the way key priorities work, we're done here. |
| 132 | 141 | } |
| 133 | 142 | // next check for mouse movement. |
| r9674 | r9675 | |
| 144 | 153 | { |
| 145 | 154 | if ((keyvalue&(1<<powerof2)) == (1<<powerof2)) |
| 146 | 155 | { |
| 147 | | socrates.kb_latch_low[1] = (shift?0x50:0x40)+row; |
| 148 | | socrates.kb_latch_high[1] = (0x80 | powerof2); |
| 156 | state->kb_latch_low[1] = (shift?0x50:0x40)+row; |
| 157 | state->kb_latch_high[1] = (0x80 | powerof2); |
| 149 | 158 | return; // get out of the for loop; due to the way key priorities work, we're done here. |
| 150 | 159 | } |
| 151 | 160 | } |
| r9674 | r9675 | |
| 154 | 163 | // no key was pressed... check if shift was hit then? |
| 155 | 164 | if (shift != 0) |
| 156 | 165 | { |
| 157 | | socrates.kb_latch_low[1] = 0x50; |
| 158 | | socrates.kb_latch_high[1] = 0x80; |
| 166 | state->kb_latch_low[1] = 0x50; |
| 167 | state->kb_latch_high[1] = 0x80; |
| 159 | 168 | } |
| 160 | 169 | } |
| 161 | 170 | |
| 162 | 171 | static void socrates_check_kb_latch( running_machine *machine ) // if kb[1] is full and kb[0] is not, shift [1] to [0] and clear [1] |
| 163 | 172 | { |
| 164 | | if (((socrates.kb_latch_low[1] != 0) || (socrates.kb_latch_high[1] != 1)) && |
| 165 | | ((socrates.kb_latch_low[0] == 0) && (socrates.kb_latch_high[0] == 1))) |
| 173 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 174 | if (((state->kb_latch_low[1] != 0) || (state->kb_latch_high[1] != 1)) && |
| 175 | ((state->kb_latch_low[0] == 0) && (state->kb_latch_high[0] == 1))) |
| 166 | 176 | { |
| 167 | | socrates.kb_latch_low[0] = socrates.kb_latch_low[1]; |
| 168 | | socrates.kb_latch_low[1] = 0; |
| 169 | | socrates.kb_latch_high[0] = socrates.kb_latch_high[1]; |
| 170 | | socrates.kb_latch_high[1] = 1; |
| 177 | state->kb_latch_low[0] = state->kb_latch_low[1]; |
| 178 | state->kb_latch_low[1] = 0; |
| 179 | state->kb_latch_high[0] = state->kb_latch_high[1]; |
| 180 | state->kb_latch_high[1] = 1; |
| 171 | 181 | } |
| 172 | 182 | } |
| 173 | 183 | |
| 174 | 184 | static MACHINE_RESET( socrates ) |
| 175 | 185 | { |
| 176 | | socrates.rom_bank = 0xF3; // actually set semi-randomly on real console but we need to initialize it somewhere... |
| 186 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 187 | state->rom_bank = 0xF3; // actually set semi-randomly on real console but we need to initialize it somewhere... |
| 177 | 188 | socrates_set_rom_bank( machine ); |
| 178 | | socrates.ram_bank = 0; // the actual console sets it semi randomly on power up, and the bios cleans it up. |
| 189 | state->ram_bank = 0; // the actual console sets it semi randomly on power up, and the bios cleans it up. |
| 179 | 190 | socrates_set_ram_bank( machine ); |
| 180 | | socrates.kb_latch_low[0] = 0xFF; |
| 181 | | socrates.kb_latch_high[0] = 0x8F; |
| 182 | | socrates.kb_latch_low[1] = 0x00; |
| 183 | | socrates.kb_latch_high[1] = 0x01; |
| 184 | | socrates.kb_latch_mouse = 0; |
| 185 | | socrates.io40_latch = 0; |
| 186 | | socrates.hblankstate = 0; |
| 187 | | socrates.vblankstate = 0; |
| 188 | | socrates.speech_running = 0; |
| 189 | | socrates.speech_address = 0; |
| 190 | | socrates.speech_settings = 0; |
| 191 | | socrates.speech_dummy_read = 0; |
| 192 | | socrates.speech_load_address_count = 0; |
| 193 | | socrates.speech_load_settings_count = 0; |
| 191 | state->kb_latch_low[0] = 0xFF; |
| 192 | state->kb_latch_high[0] = 0x8F; |
| 193 | state->kb_latch_low[1] = 0x00; |
| 194 | state->kb_latch_high[1] = 0x01; |
| 195 | state->kb_latch_mouse = 0; |
| 196 | state->io40_latch = 0; |
| 197 | state->hblankstate = 0; |
| 198 | state->vblankstate = 0; |
| 199 | state->speech_running = 0; |
| 200 | state->speech_address = 0; |
| 201 | state->speech_settings = 0; |
| 202 | state->speech_dummy_read = 0; |
| 203 | state->speech_load_address_count = 0; |
| 204 | state->speech_load_settings_count = 0; |
| 194 | 205 | } |
| 195 | 206 | |
| 196 | 207 | static DRIVER_INIT( socrates ) |
| r9674 | r9675 | |
| 206 | 217 | |
| 207 | 218 | static READ8_HANDLER( socrates_rom_bank_r ) |
| 208 | 219 | { |
| 220 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 209 | 221 | UINT8 data = 0xFF; |
| 210 | | data = socrates.rom_bank; |
| 222 | data = state->rom_bank; |
| 211 | 223 | return data; |
| 212 | 224 | } |
| 213 | 225 | |
| 214 | 226 | static WRITE8_HANDLER( socrates_rom_bank_w ) |
| 215 | 227 | { |
| 216 | | socrates.rom_bank = data; |
| 228 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 229 | state->rom_bank = data; |
| 217 | 230 | socrates_set_rom_bank( space->machine ); |
| 218 | 231 | } |
| 219 | 232 | |
| 220 | 233 | static READ8_HANDLER( socrates_ram_bank_r ) |
| 221 | 234 | { |
| 235 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 222 | 236 | UINT8 data = 0xFF; |
| 223 | | data = socrates.ram_bank; |
| 237 | data = state->ram_bank; |
| 224 | 238 | return data; |
| 225 | 239 | } |
| 226 | 240 | |
| 227 | 241 | static WRITE8_HANDLER( socrates_ram_bank_w ) |
| 228 | 242 | { |
| 229 | | socrates.ram_bank = data&0xF; |
| 243 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 244 | state->ram_bank = data&0xF; |
| 230 | 245 | socrates_set_ram_bank( space->machine ); |
| 231 | 246 | } |
| 232 | 247 | |
| r9674 | r9675 | |
| 242 | 257 | |
| 243 | 258 | static READ8_HANDLER( status_and_speech ) // read 0x4x, some sort of status reg |
| 244 | 259 | { |
| 260 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 245 | 261 | // bit 7 - speech status: high when speech is playing, low when it is not (or when speech cart is not present) |
| 246 | 262 | // bit 6 - unknown, usually set, may involve the writes to 0x30, possibly some sort of fixed-length timer? |
| 247 | 263 | // bit 5 - vblank status, high when not in vblank |
| r9674 | r9675 | |
| 253 | 269 | UINT8 *speechromint = memory_region(space->machine, "speechint"); |
| 254 | 270 | UINT8 *speechromext = memory_region(space->machine, "speechext"); |
| 255 | 271 | int temp = 0; |
| 256 | | temp |= (socrates.speech_running)?0x80:0; |
| 272 | temp |= (state->speech_running)?0x80:0; |
| 257 | 273 | temp |= 0x40; // unknown |
| 258 | | temp |= (socrates.vblankstate)?0:0x20; |
| 259 | | temp |= (socrates.hblankstate)?0:0x10; |
| 260 | | switch(socrates.io40_latch&0xF0) // what was last opcode sent? |
| 274 | temp |= (state->vblankstate)?0:0x20; |
| 275 | temp |= (state->hblankstate)?0:0x10; |
| 276 | switch(state->io40_latch&0xF0) // what was last opcode sent? |
| 261 | 277 | { |
| 262 | 278 | case 0x60: case 0xE0:// speech status 'read' register |
| 263 | | if(socrates.speech_settings&0x04) // external speech roms (outside of speech ic but still in cart) enabled |
| 279 | if(state->speech_settings&0x04) // external speech roms (outside of speech ic but still in cart) enabled |
| 264 | 280 | { |
| 265 | | logerror("reading external speech rom nybble from nybble address %x (byte address %x)\n",socrates.speech_address, socrates.speech_address>>1); |
| 266 | | temp |= ((speechromext[((socrates.speech_address>>1)&0xffff)]>>((socrates.speech_address&1)*4))&0xF); |
| 281 | logerror("reading external speech rom nybble from nybble address %x (byte address %x)\n",state->speech_address, state->speech_address>>1); |
| 282 | temp |= ((speechromext[((state->speech_address>>1)&0xffff)]>>((state->speech_address&1)*4))&0xF); |
| 267 | 283 | } |
| 268 | 284 | else |
| 269 | 285 | { |
| 270 | | logerror("reading internal speech rom nybble from nybble address %x (byte address %x)\n",socrates.speech_address, socrates.speech_address>>1); |
| 271 | | temp |= ((speechromint[((socrates.speech_address>>1)&0x1fff)]>>((socrates.speech_address&1)*4))&0xF); |
| 286 | logerror("reading internal speech rom nybble from nybble address %x (byte address %x)\n",state->speech_address, state->speech_address>>1); |
| 287 | temp |= ((speechromint[((state->speech_address>>1)&0x1fff)]>>((state->speech_address&1)*4))&0xF); |
| 272 | 288 | } |
| 273 | | if (socrates.speech_dummy_read == 0) // if we havent done the dummy read yet, do so now |
| 289 | if (state->speech_dummy_read == 0) // if we havent done the dummy read yet, do so now |
| 274 | 290 | { |
| 275 | | socrates.speech_dummy_read++; |
| 291 | state->speech_dummy_read++; |
| 276 | 292 | } |
| 277 | 293 | else |
| 278 | 294 | { |
| 279 | | socrates.speech_address++; |
| 295 | state->speech_address++; |
| 280 | 296 | } |
| 281 | 297 | break; |
| 282 | 298 | default: |
| 283 | | temp |= socrates.io40_latch&0xF; // read open bus |
| 299 | temp |= state->io40_latch&0xF; // read open bus |
| 284 | 300 | break; |
| 285 | 301 | } |
| 286 | 302 | logerror("read from i/o 0x4x of %x\n", temp); |
| r9674 | r9675 | |
| 288 | 304 | } |
| 289 | 305 | static TIMER_CALLBACK( clear_speech_cb ) |
| 290 | 306 | { |
| 291 | | socrates.speech_running = 0; |
| 292 | | socrates.speech_load_address_count = 0; // should this be here or in the write functuon subpart which is speak command? |
| 293 | | socrates.speech_load_settings_count = 0; |
| 307 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 308 | state->speech_running = 0; |
| 309 | state->speech_load_address_count = 0; // should this be here or in the write functuon subpart which is speak command? |
| 310 | state->speech_load_settings_count = 0; |
| 294 | 311 | } |
| 295 | 312 | |
| 296 | 313 | static WRITE8_HANDLER( speech_command ) // write 0x4x, some sort of bitfield; speech chip is probably hitachi hd38880 related but not exact, w/4 bit interface |
| 297 | 314 | { |
| 315 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 298 | 316 | logerror("write to i/o 0x4x of %x\n", data); |
| 299 | 317 | /* |
| 300 | 318 | // the high 4 bits of the write control which 'register' is written to, the low 4 bits are data (this is based on a readback test) |
| r9674 | r9675 | |
| 352 | 370 | if (data==0x80) |
| 353 | 371 | { |
| 354 | 372 | /* write me: start talking */ |
| 355 | | socrates.speech_running = 1; |
| 373 | state->speech_running = 1; |
| 356 | 374 | timer_set(space->machine, ATTOTIME_IN_SEC(4), NULL, 0, clear_speech_cb); // hack |
| 357 | 375 | } |
| 358 | 376 | break; |
| r9674 | r9675 | |
| 363 | 381 | case 0xB0: // unknown |
| 364 | 382 | break; |
| 365 | 383 | case 0xC0: // load address to vsm |
| 366 | | socrates.speech_address |= (((int)data&0xF)<<(socrates.speech_load_address_count*4))<<1; |
| 367 | | socrates.speech_load_address_count++; |
| 368 | | logerror("loaded address nybble %X, byte address is currently %5X with %d nybbles loaded\n", data&0xF, socrates.speech_address>>1, socrates.speech_load_address_count); |
| 384 | state->speech_address |= (((int)data&0xF)<<(state->speech_load_address_count*4))<<1; |
| 385 | state->speech_load_address_count++; |
| 386 | logerror("loaded address nybble %X, byte address is currently %5X with %d nybbles loaded\n", data&0xF, state->speech_address>>1, state->speech_load_address_count); |
| 369 | 387 | break; |
| 370 | 388 | case 0xD0: // load settings |
| 371 | | socrates.speech_settings |= ((data&0xF)<<(socrates.speech_load_settings_count*4)); |
| 372 | | socrates.speech_load_settings_count++; |
| 389 | state->speech_settings |= ((data&0xF)<<(state->speech_load_settings_count*4)); |
| 390 | state->speech_load_settings_count++; |
| 373 | 391 | break; |
| 374 | 392 | case 0xE0: // read byte, handled elsewhere |
| 375 | 393 | break; |
| 376 | 394 | case 0xF0: // command: sub 0 is speak, sub 8 is reset |
| 377 | 395 | if ((data&0xF) == 0) // speak |
| 378 | 396 | { |
| 379 | | socrates.speech_running = 1; |
| 397 | state->speech_running = 1; |
| 380 | 398 | timer_set(space->machine, ATTOTIME_IN_SEC(4), NULL, 0, clear_speech_cb); // hack |
| 381 | 399 | } |
| 382 | 400 | else if ((data&0xF) == 8) // reset |
| 383 | 401 | { |
| 384 | | socrates.speech_running = 0; |
| 385 | | socrates.speech_address = 0; |
| 386 | | socrates.speech_settings = 0; |
| 387 | | socrates.speech_dummy_read = 0; |
| 388 | | socrates.speech_load_address_count = 0; |
| 389 | | socrates.speech_load_settings_count = 0; |
| 390 | | socrates.io40_latch &= 0x0f; // set last command to 0 to prevent problems |
| 402 | state->speech_running = 0; |
| 403 | state->speech_address = 0; |
| 404 | state->speech_settings = 0; |
| 405 | state->speech_dummy_read = 0; |
| 406 | state->speech_load_address_count = 0; |
| 407 | state->speech_load_settings_count = 0; |
| 408 | state->io40_latch &= 0x0f; // set last command to 0 to prevent problems |
| 391 | 409 | } |
| 392 | 410 | else // other |
| 393 | 411 | { |
| r9674 | r9675 | |
| 397 | 415 | default: // 00 thru 70 are packets without the write bit set, ignore them |
| 398 | 416 | break; |
| 399 | 417 | } |
| 400 | | socrates.io40_latch = data; |
| 418 | state->io40_latch = data; |
| 401 | 419 | } |
| 402 | 420 | |
| 403 | 421 | static READ8_HANDLER( socrates_keyboard_low_r ) // keyboard code low |
| 404 | 422 | { |
| 423 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 405 | 424 | socrates_update_kb( space->machine ); |
| 406 | 425 | socrates_check_kb_latch( space->machine ); |
| 407 | | return socrates.kb_latch_low[0]; |
| 426 | return state->kb_latch_low[0]; |
| 408 | 427 | } |
| 409 | 428 | |
| 410 | 429 | static READ8_HANDLER( socrates_keyboard_high_r ) // keyboard code high |
| 411 | 430 | { |
| 431 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 412 | 432 | socrates_update_kb( space->machine ); |
| 413 | 433 | socrates_check_kb_latch( space->machine ); |
| 414 | | return socrates.kb_latch_high[0]; |
| 434 | return state->kb_latch_high[0]; |
| 415 | 435 | } |
| 416 | 436 | |
| 417 | 437 | static WRITE8_HANDLER( socrates_keyboard_clear ) // keyboard latch shift/clear |
| 418 | 438 | { |
| 419 | | socrates.kb_latch_low[0] = socrates.kb_latch_low[1]; |
| 420 | | socrates.kb_latch_high[0] = socrates.kb_latch_high[1]; |
| 421 | | socrates.kb_latch_low[1] = 0; |
| 422 | | socrates.kb_latch_high[1] = 1; |
| 439 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 440 | state->kb_latch_low[0] = state->kb_latch_low[1]; |
| 441 | state->kb_latch_high[0] = state->kb_latch_high[1]; |
| 442 | state->kb_latch_low[1] = 0; |
| 443 | state->kb_latch_high[1] = 1; |
| 423 | 444 | } |
| 424 | 445 | |
| 425 | 446 | static WRITE8_HANDLER( reset_speech ) // i/o 60: reset speech synth |
| 426 | 447 | { |
| 427 | | socrates.speech_running = 0; |
| 428 | | socrates.speech_address = 0; |
| 429 | | socrates.speech_settings = 0; |
| 430 | | socrates.speech_dummy_read = 0; |
| 431 | | socrates.speech_load_address_count = 0; |
| 432 | | socrates.speech_load_settings_count = 0; |
| 433 | | socrates.io40_latch &= 0x0f; // set last command to 0 to prevent problems |
| 448 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 449 | state->speech_running = 0; |
| 450 | state->speech_address = 0; |
| 451 | state->speech_settings = 0; |
| 452 | state->speech_dummy_read = 0; |
| 453 | state->speech_load_address_count = 0; |
| 454 | state->speech_load_settings_count = 0; |
| 455 | state->io40_latch &= 0x0f; // set last command to 0 to prevent problems |
| 434 | 456 | logerror("write to i/o 0x60 of %x\n",data); |
| 435 | 457 | } |
| 436 | 458 | |
| 437 | | /* stuff below belongs in video/socrates.c */ |
| 459 | /* stuff below belongs in video/nc.c */ |
| 438 | 460 | |
| 439 | 461 | static WRITE8_HANDLER( socrates_scroll_w ) |
| 440 | 462 | { |
| 463 | socrates_state *state = space->machine->driver_data<socrates_state>(); |
| 441 | 464 | if (offset == 0) |
| 442 | | socrates.scroll_offset = (socrates.scroll_offset&0x100) | data; |
| 465 | state->scroll_offset = (state->scroll_offset&0x100) | data; |
| 443 | 466 | else |
| 444 | | socrates.scroll_offset = (socrates.scroll_offset&0xFF) | ((data&1)<<8); |
| 467 | state->scroll_offset = (state->scroll_offset&0xFF) | ((data&1)<<8); |
| 445 | 468 | } |
| 446 | 469 | |
| 447 | 470 | /* NTSC-based Palette stuff */ |
| r9674 | r9675 | |
| 547 | 570 | return composedcolor; |
| 548 | 571 | } |
| 549 | 572 | |
| 550 | | static rgb_t socrates_palette[256]; |
| 551 | 573 | |
| 552 | 574 | static PALETTE_INIT( socrates ) |
| 553 | 575 | { |
| 576 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 554 | 577 | int i; // iterator |
| 555 | 578 | for (i = 0; i < 256; i++) |
| 556 | 579 | { |
| 557 | | socrates_palette[i] = socrates_create_color(i); |
| 580 | state->palette[i] = socrates_create_color(i); |
| 558 | 581 | } |
| 559 | | palette_set_colors(machine, 0, socrates_palette, ARRAY_LENGTH(socrates_palette)); |
| 582 | palette_set_colors(machine, 0, state->palette, ARRAY_LENGTH(state->palette)); |
| 560 | 583 | } |
| 561 | 584 | |
| 562 | 585 | static VIDEO_START( socrates ) |
| 563 | 586 | { |
| 564 | | socrates.videoram = memory_region(machine, "vram"); |
| 565 | | socrates.scroll_offset = 0; |
| 587 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 588 | state->videoram = memory_region(machine, "vram"); |
| 589 | state->scroll_offset = 0; |
| 566 | 590 | } |
| 567 | 591 | |
| 568 | 592 | static VIDEO_UPDATE( socrates ) |
| 569 | 593 | { |
| 570 | | UINT8 fixedcolors[8] = |
| 594 | socrates_state *state = screen->machine->driver_data<socrates_state>(); |
| 595 | static const UINT8 fixedcolors[8] = |
| 571 | 596 | { |
| 572 | 597 | 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0xF7 |
| 573 | 598 | }; |
| r9674 | r9675 | |
| 575 | 600 | int lineoffset = 0; // if display ever tries to display data at 0xfxxx, offset line displayed by 0x1000 |
| 576 | 601 | for (y = 0; y < 228; y++) |
| 577 | 602 | { |
| 578 | | if ((((y+socrates.scroll_offset)*128)&0xffff) >= 0xf000) lineoffset = 0x1000; // see comment above |
| 603 | if ((((y+state->scroll_offset)*128)&0xffff) >= 0xf000) lineoffset = 0x1000; // see comment above |
| 579 | 604 | for (x = 0; x < 264; x++) |
| 580 | 605 | { |
| 581 | 606 | if (x < 256) |
| 582 | 607 | { |
| 583 | | colidx = socrates.videoram[(((y+socrates.scroll_offset)*128)+(x>>1)+lineoffset)&0xffff]; |
| 608 | colidx = state->videoram[(((y+state->scroll_offset)*128)+(x>>1)+lineoffset)&0xffff]; |
| 584 | 609 | if (x&1) colidx >>=4; |
| 585 | 610 | colidx &= 0xF; |
| 586 | | if (colidx > 7) color=socrates.videoram[0xF000+(colidx<<8)+((y+socrates.scroll_offset)&0xFF)]; |
| 611 | if (colidx > 7) color=state->videoram[0xF000+(colidx<<8)+((y+state->scroll_offset)&0xFF)]; |
| 587 | 612 | else color=fixedcolors[colidx]; |
| 588 | 613 | *BITMAP_ADDR16(bitmap, y, x) = color; |
| 589 | 614 | } |
| 590 | 615 | else |
| 591 | 616 | { |
| 592 | | colidx = socrates.videoram[(((y+socrates.scroll_offset)*128)+(127)+lineoffset)&0xffff]; |
| 617 | colidx = state->videoram[(((y+state->scroll_offset)*128)+(127)+lineoffset)&0xffff]; |
| 593 | 618 | colidx >>=4; |
| 594 | 619 | colidx &= 0xF; |
| 595 | | if (colidx > 7) color=socrates.videoram[0xF000+(colidx<<8)+((y+socrates.scroll_offset)&0xFF)]; |
| 620 | if (colidx > 7) color=state->videoram[0xF000+(colidx<<8)+((y+state->scroll_offset)&0xFF)]; |
| 596 | 621 | else color=fixedcolors[colidx]; |
| 597 | 622 | *BITMAP_ADDR16(bitmap, y, x) = color; |
| 598 | 623 | } |
| r9674 | r9675 | |
| 601 | 626 | return 0; |
| 602 | 627 | } |
| 603 | 628 | |
| 604 | | /* below belongs in sound/socrates.c */ |
| 629 | /* below belongs in sound/nc.c */ |
| 605 | 630 | |
| 606 | 631 | static WRITE8_HANDLER(socrates_sound_w) |
| 607 | 632 | { |
| r9674 | r9675 | |
| 860 | 885 | ******************************************************************************/ |
| 861 | 886 | static TIMER_CALLBACK( clear_irq_cb ) |
| 862 | 887 | { |
| 888 | socrates_state *state = machine->driver_data<socrates_state>(); |
| 863 | 889 | cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); |
| 864 | | socrates.vblankstate = 0; |
| 890 | state->vblankstate = 0; |
| 865 | 891 | } |
| 866 | 892 | |
| 867 | 893 | static INTERRUPT_GEN( assert_irq ) |
| 868 | 894 | { |
| 895 | socrates_state *state = device->machine->driver_data<socrates_state>(); |
| 869 | 896 | cpu_set_input_line(device, 0, ASSERT_LINE); |
| 870 | 897 | timer_set(device->machine, downcast<cpu_device *>(device)->cycles_to_attotime(44), NULL, 0, clear_irq_cb); |
| 871 | 898 | // 44 is a complete and total guess, need to properly measure how many clocks/microseconds the int line is high for. |
| 872 | | socrates.vblankstate = 1; |
| 899 | state->vblankstate = 1; |
| 873 | 900 | } |
| 874 | 901 | |
| 875 | | static MACHINE_CONFIG_START( socrates, driver_device ) |
| 902 | static MACHINE_CONFIG_START( socrates, socrates_state ) |
| 876 | 903 | /* basic machine hardware */ |
| 877 | 904 | MDRV_CPU_ADD("maincpu", Z80, XTAL_21_4772MHz/6) /* Toshiba TMPZ84C00AP @ 3.579545 MHz, verified, xtal is divided by 6 */ |
| 878 | 905 | MDRV_CPU_PROGRAM_MAP(z80_mem) |
src/mess/drivers/svision.c
| r9674 | r9675 | |
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | // in pixel |
| 22 | | #define XSIZE (svision_reg[0]&~3) |
| 23 | | #define XPOS svision_reg[2] |
| 24 | | #define YPOS svision_reg[3] |
| 25 | | #define BANK svision_reg[0x26] |
| 22 | #define XSIZE (state->reg[0]&~3) |
| 23 | #define XPOS state->reg[2] |
| 24 | #define YPOS state->reg[3] |
| 25 | #define BANK state->reg[0x26] |
| 26 | 26 | |
| 27 | | static UINT8 *svision_reg; |
| 28 | | static running_device *svision_sound; |
| 29 | | static int *dma_finished; |
| 30 | 27 | |
| 31 | | static struct |
| 32 | | { |
| 33 | | emu_timer *timer1; |
| 34 | | int timer_shot; |
| 35 | | } svision; |
| 36 | | |
| 37 | | static struct |
| 38 | | { |
| 39 | | int state; |
| 40 | | int on, clock, data; |
| 41 | | UINT8 input; |
| 42 | | emu_timer *timer; |
| 43 | | } svision_pet; |
| 44 | | |
| 45 | | static struct |
| 46 | | { |
| 47 | | UINT16 palette[4/*0x40?*/]; /* rgb8 */ |
| 48 | | int palette_on; |
| 49 | | } tvlink; |
| 50 | | |
| 51 | 28 | static TIMER_CALLBACK(svision_pet_timer) |
| 52 | 29 | { |
| 53 | | switch (svision_pet.state) |
| 30 | svision_state *state = machine->driver_data<svision_state>(); |
| 31 | switch (state->pet.state) |
| 54 | 32 | { |
| 55 | 33 | case 0: |
| 56 | | svision_pet.input = input_port_read(machine, "JOY2"); |
| 34 | state->pet.input = input_port_read(machine, "JOY2"); |
| 57 | 35 | /* fall through */ |
| 58 | 36 | |
| 59 | 37 | case 2: case 4: case 6: case 8: |
| 60 | 38 | case 10: case 12: case 14: |
| 61 | | svision_pet.clock=svision_pet.state&2; |
| 62 | | svision_pet.data=svision_pet.input&1; |
| 63 | | svision_pet.input>>=1; |
| 64 | | svision_pet.state++; |
| 39 | state->pet.clock=state->pet.state&2; |
| 40 | state->pet.data=state->pet.input&1; |
| 41 | state->pet.input>>=1; |
| 42 | state->pet.state++; |
| 65 | 43 | break; |
| 66 | 44 | |
| 67 | 45 | case 16+15: |
| 68 | | svision_pet.state = 0; |
| 46 | state->pet.state = 0; |
| 69 | 47 | break; |
| 70 | 48 | |
| 71 | 49 | default: |
| 72 | | svision_pet.state++; |
| 50 | state->pet.state++; |
| 73 | 51 | break; |
| 74 | 52 | } |
| 75 | 53 | } |
| 76 | 54 | |
| 77 | 55 | void svision_irq(running_machine *machine) |
| 78 | 56 | { |
| 79 | | int irq = svision.timer_shot && (BANK & 2); |
| 80 | | irq = irq || (*dma_finished && (BANK & 4)); |
| 57 | svision_state *state = machine->driver_data<svision_state>(); |
| 58 | int irq = state->svision.timer_shot && (BANK & 2); |
| 59 | irq = irq || (*state->dma_finished && (BANK & 4)); |
| 81 | 60 | |
| 82 | 61 | cputag_set_input_line(machine, "maincpu", M6502_IRQ_LINE, irq ? ASSERT_LINE : CLEAR_LINE); |
| 83 | 62 | } |
| 84 | 63 | |
| 85 | 64 | static TIMER_CALLBACK(svision_timer) |
| 86 | 65 | { |
| 87 | | svision.timer_shot = TRUE; |
| 88 | | timer_enable(svision.timer1, FALSE); |
| 66 | svision_state *state = machine->driver_data<svision_state>(); |
| 67 | state->svision.timer_shot = TRUE; |
| 68 | timer_enable(state->svision.timer1, FALSE); |
| 89 | 69 | svision_irq( machine ); |
| 90 | 70 | } |
| 91 | 71 | |
| 92 | 72 | static READ8_HANDLER(svision_r) |
| 93 | 73 | { |
| 94 | | int data = svision_reg[offset]; |
| 74 | svision_state *state = space->machine->driver_data<svision_state>(); |
| 75 | int data = state->reg[offset]; |
| 95 | 76 | switch (offset) |
| 96 | 77 | { |
| 97 | 78 | case 0x20: |
| r9674 | r9675 | |
| 99 | 80 | break; |
| 100 | 81 | case 0x21: |
| 101 | 82 | data &= ~0xf; |
| 102 | | data |= svision_reg[0x22] & 0xf; |
| 103 | | if (svision_pet.on) |
| 83 | data |= state->reg[0x22] & 0xf; |
| 84 | if (state->pet.on) |
| 104 | 85 | { |
| 105 | | if (!svision_pet.clock) |
| 86 | if (!state->pet.clock) |
| 106 | 87 | data &= ~4; |
| 107 | | if (!svision_pet.data) |
| 88 | if (!state->pet.data) |
| 108 | 89 | data &= ~8; |
| 109 | 90 | } |
| 110 | 91 | break; |
| 111 | 92 | case 0x27: |
| 112 | 93 | data &= ~3; |
| 113 | | if (svision.timer_shot) |
| 94 | if (state->svision.timer_shot) |
| 114 | 95 | data|=1; |
| 115 | | if (*dma_finished) |
| 96 | if (*state->dma_finished) |
| 116 | 97 | data|=2; |
| 117 | 98 | break; |
| 118 | 99 | case 0x24: |
| 119 | | svision.timer_shot = FALSE; |
| 100 | state->svision.timer_shot = FALSE; |
| 120 | 101 | svision_irq( space->machine ); |
| 121 | 102 | break; |
| 122 | 103 | case 0x25: |
| 123 | | *dma_finished = FALSE; |
| 104 | *state->dma_finished = FALSE; |
| 124 | 105 | svision_irq( space->machine ); |
| 125 | 106 | break; |
| 126 | 107 | default: |
| r9674 | r9675 | |
| 133 | 114 | |
| 134 | 115 | static WRITE8_HANDLER(svision_w) |
| 135 | 116 | { |
| 117 | svision_state *state = space->machine->driver_data<svision_state>(); |
| 136 | 118 | int value; |
| 137 | 119 | int delay; |
| 138 | 120 | |
| 139 | | svision_reg[offset] = data; |
| 121 | state->reg[offset] = data; |
| 140 | 122 | |
| 141 | 123 | switch (offset) |
| 142 | 124 | { |
| r9674 | r9675 | |
| 145 | 127 | break; |
| 146 | 128 | case 0x26: /* bits 5,6 memory management for a000? */ |
| 147 | 129 | logerror("%.6f svision write %04x %02x\n", attotime_to_double(timer_get_time(space->machine)),offset,data); |
| 148 | | memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "user1") + ((svision_reg[0x26] & 0xe0) << 9)); |
| 130 | memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "user1") + ((state->reg[0x26] & 0xe0) << 9)); |
| 149 | 131 | svision_irq( space->machine ); |
| 150 | 132 | break; |
| 151 | 133 | case 0x23: /* delta hero irq routine write */ |
| r9674 | r9675 | |
| 156 | 138 | delay = 16384; |
| 157 | 139 | else |
| 158 | 140 | delay = 256; |
| 159 | | timer_enable(svision.timer1, TRUE); |
| 160 | | timer_reset(svision.timer1, space->machine->device<cpu_device>("maincpu")->cycles_to_attotime(value * delay)); |
| 141 | timer_enable(state->svision.timer1, TRUE); |
| 142 | timer_reset(state->svision.timer1, space->machine->device<cpu_device>("maincpu")->cycles_to_attotime(value * delay)); |
| 161 | 143 | break; |
| 162 | 144 | case 0x10: case 0x11: case 0x12: case 0x13: |
| 163 | | svision_soundport_w(svision_sound, 0, offset & 3, data); |
| 145 | svision_soundport_w(state->sound, 0, offset & 3, data); |
| 164 | 146 | break; |
| 165 | 147 | case 0x14: case 0x15: case 0x16: case 0x17: |
| 166 | | svision_soundport_w(svision_sound, 1, offset & 3, data); |
| 148 | svision_soundport_w(state->sound, 1, offset & 3, data); |
| 167 | 149 | break; |
| 168 | 150 | case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: |
| 169 | | svision_sounddma_w(svision_sound, offset - 0x18, data); |
| 151 | svision_sounddma_w(state->sound, offset - 0x18, data); |
| 170 | 152 | break; |
| 171 | 153 | case 0x28: case 0x29: case 0x2a: |
| 172 | | svision_noise_w(svision_sound, offset - 0x28, data); |
| 154 | svision_noise_w(state->sound, offset - 0x28, data); |
| 173 | 155 | break; |
| 174 | 156 | default: |
| 175 | 157 | logerror("%.6f svision write %04x %02x\n", attotime_to_double(timer_get_time(space->machine)), offset, data); |
| r9674 | r9675 | |
| 196 | 178 | |
| 197 | 179 | static WRITE8_HANDLER(tvlink_w) |
| 198 | 180 | { |
| 181 | svision_state *state = space->machine->driver_data<svision_state>(); |
| 199 | 182 | switch (offset) |
| 200 | 183 | { |
| 201 | 184 | case 0x0e: |
| 202 | | svision_reg[offset] = data; |
| 203 | | tvlink.palette_on = data & 1; |
| 204 | | if (tvlink.palette_on) |
| 185 | state->reg[offset] = data; |
| 186 | state->tvlink.palette_on = data & 1; |
| 187 | if (state->tvlink.palette_on) |
| 205 | 188 | { |
| 206 | 189 | // hack, normally initialising with palette from ram |
| 207 | | tvlink.palette[0] = MAKE12_RGB15(163/16,172/16,115/16); // these are the tron colors messured from screenshot |
| 208 | | tvlink.palette[1] = MAKE12_RGB15(163/16,155/16,153/16); |
| 209 | | tvlink.palette[2] = MAKE12_RGB15(77/16,125/16,73/16); |
| 210 | | tvlink.palette[3] = MAKE12_RGB15(59/16,24/16,20/16); |
| 190 | state->tvlink.palette[0] = MAKE12_RGB15(163/16,172/16,115/16); // these are the tron colors messured from screenshot |
| 191 | state->tvlink.palette[1] = MAKE12_RGB15(163/16,155/16,153/16); |
| 192 | state->tvlink.palette[2] = MAKE12_RGB15(77/16,125/16,73/16); |
| 193 | state->tvlink.palette[3] = MAKE12_RGB15(59/16,24/16,20/16); |
| 211 | 194 | } |
| 212 | 195 | else |
| 213 | 196 | { |
| 214 | 197 | // cleaner to use colors from compile time palette, or compose from "fixed" palette values |
| 215 | | tvlink.palette[0]=MAKE12_RGB15(0,0,0); |
| 216 | | tvlink.palette[1]=MAKE12_RGB15(5*16/256,18*16/256,9*16/256); |
| 217 | | tvlink.palette[2]=MAKE12_RGB15(48*16/256,76*16/256,100*16/256); |
| 218 | | tvlink.palette[3]=MAKE12_RGB15(190*16/256,190*16/256,190*16/256); |
| 198 | state->tvlink.palette[0]=MAKE12_RGB15(0,0,0); |
| 199 | state->tvlink.palette[1]=MAKE12_RGB15(5*16/256,18*16/256,9*16/256); |
| 200 | state->tvlink.palette[2]=MAKE12_RGB15(48*16/256,76*16/256,100*16/256); |
| 201 | state->tvlink.palette[3]=MAKE12_RGB15(190*16/256,190*16/256,190*16/256); |
| 219 | 202 | } |
| 220 | 203 | break; |
| 221 | 204 | default: |
| r9674 | r9675 | |
| 226 | 209 | if (offset == 0x803 && data == 0x07) |
| 227 | 210 | { |
| 228 | 211 | /* tron hack */ |
| 229 | | svision_reg[0x0804]=0x00; |
| 230 | | svision_reg[0x0805]=0x01; |
| 231 | | svision_reg[0x0806]=0x00; |
| 232 | | svision_reg[0x0807]=0x00; |
| 212 | state->reg[0x0804]=0x00; |
| 213 | state->reg[0x0805]=0x01; |
| 214 | state->reg[0x0806]=0x00; |
| 215 | state->reg[0x0807]=0x00; |
| 233 | 216 | } |
| 234 | | c = svision_reg[0x800] | (svision_reg[0x804] << 8); |
| 235 | | tvlink.palette[0] = MAKE9_RGB15( (c>>0)&7, (c>>3)&7, (c>>6)&7); |
| 236 | | c = svision_reg[0x801] | (svision_reg[0x805] << 8); |
| 237 | | tvlink.palette[1] = MAKE9_RGB15( (c>>0)&7, (c>>3)&7, (c>>6)&7); |
| 238 | | c = svision_reg[0x802] | (svision_reg[0x806]<<8); |
| 239 | | tvlink.palette[2]=MAKE9_RGB15( (c>>0)&7, (c>>3)&7, (c>>6)&7); |
| 240 | | c = svision_reg[0x803] | (svision_reg[0x807]<<8); |
| 241 | | tvlink.palette[3]=MAKE9_RGB15( (c>>0)&7, (c>>3)&7, (c>>6)&7); |
| 217 | c = state->reg[0x800] | (state->reg[0x804] << 8); |
| 218 | state->tvlink.palette[0] = MAKE9_RGB15( (c>>0)&7, (c>>3)&7, (c>>6)&7); |
| 219 | c = state->reg[0x801] | (state->reg[0x805] << 8); |
| 220 | state->tvlink.palette[1] = MAKE9_RGB15( (c>>0)&7, (c>>3)&7, (c>>6)&7); |
| 221 | c = state->reg[0x802] | (state->reg[0x806]<<8); |
| 222 | state->tvlink.palette[2]=MAKE9_RGB15( (c>>0)&7, (c>>3)&7, (c>>6)&7); |
| 223 | c = state->reg[0x803] | (state->reg[0x807]<<8); |
| 224 | state->tvlink.palette[3]=MAKE9_RGB15( (c>>0)&7, (c>>3)&7, (c>>6)&7); |
| 242 | 225 | /* writes to palette effect video color immediately */ |
| 243 | 226 | /* some writes modify other registers, */ |
| 244 | 227 | /* encoding therefor not known (rgb8 or rgb9) */ |
| r9674 | r9675 | |
| 248 | 231 | |
| 249 | 232 | static ADDRESS_MAP_START( svision_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 250 | 233 | AM_RANGE( 0x0000, 0x1fff) AM_RAM |
| 251 | | AM_RANGE( 0x2000, 0x3fff) AM_READWRITE(svision_r, svision_w) AM_BASE(&svision_reg) |
| 234 | AM_RANGE( 0x2000, 0x3fff) AM_READWRITE(svision_r, svision_w) AM_BASE_MEMBER(svision_state, reg) |
| 252 | 235 | AM_RANGE( 0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(svision_state, videoram) |
| 253 | 236 | AM_RANGE( 0x6000, 0x7fff) AM_NOP |
| 254 | 237 | AM_RANGE( 0x8000, 0xbfff) AM_ROMBANK("bank1") |
| r9674 | r9675 | |
| 257 | 240 | |
| 258 | 241 | static ADDRESS_MAP_START( tvlink_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 259 | 242 | AM_RANGE( 0x0000, 0x1fff) AM_RAM |
| 260 | | AM_RANGE( 0x2000, 0x3fff) AM_READWRITE(tvlink_r, tvlink_w) AM_BASE(&svision_reg) |
| 243 | AM_RANGE( 0x2000, 0x3fff) AM_READWRITE(tvlink_r, tvlink_w) AM_BASE_MEMBER(svision_state, reg) |
| 261 | 244 | AM_RANGE( 0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(svision_state, videoram) |
| 262 | 245 | AM_RANGE( 0x6000, 0x7fff) AM_NOP |
| 263 | 246 | AM_RANGE( 0x8000, 0xbfff) AM_ROMBANK("bank1") |
| r9674 | r9675 | |
| 412 | 395 | for (x = 3 - (XPOS & 3), i = 0; x < 160 + 3 && x < XSIZE + 3; x += 4, i++) |
| 413 | 396 | { |
| 414 | 397 | UINT8 b=videoram[j+i]; |
| 415 | | line[3]=tvlink.palette[(b>>6)&3]; |
| 416 | | line[2]=tvlink.palette[(b>>4)&3]; |
| 417 | | line[1]=tvlink.palette[(b>>2)&3]; |
| 418 | | line[0]=tvlink.palette[(b>>0)&3]; |
| 398 | line[3]=state->tvlink.palette[(b>>6)&3]; |
| 399 | line[2]=state->tvlink.palette[(b>>4)&3]; |
| 400 | line[1]=state->tvlink.palette[(b>>2)&3]; |
| 401 | line[0]=state->tvlink.palette[(b>>0)&3]; |
| 419 | 402 | line+=4; |
| 420 | 403 | } |
| 421 | 404 | j += 0x30; |
| r9674 | r9675 | |
| 432 | 415 | |
| 433 | 416 | static INTERRUPT_GEN( svision_frame_int ) |
| 434 | 417 | { |
| 418 | svision_state *state = device->machine->driver_data<svision_state>(); |
| 435 | 419 | if (BANK&1) |
| 436 | 420 | cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); |
| 437 | 421 | |
| 438 | | svision_sound_decrement(svision_sound); |
| 422 | svision_sound_decrement(state->sound); |
| 439 | 423 | } |
| 440 | 424 | |
| 441 | 425 | static DRIVER_INIT( svision ) |
| 442 | 426 | { |
| 443 | | svision.timer1 = timer_alloc(machine, svision_timer, NULL); |
| 444 | | svision_sound = machine->device("custom"); |
| 445 | | dma_finished = svision_dma_finished(svision_sound); |
| 446 | | svision_pet.on = FALSE; |
| 427 | svision_state *state = machine->driver_data<svision_state>(); |
| 428 | state->svision.timer1 = timer_alloc(machine, svision_timer, NULL); |
| 429 | state->sound = machine->device("custom"); |
| 430 | state->dma_finished = svision_dma_finished(state->sound); |
| 431 | state->pet.on = FALSE; |
| 447 | 432 | memory_set_bankptr(machine, "bank2", memory_region(machine, "user1") + 0x1c000); |
| 448 | 433 | } |
| 449 | 434 | |
| 450 | 435 | static DRIVER_INIT( svisions ) |
| 451 | 436 | { |
| 452 | | svision.timer1 = timer_alloc(machine, svision_timer, NULL); |
| 453 | | svision_sound = machine->device("custom"); |
| 454 | | dma_finished = svision_dma_finished(svision_sound); |
| 437 | svision_state *state = machine->driver_data<svision_state>(); |
| 438 | state->svision.timer1 = timer_alloc(machine, svision_timer, NULL); |
| 439 | state->sound = machine->device("custom"); |
| 440 | state->dma_finished = svision_dma_finished(state->sound); |
| 455 | 441 | memory_set_bankptr(machine, "bank2", memory_region(machine, "user1") + 0x1c000); |
| 456 | | svision.timer1 = timer_alloc(machine, svision_timer, NULL); |
| 457 | | svision_pet.on = TRUE; |
| 458 | | svision_pet.timer = timer_alloc(machine, svision_pet_timer, NULL); |
| 442 | state->svision.timer1 = timer_alloc(machine, svision_timer, NULL); |
| 443 | state->pet.on = TRUE; |
| 444 | state->pet.timer = timer_alloc(machine, svision_pet_timer, NULL); |
| 459 | 445 | timer_pulse(machine, attotime_mul(ATTOTIME_IN_SEC(8), 256/cputag_get_clock(machine, "maincpu")), NULL, 0, svision_pet_timer); |
| 460 | 446 | } |
| 461 | 447 | |
| r9674 | r9675 | |
| 504 | 490 | |
| 505 | 491 | static MACHINE_RESET( svision ) |
| 506 | 492 | { |
| 507 | | svision.timer_shot = FALSE; |
| 508 | | *dma_finished = FALSE; |
| 493 | svision_state *state = machine->driver_data<svision_state>(); |
| 494 | state->svision.timer_shot = FALSE; |
| 495 | *state->dma_finished = FALSE; |
| 509 | 496 | memory_set_bankptr(machine, "bank1", memory_region(machine, "user1")); |
| 510 | 497 | } |
| 511 | 498 | |
| 512 | 499 | |
| 513 | 500 | static MACHINE_RESET( tvlink ) |
| 514 | 501 | { |
| 515 | | svision.timer_shot = FALSE; |
| 516 | | *dma_finished = FALSE; |
| 502 | svision_state *state = machine->driver_data<svision_state>(); |
| 503 | state->svision.timer_shot = FALSE; |
| 504 | *state->dma_finished = FALSE; |
| 517 | 505 | memory_set_bankptr(machine, "bank1", memory_region(machine, "user1")); |
| 518 | | tvlink.palette_on = FALSE; |
| 506 | state->tvlink.palette_on = FALSE; |
| 519 | 507 | |
| 520 | | memset(svision_reg + 0x800, 0xff, 0x40); // normally done from tvlink microcontroller |
| 521 | | svision_reg[0x82a] = 0xdf; |
| 508 | memset(state->reg + 0x800, 0xff, 0x40); // normally done from state->tvlink microcontroller |
| 509 | state->reg[0x82a] = 0xdf; |
| 522 | 510 | |
| 523 | | tvlink.palette[0] = MAKE24_RGB15(svisionp_palette[(PALETTE_START+0)*3+0], svisionp_palette[(PALETTE_START+0)*3+1], svisionp_palette[(PALETTE_START+0)*3+2]); |
| 524 | | tvlink.palette[1] = MAKE24_RGB15(svisionp_palette[(PALETTE_START+1)*3+0], svisionp_palette[(PALETTE_START+1)*3+1], svisionp_palette[(PALETTE_START+1)*3+2]); |
| 525 | | tvlink.palette[2] = MAKE24_RGB15(svisionp_palette[(PALETTE_START+2)*3+0], svisionp_palette[(PALETTE_START+2)*3+1], svisionp_palette[(PALETTE_START+2)*3+2]); |
| 526 | | tvlink.palette[3] = MAKE24_RGB15(svisionp_palette[(PALETTE_START+3)*3+0], svisionp_palette[(PALETTE_START+3)*3+1], svisionp_palette[(PALETTE_START+3)*3+2]); |
| 511 | state->tvlink.palette[0] = MAKE24_RGB15(svisionp_palette[(PALETTE_START+0)*3+0], svisionp_palette[(PALETTE_START+0)*3+1], svisionp_palette[(PALETTE_START+0)*3+2]); |
| 512 | state->tvlink.palette[1] = MAKE24_RGB15(svisionp_palette[(PALETTE_START+1)*3+0], svisionp_palette[(PALETTE_START+1)*3+1], svisionp_palette[(PALETTE_START+1)*3+2]); |
| 513 | state->tvlink.palette[2] = MAKE24_RGB15(svisionp_palette[(PALETTE_START+2)*3+0], svisionp_palette[(PALETTE_START+2)*3+1], svisionp_palette[(PALETTE_START+2)*3+2]); |
| 514 | state->tvlink.palette[3] = MAKE24_RGB15(svisionp_palette[(PALETTE_START+3)*3+0], svisionp_palette[(PALETTE_START+3)*3+1], svisionp_palette[(PALETTE_START+3)*3+2]); |
| 527 | 515 | } |
| 528 | 516 | |
| 529 | 517 | static MACHINE_CONFIG_START( svision, svision_state ) |