src/mess/machine/apple3.c
| r3635 | r3636 | |
| 118 | 118 | |
| 119 | 119 | static READ8_HANDLER( apple3_c0xx_r ) |
| 120 | 120 | { |
| 121 | | const device_config *fdc = device_list_find_by_tag(machine->config->devicelist, |
| 121 | const device_config *fdc = device_list_find_by_tag(space->machine->config->devicelist, |
| 122 | 122 | APPLEFDC, |
| 123 | 123 | "fdc"); |
| 124 | 124 | UINT8 result = 0xFF; |
| r3635 | r3636 | |
| 180 | 180 | break; |
| 181 | 181 | |
| 182 | 182 | case 0xDB: |
| 183 | | apple3_write_charmem(); |
| 183 | apple3_write_charmem(space->machine); |
| 184 | 184 | break; |
| 185 | 185 | |
| 186 | 186 | case 0xE0: case 0xE1: case 0xE2: case 0xE3: |
| r3635 | r3636 | |
| 194 | 194 | case 0xF1: |
| 195 | 195 | case 0xF2: |
| 196 | 196 | case 0xF3: |
| 197 | | result = acia_6551_r(machine, offset & 0x03); |
| 197 | result = acia_6551_r(space, offset & 0x03); |
| 198 | 198 | break; |
| 199 | 199 | } |
| 200 | 200 | return result; |
| r3635 | r3636 | |
| 204 | 204 | |
| 205 | 205 | static WRITE8_HANDLER( apple3_c0xx_w ) |
| 206 | 206 | { |
| 207 | | const device_config *fdc = device_list_find_by_tag(machine->config->devicelist, |
| 207 | const device_config *fdc = device_list_find_by_tag(space->machine->config->devicelist, |
| 208 | 208 | IWM, |
| 209 | 209 | "fdc"); |
| 210 | 210 | switch(offset) |
| r3635 | r3636 | |
| 244 | 244 | break; |
| 245 | 245 | |
| 246 | 246 | case 0xDB: |
| 247 | | apple3_write_charmem(); |
| 247 | apple3_write_charmem(space->machine); |
| 248 | 248 | break; |
| 249 | 249 | |
| 250 | 250 | case 0xE0: case 0xE1: case 0xE2: case 0xE3: |
| r3635 | r3636 | |
| 258 | 258 | case 0xF1: |
| 259 | 259 | case 0xF2: |
| 260 | 260 | case 0xF3: |
| 261 | | acia_6551_w(machine, offset & 0x03, data); |
| 261 | acia_6551_w(space, offset & 0x03, data); |
| 262 | 262 | break; |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | INTERRUPT_GEN( apple3_interrupt ) |
| 267 | 267 | { |
| 268 | | via_set_input_ca2(machine, 1, (AY3600_keydata_strobe_r() & 0x80) ? 1 : 0); |
| 269 | | via_set_input_cb1(machine, 1, video_screen_get_vblank(machine->primary_screen)); |
| 270 | | via_set_input_cb2(machine, 1, video_screen_get_vblank(machine->primary_screen)); |
| 268 | via_set_input_ca2(device->machine, 1, (AY3600_keydata_strobe_r() & 0x80) ? 1 : 0); |
| 269 | via_set_input_cb1(device->machine, 1, video_screen_get_vblank(device->machine->primary_screen)); |
| 270 | via_set_input_cb2(device->machine, 1, video_screen_get_vblank(device->machine->primary_screen)); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | |
| r3635 | r3636 | |
| 287 | 287 | |
| 288 | 288 | |
| 289 | 289 | |
| 290 | | static void apple3_setbank(int mame_bank, UINT16 bank, offs_t offset) |
| 290 | static void apple3_setbank(running_machine *machine,int mame_bank, UINT16 bank, offs_t offset) |
| 291 | 291 | { |
| 292 | 292 | UINT8 *ptr; |
| 293 | 293 | |
| 294 | 294 | ptr = apple3_bankaddr(bank, offset); |
| 295 | | memory_set_bankptr(mame_bank, ptr); |
| 295 | memory_set_bankptr(machine, mame_bank, ptr); |
| 296 | 296 | |
| 297 | 297 | if (LOG_MEMORY) |
| 298 | 298 | { |
| r3635 | r3636 | |
| 338 | 338 | { |
| 339 | 339 | UINT16 bank; |
| 340 | 340 | UINT8 page; |
| 341 | const address_space* space = cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM); |
| 341 | 342 | |
| 342 | 343 | if (LOG_MEMORY) |
| 343 | 344 | { |
| 344 | 345 | logerror("apple3_update_memory(): via_0_b=0x%02x via_1_a=0x0x%02x\n", via_0_b, via_1_a); |
| 345 | 346 | } |
| 346 | 347 | |
| 347 | | cpunum_set_clock(machine, 0, (via_0_a & 0x80) ? 1000000 : 2000000); |
| 348 | cpu_set_clock(machine->cpu[0], (via_0_a & 0x80) ? 1000000 : 2000000); |
| 348 | 349 | |
| 349 | 350 | /* bank 2 (0100-01FF) */ |
| 350 | 351 | if (!(via_0_a & 0x04)) |
| r3635 | r3636 | |
| 370 | 371 | bank = ~0; |
| 371 | 372 | page = 0x01; |
| 372 | 373 | } |
| 373 | | apple3_setbank(2, bank, ((offs_t) page) * 0x100); |
| 374 | apple3_setbank(machine,2, bank, ((offs_t) page) * 0x100); |
| 374 | 375 | |
| 375 | 376 | /* bank 3 (0200-1FFF) */ |
| 376 | | apple3_setbank(3, ~0, 0x0200); |
| 377 | apple3_setbank(machine,3, ~0, 0x0200); |
| 377 | 378 | |
| 378 | 379 | /* bank 4 (2000-9FFF) */ |
| 379 | | apple3_setbank(4, via_1_a, 0x0000); |
| 380 | apple3_setbank(machine,4, via_1_a, 0x0000); |
| 380 | 381 | |
| 381 | 382 | /* bank 5 (A000-BFFF) */ |
| 382 | | apple3_setbank(5, ~0, 0x2000); |
| 383 | apple3_setbank(machine,5, ~0, 0x2000); |
| 383 | 384 | |
| 384 | 385 | /* install bank 8 (C000-CFFF) */ |
| 385 | 386 | if (via_0_a & 0x40) |
| 386 | 387 | { |
| 387 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC000, 0xC0FF, 0, 0, apple3_c0xx_r); |
| 388 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC000, 0xC0FF, 0, 0, apple3_c0xx_w); |
| 388 | memory_install_read8_handler(space, 0xC000, 0xC0FF, 0, 0, apple3_c0xx_r); |
| 389 | memory_install_write8_handler(space, 0xC000, 0xC0FF, 0, 0, apple3_c0xx_w); |
| 389 | 390 | } |
| 390 | 391 | else |
| 391 | 392 | { |
| 392 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC000, 0xC0FF, 0, 0, SMH_BANK8); |
| 393 | memory_install_read8_handler(space, 0xC000, 0xC0FF, 0, 0, SMH_BANK8); |
| 393 | 394 | if (via_0_a & 0x08) |
| 394 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC000, 0xC0FF, 0, 0, SMH_UNMAP); |
| 395 | memory_install_write8_handler(space, 0xC000, 0xC0FF, 0, 0, SMH_UNMAP); |
| 395 | 396 | else |
| 396 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC000, 0xC0FF, 0, 0, SMH_BANK8); |
| 397 | | apple3_setbank(8, ~0, 0x4000); |
| 397 | memory_install_write8_handler(space, 0xC000, 0xC0FF, 0, 0, SMH_BANK8); |
| 398 | apple3_setbank(machine,8, ~0, 0x4000); |
| 398 | 399 | } |
| 399 | 400 | |
| 400 | 401 | /* install bank 9 (C100-C4FF) */ |
| 401 | 402 | if (via_0_a & 0x40) |
| 402 | 403 | { |
| 403 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC100, 0xC4FF, 0, 0, SMH_NOP); |
| 404 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC100, 0xC4FF, 0, 0, SMH_NOP); |
| 404 | memory_install_read8_handler(space, 0xC100, 0xC4FF, 0, 0, SMH_NOP); |
| 405 | memory_install_write8_handler(space, 0xC100, 0xC4FF, 0, 0, SMH_NOP); |
| 405 | 406 | } |
| 406 | 407 | else |
| 407 | 408 | { |
| 408 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC100, 0xC4FF, 0, 0, SMH_BANK9); |
| 409 | memory_install_read8_handler(space, 0xC100, 0xC4FF, 0, 0, SMH_BANK9); |
| 409 | 410 | if (via_0_a & 0x08) |
| 410 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC100, 0xC4FF, 0, 0, SMH_UNMAP); |
| 411 | memory_install_write8_handler(space, 0xC100, 0xC4FF, 0, 0, SMH_UNMAP); |
| 411 | 412 | else |
| 412 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC100, 0xC4FF, 0, 0, SMH_BANK9); |
| 413 | | apple3_setbank(9, ~0, 0x4100); |
| 413 | memory_install_write8_handler(space, 0xC100, 0xC4FF, 0, 0, SMH_BANK9); |
| 414 | apple3_setbank(machine,9, ~0, 0x4100); |
| 414 | 415 | } |
| 415 | 416 | |
| 416 | 417 | /* install bank 10 (C500-C7FF) */ |
| 417 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC500, 0xC7FF, 0, 0, SMH_BANK10); |
| 418 | memory_install_read8_handler(space, 0xC500, 0xC7FF, 0, 0, SMH_BANK10); |
| 418 | 419 | if (via_0_a & 0x08) |
| 419 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC500, 0xC7FF, 0, 0, SMH_UNMAP); |
| 420 | memory_install_write8_handler(space, 0xC500, 0xC7FF, 0, 0, SMH_UNMAP); |
| 420 | 421 | else |
| 421 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC500, 0xC7FF, 0, 0, SMH_BANK10); |
| 422 | | apple3_setbank(10, ~0, 0x4500); |
| 422 | memory_install_write8_handler(space, 0xC500, 0xC7FF, 0, 0, SMH_BANK10); |
| 423 | apple3_setbank(machine,10, ~0, 0x4500); |
| 423 | 424 | |
| 424 | 425 | /* install bank 11 (C800-CFFF) */ |
| 425 | 426 | if (via_0_a & 0x40) |
| 426 | 427 | { |
| 427 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC800, 0xCFFF, 0, 0, SMH_NOP); |
| 428 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC800, 0xCFFF, 0, 0, SMH_NOP); |
| 428 | memory_install_read8_handler(space, 0xC800, 0xCFFF, 0, 0, SMH_NOP); |
| 429 | memory_install_write8_handler(space, 0xC800, 0xCFFF, 0, 0, SMH_NOP); |
| 429 | 430 | } |
| 430 | 431 | else |
| 431 | 432 | { |
| 432 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC800, 0xCFFF, 0, 0, SMH_BANK11); |
| 433 | memory_install_read8_handler(space, 0xC800, 0xCFFF, 0, 0, SMH_BANK11); |
| 433 | 434 | if (via_0_a & 0x08) |
| 434 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC800, 0xCFFF, 0, 0, SMH_UNMAP); |
| 435 | memory_install_write8_handler(space, 0xC800, 0xCFFF, 0, 0, SMH_UNMAP); |
| 435 | 436 | else |
| 436 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xC800, 0xCFFF, 0, 0, SMH_BANK11); |
| 437 | | apple3_setbank(11, ~0, 0x4800); |
| 437 | memory_install_write8_handler(space, 0xC800, 0xCFFF, 0, 0, SMH_BANK11); |
| 438 | apple3_setbank(machine,11, ~0, 0x4800); |
| 438 | 439 | } |
| 439 | 440 | |
| 440 | 441 | /* install bank 6 (D000-EFFF) */ |
| 441 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xD000, 0xEFFF, 0, 0, SMH_BANK6); |
| 442 | memory_install_read8_handler(space, 0xD000, 0xEFFF, 0, 0, SMH_BANK6); |
| 442 | 443 | if (via_0_a & 0x08) |
| 443 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xD000, 0xEFFF, 0, 0, SMH_UNMAP); |
| 444 | memory_install_write8_handler(space, 0xD000, 0xEFFF, 0, 0, SMH_UNMAP); |
| 444 | 445 | else |
| 445 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xD000, 0xEFFF, 0, 0, SMH_BANK6); |
| 446 | | apple3_setbank(6, ~0, 0x5000); |
| 446 | memory_install_write8_handler(space, 0xD000, 0xEFFF, 0, 0, SMH_BANK6); |
| 447 | apple3_setbank(machine,6, ~0, 0x5000); |
| 447 | 448 | |
| 448 | 449 | /* install bank 7 (F000-FFFF) */ |
| 449 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xF000, 0xFFFF, 0, 0, SMH_BANK7); |
| 450 | memory_install_read8_handler(space, 0xF000, 0xFFFF, 0, 0, SMH_BANK7); |
| 450 | 451 | if (via_0_a & 0x09) |
| 451 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xF000, 0xFFFF, 0, 0, SMH_UNMAP); |
| 452 | memory_install_write8_handler(space, 0xF000, 0xFFFF, 0, 0, SMH_UNMAP); |
| 452 | 453 | else |
| 453 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xF000, 0xFFFF, 0, 0, SMH_BANK7); |
| 454 | memory_install_write8_handler(space, 0xF000, 0xFFFF, 0, 0, SMH_BANK7); |
| 454 | 455 | if (via_0_a & 0x01) |
| 455 | | memory_set_bankptr(7, memory_region(machine, "main")); |
| 456 | memory_set_bankptr(machine,7, memory_region(machine, "main")); |
| 456 | 457 | else |
| 457 | | apple3_setbank(7, ~0, 0x7000); |
| 458 | apple3_setbank(machine,7, ~0, 0x7000); |
| 458 | 459 | |
| 459 | 460 | /* reinstall VIA handlers */ |
| 460 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xFFD0, 0xFFDF, 0, 0, via_0_r); |
| 461 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xFFD0, 0xFFDF, 0, 0, via_0_w); |
| 462 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xFFE0, 0xFFEF, 0, 0, via_1_r); |
| 463 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xFFE0, 0xFFEF, 0, 0, via_1_w); |
| 461 | memory_install_read8_handler(space, 0xFFD0, 0xFFDF, 0, 0, via_0_r); |
| 462 | memory_install_write8_handler(space, 0xFFD0, 0xFFDF, 0, 0, via_0_w); |
| 463 | memory_install_read8_handler(space, 0xFFE0, 0xFFEF, 0, 0, via_1_r); |
| 464 | memory_install_write8_handler(space, 0xFFE0, 0xFFEF, 0, 0, via_1_w); |
| 464 | 465 | } |
| 465 | 466 | |
| 466 | 467 | |
| r3635 | r3636 | |
| 479 | 480 | static READ8_HANDLER(apple3_via_1_in_a) { return ~0; } |
| 480 | 481 | static READ8_HANDLER(apple3_via_1_in_b) { return ~0; } |
| 481 | 482 | |
| 482 | | static WRITE8_HANDLER(apple3_via_0_out_a) { apple3_via_out(machine, &via_0_a, data); } |
| 483 | | static WRITE8_HANDLER(apple3_via_0_out_b) { apple3_via_out(machine, &via_0_b, data); } |
| 484 | | static WRITE8_HANDLER(apple3_via_1_out_a) { apple3_via_out(machine, &via_1_a, data); } |
| 485 | | static WRITE8_HANDLER(apple3_via_1_out_b) { apple3_via_out(machine, &via_1_b, data); } |
| 483 | static WRITE8_HANDLER(apple3_via_0_out_a) { apple3_via_out(space->machine, &via_0_a, data); } |
| 484 | static WRITE8_HANDLER(apple3_via_0_out_b) { apple3_via_out(space->machine, &via_0_b, data); } |
| 485 | static WRITE8_HANDLER(apple3_via_1_out_a) { apple3_via_out(space->machine, &via_1_a, data); } |
| 486 | static WRITE8_HANDLER(apple3_via_1_out_b) { apple3_via_out(space->machine, &via_1_b, data); } |
| 486 | 487 | |
| 487 | 488 | static void apple2_via_1_irq_func(running_machine *machine, int state) |
| 488 | 489 | { |
| r3635 | r3636 | |
| 621 | 622 | else if (addr != (UINT8 *) ~0) |
| 622 | 623 | result = *addr; |
| 623 | 624 | else |
| 624 | | result = memory_region(machine, "main")[offset % memory_region_length(machine, "main")]; |
| 625 | result = memory_region(space->machine, "main")[offset % memory_region_length(space->machine, "main")]; |
| 625 | 626 | return result; |
| 626 | 627 | } |
| 627 | 628 | |
| r3635 | r3636 | |
| 647 | 648 | if ((address & 0xFF00) == 0x0000) |
| 648 | 649 | { |
| 649 | 650 | opptr = apple3_get_zpa_addr(address); |
| 650 | | opbase->mask = ~0; |
| 651 | direct->mask = ~0; |
| 651 | 652 | direct->raw = direct->decrypted = opptr - address; |
| 652 | | opbase->mem_min = address; |
| 653 | | opbase->mem_max = address; |
| 653 | direct->min = address; |
| 654 | direct->max = address; |
| 654 | 655 | address = ~0; |
| 655 | 656 | } |
| 656 | 657 | return address; |
| r3635 | r3636 | |
| 729 | 730 | via_1_irq = 0; |
| 730 | 731 | apple3_update_memory(machine); |
| 731 | 732 | |
| 732 | | memory_set_direct_update_handler(0, apple3_opbase); |
| 733 | memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM), apple3_opbase); |
| 733 | 734 | |
| 734 | 735 | /* the Apple /// does some weird tricks whereby it monitors the SYNC pin |
| 735 | 736 | * on the CPU to check for indexed instructions and directs them to |
| 736 | 737 | * different memory locations */ |
| 737 | | cpunum_set_info_fct(0, CPUINFO_PTR_M6502_READINDEXED_CALLBACK, (genf *) apple3_indexed_read); |
| 738 | | cpunum_set_info_fct(0, CPUINFO_PTR_M6502_WRITEINDEXED_CALLBACK, (genf *) apple3_indexed_write); |
| 738 | cpu_set_info_fct(machine->cpu[0], CPUINFO_PTR_M6502_READINDEXED_CALLBACK, (genf *) apple3_indexed_read); |
| 739 | cpu_set_info_fct(machine->cpu[0], CPUINFO_PTR_M6502_WRITEINDEXED_CALLBACK, (genf *) apple3_indexed_write); |
| 739 | 740 | } |
src/mess/machine/apple2gs.c
| r3635 | r3636 | |
| 795 | 795 | int scanline; |
| 796 | 796 | |
| 797 | 797 | // make sure we're in the 65816's context |
| 798 | | cpuintrf_push_context(0); |
| 798 | cpu_push_context(machine->cpu[0]); |
| 799 | 799 | |
| 800 | 800 | scanline = video_screen_get_vpos(machine->primary_screen); |
| 801 | 801 | video_screen_update_partial(machine->primary_screen, scanline); |
| r3635 | r3636 | |
| 831 | 831 | |
| 832 | 832 | /* call Apple II interrupt handler */ |
| 833 | 833 | if ((video_screen_get_vpos(machine->primary_screen) % 8) == 7) |
| 834 | | apple2_interrupt(machine, 0); |
| 834 | apple2_interrupt(machine->cpu[0]); |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | timer_adjust_oneshot(apple2gs_scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, (scanline+1)%262, 0), 0); |
| 838 | 838 | |
| 839 | | cpuintrf_pop_context(); |
| 839 | cpu_pop_context(); |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | 842 | |
| r3635 | r3636 | |
| 866 | 866 | } |
| 867 | 867 | else |
| 868 | 868 | { |
| 869 | | sndglu_dummy_read = es5503_reg_0_r(machine, sndglu_addr); |
| 869 | sndglu_dummy_read = es5503_reg_0_r(space, sndglu_addr); |
| 870 | 870 | } |
| 871 | 871 | |
| 872 | 872 | if (sndglu_ctrl & 0x20) // auto-increment |
| r3635 | r3636 | |
| 905 | 905 | } |
| 906 | 906 | else |
| 907 | 907 | { |
| 908 | | es5503_reg_0_w(machine, sndglu_addr, data); |
| 908 | es5503_reg_0_w(space, sndglu_addr, data); |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | 911 | if (sndglu_ctrl & 0x20) // auto-increment |
| r3635 | r3636 | |
| 965 | 965 | switch(offset) |
| 966 | 966 | { |
| 967 | 967 | case 0x19: /* C019 - RDVBLBAR */ |
| 968 | | result = (video_screen_get_vpos(machine->primary_screen) >= (192+BORDER_TOP)) ? 0x80 : 0x00; |
| 968 | result = (video_screen_get_vpos(space->machine->primary_screen) >= (192+BORDER_TOP)) ? 0x80 : 0x00; |
| 969 | 969 | break; |
| 970 | 970 | |
| 971 | 971 | case 0x22: /* C022 - TBCOLOR */ |
| r3635 | r3636 | |
| 978 | 978 | break; |
| 979 | 979 | |
| 980 | 980 | case 0x24: /* C024 - MOUSEDATA */ |
| 981 | | result = adb_read_mousedata(machine); |
| 981 | result = adb_read_mousedata(space->machine); |
| 982 | 982 | break; |
| 983 | 983 | |
| 984 | 984 | case 0x25: /* C025 - KEYMODREG */ |
| r3635 | r3636 | |
| 1006 | 1006 | break; |
| 1007 | 1007 | |
| 1008 | 1008 | case 0x2E: /* C02E - VERTCNT */ |
| 1009 | | result = apple2gs_get_vpos(machine) >> 1; |
| 1009 | result = apple2gs_get_vpos(space->machine) >> 1; |
| 1010 | 1010 | break; |
| 1011 | 1011 | |
| 1012 | 1012 | case 0x2F: /* C02F - HORIZCNT */ |
| 1013 | | result = video_screen_get_hpos(machine->primary_screen) / 11; |
| 1013 | result = video_screen_get_hpos(space->machine->primary_screen) / 11; |
| 1014 | 1014 | if (result > 0) |
| 1015 | 1015 | { |
| 1016 | 1016 | result += 0x40; |
| 1017 | 1017 | } |
| 1018 | 1018 | |
| 1019 | | if (apple2gs_get_vpos(machine) & 1) |
| 1019 | if (apple2gs_get_vpos(space->machine) & 1) |
| 1020 | 1020 | { |
| 1021 | 1021 | result |= 0x80; |
| 1022 | 1022 | } |
| r3635 | r3636 | |
| 1046 | 1046 | case 0x39: /* C039 - SCCAREG */ |
| 1047 | 1047 | case 0x3A: /* C03A - SCCBDATA */ |
| 1048 | 1048 | case 0x3B: /* C03B - SCCADATA */ |
| 1049 | | scc = device_list_find_by_tag(machine->config->devicelist, SCC8530, "scc"); |
| 1049 | scc = device_list_find_by_tag(space->machine->config->devicelist, SCC8530, "scc"); |
| 1050 | 1050 | result = scc_r(scc, offset & 0x03); |
| 1051 | 1051 | break; |
| 1052 | 1052 | |
| r3635 | r3636 | |
| 1054 | 1054 | case 0x3D: /* C03D - SOUNDDATA */ |
| 1055 | 1055 | case 0x3E: /* C03E - SOUNDADRL */ |
| 1056 | 1056 | case 0x3F: /* C03F - SOUNDADRH */ |
| 1057 | | result = gssnd_r(machine, offset & 0x03); |
| 1057 | result = gssnd_r(space, offset & 0x03); |
| 1058 | 1058 | break; |
| 1059 | 1059 | |
| 1060 | 1060 | case 0x41: /* C041 - INTEN */ |
| r3635 | r3636 | |
| 1079 | 1079 | case 0x74: case 0x75: case 0x76: case 0x77: |
| 1080 | 1080 | case 0x78: case 0x79: case 0x7a: case 0x7b: |
| 1081 | 1081 | case 0x7c: case 0x7d: case 0x7e: case 0x7f: |
| 1082 | | offset |= (memory_region_length(machine, "main") - 1) & ~0x3FFF; |
| 1083 | | result = memory_region(machine, "main")[offset]; |
| 1082 | offset |= (memory_region_length(space->machine, "main") - 1) & ~0x3FFF; |
| 1083 | result = memory_region(space->machine, "main")[offset]; |
| 1084 | 1084 | break; |
| 1085 | 1085 | |
| 1086 | 1086 | case 0x21: /* C021 - MONOCOLOR */ |
| r3635 | r3636 | |
| 1088 | 1088 | result = 0x00; |
| 1089 | 1089 | |
| 1090 | 1090 | default: |
| 1091 | | result = apple2_c0xx_r(machine, offset); |
| 1091 | result = apple2_c0xx_r(space, offset); |
| 1092 | 1092 | break; |
| 1093 | 1093 | } |
| 1094 | 1094 | |
| r3635 | r3636 | |
| 1130 | 1130 | break; |
| 1131 | 1131 | |
| 1132 | 1132 | case 0x26: /* C026 - DATAREG */ |
| 1133 | | adb_write_datareg(machine, data); |
| 1133 | adb_write_datareg(space->machine, data); |
| 1134 | 1134 | break; |
| 1135 | 1135 | |
| 1136 | 1136 | case 0x27: /* C027 - KMSTATUS */ |
| r3635 | r3636 | |
| 1147 | 1147 | |
| 1148 | 1148 | case 0x2D: /* C02D - SLTROMSEL */ |
| 1149 | 1149 | apple2gs_sltromsel = data; |
| 1150 | | apple2_update_memory(machine); |
| 1150 | apple2_update_memory(space->machine); |
| 1151 | 1151 | break; |
| 1152 | 1152 | |
| 1153 | 1153 | case 0x31: /* C031 - DISKREG */ |
| 1154 | | apple2_iwm_setdiskreg(machine, data); |
| 1154 | apple2_iwm_setdiskreg(space->machine, data); |
| 1155 | 1155 | break; |
| 1156 | 1156 | |
| 1157 | 1157 | case 0x32: /* C032 - SCANINT */ |
| 1158 | | apple2gs_set_scanint(machine, data); |
| 1158 | apple2gs_set_scanint(space->machine, data); |
| 1159 | 1159 | break; |
| 1160 | 1160 | |
| 1161 | 1161 | case 0x33: /* C033 - CLOCKDATA */ |
| r3635 | r3636 | |
| 1173 | 1173 | if (apple2gs_shadow != data) |
| 1174 | 1174 | { |
| 1175 | 1175 | apple2gs_shadow = data; |
| 1176 | | apple2_update_memory(machine); |
| 1176 | apple2_update_memory(space->machine); |
| 1177 | 1177 | } |
| 1178 | 1178 | break; |
| 1179 | 1179 | |
| 1180 | 1180 | case 0x36: /* C036 - CYAREG */ |
| 1181 | 1181 | apple2gs_cyareg = data & ~0x20; |
| 1182 | | cpunum_set_clock(machine, 0, (data & 0x80) ? APPLE2GS_14M/5 : APPLE2GS_7M/7); |
| 1182 | cpu_set_clock(space->machine->cpu[0], (data & 0x80) ? APPLE2GS_14M/5 : APPLE2GS_7M/7); |
| 1183 | 1183 | break; |
| 1184 | 1184 | |
| 1185 | 1185 | case 0x38: /* C038 - SCCBREG */ |
| 1186 | 1186 | case 0x39: /* C039 - SCCAREG */ |
| 1187 | 1187 | case 0x3A: /* C03A - SCCBDATA */ |
| 1188 | 1188 | case 0x3B: /* C03B - SCCADATA */ |
| 1189 | | scc = device_list_find_by_tag(machine->config->devicelist, SCC8530, "scc"); |
| 1189 | scc = device_list_find_by_tag(space->machine->config->devicelist, SCC8530, "scc"); |
| 1190 | 1190 | scc_w(scc, offset & 0x03, data); |
| 1191 | 1191 | break; |
| 1192 | 1192 | |
| r3635 | r3636 | |
| 1194 | 1194 | case 0x3D: /* C03D - SOUNDDATA */ |
| 1195 | 1195 | case 0x3E: /* C03E - SOUNDADRL */ |
| 1196 | 1196 | case 0x3F: /* C03F - SOUNDADRH */ |
| 1197 | | gssnd_w(machine, offset & 0x03, data); |
| 1197 | gssnd_w(space, offset & 0x03, data); |
| 1198 | 1198 | break; |
| 1199 | 1199 | |
| 1200 | 1200 | case 0x41: /* C041 - INTEN */ |
| 1201 | 1201 | apple2gs_inten = data & 0x1F; |
| 1202 | 1202 | if ((apple2gs_inten & 0x10) == 0x00) |
| 1203 | | apple2gs_remove_irq(machine, IRQ_INTEN_QSECOND); |
| 1203 | apple2gs_remove_irq(space->machine, IRQ_INTEN_QSECOND); |
| 1204 | 1204 | if ((apple2gs_inten & 0x08) == 0x00) |
| 1205 | | apple2gs_remove_irq(machine, IRQ_INTEN_VBL); |
| 1205 | apple2gs_remove_irq(space->machine, IRQ_INTEN_VBL); |
| 1206 | 1206 | break; |
| 1207 | 1207 | |
| 1208 | 1208 | case 0x47: /* C047 - CLRVBLINT */ |
| 1209 | 1209 | apple2gs_intflag &= ~0x18; |
| 1210 | | apple2gs_remove_irq(machine, IRQ_INTEN_QSECOND); |
| 1211 | | apple2gs_remove_irq(machine, IRQ_INTEN_VBL); |
| 1210 | apple2gs_remove_irq(space->machine, IRQ_INTEN_QSECOND); |
| 1211 | apple2gs_remove_irq(space->machine, IRQ_INTEN_VBL); |
| 1212 | 1212 | break; |
| 1213 | 1213 | |
| 1214 | 1214 | case 0x68: /* C068 - STATEREG */ |
| 1215 | | apple2_setvar(machine, |
| 1215 | apple2_setvar(space->machine, |
| 1216 | 1216 | ((data & 0x80) ? VAR_ALTZP : 0) | |
| 1217 | 1217 | ((data & 0x40) ? VAR_PAGE2 : 0) | |
| 1218 | 1218 | ((data & 0x20) ? VAR_RAMRD : 0) | |
| r3635 | r3636 | |
| 1224 | 1224 | break; |
| 1225 | 1225 | |
| 1226 | 1226 | default: |
| 1227 | | apple2_c0xx_w(machine, offset, data); |
| 1227 | apple2_c0xx_w(space, offset, data); |
| 1228 | 1228 | break; |
| 1229 | 1229 | } |
| 1230 | 1230 | } |
| r3635 | r3636 | |
| 1311 | 1311 | { |
| 1312 | 1312 | int color = (offset - 0x19e00) >> 1; |
| 1313 | 1313 | |
| 1314 | | palette_set_color_rgb(machine, color + 16, |
| 1314 | palette_set_color_rgb(space->machine, color + 16, |
| 1315 | 1315 | ((apple2gs_slowmem[0x19E00 + (color * 2) + 1] >> 0) & 0x0F) * 17, |
| 1316 | 1316 | ((apple2gs_slowmem[0x19E00 + (color * 2) + 0] >> 4) & 0x0F) * 17, |
| 1317 | 1317 | ((apple2gs_slowmem[0x19E00 + (color * 2) + 0] >> 0) & 0x0F) * 17); |
| r3635 | r3636 | |
| 1541 | 1541 | } |
| 1542 | 1542 | else if ((address & 0x000F00) == 0x000000) |
| 1543 | 1543 | { |
| 1544 | | result = apple2gs_c0xx_r(machine, address); |
| 1544 | result = apple2gs_c0xx_r(cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM), address); |
| 1545 | 1545 | } |
| 1546 | 1546 | else |
| 1547 | 1547 | { |
| r3635 | r3636 | |
| 1567 | 1567 | } |
| 1568 | 1568 | else if ((address & 0x000F00) == 0x000000) |
| 1569 | 1569 | { |
| 1570 | | apple2gs_c0xx_w(machine, address, data); |
| 1570 | apple2gs_c0xx_w(cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM), address, data); |
| 1571 | 1571 | } |
| 1572 | 1572 | else |
| 1573 | 1573 | { |
| r3635 | r3636 | |
| 1594 | 1594 | else if ((address & 0x000F00) == 0x000000) |
| 1595 | 1595 | { |
| 1596 | 1596 | if (((address & 0xFF) >= 0x71) && ((address & 0xFF) <= 0x7F)) |
| 1597 | | opptr = apple2gs_getslotmem(machine, address); |
| 1597 | opptr = apple2gs_getslotmem(space->machine, address); |
| 1598 | 1598 | } |
| 1599 | 1599 | else |
| 1600 | 1600 | { |
| 1601 | 1601 | slot = (address & 0x000F00) / 0x100; |
| 1602 | 1602 | |
| 1603 | 1603 | if ((slot > 7) || ((apple2gs_sltromsel & (1 << slot)) == 0)) |
| 1604 | | opptr = apple2gs_getslotmem(machine, address); |
| 1604 | opptr = apple2gs_getslotmem(space->machine, address); |
| 1605 | 1605 | } |
| 1606 | 1606 | |
| 1607 | 1607 | if (opptr != NULL) |
| 1608 | 1608 | { |
| 1609 | | opbase->mask = ~0; |
| 1609 | direct->mask = ~0; |
| 1610 | 1610 | direct->raw = direct->decrypted = opptr - address; |
| 1611 | | opbase->mem_min = address; |
| 1612 | | opbase->mem_max = address; |
| 1611 | direct->min = address; |
| 1612 | direct->max = address; |
| 1613 | 1613 | address = ~0; |
| 1614 | 1614 | } |
| 1615 | 1615 | } |
| r3635 | r3636 | |
| 1618 | 1618 | |
| 1619 | 1619 | |
| 1620 | 1620 | |
| 1621 | | static READ8_HANDLER( apple2gs_00Cxxx_r ) { return apple2gs_xxCxxx_r(machine, offset | 0x00C000); } |
| 1622 | | static READ8_HANDLER( apple2gs_01Cxxx_r ) { return apple2gs_xxCxxx_r(machine, offset | 0x01C000); } |
| 1623 | | static READ8_HANDLER( apple2gs_E0Cxxx_r ) { return apple2gs_xxCxxx_r(machine, offset | 0xE0C000); } |
| 1624 | | static READ8_HANDLER( apple2gs_E1Cxxx_r ) { return apple2gs_xxCxxx_r(machine, offset | 0xE1C000); } |
| 1621 | static READ8_HANDLER( apple2gs_00Cxxx_r ) { return apple2gs_xxCxxx_r(space->machine, offset | 0x00C000); } |
| 1622 | static READ8_HANDLER( apple2gs_01Cxxx_r ) { return apple2gs_xxCxxx_r(space->machine, offset | 0x01C000); } |
| 1623 | static READ8_HANDLER( apple2gs_E0Cxxx_r ) { return apple2gs_xxCxxx_r(space->machine, offset | 0xE0C000); } |
| 1624 | static READ8_HANDLER( apple2gs_E1Cxxx_r ) { return apple2gs_xxCxxx_r(space->machine, offset | 0xE1C000); } |
| 1625 | 1625 | |
| 1626 | | static WRITE8_HANDLER( apple2gs_00Cxxx_w) { apple2gs_xxCxxx_w(machine, offset | 0x00C000, data); } |
| 1627 | | static WRITE8_HANDLER( apple2gs_01Cxxx_w) { apple2gs_xxCxxx_w(machine, offset | 0x01C000, data); } |
| 1628 | | static WRITE8_HANDLER( apple2gs_E0Cxxx_w) { apple2gs_xxCxxx_w(machine, offset | 0xE0C000, data); } |
| 1629 | | static WRITE8_HANDLER( apple2gs_E1Cxxx_w) { apple2gs_xxCxxx_w(machine, offset | 0xE1C000, data); } |
| 1626 | static WRITE8_HANDLER( apple2gs_00Cxxx_w) { apple2gs_xxCxxx_w(space->machine, offset | 0x00C000, data); } |
| 1627 | static WRITE8_HANDLER( apple2gs_01Cxxx_w) { apple2gs_xxCxxx_w(space->machine, offset | 0x01C000, data); } |
| 1628 | static WRITE8_HANDLER( apple2gs_E0Cxxx_w) { apple2gs_xxCxxx_w(space->machine, offset | 0xE0C000, data); } |
| 1629 | static WRITE8_HANDLER( apple2gs_E1Cxxx_w) { apple2gs_xxCxxx_w(space->machine, offset | 0xE1C000, data); } |
| 1630 | 1630 | |
| 1631 | 1631 | static WRITE8_HANDLER( apple2gs_Exxxxx_w ) |
| 1632 | 1632 | { |
| 1633 | 1633 | apple2gs_slowmem[offset] = data; |
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | | static WRITE8_HANDLER( apple2gs_E004xx_w ) { apple2gs_Exxxxx_w(machine, offset + 0x00400, data); } |
| 1637 | | static WRITE8_HANDLER( apple2gs_E02xxx_w ) { apple2gs_Exxxxx_w(machine, offset + 0x02000, data); } |
| 1638 | | static WRITE8_HANDLER( apple2gs_E104xx_w ) { apple2gs_Exxxxx_w(machine, offset + 0x10400, data); } |
| 1639 | | static WRITE8_HANDLER( apple2gs_E12xxx_w ) { apple2gs_Exxxxx_w(machine, offset + 0x12000, data); } |
| 1636 | static WRITE8_HANDLER( apple2gs_E004xx_w ) { apple2gs_Exxxxx_w(space, offset + 0x00400, data); } |
| 1637 | static WRITE8_HANDLER( apple2gs_E02xxx_w ) { apple2gs_Exxxxx_w(space, offset + 0x02000, data); } |
| 1638 | static WRITE8_HANDLER( apple2gs_E104xx_w ) { apple2gs_Exxxxx_w(space, offset + 0x10400, data); } |
| 1639 | static WRITE8_HANDLER( apple2gs_E12xxx_w ) { apple2gs_Exxxxx_w(space, offset + 0x12000, data); } |
| 1640 | 1640 | |
| 1641 | 1641 | static WRITE8_HANDLER( apple2gs_slowmem_w ) |
| 1642 | 1642 | { |
| r3635 | r3636 | |
| 1646 | 1646 | { |
| 1647 | 1647 | int color = (offset - 0x19e00) >> 1; |
| 1648 | 1648 | |
| 1649 | | palette_set_color_rgb(machine, color + 16, |
| 1649 | palette_set_color_rgb(space->machine, color + 16, |
| 1650 | 1650 | ((apple2gs_slowmem[0x19E00 + (color * 2) + 1] >> 0) & 0x0F) * 17, |
| 1651 | 1651 | ((apple2gs_slowmem[0x19E00 + (color * 2) + 0] >> 4) & 0x0F) * 17, |
| 1652 | 1652 | ((apple2gs_slowmem[0x19E00 + (color * 2) + 0] >> 0) & 0x0F) * 17); |
| r3635 | r3636 | |
| 1656 | 1656 | |
| 1657 | 1657 | static void apple2gs_setup_memory(running_machine *machine) |
| 1658 | 1658 | { |
| 1659 | const address_space* space = cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM); |
| 1659 | 1660 | offs_t begin, end; |
| 1660 | 1661 | apple2_memmap_config cfg; |
| 1661 | 1662 | |
| r3635 | r3636 | |
| 1663 | 1664 | apple2gs_slowmem = auto_malloc(128*1024); |
| 1664 | 1665 | memset(apple2gs_slowmem, 0, 128*1024); |
| 1665 | 1666 | |
| 1666 | | state_save_register_item_array("APPLE2GS_SLOWMEM", 0, apple2gs_slowmem); |
| 1667 | state_save_register_item_array("APPLE2GS_SLOWMEM", NULL, 0, apple2gs_slowmem); |
| 1667 | 1668 | |
| 1668 | 1669 | /* install expanded memory */ |
| 1669 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x010000, mess_ram_size - 1, 0, 0, SMH_BANK1); |
| 1670 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x010000, mess_ram_size - 1, 0, 0, SMH_BANK1); |
| 1671 | | memory_set_bankptr(1, mess_ram + 0x010000); |
| 1670 | memory_install_read8_handler(space, 0x010000, mess_ram_size - 1, 0, 0, SMH_BANK1); |
| 1671 | memory_install_write8_handler(space, 0x010000, mess_ram_size - 1, 0, 0, SMH_BANK1); |
| 1672 | memory_set_bankptr(machine,1, mess_ram + 0x010000); |
| 1672 | 1673 | |
| 1673 | 1674 | /* install hi memory */ |
| 1674 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe00000, 0xe1ffff, 0, 0, SMH_BANK2); |
| 1675 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe00000, 0xe1ffff, 0, 0, apple2gs_slowmem_w); |
| 1676 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe00400, 0xe007ff, 0, 0, apple2gs_E004xx_w); |
| 1677 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe02000, 0xe03fff, 0, 0, apple2gs_E02xxx_w); |
| 1678 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe10400, 0xe107ff, 0, 0, apple2gs_E104xx_w); |
| 1679 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe12000, 0xe13fff, 0, 0, apple2gs_E12xxx_w); |
| 1680 | | memory_set_bankptr(2, apple2gs_slowmem); |
| 1675 | memory_install_read8_handler(space, 0xe00000, 0xe1ffff, 0, 0, SMH_BANK2); |
| 1676 | memory_install_write8_handler(space, 0xe00000, 0xe1ffff, 0, 0, apple2gs_slowmem_w); |
| 1677 | memory_install_write8_handler(space, 0xe00400, 0xe007ff, 0, 0, apple2gs_E004xx_w); |
| 1678 | memory_install_write8_handler(space, 0xe02000, 0xe03fff, 0, 0, apple2gs_E02xxx_w); |
| 1679 | memory_install_write8_handler(space, 0xe10400, 0xe107ff, 0, 0, apple2gs_E104xx_w); |
| 1680 | memory_install_write8_handler(space, 0xe12000, 0xe13fff, 0, 0, apple2gs_E12xxx_w); |
| 1681 | memory_set_bankptr(machine,2, apple2gs_slowmem); |
| 1681 | 1682 | |
| 1682 | 1683 | /* install alternate ROM bank */ |
| 1683 | 1684 | begin = 0x1000000 - memory_region_length(machine, "main"); |
| 1684 | 1685 | end = 0xffffff; |
| 1685 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, begin, end, 0, 0, SMH_BANK3); |
| 1686 | | memory_set_bankptr(3, memory_region(machine, "main")); |
| 1686 | memory_install_read8_handler(space, begin, end, 0, 0, SMH_BANK3); |
| 1687 | memory_set_bankptr(machine,3, memory_region(machine, "main")); |
| 1687 | 1688 | |
| 1688 | 1689 | /* install new xxC000-xxCFFF handlers */ |
| 1689 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x00c000, 0x00cfff, 0, 0, apple2gs_00Cxxx_r); |
| 1690 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x00c000, 0x00cfff, 0, 0, apple2gs_00Cxxx_w); |
| 1691 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x01c000, 0x01cfff, 0, 0, apple2gs_01Cxxx_r); |
| 1692 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x01c000, 0x01cfff, 0, 0, apple2gs_01Cxxx_w); |
| 1693 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe0c000, 0xe0cfff, 0, 0, apple2gs_E0Cxxx_r); |
| 1694 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe0c000, 0xe0cfff, 0, 0, apple2gs_E0Cxxx_w); |
| 1695 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe1c000, 0xe1cfff, 0, 0, apple2gs_E1Cxxx_r); |
| 1696 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xe1c000, 0xe1cfff, 0, 0, apple2gs_E1Cxxx_w); |
| 1697 | | memory_set_direct_update_handler(0, apple2gs_opbase); |
| 1690 | memory_install_read8_handler(space, 0x00c000, 0x00cfff, 0, 0, apple2gs_00Cxxx_r); |
| 1691 | memory_install_write8_handler(space, 0x00c000, 0x00cfff, 0, 0, apple2gs_00Cxxx_w); |
| 1692 | memory_install_read8_handler(space, 0x01c000, 0x01cfff, 0, 0, apple2gs_01Cxxx_r); |
| 1693 | memory_install_write8_handler(space, 0x01c000, 0x01cfff, 0, 0, apple2gs_01Cxxx_w); |
| 1694 | memory_install_read8_handler(space, 0xe0c000, 0xe0cfff, 0, 0, apple2gs_E0Cxxx_r); |
| 1695 | memory_install_write8_handler(space, 0xe0c000, 0xe0cfff, 0, 0, apple2gs_E0Cxxx_w); |
| 1696 | memory_install_read8_handler(space, 0xe1c000, 0xe1cfff, 0, 0, apple2gs_E1Cxxx_r); |
| 1697 | memory_install_write8_handler(space, 0xe1c000, 0xe1cfff, 0, 0, apple2gs_E1Cxxx_w); |
| 1698 | memory_set_direct_update_handler(space, apple2gs_opbase); |
| 1698 | 1699 | |
| 1699 | 1700 | /* install aux memory writes (for shadowing) */ |
| 1700 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x010400, 0x0107FF, 0, 0, apple2gs_aux0400_w); |
| 1701 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x012000, 0x013FFF, 0, 0, apple2gs_aux2000_w); |
| 1702 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x014000, 0x019FFF, 0, 0, apple2gs_aux4000_w); |
| 1701 | memory_install_write8_handler(space, 0x010400, 0x0107FF, 0, 0, apple2gs_aux0400_w); |
| 1702 | memory_install_write8_handler(space, 0x012000, 0x013FFF, 0, 0, apple2gs_aux2000_w); |
| 1703 | memory_install_write8_handler(space, 0x014000, 0x019FFF, 0, 0, apple2gs_aux4000_w); |
| 1703 | 1704 | |
| 1704 | 1705 | /* setup the Apple II memory system */ |
| 1705 | 1706 | memset(&cfg, 0, sizeof(cfg)); |
| r3635 | r3636 | |
| 1741 | 1742 | apple2_init_common(machine); |
| 1742 | 1743 | |
| 1743 | 1744 | /* set up Apple IIgs vectoring */ |
| 1744 | | cpunum_set_info_fct(0, CPUINFO_PTR_G65816_READVECTOR_CALLBACK, (genf *) apple2gs_read_vector); |
| 1745 | cpu_set_info_fct(machine->cpu[0], CPUINFO_PTR_G65816_READVECTOR_CALLBACK, (genf *) apple2gs_read_vector); |
| 1745 | 1746 | |
| 1746 | 1747 | /* setup globals */ |
| 1747 | 1748 | apple2gs_cur_slot6_image = NULL; |
| r3635 | r3636 | |
| 1792 | 1793 | /* save state stuff. note that the driver takes care of docram. */ |
| 1793 | 1794 | state_save_register_global_array(mess_ram); |
| 1794 | 1795 | |
| 1795 | | state_save_register_item("NEWVIDEO", 0, apple2gs_newvideo); |
| 1796 | state_save_register_item("NEWVIDEO", NULL, 0, apple2gs_newvideo); |
| 1796 | 1797 | |
| 1797 | | state_save_register_item("VGCINT", 0, apple2gs_vgcint); |
| 1798 | | state_save_register_item("LANGSEL", 0, apple2gs_langsel); |
| 1799 | | state_save_register_item("SLTROMSEL", 0, apple2gs_sltromsel); |
| 1800 | | state_save_register_item("CYAREG", 0, apple2gs_cyareg); |
| 1801 | | state_save_register_item("INTEN", 0, apple2gs_inten); |
| 1802 | | state_save_register_item("INTFLAG", 0, apple2gs_intflag); |
| 1803 | | state_save_register_item("SHADOW", 0, apple2gs_shadow); |
| 1804 | | state_save_register_item("PENDIRQ", 0, apple2gs_pending_irqs); |
| 1805 | | state_save_register_item("MX", 0, apple2gs_mouse_x); |
| 1806 | | state_save_register_item("MY", 0, apple2gs_mouse_y); |
| 1807 | | state_save_register_item("MDX", 0, apple2gs_mouse_dx); |
| 1808 | | state_save_register_item("MDY", 0, apple2gs_mouse_dy); |
| 1798 | state_save_register_item("VGCINT", NULL,0, apple2gs_vgcint); |
| 1799 | state_save_register_item("LANGSEL", NULL,0, apple2gs_langsel); |
| 1800 | state_save_register_item("SLTROMSEL", NULL,0, apple2gs_sltromsel); |
| 1801 | state_save_register_item("CYAREG", NULL,0, apple2gs_cyareg); |
| 1802 | state_save_register_item("INTEN", NULL,0, apple2gs_inten); |
| 1803 | state_save_register_item("INTFLAG", NULL,0, apple2gs_intflag); |
| 1804 | state_save_register_item("SHADOW", NULL,0, apple2gs_shadow); |
| 1805 | state_save_register_item("PENDIRQ", NULL,0, apple2gs_pending_irqs); |
| 1806 | state_save_register_item("MX", NULL,0, apple2gs_mouse_x); |
| 1807 | state_save_register_item("MY", NULL,0, apple2gs_mouse_y); |
| 1808 | state_save_register_item("MDX", NULL,0, apple2gs_mouse_dx); |
| 1809 | state_save_register_item("MDY", NULL,0, apple2gs_mouse_dy); |
| 1809 | 1810 | |
| 1810 | | state_save_register_item("CLKDATA", 0, clock_data); |
| 1811 | | state_save_register_item("CLKCTRL", 0, clock_control); |
| 1812 | | state_save_register_item("CLKRD", 0, clock_read); |
| 1813 | | state_save_register_item("CLKREG1", 0, clock_reg1); |
| 1814 | | state_save_register_item("CLKCURTIME", 0, clock_curtime); |
| 1815 | | state_save_register_item("CLKCURTIMEINT", 0, clock_curtime_interval); |
| 1816 | | state_save_register_item("CLKMODE", 0, clock_mode); |
| 1811 | state_save_register_item("CLKDATA", NULL,0, clock_data); |
| 1812 | state_save_register_item("CLKCTRL", NULL,0, clock_control); |
| 1813 | state_save_register_item("CLKRD", NULL,0, clock_read); |
| 1814 | state_save_register_item("CLKREG1", NULL,0, clock_reg1); |
| 1815 | state_save_register_item("CLKCURTIME", NULL,0, clock_curtime); |
| 1816 | state_save_register_item("CLKCURTIMEINT", NULL,0, clock_curtime_interval); |
| 1817 | state_save_register_item("CLKMODE", NULL,0, clock_mode); |
| 1817 | 1818 | state_save_register_global_array(clock_bram); |
| 1818 | 1819 | |
| 1819 | 1820 | state_save_register_global_array(adb_memory); |
| 1820 | 1821 | state_save_register_global_array(adb_command_bytes); |
| 1821 | 1822 | state_save_register_global_array(adb_response_bytes); |
| 1822 | | state_save_register_item("ADB", 0, adb_state); |
| 1823 | | state_save_register_item("ADB", 0, adb_command); |
| 1824 | | state_save_register_item("ADB", 0, adb_mode); |
| 1825 | | state_save_register_item("ADB", 0, adb_kmstatus); |
| 1826 | | state_save_register_item("ADB", 0, adb_latent_result); |
| 1827 | | state_save_register_item("ADB", 0, adb_command_length); |
| 1828 | | state_save_register_item("ADB", 0, adb_command_pos); |
| 1829 | | state_save_register_item("ADB", 0, adb_response_length); |
| 1830 | | state_save_register_item("ADB", 0, adb_response_pos); |
| 1831 | | state_save_register_item("ADB", 0, adb_address_keyboard); |
| 1832 | | state_save_register_item("ADB", 0, adb_address_mouse); |
| 1823 | state_save_register_item("ADB", NULL,0, adb_state); |
| 1824 | state_save_register_item("ADB", NULL,0, adb_command); |
| 1825 | state_save_register_item("ADB", NULL,0, adb_mode); |
| 1826 | state_save_register_item("ADB", NULL,0, adb_kmstatus); |
| 1827 | state_save_register_item("ADB", NULL,0, adb_latent_result); |
| 1828 | state_save_register_item("ADB", NULL,0, adb_command_length); |
| 1829 | state_save_register_item("ADB", NULL,0, adb_command_pos); |
| 1830 | state_save_register_item("ADB", NULL,0, adb_response_length); |
| 1831 | state_save_register_item("ADB", NULL,0, adb_response_pos); |
| 1832 | state_save_register_item("ADB", NULL,0, adb_address_keyboard); |
| 1833 | state_save_register_item("ADB", NULL,0, adb_address_mouse); |
| 1833 | 1834 | |
| 1834 | | state_save_register_item("SNDGLUCTRL", 0, sndglu_ctrl); |
| 1835 | | state_save_register_item("SNDGLUADDR", 0, sndglu_addr); |
| 1836 | | state_save_register_item("SNDGLUDUMMYRD", 0, sndglu_dummy_read); |
| 1835 | state_save_register_item("SNDGLUCTRL", NULL,0, sndglu_ctrl); |
| 1836 | state_save_register_item("SNDGLUADDR", NULL,0, sndglu_addr); |
| 1837 | state_save_register_item("SNDGLUDUMMYRD", NULL,0, sndglu_dummy_read); |
| 1837 | 1838 | } |
src/mess/machine/mac.c
| r3635 | r3636 | |
| 114 | 114 | static WRITE8_HANDLER(mac_adb_via_out_cb2); |
| 115 | 115 | static WRITE8_HANDLER(mac_via_out_cb2); |
| 116 | 116 | static void mac_via_irq(running_machine *machine, int state); |
| 117 | | static offs_t mac_dasm_override(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); |
| 117 | static offs_t mac_dasm_override(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); |
| 118 | 118 | |
| 119 | 119 | static const struct via6522_interface mac_via6522_intf = |
| 120 | 120 | { |
| r3635 | r3636 | |
| 182 | 182 | static void mac_install_memory(running_machine *machine, offs_t memory_begin, offs_t memory_end, |
| 183 | 183 | offs_t memory_size, void *memory_data, int is_rom, int bank) |
| 184 | 184 | { |
| 185 | const address_space* space = cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM); |
| 185 | 186 | offs_t memory_mask; |
| 186 | | read16_machine_func rh; |
| 187 | | write16_machine_func wh; |
| 187 | read16_space_func rh; |
| 188 | write16_space_func wh; |
| 188 | 189 | |
| 189 | 190 | memory_size = MIN(memory_size, (memory_end + 1 - memory_begin)); |
| 190 | 191 | memory_mask = memory_size - 1; |
| 191 | 192 | |
| 192 | | rh = (read16_machine_func) (FPTR)bank; |
| 193 | | wh = is_rom ? SMH_UNMAP : (write16_machine_func) (FPTR)bank; |
| 193 | rh = (read16_space_func) (FPTR)bank; |
| 194 | wh = is_rom ? SMH_UNMAP : (write16_space_func) (FPTR)bank; |
| 194 | 195 | |
| 195 | | memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, memory_begin, |
| 196 | memory_install_read16_handler(space, memory_begin, |
| 196 | 197 | memory_end, memory_mask, 0, rh); |
| 197 | | memory_install_write16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, memory_begin, |
| 198 | memory_install_write16_handler(space, memory_begin, |
| 198 | 199 | memory_end, memory_mask, 0, wh); |
| 199 | 200 | |
| 200 | | memory_set_bankptr(bank, memory_data); |
| 201 | memory_set_bankptr(machine,bank, memory_data); |
| 201 | 202 | |
| 202 | 203 | if (LOG_MEMORY) |
| 203 | 204 | { |
| r3635 | r3636 | |
| 783 | 784 | reg = R5380_CURDATA_DTACK; |
| 784 | 785 | } |
| 785 | 786 | |
| 786 | | return ncr5380_r(machine, reg)<<8; |
| 787 | return ncr5380_r(space, reg)<<8; |
| 787 | 788 | } |
| 788 | 789 | |
| 789 | 790 | WRITE16_HANDLER ( macplus_scsi_w ) |
| r3635 | r3636 | |
| 795 | 796 | reg = R5380_OUTDATA_DTACK; |
| 796 | 797 | } |
| 797 | 798 | |
| 798 | | ncr5380_w(machine, reg, data); |
| 799 | ncr5380_w(space, reg, data); |
| 799 | 800 | } |
| 800 | 801 | |
| 801 | 802 | static void mac_scsi_irq(running_machine *machine, int state) |
| r3635 | r3636 | |
| 850 | 851 | |
| 851 | 852 | READ16_HANDLER ( mac_scc_r ) |
| 852 | 853 | { |
| 853 | | const device_config *scc = device_list_find_by_tag(machine->config->devicelist, SCC8530, "scc"); |
| 854 | const device_config *scc = device_list_find_by_tag(space->machine->config->devicelist, SCC8530, "scc"); |
| 854 | 855 | UINT16 result; |
| 855 | 856 | |
| 856 | 857 | result = scc_r(scc, offset); |
| r3635 | r3636 | |
| 861 | 862 | |
| 862 | 863 | WRITE16_HANDLER ( mac_scc_w ) |
| 863 | 864 | { |
| 864 | | const device_config *scc = device_list_find_by_tag(machine->config->devicelist, SCC8530, "scc"); |
| 865 | const device_config *scc = device_list_find_by_tag(space->machine->config->devicelist, SCC8530, "scc"); |
| 865 | 866 | scc_w(scc, offset, (UINT8) data); |
| 866 | 867 | } |
| 867 | 868 | |
| r3635 | r3636 | |
| 1217 | 1218 | */ |
| 1218 | 1219 | |
| 1219 | 1220 | UINT16 result = 0; |
| 1220 | | const device_config *fdc = device_list_find_by_tag(machine->config->devicelist, |
| 1221 | const device_config *fdc = device_list_find_by_tag(space->machine->config->devicelist, |
| 1221 | 1222 | IWM, |
| 1222 | 1223 | "fdc"); |
| 1223 | 1224 | |
| r3635 | r3636 | |
| 1230 | 1231 | |
| 1231 | 1232 | WRITE16_HANDLER ( mac_iwm_w ) |
| 1232 | 1233 | { |
| 1233 | | const device_config *fdc = device_list_find_by_tag(machine->config->devicelist, |
| 1234 | const device_config *fdc = device_list_find_by_tag(space->machine->config->devicelist, |
| 1234 | 1235 | IWM, |
| 1235 | 1236 | "fdc"); |
| 1236 | 1237 | |
| r3635 | r3636 | |
| 1542 | 1543 | int val = 0; |
| 1543 | 1544 | |
| 1544 | 1545 | /* video beam in display (! VBLANK && ! HBLANK basically) */ |
| 1545 | | if (video_screen_get_vpos(machine->primary_screen) >= MAC_V_VIS) |
| 1546 | if (video_screen_get_vpos(space->machine->primary_screen) >= MAC_V_VIS) |
| 1546 | 1547 | val |= 0x40; |
| 1547 | 1548 | |
| 1548 | 1549 | if (has_adb()) |
| r3635 | r3636 | |
| 1560 | 1561 | val |= 0x20; |
| 1561 | 1562 | if (mouse_bit_x) /* Mouse X2 */ |
| 1562 | 1563 | val |= 0x10; |
| 1563 | | if ((input_port_read(machine, "MOUSE0") & 0x01) == 0) |
| 1564 | if ((input_port_read(space->machine, "MOUSE0") & 0x01) == 0) |
| 1564 | 1565 | val |= 0x08; |
| 1565 | 1566 | } |
| 1566 | 1567 | if (rtc_data_out) |
| r3635 | r3636 | |
| 1589 | 1590 | * possibly later models), overlay was set on reset, but cleared on the |
| 1590 | 1591 | * first access to the ROM. */ |
| 1591 | 1592 | if (mac_model < MODEL_MAC_SE) |
| 1592 | | set_memory_overlay(machine, (data & 0x10) >> 4); |
| 1593 | set_memory_overlay(space->machine, (data & 0x10) >> 4); |
| 1593 | 1594 | } |
| 1594 | 1595 | |
| 1595 | 1596 | static WRITE8_HANDLER(mac_via_out_b) |
| r3635 | r3636 | |
| 1632 | 1633 | |
| 1633 | 1634 | if (LOG_VIA) |
| 1634 | 1635 | logerror("mac_via_r: offset=0x%02x\n", offset); |
| 1635 | | data = via_0_r(machine, offset); |
| 1636 | data = via_0_r(space, offset); |
| 1636 | 1637 | |
| 1637 | 1638 | return (data & 0xff) | (data << 8); |
| 1638 | 1639 | } |
| r3635 | r3636 | |
| 1646 | 1647 | logerror("mac_via_w: offset=0x%02x data=0x%08x\n", offset, data); |
| 1647 | 1648 | |
| 1648 | 1649 | if (ACCESSING_BITS_8_15) |
| 1649 | | via_0_w(machine, offset, (data >> 8) & 0xff); |
| 1650 | via_0_w(space, offset, (data >> 8) & 0xff); |
| 1650 | 1651 | } |
| 1651 | 1652 | |
| 1652 | 1653 | |
| r3635 | r3636 | |
| 1712 | 1713 | { |
| 1713 | 1714 | if ((address >= 0x400000) && (address <= 0x4fffff)) |
| 1714 | 1715 | { |
| 1715 | | set_memory_overlay(machine, 0); // kill the overlay |
| 1716 | set_memory_overlay(space->machine, 0); // kill the overlay |
| 1716 | 1717 | mac_overlay = -1; |
| 1717 | 1718 | } |
| 1718 | 1719 | } |
| r3635 | r3636 | |
| 1740 | 1741 | // classic will fail RAM test and try to boot appletalk if RAM is not all zero |
| 1741 | 1742 | memset(mess_ram, 0, mess_ram_size); |
| 1742 | 1743 | |
| 1743 | | memory_set_direct_update_handler(0, overlay_opbaseoverride); |
| 1744 | memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM), overlay_opbaseoverride); |
| 1744 | 1745 | mac_overlay = 1; |
| 1745 | 1746 | } |
| 1746 | 1747 | |
| r3635 | r3636 | |
| 1760 | 1761 | |
| 1761 | 1762 | inquiry_timeout = timer_alloc(inquiry_timeout_func, NULL); |
| 1762 | 1763 | |
| 1763 | | cpuintrf_set_dasm_override(0, mac_dasm_override); |
| 1764 | cpu_set_dasm_override(machine->cpu[0], mac_dasm_override); |
| 1764 | 1765 | |
| 1765 | 1766 | /* save state stuff */ |
| 1766 | 1767 | state_save_register_global(mac_overlay); |
| r3635 | r3636 | |
| 1863 | 1864 | { |
| 1864 | 1865 | int scanline; |
| 1865 | 1866 | |
| 1866 | | cpuintrf_push_context(0); |
| 1867 | cpu_push_context(machine->cpu[0]); |
| 1867 | 1868 | |
| 1868 | 1869 | mac_sh_updatebuffer(); |
| 1869 | 1870 | |
| r3635 | r3636 | |
| 1877 | 1878 | |
| 1878 | 1879 | timer_adjust_oneshot(mac_scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, (scanline+1) % MAC_V_TOTAL, 0), 0); |
| 1879 | 1880 | |
| 1880 | | cpuintrf_pop_context(); |
| 1881 | cpu_pop_context(); |
| 1881 | 1882 | } |
| 1882 | 1883 | |
| 1883 | 1884 | |
| r3635 | r3636 | |
| 2708 | 2709 | |
| 2709 | 2710 | |
| 2710 | 2711 | |
| 2711 | | static offs_t mac_dasm_override(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) |
| 2712 | static offs_t mac_dasm_override(const device_config *device, char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram) |
| 2712 | 2713 | { |
| 2713 | 2714 | UINT16 opcode; |
| 2714 | 2715 | unsigned result = 0; |
src/mess/machine/lisa.c
| r3635 | r3636 | |
| 222 | 222 | |
| 223 | 223 | /*if (RSIR) |
| 224 | 224 | // serial interrupt |
| 225 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_6, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 225 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_6, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 226 | 226 | else if (int0) |
| 227 | 227 | // external interrupt |
| 228 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_5, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 228 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_5, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 229 | 229 | else if (int1) |
| 230 | 230 | // external interrupt |
| 231 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_4, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 231 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_4, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 232 | 232 | else if (int2) |
| 233 | 233 | // external interrupt |
| 234 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 234 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 235 | 235 | else*/ if (KBIR) |
| 236 | 236 | /* COPS VIA interrupt */ |
| 237 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 237 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 238 | 238 | else if (FDIR || VTIR) |
| 239 | 239 | /* floppy disk or VBl */ |
| 240 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 240 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 241 | 241 | else |
| 242 | 242 | /* clear all interrupts */ |
| 243 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 243 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | static void set_parity_error_pending(running_machine *machine, int value) |
| r3635 | r3636 | |
| 250 | 250 | parity_error_pending = value; |
| 251 | 251 | if (parity_error_pending) |
| 252 | 252 | { |
| 253 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 253 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 254 | 254 | } |
| 255 | 255 | else |
| 256 | 256 | { |
| r3635 | r3636 | |
| 261 | 261 | if ((! parity_error_pending) && value) |
| 262 | 262 | { |
| 263 | 263 | parity_error_pending = 1; |
| 264 | | cpunum_set_input_line_and_vector(machine, 0, M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 264 | cpu_set_input_line_and_vector(machine->cpu[0], M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR); |
| 265 | 265 | } |
| 266 | 266 | else if (parity_error_pending && (! value)) |
| 267 | 267 | { |
| r3635 | r3636 | |
| 781 | 781 | /*logerror("COPS CA2 line state : %d\n", val);*/ |
| 782 | 782 | |
| 783 | 783 | /*logerror("COPS_via_out_ca2 : trying to send data to VIA\n");*/ |
| 784 | | COPS_send_data_if_possible(machine); |
| 784 | COPS_send_data_if_possible(space->machine); |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | /* |
| r3635 | r3636 | |
| 814 | 814 | static WRITE8_HANDLER(COPS_via_out_b) |
| 815 | 815 | { |
| 816 | 816 | /* pull-up */ |
| 817 | | data |= (~ via_read(machine, 0, VIA_DDRA)) & 0x01; |
| 817 | data |= (~ via_read(space->machine, 0, VIA_DDRA)) & 0x01; |
| 818 | 818 | |
| 819 | 819 | if (data & 0x01) |
| 820 | 820 | { |
| 821 | 821 | if (COPS_force_unplug) |
| 822 | 822 | { |
| 823 | 823 | COPS_force_unplug = 0; |
| 824 | | plug_keyboard(machine); |
| 824 | plug_keyboard(space->machine); |
| 825 | 825 | } |
| 826 | 826 | } |
| 827 | 827 | else |
| r3635 | r3636 | |
| 829 | 829 | if (! COPS_force_unplug) |
| 830 | 830 | { |
| 831 | 831 | COPS_force_unplug = 1; |
| 832 | | unplug_keyboard(machine); |
| 832 | unplug_keyboard(space->machine); |
| 833 | 833 | //reset_COPS(); |
| 834 | 834 | } |
| 835 | 835 | } |
| r3635 | r3636 | |
| 949 | 949 | } |
| 950 | 950 | else |
| 951 | 951 | { /* system ROMs */ |
| 952 | | opbase->mask = 0xffffff; |
| 952 | direct->mask = 0xffffff; |
| 953 | 953 | direct->raw = direct->decrypted = lisa_rom_ptr - (address & 0xffc000); |
| 954 | | opbase->mem_min = (address & 0xffc000); |
| 955 | | opbase->mem_max = (address & 0xffc000) + 0x003fff; |
| 954 | direct->min = (address & 0xffc000); |
| 955 | direct->max = (address & 0xffc000) + 0x003fff; |
| 956 | 956 | /*logerror("ROM (setup mode)\n");*/ |
| 957 | 957 | } |
| 958 | 958 | |
| r3635 | r3636 | |
| 961 | 961 | |
| 962 | 962 | } |
| 963 | 963 | |
| 964 | | if (cpunum_get_reg(0, M68K_SR) & 0x2000) |
| 964 | if (cpu_get_reg(space->machine->cpu[0], M68K_SR) & 0x2000) |
| 965 | 965 | /* supervisor mode -> force register file 0 */ |
| 966 | 966 | the_seg = 0; |
| 967 | 967 | |
| r3635 | r3636 | |
| 981 | 981 | /* out of segment limits : bus error */ |
| 982 | 982 | logerror("illegal opbase address%lX\n", (long) address); |
| 983 | 983 | } |
| 984 | | opbase->mask = 0xffffff; |
| 984 | direct->mask = 0xffffff; |
| 985 | 985 | direct->raw = direct->decrypted = lisa_ram_ptr + mapped_address - address; |
| 986 | | opbase->mem_min = (address & 0xffc000); |
| 987 | | opbase->mem_max = (address & 0xffc000) + 0x003fff; |
| 986 | direct->min = (address & 0xffc000); |
| 987 | direct->max = (address & 0xffc000) + 0x003fff; |
| 988 | 988 | /*logerror("RAM\n");*/ |
| 989 | 989 | break; |
| 990 | 990 | |
| r3635 | r3636 | |
| 997 | 997 | break; |
| 998 | 998 | |
| 999 | 999 | case special_IO: |
| 1000 | | opbase->mask = 0xffffff; |
| 1000 | direct->mask = 0xffffff; |
| 1001 | 1001 | direct->raw = direct->decrypted = lisa_rom_ptr + (mapped_address & 0x003fff) - address; |
| 1002 | | opbase->mem_min = (address & 0xffc000); |
| 1003 | | opbase->mem_max = (address & 0xffc000) + 0x003fff; |
| 1002 | direct->min = (address & 0xffc000); |
| 1003 | direct->max = (address & 0xffc000) + 0x003fff; |
| 1004 | 1004 | /*logerror("ROM\n");*/ |
| 1005 | 1005 | break; |
| 1006 | 1006 | } |
| r3635 | r3636 | |
| 1125 | 1125 | |
| 1126 | 1126 | videoROM_ptr = memory_region(machine, "gfx1"); |
| 1127 | 1127 | |
| 1128 | | memory_set_direct_update_handler(0, lisa_OPbaseoverride); |
| 1129 | | memory_set_direct_update_handler(1, lisa_fdc_OPbaseoverride); |
| 1128 | memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM), lisa_OPbaseoverride); |
| 1129 | memory_set_direct_update_handler(cpu_get_address_space(machine->cpu[1],ADDRESS_SPACE_PROGRAM), lisa_fdc_OPbaseoverride); |
| 1130 | 1130 | |
| 1131 | | cpunum_set_info_fct(0, CPUINFO_PTR_M68K_RESET_CALLBACK, (genf *)/*lisa_reset_instr_callback*/NULL); |
| 1131 | cpu_set_info_fct(machine->cpu[0], CPUINFO_PTR_M68K_RESET_CALLBACK, (genf *)/*lisa_reset_instr_callback*/NULL); |
| 1132 | 1132 | |
| 1133 | 1133 | /* init MMU */ |
| 1134 | 1134 | |
| r3635 | r3636 | |
| 1163 | 1163 | via_set_clock(1, lisa_features.has_fast_timers ? 1250000 : 500000); /* one of these values must be wrong : see note after description of the has_fast_timers field */ |
| 1164 | 1164 | |
| 1165 | 1165 | via_reset(); |
| 1166 | | COPS_via_out_ca2(machine, 0, 0); /* VIA core forgets to do so */ |
| 1166 | COPS_via_out_ca2(cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM), 0, 0); /* VIA core forgets to do so */ |
| 1167 | 1167 | |
| 1168 | 1168 | /* initialize floppy */ |
| 1169 | 1169 | { |
| r3635 | r3636 | |
| 1196 | 1196 | 0x80, /* RESET code */ |
| 1197 | 1197 | 0xFC /* timer time-out */ |
| 1198 | 1198 | }; |
| 1199 | | COPS_queue_data(machine, cmd, 2); |
| 1199 | COPS_queue_data(device->machine, cmd, 2); |
| 1200 | 1200 | |
| 1201 | 1201 | clock_regs.alarm = 0xfffffL; |
| 1202 | 1202 | } |
| r3635 | r3636 | |
| 1263 | 1263 | |
| 1264 | 1264 | /* set VBI */ |
| 1265 | 1265 | if (VTMSK) |
| 1266 | | set_VTIR(machine, 1); |
| 1266 | set_VTIR(device->machine, 1); |
| 1267 | 1267 | else |
| 1268 | | set_VTIR(machine, 0); |
| 1268 | set_VTIR(device->machine, 0); |
| 1269 | 1269 | |
| 1270 | 1270 | /* do keyboard scan */ |
| 1271 | | scan_keyboard(machine); |
| 1271 | scan_keyboard(device->machine); |
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | 1274 | /* |
| r3635 | r3636 | |
| 1334 | 1334 | READ8_HANDLER ( lisa_fdc_io_r ) |
| 1335 | 1335 | { |
| 1336 | 1336 | int answer=0; |
| 1337 | | const device_config *fdc = device_list_find_by_tag(machine->config->devicelist, |
| 1337 | const device_config *fdc = device_list_find_by_tag(space->machine->config->devicelist, |
| 1338 | 1338 | IWM, |
| 1339 | 1339 | "fdc"); |
| 1340 | 1340 | |
| r3635 | r3636 | |
| 1345 | 1345 | break; |
| 1346 | 1346 | |
| 1347 | 1347 | case 1: /* TTL glue */ |
| 1348 | | lisa_fdc_ttl_glue_access(machine, offset); |
| 1348 | lisa_fdc_ttl_glue_access(space->machine, offset); |
| 1349 | 1349 | answer = 0; /* ??? */ |
| 1350 | 1350 | break; |
| 1351 | 1351 | |
| r3635 | r3636 | |
| 1363 | 1363 | |
| 1364 | 1364 | WRITE8_HANDLER ( lisa_fdc_io_w ) |
| 1365 | 1365 | { |
| 1366 | | const device_config *fdc = device_list_find_by_tag(machine->config->devicelist, |
| 1366 | const device_config *fdc = device_list_find_by_tag(space->machine->config->devicelist, |
| 1367 | 1367 | IWM, |
| 1368 | 1368 | "fdc"); |
| 1369 | 1369 | |
| r3635 | r3636 | |
| 1374 | 1374 | break; |
| 1375 | 1375 | |
| 1376 | 1376 | case 1: /* TTL glue */ |
| 1377 | | lisa_fdc_ttl_glue_access(machine, offset); |
| 1377 | lisa_fdc_ttl_glue_access(space->machine, offset); |
| 1378 | 1378 | break; |
| 1379 | 1379 | |
| 1380 | 1380 | case 2: /* writes the PWM register */ |
| r3635 | r3636 | |
| 1398 | 1398 | if (! (offset & 0x0400)) |
| 1399 | 1399 | return lisa_fdc_ram[offset & 0x03ff]; |
| 1400 | 1400 | else |
| 1401 | | return lisa_fdc_io_r(machine, offset & 0x03ff); |
| 1401 | return lisa_fdc_io_r(space, offset & 0x03ff); |
| 1402 | 1402 | else |
| 1403 | 1403 | return 0; /* ??? */ |
| 1404 | 1404 | } |
| r3635 | r3636 | |
| 1414 | 1414 | if (! (offset & 0x0800)) |
| 1415 | 1415 | return lisa_fdc_ram[offset & 0x03ff]; |
| 1416 | 1416 | else |
| 1417 | | return lisa_fdc_io_r(machine, offset & 0x03ff); |
| 1417 | return lisa_fdc_io_r(space, offset & 0x03ff); |
| 1418 | 1418 | else |
| 1419 | 1419 | return 0; /* ??? */ |
| 1420 | 1420 | } |
| r3635 | r3636 | |
| 1431 | 1431 | if (! (offset & 0x0400)) |
| 1432 | 1432 | lisa_fdc_ram[offset & 0x03ff] = data; |
| 1433 | 1433 | else |
| 1434 | | lisa_fdc_io_w(machine, offset & 0x03ff, data); |
| 1434 | lisa_fdc_io_w(space, offset & 0x03ff, data); |
| 1435 | 1435 | } |
| 1436 | 1436 | } |
| 1437 | 1437 | } |
| r3635 | r3636 | |
| 1445 | 1445 | if (! (offset & 0x0800)) |
| 1446 | 1446 | lisa_fdc_ram[offset & 0x03ff] = data; |
| 1447 | 1447 | else |
| 1448 | | lisa_fdc_io_w(machine, offset & 0x03ff, data); |
| 1448 | lisa_fdc_io_w(space, offset & 0x03ff, data); |
| 1449 | 1449 | } |
| 1450 | 1450 | } |
| 1451 | 1451 | } |
| r3635 | r3636 | |
| 1496 | 1496 | } |
| 1497 | 1497 | } |
| 1498 | 1498 | |
| 1499 | | if (cpunum_get_reg(0, M68K_SR) & 0x2000) |
| 1499 | if (cpu_get_reg(space->machine->cpu[0], M68K_SR) & 0x2000) |
| 1500 | 1500 | /* supervisor mode -> force register file 0 */ |
| 1501 | 1501 | the_seg = 0; |
| 1502 | 1502 | |
| r3635 | r3636 | |
| 1526 | 1526 | && (bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))) |
| 1527 | 1527 | { |
| 1528 | 1528 | mem_err_addr_latch = address >> 5; |
| 1529 | | set_parity_error_pending(machine, 1); |
| 1529 | set_parity_error_pending(space->machine, 1); |
| 1530 | 1530 | } |
| 1531 | 1531 | break; |
| 1532 | 1532 | |
| r3635 | r3636 | |
| 1543 | 1543 | && (bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))) |
| 1544 | 1544 | { |
| 1545 | 1545 | mem_err_addr_latch = address >> 5; |
| 1546 | | set_parity_error_pending(machine, 1); |
| 1546 | set_parity_error_pending(space->machine, 1); |
| 1547 | 1547 | } |
| 1548 | 1548 | break; |
| 1549 | 1549 | |
| 1550 | 1550 | case IO: |
| 1551 | | answer = lisa_IO_r(machine, (address & 0x00ffff) >> 1, mem_mask); |
| 1551 | answer = lisa_IO_r(space, (address & 0x00ffff) >> 1, mem_mask); |
| 1552 | 1552 | break; |
| 1553 | 1553 | |
| 1554 | 1554 | case invalid: /* unmapped segment */ |
| r3635 | r3636 | |
| 1568 | 1568 | /* problem : due to collisions with video, timings of the LISA CPU |
| 1569 | 1569 | are slightly different from timings of a bare 68k */ |
| 1570 | 1570 | /* so we use a kludge... */ |
| 1571 | | int time_in_frame = video_screen_get_vpos(machine->primary_screen); |
| 1571 | int time_in_frame = video_screen_get_vpos(space->machine->primary_screen); |
| 1572 | 1572 | static int videoROM_address = 0; |
| 1573 | 1573 | |
| 1574 | 1574 | /* the BOOT ROM only reads 56 bits, so there must be some wrap-around for |
| r3635 | r3636 | |
| 1596 | 1596 | if ((time_in_frame >= 364) && (time_in_frame <= 375)) |
| 1597 | 1597 | { |
| 1598 | 1598 | answer = videoROM_ptr[videoROM_address|0x80] << 8; |
| 1599 | | logerror("reading1 %06X=%04x PC=%06x time=%d\n", address, answer,safe_activecpu_get_pc(),time_in_frame); |
| 1599 | logerror("reading1 %06X=%04x PC=%06x time=%d\n", address, answer,safe_cpu_get_pc(space->machine->cpu[0]),time_in_frame); |
| 1600 | 1600 | } |
| 1601 | 1601 | else |
| 1602 | 1602 | { |
| 1603 | 1603 | answer = videoROM_ptr[videoROM_address] << 8; |
| 1604 | | logerror("reading2 %06X=%04x PC=%06x time=%d\n", address, answer,safe_activecpu_get_pc(),time_in_frame); |
| 1604 | logerror("reading2 %06X=%04x PC=%06x time=%d\n", address, answer,safe_cpu_get_pc(space->machine->cpu[0]),time_in_frame); |
| 1605 | 1605 | } |
| 1606 | 1606 | } |
| 1607 | 1607 | |
| r3635 | r3636 | |
| 1699 | 1699 | } |
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | | if (cpunum_get_reg(0, M68K_SR) & 0x2000) |
| 1702 | if (cpu_get_reg(space->machine->cpu[0], M68K_SR) & 0x2000) |
| 1703 | 1703 | /* supervisor mode -> force register file 0 */ |
| 1704 | 1704 | the_seg = 0; |
| 1705 | 1705 | |
| r3635 | r3636 | |
| 1792 | 1792 | break; |
| 1793 | 1793 | |
| 1794 | 1794 | case IO: |
| 1795 | | lisa_IO_w(machine, (address & 0x00ffff) >> 1, data, mem_mask); |
| 1795 | lisa_IO_w(space, (address & 0x00ffff) >> 1, data, mem_mask); |
| 1796 | 1796 | break; |
| 1797 | 1797 | |
| 1798 | 1798 | case RAM_stack_r: /* read-only */ |
| r3635 | r3636 | |
| 1861 | 1861 | seg &= ~2; |
| 1862 | 1862 | break; |
| 1863 | 1863 | case 0x0010: /* SETUP register SET */ |
| 1864 | | logerror("setup SET PC=%x\n", safe_activecpu_get_pc()); |
| 1864 | logerror("setup SET PC=%x\n", safe_cpu_get_pc(machine->cpu[0])); |
| 1865 | 1865 | setup = 1; |
| 1866 | 1866 | break; |
| 1867 | 1867 | case 0x0012: /* SETUP register RESET */ |
| 1868 | | logerror("setup UNSET PC=%x\n", safe_activecpu_get_pc()); |
| 1868 | logerror("setup UNSET PC=%x\n", safe_cpu_get_pc(machine->cpu[0])); |
| 1869 | 1869 | setup = 0; |
| 1870 | 1870 | break; |
| 1871 | 1871 | case 0x001A: /* Enable Vertical Retrace Interrupt */ |
| 1872 | | logerror("enable retrace PC=%x\n", safe_activecpu_get_pc()); |
| 1872 | logerror("enable retrace PC=%x\n", safe_cpu_get_pc(machine->cpu[0])); |
| 1873 | 1873 | VTMSK = 1; |
| 1874 | 1874 | break; |
| 1875 | 1875 | case 0x0018: /* Disable Vertical Retrace Interrupt */ |
| 1876 | | logerror("disable retrace PC=%x\n", safe_activecpu_get_pc()); |
| 1876 | logerror("disable retrace PC=%x\n", safe_cpu_get_pc(machine->cpu[0])); |
| 1877 | 1877 | VTMSK = 0; |
| 1878 | 1878 | set_VTIR(machine, 2); |
| 1879 | 1879 | break; |
| r3635 | r3636 | |
| 1943 | 1943 | case 2: /* parallel port */ |
| 1944 | 1944 | /* 1 VIA located at 0xD901 */ |
| 1945 | 1945 | if (ACCESSING_BITS_0_7) |
| 1946 | | return via_read(machine, 1, (offset >> 2) & 0xf); |
| 1946 | return via_read(space->machine, 1, (offset >> 2) & 0xf); |
| 1947 | 1947 | break; |
| 1948 | 1948 | |
| 1949 | 1949 | case 3: /* keyboard/mouse cops via */ |
| 1950 | 1950 | /* 1 VIA located at 0xDD81 */ |
| 1951 | 1951 | if (ACCESSING_BITS_0_7) |
| 1952 | | return via_read(machine, 0, offset & 0xf); |
| 1952 | return via_read(space->machine, 0, offset & 0xf); |
| 1953 | 1953 | break; |
| 1954 | 1954 | } |
| 1955 | 1955 | } |
| r3635 | r3636 | |
| 1960 | 1960 | switch ((offset & 0x0C00) >> 10) |
| 1961 | 1961 | { |
| 1962 | 1962 | case 0x0: /* cpu board control */ |
| 1963 | | cpu_board_control_access(machine, offset & 0x03ff); |
| 1963 | cpu_board_control_access(space->machine, offset & 0x03ff); |
| 1964 | 1964 | break; |
| 1965 | 1965 | |
| 1966 | 1966 | case 0x1: /* Video Address Latch */ |
| r3635 | r3636 | |
| 1978 | 1978 | if (VTIR<=1) |
| 1979 | 1979 | // GFE : needs to be in phase with Serial NUM |
| 1980 | 1980 | { |
| 1981 | | int time_in_frame = video_screen_get_vpos(machine->primary_screen); |
| 1981 | int time_in_frame = video_screen_get_vpos(space->machine->primary_screen); |
| 1982 | 1982 | if (lisa_features.has_mac_xl_video) |
| 1983 | 1983 | { |
| 1984 | 1984 | if ((time_in_frame >= 374) && (time_in_frame <= 392)) /* these values have not been tested */ |
| r3635 | r3636 | |
| 2007 | 2007 | else |
| 2008 | 2008 | answer |= 0x04; |
| 2009 | 2009 | /* huh... we need to emulate some other bits */ |
| 2010 | | logerror("read status PC=%x val=%x\n", safe_activecpu_get_pc(),answer); |
| 2010 | logerror("read status PC=%x val=%x\n", safe_cpu_get_pc(space->machine->cpu[0]),answer); |
| 2011 | 2011 | |
| 2012 | 2012 | break; |
| 2013 | 2013 | } |
| r3635 | r3636 | |
| 2065 | 2065 | |
| 2066 | 2066 | case 2: /* paralel port */ |
| 2067 | 2067 | if (ACCESSING_BITS_0_7) |
| 2068 | | via_write(machine, 1, (offset >> 2) & 0xf, data & 0xff); |
| 2068 | via_write(space->machine, 1, (offset >> 2) & 0xf, data & 0xff); |
| 2069 | 2069 | break; |
| 2070 | 2070 | |
| 2071 | 2071 | case 3: /* keyboard/mouse cops via */ |
| 2072 | 2072 | if (ACCESSING_BITS_0_7) |
| 2073 | | via_write(machine, 0, offset & 0xf, data & 0xff); |
| 2073 | via_write(space->machine, 0, offset & 0xf, data & 0xff); |
| 2074 | 2074 | break; |
| 2075 | 2075 | } |
| 2076 | 2076 | } |
| r3635 | r3636 | |
| 2081 | 2081 | switch ((offset & 0x0C00) >> 10) |
| 2082 | 2082 | { |
| 2083 | 2083 | case 0x0: /* cpu board control */ |
| 2084 | | cpu_board_control_access(machine, offset & 0x03ff); |
| 2084 | cpu_board_control_access(space->machine, offset & 0x03ff); |
| 2085 | 2085 | break; |
| 2086 | 2086 | |
| 2087 | 2087 | case 0x1: /* Video Address Latch */ |
src/mess/machine/apple2.c
| r3635 | r3636 | |
| 101 | 101 | |
| 102 | 102 | void apple2_update_memory(running_machine *machine) |
| 103 | 103 | { |
| 104 | const address_space* space = cpu_get_address_space(machine->cpu[0],ADDRESS_SPACE_PROGRAM); |
| 104 | 105 | int i, bank, rbank, wbank; |
| 105 | 106 | int full_update = 0; |
| 106 | 107 | apple2_meminfo meminfo; |
| 107 | | read8_machine_func rh; |
| 108 | | write8_machine_func wh; |
| 108 | read8_space_func rh; |
| 109 | write8_space_func wh; |
| 109 | 110 | offs_t begin, end_r, end_w; |
| 110 | 111 | UINT8 *rbase, *wbase, *rom, *slot_ram; |
| 111 | 112 | UINT32 rom_length, slot_length, offset; |
| r3635 | r3636 | |
| 145 | 146 | rbank = (bank_disposition != A2MEM_IO) ? bank : 0; |
| 146 | 147 | begin = apple2_mem_config.memmap[i].begin; |
| 147 | 148 | end_r = apple2_mem_config.memmap[i].end; |
| 148 | | rh = (read8_machine_func) (STATIC_BANK1 + (FPTR)(rbank - 1)); |
| 149 | rh = (read8_space_func) (STATIC_BANK1 + (FPTR)(rbank - 1)); |
| 149 | 150 | |
| 150 | 151 | LOG(("apple2_update_memory(): Updating RD {%06X..%06X} [#%02d] --> %08X\n", |
| 151 | 152 | begin, end_r, rbank, meminfo.read_mem)); |
| r3635 | r3636 | |
| 194 | 195 | |
| 195 | 196 | /* install the actual handlers */ |
| 196 | 197 | if (begin <= end_r) |
| 197 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, begin, end_r, 0, 0, rh); |
| 198 | memory_install_read8_handler(space, begin, end_r, 0, 0, rh); |
| 198 | 199 | |
| 199 | 200 | /* did we 'go past the end?' */ |
| 200 | 201 | if (end_r < apple2_mem_config.memmap[i].end) |
| 201 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, end_r + 1, apple2_mem_config.memmap[i].end, 0, 0, SMH_NOP); |
| 202 | memory_install_read8_handler(space, end_r + 1, apple2_mem_config.memmap[i].end, 0, 0, SMH_NOP); |
| 202 | 203 | |
| 203 | 204 | /* set the memory bank */ |
| 204 | 205 | if (rbase) |
| 205 | 206 | { |
| 206 | | memory_set_bankptr(rbank, rbase); |
| 207 | memory_set_bankptr(machine, rbank, rbase); |
| 207 | 208 | } |
| 208 | 209 | |
| 209 | 210 | /* record the current settings */ |
| r3635 | r3636 | |
| 225 | 226 | wbank = 0; |
| 226 | 227 | begin = apple2_mem_config.memmap[i].begin; |
| 227 | 228 | end_w = apple2_mem_config.memmap[i].end; |
| 228 | | wh = (write8_machine_func) (STATIC_BANK1 + (FPTR)(wbank - 1)); |
| 229 | wh = (write8_space_func) (STATIC_BANK1 + (FPTR)(wbank - 1)); |
| 229 | 230 | |
| 230 | 231 | LOG(("apple2_update_memory(): Updating WR {%06X..%06X} [#%02d] --> %08X\n", |
| 231 | 232 | begin, end_w, wbank, meminfo.write_mem)); |
| r3635 | r3636 | |
| 269 | 270 | |
| 270 | 271 | /* install the actual handlers */ |
| 271 | 272 | if (begin <= end_w) |
| 272 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, begin, end_w, 0, 0, wh); |
| 273 | memory_install_write8_handler(space, begin, end_w, 0, 0, wh); |
| 273 | 274 | |
| 274 | 275 | /* did we 'go past the end?' */ |
| 275 | 276 | if (end_w < apple2_mem_config.memmap[i].end) |
| 276 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, end_w + 1, apple2_mem_config.memmap[i].end, 0, 0, SMH_NOP); |
| 277 | memory_install_write8_handler(space, end_w + 1, apple2_mem_config.memmap[i].end, 0, 0, SMH_NOP); |
| 277 | 278 | |
| 278 | 279 | /* set the memory bank */ |
| 279 | 280 | if (wbase) |
| 280 | 281 | { |
| 281 | | memory_set_bankptr(wbank, wbase); |
| 282 | memory_set_bankptr(machine, wbank, wbase); |
| 282 | 283 | } |
| 283 | 284 | |
| 284 | 285 | /* record the current settings */ |
| r3635 | r3636 | |
| 304 | 305 | |
| 305 | 306 | READ8_HANDLER(apple2_c0xx_r) |
| 306 | 307 | { |
| 307 | | static const read8_machine_func handlers[] = |
| 308 | static const read8_space_func handlers[] = |
| 308 | 309 | { |
| 309 | 310 | apple2_c00x_r, |
| 310 | 311 | apple2_c01x_r, |
| r3635 | r3636 | |
| 325 | 326 | { |
| 326 | 327 | /* normal handler */ |
| 327 | 328 | if (handlers[offset / 0x10]) |
| 328 | | result = handlers[offset / 0x10](machine, offset % 0x10); |
| 329 | result = handlers[offset / 0x10](space, offset % 0x10); |
| 329 | 330 | } |
| 330 | 331 | else |
| 331 | 332 | { |
| r3635 | r3636 | |
| 333 | 334 | slotnum = (offset - 0x80) / 0x10; |
| 334 | 335 | |
| 335 | 336 | /* now identify the device */ |
| 336 | | slotdevice = apple2_slot(machine, slotnum); |
| 337 | slotdevice = apple2_slot(space->machine, slotnum); |
| 337 | 338 | |
| 338 | 339 | /* and if we can, read from the slot */ |
| 339 | 340 | if (slotdevice != NULL) |
| r3635 | r3636 | |
| 346 | 347 | |
| 347 | 348 | WRITE8_HANDLER(apple2_c0xx_w) |
| 348 | 349 | { |
| 349 | | static const write8_machine_func handlers[] = |
| 350 | static const write8_space_func handlers[] = |
| 350 | 351 | { |
| 351 | 352 | apple2_c00x_w, |
| 352 | 353 | apple2_c01x_w, |
| r3635 | r3636 | |
| 366 | 367 | { |
| 367 | 368 | /* normal handler */ |
| 368 | 369 | if (handlers[offset / 0x10]) |
| 369 | | handlers[offset / 0x10](machine, offset % 0x10, data); |
| 370 | handlers[offset / 0x10](space, offset % 0x10, data); |
| 370 | 371 | } |
| 371 | 372 | else |
| 372 | 373 | { |
| r3635 | r3636 | |
| 374 | 375 | slotnum = (offset - 0x80) / 0x10; |
| 375 | 376 | |
| 376 | 377 | /* now identify the device */ |
| 377 | | slotdevice = apple2_slot(machine, slotnum); |
| 378 | slotdevice = apple2_slot(space->machine, slotnum); |
| 378 | 379 | |
| 379 | 380 | /* and if we can, write to the slot */ |
| 380 | 381 | if (slotdevice != NULL) |
| r3635 | r3636 | |
| 569 | 570 | |
| 570 | 571 | void apple2_setvar(running_machine *machine, UINT32 val, UINT32 mask) |
| 571 | 572 | { |
| 572 | | LOG(("apple2_setvar(): val=0x%06x mask=0x%06x pc=0x%04x\n", val, mask, (unsigned int) cpunum_get_reg(0, REG_PC))); |
| 573 | LOG(("apple2_setvar(): val=0x%06x mask=0x%06x pc=0x%04x\n", val, mask, (unsigned int) cpu_get_reg(machine->cpu[0], REG_PC))); |
| 573 | 574 | |
| 574 | 575 | assert((val & mask) == val); |
| 575 | 576 | |
| r3635 | r3636 | |
| 628 | 629 | |
| 629 | 630 | // video scanner data |
| 630 | 631 | // |
| 631 | | i = activecpu_gettotalcycles() % kClocksPerVSync; // cycles into this VSync |
| 632 | i = cpu_get_total_cycles(Machine->cpu[0]) % kClocksPerVSync; // cycles into this VSync |
| 632 | 633 | |
| 633 | 634 | // machine state switches |
| 634 | 635 | // |
| r3635 | r3636 | |
| 775 | 776 | |
| 776 | 777 | profiler_mark(PROFILER_A2INT); |
| 777 | 778 | |
| 778 | | scanline = video_screen_get_vpos(machine->primary_screen); |
| 779 | scanline = video_screen_get_vpos(device->machine->primary_screen); |
| 779 | 780 | |
| 780 | 781 | if (scanline > 190) |
| 781 | 782 | { |
| r3635 | r3636 | |
| 784 | 785 | irq_freq = 1; |
| 785 | 786 | |
| 786 | 787 | if (irq_freq) |
| 787 | | cpu_set_input_line(machine->cpu[0], M6502_IRQ_LINE, PULSE_LINE); |
| 788 | cpu_set_input_line(device->machine->cpu[0], M6502_IRQ_LINE, PULSE_LINE); |
| 788 | 789 | } |
| 789 | 790 | |
| 790 | | video_screen_update_partial(machine->primary_screen, scanline); |
| 791 | video_screen_update_partial(device->machine->primary_screen, scanline); |
| 791 | 792 | |
| 792 | 793 | profiler_mark(PROFILER_END); |
| 793 | 794 | } |
| r3635 | r3636 | |
| 870 | 871 | { |
| 871 | 872 | UINT32 mask; |
| 872 | 873 | mask = 1 << (offset / 2); |
| 873 | | apple2_setvar(machine, (offset & 1) ? mask : 0, mask); |
| 874 | apple2_setvar(space->machine, (offset & 1) ? mask : 0, mask); |
| 874 | 875 | } |
| 875 | 876 | |
| 876 | 877 | |
| r3635 | r3636 | |
| 897 | 898 | case 0x06: result |= (a2 & VAR_ALTZP) ? 0x80 : 0x00; break; |
| 898 | 899 | case 0x07: result |= (a2 & VAR_SLOTC3ROM) ? 0x80 : 0x00; break; |
| 899 | 900 | case 0x08: result |= (a2 & VAR_80STORE) ? 0x80 : 0x00; break; |
| 900 | | case 0x09: result |= !video_screen_get_vblank(machine->primary_screen) ? 0x80 : 0x00; break; |
| 901 | case 0x09: result |= !video_screen_get_vblank(space->machine->primary_screen) ? 0x80 : 0x00; break; |
| 901 | 902 | case 0x0A: result |= (a2 & VAR_TEXT) ? 0x80 : 0x00; break; |
| 902 | 903 | case 0x0B: result |= (a2 & VAR_MIXED) ? 0x80 : 0x00; break; |
| 903 | 904 | case 0x0C: result |= (a2 & VAR_PAGE2) ? 0x80 : 0x00; break; |
| r3635 | r3636 | |
| 932 | 933 | |
| 933 | 934 | READ8_HANDLER( apple2_c02x_r ) |
| 934 | 935 | { |
| 935 | | apple2_c02x_w(machine, offset, 0); |
| 936 | apple2_c02x_w(space, offset, 0); |
| 936 | 937 | return apple2_getfloatingbusvalue(); |
| 937 | 938 | } |
| 938 | 939 | |
| r3635 | r3636 | |
| 947 | 948 | switch(offset) |
| 948 | 949 | { |
| 949 | 950 | case 0x08: |
| 950 | | apple2_setvar(machine, (a2 & VAR_ROMSWITCH) ^ VAR_ROMSWITCH, VAR_ROMSWITCH); |
| 951 | apple2_setvar(space->machine, (a2 & VAR_ROMSWITCH) ^ VAR_ROMSWITCH, VAR_ROMSWITCH); |
| 951 | 952 | break; |
| 952 | 953 | } |
| 953 | 954 | } |
| r3635 | r3636 | |
| 979 | 980 | |
| 980 | 981 | WRITE8_HANDLER ( apple2_c03x_w ) |
| 981 | 982 | { |
| 982 | | apple2_c03x_r(machine, offset); |
| 983 | apple2_c03x_r(space, offset); |
| 983 | 984 | } |
| 984 | 985 | |
| 985 | 986 | |
| r3635 | r3636 | |
| 997 | 998 | offset ^= 1; |
| 998 | 999 | |
| 999 | 1000 | mask = 0x100 << (offset / 2); |
| 1000 | | apple2_setvar(machine, (offset & 1) ? mask : 0, mask); |
| 1001 | apple2_setvar(space->machine, (offset & 1) ? mask : 0, mask); |
| 1001 | 1002 | return apple2_getfloatingbusvalue(); |
| 1002 | 1003 | } |
| 1003 | 1004 | |
| r3635 | r3636 | |
| 1009 | 1010 | |
| 1010 | 1011 | WRITE8_HANDLER ( apple2_c05x_w ) |
| 1011 | 1012 | { |
| 1012 | | apple2_c05x_r(machine, offset); |
| 1013 | apple2_c05x_r(space, offset); |
| 1013 | 1014 | } |
| 1014 | 1015 | |
| 1015 | 1016 | |
| r3635 | r3636 | |
| 1025 | 1026 | { |
| 1026 | 1027 | case 0x01: |
| 1027 | 1028 | /* Open-Apple/Joystick button 0 */ |
| 1028 | | result = apple2_pressed_specialkey(machine, SPECIALKEY_BUTTON0); |
| 1029 | result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON0); |
| 1029 | 1030 | break; |
| 1030 | 1031 | case 0x02: |
| 1031 | 1032 | /* Closed-Apple/Joystick button 1 */ |
| 1032 | | result = apple2_pressed_specialkey(machine, SPECIALKEY_BUTTON1); |
| 1033 | result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON1); |
| 1033 | 1034 | break; |
| 1034 | 1035 | case 0x03: |
| 1035 | 1036 | /* Joystick button 2. Later revision motherboards connected this to SHIFT also */ |
| 1036 | | result = apple2_pressed_specialkey(machine, SPECIALKEY_BUTTON2); |
| 1037 | result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON2); |
| 1037 | 1038 | break; |
| 1038 | 1039 | case 0x04: |
| 1039 | 1040 | /* X Joystick 1 axis */ |
| r3635 | r3636 | |
| 1074 | 1075 | |
| 1075 | 1076 | if (offset == 0) |
| 1076 | 1077 | { |
| 1077 | | joystick_x1_time = attotime_to_double(timer_get_time()) + x_calibration * input_port_read(machine, "joystick_1_x"); |
| 1078 | | joystick_y1_time = attotime_to_double(timer_get_time()) + y_calibration * input_port_read(machine, "joystick_1_y"); |
| 1079 | | joystick_x2_time = attotime_to_double(timer_get_time()) + x_calibration * input_port_read(machine, "joystick_2_x"); |
| 1080 | | joystick_y2_time = attotime_to_double(timer_get_time()) + y_calibration * input_port_read(machine, "joystick_2_y"); |
| 1078 | joystick_x1_time = attotime_to_double(timer_get_time()) + x_calibration * input_port_read(space->machine, "joystick_1_x"); |
| 1079 | joystick_y1_time = attotime_to_double(timer_get_time()) + y_calibration * input_port_read(space->machine, "joystick_1_y"); |
| 1080 | joystick_x2_time = attotime_to_double(timer_get_time()) + x_calibration * input_port_read(space->machine, "joystick_2_x"); |
| 1081 | joystick_y2_time = attotime_to_double(timer_get_time()) + y_calibration * input_port_read(space->machine, "joystick_2_y"); |
| 1081 | 1082 | } |
| 1082 | 1083 | return 0; |
| 1083 | 1084 | } |
| r3635 | r3636 | |
| 1090 | 1091 | |
| 1091 | 1092 | WRITE8_HANDLER ( apple2_c07x_w ) |
| 1092 | 1093 | { |
| 1093 | | apple2_c07x_r(machine, offset); |
| 1094 | apple2_c07x_r(space, offset); |
| 1094 | 1095 | } |
| 1095 | 1096 | |
| 1096 | 1097 | |