src/mess/machine/cbmb.c
| r4017 | r4018 | |
| 38 | 38 | |
| 39 | 39 | static TIMER_CALLBACK(cbmb_frame_interrupt); |
| 40 | 40 | |
| 41 | | /* keyboard lines */ |
| 42 | | static int cbmb_keyline_a, cbmb_keyline_b, cbmb_keyline_c; |
| 43 | | |
| 44 | | static int p500 = 0; |
| 45 | | static int cbm700; |
| 46 | | static int cbm_ntsc; |
| 47 | 41 | UINT8 *cbmb_basic; |
| 48 | 42 | UINT8 *cbmb_kernal; |
| 49 | 43 | static UINT8 *cbmb_chargen; |
| r4017 | r4018 | |
| 111 | 105 | port a7..a0 b7..b0 keyboard input */ |
| 112 | 106 | WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_a ) |
| 113 | 107 | { |
| 114 | | cbmb_keyline_a = data; |
| 108 | cbmb_state *state = device->machine->driver_data; |
| 109 | state->cbmb_keyline_a = data; |
| 115 | 110 | } |
| 116 | 111 | |
| 117 | 112 | WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_b ) |
| 118 | 113 | { |
| 119 | | cbmb_keyline_b = data; |
| 114 | cbmb_state *state = device->machine->driver_data; |
| 115 | state->cbmb_keyline_b = data; |
| 120 | 116 | } |
| 121 | 117 | |
| 122 | 118 | WRITE8_DEVICE_HANDLER( cbmb_keyboard_line_select_c ) |
| 123 | 119 | { |
| 124 | | cbmb_keyline_c = data; |
| 120 | cbmb_state *state = device->machine->driver_data; |
| 121 | state->cbmb_keyline_c = data; |
| 125 | 122 | } |
| 126 | 123 | |
| 127 | 124 | READ8_DEVICE_HANDLER( cbmb_keyboard_line_a ) |
| 128 | 125 | { |
| 129 | 126 | int data = 0; |
| 130 | | |
| 131 | | if (!(cbmb_keyline_c & 0x01)) |
| 127 | cbmb_state *state = device->machine->driver_data; |
| 128 | if (!(state->cbmb_keyline_c & 0x01)) |
| 132 | 129 | data |= input_port_read(device->machine, "ROW0"); |
| 133 | 130 | |
| 134 | | if (!(cbmb_keyline_c & 0x02)) |
| 131 | if (!(state->cbmb_keyline_c & 0x02)) |
| 135 | 132 | data |= input_port_read(device->machine, "ROW2"); |
| 136 | 133 | |
| 137 | | if (!(cbmb_keyline_c & 0x04)) |
| 134 | if (!(state->cbmb_keyline_c & 0x04)) |
| 138 | 135 | data |= input_port_read(device->machine, "ROW4"); |
| 139 | 136 | |
| 140 | | if (!(cbmb_keyline_c & 0x08)) |
| 137 | if (!(state->cbmb_keyline_c & 0x08)) |
| 141 | 138 | data |= input_port_read(device->machine, "ROW6"); |
| 142 | 139 | |
| 143 | | if (!(cbmb_keyline_c & 0x10)) |
| 140 | if (!(state->cbmb_keyline_c & 0x10)) |
| 144 | 141 | data |= input_port_read(device->machine, "ROW8"); |
| 145 | 142 | |
| 146 | | if (!(cbmb_keyline_c & 0x20)) |
| 143 | if (!(state->cbmb_keyline_c & 0x20)) |
| 147 | 144 | data |= input_port_read(device->machine, "ROW10"); |
| 148 | 145 | |
| 149 | 146 | return data ^0xff; |
| r4017 | r4018 | |
| 152 | 149 | READ8_DEVICE_HANDLER( cbmb_keyboard_line_b ) |
| 153 | 150 | { |
| 154 | 151 | int data = 0; |
| 155 | | |
| 156 | | if (!(cbmb_keyline_c & 0x01)) |
| 152 | cbmb_state *state = device->machine->driver_data; |
| 153 | if (!(state->cbmb_keyline_c & 0x01)) |
| 157 | 154 | data |= input_port_read(device->machine, "ROW1"); |
| 158 | 155 | |
| 159 | | if (!(cbmb_keyline_c & 0x02)) |
| 156 | if (!(state->cbmb_keyline_c & 0x02)) |
| 160 | 157 | data |= input_port_read(device->machine, "ROW3"); |
| 161 | 158 | |
| 162 | | if (!(cbmb_keyline_c & 0x04)) |
| 159 | if (!(state->cbmb_keyline_c & 0x04)) |
| 163 | 160 | data |= input_port_read(device->machine, "ROW5"); |
| 164 | 161 | |
| 165 | | if (!(cbmb_keyline_c & 0x08)) |
| 162 | if (!(state->cbmb_keyline_c & 0x08)) |
| 166 | 163 | data |= input_port_read(device->machine, "ROW7"); |
| 167 | 164 | |
| 168 | | if (!(cbmb_keyline_c & 0x10)) |
| 165 | if (!(state->cbmb_keyline_c & 0x10)) |
| 169 | 166 | data |= input_port_read(device->machine, "ROW9") | ((input_port_read(device->machine, "SPECIAL") & 0x04) ? 1 : 0 ); |
| 170 | 167 | |
| 171 | | if (!(cbmb_keyline_c & 0x20)) |
| 168 | if (!(state->cbmb_keyline_c & 0x20)) |
| 172 | 169 | data |= input_port_read(device->machine, "ROW11"); |
| 173 | 170 | |
| 174 | 171 | return data ^0xff; |
| r4017 | r4018 | |
| 177 | 174 | READ8_DEVICE_HANDLER( cbmb_keyboard_line_c ) |
| 178 | 175 | { |
| 179 | 176 | int data = 0; |
| 180 | | |
| 181 | | if ((input_port_read(device->machine, "ROW0") & ~cbmb_keyline_a) || |
| 182 | | (input_port_read(device->machine, "ROW1") & ~cbmb_keyline_b)) |
| 177 | cbmb_state *state = device->machine->driver_data; |
| 178 | if ((input_port_read(device->machine, "ROW0") & ~state->cbmb_keyline_a) || |
| 179 | (input_port_read(device->machine, "ROW1") & ~state->cbmb_keyline_b)) |
| 183 | 180 | data |= 0x01; |
| 184 | 181 | |
| 185 | | if ((input_port_read(device->machine, "ROW2") & ~cbmb_keyline_a) || |
| 186 | | (input_port_read(device->machine, "ROW3") & ~cbmb_keyline_b)) |
| 182 | if ((input_port_read(device->machine, "ROW2") & ~state->cbmb_keyline_a) || |
| 183 | (input_port_read(device->machine, "ROW3") & ~state->cbmb_keyline_b)) |
| 187 | 184 | data |= 0x02; |
| 188 | 185 | |
| 189 | | if ((input_port_read(device->machine, "ROW4") & ~cbmb_keyline_a) || |
| 190 | | (input_port_read(device->machine, "ROW5") & ~cbmb_keyline_b)) |
| 186 | if ((input_port_read(device->machine, "ROW4") & ~state->cbmb_keyline_a) || |
| 187 | (input_port_read(device->machine, "ROW5") & ~state->cbmb_keyline_b)) |
| 191 | 188 | data |= 0x04; |
| 192 | 189 | |
| 193 | | if ((input_port_read(device->machine, "ROW6") & ~cbmb_keyline_a) || |
| 194 | | (input_port_read(device->machine, "ROW7") & ~cbmb_keyline_b)) |
| 190 | if ((input_port_read(device->machine, "ROW6") & ~state->cbmb_keyline_a) || |
| 191 | (input_port_read(device->machine, "ROW7") & ~state->cbmb_keyline_b)) |
| 195 | 192 | data |= 0x08; |
| 196 | 193 | |
| 197 | | if ((input_port_read(device->machine, "ROW8") & ~cbmb_keyline_a) || |
| 198 | | ((input_port_read(device->machine, "ROW9") | ((input_port_read(device->machine, "SPECIAL") & 0x04) ? 1 : 0)) & ~cbmb_keyline_b)) |
| 194 | if ((input_port_read(device->machine, "ROW8") & ~state->cbmb_keyline_a) || |
| 195 | ((input_port_read(device->machine, "ROW9") | ((input_port_read(device->machine, "SPECIAL") & 0x04) ? 1 : 0)) & ~state->cbmb_keyline_b)) |
| 199 | 196 | data |= 0x10; |
| 200 | 197 | |
| 201 | | if ((input_port_read(device->machine, "ROW10") & ~cbmb_keyline_a) || |
| 202 | | (input_port_read(device->machine, "ROW11") & ~cbmb_keyline_b)) |
| 198 | if ((input_port_read(device->machine, "ROW10") & ~state->cbmb_keyline_a) || |
| 199 | (input_port_read(device->machine, "ROW11") & ~state->cbmb_keyline_b)) |
| 203 | 200 | data |= 0x20; |
| 204 | 201 | |
| 205 | | if (!p500) |
| 202 | if (!state->p500) |
| 206 | 203 | { |
| 207 | | if (!cbm_ntsc) |
| 204 | if (!state->cbm_ntsc) |
| 208 | 205 | data |= 0x40; |
| 209 | 206 | |
| 210 | | if (!cbm700) |
| 207 | if (!state->cbm700) |
| 211 | 208 | data |= 0x80; |
| 212 | 209 | } |
| 213 | 210 | return data ^0xff; |
| r4017 | r4018 | |
| 287 | 284 | |
| 288 | 285 | static void cbmb_common_driver_init(running_machine *machine) |
| 289 | 286 | { |
| 287 | cbmb_state *state = machine->driver_data; |
| 290 | 288 | cbmb_chargen=memory_region(machine, "main") + 0x100000; |
| 291 | 289 | /* memset(c64_memory, 0, 0xfd00); */ |
| 292 | 290 | |
| 293 | 291 | timer_pulse(machine, ATTOTIME_IN_MSEC(10), NULL, 0, cbmb_frame_interrupt); |
| 294 | 292 | |
| 295 | | p500 = 0; |
| 296 | | cbm700 = 0; |
| 293 | state->p500 = 0; |
| 294 | state->cbm700 = 0; |
| 297 | 295 | cbm_ieee_open(); |
| 298 | 296 | } |
| 299 | 297 | |
| 300 | 298 | DRIVER_INIT( cbm600 ) |
| 301 | 299 | { |
| 302 | | cbmb_common_driver_init(machine); |
| 303 | | cbm_ntsc = 1; |
| 300 | cbmb_state *state = machine->driver_data; |
| 301 | cbmb_common_driver_init(machine); |
| 302 | state->cbm_ntsc = 1; |
| 304 | 303 | cbm600_vh_init(machine); |
| 305 | 304 | } |
| 306 | 305 | |
| 307 | 306 | DRIVER_INIT( cbm600pal ) |
| 308 | 307 | { |
| 308 | cbmb_state *state = machine->driver_data; |
| 309 | 309 | cbmb_common_driver_init(machine); |
| 310 | | cbm_ntsc = 0; |
| 310 | state->cbm_ntsc = 0; |
| 311 | 311 | cbm600_vh_init(machine); |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | DRIVER_INIT( cbm600hu ) |
| 315 | 315 | { |
| 316 | cbmb_state *state = machine->driver_data; |
| 316 | 317 | cbmb_common_driver_init(machine); |
| 317 | | cbm_ntsc = 0; |
| 318 | state->cbm_ntsc = 0; |
| 318 | 319 | } |
| 319 | 320 | |
| 320 | 321 | DRIVER_INIT( cbm700 ) |
| 321 | 322 | { |
| 323 | cbmb_state *state = machine->driver_data; |
| 322 | 324 | cbmb_common_driver_init(machine); |
| 323 | | cbm700 = 1; |
| 324 | | cbm_ntsc = 0; |
| 325 | state->cbm700 = 1; |
| 326 | state->cbm_ntsc = 0; |
| 325 | 327 | cbm700_vh_init(machine); |
| 326 | 328 | } |
| 327 | 329 | |
| 328 | 330 | DRIVER_INIT( p500 ) |
| 329 | 331 | { |
| 332 | cbmb_state *state = machine->driver_data; |
| 330 | 333 | cbmb_common_driver_init(machine); |
| 331 | | p500 = 1; |
| 332 | | cbm_ntsc = 1; |
| 334 | state->p500 = 1; |
| 335 | state->cbm_ntsc = 1; |
| 333 | 336 | vic6567_init(0, 0, cbmb_dma_read, cbmb_dma_read_color, NULL); |
| 334 | 337 | } |
| 335 | 338 | |
src/mess/machine/pet.c
| r4017 | r4018 | |
| 31 | 31 | } \ |
| 32 | 32 | } while (0) |
| 33 | 33 | |
| 34 | | /* keyboard lines */ |
| 35 | | static int pet_basic1 = 0; /* basic version 1 for quickloader */ |
| 36 | | static int superpet = 0; |
| 37 | | static int cbm8096 = 0; |
| 38 | | static int pet_keyline_select; |
| 39 | | |
| 40 | 34 | int pet_font = 0; |
| 41 | 35 | UINT8 *pet_memory; |
| 42 | 36 | UINT8 *superpet_memory; |
| 43 | 37 | UINT8 *pet_videoram; |
| 44 | 38 | static UINT8 *pet80_bank1_base; |
| 39 | static int pet_keyline_select; |
| 45 | 40 | |
| 46 | 41 | static emu_timer *datasette1_timer; |
| 47 | 42 | static emu_timer *datasette2_timer; |
| r4017 | r4018 | |
| 80 | 75 | cb2 cassette 1 motor out |
| 81 | 76 | */ |
| 82 | 77 | static READ8_HANDLER ( pet_pia0_port_a_read ) |
| 83 | | { |
| 78 | { |
| 84 | 79 | int data = 0xf0 | pet_keyline_select; |
| 85 | 80 | |
| 86 | 81 | if ((cassette_get_state(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette1" )) & CASSETTE_MASK_UISTATE) != CASSETTE_STOPPED) |
| r4017 | r4018 | |
| 121 | 116 | static READ8_HANDLER( petb_pia0_port_b_read ) |
| 122 | 117 | { |
| 123 | 118 | UINT8 data = 0xff; |
| 119 | pet_state *state = space->machine->driver_data; |
| 124 | 120 | static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4", |
| 125 | 121 | "ROW5", "ROW6", "ROW7", "ROW8", "ROW9" }; |
| 126 | 122 | |
| r4017 | r4018 | |
| 130 | 126 | /* Check for left-shift lock */ |
| 131 | 127 | /* 2008-05 FP: For some reason, superpet read it in the opposite way!! */ |
| 132 | 128 | /* While waiting for confirmation from docs, we add a workaround here. */ |
| 133 | | if (superpet) |
| 129 | if (state->superpet) |
| 134 | 130 | { |
| 135 | 131 | if ((pet_keyline_select == 6) && !(input_port_read(space->machine, "SPECIAL") & 0x80)) |
| 136 | 132 | data &= 0xfe; |
| r4017 | r4018 | |
| 175 | 171 | static void pet_irq (running_machine *machine, int level) |
| 176 | 172 | { |
| 177 | 173 | static int old_level = 0; |
| 178 | | |
| 174 | pet_state *state = machine->driver_data; |
| 179 | 175 | if (level != old_level) |
| 180 | 176 | { |
| 181 | 177 | DBG_LOG (3, "mos6502", ("irq %s\n", level ? "start" : "end")); |
| 182 | | if (superpet) |
| 178 | if (state->superpet) |
| 183 | 179 | cpu_set_input_line(machine->cpu[1], M6809_IRQ_LINE, level); |
| 184 | 180 | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, level); |
| 185 | 181 | old_level = level; |
| r4017 | r4018 | |
| 583 | 579 | static void pet_common_driver_init(running_machine *machine) |
| 584 | 580 | { |
| 585 | 581 | int i; |
| 582 | pet_state *state = machine->driver_data; |
| 586 | 583 | |
| 584 | state->pet_basic1 = 0; |
| 585 | state->superpet = 0; |
| 586 | state->cbm8096 = 0; |
| 587 | |
| 587 | 588 | /* BIG HACK; need to phase out this retarded memory management */ |
| 588 | 589 | if (!pet_memory) |
| 589 | 590 | pet_memory = mess_ram; |
| r4017 | r4018 | |
| 619 | 620 | |
| 620 | 621 | DRIVER_INIT( pet2001 ) |
| 621 | 622 | { |
| 622 | | pet_basic1 = 1; |
| 623 | pet_state *state = machine->driver_data; |
| 623 | 624 | pet_common_driver_init(machine); |
| 625 | state->pet_basic1 = 1; |
| 624 | 626 | pia_config(machine, 0, &pet_pia0); |
| 625 | 627 | pet_vh_init(machine); |
| 626 | 628 | } |
| r4017 | r4018 | |
| 648 | 650 | |
| 649 | 651 | DRIVER_INIT( pet80 ) |
| 650 | 652 | { |
| 651 | | cbm8096 = 1; |
| 653 | |
| 654 | pet_state *state = machine->driver_data; |
| 652 | 655 | pet_memory = memory_region(machine, "main"); |
| 653 | 656 | |
| 654 | 657 | pet_common_driver_init(machine); |
| 658 | state->cbm8096 = 1; |
| 655 | 659 | pia_config(machine, 0, &petb_pia0); |
| 656 | 660 | videoram = &pet_memory[0x8000]; |
| 657 | 661 | videoram_size = 0x800; |
| 658 | 662 | pet80_vh_init(machine); |
| 663 | |
| 659 | 664 | } |
| 660 | 665 | |
| 661 | 666 | DRIVER_INIT( superpet ) |
| 662 | 667 | { |
| 663 | | superpet = 1; |
| 668 | |
| 669 | pet_state *state = machine->driver_data; |
| 664 | 670 | pet_common_driver_init(machine); |
| 671 | state->superpet = 1; |
| 665 | 672 | pia_config(machine, 0, &petb_pia0); |
| 666 | 673 | |
| 667 | 674 | superpet_memory = auto_malloc(0x10000); |
| r4017 | r4018 | |
| 674 | 681 | |
| 675 | 682 | MACHINE_RESET( pet ) |
| 676 | 683 | { |
| 684 | pet_state *state = machine->driver_data; |
| 677 | 685 | pia_reset(); |
| 678 | | |
| 679 | | if (superpet) |
| 686 | |
| 687 | if (state->superpet) |
| 680 | 688 | { |
| 681 | 689 | spet.rom = 0; |
| 682 | 690 | if (input_port_read(machine, "CFG") & 0x04) |
| r4017 | r4018 | |
| 693 | 701 | } |
| 694 | 702 | } |
| 695 | 703 | |
| 696 | | if (cbm8096) |
| 704 | if (state->cbm8096) |
| 697 | 705 | { |
| 698 | 706 | if (input_port_read(machine, "CFG") & 0x08) |
| 699 | 707 | { |
| r4017 | r4018 | |
| 714 | 722 | |
| 715 | 723 | INTERRUPT_GEN( pet_frame_interrupt ) |
| 716 | 724 | { |
| 717 | | if (superpet) |
| 725 | pet_state *state = device->machine->driver_data; |
| 726 | if (state->superpet) |
| 718 | 727 | { |
| 719 | 728 | if (input_port_read(device->machine, "CFG") & 0x04) |
| 720 | 729 | { |