src/mess/machine/mac.c
| r9489 | r9490 | |
| 79 | 79 | |
| 80 | 80 | ****************************************************************************/ |
| 81 | 81 | |
| 82 | #define ADDRESS_MAP_MODERN |
| 83 | |
| 82 | 84 | #include <time.h> |
| 83 | 85 | |
| 84 | 86 | #include "emu.h" |
| r9489 | r9490 | |
| 88 | 90 | #include "machine/applefdc.h" |
| 89 | 91 | #include "devices/sonydriv.h" |
| 90 | 92 | #include "machine/ncr5380.h" |
| 93 | #include "sound/asc.h" |
| 91 | 94 | #include "includes/mac.h" |
| 92 | 95 | #include "debug/debugcpu.h" |
| 93 | 96 | #include "devices/messram.h" |
| 94 | 97 | #include "debugger.h" |
| 95 | 98 | |
| 96 | | #define ADB_IS_BITBANG ((mac->model == MODEL_MAC_SE || mac->model == MODEL_MAC_CLASSIC) || (mac->model >= MODEL_MAC_II && mac->model <= MODEL_MAC_IICI) || (mac->model == MODEL_MAC_SE30)) |
| 97 | | #define ADB_IS_EGRET (mac->model >= MODEL_MAC_LC && mac->model <= MODEL_MAC_COLOR_CLASSIC) || ((mac->model >= MODEL_MAC_IISI) && (mac->model <= MODEL_MAC_IIVI)) |
| 98 | | #define ADB_IS_PM (mac->model >= MODEL_MAC_PORTABLE && mac->model <= MODEL_MAC_PB100) |
| 99 | #define ADB_IS_BITBANG ((mac->m_model == MODEL_MAC_SE || mac->m_model == MODEL_MAC_CLASSIC) || (mac->m_model >= MODEL_MAC_II && mac->m_model <= MODEL_MAC_IICI) || (mac->m_model == MODEL_MAC_SE30)) |
| 100 | #define ADB_IS_BITBANG_CLASS ((m_model == MODEL_MAC_SE || m_model == MODEL_MAC_CLASSIC) || (m_model >= MODEL_MAC_II && m_model <= MODEL_MAC_IICI) || (m_model == MODEL_MAC_SE30)) |
| 101 | #define ADB_IS_EGRET (mac->m_model >= MODEL_MAC_LC && mac->m_model <= MODEL_MAC_COLOR_CLASSIC) || ((mac->m_model >= MODEL_MAC_IISI) && (mac->m_model <= MODEL_MAC_IIVI)) |
| 102 | #define ADB_IS_PM (mac->m_model >= MODEL_MAC_PORTABLE && mac->m_model <= MODEL_MAC_PB100) |
| 103 | #define ADB_IS_PM_CLASS (m_model >= MODEL_MAC_PORTABLE && m_model <= MODEL_MAC_PB100) |
| 99 | 104 | |
| 100 | | #define AUDIO_IS_CLASSIC (mac->model < MODEL_MAC_II) && (mac->model != MODEL_MAC_PORTABLE) && (mac->model != MODEL_MAC_PB100) |
| 101 | | #define MAC_HAS_VIA2 (mac->model >= MODEL_MAC_II) |
| 105 | #define AUDIO_IS_CLASSIC (mac->m_model < MODEL_MAC_II) && (mac->m_model != MODEL_MAC_PORTABLE) && (mac->m_model != MODEL_MAC_PB100) |
| 106 | #define AUDIO_IS_CLASSIC_CLASS (m_model < MODEL_MAC_II) && (m_model != MODEL_MAC_PORTABLE) && (m_model != MODEL_MAC_PB100) |
| 107 | #define MAC_HAS_VIA2 (m_model >= MODEL_MAC_II) |
| 102 | 108 | |
| 103 | | #define ASC_INTS_RBV ((mac->model >= MODEL_MAC_IICI) && (mac->model <= MODEL_MAC_IIVI)) || ((mac->model >= MODEL_MAC_LC) && (mac->model <= MODEL_MAC_COLOR_CLASSIC)) |
| 109 | #define ASC_INTS_RBV ((mac->m_model >= MODEL_MAC_IICI) && (mac->m_model <= MODEL_MAC_IIVI)) || ((mac->m_model >= MODEL_MAC_LC) && (mac->m_model <= MODEL_MAC_COLOR_CLASSIC)) |
| 104 | 110 | |
| 105 | 111 | #ifdef MAME_DEBUG |
| 106 | 112 | #define LOG_VIA 0 |
| r9489 | r9490 | |
| 189 | 195 | }; |
| 190 | 196 | |
| 191 | 197 | // returns non-zero if this Mac has ADB |
| 192 | | static int has_adb(mac_state *mac) |
| 198 | int mac_state::has_adb() |
| 193 | 199 | { |
| 194 | | return mac->model >= MODEL_MAC_SE; |
| 200 | return m_model >= MODEL_MAC_SE; |
| 195 | 201 | } |
| 196 | 202 | |
| 197 | 203 | // handle disk enable lines |
| 198 | | void mac_fdc_set_enable_lines(running_device *device,int enable_mask) |
| 204 | void mac_fdc_set_enable_lines(running_device *device, int enable_mask) |
| 199 | 205 | { |
| 200 | 206 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 201 | 207 | |
| 202 | | if (mac->model != MODEL_MAC_SE) |
| 208 | if (mac->m_model != MODEL_MAC_SE) |
| 203 | 209 | { |
| 204 | | sony_set_enable_lines(device,enable_mask); |
| 210 | sony_set_enable_lines(device, enable_mask); |
| 205 | 211 | } |
| 206 | 212 | else |
| 207 | 213 | { |
| 208 | 214 | if (enable_mask) |
| 209 | 215 | { |
| 210 | | sony_set_enable_lines(device,mac->drive_select ? 1 : 2); |
| 216 | sony_set_enable_lines(device, mac->m_drive_select ? 1 : 2); |
| 211 | 217 | } |
| 212 | 218 | else |
| 213 | 219 | { |
| 214 | | sony_set_enable_lines(device,enable_mask); |
| 220 | sony_set_enable_lines(device, enable_mask); |
| 215 | 221 | } |
| 216 | 222 | } |
| 217 | 223 | } |
| r9489 | r9490 | |
| 250 | 256 | Interrupt handling |
| 251 | 257 | */ |
| 252 | 258 | |
| 253 | | static int scc_interrupt, via_interrupt, via2_interrupt, scsi_interrupt, last_taken_interrupt; |
| 254 | | |
| 255 | | static void mac_field_interrupts(running_machine *machine) |
| 259 | void mac_state::field_interrupts(running_machine *machine) |
| 256 | 260 | { |
| 257 | | mac_state *mac = machine->driver_data<mac_state>(); |
| 258 | | |
| 259 | 261 | int take_interrupt = -1; |
| 260 | 262 | |
| 261 | | if (mac->model < MODEL_MAC_II) |
| 263 | if (m_model < MODEL_MAC_II) |
| 262 | 264 | { |
| 263 | | if ((scc_interrupt) || (scsi_interrupt)) |
| 265 | if ((m_scc_interrupt) || (m_scsi_interrupt)) |
| 264 | 266 | { |
| 265 | 267 | take_interrupt = 2; |
| 266 | 268 | } |
| 267 | | else if (via_interrupt) |
| 269 | else if (m_via_interrupt) |
| 268 | 270 | { |
| 269 | 271 | take_interrupt = 1; |
| 270 | 272 | } |
| 271 | 273 | } |
| 272 | | else if (mac->model < MODEL_MAC_POWERMAC_6100) |
| 274 | else if (m_model < MODEL_MAC_POWERMAC_6100) |
| 273 | 275 | { |
| 274 | | if (scc_interrupt) |
| 276 | if (m_scc_interrupt) |
| 275 | 277 | { |
| 276 | 278 | take_interrupt = 4; |
| 277 | 279 | } |
| 278 | | else if (via2_interrupt) |
| 280 | else if (m_via2_interrupt) |
| 279 | 281 | { |
| 280 | 282 | take_interrupt = 2; |
| 281 | 283 | } |
| 282 | | else if (via_interrupt) |
| 284 | else if (m_via_interrupt) |
| 283 | 285 | { |
| 284 | 286 | take_interrupt = 1; |
| 285 | 287 | } |
| r9489 | r9490 | |
| 289 | 291 | return; // no interrupts for PowerPC yet |
| 290 | 292 | } |
| 291 | 293 | |
| 292 | | if (last_taken_interrupt != -1) |
| 294 | if (m_last_taken_interrupt != -1) |
| 293 | 295 | { |
| 294 | | cputag_set_input_line(machine, "maincpu", last_taken_interrupt, CLEAR_LINE); |
| 295 | | last_taken_interrupt = -1; |
| 296 | cputag_set_input_line(machine, "maincpu", m_last_taken_interrupt, CLEAR_LINE); |
| 297 | m_last_taken_interrupt = -1; |
| 296 | 298 | } |
| 297 | 299 | |
| 298 | 300 | if (take_interrupt != -1) |
| 299 | 301 | { |
| 300 | 302 | cputag_set_input_line(machine, "maincpu", take_interrupt, ASSERT_LINE); |
| 301 | | last_taken_interrupt = take_interrupt; |
| 303 | m_last_taken_interrupt = take_interrupt; |
| 302 | 304 | } |
| 303 | 305 | } |
| 304 | 306 | |
| 305 | | static void set_scc_interrupt(running_machine *machine, int value) |
| 307 | void mac_state::set_scc_interrupt(running_machine *machine, int value) |
| 306 | 308 | { |
| 307 | | scc_interrupt = value; |
| 308 | | mac_field_interrupts(machine); |
| 309 | m_scc_interrupt = value; |
| 310 | field_interrupts(machine); |
| 309 | 311 | } |
| 310 | 312 | |
| 311 | | static void set_via_interrupt(running_machine *machine, int value) |
| 313 | void mac_state::set_via_interrupt(running_machine *machine, int value) |
| 312 | 314 | { |
| 313 | | via_interrupt = value; |
| 314 | | mac_field_interrupts(machine); |
| 315 | m_via_interrupt = value; |
| 316 | field_interrupts(machine); |
| 315 | 317 | } |
| 316 | 318 | |
| 317 | 319 | |
| 318 | | void mac_set_via2_interrupt(running_machine *machine, int value) |
| 320 | void mac_state::set_via2_interrupt(running_machine *machine, int value) |
| 319 | 321 | { |
| 320 | | via2_interrupt = value; |
| 321 | | |
| 322 | | mac_field_interrupts(machine); |
| 322 | m_via2_interrupt = value; |
| 323 | field_interrupts(machine); |
| 323 | 324 | } |
| 324 | 325 | |
| 325 | 326 | void mac_asc_irq(running_device *device, int state) |
| r9489 | r9490 | |
| 330 | 331 | { |
| 331 | 332 | if (state) |
| 332 | 333 | { |
| 333 | | mac->rbv_regs[3] |= 0x90; // any VIA 2 interrupt | sound interrupt |
| 334 | mac->m_rbv_regs[3] |= 0x90; // any VIA 2 interrupt | sound interrupt |
| 334 | 335 | |
| 335 | | if (mac->rbv_ier & 0x10) // ASC on RBV is CB1, bit 4 of IER/IFR |
| 336 | if (mac->m_rbv_ier & 0x10) // ASC on RBV is CB1, bit 4 of IER/IFR |
| 336 | 337 | { |
| 337 | | mac->rbv_ifr |= 0x90; |
| 338 | | mac_set_via2_interrupt(device->machine, 1); |
| 338 | mac->m_rbv_ifr |= 0x90; |
| 339 | mac->set_via2_interrupt(device->machine, 1); |
| 339 | 340 | } |
| 340 | 341 | } |
| 341 | 342 | else |
| 342 | 343 | { |
| 343 | | mac->rbv_regs[3] &= ~0x90; |
| 344 | | mac->rbv_ifr &= ~0x10; |
| 344 | mac->m_rbv_regs[3] &= ~0x90; |
| 345 | mac->m_rbv_ifr &= ~0x10; |
| 345 | 346 | } |
| 346 | 347 | |
| 347 | 348 | } |
| 348 | | else if (mac->model >= MODEL_MAC_II) |
| 349 | else if (mac->m_model >= MODEL_MAC_II) |
| 349 | 350 | { |
| 350 | | via6522_device *via2 = device->machine->device<via6522_device>("via6522_1"); |
| 351 | | |
| 352 | | via2->write_cb1(state^1); |
| 351 | mac->m_via2->write_cb1(state^1); |
| 353 | 352 | } |
| 354 | 353 | |
| 355 | 354 | // todo: portable/pb100 hook up ASC IRQ differently |
| 356 | 355 | } |
| 357 | 356 | |
| 358 | | WRITE16_HANDLER ( mac_autovector_w ) |
| 357 | WRITE16_MEMBER ( mac_state::mac_autovector_w ) |
| 359 | 358 | { |
| 360 | 359 | if (LOG_GENERAL) |
| 361 | 360 | logerror("mac_autovector_w: offset=0x%08x data=0x%04x\n", offset, data); |
| r9489 | r9490 | |
| 365 | 364 | /* Not yet implemented */ |
| 366 | 365 | } |
| 367 | 366 | |
| 368 | | READ16_HANDLER ( mac_autovector_r ) |
| 367 | READ16_MEMBER ( mac_state::mac_autovector_r ) |
| 369 | 368 | { |
| 370 | 369 | if (LOG_GENERAL) |
| 371 | 370 | logerror("mac_autovector_r: offset=0x%08x\n", offset); |
| r9489 | r9490 | |
| 384 | 383 | /* Not Yet Implemented */ |
| 385 | 384 | } |
| 386 | 385 | |
| 387 | | void mac_v8_resize(running_machine *machine, mac_state *mac) |
| 386 | void mac_state::v8_resize(running_machine *machine) |
| 388 | 387 | { |
| 389 | 388 | offs_t memory_size; |
| 390 | 389 | UINT8 *memory_data; |
| 391 | 390 | int is_rom; |
| 392 | 391 | |
| 393 | | is_rom = (mac->overlay) ? 1 : 0; |
| 392 | is_rom = (m_overlay) ? 1 : 0; |
| 394 | 393 | |
| 395 | 394 | // get what memory we're going to map |
| 396 | 395 | if (is_rom) |
| r9489 | r9490 | |
| 403 | 402 | else |
| 404 | 403 | { |
| 405 | 404 | /* RAM */ |
| 406 | | memory_size = messram_get_size(machine->device("messram")); |
| 407 | | memory_data = messram_get_ptr(machine->device("messram")); |
| 405 | memory_size = messram_get_size(m_ram); |
| 406 | memory_data = messram_get_ptr(m_ram); |
| 408 | 407 | is_rom = FALSE; |
| 409 | 408 | } |
| 410 | 409 | |
| 411 | | // printf("mac_v8_resize: memory_size = %x, ctrl bits %02x (overlay %d = %s)\n", memory_size, mac->rbv_regs[1] & 0xe0, mac->overlay, is_rom ? "ROM" : "RAM"); |
| 410 | // printf("mac_v8_resize: memory_size = %x, ctrl bits %02x (overlay %d = %s)\n", memory_size, mac->m_rbv_regs[1] & 0xe0, mac->m_overlay, is_rom ? "ROM" : "RAM"); |
| 412 | 411 | |
| 413 | 412 | if (is_rom) |
| 414 | 413 | { |
| r9489 | r9490 | |
| 426 | 425 | // LC has 2 MB built-in, all other V8-style machines have 4 MB |
| 427 | 426 | // we reserve the first 2 or 4 MB of mess_ram for the onboard, |
| 428 | 427 | // RAM above that mark is the SIMM |
| 429 | | onboard_amt = ((mac->model == MODEL_MAC_LC) || (mac->model == MODEL_MAC_CLASSIC_II)) ? 2*1024*1024 : 4*1024*1024; |
| 430 | | simm_amt = (mac->rbv_regs[1]>>6) & 3; // size of SIMM RAM window |
| 428 | onboard_amt = ((m_model == MODEL_MAC_LC) || (m_model == MODEL_MAC_CLASSIC_II)) ? 2*1024*1024 : 4*1024*1024; |
| 429 | simm_amt = (m_rbv_regs[1]>>6) & 3; // size of SIMM RAM window |
| 431 | 430 | simm_size = memory_size - onboard_amt; // actual amount of RAM available for SIMMs |
| 432 | 431 | |
| 433 | 432 | // installing SIMM RAM? |
| r9489 | r9490 | |
| 459 | 458 | } |
| 460 | 459 | } |
| 461 | 460 | |
| 462 | | void mac_set_memory_overlay(running_machine *machine, int overlay) |
| 461 | void mac_state::set_memory_overlay(running_machine *machine, int overlay) |
| 463 | 462 | { |
| 464 | 463 | offs_t memory_size; |
| 465 | 464 | UINT8 *memory_data; |
| 466 | 465 | int is_rom; |
| 467 | | mac_state *mac = machine->driver_data<mac_state>(); |
| 468 | 466 | |
| 469 | 467 | /* normalize overlay */ |
| 470 | 468 | overlay = overlay ? TRUE : FALSE; |
| 471 | 469 | |
| 472 | | if (overlay != mac->overlay) |
| 470 | if (overlay != m_overlay) |
| 473 | 471 | { |
| 474 | 472 | /* set up either main RAM area or ROM mirror at 0x000000-0x3fffff */ |
| 475 | 473 | if (overlay) |
| r9489 | r9490 | |
| 482 | 480 | else |
| 483 | 481 | { |
| 484 | 482 | /* RAM */ |
| 485 | | memory_size = messram_get_size(machine->device("messram")); |
| 486 | | memory_data = messram_get_ptr(machine->device("messram")); |
| 483 | memory_size = messram_get_size(m_ram); |
| 484 | memory_data = messram_get_ptr(m_ram); |
| 487 | 485 | is_rom = FALSE; |
| 488 | 486 | } |
| 489 | 487 | |
| 490 | 488 | /* install the memory */ |
| 491 | | if (((mac->model >= MODEL_MAC_LC) && (mac->model <= MODEL_MAC_COLOR_CLASSIC) && ((mac->model != MODEL_MAC_LC_III) && (mac->model != MODEL_MAC_LC_III_PLUS))) || (mac->model == MODEL_MAC_CLASSIC_II)) |
| 489 | if (((m_model >= MODEL_MAC_LC) && (m_model <= MODEL_MAC_COLOR_CLASSIC) && ((m_model != MODEL_MAC_LC_III) && (m_model != MODEL_MAC_LC_III_PLUS))) || (m_model == MODEL_MAC_CLASSIC_II)) |
| 492 | 490 | { |
| 493 | | mac->overlay = overlay; |
| 494 | | mac_v8_resize(machine, mac); |
| 491 | m_overlay = overlay; |
| 492 | v8_resize(machine); |
| 495 | 493 | } |
| 496 | | else if ((mac->model >= MODEL_MAC_POWERMAC_6100) && (mac->model >= MODEL_MAC_POWERMAC_8100)) |
| 494 | else if ((m_model >= MODEL_MAC_POWERMAC_6100) && (m_model >= MODEL_MAC_POWERMAC_8100)) |
| 497 | 495 | { |
| 498 | 496 | // mac_install_memory(machine, 0x00000000, memory_size-1, memory_size, memory_data, is_rom, "bank1"); |
| 499 | 497 | } |
| 500 | | else if ((mac->model == MODEL_MAC_IICI) || (mac->model == MODEL_MAC_IISI)) |
| 498 | else if ((m_model == MODEL_MAC_IICI) || (m_model == MODEL_MAC_IISI)) |
| 501 | 499 | { |
| 502 | 500 | // ROM is OK to flood to 3fffffff |
| 503 | 501 | if (is_rom) |
| r9489 | r9490 | |
| 509 | 507 | mac_install_memory(machine, 0x00000000, 0x03ffffff, memory_size, memory_data, is_rom, "bank1"); |
| 510 | 508 | } |
| 511 | 509 | } |
| 512 | | else if ((mac->model == MODEL_MAC_PORTABLE) || (mac->model == MODEL_MAC_PB100)) |
| 510 | else if ((m_model == MODEL_MAC_PORTABLE) || (m_model == MODEL_MAC_PB100)) |
| 513 | 511 | { |
| 514 | 512 | mac_install_memory(machine, 0x000000, 0x8fffff, memory_size, memory_data, is_rom, "bank1"); |
| 515 | 513 | } |
| 516 | | else if ((mac->model >= MODEL_MAC_II) && (mac->model <= MODEL_MAC_SE30)) |
| 514 | else if ((m_model >= MODEL_MAC_II) && (m_model <= MODEL_MAC_SE30)) |
| 517 | 515 | { |
| 518 | 516 | mac_install_memory(machine, 0x00000000, 0x3fffffff, memory_size, memory_data, is_rom, "bank1"); |
| 519 | 517 | } |
| 520 | | else if ((mac->model == MODEL_MAC_LC_III) || (mac->model == MODEL_MAC_LC_III_PLUS)) // up to 36 MB |
| 518 | else if ((m_model == MODEL_MAC_LC_III) || (m_model == MODEL_MAC_LC_III_PLUS)) // up to 36 MB |
| 521 | 519 | { |
| 522 | 520 | mac_install_memory(machine, 0x00000000, memory_size-1, memory_size, memory_data, is_rom, "bank1"); |
| 523 | 521 | } |
| r9489 | r9490 | |
| 526 | 524 | mac_install_memory(machine, 0x00000000, 0x003fffff, memory_size, memory_data, is_rom, "bank1"); |
| 527 | 525 | } |
| 528 | 526 | |
| 529 | | mac->overlay = overlay; |
| 527 | m_overlay = overlay; |
| 530 | 528 | |
| 531 | 529 | if (LOG_GENERAL) |
| 532 | 530 | logerror("mac_set_memory_overlay: overlay=%i\n", overlay); |
| r9489 | r9490 | |
| 572 | 570 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6" }; |
| 573 | 571 | mac_state *mac = machine->driver_data<mac_state>(); |
| 574 | 572 | |
| 575 | | if (mac->keycode_buf_index) |
| 573 | if (mac->m_keycode_buf_index) |
| 576 | 574 | { |
| 577 | | return mac->keycode_buf[--mac->keycode_buf_index]; |
| 575 | return mac->m_keycode_buf[--mac->m_keycode_buf_index]; |
| 578 | 576 | } |
| 579 | 577 | |
| 580 | 578 | for (i=0; i<7; i++) |
| 581 | 579 | { |
| 582 | 580 | keybuf = input_port_read(machine, keynames[i]); |
| 583 | 581 | |
| 584 | | if (keybuf != mac->key_matrix[i]) |
| 582 | if (keybuf != mac->m_key_matrix[i]) |
| 585 | 583 | { |
| 586 | 584 | /* if state has changed, find first bit which has changed */ |
| 587 | 585 | if (LOG_KEYBOARD) |
| r9489 | r9490 | |
| 589 | 587 | |
| 590 | 588 | for (j=0; j<16; j++) |
| 591 | 589 | { |
| 592 | | if (((keybuf ^ mac->key_matrix[i]) >> j) & 1) |
| 590 | if (((keybuf ^ mac->m_key_matrix[i]) >> j) & 1) |
| 593 | 591 | { |
| 594 | | /* update mac->key_matrix */ |
| 595 | | mac->key_matrix[i] = (mac->key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j)); |
| 592 | /* update mac->m_key_matrix */ |
| 593 | mac->m_key_matrix[i] = (mac->m_key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j)); |
| 596 | 594 | |
| 597 | 595 | if (i < 4) |
| 598 | 596 | { |
| r9489 | r9490 | |
| 616 | 614 | if (keybuf & (1 << j)) |
| 617 | 615 | { |
| 618 | 616 | /* key down */ |
| 619 | | if (! (mac->key_matrix[3] & 0x0100)) |
| 617 | if (! (mac->m_key_matrix[3] & 0x0100)) |
| 620 | 618 | { |
| 621 | 619 | /* shift key is really up */ |
| 622 | | mac->keycode_buf[0] = keycode; |
| 623 | | mac->keycode_buf[1] = 0x79; |
| 624 | | mac->keycode_buf_index = 2; |
| 620 | mac->m_keycode_buf[0] = keycode; |
| 621 | mac->m_keycode_buf[1] = 0x79; |
| 622 | mac->m_keycode_buf_index = 2; |
| 625 | 623 | return 0x71; /* "presses" shift down */ |
| 626 | 624 | } |
| 627 | 625 | } |
| 628 | 626 | else |
| 629 | 627 | { /* key up */ |
| 630 | | if (! (mac->key_matrix[3] & 0x0100)) |
| 628 | if (! (mac->m_key_matrix[3] & 0x0100)) |
| 631 | 629 | { |
| 632 | 630 | /* shift key is really up */ |
| 633 | | mac->keycode_buf[0] = keycode | 0x80;; |
| 634 | | mac->keycode_buf[1] = 0x79; |
| 635 | | mac->keycode_buf_index = 2; |
| 631 | mac->m_keycode_buf[0] = keycode | 0x80;; |
| 632 | mac->m_keycode_buf[1] = 0x79; |
| 633 | mac->m_keycode_buf_index = 2; |
| 636 | 634 | return 0xF1; /* "releases" shift */ |
| 637 | 635 | } |
| 638 | 636 | } |
| r9489 | r9490 | |
| 643 | 641 | /* key up */ |
| 644 | 642 | keycode |= 0x80; |
| 645 | 643 | } |
| 646 | | mac->keycode_buf[0] = keycode; |
| 647 | | mac->keycode_buf_index = 1; |
| 644 | mac->m_keycode_buf[0] = keycode; |
| 645 | mac->m_keycode_buf_index = 1; |
| 648 | 646 | return 0x79; |
| 649 | 647 | } |
| 650 | 648 | else /* i == 6 */ |
| r9489 | r9490 | |
| 656 | 654 | /* key up */ |
| 657 | 655 | keycode |= 0x80; |
| 658 | 656 | } |
| 659 | | mac->keycode_buf[0] = keycode; |
| 660 | | mac->keycode_buf_index = 1; |
| 657 | mac->m_keycode_buf[0] = keycode; |
| 658 | mac->m_keycode_buf_index = 1; |
| 661 | 659 | return 0x79; |
| 662 | 660 | } |
| 663 | 661 | } |
| r9489 | r9490 | |
| 676 | 674 | int i; |
| 677 | 675 | |
| 678 | 676 | /* init flag */ |
| 679 | | mac->kbd_comm = FALSE; |
| 680 | | mac->kbd_receive = FALSE; |
| 681 | | mac->kbd_shift_reg=0; |
| 682 | | mac->kbd_shift_count=0; |
| 677 | mac->m_kbd_comm = FALSE; |
| 678 | mac->m_kbd_receive = FALSE; |
| 679 | mac->m_kbd_shift_reg=0; |
| 680 | mac->m_kbd_shift_count=0; |
| 683 | 681 | |
| 684 | 682 | /* clear key matrix */ |
| 685 | 683 | for (i=0; i<7; i++) |
| 686 | 684 | { |
| 687 | | mac->key_matrix[i] = 0; |
| 685 | mac->m_key_matrix[i] = 0; |
| 688 | 686 | } |
| 689 | 687 | |
| 690 | 688 | /* purge transmission buffer */ |
| 691 | | mac->keycode_buf_index = 0; |
| 689 | mac->m_keycode_buf_index = 0; |
| 692 | 690 | } |
| 693 | 691 | |
| 694 | 692 | /******************* Keyboard <-> VIA communication ***********************/ |
| r9489 | r9490 | |
| 696 | 694 | static TIMER_CALLBACK(kbd_clock) |
| 697 | 695 | { |
| 698 | 696 | int i; |
| 699 | | via6522_device *via_0 = machine->device<via6522_device>("via6522_0"); |
| 700 | 697 | mac_state *mac = machine->driver_data<mac_state>(); |
| 701 | 698 | |
| 702 | | if (mac->kbd_comm == TRUE) |
| 699 | if (mac->m_kbd_comm == TRUE) |
| 703 | 700 | { |
| 704 | 701 | for (i=0; i<8; i++) |
| 705 | 702 | { |
| 706 | 703 | /* Put data on CB2 if we are sending*/ |
| 707 | | if (mac->kbd_receive == FALSE) |
| 708 | | via_0->write_cb2(mac->kbd_shift_reg&0x80?1:0); |
| 709 | | mac->kbd_shift_reg <<= 1; |
| 710 | | via_0->write_cb1(0); |
| 711 | | via_0->write_cb1(1); |
| 704 | if (mac->m_kbd_receive == FALSE) |
| 705 | mac->m_via1->write_cb2(mac->m_kbd_shift_reg&0x80?1:0); |
| 706 | mac->m_kbd_shift_reg <<= 1; |
| 707 | mac->m_via1->write_cb1(0); |
| 708 | mac->m_via1->write_cb1(1); |
| 712 | 709 | } |
| 713 | | if (mac->kbd_receive == TRUE) |
| 710 | if (mac->m_kbd_receive == TRUE) |
| 714 | 711 | { |
| 715 | | mac->kbd_receive = FALSE; |
| 712 | mac->m_kbd_receive = FALSE; |
| 716 | 713 | /* Process the command received from mac */ |
| 717 | | keyboard_receive(machine, mac->kbd_shift_reg & 0xff); |
| 714 | keyboard_receive(machine, mac->m_kbd_shift_reg & 0xff); |
| 718 | 715 | } |
| 719 | 716 | else |
| 720 | 717 | { |
| 721 | 718 | /* Communication is over */ |
| 722 | | mac->kbd_comm = FALSE; |
| 719 | mac->m_kbd_comm = FALSE; |
| 723 | 720 | } |
| 724 | 721 | } |
| 725 | 722 | } |
| r9489 | r9490 | |
| 728 | 725 | { |
| 729 | 726 | mac_state *mac = machine->driver_data<mac_state>(); |
| 730 | 727 | |
| 731 | | if (mac->kbd_comm == TRUE) |
| 728 | if (mac->m_kbd_comm == TRUE) |
| 732 | 729 | { |
| 733 | | mac->kbd_shift_reg = data; |
| 730 | mac->m_kbd_shift_reg = data; |
| 734 | 731 | timer_set(machine, ATTOTIME_IN_MSEC(1), NULL, 0, kbd_clock); |
| 735 | 732 | } |
| 736 | 733 | } |
| r9489 | r9490 | |
| 739 | 736 | { |
| 740 | 737 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 741 | 738 | |
| 742 | | if (mac->kbd_comm == FALSE && data == 0) |
| 739 | if (mac->m_kbd_comm == FALSE && data == 0) |
| 743 | 740 | { |
| 744 | 741 | /* Mac pulls CB2 down to initiate communication */ |
| 745 | | mac->kbd_comm = TRUE; |
| 746 | | mac->kbd_receive = TRUE; |
| 742 | mac->m_kbd_comm = TRUE; |
| 743 | mac->m_kbd_receive = TRUE; |
| 747 | 744 | timer_set(device->machine, ATTOTIME_IN_USEC(100), NULL, 0, kbd_clock); |
| 748 | 745 | } |
| 749 | | if (mac->kbd_comm == TRUE && mac->kbd_receive == TRUE) |
| 746 | if (mac->m_kbd_comm == TRUE && mac->m_kbd_receive == TRUE) |
| 750 | 747 | { |
| 751 | 748 | /* Shift in what mac is sending */ |
| 752 | | mac->kbd_shift_reg = (mac->kbd_shift_reg & ~1) | data; |
| 749 | mac->m_kbd_shift_reg = (mac->m_kbd_shift_reg & ~1) | data; |
| 753 | 750 | } |
| 754 | 751 | } |
| 755 | 752 | |
| r9489 | r9490 | |
| 777 | 774 | if (LOG_KEYBOARD) |
| 778 | 775 | logerror("keyboard command : inquiry\n"); |
| 779 | 776 | |
| 780 | | mac->keyboard_reply = scan_keyboard(machine); |
| 781 | | if (mac->keyboard_reply == 0x7B) |
| 777 | mac->m_keyboard_reply = scan_keyboard(machine); |
| 778 | if (mac->m_keyboard_reply == 0x7B) |
| 782 | 779 | { |
| 783 | 780 | /* if NULL, wait until key pressed or timeout */ |
| 784 | | timer_adjust_oneshot(mac->inquiry_timeout, |
| 781 | timer_adjust_oneshot(mac->m_inquiry_timeout, |
| 785 | 782 | attotime_make(0, DOUBLE_TO_ATTOSECONDS(0.25)), 0); |
| 786 | 783 | } |
| 787 | 784 | break; |
| r9489 | r9490 | |
| 805 | 802 | /* clear key matrix */ |
| 806 | 803 | for (i=0; i<7; i++) |
| 807 | 804 | { |
| 808 | | mac->key_matrix[i] = 0; |
| 805 | mac->m_key_matrix[i] = 0; |
| 809 | 806 | } |
| 810 | 807 | |
| 811 | 808 | /* purge transmission buffer */ |
| 812 | | mac->keycode_buf_index = 0; |
| 809 | mac->m_keycode_buf_index = 0; |
| 813 | 810 | } |
| 814 | 811 | |
| 815 | 812 | /* format : 1 if another device (-> keypad ?) connected | next device (-> keypad ?) number 1-8 |
| r9489 | r9490 | |
| 893 | 890 | if (count_x < 0) |
| 894 | 891 | { |
| 895 | 892 | count_x++; |
| 896 | | mac->mouse_bit_x = 0; |
| 893 | mac->m_mouse_bit_x = 0; |
| 897 | 894 | } |
| 898 | 895 | else |
| 899 | 896 | { |
| 900 | 897 | count_x--; |
| 901 | | mac->mouse_bit_x = 1; |
| 898 | mac->m_mouse_bit_x = 1; |
| 902 | 899 | } |
| 903 | 900 | x_needs_update = 1; |
| 904 | 901 | } |
| r9489 | r9490 | |
| 907 | 904 | if (count_y < 0) |
| 908 | 905 | { |
| 909 | 906 | count_y++; |
| 910 | | mac->mouse_bit_y = 1; |
| 907 | mac->m_mouse_bit_y = 1; |
| 911 | 908 | } |
| 912 | 909 | else |
| 913 | 910 | { |
| 914 | 911 | count_y--; |
| 915 | | mac->mouse_bit_y = 0; |
| 912 | mac->m_mouse_bit_y = 0; |
| 916 | 913 | } |
| 917 | 914 | y_needs_update = 1; |
| 918 | 915 | } |
| 919 | 916 | |
| 920 | 917 | if (x_needs_update || y_needs_update) |
| 921 | 918 | /* assert Port B External Interrupt on the SCC */ |
| 922 | | mac_scc_mouse_irq( machine, x_needs_update, y_needs_update ); |
| 919 | mac->scc_mouse_irq(machine, x_needs_update, y_needs_update ); |
| 923 | 920 | } |
| 924 | 921 | |
| 925 | 922 | /* ************************************************************************* |
| r9489 | r9490 | |
| 972 | 969 | scsiRd+sRESET $580070 Reset Parity/Interrupt |
| 973 | 970 | */ |
| 974 | 971 | |
| 975 | | READ16_HANDLER ( macplus_scsi_r ) |
| 972 | READ16_MEMBER ( mac_state::macplus_scsi_r ) |
| 976 | 973 | { |
| 977 | 974 | int reg = (offset>>3) & 0xf; |
| 978 | | running_device *ncr = space->machine->device("ncr5380"); |
| 975 | running_device *ncr = space.machine->device("ncr5380"); |
| 979 | 976 | |
| 980 | 977 | // logerror("macplus_scsi_r: offset %x mask %x\n", offset, mem_mask); |
| 981 | 978 | |
| r9489 | r9490 | |
| 987 | 984 | return ncr5380_read_reg(ncr, reg)<<8; |
| 988 | 985 | } |
| 989 | 986 | |
| 990 | | READ32_HANDLER (macii_scsi_drq_r) |
| 987 | READ32_MEMBER (mac_state::macii_scsi_drq_r) |
| 991 | 988 | { |
| 992 | | running_device *ncr = space->machine->device("ncr5380"); |
| 989 | running_device *ncr = space.machine->device("ncr5380"); |
| 993 | 990 | |
| 994 | 991 | switch (mem_mask) |
| 995 | 992 | { |
| r9489 | r9490 | |
| 1009 | 1006 | return 0; |
| 1010 | 1007 | } |
| 1011 | 1008 | |
| 1012 | | WRITE32_HANDLER (macii_scsi_drq_w) |
| 1009 | WRITE32_MEMBER (mac_state::macii_scsi_drq_w) |
| 1013 | 1010 | { |
| 1014 | | running_device *ncr = space->machine->device("ncr5380"); |
| 1011 | running_device *ncr = space.machine->device("ncr5380"); |
| 1015 | 1012 | |
| 1016 | 1013 | switch (mem_mask) |
| 1017 | 1014 | { |
| r9489 | r9490 | |
| 1037 | 1034 | } |
| 1038 | 1035 | } |
| 1039 | 1036 | |
| 1040 | | WRITE16_HANDLER ( macplus_scsi_w ) |
| 1037 | WRITE16_MEMBER ( mac_state::macplus_scsi_w ) |
| 1041 | 1038 | { |
| 1042 | 1039 | int reg = (offset>>3) & 0xf; |
| 1043 | | running_device *ncr = space->machine->device("ncr5380"); |
| 1040 | running_device *ncr = space.machine->device("ncr5380"); |
| 1044 | 1041 | |
| 1045 | 1042 | // logerror("macplus_scsi_w: data %x offset %x mask %x\n", data, offset, mem_mask); |
| 1046 | 1043 | |
| r9489 | r9490 | |
| 1052 | 1049 | ncr5380_write_reg(ncr, reg, data); |
| 1053 | 1050 | } |
| 1054 | 1051 | |
| 1055 | | WRITE16_HANDLER ( macii_scsi_w ) |
| 1052 | WRITE16_MEMBER ( mac_state::macii_scsi_w ) |
| 1056 | 1053 | { |
| 1057 | 1054 | int reg = (offset>>3) & 0xf; |
| 1058 | | running_device *ncr = space->machine->device("ncr5380"); |
| 1055 | running_device *ncr = space.machine->device("ncr5380"); |
| 1059 | 1056 | |
| 1060 | 1057 | // logerror("macplus_scsi_w: data %x offset %x mask %x (PC=%x)\n", data, offset, mem_mask, cpu_get_pc(space->cpu)); |
| 1061 | 1058 | |
| r9489 | r9490 | |
| 1071 | 1068 | { |
| 1072 | 1069 | mac_state *mac = machine->driver_data<mac_state>(); |
| 1073 | 1070 | |
| 1074 | | if ((mac->scsiirq_enable) && ((mac->model == MODEL_MAC_SE) || (mac->model == MODEL_MAC_CLASSIC))) |
| 1071 | if ((mac->m_scsiirq_enable) && ((mac->m_model == MODEL_MAC_SE) || (mac->m_model == MODEL_MAC_CLASSIC))) |
| 1075 | 1072 | { |
| 1076 | | scsi_interrupt = state; |
| 1077 | | mac_field_interrupts(machine); |
| 1073 | mac->m_scsi_interrupt = state; |
| 1074 | mac->field_interrupts(machine); |
| 1078 | 1075 | } |
| 1079 | 1076 | } |
| 1080 | 1077 | |
| r9489 | r9490 | |
| 1086 | 1083 | |
| 1087 | 1084 | void mac_scc_irq(running_device *device, int status) |
| 1088 | 1085 | { |
| 1089 | | set_scc_interrupt(device->machine, status); |
| 1086 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 1087 | |
| 1088 | mac->set_scc_interrupt(device->machine, status); |
| 1090 | 1089 | } |
| 1091 | 1090 | |
| 1092 | 1091 | |
| 1093 | 1092 | |
| 1094 | | void mac_scc_mouse_irq(running_machine *machine, int x, int y) |
| 1093 | void mac_state::scc_mouse_irq(running_machine *machine, int x, int y) |
| 1095 | 1094 | { |
| 1096 | 1095 | running_device *scc = machine->device("scc"); |
| 1097 | 1096 | static int last_was_x = 0; |
| r9489 | r9490 | |
| 1118 | 1117 | |
| 1119 | 1118 | |
| 1120 | 1119 | |
| 1121 | | READ16_HANDLER ( mac_scc_r ) |
| 1120 | READ16_MEMBER ( mac_state::mac_scc_r ) |
| 1122 | 1121 | { |
| 1123 | | running_device *scc = space->machine->device("scc"); |
| 1122 | running_device *scc = space.machine->device("scc"); |
| 1124 | 1123 | UINT16 result; |
| 1125 | 1124 | |
| 1126 | 1125 | result = scc8530_r(scc, offset); |
| r9489 | r9490 | |
| 1129 | 1128 | |
| 1130 | 1129 | |
| 1131 | 1130 | |
| 1132 | | WRITE16_HANDLER ( mac_scc_w ) |
| 1131 | WRITE16_MEMBER ( mac_state::mac_scc_w ) |
| 1133 | 1132 | { |
| 1134 | | running_device *scc = space->machine->device("scc"); |
| 1133 | running_device *scc = space.machine->device("scc"); |
| 1135 | 1134 | scc8530_w(scc, offset, (UINT8) data); |
| 1136 | 1135 | } |
| 1137 | 1136 | |
| 1138 | | WRITE16_HANDLER ( mac_scc_2_w ) |
| 1137 | WRITE16_MEMBER ( mac_state::mac_scc_2_w ) |
| 1139 | 1138 | { |
| 1140 | | running_device *scc = space->machine->device("scc"); |
| 1139 | running_device *scc = space.machine->device("scc"); |
| 1141 | 1140 | UINT8 wdata = data>>8; |
| 1142 | 1141 | scc8530_w(scc, offset, wdata); |
| 1143 | 1142 | } |
| r9489 | r9490 | |
| 1150 | 1149 | * Real Time Clock chip - contains clock information and PRAM. This chip is |
| 1151 | 1150 | * accessed through the VIA |
| 1152 | 1151 | * *************************************************************************/ |
| 1153 | | |
| 1154 | | /* a few protos */ |
| 1155 | | static void rtc_write_rTCEnb(mac_state *mac, int data); |
| 1156 | | static void rtc_execute_cmd(mac_state *mac, int data); |
| 1157 | | |
| 1158 | 1152 | enum |
| 1159 | 1153 | { |
| 1160 | 1154 | RTC_STATE_NORMAL, |
| r9489 | r9490 | |
| 1164 | 1158 | }; |
| 1165 | 1159 | |
| 1166 | 1160 | /* init the rtc core */ |
| 1167 | | static void rtc_init(mac_state *mac) |
| 1161 | void mac_state::rtc_init() |
| 1168 | 1162 | { |
| 1169 | | mac->rtc_rTCClk = 0; |
| 1163 | m_rtc_rTCClk = 0; |
| 1170 | 1164 | |
| 1171 | | mac->rtc_write_protect = 0; |
| 1172 | | mac->rtc_rTCEnb = 0; |
| 1173 | | rtc_write_rTCEnb(mac, 1); |
| 1174 | | mac->rtc_state = RTC_STATE_NORMAL; |
| 1165 | m_rtc_write_protect = 0; |
| 1166 | m_rtc_rTCEnb = 0; |
| 1167 | rtc_write_rTCEnb(1); |
| 1168 | m_rtc_state = RTC_STATE_NORMAL; |
| 1175 | 1169 | } |
| 1176 | 1170 | |
| 1177 | 1171 | /* write the rTCEnb state */ |
| 1178 | | static void rtc_write_rTCEnb(mac_state *mac, int val) |
| 1172 | void mac_state::rtc_write_rTCEnb(int val) |
| 1179 | 1173 | { |
| 1180 | | if (val && (! mac->rtc_rTCEnb)) |
| 1174 | if (val && (! m_rtc_rTCEnb)) |
| 1181 | 1175 | { |
| 1182 | 1176 | /* rTCEnb goes high (inactive) */ |
| 1183 | | mac->rtc_rTCEnb = 1; |
| 1177 | m_rtc_rTCEnb = 1; |
| 1184 | 1178 | /* abort current transmission */ |
| 1185 | | mac->rtc_data_byte = mac->rtc_bit_count = mac->rtc_data_dir = mac->rtc_data_out = 0; |
| 1186 | | mac->rtc_state = RTC_STATE_NORMAL; |
| 1179 | m_rtc_data_byte = m_rtc_bit_count = m_rtc_data_dir = m_rtc_data_out = 0; |
| 1180 | m_rtc_state = RTC_STATE_NORMAL; |
| 1187 | 1181 | } |
| 1188 | | else if ((! val) && mac->rtc_rTCEnb) |
| 1182 | else if ((! val) && m_rtc_rTCEnb) |
| 1189 | 1183 | { |
| 1190 | 1184 | /* rTCEnb goes low (active) */ |
| 1191 | | mac->rtc_rTCEnb = 0; |
| 1185 | m_rtc_rTCEnb = 0; |
| 1192 | 1186 | /* abort current transmission */ |
| 1193 | | mac->rtc_data_byte = mac->rtc_bit_count = mac->rtc_data_dir = mac->rtc_data_out = 0; |
| 1194 | | mac->rtc_state = RTC_STATE_NORMAL; |
| 1187 | m_rtc_data_byte = m_rtc_bit_count = m_rtc_data_dir = m_rtc_data_out = 0; |
| 1188 | m_rtc_state = RTC_STATE_NORMAL; |
| 1195 | 1189 | } |
| 1196 | 1190 | } |
| 1197 | 1191 | |
| 1198 | 1192 | /* shift data (called on rTCClk high-to-low transition (?)) */ |
| 1199 | | static void rtc_shift_data(mac_state *mac, int data) |
| 1193 | void mac_state::rtc_shift_data(int data) |
| 1200 | 1194 | { |
| 1201 | | if (mac->rtc_rTCEnb) |
| 1195 | if (m_rtc_rTCEnb) |
| 1202 | 1196 | /* if enable line inactive (high), do nothing */ |
| 1203 | 1197 | return; |
| 1204 | 1198 | |
| 1205 | | if (mac->rtc_data_dir) |
| 1199 | if (m_rtc_data_dir) |
| 1206 | 1200 | { /* RTC -> VIA transmission */ |
| 1207 | | mac->rtc_data_out = (mac->rtc_data_byte >> --mac->rtc_bit_count) & 0x01; |
| 1201 | m_rtc_data_out = (m_rtc_data_byte >> --m_rtc_bit_count) & 0x01; |
| 1208 | 1202 | if (LOG_RTC) |
| 1209 | | logerror("RTC shifted new data %d\n", mac->rtc_data_out); |
| 1203 | logerror("RTC shifted new data %d\n", m_rtc_data_out); |
| 1210 | 1204 | } |
| 1211 | 1205 | else |
| 1212 | 1206 | { /* VIA -> RTC transmission */ |
| 1213 | | mac->rtc_data_byte = (mac->rtc_data_byte << 1) | (data ? 1 : 0); |
| 1207 | m_rtc_data_byte = (m_rtc_data_byte << 1) | (data ? 1 : 0); |
| 1214 | 1208 | |
| 1215 | | if (++mac->rtc_bit_count == 8) |
| 1209 | if (++m_rtc_bit_count == 8) |
| 1216 | 1210 | { /* if one byte received, send to command interpreter */ |
| 1217 | | rtc_execute_cmd(mac, mac->rtc_data_byte); |
| 1211 | rtc_execute_cmd(m_rtc_data_byte); |
| 1218 | 1212 | } |
| 1219 | 1213 | } |
| 1220 | 1214 | } |
| 1221 | 1215 | |
| 1222 | 1216 | /* called every second, to increment the Clock count */ |
| 1223 | | static void rtc_incticks(mac_state *mac) |
| 1217 | void mac_state::rtc_incticks() |
| 1224 | 1218 | { |
| 1225 | 1219 | if (LOG_RTC) |
| 1226 | 1220 | logerror("rtc_incticks called\n"); |
| 1227 | 1221 | |
| 1228 | | if (++mac->rtc_seconds[0] == 0) |
| 1229 | | if (++mac->rtc_seconds[1] == 0) |
| 1230 | | if (++mac->rtc_seconds[2] == 0) |
| 1231 | | ++mac->rtc_seconds[3]; |
| 1222 | if (++m_rtc_seconds[0] == 0) |
| 1223 | if (++m_rtc_seconds[1] == 0) |
| 1224 | if (++m_rtc_seconds[2] == 0) |
| 1225 | ++m_rtc_seconds[3]; |
| 1232 | 1226 | |
| 1233 | | /*if (++mac->rtc_seconds[4] == 0) |
| 1234 | | if (++mac->rtc_seconds[5] == 0) |
| 1235 | | if (++mac->rtc_seconds[6] == 0) |
| 1236 | | ++mac->rtc_seconds[7];*/ |
| 1227 | /*if (++m_rtc_seconds[4] == 0) |
| 1228 | if (++m_rtc_seconds[5] == 0) |
| 1229 | if (++m_rtc_seconds[6] == 0) |
| 1230 | ++m_rtc_seconds[7];*/ |
| 1237 | 1231 | } |
| 1238 | 1232 | |
| 1239 | 1233 | /* Executes a command. |
| 1240 | 1234 | Called when the first byte after "enable" is received, and when the data byte after a write command |
| 1241 | 1235 | is received. */ |
| 1242 | | static void rtc_execute_cmd(mac_state *mac, int data) |
| 1236 | void mac_state::rtc_execute_cmd(int data) |
| 1243 | 1237 | { |
| 1244 | 1238 | int i; |
| 1245 | 1239 | |
| 1246 | 1240 | if (LOG_RTC) |
| 1247 | | logerror("rtc_execute_cmd: data=%x, state=%x\n", data, mac->rtc_state); |
| 1241 | logerror("rtc_execute_cmd: data=%x, state=%x\n", data, m_rtc_state); |
| 1248 | 1242 | |
| 1249 | | if (mac->rtc_state == RTC_STATE_XPCOMMAND) |
| 1243 | if (m_rtc_state == RTC_STATE_XPCOMMAND) |
| 1250 | 1244 | { |
| 1251 | | mac->rtc_xpaddr = ((mac->rtc_cmd & 7)<<5) | ((data&0x7c)>>2); |
| 1252 | | if ((mac->rtc_cmd & 0x80) != 0) |
| 1245 | m_rtc_xpaddr = ((m_rtc_cmd & 7)<<5) | ((data&0x7c)>>2); |
| 1246 | if ((m_rtc_cmd & 0x80) != 0) |
| 1253 | 1247 | { |
| 1254 | 1248 | // read command |
| 1255 | 1249 | if (LOG_RTC) |
| 1256 | | logerror("RTC: Reading extended address %x = %x\n", mac->rtc_xpaddr, mac->rtc_ram[mac->rtc_xpaddr]); |
| 1250 | logerror("RTC: Reading extended address %x = %x\n", m_rtc_xpaddr, m_rtc_ram[m_rtc_xpaddr]); |
| 1257 | 1251 | |
| 1258 | | mac->rtc_data_dir = 1; |
| 1259 | | mac->rtc_data_byte = mac->rtc_ram[mac->rtc_xpaddr]; |
| 1260 | | mac->rtc_state = RTC_STATE_NORMAL; |
| 1252 | m_rtc_data_dir = 1; |
| 1253 | m_rtc_data_byte = m_rtc_ram[m_rtc_xpaddr]; |
| 1254 | m_rtc_state = RTC_STATE_NORMAL; |
| 1261 | 1255 | } |
| 1262 | 1256 | else |
| 1263 | 1257 | { |
| 1264 | 1258 | // write command |
| 1265 | | mac->rtc_state = RTC_STATE_XPWRITE; |
| 1266 | | mac->rtc_data_byte = 0; |
| 1267 | | mac->rtc_bit_count = 0; |
| 1259 | m_rtc_state = RTC_STATE_XPWRITE; |
| 1260 | m_rtc_data_byte = 0; |
| 1261 | m_rtc_bit_count = 0; |
| 1268 | 1262 | } |
| 1269 | 1263 | } |
| 1270 | | else if (mac->rtc_state == RTC_STATE_XPWRITE) |
| 1264 | else if (m_rtc_state == RTC_STATE_XPWRITE) |
| 1271 | 1265 | { |
| 1272 | 1266 | if (LOG_RTC) |
| 1273 | | logerror("RTC: writing %x to extended address %x\n", data, mac->rtc_xpaddr); |
| 1274 | | mac->rtc_ram[mac->rtc_xpaddr] = data; |
| 1275 | | mac->rtc_state = RTC_STATE_NORMAL; |
| 1267 | logerror("RTC: writing %x to extended address %x\n", data, m_rtc_xpaddr); |
| 1268 | m_rtc_ram[m_rtc_xpaddr] = data; |
| 1269 | m_rtc_state = RTC_STATE_NORMAL; |
| 1276 | 1270 | } |
| 1277 | | else if (mac->rtc_state == RTC_STATE_WRITE) |
| 1271 | else if (m_rtc_state == RTC_STATE_WRITE) |
| 1278 | 1272 | { |
| 1279 | | mac->rtc_state = RTC_STATE_NORMAL; |
| 1273 | m_rtc_state = RTC_STATE_NORMAL; |
| 1280 | 1274 | |
| 1281 | 1275 | /* Writing an RTC register */ |
| 1282 | | i = (mac->rtc_cmd >> 2) & 0x1f; |
| 1283 | | if (mac->rtc_write_protect && (i != 13)) |
| 1276 | i = (m_rtc_cmd >> 2) & 0x1f; |
| 1277 | if (m_rtc_write_protect && (i != 13)) |
| 1284 | 1278 | /* write-protection : only write-protect can be written again */ |
| 1285 | 1279 | return; |
| 1286 | 1280 | switch(i) |
| 1287 | 1281 | { |
| 1288 | 1282 | case 0: case 1: case 2: case 3: /* seconds register */ |
| 1289 | 1283 | case 4: case 5: case 6: case 7: /* ??? (not described in IM III) */ |
| 1290 | | /* after various tries, I assumed mac->rtc_seconds[4+i] is mapped to mac->rtc_seconds[i] */ |
| 1284 | /* after various tries, I assumed m_rtc_seconds[4+i] is mapped to m_rtc_seconds[i] */ |
| 1291 | 1285 | if (LOG_RTC) |
| 1292 | | logerror("RTC clock write, address = %X, data = %X\n", i, (int) mac->rtc_data_byte); |
| 1293 | | mac->rtc_seconds[i & 3] = mac->rtc_data_byte; |
| 1286 | logerror("RTC clock write, address = %X, data = %X\n", i, (int) m_rtc_data_byte); |
| 1287 | m_rtc_seconds[i & 3] = m_rtc_data_byte; |
| 1294 | 1288 | break; |
| 1295 | 1289 | |
| 1296 | 1290 | case 8: case 9: case 10: case 11: /* RAM address $10-$13 */ |
| 1297 | 1291 | if (LOG_RTC) |
| 1298 | | logerror("RTC RAM write, address = %X, data = %X\n", (i & 3) + 0x10, (int) mac->rtc_data_byte); |
| 1299 | | mac->rtc_ram[(i & 3) + 0x10] = mac->rtc_data_byte; |
| 1292 | logerror("RTC RAM write, address = %X, data = %X\n", (i & 3) + 0x10, (int) m_rtc_data_byte); |
| 1293 | m_rtc_ram[(i & 3) + 0x10] = m_rtc_data_byte; |
| 1300 | 1294 | break; |
| 1301 | 1295 | |
| 1302 | 1296 | case 12: |
| 1303 | 1297 | /* Test register - do nothing */ |
| 1304 | 1298 | if (LOG_RTC) |
| 1305 | | logerror("RTC write to test register, data = %X\n", (int) mac->rtc_data_byte); |
| 1299 | logerror("RTC write to test register, data = %X\n", (int) m_rtc_data_byte); |
| 1306 | 1300 | break; |
| 1307 | 1301 | |
| 1308 | 1302 | case 13: |
| 1309 | 1303 | /* Write-protect register */ |
| 1310 | 1304 | if (LOG_RTC) |
| 1311 | | logerror("RTC write to write-protect register, data = %X\n", (int) mac->rtc_data_byte&0x80); |
| 1312 | | mac->rtc_write_protect = (mac->rtc_data_byte & 0x80) ? TRUE : FALSE; |
| 1305 | logerror("RTC write to write-protect register, data = %X\n", (int) m_rtc_data_byte&0x80); |
| 1306 | m_rtc_write_protect = (m_rtc_data_byte & 0x80) ? TRUE : FALSE; |
| 1313 | 1307 | break; |
| 1314 | 1308 | |
| 1315 | 1309 | case 16: case 17: case 18: case 19: /* RAM address $00-$0f */ |
| r9489 | r9490 | |
| 1317 | 1311 | case 24: case 25: case 26: case 27: |
| 1318 | 1312 | case 28: case 29: case 30: case 31: |
| 1319 | 1313 | if (LOG_RTC) |
| 1320 | | logerror("RTC RAM write, address = %X, data = %X\n", i & 15, (int) mac->rtc_data_byte); |
| 1321 | | mac->rtc_ram[i & 15] = mac->rtc_data_byte; |
| 1314 | logerror("RTC RAM write, address = %X, data = %X\n", i & 15, (int) m_rtc_data_byte); |
| 1315 | m_rtc_ram[i & 15] = m_rtc_data_byte; |
| 1322 | 1316 | break; |
| 1323 | 1317 | |
| 1324 | 1318 | default: |
| 1325 | | printf("Unknown RTC write command : %X, data = %d\n", (int) mac->rtc_cmd, (int) mac->rtc_data_byte); |
| 1319 | printf("Unknown RTC write command : %X, data = %d\n", (int) m_rtc_cmd, (int) m_rtc_data_byte); |
| 1326 | 1320 | break; |
| 1327 | 1321 | } |
| 1328 | 1322 | } |
| 1329 | 1323 | else |
| 1330 | 1324 | { |
| 1331 | | // always save this byte to mac->rtc_cmd |
| 1332 | | mac->rtc_cmd = mac->rtc_data_byte; |
| 1325 | // always save this byte to m_rtc_cmd |
| 1326 | m_rtc_cmd = m_rtc_data_byte; |
| 1333 | 1327 | |
| 1334 | | if ((mac->rtc_cmd & 0x78) == 0x38) // extended command |
| 1328 | if ((m_rtc_cmd & 0x78) == 0x38) // extended command |
| 1335 | 1329 | { |
| 1336 | | mac->rtc_state = RTC_STATE_XPCOMMAND; |
| 1337 | | mac->rtc_data_byte = 0; |
| 1338 | | mac->rtc_bit_count = 0; |
| 1330 | m_rtc_state = RTC_STATE_XPCOMMAND; |
| 1331 | m_rtc_data_byte = 0; |
| 1332 | m_rtc_bit_count = 0; |
| 1339 | 1333 | } |
| 1340 | 1334 | else |
| 1341 | 1335 | { |
| 1342 | | if (mac->rtc_cmd & 0x80) |
| 1336 | if (m_rtc_cmd & 0x80) |
| 1343 | 1337 | { |
| 1344 | | mac->rtc_state = RTC_STATE_NORMAL; |
| 1338 | m_rtc_state = RTC_STATE_NORMAL; |
| 1345 | 1339 | |
| 1346 | 1340 | /* Reading an RTC register */ |
| 1347 | | mac->rtc_data_dir = 1; |
| 1348 | | i = (mac->rtc_cmd >> 2) & 0x1f; |
| 1341 | m_rtc_data_dir = 1; |
| 1342 | i = (m_rtc_cmd >> 2) & 0x1f; |
| 1349 | 1343 | switch(i) |
| 1350 | 1344 | { |
| 1351 | 1345 | case 0: case 1: case 2: case 3: |
| 1352 | 1346 | case 4: case 5: case 6: case 7: |
| 1353 | | mac->rtc_data_byte = mac->rtc_seconds[i & 3]; |
| 1347 | m_rtc_data_byte = m_rtc_seconds[i & 3]; |
| 1354 | 1348 | if (LOG_RTC) |
| 1355 | | logerror("RTC clock read, address = %X -> data = %X\n", i, mac->rtc_data_byte); |
| 1349 | logerror("RTC clock read, address = %X -> data = %X\n", i, m_rtc_data_byte); |
| 1356 | 1350 | break; |
| 1357 | 1351 | |
| 1358 | 1352 | case 8: case 9: case 10: case 11: |
| 1359 | 1353 | if (LOG_RTC) |
| 1360 | | logerror("RTC RAM read, address = %X data = %x\n", (i & 3) + 0x10, mac->rtc_ram[(i & 3) + 0x10]); |
| 1361 | | mac->rtc_data_byte = mac->rtc_ram[(i & 3) + 0x10]; |
| 1354 | logerror("RTC RAM read, address = %X data = %x\n", (i & 3) + 0x10, m_rtc_ram[(i & 3) + 0x10]); |
| 1355 | m_rtc_data_byte = m_rtc_ram[(i & 3) + 0x10]; |
| 1362 | 1356 | break; |
| 1363 | 1357 | |
| 1364 | 1358 | case 16: case 17: case 18: case 19: |
| r9489 | r9490 | |
| 1366 | 1360 | case 24: case 25: case 26: case 27: |
| 1367 | 1361 | case 28: case 29: case 30: case 31: |
| 1368 | 1362 | if (LOG_RTC) |
| 1369 | | logerror("RTC RAM read, address = %X data = %x\n", i & 15, mac->rtc_ram[i & 15]); |
| 1370 | | mac->rtc_data_byte = mac->rtc_ram[i & 15]; |
| 1363 | logerror("RTC RAM read, address = %X data = %x\n", i & 15, m_rtc_ram[i & 15]); |
| 1364 | m_rtc_data_byte = m_rtc_ram[i & 15]; |
| 1371 | 1365 | break; |
| 1372 | 1366 | |
| 1373 | 1367 | default: |
| 1374 | 1368 | if (LOG_RTC) |
| 1375 | | logerror("Unknown RTC read command : %X\n", (int) mac->rtc_cmd); |
| 1376 | | mac->rtc_data_byte = 0; |
| 1369 | logerror("Unknown RTC read command : %X\n", (int) m_rtc_cmd); |
| 1370 | m_rtc_data_byte = 0; |
| 1377 | 1371 | break; |
| 1378 | 1372 | } |
| 1379 | 1373 | } |
| r9489 | r9490 | |
| 1382 | 1376 | /* Writing an RTC register */ |
| 1383 | 1377 | /* wait for extra data byte */ |
| 1384 | 1378 | if (LOG_RTC) |
| 1385 | | logerror("RTC write, waiting for data byte : %X\n", (int) mac->rtc_cmd); |
| 1386 | | mac->rtc_state = RTC_STATE_WRITE; |
| 1387 | | mac->rtc_data_byte = 0; |
| 1388 | | mac->rtc_bit_count = 0; |
| 1379 | logerror("RTC write, waiting for data byte : %X\n", (int) m_rtc_cmd); |
| 1380 | m_rtc_state = RTC_STATE_WRITE; |
| 1381 | m_rtc_data_byte = 0; |
| 1382 | m_rtc_bit_count = 0; |
| 1389 | 1383 | } |
| 1390 | 1384 | } |
| 1391 | 1385 | } |
| r9489 | r9490 | |
| 1401 | 1395 | { |
| 1402 | 1396 | if (LOG_RTC) |
| 1403 | 1397 | logerror("Writing PRAM to file\n"); |
| 1404 | | mame_fwrite(file, mac->rtc_ram, sizeof(mac->rtc_ram)); |
| 1398 | mame_fwrite(file, mac->m_rtc_ram, sizeof(mac->m_rtc_ram)); |
| 1405 | 1399 | } |
| 1406 | 1400 | else |
| 1407 | 1401 | { |
| r9489 | r9490 | |
| 1409 | 1403 | { |
| 1410 | 1404 | if (LOG_RTC) |
| 1411 | 1405 | logerror("Reading PRAM from file\n"); |
| 1412 | | mame_fread(file, mac->rtc_ram, sizeof(mac->rtc_ram)); |
| 1406 | mame_fread(file, mac->m_rtc_ram, sizeof(mac->m_rtc_ram)); |
| 1413 | 1407 | } |
| 1414 | 1408 | else |
| 1415 | 1409 | { |
| 1416 | 1410 | if (LOG_RTC) |
| 1417 | 1411 | logerror("trashing PRAM\n"); |
| 1418 | 1412 | |
| 1419 | | memset(mac->rtc_ram, 0, sizeof(mac->rtc_ram)); |
| 1413 | memset(mac->m_rtc_ram, 0, sizeof(mac->m_rtc_ram)); |
| 1420 | 1414 | |
| 1421 | 1415 | // some Mac ROMs are buggy in the presence of |
| 1422 | 1416 | // no NVRAM, so let's initialize it right |
| 1423 | | mac->rtc_ram[0] = 0xa8; // valid |
| 1424 | | mac->rtc_ram[4] = 0xcc; |
| 1425 | | mac->rtc_ram[5] = 0x0a; |
| 1426 | | mac->rtc_ram[6] = 0xcc; |
| 1427 | | mac->rtc_ram[7] = 0x0a; |
| 1428 | | mac->rtc_ram[0xc] = 0x42; // XPRAM valid for Plus/SE |
| 1429 | | mac->rtc_ram[0xd] = 0x75; |
| 1430 | | mac->rtc_ram[0xe] = 0x67; |
| 1431 | | mac->rtc_ram[0xf] = 0x73; |
| 1432 | | mac->rtc_ram[0x10] = 0x18; |
| 1433 | | mac->rtc_ram[0x11] = 0x88; |
| 1434 | | mac->rtc_ram[0x12] = 0x01; |
| 1435 | | mac->rtc_ram[0x13] = 0x4c; |
| 1417 | mac->m_rtc_ram[0] = 0xa8; // valid |
| 1418 | mac->m_rtc_ram[4] = 0xcc; |
| 1419 | mac->m_rtc_ram[5] = 0x0a; |
| 1420 | mac->m_rtc_ram[6] = 0xcc; |
| 1421 | mac->m_rtc_ram[7] = 0x0a; |
| 1422 | mac->m_rtc_ram[0xc] = 0x42; // XPRAM valid for Plus/SE |
| 1423 | mac->m_rtc_ram[0xd] = 0x75; |
| 1424 | mac->m_rtc_ram[0xe] = 0x67; |
| 1425 | mac->m_rtc_ram[0xf] = 0x73; |
| 1426 | mac->m_rtc_ram[0x10] = 0x18; |
| 1427 | mac->m_rtc_ram[0x11] = 0x88; |
| 1428 | mac->m_rtc_ram[0x12] = 0x01; |
| 1429 | mac->m_rtc_ram[0x13] = 0x4c; |
| 1436 | 1430 | |
| 1437 | | if (mac->model >= MODEL_MAC_II) |
| 1431 | if (mac->m_model >= MODEL_MAC_II) |
| 1438 | 1432 | { |
| 1439 | | mac->rtc_ram[0xc] = 0x4e; // XPRAM valid is different for these |
| 1440 | | mac->rtc_ram[0xd] = 0x75; |
| 1441 | | mac->rtc_ram[0xe] = 0x4d; |
| 1442 | | mac->rtc_ram[0xf] = 0x63; |
| 1443 | | mac->rtc_ram[0x77] = 0x01; |
| 1444 | | mac->rtc_ram[0x78] = 0xff; |
| 1445 | | mac->rtc_ram[0x79] = 0xff; |
| 1446 | | mac->rtc_ram[0x7a] = 0xff; |
| 1447 | | mac->rtc_ram[0x7b] = 0xdf; |
| 1433 | mac->m_rtc_ram[0xc] = 0x4e; // XPRAM valid is different for these |
| 1434 | mac->m_rtc_ram[0xd] = 0x75; |
| 1435 | mac->m_rtc_ram[0xe] = 0x4d; |
| 1436 | mac->m_rtc_ram[0xf] = 0x63; |
| 1437 | mac->m_rtc_ram[0x77] = 0x01; |
| 1438 | mac->m_rtc_ram[0x78] = 0xff; |
| 1439 | mac->m_rtc_ram[0x79] = 0xff; |
| 1440 | mac->m_rtc_ram[0x7a] = 0xff; |
| 1441 | mac->m_rtc_ram[0x7b] = 0xdf; |
| 1448 | 1442 | } |
| 1449 | 1443 | } |
| 1450 | 1444 | |
| r9489 | r9490 | |
| 1471 | 1465 | if (LOG_RTC) |
| 1472 | 1466 | logerror("second count 0x%lX\n", (unsigned long) seconds); |
| 1473 | 1467 | |
| 1474 | | mac->rtc_seconds[0] = seconds & 0xff; |
| 1475 | | mac->rtc_seconds[1] = (seconds >> 8) & 0xff; |
| 1476 | | mac->rtc_seconds[2] = (seconds >> 16) & 0xff; |
| 1477 | | mac->rtc_seconds[3] = (seconds >> 24) & 0xff; |
| 1468 | mac->m_rtc_seconds[0] = seconds & 0xff; |
| 1469 | mac->m_rtc_seconds[1] = (seconds >> 8) & 0xff; |
| 1470 | mac->m_rtc_seconds[2] = (seconds >> 16) & 0xff; |
| 1471 | mac->m_rtc_seconds[3] = (seconds >> 24) & 0xff; |
| 1478 | 1472 | } |
| 1479 | 1473 | } |
| 1480 | 1474 | } |
| r9489 | r9490 | |
| 1483 | 1477 | * IWM Code specific to the Mac Plus * |
| 1484 | 1478 | * ********************************** */ |
| 1485 | 1479 | |
| 1486 | | READ16_HANDLER ( mac_iwm_r ) |
| 1480 | READ16_MEMBER ( mac_state::mac_iwm_r ) |
| 1487 | 1481 | { |
| 1488 | 1482 | /* The first time this is called is in a floppy test, which goes from |
| 1489 | 1483 | * $400104 to $400126. After that, all access to the floppy goes through |
| r9489 | r9490 | |
| 1494 | 1488 | */ |
| 1495 | 1489 | |
| 1496 | 1490 | UINT16 result = 0; |
| 1497 | | running_device *fdc = space->machine->device("fdc"); |
| 1491 | running_device *fdc = space.machine->device("fdc"); |
| 1498 | 1492 | |
| 1499 | 1493 | if (LOG_MAC_IWM) |
| 1500 | | logerror("mac_iwm_r: offset=0x%08x mem_mask %04x (PC %x)\n", offset, mem_mask, cpu_get_pc(space->cpu)); |
| 1494 | logerror("mac_iwm_r: offset=0x%08x mem_mask %04x (PC %x)\n", offset, mem_mask, cpu_get_pc(space.cpu)); |
| 1501 | 1495 | |
| 1502 | 1496 | result = applefdc_r(fdc, (offset >> 8)); |
| 1503 | 1497 | return (result << 8) | result; |
| 1504 | 1498 | } |
| 1505 | 1499 | |
| 1506 | | WRITE16_HANDLER ( mac_iwm_w ) |
| 1500 | WRITE16_MEMBER ( mac_state::mac_iwm_w ) |
| 1507 | 1501 | { |
| 1508 | | running_device *fdc = space->machine->device("fdc"); |
| 1502 | running_device *fdc = space.machine->device("fdc"); |
| 1509 | 1503 | |
| 1510 | 1504 | if (LOG_MAC_IWM) |
| 1511 | | logerror("mac_iwm_w: offset=0x%08x data=0x%04x mask %04x (PC=%x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu)); |
| 1505 | logerror("mac_iwm_w: offset=0x%08x data=0x%04x mask %04x (PC=%x)\n", offset, data, mem_mask, cpu_get_pc(space.cpu)); |
| 1512 | 1506 | |
| 1513 | 1507 | if (ACCESSING_BITS_0_7) |
| 1514 | 1508 | applefdc_w(fdc, (offset >> 8), data & 0xff); |
| r9489 | r9490 | |
| 1546 | 1540 | keybuf = input_port_read(machine, keynames[i]); |
| 1547 | 1541 | |
| 1548 | 1542 | // any changes in this row? |
| 1549 | | if ((keybuf != mac->key_matrix[i]) && (report < 2)) |
| 1543 | if ((keybuf != mac->m_key_matrix[i]) && (report < 2)) |
| 1550 | 1544 | { |
| 1551 | 1545 | // check each column bit |
| 1552 | 1546 | for (j=0; j<16; j++) |
| 1553 | 1547 | { |
| 1554 | | if (((keybuf ^ mac->key_matrix[i]) >> j) & 1) |
| 1548 | if (((keybuf ^ mac->m_key_matrix[i]) >> j) & 1) |
| 1555 | 1549 | { |
| 1556 | | // update mac->key_matrix |
| 1550 | // update mac->m_key_matrix |
| 1557 | 1551 | if (update) |
| 1558 | 1552 | { |
| 1559 | | mac->key_matrix[i] = (mac->key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j)); |
| 1553 | mac->m_key_matrix[i] = (mac->m_key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j)); |
| 1560 | 1554 | } |
| 1561 | 1555 | |
| 1562 | 1556 | codes[report] = (i<<4)|j; |
| r9489 | r9490 | |
| 1732 | 1726 | int addr, reg; |
| 1733 | 1727 | mac_state *mac = machine->driver_data<mac_state>(); |
| 1734 | 1728 | |
| 1735 | | addr = (mac->adb_command>>4); |
| 1736 | | reg = (mac->adb_command & 3); |
| 1729 | addr = (mac->m_adb_command>>4); |
| 1730 | reg = (mac->m_adb_command & 3); |
| 1737 | 1731 | |
| 1738 | | // printf("Mac sent %x (cmd %d addr %d reg %d mr %d kr %d)\n", mac->adb_command, (mac->adb_command>>2)&3, addr, reg, adb_mouseaddr, adb_keybaddr); |
| 1732 | // printf("Mac sent %x (cmd %d addr %d reg %d mr %d kr %d)\n", mac->m_adb_command, (mac->m_adb_command>>2)&3, addr, reg, adb_mouseaddr, adb_keybaddr); |
| 1739 | 1733 | |
| 1740 | | if (mac->adb_waiting_cmd) |
| 1734 | if (mac->m_adb_waiting_cmd) |
| 1741 | 1735 | { |
| 1742 | | switch ((mac->adb_command>>2)&3) |
| 1736 | switch ((mac->m_adb_command>>2)&3) |
| 1743 | 1737 | { |
| 1744 | 1738 | case 0: |
| 1745 | 1739 | case 1: |
| r9489 | r9490 | |
| 1749 | 1743 | #if LOG_ADB |
| 1750 | 1744 | printf("ADB RESET: reg %x address %x\n", reg, addr); |
| 1751 | 1745 | #endif |
| 1752 | | mac->adb_direction = 0; |
| 1753 | | mac->adb_send = 0; |
| 1746 | mac->m_adb_direction = 0; |
| 1747 | mac->m_adb_send = 0; |
| 1754 | 1748 | break; |
| 1755 | 1749 | |
| 1756 | 1750 | case ADB_CMD_FLUSH: |
| r9489 | r9490 | |
| 1758 | 1752 | printf("ADB FLUSH: reg %x address %x\n", reg, addr); |
| 1759 | 1753 | #endif |
| 1760 | 1754 | |
| 1761 | | mac->adb_direction = 0; |
| 1762 | | mac->adb_send = 0; |
| 1755 | mac->m_adb_direction = 0; |
| 1756 | mac->m_adb_send = 0; |
| 1763 | 1757 | break; |
| 1764 | 1758 | |
| 1765 | 1759 | default: // reserved/unused |
| r9489 | r9490 | |
| 1772 | 1766 | printf("ADB LISTEN: reg %x address %x\n", reg, addr); |
| 1773 | 1767 | #endif |
| 1774 | 1768 | |
| 1775 | | mac->adb_direction = 1; // input from Mac |
| 1776 | | mac->adb_listenreg = reg; |
| 1777 | | mac->adb_listenaddr = addr; |
| 1778 | | mac->adb_command = 0; |
| 1769 | mac->m_adb_direction = 1; // input from Mac |
| 1770 | mac->m_adb_listenreg = reg; |
| 1771 | mac->m_adb_listenaddr = addr; |
| 1772 | mac->m_adb_command = 0; |
| 1779 | 1773 | break; |
| 1780 | 1774 | |
| 1781 | 1775 | case 3: // talk |
| r9489 | r9490 | |
| 1784 | 1778 | #endif |
| 1785 | 1779 | |
| 1786 | 1780 | // keep track of what device the Mac last TALKed to |
| 1787 | | mac->adb_last_talk = addr; |
| 1781 | mac->m_adb_last_talk = addr; |
| 1788 | 1782 | |
| 1789 | | mac->adb_direction = 0; // output to Mac |
| 1783 | mac->m_adb_direction = 0; // output to Mac |
| 1790 | 1784 | if (addr == adb_mouseaddr) |
| 1791 | 1785 | { |
| 1792 | 1786 | UINT8 mouseX, mouseY; |
| r9489 | r9490 | |
| 1799 | 1793 | { |
| 1800 | 1794 | // read mouse |
| 1801 | 1795 | case 0: |
| 1802 | | if (mac->adb_srq_switch) |
| 1796 | if (mac->m_adb_srq_switch) |
| 1803 | 1797 | { |
| 1804 | | mac->adb_srq_switch = 0; |
| 1798 | mac->m_adb_srq_switch = 0; |
| 1805 | 1799 | mouseX = mouseY = 0; |
| 1806 | 1800 | } |
| 1807 | 1801 | else |
| 1808 | 1802 | { |
| 1809 | 1803 | mac_adb_accummouse(machine, &mouseX, &mouseY); |
| 1810 | 1804 | } |
| 1811 | | mac->adb_buffer[0] = (adb_lastbutton & 0x01) ? 0x00 : 0x80; |
| 1812 | | mac->adb_buffer[0] |= mouseX & 0x7f; |
| 1813 | | mac->adb_buffer[1] = mouseY & 0x7f; |
| 1814 | | mac->adb_datasize = 2; |
| 1805 | mac->m_adb_buffer[0] = (adb_lastbutton & 0x01) ? 0x00 : 0x80; |
| 1806 | mac->m_adb_buffer[0] |= mouseX & 0x7f; |
| 1807 | mac->m_adb_buffer[1] = mouseY & 0x7f; |
| 1808 | mac->m_adb_datasize = 2; |
| 1815 | 1809 | break; |
| 1816 | 1810 | |
| 1817 | 1811 | // get ID/handler |
| 1818 | 1812 | case 3: |
| 1819 | | mac->adb_buffer[0] = 0x60 | ((adb_mouseaddr<<8)&0xf); // SRQ enable, no exceptional event |
| 1820 | | mac->adb_buffer[1] = 0x01; // handler 1 |
| 1821 | | mac->adb_datasize = 2; |
| 1813 | mac->m_adb_buffer[0] = 0x60 | ((adb_mouseaddr<<8)&0xf); // SRQ enable, no exceptional event |
| 1814 | mac->m_adb_buffer[1] = 0x01; // handler 1 |
| 1815 | mac->m_adb_datasize = 2; |
| 1822 | 1816 | |
| 1823 | 1817 | adb_mouse_initialized = 1; |
| 1824 | 1818 | break; |
| r9489 | r9490 | |
| 1837 | 1831 | { |
| 1838 | 1832 | // read keyboard |
| 1839 | 1833 | case 0: |
| 1840 | | if (mac->adb_srq_switch) |
| 1834 | if (mac->m_adb_srq_switch) |
| 1841 | 1835 | { |
| 1842 | | mac->adb_srq_switch = 0; |
| 1836 | mac->m_adb_srq_switch = 0; |
| 1843 | 1837 | } |
| 1844 | 1838 | else |
| 1845 | 1839 | { |
| 1846 | 1840 | mac_adb_pollkbd(machine, 1); |
| 1847 | 1841 | } |
| 1848 | 1842 | // printf("keyboard = %02x %02x\n", adb_currentkeys[0], adb_currentkeys[1]); |
| 1849 | | mac->adb_buffer[0] = adb_currentkeys[1]; |
| 1850 | | mac->adb_buffer[1] = adb_currentkeys[0]; |
| 1851 | | mac->adb_datasize = 2; |
| 1843 | mac->m_adb_buffer[0] = adb_currentkeys[1]; |
| 1844 | mac->m_adb_buffer[1] = adb_currentkeys[0]; |
| 1845 | mac->m_adb_datasize = 2; |
| 1852 | 1846 | break; |
| 1853 | 1847 | |
| 1854 | 1848 | // read modifier keys |
| 1855 | 1849 | case 2: |
| 1856 | 1850 | mac_adb_pollkbd(machine, 1); |
| 1857 | | mac->adb_buffer[0] = adb_modifiers; // nothing pressed |
| 1858 | | mac->adb_buffer[1] = 0; |
| 1859 | | mac->adb_datasize = 2; |
| 1851 | mac->m_adb_buffer[0] = adb_modifiers; // nothing pressed |
| 1852 | mac->m_adb_buffer[1] = 0; |
| 1853 | mac->m_adb_datasize = 2; |
| 1860 | 1854 | break; |
| 1861 | 1855 | |
| 1862 | 1856 | // get ID/handler |
| 1863 | 1857 | case 3: |
| 1864 | | mac->adb_buffer[0] = 0x60 | ((adb_keybaddr<<8)&0xf); // SRQ enable, no exceptional event |
| 1865 | | mac->adb_buffer[1] = 0x01; // handler 1 |
| 1866 | | mac->adb_datasize = 2; |
| 1858 | mac->m_adb_buffer[0] = 0x60 | ((adb_keybaddr<<8)&0xf); // SRQ enable, no exceptional event |
| 1859 | mac->m_adb_buffer[1] = 0x01; // handler 1 |
| 1860 | mac->m_adb_datasize = 2; |
| 1867 | 1861 | |
| 1868 | 1862 | adb_keybinitialized = 1; |
| 1869 | 1863 | break; |
| r9489 | r9490 | |
| 1877 | 1871 | #if LOG_ADB |
| 1878 | 1872 | printf("ADB: talking to unconnected device\n"); |
| 1879 | 1873 | #endif |
| 1880 | | mac->adb_buffer[0] = mac->adb_buffer[1] = 0; |
| 1881 | | mac->adb_datasize = 0; |
| 1874 | mac->m_adb_buffer[0] = mac->m_adb_buffer[1] = 0; |
| 1875 | mac->m_adb_datasize = 0; |
| 1882 | 1876 | } |
| 1883 | 1877 | break; |
| 1884 | 1878 | } |
| 1885 | 1879 | |
| 1886 | | mac->adb_waiting_cmd = 0; |
| 1880 | mac->m_adb_waiting_cmd = 0; |
| 1887 | 1881 | } |
| 1888 | 1882 | else |
| 1889 | 1883 | { |
| 1890 | 1884 | #if LOG_ADB |
| 1891 | | printf("Got LISTEN data %x for device %x reg %x\n", mac->adb_command, mac->adb_listenaddr, mac->adb_listenreg); |
| 1885 | printf("Got LISTEN data %x for device %x reg %x\n", mac->m_adb_command, mac->m_adb_listenaddr, mac->m_adb_listenreg); |
| 1892 | 1886 | #endif |
| 1893 | 1887 | |
| 1894 | | if (mac->adb_listenaddr == adb_mouseaddr) |
| 1888 | if (mac->m_adb_listenaddr == adb_mouseaddr) |
| 1895 | 1889 | { |
| 1896 | | if ((mac->adb_listenreg == 3) && (mac->adb_command > 0) && (mac->adb_command < 16)) |
| 1890 | if ((mac->m_adb_listenreg == 3) && (mac->m_adb_command > 0) && (mac->m_adb_command < 16)) |
| 1897 | 1891 | { |
| 1898 | 1892 | #if LOG_ADB |
| 1899 | | printf("MOUSE: moving to address %x\n", mac->adb_command); |
| 1893 | printf("MOUSE: moving to address %x\n", mac->m_adb_command); |
| 1900 | 1894 | #endif |
| 1901 | | adb_mouseaddr = mac->adb_command&0x0f; |
| 1895 | adb_mouseaddr = mac->m_adb_command&0x0f; |
| 1902 | 1896 | } |
| 1903 | 1897 | } |
| 1904 | | else if (mac->adb_listenaddr == adb_keybaddr) |
| 1898 | else if (mac->m_adb_listenaddr == adb_keybaddr) |
| 1905 | 1899 | { |
| 1906 | | if ((mac->adb_listenreg == 3) && (mac->adb_command > 0) && (mac->adb_command < 16)) |
| 1900 | if ((mac->m_adb_listenreg == 3) && (mac->m_adb_command > 0) && (mac->m_adb_command < 16)) |
| 1907 | 1901 | { |
| 1908 | 1902 | #if LOG_ADB |
| 1909 | | printf("KEYBOARD: moving to address %x\n", mac->adb_command); |
| 1903 | printf("KEYBOARD: moving to address %x\n", mac->m_adb_command); |
| 1910 | 1904 | #endif |
| 1911 | | adb_keybaddr = mac->adb_command&0x0f; |
| 1905 | adb_keybaddr = mac->m_adb_command&0x0f; |
| 1912 | 1906 | } |
| 1913 | 1907 | } |
| 1914 | 1908 | } |
| r9489 | r9490 | |
| 1916 | 1910 | |
| 1917 | 1911 | static TIMER_CALLBACK(mac_adb_tick) |
| 1918 | 1912 | { |
| 1919 | | via6522_device *via_0 = machine->device<via6522_device>("via6522_0"); |
| 1920 | 1913 | mac_state *mac = machine->driver_data<mac_state>(); |
| 1921 | 1914 | |
| 1922 | 1915 | // do one clock transition on CB1 to advance the VIA shifter |
| 1923 | | mac->adb_extclock ^= 1; |
| 1924 | | via_0->write_cb1(mac->adb_extclock); |
| 1925 | | mac->adb_extclock ^= 1; |
| 1926 | | via_0->write_cb1(mac->adb_extclock); |
| 1916 | mac->m_adb_extclock ^= 1; |
| 1917 | mac->m_via1->write_cb1(mac->m_adb_extclock); |
| 1918 | mac->m_adb_extclock ^= 1; |
| 1919 | mac->m_via1->write_cb1(mac->m_adb_extclock); |
| 1927 | 1920 | |
| 1928 | | mac->adb_timer_ticks--; |
| 1929 | | if (!mac->adb_timer_ticks) |
| 1921 | mac->m_adb_timer_ticks--; |
| 1922 | if (!mac->m_adb_timer_ticks) |
| 1930 | 1923 | { |
| 1931 | 1924 | timer_adjust_oneshot(mac_adb_timer, attotime_never, 0); |
| 1932 | 1925 | |
| 1933 | | if ((mac->adb_direction) && (ADB_IS_BITBANG)) |
| 1926 | if ((mac->m_adb_direction) && (ADB_IS_BITBANG)) |
| 1934 | 1927 | { |
| 1935 | 1928 | mac_adb_talk(machine); |
| 1936 | 1929 | } |
| 1937 | 1930 | else if (ADB_IS_EGRET) |
| 1938 | 1931 | { |
| 1939 | 1932 | // Egret sending a response to the 680x0? |
| 1940 | | if (mac->adb_state & 1) |
| 1933 | if (mac->m_adb_state & 1) |
| 1941 | 1934 | { |
| 1942 | | if (mac->adb_datasize > 0) |
| 1935 | if (mac->m_adb_datasize > 0) |
| 1943 | 1936 | { |
| 1944 | | mac->adb_send = mac->adb_buffer[mac->adb_datasize]; |
| 1937 | mac->m_adb_send = mac->m_adb_buffer[mac->m_adb_datasize]; |
| 1945 | 1938 | #if LOG_ADB |
| 1946 | | printf("Egret ADB: sending byte %02x, %d left\n", mac->adb_send, mac->adb_datasize-1); |
| 1939 | printf("Egret ADB: sending byte %02x, %d left\n", mac->m_adb_send, mac->m_adb_datasize-1); |
| 1947 | 1940 | #endif |
| 1948 | 1941 | |
| 1949 | | mac->adb_datasize--; |
| 1942 | mac->m_adb_datasize--; |
| 1950 | 1943 | } |
| 1951 | 1944 | else |
| 1952 | 1945 | { |
| 1953 | | switch (mac->adb_streaming) |
| 1946 | switch (mac->m_adb_streaming) |
| 1954 | 1947 | { |
| 1955 | 1948 | case MCU_STREAMING_PRAMRD: |
| 1956 | 1949 | #if LOG_ADB |
| 1957 | | printf("Egret ADB: streaming PRAM byte %02x = %02x\n", mac->adb_stream_ptr, mac->rtc_ram[mac->adb_stream_ptr]); |
| 1950 | printf("Egret ADB: streaming PRAM byte %02x = %02x\n", mac->m_adb_stream_ptr, mac->m_rtc_ram[mac->m_adb_stream_ptr]); |
| 1958 | 1951 | #endif |
| 1959 | | mac->adb_send = mac->rtc_ram[mac->adb_stream_ptr++]; |
| 1960 | | if (mac->adb_stream_ptr >= 256) |
| 1952 | mac->m_adb_send = mac->m_rtc_ram[mac->m_adb_stream_ptr++]; |
| 1953 | if (mac->m_adb_stream_ptr >= 256) |
| 1961 | 1954 | { |
| 1962 | 1955 | #if LOG_ADB |
| 1963 | 1956 | printf("Egret ADB: this is the last PRAM byte, dropping XS\n"); |
| 1964 | 1957 | #endif |
| 1965 | | mac->adb_state &= ~1; |
| 1958 | mac->m_adb_state &= ~1; |
| 1966 | 1959 | } |
| 1967 | 1960 | break; |
| 1968 | 1961 | |
| r9489 | r9490 | |
| 1970 | 1963 | #if LOG_ADB |
| 1971 | 1964 | printf("Egret ADB: trying to stream unhandled type\n"); |
| 1972 | 1965 | #endif |
| 1973 | | mac->adb_send = 0; |
| 1966 | mac->m_adb_send = 0; |
| 1974 | 1967 | break; |
| 1975 | 1968 | } |
| 1976 | 1969 | } |
| 1977 | 1970 | |
| 1978 | | // mac->adb_timer_ticks = 8; |
| 1971 | // mac->m_adb_timer_ticks = 8; |
| 1979 | 1972 | // timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 1980 | 1973 | |
| 1981 | | if ((mac->adb_datasize == 0) && (mac->adb_streaming == MCU_STREAMING_NONE)) |
| 1974 | if ((mac->m_adb_datasize == 0) && (mac->m_adb_streaming == MCU_STREAMING_NONE)) |
| 1982 | 1975 | { |
| 1983 | 1976 | #if LOG_ADB |
| 1984 | 1977 | printf("Egret ADB: this is the last byte, dropping XS\n"); |
| 1985 | 1978 | #endif |
| 1986 | | mac->adb_state &= ~1; |
| 1979 | mac->m_adb_state &= ~1; |
| 1987 | 1980 | } |
| 1988 | 1981 | } |
| 1989 | 1982 | else |
| 1990 | 1983 | { |
| 1991 | 1984 | // it's not a command byte if SS is low |
| 1992 | | if (mac->adb_state & 0x02) |
| 1985 | if (mac->m_adb_state & 0x02) |
| 1993 | 1986 | { |
| 1994 | 1987 | #if LOG_ADB |
| 1995 | | printf("Egret ADB: got command byte %02x [%02x]\n", mac->adb_command, mac->adb_datasize); |
| 1988 | printf("Egret ADB: got command byte %02x [%02x]\n", mac->m_adb_command, mac->m_adb_datasize); |
| 1996 | 1989 | #endif |
| 1997 | | mac->adb_buffer[mac->adb_datasize++] = mac->adb_command; |
| 1998 | | mac->adb_command = 0; |
| 1990 | mac->m_adb_buffer[mac->m_adb_datasize++] = mac->m_adb_command; |
| 1991 | mac->m_adb_command = 0; |
| 1999 | 1992 | } |
| 2000 | 1993 | } |
| 2001 | 1994 | } |
| r9489 | r9490 | |
| 2011 | 2004 | UINT8 ret; |
| 2012 | 2005 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 2013 | 2006 | |
| 2014 | | ret = (mac->adb_send & 0x80)>>7; |
| 2015 | | mac->adb_send <<= 1; |
| 2007 | ret = (mac->m_adb_send & 0x80)>>7; |
| 2008 | mac->m_adb_send <<= 1; |
| 2016 | 2009 | |
| 2017 | 2010 | // printf("VIA IN CB2 = %x\n", ret); |
| 2018 | 2011 | |
| r9489 | r9490 | |
| 2024 | 2017 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 2025 | 2018 | |
| 2026 | 2019 | // printf("VIA OUT CB2 = %x\n", data); |
| 2027 | | mac->adb_command <<= 1; |
| 2028 | | mac->adb_command |= data & 1; |
| 2020 | mac->m_adb_command <<= 1; |
| 2021 | mac->m_adb_command |= data & 1; |
| 2029 | 2022 | } |
| 2030 | 2023 | |
| 2031 | 2024 | static void mac_adb_newaction(mac_state *mac, int state) |
| 2032 | 2025 | { |
| 2033 | | if (state != mac->adb_state) |
| 2026 | if (state != mac->m_adb_state) |
| 2034 | 2027 | { |
| 2035 | 2028 | #if LOG_ADB |
| 2036 | 2029 | printf("New ADB state: %s\n", adb_statenames[state]); |
| 2037 | 2030 | #endif |
| 2038 | 2031 | |
| 2039 | | mac->adb_state = state; |
| 2040 | | mac->adb_timer_ticks = 8; |
| 2032 | mac->m_adb_state = state; |
| 2033 | mac->m_adb_timer_ticks = 8; |
| 2041 | 2034 | |
| 2042 | 2035 | switch (state) |
| 2043 | 2036 | { |
| 2044 | 2037 | case ADB_STATE_NEW_COMMAND: |
| 2045 | | mac->adb_command = mac->adb_send = 0; |
| 2046 | | mac->adb_direction = 1; // Mac is shifting us a command |
| 2047 | | mac->adb_waiting_cmd = 1; // we're going to get a command |
| 2048 | | mac->adb_irq_pending = 0; |
| 2038 | mac->m_adb_command = mac->m_adb_send = 0; |
| 2039 | mac->m_adb_direction = 1; // Mac is shifting us a command |
| 2040 | mac->m_adb_waiting_cmd = 1; // we're going to get a command |
| 2041 | mac->m_adb_irq_pending = 0; |
| 2049 | 2042 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2050 | 2043 | break; |
| 2051 | 2044 | |
| 2052 | 2045 | case ADB_STATE_XFER_EVEN: |
| 2053 | 2046 | case ADB_STATE_XFER_ODD: |
| 2054 | | if (mac->adb_datasize > 0) |
| 2047 | if (mac->m_adb_datasize > 0) |
| 2055 | 2048 | { |
| 2056 | 2049 | int i; |
| 2057 | 2050 | |
| 2058 | 2051 | // is something trying to send to the Mac? |
| 2059 | | if (mac->adb_direction == 0) |
| 2052 | if (mac->m_adb_direction == 0) |
| 2060 | 2053 | { |
| 2061 | 2054 | // set up the byte |
| 2062 | | mac->adb_send = mac->adb_buffer[0]; |
| 2063 | | mac->adb_datasize--; |
| 2055 | mac->m_adb_send = mac->m_adb_buffer[0]; |
| 2056 | mac->m_adb_datasize--; |
| 2064 | 2057 | |
| 2065 | 2058 | // move down the rest of the buffer, if any |
| 2066 | | for (i = 0; i < mac->adb_datasize; i++) |
| 2059 | for (i = 0; i < mac->m_adb_datasize; i++) |
| 2067 | 2060 | { |
| 2068 | | mac->adb_buffer[i] = mac->adb_buffer[i+1]; |
| 2061 | mac->m_adb_buffer[i] = mac->m_adb_buffer[i+1]; |
| 2069 | 2062 | } |
| 2070 | 2063 | } |
| 2071 | 2064 | |
| 2072 | 2065 | } |
| 2073 | 2066 | else |
| 2074 | 2067 | { |
| 2075 | | mac->adb_send = 0; |
| 2076 | | mac->adb_irq_pending = 1; |
| 2068 | mac->m_adb_send = 0; |
| 2069 | mac->m_adb_irq_pending = 1; |
| 2077 | 2070 | } |
| 2078 | 2071 | |
| 2079 | 2072 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2080 | 2073 | break; |
| 2081 | 2074 | |
| 2082 | 2075 | case ADB_STATE_IDLE: |
| 2083 | | mac->adb_irq_pending = 0; |
| 2076 | mac->m_adb_irq_pending = 0; |
| 2084 | 2077 | break; |
| 2085 | 2078 | } |
| 2086 | 2079 | } |
| r9489 | r9490 | |
| 2088 | 2081 | |
| 2089 | 2082 | static void mac_egret_response_std(mac_state *mac, int type, int flag, int cmd) |
| 2090 | 2083 | { |
| 2091 | | mac->adb_send = 0xaa; |
| 2092 | | mac->adb_buffer[3] = type; |
| 2093 | | mac->adb_buffer[2] = flag; |
| 2094 | | mac->adb_buffer[1] = cmd; |
| 2095 | | mac->adb_state |= 1; |
| 2096 | | mac->adb_timer_ticks = 8; |
| 2097 | | mac->adb_datasize = 3; |
| 2084 | mac->m_adb_send = 0xaa; |
| 2085 | mac->m_adb_buffer[3] = type; |
| 2086 | mac->m_adb_buffer[2] = flag; |
| 2087 | mac->m_adb_buffer[1] = cmd; |
| 2088 | mac->m_adb_state |= 1; |
| 2089 | mac->m_adb_timer_ticks = 8; |
| 2090 | mac->m_adb_datasize = 3; |
| 2098 | 2091 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2099 | 2092 | } |
| 2100 | 2093 | |
| 2101 | 2094 | static void mac_egret_response_read_pram(mac_state *mac, int cmd, int addr) |
| 2102 | 2095 | { |
| 2103 | | mac->adb_datasize = 4; |
| 2096 | mac->m_adb_datasize = 4; |
| 2104 | 2097 | |
| 2105 | | mac->adb_send = 0xaa; |
| 2106 | | mac->adb_buffer[4] = 1; // type |
| 2107 | | mac->adb_buffer[3] = 0; // flag |
| 2108 | | mac->adb_buffer[2] = cmd; // command |
| 2109 | | mac->adb_buffer[1] = mac->rtc_ram[addr]; |
| 2098 | mac->m_adb_send = 0xaa; |
| 2099 | mac->m_adb_buffer[4] = 1; // type |
| 2100 | mac->m_adb_buffer[3] = 0; // flag |
| 2101 | mac->m_adb_buffer[2] = cmd; // command |
| 2102 | mac->m_adb_buffer[1] = mac->m_rtc_ram[addr]; |
| 2110 | 2103 | |
| 2111 | | mac->adb_state |= 1; |
| 2112 | | mac->adb_timer_ticks = 8; |
| 2104 | mac->m_adb_state |= 1; |
| 2105 | mac->m_adb_timer_ticks = 8; |
| 2113 | 2106 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2114 | 2107 | |
| 2115 | 2108 | // read PRAM is a "streaming" command, don't drop the state line when we're out of data |
| 2116 | | mac->adb_streaming = MCU_STREAMING_PRAMRD; |
| 2117 | | mac->adb_stream_ptr = addr+1; |
| 2109 | mac->m_adb_streaming = MCU_STREAMING_PRAMRD; |
| 2110 | mac->m_adb_stream_ptr = addr+1; |
| 2118 | 2111 | } |
| 2119 | 2112 | |
| 2120 | 2113 | static void mac_egret_response_read_rtc(mac_state *mac) |
| 2121 | 2114 | { |
| 2122 | | mac->adb_datasize = 7; |
| 2115 | mac->m_adb_datasize = 7; |
| 2123 | 2116 | |
| 2124 | | mac->adb_send = 0xaa; |
| 2125 | | mac->adb_buffer[7] = 1; // type |
| 2126 | | mac->adb_buffer[6] = 0; // flag |
| 2127 | | mac->adb_buffer[5] = 7; // command |
| 2128 | | mac->adb_buffer[4] = mac->rtc_seconds[3]; |
| 2129 | | mac->adb_buffer[3] = mac->rtc_seconds[2]; |
| 2130 | | mac->adb_buffer[2] = mac->rtc_seconds[1]; |
| 2131 | | mac->adb_buffer[1] = mac->rtc_seconds[0]; |
| 2117 | mac->m_adb_send = 0xaa; |
| 2118 | mac->m_adb_buffer[7] = 1; // type |
| 2119 | mac->m_adb_buffer[6] = 0; // flag |
| 2120 | mac->m_adb_buffer[5] = 7; // command |
| 2121 | mac->m_adb_buffer[4] = mac->m_rtc_seconds[3]; |
| 2122 | mac->m_adb_buffer[3] = mac->m_rtc_seconds[2]; |
| 2123 | mac->m_adb_buffer[2] = mac->m_rtc_seconds[1]; |
| 2124 | mac->m_adb_buffer[1] = mac->m_rtc_seconds[0]; |
| 2132 | 2125 | |
| 2133 | | mac->adb_state |= 1; |
| 2134 | | mac->adb_timer_ticks = 8; |
| 2126 | mac->m_adb_state |= 1; |
| 2127 | mac->m_adb_timer_ticks = 8; |
| 2135 | 2128 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2136 | 2129 | } |
| 2137 | 2130 | |
| 2138 | 2131 | static void mac_egret_mcu_exec(mac_state *mac) |
| 2139 | 2132 | { |
| 2140 | | mac->adb_streaming = MCU_STREAMING_NONE; |
| 2141 | | switch (mac->adb_buffer[1]) |
| 2133 | mac->m_adb_streaming = MCU_STREAMING_NONE; |
| 2134 | switch (mac->m_adb_buffer[1]) |
| 2142 | 2135 | { |
| 2143 | 2136 | case 0x01: // enable/disable ADB auto-polling |
| 2144 | 2137 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2145 | | if (mac->adb_buffer[2]) |
| 2138 | if (mac->m_adb_buffer[2]) |
| 2146 | 2139 | { |
| 2147 | 2140 | printf("ADB: Egret enable ADB auto-poll\n"); |
| 2148 | 2141 | } |
| r9489 | r9490 | |
| 2157 | 2150 | |
| 2158 | 2151 | case 0x02: // read 6805 address |
| 2159 | 2152 | { |
| 2160 | | int addr = mac->adb_buffer[2]<<8 | mac->adb_buffer[3]; |
| 2153 | int addr = mac->m_adb_buffer[2]<<8 | mac->m_adb_buffer[3]; |
| 2161 | 2154 | |
| 2162 | 2155 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2163 | 2156 | printf("ADB: Egret read 6805 address %x\n", addr); |
| r9489 | r9490 | |
| 2179 | 2172 | |
| 2180 | 2173 | case 0x03: // read RTC |
| 2181 | 2174 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2182 | | printf("ADB: Egret read RTC = %08x\n", mac->rtc_seconds[3]<<24|mac->rtc_seconds[2]<<16|mac->rtc_seconds[1]<<8|mac->rtc_seconds[0]); |
| 2175 | printf("ADB: Egret read RTC = %08x\n", mac->m_rtc_seconds[3]<<24|mac->m_rtc_seconds[2]<<16|mac->m_rtc_seconds[1]<<8|mac->m_rtc_seconds[0]); |
| 2183 | 2176 | #endif |
| 2184 | 2177 | |
| 2185 | 2178 | mac_egret_response_read_rtc(mac); |
| r9489 | r9490 | |
| 2187 | 2180 | |
| 2188 | 2181 | case 0x07: // read PRAM |
| 2189 | 2182 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2190 | | printf("ADB: Egret read PRAM from %x\n", mac->adb_buffer[2]<<8 | mac->adb_buffer[3]); |
| 2183 | printf("ADB: Egret read PRAM from %x\n", mac->m_adb_buffer[2]<<8 | mac->m_adb_buffer[3]); |
| 2191 | 2184 | #endif |
| 2192 | 2185 | |
| 2193 | | mac_egret_response_read_pram(mac, 7, mac->adb_buffer[2]<<8 | mac->adb_buffer[3]); |
| 2186 | mac_egret_response_read_pram(mac, 7, mac->m_adb_buffer[2]<<8 | mac->m_adb_buffer[3]); |
| 2194 | 2187 | break; |
| 2195 | 2188 | |
| 2196 | 2189 | case 0x08: // write 6805 address |
| 2197 | 2190 | { |
| 2198 | | int addr = mac->adb_buffer[2]<<8 | mac->adb_buffer[3]; |
| 2199 | | int len = mac->adb_datasize - 4; |
| 2191 | int addr = mac->m_adb_buffer[2]<<8 | mac->m_adb_buffer[3]; |
| 2192 | int len = mac->m_adb_datasize - 4; |
| 2200 | 2193 | |
| 2201 | 2194 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2202 | 2195 | printf("ADB: Egret write %d bytes to address %x\n", len, addr); |
| r9489 | r9490 | |
| 2207 | 2200 | { |
| 2208 | 2201 | for (int i = 0; i < len; i++) |
| 2209 | 2202 | { |
| 2210 | | mac->rtc_ram[(addr-0x100)+i] = mac->adb_buffer[4+i]; |
| 2203 | mac->m_rtc_ram[(addr-0x100)+i] = mac->m_adb_buffer[4+i]; |
| 2211 | 2204 | } |
| 2212 | 2205 | } |
| 2213 | 2206 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| r9489 | r9490 | |
| 2223 | 2216 | |
| 2224 | 2217 | case 0x0c: // write PRAM |
| 2225 | 2218 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2226 | | printf("ADB: Egret write %02x to PRAM at %x\n", mac->adb_buffer[4], mac->adb_buffer[2]<<8 | mac->adb_buffer[3]); |
| 2219 | printf("ADB: Egret write %02x to PRAM at %x\n", mac->m_adb_buffer[4], mac->m_adb_buffer[2]<<8 | mac->m_adb_buffer[3]); |
| 2227 | 2220 | #endif |
| 2228 | 2221 | |
| 2229 | | mac->rtc_ram[mac->adb_buffer[2]<<8 | mac->adb_buffer[3]] = mac->adb_buffer[4]; |
| 2222 | mac->m_rtc_ram[mac->m_adb_buffer[2]<<8 | mac->m_adb_buffer[3]] = mac->m_adb_buffer[4]; |
| 2230 | 2223 | |
| 2231 | | mac->adb_datasize = 4; |
| 2232 | | mac->adb_buffer[4] = 1; // type |
| 2233 | | mac->adb_buffer[3] = 0; // flag |
| 2234 | | mac->adb_buffer[2] = 0x0c; // command |
| 2235 | | mac->adb_buffer[1] = 0; // spare |
| 2236 | | mac->adb_state |= 1; |
| 2237 | | mac->adb_timer_ticks = 8; |
| 2224 | mac->m_adb_datasize = 4; |
| 2225 | mac->m_adb_buffer[4] = 1; // type |
| 2226 | mac->m_adb_buffer[3] = 0; // flag |
| 2227 | mac->m_adb_buffer[2] = 0x0c; // command |
| 2228 | mac->m_adb_buffer[1] = 0; // spare |
| 2229 | mac->m_adb_state |= 1; |
| 2230 | mac->m_adb_timer_ticks = 8; |
| 2238 | 2231 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2239 | 2232 | break; |
| 2240 | 2233 | |
| 2241 | 2234 | case 0x0e: // send to DFAC |
| 2242 | 2235 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2243 | | printf("ADB: Egret send %02x to DFAC\n", mac->adb_buffer[2]); |
| 2236 | printf("ADB: Egret send %02x to DFAC\n", mac->m_adb_buffer[2]); |
| 2244 | 2237 | #endif |
| 2245 | 2238 | |
| 2246 | 2239 | mac_egret_response_std(mac, 1, 0, 0x0e); |
| r9489 | r9490 | |
| 2248 | 2241 | |
| 2249 | 2242 | case 0x1b: // set one-second interrupt |
| 2250 | 2243 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2251 | | if (mac->adb_buffer[2]) |
| 2244 | if (mac->m_adb_buffer[2]) |
| 2252 | 2245 | { |
| 2253 | 2246 | printf("ADB: Egret enable one-second IRQ\n"); |
| 2254 | 2247 | } |
| r9489 | r9490 | |
| 2263 | 2256 | |
| 2264 | 2257 | case 0x1c: // enable/disable keyboard NMI |
| 2265 | 2258 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2266 | | if (mac->adb_buffer[2]) |
| 2259 | if (mac->m_adb_buffer[2]) |
| 2267 | 2260 | { |
| 2268 | 2261 | printf("ADB: Egret enable keyboard NMI\n"); |
| 2269 | 2262 | } |
| r9489 | r9490 | |
| 2278 | 2271 | |
| 2279 | 2272 | default: |
| 2280 | 2273 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2281 | | printf("ADB: Unknown Egret MCU command %02x\n", mac->adb_buffer[1]); |
| 2274 | printf("ADB: Unknown Egret MCU command %02x\n", mac->m_adb_buffer[1]); |
| 2282 | 2275 | #endif |
| 2283 | 2276 | break; |
| 2284 | 2277 | } |
| r9489 | r9490 | |
| 2286 | 2279 | |
| 2287 | 2280 | static void mac_egret_newaction(mac_state *mac, int state) |
| 2288 | 2281 | { |
| 2289 | | if (state != mac->adb_state) |
| 2282 | if (state != mac->m_adb_state) |
| 2290 | 2283 | { |
| 2291 | 2284 | #if LOG_ADB |
| 2292 | | printf("ADB: New Egret state: SS %d VF %d XS (68k %d MCU %d)\n", (state>>2)&1, (state>>1)&1, state&1, mac->adb_state&1); |
| 2285 | printf("ADB: New Egret state: SS %d VF %d XS (68k %d MCU %d)\n", (state>>2)&1, (state>>1)&1, state&1, mac->m_adb_state&1); |
| 2293 | 2286 | #endif |
| 2294 | 2287 | |
| 2295 | 2288 | // if bit 2 is high and stays high, the rising edge of bit 1 indicates the start of sending a byte to the MCU if XS isn't high |
| 2296 | | if ((state & 0x04) && (mac->adb_state & 0x04) && (state & 0x02) && !(mac->adb_state & 0x02) && !(mac->adb_state & 0x01)) |
| 2289 | if ((state & 0x04) && (mac->m_adb_state & 0x04) && (state & 0x02) && !(mac->m_adb_state & 0x02) && !(mac->m_adb_state & 0x01)) |
| 2297 | 2290 | { |
| 2298 | | mac->adb_command = 0; |
| 2299 | | mac->adb_timer_ticks = 8; |
| 2291 | mac->m_adb_command = 0; |
| 2292 | mac->m_adb_timer_ticks = 8; |
| 2300 | 2293 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2301 | 2294 | } |
| 2302 | 2295 | |
| 2303 | 2296 | // if bit 2 is high and stays high, the falling edge of bit 1, and we're in send phase, the MCU should clock out a byte |
| 2304 | | if ((state & 0x04) && (mac->adb_state & 0x04) && !(state & 0x02) && (mac->adb_state & 0x02) && (mac->adb_state & 0x01)) |
| 2297 | if ((state & 0x04) && (mac->m_adb_state & 0x04) && !(state & 0x02) && (mac->m_adb_state & 0x02) && (mac->m_adb_state & 0x01)) |
| 2305 | 2298 | { |
| 2306 | | mac->adb_timer_ticks = 8; |
| 2299 | mac->m_adb_timer_ticks = 8; |
| 2307 | 2300 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2308 | 2301 | } |
| 2309 | 2302 | |
| 2310 | 2303 | // if bit 2 rises, bit 1 is 0, and MCU XS is high, the MCU should clock out a byte |
| 2311 | | if ((state & 0x04) && !(mac->adb_state & 0x04) && !(state & 0x02) && (mac->adb_state & 0x01)) |
| 2304 | if ((state & 0x04) && !(mac->m_adb_state & 0x04) && !(state & 0x02) && (mac->m_adb_state & 0x01)) |
| 2312 | 2305 | { |
| 2313 | | mac->adb_timer_ticks = 8; |
| 2306 | mac->m_adb_timer_ticks = 8; |
| 2314 | 2307 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2315 | 2308 | } |
| 2316 | 2309 | |
| 2317 | 2310 | // if bit 2 drops and bit 1 is 1, terminate the command |
| 2318 | | if ((state & 0x02) && !(state & 0x04) && (mac->adb_state & 0x04)) |
| 2311 | if ((state & 0x02) && !(state & 0x04) && (mac->m_adb_state & 0x04)) |
| 2319 | 2312 | { |
| 2320 | 2313 | #if LOG_ADB |
| 2321 | 2314 | printf("Egret ADB: SESSION dropped with VF=1, terminating command\n"); |
| 2322 | 2315 | #endif |
| 2323 | | mac->adb_streaming = MCU_STREAMING_NONE; |
| 2324 | | mac->adb_state &= ~1; |
| 2325 | | mac->adb_datasize = 0; |
| 2316 | mac->m_adb_streaming = MCU_STREAMING_NONE; |
| 2317 | mac->m_adb_state &= ~1; |
| 2318 | mac->m_adb_datasize = 0; |
| 2326 | 2319 | } |
| 2327 | 2320 | |
| 2328 | 2321 | // if bit 2 drops and bit 1 is zero, execute the command |
| 2329 | | if (!(state & 0x02) && !(state & 0x04) && (mac->adb_state & 0x04) && (mac->adb_datasize > 0)) |
| 2322 | if (!(state & 0x02) && !(state & 0x04) && (mac->m_adb_state & 0x04) && (mac->m_adb_datasize > 0)) |
| 2330 | 2323 | { |
| 2331 | 2324 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| 2332 | 2325 | int i; |
| 2333 | 2326 | |
| 2334 | | printf("Egret ADB: exec command with %d bytes: ", mac->adb_datasize); |
| 2327 | printf("Egret ADB: exec command with %d bytes: ", mac->m_adb_datasize); |
| 2335 | 2328 | |
| 2336 | | for (i = 0; i < mac->adb_datasize; i++) |
| 2329 | for (i = 0; i < mac->m_adb_datasize; i++) |
| 2337 | 2330 | { |
| 2338 | | printf("%02x ", mac->adb_buffer[i]); |
| 2331 | printf("%02x ", mac->m_adb_buffer[i]); |
| 2339 | 2332 | } |
| 2340 | 2333 | |
| 2341 | 2334 | printf("\n"); |
| 2342 | 2335 | #endif |
| 2343 | 2336 | |
| 2344 | 2337 | // exec command here |
| 2345 | | switch (mac->adb_buffer[0]) |
| 2338 | switch (mac->m_adb_buffer[0]) |
| 2346 | 2339 | { |
| 2347 | 2340 | case 0: // ADB command |
| 2348 | | switch (mac->adb_buffer[1] & 0xf) |
| 2341 | switch (mac->m_adb_buffer[1] & 0xf) |
| 2349 | 2342 | { |
| 2350 | 2343 | case 0: // reset |
| 2351 | 2344 | #if LOG_ADB || LOG_ADB_MCU_CMD |
| r9489 | r9490 | |
| 2362 | 2355 | break; |
| 2363 | 2356 | |
| 2364 | 2357 | default: |
| 2365 | | printf("Egret: Unhandled ADB command %x\n", mac->adb_buffer[1]); |
| 2366 | | mac->adb_datasize = 0; |
| 2358 | printf("Egret: Unhandled ADB command %x\n", mac->m_adb_buffer[1]); |
| 2359 | mac->m_adb_datasize = 0; |
| 2367 | 2360 | break; |
| 2368 | 2361 | |
| 2369 | 2362 | } |
| r9489 | r9490 | |
| 2374 | 2367 | break; |
| 2375 | 2368 | |
| 2376 | 2369 | case 2: // error |
| 2377 | | mac->adb_datasize = 0; |
| 2370 | mac->m_adb_datasize = 0; |
| 2378 | 2371 | break; |
| 2379 | 2372 | |
| 2380 | 2373 | case 3: // one-second interrupt |
| 2381 | | mac->adb_datasize = 0; |
| 2374 | mac->m_adb_datasize = 0; |
| 2382 | 2375 | break; |
| 2383 | 2376 | } |
| 2384 | 2377 | } |
| 2385 | 2378 | |
| 2386 | | mac->adb_state &= ~0x6; |
| 2387 | | mac->adb_state |= state & 0x6; |
| 2379 | mac->m_adb_state &= ~0x6; |
| 2380 | mac->m_adb_state |= state & 0x6; |
| 2388 | 2381 | } |
| 2389 | 2382 | } |
| 2390 | 2383 | |
| r9489 | r9490 | |
| 2395 | 2388 | #if LOG_ADB |
| 2396 | 2389 | printf("PM: timer tick, lowering ACK\n"); |
| 2397 | 2390 | #endif |
| 2398 | | mac->pm_ack &= ~2; // lower ACK to handshake next step |
| 2391 | mac->m_pm_ack &= ~2; // lower ACK to handshake next step |
| 2399 | 2392 | } |
| 2400 | 2393 | |
| 2401 | 2394 | static void pmu_one_byte_reply(mac_state *mac, UINT8 result) |
| 2402 | 2395 | { |
| 2403 | | mac->pm_out[0] = 1; // length |
| 2404 | | mac->pm_out[1] = result; |
| 2405 | | mac->pm_slen = 2; |
| 2406 | | timer_adjust_oneshot(mac->pmu_send_timer, attotime_make(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2396 | mac->m_pm_out[0] = 1; // length |
| 2397 | mac->m_pm_out[1] = result; |
| 2398 | mac->m_pm_slen = 2; |
| 2399 | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime_make(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2407 | 2400 | } |
| 2408 | 2401 | |
| 2409 | 2402 | static void pmu_exec(mac_state *mac) |
| 2410 | 2403 | { |
| 2411 | | mac->pm_sptr = 0; // clear send pointer |
| 2412 | | mac->pm_slen = 0; // and send length |
| 2413 | | mac->pm_dptr = 0; // and recieve pointer |
| 2404 | mac->m_pm_sptr = 0; // clear send pointer |
| 2405 | mac->m_pm_slen = 0; // and send length |
| 2406 | mac->m_pm_dptr = 0; // and recieve pointer |
| 2414 | 2407 | |
| 2415 | | switch (mac->pm_cmd[0]) |
| 2408 | switch (mac->m_pm_cmd[0]) |
| 2416 | 2409 | { |
| 2417 | 2410 | case 0x10: // subsystem power and clock ctrl (no response) |
| 2418 | 2411 | break; |
| 2419 | 2412 | |
| 2420 | 2413 | case 0x32: // write extended PRAM byte(s). cmd[2] = address, cmd[3] = length, cmd[4...] = data |
| 2421 | | if ((mac->pm_cmd[2] + mac->pm_cmd[3]) < 0x100) |
| 2414 | if ((mac->m_pm_cmd[2] + mac->m_pm_cmd[3]) < 0x100) |
| 2422 | 2415 | { |
| 2423 | 2416 | int i; |
| 2424 | 2417 | |
| 2425 | | for (i = 0; i < mac->pm_cmd[3]; i++) |
| 2418 | for (i = 0; i < mac->m_pm_cmd[3]; i++) |
| 2426 | 2419 | { |
| 2427 | | mac->rtc_ram[mac->pm_cmd[2] + i] = mac->pm_cmd[4+i]; |
| 2420 | mac->m_rtc_ram[mac->m_pm_cmd[2] + i] = mac->m_pm_cmd[4+i]; |
| 2428 | 2421 | } |
| 2429 | 2422 | } |
| 2430 | 2423 | break; |
| r9489 | r9490 | |
| 2433 | 2426 | { |
| 2434 | 2427 | int i; |
| 2435 | 2428 | |
| 2436 | | mac->pm_out[0] = 20; |
| 2429 | mac->m_pm_out[0] = 20; |
| 2437 | 2430 | for (i = 0; i < 20; i++) |
| 2438 | 2431 | { |
| 2439 | | mac->pm_out[1 + i] = mac->rtc_ram[i]; |
| 2432 | mac->m_pm_out[1 + i] = mac->m_rtc_ram[i]; |
| 2440 | 2433 | } |
| 2441 | | mac->pm_slen = 21; |
| 2442 | | timer_adjust_oneshot(mac->pmu_send_timer, attotime_make(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2434 | mac->m_pm_slen = 21; |
| 2435 | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime_make(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2443 | 2436 | } |
| 2444 | 2437 | break; |
| 2445 | 2438 | |
| 2446 | 2439 | case 0x3a: // read extended PRAM byte(s). cmd[2] = address, cmd[3] = length |
| 2447 | | if ((mac->pm_cmd[2] + mac->pm_cmd[3]) < 0x100) |
| 2440 | if ((mac->m_pm_cmd[2] + mac->m_pm_cmd[3]) < 0x100) |
| 2448 | 2441 | { |
| 2449 | 2442 | int i; |
| 2450 | 2443 | |
| 2451 | | mac->pm_out[0] = mac->pm_cmd[3]; |
| 2452 | | for (i = 0; i < mac->pm_cmd[3]; i++) |
| 2444 | mac->m_pm_out[0] = mac->m_pm_cmd[3]; |
| 2445 | for (i = 0; i < mac->m_pm_cmd[3]; i++) |
| 2453 | 2446 | { |
| 2454 | | mac->pm_out[1 + i] = mac->rtc_ram[mac->pm_cmd[2] + i]; |
| 2447 | mac->m_pm_out[1 + i] = mac->m_rtc_ram[mac->m_pm_cmd[2] + i]; |
| 2455 | 2448 | } |
| 2456 | | mac->pm_slen = mac->pm_cmd[3] + 1; |
| 2457 | | timer_adjust_oneshot(mac->pmu_send_timer, attotime_make(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2449 | mac->m_pm_slen = mac->m_pm_cmd[3] + 1; |
| 2450 | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime_make(0, ATTOSECONDS_IN_USEC(200)), 0); |
| 2458 | 2451 | } |
| 2459 | 2452 | break; |
| 2460 | 2453 | |
| r9489 | r9490 | |
| 2471 | 2464 | break; |
| 2472 | 2465 | |
| 2473 | 2466 | default: |
| 2474 | | fatalerror("PMU: Unhandled command %02x\n", mac->pm_cmd[0]); |
| 2467 | fatalerror("PMU: Unhandled command %02x\n", mac->m_pm_cmd[0]); |
| 2475 | 2468 | break; |
| 2476 | 2469 | } |
| 2477 | 2470 | |
| 2478 | | if (mac->pm_slen > 0) |
| 2471 | if (mac->m_pm_slen > 0) |
| 2479 | 2472 | { |
| 2480 | | mac->pm_state = 1; |
| 2473 | mac->m_pm_state = 1; |
| 2481 | 2474 | } |
| 2482 | 2475 | } |
| 2483 | 2476 | |
| 2484 | | static void adb_vblank(running_machine *machine) |
| 2477 | void mac_state::adb_vblank(running_machine *machine) |
| 2485 | 2478 | { |
| 2486 | | mac_state *mac = machine->driver_data<mac_state>(); |
| 2487 | | |
| 2488 | | if (mac->adb_state == ADB_STATE_IDLE) |
| 2479 | if (m_adb_state == ADB_STATE_IDLE) |
| 2489 | 2480 | { |
| 2490 | 2481 | if (mac_adb_pollmouse(machine)) |
| 2491 | 2482 | { |
| 2492 | 2483 | // if the mouse was the last TALK, we can just send the new data |
| 2493 | 2484 | // otherwise we need to pull SRQ |
| 2494 | | if (mac->adb_last_talk == adb_mouseaddr) |
| 2485 | if (m_adb_last_talk == adb_mouseaddr) |
| 2495 | 2486 | { |
| 2496 | 2487 | // repeat last TALK to get updated data |
| 2497 | | mac->adb_waiting_cmd = 1; |
| 2488 | m_adb_waiting_cmd = 1; |
| 2498 | 2489 | mac_adb_talk(machine); |
| 2499 | 2490 | |
| 2500 | | mac->adb_timer_ticks = 8; |
| 2491 | m_adb_timer_ticks = 8; |
| 2501 | 2492 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2502 | 2493 | } |
| 2503 | 2494 | else |
| 2504 | 2495 | { |
| 2505 | | mac->adb_irq_pending = 1; |
| 2506 | | mac->adb_command = mac->adb_send = 0; |
| 2507 | | mac->adb_timer_ticks = 1; // one tick should be sufficient to make it see the IRQ |
| 2496 | m_adb_irq_pending = 1; |
| 2497 | m_adb_command = m_adb_send = 0; |
| 2498 | m_adb_timer_ticks = 1; // one tick should be sufficient to make it see the IRQ |
| 2508 | 2499 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2509 | | mac->adb_srq_switch = 1; |
| 2500 | m_adb_srq_switch = 1; |
| 2510 | 2501 | } |
| 2511 | 2502 | } |
| 2512 | 2503 | else if (mac_adb_pollkbd(machine, 0)) |
| 2513 | 2504 | { |
| 2514 | | if (mac->adb_last_talk == adb_keybaddr) |
| 2505 | if (m_adb_last_talk == adb_keybaddr) |
| 2515 | 2506 | { |
| 2516 | 2507 | // repeat last TALK to get updated data |
| 2517 | | mac->adb_waiting_cmd = 1; |
| 2508 | m_adb_waiting_cmd = 1; |
| 2518 | 2509 | mac_adb_talk(machine); |
| 2519 | 2510 | |
| 2520 | | mac->adb_timer_ticks = 8; |
| 2511 | m_adb_timer_ticks = 8; |
| 2521 | 2512 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2522 | 2513 | } |
| 2523 | 2514 | else |
| 2524 | 2515 | { |
| 2525 | | mac->adb_irq_pending = 1; |
| 2526 | | mac->adb_command = mac->adb_send = 0; |
| 2527 | | mac->adb_timer_ticks = 1; // one tick should be sufficient to make it see the IRQ |
| 2516 | m_adb_irq_pending = 1; |
| 2517 | m_adb_command = m_adb_send = 0; |
| 2518 | m_adb_timer_ticks = 1; // one tick should be sufficient to make it see the IRQ |
| 2528 | 2519 | timer_adjust_oneshot(mac_adb_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2529 | | mac->adb_srq_switch = 1; |
| 2520 | m_adb_srq_switch = 1; |
| 2530 | 2521 | } |
| 2531 | 2522 | } |
| 2532 | 2523 | } |
| 2533 | 2524 | } |
| 2534 | 2525 | |
| 2535 | | static void adb_reset(mac_state *mac) |
| 2526 | void mac_state::adb_reset(running_machine *machine) |
| 2536 | 2527 | { |
| 2537 | 2528 | int i; |
| 2538 | 2529 | |
| 2539 | | mac->adb_srq_switch = 0; |
| 2540 | | mac->adb_irq_pending = 0; // no interrupt |
| 2541 | | mac->adb_timer_ticks = 0; |
| 2542 | | mac->adb_command = 0; |
| 2543 | | mac->adb_extclock = 0; |
| 2544 | | mac->adb_send = 0; |
| 2545 | | mac->adb_waiting_cmd = 0; |
| 2546 | | mac->adb_streaming = MCU_STREAMING_NONE; |
| 2547 | | if (ADB_IS_BITBANG) |
| 2530 | m_adb_srq_switch = 0; |
| 2531 | m_adb_irq_pending = 0; // no interrupt |
| 2532 | m_adb_timer_ticks = 0; |
| 2533 | m_adb_command = 0; |
| 2534 | m_adb_extclock = 0; |
| 2535 | m_adb_send = 0; |
| 2536 | m_adb_waiting_cmd = 0; |
| 2537 | m_adb_streaming = MCU_STREAMING_NONE; |
| 2538 | m_adb_state = 0; |
| 2539 | if (ADB_IS_BITBANG_CLASS) |
| 2548 | 2540 | { |
| 2549 | | mac->adb_state = ADB_STATE_NOTINIT; |
| 2541 | m_adb_state = ADB_STATE_NOTINIT; |
| 2550 | 2542 | } |
| 2551 | | else if (ADB_IS_EGRET) |
| 2552 | | { |
| 2553 | | mac->adb_state = 0; |
| 2554 | | } |
| 2555 | | mac->adb_direction = 0; |
| 2556 | | mac->adb_datasize = 0; |
| 2557 | | mac->adb_last_talk = -1; |
| 2543 | m_adb_direction = 0; |
| 2544 | m_adb_datasize = 0; |
| 2545 | m_adb_last_talk = -1; |
| 2558 | 2546 | |
| 2559 | 2547 | // mouse |
| 2560 | 2548 | adb_mouseaddr = 3; |
| r9489 | r9490 | |
| 2568 | 2556 | adb_modifiers = 0; |
| 2569 | 2557 | for (i=0; i<7; i++) |
| 2570 | 2558 | { |
| 2571 | | mac->key_matrix[i] = 0; |
| 2559 | m_key_matrix[i] = 0; |
| 2572 | 2560 | } |
| 2573 | 2561 | } |
| 2574 | 2562 | |
| r9489 | r9490 | |
| 2614 | 2602 | |
| 2615 | 2603 | // printf("VIA1 IN_A (PC %x)\n", cpu_get_pc(device->machine->device("maincpu"))); |
| 2616 | 2604 | |
| 2617 | | switch (mac->model) |
| 2605 | switch (mac->m_model) |
| 2618 | 2606 | { |
| 2619 | 2607 | case MODEL_MAC_PORTABLE: |
| 2620 | 2608 | case MODEL_MAC_PB100: |
| 2621 | 2609 | #if LOG_ADB |
| 2622 | | // printf("Read PM data %x\n", mac->pm_data_recv); |
| 2610 | // printf("Read PM data %x\n", mac->m_pm_data_recv); |
| 2623 | 2611 | #endif |
| 2624 | | return mac->pm_data_recv; |
| 2612 | return mac->m_pm_data_recv; |
| 2625 | 2613 | |
| 2626 | 2614 | case MODEL_MAC_CLASSIC: |
| 2627 | 2615 | case MODEL_MAC_II: |
| r9489 | r9490 | |
| 2678 | 2666 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 2679 | 2667 | |
| 2680 | 2668 | // portable/PB100 is pretty different |
| 2681 | | if (mac->model >= MODEL_MAC_PORTABLE && mac->model <= MODEL_MAC_PB100) |
| 2669 | if (mac->m_model >= MODEL_MAC_PORTABLE && mac->m_model <= MODEL_MAC_PB100) |
| 2682 | 2670 | { |
| 2683 | | // printf("Read VIA B: PM_ACK %x\n", mac->pm_ack); |
| 2684 | | val = 0x80 | 0x04 | mac->pm_ack; // SCC wait/request (bit 2 must be set at 900c1a or startup tests always fail) |
| 2671 | // printf("Read VIA B: PM_ACK %x\n", mac->m_pm_ack); |
| 2672 | val = 0x80 | 0x04 | mac->m_pm_ack; // SCC wait/request (bit 2 must be set at 900c1a or startup tests always fail) |
| 2685 | 2673 | } |
| 2686 | 2674 | else |
| 2687 | 2675 | { |
| r9489 | r9490 | |
| 2691 | 2679 | |
| 2692 | 2680 | if (ADB_IS_BITBANG) |
| 2693 | 2681 | { |
| 2694 | | val |= mac->adb_state<<4; |
| 2682 | val |= mac->m_adb_state<<4; |
| 2695 | 2683 | |
| 2696 | | if (!mac->adb_irq_pending) |
| 2684 | if (!mac->m_adb_irq_pending) |
| 2697 | 2685 | { |
| 2698 | 2686 | val |= 0x08; |
| 2699 | 2687 | } |
| 2700 | 2688 | } |
| 2701 | 2689 | else if (ADB_IS_EGRET) |
| 2702 | 2690 | { |
| 2703 | | val |= mac->adb_state<<3; |
| 2691 | val |= mac->m_adb_state<<3; |
| 2704 | 2692 | val ^= 0x08; // maybe it's reversed? |
| 2705 | 2693 | } |
| 2706 | 2694 | else |
| 2707 | 2695 | { |
| 2708 | | if (mac->mouse_bit_y) /* Mouse Y2 */ |
| 2696 | if (mac->m_mouse_bit_y) /* Mouse Y2 */ |
| 2709 | 2697 | val |= 0x20; |
| 2710 | | if (mac->mouse_bit_x) /* Mouse X2 */ |
| 2698 | if (mac->m_mouse_bit_x) /* Mouse X2 */ |
| 2711 | 2699 | val |= 0x10; |
| 2712 | 2700 | if ((input_port_read(device->machine, "MOUSE0") & 0x01) == 0) |
| 2713 | 2701 | val |= 0x08; |
| 2714 | 2702 | } |
| 2715 | | if (mac->rtc_data_out) |
| 2703 | if (mac->m_rtc_data_out) |
| 2716 | 2704 | val |= 1; |
| 2717 | 2705 | } |
| 2718 | 2706 | |
| r9489 | r9490 | |
| 2729 | 2717 | |
| 2730 | 2718 | // printf("VIA1 OUT A: %02x (PC %x)\n", data, cpu_get_pc(device->machine->device("maincpu"))); |
| 2731 | 2719 | |
| 2732 | | if (mac->model >= MODEL_MAC_PORTABLE && mac->model <= MODEL_MAC_PB100) |
| 2720 | if (mac->m_model >= MODEL_MAC_PORTABLE && mac->m_model <= MODEL_MAC_PB100) |
| 2733 | 2721 | { |
| 2734 | 2722 | #if LOG_ADB |
| 2735 | 2723 | // printf("%02x to PM\n", data); |
| 2736 | 2724 | #endif |
| 2737 | | mac->pm_data_send = data; |
| 2725 | mac->m_pm_data_send = data; |
| 2738 | 2726 | return; |
| 2739 | 2727 | } |
| 2740 | 2728 | |
| 2741 | 2729 | set_scc_waitrequest((data & 0x80) >> 7); |
| 2742 | 2730 | mac_set_screen_buffer((data & 0x40) >> 6); |
| 2743 | 2731 | sony_set_sel_line(fdc,(data & 0x20) >> 5); |
| 2744 | | if (mac->model == MODEL_MAC_SE) // on SE this selects which floppy drive (0 = upper, 1 = lower) |
| 2732 | if (mac->m_model == MODEL_MAC_SE) // on SE this selects which floppy drive (0 = upper, 1 = lower) |
| 2745 | 2733 | { |
| 2746 | | mac->drive_select = ((data & 0x10) >> 4); |
| 2734 | mac->m_drive_select = ((data & 0x10) >> 4); |
| 2747 | 2735 | } |
| 2748 | 2736 | |
| 2749 | | if (mac->model < MODEL_MAC_SE) // SE no longer has dual buffers |
| 2737 | if (mac->m_model < MODEL_MAC_SE) // SE no longer has dual buffers |
| 2750 | 2738 | { |
| 2751 | 2739 | mac_set_sound_buffer(sound, (data & 0x08) >> 3); |
| 2752 | 2740 | } |
| 2753 | 2741 | |
| 2754 | | if (mac->model < MODEL_MAC_II) |
| 2742 | if (mac->m_model < MODEL_MAC_II) |
| 2755 | 2743 | { |
| 2756 | 2744 | mac_set_volume(sound, data & 0x07); |
| 2757 | 2745 | } |
| r9489 | r9490 | |
| 2759 | 2747 | /* Early Mac models had VIA A4 control overlaying. In the Mac SE (and |
| 2760 | 2748 | * possibly later models), overlay was set on reset, but cleared on the |
| 2761 | 2749 | * first access to the ROM. */ |
| 2762 | | if (mac->model < MODEL_MAC_SE) |
| 2750 | if (mac->m_model < MODEL_MAC_SE) |
| 2763 | 2751 | { |
| 2764 | | mac_set_memory_overlay(device->machine, (data & 0x10) >> 4); |
| 2752 | mac->set_memory_overlay(device->machine, (data & 0x10) >> 4); |
| 2765 | 2753 | } |
| 2766 | 2754 | } |
| 2767 | 2755 | |
| r9489 | r9490 | |
| 2773 | 2761 | |
| 2774 | 2762 | // printf("VIA1 OUT B: %02x (PC %x)\n", data, cpu_get_pc(device->machine->device("maincpu"))); |
| 2775 | 2763 | |
| 2776 | | if (mac->model >= MODEL_MAC_PORTABLE && mac->model <= MODEL_MAC_PB100) |
| 2764 | if (mac->m_model >= MODEL_MAC_PORTABLE && mac->m_model <= MODEL_MAC_PB100) |
| 2777 | 2765 | { |
| 2778 | 2766 | running_device *fdc = device->machine->device("fdc"); |
| 2779 | 2767 | |
| 2780 | 2768 | sony_set_sel_line(fdc,(data & 0x20) >> 5); |
| 2781 | | mac->drive_select = ((data & 0x10) >> 4); |
| 2769 | mac->m_drive_select = ((data & 0x10) >> 4); |
| 2782 | 2770 | |
| 2783 | | if ((data & 1) && !(mac->pm_req & 1)) |
| 2771 | if ((data & 1) && !(mac->m_pm_req & 1)) |
| 2784 | 2772 | { |
| 2785 | 2773 | #if LOG_ADB |
| 2786 | 2774 | printf("PM: 68k dropping /REQ\n"); |
| 2787 | 2775 | #endif |
| 2788 | 2776 | |
| 2789 | | if (mac->pm_state == 0) // do this in receive state only |
| 2777 | if (mac->m_pm_state == 0) // do this in receive state only |
| 2790 | 2778 | { |
| 2791 | | mac->pm_data_recv = 0xff; |
| 2792 | | mac->pm_ack |= 2; |
| 2779 | mac->m_pm_data_recv = 0xff; |
| 2780 | mac->m_pm_ack |= 2; |
| 2793 | 2781 | |
| 2794 | 2782 | // check if length byte matches |
| 2795 | | if ((mac->pm_dptr >= 2) && (mac->pm_cmd[1] == (mac->pm_dptr-2))) |
| 2783 | if ((mac->m_pm_dptr >= 2) && (mac->m_pm_cmd[1] == (mac->m_pm_dptr-2))) |
| 2796 | 2784 | { |
| 2797 | 2785 | pmu_exec(mac); |
| 2798 | 2786 | #if LOG_ADB |
| 2799 | | printf("PMU exec: command %02x length %d\n", mac->pm_cmd[0], mac->pm_cmd[1]); |
| 2787 | printf("PMU exec: command %02x length %d\n", mac->m_pm_cmd[0], mac->m_pm_cmd[1]); |
| 2800 | 2788 | #endif |
| 2801 | 2789 | } |
| 2802 | 2790 | } |
| 2803 | 2791 | } |
| 2804 | | else if (!(data & 1) && (mac->pm_req & 1)) |
| 2792 | else if (!(data & 1) && (mac->m_pm_req & 1)) |
| 2805 | 2793 | { |
| 2806 | | if (mac->pm_state == 0) |
| 2794 | if (mac->m_pm_state == 0) |
| 2807 | 2795 | { |
| 2808 | 2796 | #if LOG_ADB |
| 2809 | | printf("PM: 68k asserting /REQ, clocking in byte [%d] = %02x\n", mac->pm_dptr, mac->pm_data_send); |
| 2797 | printf("PM: 68k asserting /REQ, clocking in byte [%d] = %02x\n", mac->m_pm_dptr, mac->m_pm_data_send); |
| 2810 | 2798 | #endif |
| 2811 | | mac->pm_ack &= ~2; // clear, we're waiting for more bytes |
| 2812 | | mac->pm_cmd[mac->pm_dptr++] = mac->pm_data_send; |
| 2799 | mac->m_pm_ack &= ~2; // clear, we're waiting for more bytes |
| 2800 | mac->m_pm_cmd[mac->m_pm_dptr++] = mac->m_pm_data_send; |
| 2813 | 2801 | } |
| 2814 | 2802 | else // receiving, so this is different |
| 2815 | 2803 | { |
| 2816 | | mac->pm_data_recv = mac->pm_out[mac->pm_sptr++]; |
| 2817 | | mac->pm_slen--; |
| 2818 | | mac->pm_ack |= 2; // raise ACK to indicate available byte |
| 2804 | mac->m_pm_data_recv = mac->m_pm_out[mac->m_pm_sptr++]; |
| 2805 | mac->m_pm_slen--; |
| 2806 | mac->m_pm_ack |= 2; // raise ACK to indicate available byte |
| 2819 | 2807 | #if LOG_ADB |
| 2820 | | printf("PM: 68k asserted /REQ, sending byte %02x\n", mac->pm_data_recv); |
| 2808 | printf("PM: 68k asserted /REQ, sending byte %02x\n", mac->m_pm_data_recv); |
| 2821 | 2809 | #endif |
| 2822 | 2810 | |
| 2823 | 2811 | // another byte to send? |
| 2824 | | if (mac->pm_slen) |
| 2812 | if (mac->m_pm_slen) |
| 2825 | 2813 | { |
| 2826 | | timer_adjust_oneshot(mac->pmu_send_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2814 | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime_make(0, ATTOSECONDS_IN_USEC(100)), 0); |
| 2827 | 2815 | } |
| 2828 | 2816 | else |
| 2829 | 2817 | { |
| 2830 | | mac->pm_state = 0; // back to receive state |
| 2831 | | timer_adjust_oneshot(mac->pmu_send_timer, attotime_never, 0); |
| 2818 | mac->m_pm_state = 0; // back to receive state |
| 2819 | timer_adjust_oneshot(mac->m_pmu_send_timer, attotime_never, 0); |
| 2832 | 2820 | } |
| 2833 | 2821 | } |
| 2834 | 2822 | } |
| 2835 | 2823 | |
| 2836 | | mac->pm_req = data & 1; |
| 2824 | mac->m_pm_req = data & 1; |
| 2837 | 2825 | return; |
| 2838 | 2826 | } |
| 2839 | 2827 | |
| r9489 | r9490 | |
| 2843 | 2831 | } |
| 2844 | 2832 | |
| 2845 | 2833 | // SE and Classic have SCSI enable/disable here |
| 2846 | | if ((mac->model == MODEL_MAC_SE) || (mac->model == MODEL_MAC_CLASSIC)) |
| 2834 | if ((mac->m_model == MODEL_MAC_SE) || (mac->m_model == MODEL_MAC_CLASSIC)) |
| 2847 | 2835 | { |
| 2848 | | mac->scsiirq_enable = (data & 0x40) ? 0 : 1; |
| 2849 | | // printf("VIAB & 0x40 = %02x, IRQ enable %d\n", data & 0x40, mac->scsiirq_enable); |
| 2836 | mac->m_scsiirq_enable = (data & 0x40) ? 0 : 1; |
| 2837 | // printf("VIAB & 0x40 = %02x, IRQ enable %d\n", data & 0x40, mac->m_scsiirq_enable); |
| 2850 | 2838 | } |
| 2851 | 2839 | |
| 2852 | | if (mac->model == MODEL_MAC_SE30) |
| 2840 | if (mac->m_model == MODEL_MAC_SE30) |
| 2853 | 2841 | { |
| 2854 | 2842 | // 0x40 = 0 means enable vblank on SE/30 |
| 2855 | | mac->mac_se30_vbl_enable = (data & 0x40) ? 0 : 1; |
| 2843 | mac->m_se30_vbl_enable = (data & 0x40) ? 0 : 1; |
| 2856 | 2844 | |
| 2857 | 2845 | // clear the interrupt if we disabled it |
| 2858 | | if (!mac->mac_se30_vbl_enable) |
| 2846 | if (!mac->m_se30_vbl_enable) |
| 2859 | 2847 | { |
| 2860 | | mac_nubus_slot_interrupt(device->machine, 0xe, 0); |
| 2848 | mac->nubus_slot_interrupt(device->machine, 0xe, 0); |
| 2861 | 2849 | } |
| 2862 | 2850 | } |
| 2863 | 2851 | |
| 2864 | | rtc_write_rTCEnb(mac, data & 0x04); |
| 2852 | mac->rtc_write_rTCEnb(data & 0x04); |
| 2865 | 2853 | new_rtc_rTCClk = (data >> 1) & 0x01; |
| 2866 | | if ((! new_rtc_rTCClk) && (mac->rtc_rTCClk)) |
| 2867 | | rtc_shift_data(mac, data & 0x01); |
| 2868 | | mac->rtc_rTCClk = new_rtc_rTCClk; |
| 2854 | if ((! new_rtc_rTCClk) && (mac->m_rtc_rTCClk)) |
| 2855 | mac->rtc_shift_data(data & 0x01); |
| 2856 | mac->m_rtc_rTCClk = new_rtc_rTCClk; |
| 2869 | 2857 | |
| 2870 | 2858 | if (ADB_IS_BITBANG) |
| 2871 | 2859 | { |
| r9489 | r9490 | |
| 2879 | 2867 | |
| 2880 | 2868 | static void mac_via_irq(running_device *device, int state) |
| 2881 | 2869 | { |
| 2870 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 2871 | |
| 2882 | 2872 | /* interrupt the 68k (level 1) */ |
| 2883 | | set_via_interrupt(device->machine, state); |
| 2873 | mac->set_via_interrupt(device->machine, state); |
| 2884 | 2874 | } |
| 2885 | 2875 | |
| 2886 | | READ16_HANDLER ( mac_via_r ) |
| 2876 | READ16_MEMBER ( mac_state::mac_via_r ) |
| 2887 | 2877 | { |
| 2888 | 2878 | UINT16 data; |
| 2889 | | via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");; |
| 2890 | 2879 | |
| 2891 | 2880 | offset >>= 8; |
| 2892 | 2881 | offset &= 0x0f; |
| 2893 | 2882 | |
| 2894 | 2883 | if (LOG_VIA) |
| 2895 | 2884 | logerror("mac_via_r: offset=0x%02x\n", offset); |
| 2896 | | data = via_0->read(*space, offset); |
| 2885 | data = m_via1->read(space, offset); |
| 2897 | 2886 | |
| 2898 | 2887 | return (data & 0xff) | (data << 8); |
| 2899 | 2888 | } |
| 2900 | 2889 | |
| 2901 | | WRITE16_HANDLER ( mac_via_w ) |
| 2890 | WRITE16_MEMBER ( mac_state::mac_via_w ) |
| 2902 | 2891 | { |
| 2903 | | via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");; |
| 2904 | | |
| 2905 | 2892 | offset >>= 8; |
| 2906 | 2893 | offset &= 0x0f; |
| 2907 | 2894 | |
| r9489 | r9490 | |
| 2909 | 2896 | logerror("mac_via_w: offset=0x%02x data=0x%08x\n", offset, data); |
| 2910 | 2897 | |
| 2911 | 2898 | if (ACCESSING_BITS_8_15) |
| 2912 | | via_0->write(*space, offset, (data >> 8) & 0xff); |
| 2899 | m_via1->write(space, offset, (data >> 8) & 0xff); |
| 2913 | 2900 | } |
| 2914 | 2901 | |
| 2915 | 2902 | /* ************************************************************************* |
| r9489 | r9490 | |
| 2918 | 2905 | |
| 2919 | 2906 | static void mac_via2_irq(running_device *device, int state) |
| 2920 | 2907 | { |
| 2921 | | mac_set_via2_interrupt(device->machine, state); |
| 2908 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 2909 | mac->set_via2_interrupt(device->machine, state); |
| 2922 | 2910 | } |
| 2923 | 2911 | |
| 2924 | | READ16_HANDLER ( mac_via2_r ) |
| 2912 | READ16_MEMBER ( mac_state::mac_via2_r ) |
| 2925 | 2913 | { |
| 2926 | 2914 | int data; |
| 2927 | | via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1"); |
| 2928 | 2915 | |
| 2929 | 2916 | offset >>= 8; |
| 2930 | 2917 | offset &= 0x0f; |
| 2931 | 2918 | |
| 2932 | | data = via_1->read(*space, offset); |
| 2919 | data = m_via2->read(space, offset); |
| 2933 | 2920 | |
| 2934 | 2921 | // if (LOG_VIA) |
| 2935 | | logerror("mac_via2_r: offset=0x%02x = %02x (PC=%x)\n", offset*2, data, cpu_get_pc(space->machine->device("maincpu"))); |
| 2922 | logerror("mac_via2_r: offset=0x%02x = %02x (PC=%x)\n", offset*2, data, cpu_get_pc(space.machine->device("maincpu"))); |
| 2936 | 2923 | |
| 2937 | 2924 | return (data & 0xff) | (data << 8); |
| 2938 | 2925 | } |
| 2939 | 2926 | |
| 2940 | | WRITE16_HANDLER ( mac_via2_w ) |
| 2927 | WRITE16_MEMBER ( mac_state::mac_via2_w ) |
| 2941 | 2928 | { |
| 2942 | | via6522_device *via_1 = space->machine->device<via6522_device>("via6522_1"); |
| 2943 | | |
| 2944 | 2929 | offset >>= 8; |
| 2945 | 2930 | offset &= 0x0f; |
| 2946 | 2931 | |
| 2947 | 2932 | // if (LOG_VIA) |
| 2948 | | logerror("mac_via2_w: offset=%x data=0x%08x (PC=%x)\n", offset, data, cpu_get_pc(space->machine->device("maincpu"))); |
| 2933 | logerror("mac_via2_w: offset=%x data=0x%08x (PC=%x)\n", offset, data, cpu_get_pc(space.machine->device("maincpu"))); |
| 2949 | 2934 | |
| 2950 | 2935 | if (ACCESSING_BITS_8_15) |
| 2951 | | via_1->write(*space, offset, (data >> 8) & 0xff); |
| 2936 | m_via2->write(space, offset, (data >> 8) & 0xff); |
| 2952 | 2937 | } |
| 2953 | 2938 | |
| 2954 | 2939 | |
| r9489 | r9490 | |
| 2957 | 2942 | UINT8 result = 0xc0; |
| 2958 | 2943 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 2959 | 2944 | |
| 2960 | | result |= mac->mac_nubus_irq_state; |
| 2945 | result |= mac->m_nubus_irq_state; |
| 2961 | 2946 | |
| 2962 | 2947 | return result; |
| 2963 | 2948 | } |
| r9489 | r9490 | |
| 2968 | 2953 | |
| 2969 | 2954 | // logerror("VIA2 IN B (PC %x)\n", cpu_get_pc(device->machine->device("maincpu"))); |
| 2970 | 2955 | |
| 2971 | | if ((mac->model == MODEL_MAC_LC) || (mac->model == MODEL_MAC_LC_II) || (mac->model == MODEL_MAC_CLASSIC_II)) |
| 2956 | if ((mac->m_model == MODEL_MAC_LC) || (mac->m_model == MODEL_MAC_LC_II) || (mac->m_model == MODEL_MAC_CLASSIC_II)) |
| 2972 | 2957 | { |
| 2973 | 2958 | return 0x4f; |
| 2974 | 2959 | } |
| 2975 | 2960 | |
| 2976 | | if (mac->model == MODEL_MAC_SE30) |
| 2961 | if (mac->m_model == MODEL_MAC_SE30) |
| 2977 | 2962 | { |
| 2978 | 2963 | return 0x87; // bits 3 and 6 are tied low on SE/30 |
| 2979 | 2964 | } |
| r9489 | r9490 | |
| 2988 | 2973 | |
| 2989 | 2974 | static WRITE8_DEVICE_HANDLER(mac_via2_out_b) |
| 2990 | 2975 | { |
| 2991 | | via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0"); |
| 2976 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 2992 | 2977 | |
| 2993 | 2978 | // logerror("VIA2 OUT B: %02x (PC %x)\n", data, cpu_get_pc(device->machine->device("maincpu"))); |
| 2994 | 2979 | |
| 2995 | | logerror("VIA2 OUT B: %02x (MMU = %02x)\n", data, data & 0x08); |
| 2980 | if (mac->m_model == MODEL_MAC_II) |
| 2981 | { |
| 2982 | m68k_set_hmmu_enable(mac->m_maincpu, (data & 0x8) ? M68K_HMMU_DISABLE : M68K_HMMU_ENABLE_II); |
| 2983 | } |
| 2996 | 2984 | |
| 2997 | 2985 | // chain 60.15 Hz to VIA1 |
| 2998 | | via_0->write_ca1(data>>7); |
| 2986 | mac->m_via1->write_ca1(data>>7); |
| 2999 | 2987 | } |
| 3000 | 2988 | |
| 3001 | 2989 | // This signal is generated internally on RBV, V8, Sonora, VASP, Eagle, etc. |
| 3002 | 2990 | static TIMER_CALLBACK(mac_6015_tick) |
| 3003 | 2991 | { |
| 3004 | | via6522_device *via_0 = machine->device<via6522_device>("via6522_0"); |
| 2992 | mac_state *mac = machine->driver_data<mac_state>(); |
| 3005 | 2993 | |
| 3006 | | via_0->write_ca1(0); |
| 3007 | | via_0->write_ca1(1); |
| 2994 | mac->m_via1->write_ca1(0); |
| 2995 | mac->m_via1->write_ca1(1); |
| 3008 | 2996 | } |
| 3009 | 2997 | |
| 3010 | 2998 | /* ************************************************************************* |
| 3011 | 2999 | * Main |
| 3012 | 3000 | * *************************************************************************/ |
| 3013 | 3001 | |
| 3014 | | MACHINE_START( mac ) |
| 3002 | void mac_state::machine_start() |
| 3015 | 3003 | { |
| 3016 | | mac_state *mac = machine->driver_data<mac_state>(); |
| 3017 | | if (has_adb(mac)) |
| 3004 | if (has_adb()) |
| 3018 | 3005 | { |
| 3019 | 3006 | mac_adb_timer = timer_alloc(machine, mac_adb_tick, NULL); |
| 3020 | 3007 | timer_adjust_oneshot(mac_adb_timer, attotime_never, 0); |
| 3021 | 3008 | |
| 3022 | 3009 | // also allocate PMU timer |
| 3023 | | if (ADB_IS_PM) |
| 3010 | if (ADB_IS_PM_CLASS) |
| 3024 | 3011 | { |
| 3025 | | mac->pmu_send_timer = timer_alloc(machine, mac_pmu_tick, NULL); |
| 3012 | m_pmu_send_timer = timer_alloc(machine, mac_pmu_tick, NULL); |
| 3026 | 3013 | timer_adjust_oneshot(mac_adb_timer, attotime_never, 0); |
| 3027 | 3014 | } |
| 3028 | 3015 | |
| r9489 | r9490 | |
| 3030 | 3017 | mac_scanline_timer = timer_alloc(machine, mac_scanline_tick, NULL); |
| 3031 | 3018 | timer_adjust_oneshot(mac_scanline_timer, machine->primary_screen->time_until_pos(0, 0), 0); |
| 3032 | 3019 | |
| 3033 | | mac->mac6015_timer = timer_alloc(machine, mac_6015_tick, NULL); |
| 3034 | | timer_adjust_oneshot(mac->mac6015_timer, attotime_never, 0); |
| 3020 | m_6015_timer = timer_alloc(machine, mac_6015_tick, NULL); |
| 3021 | timer_adjust_oneshot(m_6015_timer, attotime_never, 0); |
| 3035 | 3022 | } |
| 3036 | 3023 | |
| 3037 | | MACHINE_RESET(mac) |
| 3024 | void mac_state::machine_reset() |
| 3038 | 3025 | { |
| 3039 | | mac_state *mac = machine->driver_data<mac_state>(); |
| 3040 | | |
| 3041 | 3026 | // stop 60.15 Hz timer |
| 3042 | | timer_adjust_oneshot(mac->mac6015_timer, attotime_never, 0); |
| 3027 | timer_adjust_oneshot(m_6015_timer, attotime_never, 0); |
| 3043 | 3028 | |
| 3044 | 3029 | // start 60.15 Hz timer for IIci/IIsi (and eventually others) |
| 3045 | | if ((mac->model == MODEL_MAC_IICI) || (mac->model == MODEL_MAC_IISI)) |
| 3030 | if ((m_model == MODEL_MAC_IICI) || (m_model == MODEL_MAC_IISI)) |
| 3046 | 3031 | { |
| 3047 | | timer_adjust_periodic(mac->mac6015_timer, ATTOTIME_IN_HZ(60.15), 0, ATTOTIME_IN_HZ(60.15)); |
| 3032 | timer_adjust_periodic(m_6015_timer, ATTOTIME_IN_HZ(60.15), 0, ATTOTIME_IN_HZ(60.15)); |
| 3048 | 3033 | } |
| 3049 | 3034 | |
| 3050 | 3035 | // clear PMU response timer |
| 3051 | | if (ADB_IS_PM) |
| 3036 | if (ADB_IS_PM_CLASS) |
| 3052 | 3037 | { |
| 3053 | 3038 | timer_adjust_oneshot(mac_adb_timer, attotime_never, 0); |
| 3054 | 3039 | } |
| 3055 | 3040 | |
| 3056 | | last_taken_interrupt = -1; |
| 3041 | // default to 32-bit mode on LC |
| 3042 | if (m_model == MODEL_MAC_LC) |
| 3043 | { |
| 3044 | m68k_set_hmmu_enable(m_maincpu, M68K_HMMU_DISABLE); |
| 3045 | } |
| 3057 | 3046 | |
| 3047 | m_last_taken_interrupt = -1; |
| 3048 | |
| 3058 | 3049 | /* initialize real-time clock */ |
| 3059 | | rtc_init(mac); |
| 3050 | rtc_init(); |
| 3060 | 3051 | |
| 3061 | 3052 | /* setup the memory overlay */ |
| 3062 | | if (mac->model < MODEL_MAC_POWERMAC_6100) // no overlay for PowerPC |
| 3053 | if (m_model < MODEL_MAC_POWERMAC_6100) // no overlay for PowerPC |
| 3063 | 3054 | { |
| 3064 | | mac->overlay = -1; // insure no match |
| 3065 | | mac_set_memory_overlay(machine, 1); |
| 3055 | m_overlay = -1; // insure no match |
| 3056 | set_memory_overlay(machine, 1); |
| 3066 | 3057 | } |
| 3067 | 3058 | |
| 3068 | 3059 | /* setup videoram */ |
| 3069 | 3060 | mac_set_screen_buffer(1); |
| 3070 | 3061 | |
| 3071 | 3062 | /* setup sound */ |
| 3072 | | if (AUDIO_IS_CLASSIC) |
| 3063 | if (AUDIO_IS_CLASSIC_CLASS) |
| 3073 | 3064 | { |
| 3074 | 3065 | mac_set_sound_buffer(machine->device("custom"), 0); |
| 3075 | 3066 | } |
| 3076 | 3067 | else if (MAC_HAS_VIA2) // prime CB1 for ASC and slot interrupts |
| 3077 | 3068 | { |
| 3078 | | via6522_device *via2 = machine->device<via6522_device>("via6522_1"); |
| 3079 | | via2->write_ca1(1); |
| 3080 | | via2->write_cb1(1); |
| 3069 | m_via2->write_ca1(1); |
| 3070 | m_via2->write_cb1(1); |
| 3081 | 3071 | } |
| 3082 | 3072 | |
| 3083 | | if (has_adb(mac)) |
| 3073 | if (has_adb()) |
| 3084 | 3074 | { |
| 3085 | | adb_reset(mac); |
| 3075 | adb_reset(machine); |
| 3086 | 3076 | } |
| 3087 | 3077 | |
| 3088 | | if ((mac->model == MODEL_MAC_SE) || (mac->model == MODEL_MAC_CLASSIC)) |
| 3078 | if ((m_model == MODEL_MAC_SE) || (m_model == MODEL_MAC_CLASSIC)) |
| 3089 | 3079 | { |
| 3090 | 3080 | mac_set_sound_buffer(machine->device("custom"), 1); |
| 3091 | 3081 | |
| 3092 | 3082 | // classic will fail RAM test and try to boot appletalk if RAM is not all zero |
| 3093 | | memset(messram_get_ptr(machine->device("messram")), 0, messram_get_size(machine->device("messram"))); |
| 3083 | memset(messram_get_ptr(m_ram), 0, messram_get_size(m_ram)); |
| 3094 | 3084 | } |
| 3095 | 3085 | |
| 3096 | | scsi_interrupt = 0; |
| 3086 | m_scsi_interrupt = 0; |
| 3097 | 3087 | if (machine->device<cpu_device>("maincpu")->debug()) |
| 3098 | 3088 | { |
| 3099 | 3089 | machine->device<cpu_device>("maincpu")->debug()->set_dasm_override(mac_dasm_override); |
| 3100 | 3090 | } |
| 3101 | 3091 | |
| 3102 | | mac->drive_select = 0; |
| 3103 | | mac->scsiirq_enable = 0; |
| 3104 | | mac->mac_via2_vbl = 0; |
| 3105 | | mac->mac_se30_vbl_enable = 0; |
| 3106 | | mac->mac_nubus_irq_state = 0xff; |
| 3107 | | mac->keyboard_reply = 0; |
| 3108 | | mac->kbd_comm = 0; |
| 3109 | | mac->kbd_receive = 0; |
| 3110 | | mac->kbd_shift_reg = 0; |
| 3111 | | mac->kbd_shift_count = 0; |
| 3112 | | mac->mouse_bit_x = mac->mouse_bit_y = 0; |
| 3113 | | mac->rtc_rTCEnb = 0; |
| 3114 | | mac->rtc_rTCClk = 0; |
| 3115 | | mac->rtc_bit_count = 0; |
| 3116 | | mac->rtc_data_dir = 0; |
| 3117 | | mac->rtc_data_out = 0; |
| 3118 | | mac->rtc_cmd = 0; |
| 3119 | | mac->rtc_write_protect = 0; |
| 3120 | | mac->rtc_state = 0; |
| 3121 | | mac->pm_data_send = mac->pm_data_recv = mac->pm_ack = mac->pm_req = mac->pm_dptr = 0; |
| 3122 | | mac->pm_state = 0; |
| 3092 | m_drive_select = 0; |
| 3093 | m_scsiirq_enable = 0; |
| 3094 | m_via2_vbl = 0; |
| 3095 | m_se30_vbl_enable = 0; |
| 3096 | m_nubus_irq_state = 0xff; |
| 3097 | m_keyboard_reply = 0; |
| 3098 | m_kbd_comm = 0; |
| 3099 | m_kbd_receive = 0; |
| 3100 | m_kbd_shift_reg = 0; |
| 3101 | m_kbd_shift_count = 0; |
| 3102 | m_mouse_bit_x = m_mouse_bit_y = 0; |
| 3103 | m_rtc_rTCEnb = 0; |
| 3104 | m_rtc_rTCClk = 0; |
| 3105 | m_rtc_bit_count = 0; |
| 3106 | m_rtc_data_dir = 0; |
| 3107 | m_rtc_data_out = 0; |
| 3108 | m_rtc_cmd = 0; |
| 3109 | m_rtc_write_protect = 0; |
| 3110 | m_rtc_state = 0; |
| 3111 | m_pm_data_send = m_pm_data_recv = m_pm_ack = m_pm_req = m_pm_dptr = 0; |
| 3112 | m_pm_state = 0; |
| 3123 | 3113 | |
| 3124 | | memset(mac->egregs, 0xff, sizeof(mac->egregs)); |
| 3114 | memset(m_egregs, 0xff, sizeof(m_egregs)); |
| 3125 | 3115 | } |
| 3126 | 3116 | |
| 3127 | 3117 | |
| r9489 | r9490 | |
| 3131 | 3121 | int overlay; |
| 3132 | 3122 | mac_state *mac = machine->driver_data<mac_state>(); |
| 3133 | 3123 | |
| 3134 | | overlay = mac->overlay; |
| 3135 | | mac->overlay = -1; |
| 3136 | | mac_set_memory_overlay(machine, overlay); |
| 3124 | overlay = mac->m_overlay; |
| 3125 | mac->m_overlay = -1; |
| 3126 | mac->set_memory_overlay(machine, overlay); |
| 3137 | 3127 | } |
| 3138 | 3128 | |
| 3139 | 3129 | |
| r9489 | r9490 | |
| 3141 | 3131 | { |
| 3142 | 3132 | mac_state *mac = machine->driver_data<mac_state>(); |
| 3143 | 3133 | |
| 3144 | | if (mac->overlay != -1) |
| 3134 | if (mac->m_overlay != -1) |
| 3145 | 3135 | { |
| 3146 | | if ((mac->model == MODEL_MAC_PORTABLE) || (mac->model == MODEL_MAC_PB100)) |
| 3136 | if ((mac->m_model == MODEL_MAC_PORTABLE) || (mac->m_model == MODEL_MAC_PB100)) |
| 3147 | 3137 | { |
| 3148 | 3138 | if ((address >= 0x900000) && (address <= 0x9fffff)) |
| 3149 | 3139 | { |
| 3150 | | mac_set_memory_overlay(machine, 0); // kill the overlay |
| 3140 | mac->set_memory_overlay(machine, 0); // kill the overlay |
| 3151 | 3141 | } |
| 3152 | 3142 | } |
| 3153 | | else if ((mac->model == MODEL_MAC_SE) || (mac->model == MODEL_MAC_CLASSIC)) |
| 3143 | else if ((mac->m_model == MODEL_MAC_SE) || (mac->m_model == MODEL_MAC_CLASSIC)) |
| 3154 | 3144 | { |
| 3155 | 3145 | if ((address >= 0x400000) && (address <= 0x4fffff)) |
| 3156 | 3146 | { |
| 3157 | | mac_set_memory_overlay(machine, 0); // kill the overlay |
| 3147 | mac->set_memory_overlay(machine, 0); // kill the overlay |
| 3158 | 3148 | } |
| 3159 | 3149 | } |
| 3160 | | else if ((mac->model == MODEL_MAC_LC) || (mac->model == MODEL_MAC_LC_II) || (mac->model == MODEL_MAC_CLASSIC_II)) |
| 3150 | else if ((mac->m_model == MODEL_MAC_LC) || (mac->m_model == MODEL_MAC_LC_II) || (mac->m_model == MODEL_MAC_CLASSIC_II)) |
| 3161 | 3151 | { |
| 3162 | 3152 | if ((address >= 0xa00000) && (address <= 0xafffff)) |
| 3163 | 3153 | { |
| 3164 | | mac_set_memory_overlay(machine, 0); // kill the overlay |
| 3154 | mac->set_memory_overlay(machine, 0); // kill the overlay |
| 3165 | 3155 | } |
| 3166 | 3156 | } |
| 3167 | 3157 | else |
| 3168 | 3158 | { |
| 3169 | 3159 | if ((address >= 0x40000000) && (address <= 0x4fffffff)) |
| 3170 | 3160 | { |
| 3171 | | mac_set_memory_overlay(machine, 0); // kill the overlay |
| 3161 | mac->set_memory_overlay(machine, 0); // kill the overlay |
| 3172 | 3162 | } |
| 3173 | 3163 | } |
| 3174 | 3164 | } |
| r9489 | r9490 | |
| 3180 | 3170 | { |
| 3181 | 3171 | mac_state *mac = machine->driver_data<mac_state>(); |
| 3182 | 3172 | |
| 3183 | | mac->overlay = 1; |
| 3184 | | scsi_interrupt = 0; |
| 3185 | | mac->model = model; |
| 3173 | mac->m_overlay = 1; |
| 3174 | mac->m_scsi_interrupt = 0; |
| 3175 | mac->m_model = model; |
| 3186 | 3176 | |
| 3187 | | if ((mac->model == MODEL_MAC_PORTABLE) || (mac->model == MODEL_MAC_PB100)) |
| 3177 | if ((mac->m_model == MODEL_MAC_PORTABLE) || (mac->m_model == MODEL_MAC_PB100)) |
| 3188 | 3178 | { |
| 3189 | 3179 | } |
| 3190 | 3180 | else if (model < MODEL_MAC_II) |
| 3191 | 3181 | { |
| 3192 | 3182 | /* set up RAM mirror at 0x600000-0x6fffff (0x7fffff ???) */ |
| 3193 | | mac_install_memory(machine, 0x600000, 0x6fffff, messram_get_size(machine->device("messram")), messram_get_ptr(machine->device("messram")), FALSE, "bank2"); |
| 3183 | mac_install_memory(machine, 0x600000, 0x6fffff, messram_get_size(mac->m_ram), messram_get_ptr(mac->m_ram), FALSE, "bank2"); |
| 3194 | 3184 | |
| 3195 | 3185 | /* set up ROM at 0x400000-0x43ffff (-0x5fffff for mac 128k/512k/512ke) */ |
| 3196 | 3186 | mac_install_memory(machine, 0x400000, (model >= MODEL_MAC_PLUS) ? 0x43ffff : 0x5fffff, |
| 3197 | 3187 | memory_region_length(machine, "bootrom"), memory_region(machine, "bootrom"), TRUE, "bank3"); |
| 3198 | 3188 | } |
| 3199 | 3189 | |
| 3200 | | mac->overlay = -1; |
| 3201 | | mac_set_memory_overlay(machine, 1); |
| 3190 | mac->m_overlay = -1; |
| 3191 | mac->set_memory_overlay(machine, 1); |
| 3202 | 3192 | |
| 3203 | | memset(messram_get_ptr(machine->device("messram")), 0, messram_get_size(machine->device("messram"))); |
| 3193 | memset(messram_get_ptr(mac->m_ram), 0, messram_get_size(mac->m_ram)); |
| 3204 | 3194 | |
| 3205 | 3195 | if ((model == MODEL_MAC_SE) || (model == MODEL_MAC_CLASSIC) || (model == MODEL_MAC_CLASSIC_II) || (model == MODEL_MAC_LC) || |
| 3206 | | (model == MODEL_MAC_LC_II) || (model == MODEL_MAC_LC_III) || (model == MODEL_MAC_LC_III_PLUS) || ((mac->model >= MODEL_MAC_II) && (mac->model <= MODEL_MAC_SE30)) || |
| 3196 | (model == MODEL_MAC_LC_II) || (model == MODEL_MAC_LC_III) || (model == MODEL_MAC_LC_III_PLUS) || ((mac->m_model >= MODEL_MAC_II) && (mac->m_model <= MODEL_MAC_SE30)) || |
| 3207 | 3197 | (model == MODEL_MAC_PORTABLE) || (model == MODEL_MAC_PB100)) |
| 3208 | 3198 | { |
| 3209 | 3199 | cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM)->set_direct_update_handler(direct_update_delegate_create_static(overlay_opbaseoverride, *machine)); |
| r9489 | r9490 | |
| 3212 | 3202 | /* setup keyboard */ |
| 3213 | 3203 | keyboard_init(mac); |
| 3214 | 3204 | |
| 3215 | | mac->inquiry_timeout = timer_alloc(machine, inquiry_timeout_func, NULL); |
| 3205 | mac->m_inquiry_timeout = timer_alloc(machine, inquiry_timeout_func, NULL); |
| 3216 | 3206 | |
| 3217 | 3207 | /* save state stuff */ |
| 3218 | | state_save_register_global(machine, mac->overlay); |
| 3219 | 3208 | state_save_register_postload(machine, mac_state_load, NULL); |
| 3220 | 3209 | } |
| 3221 | 3210 | |
| r9489 | r9490 | |
| 3274 | 3263 | mac_driver_init(machine, MODEL_MAC_IIX); |
| 3275 | 3264 | } |
| 3276 | 3265 | |
| 3277 | | void mac_nubus_slot_interrupt(running_machine *machine, UINT8 slot, UINT32 state) |
| 3266 | void mac_state::nubus_slot_interrupt(running_machine *machine, UINT8 slot, UINT32 state) |
| 3278 | 3267 | { |
| 3279 | 3268 | UINT8 masks[6] = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20 }; |
| 3280 | 3269 | mac_state *mac = machine->driver_data<mac_state>(); |
| 3281 | | via6522_device *via_1 = machine->device<via6522_device>("via6522_1"); |
| 3282 | 3270 | |
| 3283 | 3271 | slot -= 9; |
| 3284 | 3272 | |
| 3285 | 3273 | if (state) |
| 3286 | 3274 | { |
| 3287 | | mac->mac_nubus_irq_state &= ~masks[slot]; |
| 3275 | mac->m_nubus_irq_state &= ~masks[slot]; |
| 3288 | 3276 | } |
| 3289 | 3277 | else |
| 3290 | 3278 | { |
| 3291 | | mac->mac_nubus_irq_state |= masks[slot]; |
| 3279 | mac->m_nubus_irq_state |= masks[slot]; |
| 3292 | 3280 | } |
| 3293 | 3281 | |
| 3294 | | if ((mac->mac_nubus_irq_state & 0x3f) != 0x3f) |
| 3282 | if ((mac->m_nubus_irq_state & 0x3f) != 0x3f) |
| 3295 | 3283 | { |
| 3296 | 3284 | // HACK: sometimes we miss an ack (possible misbehavior in the VIA?) |
| 3297 | | if (via_1->read_ca1() == 0) |
| 3285 | if (m_via2->read_ca1() == 0) |
| 3298 | 3286 | { |
| 3299 | | via_1->write_ca1(1); |
| 3287 | m_via2->write_ca1(1); |
| 3300 | 3288 | } |
| 3301 | 3289 | |
| 3302 | | via_1->write_ca1(0); |
| 3290 | m_via2->write_ca1(0); |
| 3303 | 3291 | } |
| 3304 | 3292 | else |
| 3305 | 3293 | { |
| 3306 | | via_1->write_ca1(1); |
| 3294 | m_via2->write_ca1(1); |
| 3307 | 3295 | } |
| 3308 | 3296 | } |
| 3309 | 3297 | |
| 3310 | | static void mac_vblank_irq(running_machine *machine) |
| 3298 | void mac_state::vblank_irq(running_machine *machine) |
| 3311 | 3299 | { |
| 3312 | 3300 | static int irq_count = 0, ca1_data = 0, ca2_data = 0; |
| 3313 | | via6522_device *via_0 = machine->device<via6522_device>("via6522_0"); |
| 3314 | | mac_state *mac = machine->driver_data<mac_state>(); |
| 3315 | 3301 | |
| 3316 | 3302 | /* handle ADB keyboard/mouse */ |
| 3317 | | if (has_adb(mac)) |
| 3303 | if (has_adb()) |
| 3318 | 3304 | { |
| 3319 | 3305 | adb_vblank(machine); |
| 3320 | 3306 | } |
| 3321 | 3307 | |
| 3322 | 3308 | /* handle keyboard */ |
| 3323 | | if (mac->kbd_comm == TRUE) |
| 3309 | if (m_kbd_comm == TRUE) |
| 3324 | 3310 | { |
| 3325 | 3311 | int keycode = scan_keyboard(machine); |
| 3326 | 3312 | |
| r9489 | r9490 | |
| 3330 | 3316 | |
| 3331 | 3317 | logerror("keyboard enquiry successful, keycode %X\n", keycode); |
| 3332 | 3318 | |
| 3333 | | timer_reset(mac->inquiry_timeout, attotime_never); |
| 3319 | timer_reset(m_inquiry_timeout, attotime_never); |
| 3334 | 3320 | kbd_shift_out(machine, keycode); |
| 3335 | 3321 | } |
| 3336 | 3322 | } |
| 3337 | 3323 | |
| 3338 | 3324 | /* signal VBlank on CA1 input on the VIA */ |
| 3339 | | if (mac->model < MODEL_MAC_II) |
| 3325 | if (m_model < MODEL_MAC_II) |
| 3340 | 3326 | { |
| 3341 | 3327 | ca1_data ^= 1; |
| 3342 | | via_0->write_ca1(ca1_data); |
| 3328 | m_via1->write_ca1(ca1_data); |
| 3343 | 3329 | } |
| 3344 | 3330 | |
| 3345 | 3331 | if (++irq_count == 60) |
| r9489 | r9490 | |
| 3348 | 3334 | |
| 3349 | 3335 | ca2_data ^= 1; |
| 3350 | 3336 | /* signal 1 Hz irq on CA2 input on the VIA */ |
| 3351 | | via_0->write_ca2(ca2_data); |
| 3337 | m_via1->write_ca2(ca2_data); |
| 3352 | 3338 | |
| 3353 | | rtc_incticks(mac); |
| 3339 | rtc_incticks(); |
| 3354 | 3340 | } |
| 3355 | 3341 | |
| 3356 | 3342 | // handle SE/30 vblank IRQ |
| 3357 | | if (mac->model == MODEL_MAC_SE30) |
| 3343 | if (m_model == MODEL_MAC_SE30) |
| 3358 | 3344 | { |
| 3359 | | if (mac->mac_se30_vbl_enable) |
| 3345 | if (m_se30_vbl_enable) |
| 3360 | 3346 | { |
| 3361 | | mac->mac_via2_vbl ^= 1; |
| 3362 | | if (!mac->mac_via2_vbl) |
| 3347 | m_via2_vbl ^= 1; |
| 3348 | if (!m_via2_vbl) |
| 3363 | 3349 | { |
| 3364 | | mac_nubus_slot_interrupt(machine, 0xe, 1); |
| 3350 | nubus_slot_interrupt(machine, 0xe, 1); |
| 3365 | 3351 | } |
| 3366 | 3352 | } |
| 3367 | 3353 | } |
| r9489 | r9490 | |
| 3379 | 3365 | |
| 3380 | 3366 | scanline = machine->primary_screen->vpos(); |
| 3381 | 3367 | if (scanline == MAC_V_VIS) |
| 3382 | | mac_vblank_irq(machine); |
| 3383 | | |
| 3368 | mac->vblank_irq(machine); |
| 3369 | |
| 3384 | 3370 | /* check for mouse changes at 10 irqs per frame */ |
| 3385 | | if (mac->model <= MODEL_MAC_PLUS) |
| 3371 | if (mac->m_model <= MODEL_MAC_PLUS) |
| 3386 | 3372 | { |
| 3387 | 3373 | if (!(scanline % 10)) |
| 3388 | 3374 | mouse_callback(machine); |
src/mess/drivers/mac.c
| r9489 | r9490 | |
| 36 | 36 | |
| 37 | 37 | ****************************************************************************/ |
| 38 | 38 | |
| 39 | #define ADDRESS_MAP_MODERN |
| 40 | |
| 39 | 41 | #include "emu.h" |
| 40 | 42 | #include "cpu/m68000/m68000.h" |
| 41 | 43 | #include "cpu/powerpc/ppc.h" |
| 42 | 44 | #include "cpu/m6805/m6805.h" |
| 43 | | #include "includes/mac.h" |
| 44 | 45 | #include "machine/6522via.h" |
| 45 | 46 | #include "machine/ncr5380.h" |
| 46 | 47 | #include "machine/applefdc.h" |
| r9489 | r9490 | |
| 51 | 52 | #include "devices/chd_cd.h" |
| 52 | 53 | #include "sound/asc.h" |
| 53 | 54 | #include "sound/cdda.h" |
| 55 | #include "includes/mac.h" |
| 54 | 56 | |
| 55 | 57 | #define C7M (7833600) |
| 56 | 58 | #define C15M (C7M*2) |
| 57 | 59 | #define C32M (C15M*2) |
| 58 | 60 | |
| 59 | | // ASC trampolines |
| 60 | | static READ8_HANDLER(mac_asc_r) |
| 61 | | { |
| 62 | | return space->machine->device<asc_device>("asc")->read(offset); |
| 63 | | } |
| 64 | | |
| 65 | | static WRITE8_HANDLER(mac_asc_w) |
| 66 | | { |
| 67 | | space->machine->device<asc_device>("asc")->write(offset, data); |
| 68 | | } |
| 69 | | |
| 70 | 61 | // do this here - VIDEO_UPDATE is called each scanline when stepping in the |
| 71 | 62 | // debugger, which means you can't escape the VIA2 IRQ handler |
| 72 | 63 | // |
| r9489 | r9490 | |
| 80 | 71 | { |
| 81 | 72 | mac_state *mac = device->machine->driver_data<mac_state>(); |
| 82 | 73 | |
| 83 | | mac->rbv_regs[2] &= ~0x40; // set vblank signal |
| 74 | mac->m_rbv_regs[2] &= ~0x40; // set vblank signal |
| 84 | 75 | |
| 85 | | if ((mac->rbv_regs[0x12] & 0x40) && (mac->rbv_ier & 0x2)) |
| 76 | if ((mac->m_rbv_regs[0x12] & 0x40) && (mac->m_rbv_ier & 0x2)) |
| 86 | 77 | { |
| 87 | | mac->rbv_ifr |= 0x82; |
| 88 | | mac_set_via2_interrupt(device->machine, 1); |
| 78 | mac->m_rbv_ifr |= 0x82; |
| 79 | mac->set_via2_interrupt(device->machine, 1); |
| 89 | 80 | } |
| 90 | 81 | } |
| 91 | 82 | |
| 92 | | static READ32_HANDLER( rbv_ramdac_r ) |
| 83 | READ32_MEMBER( mac_state::rbv_ramdac_r ) |
| 93 | 84 | { |
| 94 | 85 | return 0; |
| 95 | 86 | } |
| 96 | 87 | |
| 97 | | static WRITE32_HANDLER( rbv_ramdac_w ) |
| 88 | WRITE32_MEMBER( mac_state::rbv_ramdac_w ) |
| 98 | 89 | { |
| 99 | | mac_state *mac = space->machine->driver_data<mac_state>(); |
| 100 | | |
| 101 | 90 | if (!offset) |
| 102 | 91 | { |
| 103 | | mac->rbv_clutoffs = data>>24; |
| 104 | | mac->rbv_count = 0; |
| 92 | m_rbv_clutoffs = data>>24; |
| 93 | m_rbv_count = 0; |
| 105 | 94 | } |
| 106 | 95 | else |
| 107 | 96 | { |
| 108 | | mac->rbv_colors[mac->rbv_count++] = data>>24; |
| 97 | m_rbv_colors[m_rbv_count++] = data>>24; |
| 109 | 98 | |
| 110 | | if (mac->rbv_count == 3) |
| 99 | if (m_rbv_count == 3) |
| 111 | 100 | { |
| 112 | 101 | // for portrait display, force monochrome by using the blue channel |
| 113 | | if (mac->model != MODEL_MAC_CLASSIC_II) |
| 102 | if (m_model != MODEL_MAC_CLASSIC_II) |
| 114 | 103 | { |
| 115 | 104 | // Color Classic has no MONTYPE so the safe read gets us 512x384, which is right |
| 116 | | if (input_port_read_safe(space->machine, "MONTYPE", 2) == 1) |
| 105 | if (input_port_read_safe(space.machine, "MONTYPE", 2) == 1) |
| 117 | 106 | { |
| 118 | | palette_set_color(space->machine, mac->rbv_clutoffs, MAKE_RGB(mac->rbv_colors[2], mac->rbv_colors[2], mac->rbv_colors[2])); |
| 119 | | mac->rbv_palette[mac->rbv_clutoffs] = MAKE_RGB(mac->rbv_colors[2], mac->rbv_colors[2], mac->rbv_colors[2]); |
| 120 | | mac->rbv_clutoffs++; |
| 121 | | mac->rbv_count = 0; |
| 107 | palette_set_color(space.machine, m_rbv_clutoffs, MAKE_RGB(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2])); |
| 108 | m_rbv_palette[m_rbv_clutoffs] = MAKE_RGB(m_rbv_colors[2], m_rbv_colors[2], m_rbv_colors[2]); |
| 109 | m_rbv_clutoffs++; |
| 110 | m_rbv_count = 0; |
| 122 | 111 | } |
| 123 | 112 | else |
| 124 | 113 | { |
| 125 | | palette_set_color(space->machine, mac->rbv_clutoffs, MAKE_RGB(mac->rbv_colors[0], mac->rbv_colors[1], mac->rbv_colors[2])); |
| 126 | | mac->rbv_palette[mac->rbv_clutoffs] = MAKE_RGB(mac->rbv_colors[0], mac->rbv_colors[1], mac->rbv_colors[2]); |
| 127 | | mac->rbv_clutoffs++; |
| 128 | | mac->rbv_count = 0; |
| 114 | palette_set_color(space.machine, m_rbv_clutoffs, MAKE_RGB(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2])); |
| 115 | m_rbv_palette[m_rbv_clutoffs] = MAKE_RGB(m_rbv_colors[0], m_rbv_colors[1], m_rbv_colors[2]); |
| 116 | m_rbv_clutoffs++; |
| 117 | m_rbv_count = 0; |
| 129 | 118 | } |
| 130 | 119 | } |
| 131 | 120 | } |
| 132 | 121 | } |
| 133 | 122 | } |
| 134 | 123 | |
| 135 | | static READ8_HANDLER( mac_sonora_vctl_r ) |
| 124 | READ8_MEMBER( mac_state::mac_sonora_vctl_r ) |
| 136 | 125 | { |
| 137 | | mac_state *mac = space->machine->driver_data<mac_state>(); |
| 138 | | |
| 139 | 126 | if (offset == 2) |
| 140 | 127 | { |
| 141 | 128 | return (6 << 4); // 640x480 RGB monitor |
| 142 | 129 | } |
| 143 | 130 | |
| 144 | | return mac->sonora_vctl[offset]; |
| 131 | return m_sonora_vctl[offset]; |
| 145 | 132 | } |
| 146 | 133 | |
| 147 | | static WRITE8_HANDLER( mac_sonora_vctl_w ) |
| 134 | WRITE8_MEMBER( mac_state::mac_sonora_vctl_w ) |
| 148 | 135 | { |
| 149 | | mac_state *mac = space->machine->driver_data<mac_state>(); |
| 150 | | |
| 151 | | mac->sonora_vctl[offset] = data; |
| 136 | m_sonora_vctl[offset] = data; |
| 152 | 137 | } |
| 153 | 138 | |
| 154 | | static READ8_HANDLER ( mac_rbv_r ) |
| 139 | READ8_MEMBER ( mac_state::mac_rbv_r ) |
| 155 | 140 | { |
| 156 | 141 | int data = 0; |
| 157 | | mac_state *mac = space->machine->driver_data<mac_state>(); |
| 158 | 142 | |
| 159 | 143 | if (offset < 0x100) |
| 160 | 144 | { |
| 161 | | data = mac->rbv_regs[offset]; |
| 145 | data = m_rbv_regs[offset]; |
| 162 | 146 | |
| 163 | 147 | if (offset == 0x02) |
| 164 | 148 | { |
| 165 | | if (!space->machine->primary_screen->vblank()) |
| 149 | if (!space.machine->primary_screen->vblank()) |
| 166 | 150 | { |
| 167 | 151 | data |= 0x40; |
| 168 | 152 | } |
| r9489 | r9490 | |
| 170 | 154 | |
| 171 | 155 | if (offset == 0x10) |
| 172 | 156 | { |
| 173 | | if (!mac->rbv_immed10wr) |
| 157 | if (!m_rbv_immed10wr) |
| 174 | 158 | { |
| 175 | 159 | data &= ~0x38; |
| 176 | | data |= (input_port_read_safe(space->machine, "MONTYPE", 2)<<3); |
| 160 | data |= (input_port_read_safe(space.machine, "MONTYPE", 2)<<3); |
| 177 | 161 | } |
| 178 | 162 | else |
| 179 | 163 | { |
| 180 | | mac->rbv_immed10wr = 0; |
| 164 | m_rbv_immed10wr = 0; |
| 181 | 165 | } |
| 182 | 166 | } |
| 183 | 167 | |
| r9489 | r9490 | |
| 194 | 178 | switch (offset) |
| 195 | 179 | { |
| 196 | 180 | case 13: // IFR |
| 197 | | // printf("Read IER = %02x (PC=%x)\n", mac->rbv_ier, cpu_get_pc(space->cpu)); |
| 198 | | return mac->rbv_ifr; |
| 181 | // printf("Read IER = %02x (PC=%x)\n", m_rbv_ier, cpu_get_pc(space.cpu)); |
| 182 | return m_rbv_ifr; |
| 199 | 183 | break; |
| 200 | 184 | |
| 201 | 185 | case 14: // IER |
| 202 | | // printf("Read IFR = %02x (PC=%x)\n", mac->rbv_ifr, cpu_get_pc(space->cpu)); |
| 203 | | return mac->rbv_ier; |
| 186 | // printf("Read IFR = %02x (PC=%x)\n", m_rbv_ifr, cpu_get_pc(space.cpu)); |
| 187 | return m_rbv_ier; |
| 204 | 188 | break; |
| 205 | 189 | |
| 206 | 190 | default: |
| r9489 | r9490 | |
| 209 | 193 | } |
| 210 | 194 | } |
| 211 | 195 | |
| 212 | | // if (offset != 2) printf("rbv_r: %x = %02x (PC=%x)\n", offset, data, cpu_get_pc(space->cpu)); |
| 196 | // if (offset != 2) printf("rbv_r: %x = %02x (PC=%x)\n", offset, data, cpu_get_pc(space.cpu)); |
| 213 | 197 | |
| 214 | 198 | return data; |
| 215 | 199 | } |
| 216 | 200 | |
| 217 | | static WRITE8_HANDLER ( mac_rbv_w ) |
| 201 | WRITE8_MEMBER ( mac_state::mac_rbv_w ) |
| 218 | 202 | { |
| 219 | | mac_state *mac = space->machine->driver_data<mac_state>(); |
| 220 | | |
| 221 | 203 | if (offset < 0x100) |
| 222 | 204 | { |
| 223 | 205 | // if (offset == 0x10) |
| 224 | | // printf("rbv_w: %02x to offset %x (PC=%x)\n", data, offset, cpu_get_pc(space->cpu)); |
| 206 | // printf("rbv_w: %02x to offset %x (PC=%x)\n", data, offset, cpu_get_pc(space.cpu)); |
| 225 | 207 | switch (offset) |
| 226 | 208 | { |
| 227 | 209 | case 0x00: |
| 228 | | if (mac->model == MODEL_MAC_LC) |
| 210 | if (m_model == MODEL_MAC_LC) |
| 229 | 211 | { |
| 230 | | running_device *cpu = space->machine->device("maincpu"); |
| 231 | | |
| 232 | | m68k_set_hmmu_enable(cpu, (data & 0x8) ? M68K_HMMU_DISABLE : M68K_HMMU_ENABLE_LC); |
| 212 | m68k_set_hmmu_enable(m_maincpu, (data & 0x8) ? M68K_HMMU_DISABLE : M68K_HMMU_ENABLE_LC); |
| 233 | 213 | } |
| 234 | 214 | break; |
| 235 | 215 | |
| 236 | 216 | case 0x01: |
| 237 | | if (((data & 0xc0) != (mac->rbv_regs[1] & 0xc0)) && (mac->rbv_type == RBV_TYPE_V8)) |
| 217 | if (((data & 0xc0) != (m_rbv_regs[1] & 0xc0)) && (m_rbv_type == RBV_TYPE_V8)) |
| 238 | 218 | { |
| 239 | | mac->rbv_regs[1] = data; |
| 240 | | mac_v8_resize(space->machine, mac); |
| 219 | m_rbv_regs[1] = data; |
| 220 | v8_resize(space.machine); |
| 241 | 221 | } |
| 242 | 222 | break; |
| 243 | 223 | |
| 244 | 224 | case 0x02: |
| 245 | | if ((data & 0x40) && (mac->rbv_type == RBV_TYPE_SONORA)) |
| 225 | if ((data & 0x40) && (m_rbv_type == RBV_TYPE_SONORA)) |
| 246 | 226 | { |
| 247 | | mac->rbv_regs[offset] &= ~0x40; |
| 227 | m_rbv_regs[offset] &= ~0x40; |
| 248 | 228 | } |
| 249 | 229 | else |
| 250 | 230 | { |
| 251 | | mac->rbv_regs[offset] = data; |
| 231 | m_rbv_regs[offset] = data; |
| 252 | 232 | } |
| 253 | 233 | break; |
| 254 | 234 | |
| 255 | 235 | case 0x03: |
| 256 | | mac_set_via2_interrupt(space->machine, 0); |
| 257 | | mac->rbv_regs[offset] = data; |
| 236 | set_via2_interrupt(space.machine, 0); |
| 237 | m_rbv_regs[offset] = data; |
| 258 | 238 | break; |
| 259 | 239 | |
| 260 | 240 | case 0x10: |
| 261 | 241 | if (data != 0) |
| 262 | 242 | { |
| 263 | | mac->rbv_immed10wr = 1; |
| 243 | m_rbv_immed10wr = 1; |
| 264 | 244 | } |
| 265 | | mac->rbv_regs[offset] = data; |
| 245 | m_rbv_regs[offset] = data; |
| 266 | 246 | break; |
| 267 | 247 | |
| 268 | 248 | case 0x12: |
| 269 | 249 | if (data & 0x80) // 1 bits write 1s |
| 270 | 250 | { |
| 271 | | mac->rbv_regs[offset] |= data & 0x7f; |
| 251 | m_rbv_regs[offset] |= data & 0x7f; |
| 272 | 252 | } |
| 273 | 253 | else // 1 bits write 0s |
| 274 | 254 | { |
| 275 | | mac->rbv_regs[offset] &= ~(data & 0x7f); |
| 255 | m_rbv_regs[offset] &= ~(data & 0x7f); |
| 276 | 256 | } |
| 277 | 257 | break; |
| 278 | 258 | |
| 279 | 259 | case 0x13: |
| 280 | 260 | if (data & 0x80) // 1 bits write 1s |
| 281 | 261 | { |
| 282 | | mac->rbv_regs[offset] |= data & 0x7f; |
| 262 | m_rbv_regs[offset] |= data & 0x7f; |
| 283 | 263 | |
| 284 | | if (data == 0xff) mac->rbv_regs[offset] = 0x1f; // I don't know why this is special, but the IIci ROM's POST demands it |
| 264 | if (data == 0xff) m_rbv_regs[offset] = 0x1f; // I don't know why this is special, but the IIci ROM's POST demands it |
| 285 | 265 | } |
| 286 | 266 | else // 1 bits write 0s |
| 287 | 267 | { |
| 288 | | mac->rbv_regs[offset] &= ~(data & 0x7f); |
| 268 | m_rbv_regs[offset] &= ~(data & 0x7f); |
| 289 | 269 | } |
| 290 | | // printf("RBV: 0x13 (%02x) = %02x (PC %x)\n", data, mac->rbv_regs[offset], cpu_get_pc(space->cpu)); |
| 270 | // printf("RBV: 0x13 (%02x) = %02x (PC %x)\n", data, m_rbv_regs[offset], cpu_get_pc(space.cpu)); |
| 291 | 271 | break; |
| 292 | 272 | |
| 293 | 273 | default: |
| 294 | | mac->rbv_regs[offset] = data; |
| 274 | m_rbv_regs[offset] = data; |
| 295 | 275 | break; |
| 296 | 276 | } |
| 297 | 277 | } |
| r9489 | r9490 | |
| 303 | 283 | { |
| 304 | 284 | case 13: // IFR |
| 305 | 285 | // printf("rbv_w: %02x to IFR\n", data); |
| 306 | | mac->rbv_ifr = data; |
| 307 | | mac_set_via2_interrupt(space->machine, 0); |
| 286 | m_rbv_ifr = data; |
| 287 | set_via2_interrupt(space.machine, 0); |
| 308 | 288 | break; |
| 309 | 289 | |
| 310 | 290 | case 14: // IER |
| 311 | 291 | if (data & 0x80) // 1 bits write 1s |
| 312 | 292 | { |
| 313 | | mac->rbv_ier |= data & 0x7f; |
| 293 | m_rbv_ier |= data & 0x7f; |
| 314 | 294 | } |
| 315 | 295 | else // 1 bits write 0s |
| 316 | 296 | { |
| 317 | | mac->rbv_ier &= ~(data & 0x7f); |
| 297 | m_rbv_ier &= ~(data & 0x7f); |
| 318 | 298 | } |
| 319 | 299 | |
| 320 | | // printf("rbv_w: %02x to IER => %02x\n", data, mac->rbv_ier); |
| 300 | // printf("rbv_w: %02x to IER => %02x\n", data, m_rbv_ier); |
| 321 | 301 | break; |
| 322 | 302 | |
| 323 | 303 | default: |
| r9489 | r9490 | |
| 327 | 307 | } |
| 328 | 308 | } |
| 329 | 309 | |
| 330 | | static READ32_HANDLER(mac_read_id) |
| 310 | READ32_MEMBER(mac_state::mac_read_id) |
| 331 | 311 | { |
| 332 | | mac_state *mac = space->machine->driver_data<mac_state>(); |
| 312 | logerror("Mac read ID reg @ PC=%x\n", cpu_get_pc(space.cpu)); |
| 333 | 313 | |
| 334 | | logerror("Mac read ID reg @ PC=%x\n", cpu_get_pc(space->cpu)); |
| 335 | | |
| 336 | | switch (mac->model) |
| 314 | switch (m_model) |
| 337 | 315 | { |
| 338 | 316 | case MODEL_MAC_LC_III: |
| 339 | 317 | return 0xa55a0001; // 25 MHz LC III |
| r9489 | r9490 | |
| 374 | 352 | return 0; |
| 375 | 353 | } |
| 376 | 354 | |
| 377 | | static READ16_HANDLER(mac_config_r) |
| 355 | READ16_MEMBER(mac_state::mac_config_r) |
| 378 | 356 | { |
| 379 | 357 | return 0xffff; // not sure what this does |
| 380 | 358 | } |
| r9489 | r9490 | |
| 383 | 361 | ADDRESS MAPS |
| 384 | 362 | ***************************************************************************/ |
| 385 | 363 | |
| 386 | | static ADDRESS_MAP_START(mac512ke_map, ADDRESS_SPACE_PROGRAM, 16) |
| 364 | static ADDRESS_MAP_START(mac512ke_map, ADDRESS_SPACE_PROGRAM, 16, mac_state ) |
| 387 | 365 | AM_RANGE(0x800000, 0x9fffff) AM_READ(mac_scc_r) |
| 388 | 366 | AM_RANGE(0xa00000, 0xbfffff) AM_WRITE(mac_scc_w) |
| 389 | 367 | AM_RANGE(0xc00000, 0xdfffff) AM_READWRITE(mac_iwm_r, mac_iwm_w) |
| r9489 | r9490 | |
| 391 | 369 | AM_RANGE(0xfffff0, 0xffffff) AM_READWRITE(mac_autovector_r, mac_autovector_w) |
| 392 | 370 | ADDRESS_MAP_END |
| 393 | 371 | |
| 394 | | static ADDRESS_MAP_START(macplus_map, ADDRESS_SPACE_PROGRAM, 16) |
| 372 | static ADDRESS_MAP_START(macplus_map, ADDRESS_SPACE_PROGRAM, 16, mac_state ) |
| 395 | 373 | AM_RANGE(0x580000, 0x5fffff) AM_READWRITE(macplus_scsi_r, macplus_scsi_w) |
| 396 | 374 | AM_RANGE(0x800000, 0x9fffff) AM_READ(mac_scc_r) |
| 397 | 375 | AM_RANGE(0xa00000, 0xbfffff) AM_WRITE(mac_scc_w) |
| r9489 | r9490 | |
| 400 | 378 | AM_RANGE(0xfffff0, 0xffffff) AM_READWRITE(mac_autovector_r, mac_autovector_w) |
| 401 | 379 | ADDRESS_MAP_END |
| 402 | 380 | |
| 403 | | static ADDRESS_MAP_START(macprtb_map, ADDRESS_SPACE_PROGRAM, 16) |
| 381 | static ADDRESS_MAP_START(macprtb_map, ADDRESS_SPACE_PROGRAM, 16, mac_state ) |
| 404 | 382 | AM_RANGE(0x900000, 0x93ffff) AM_ROM AM_REGION("bootrom", 0) AM_MIRROR(0x0c0000) |
| 405 | 383 | AM_RANGE(0xf60000, 0xf6ffff) AM_READWRITE(mac_iwm_r, mac_iwm_w) |
| 406 | 384 | AM_RANGE(0xf70000, 0xf7ffff) AM_READWRITE(mac_via_r, mac_via_w) |
| 407 | 385 | AM_RANGE(0xf90000, 0xf9ffff) AM_READWRITE(macplus_scsi_r, macplus_scsi_w) |
| 408 | 386 | AM_RANGE(0xfa8000, 0xfaffff) AM_RAM // VRAM |
| 409 | | AM_RANGE(0xfb0000, 0xfbffff) AM_READWRITE8(mac_asc_r, mac_asc_w, 0xffff) |
| 387 | AM_RANGE(0xfb0000, 0xfbffff) AM_DEVREADWRITE8("asc", asc_device, read, write, 0xffff) |
| 410 | 388 | AM_RANGE(0xfc0000, 0xfcffff) AM_READ(mac_config_r) |
| 411 | 389 | AM_RANGE(0xfd0000, 0xfdffff) AM_READWRITE(mac_scc_r, mac_scc_2_w) |
| 412 | 390 | AM_RANGE(0xfffff0, 0xffffff) AM_READWRITE(mac_autovector_r, mac_autovector_w) |
| 413 | 391 | ADDRESS_MAP_END |
| 414 | 392 | |
| 415 | | static ADDRESS_MAP_START(maclc_map, ADDRESS_SPACE_PROGRAM, 32) |
| 416 | | AM_RANGE(0x00a00000, 0x00a7ffff) AM_ROM AM_REGION("bootrom", 0) // ROM (in 32-bit mode) |
| 393 | static ADDRESS_MAP_START(maclc_map, ADDRESS_SPACE_PROGRAM, 32, mac_state ) |
| 394 | ADDRESS_MAP_GLOBAL_MASK(0x80ffffff) // V8 uses bit 31 and 23-0 for address decoding only |
| 417 | 395 | |
| 418 | | AM_RANGE(0xf00000, 0xf01fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) |
| 419 | | AM_RANGE(0xf04000, 0xf05fff) AM_READWRITE16(mac_scc_r, mac_scc_2_w, 0xffffffff) |
| 420 | | AM_RANGE(0xf06000, 0xf06003) AM_WRITE(macii_scsi_drq_w) AM_MIRROR(0x00f00000) |
| 421 | | AM_RANGE(0xf10000, 0xf11fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 422 | | AM_RANGE(0xf12060, 0xf12063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 423 | | AM_RANGE(0xf14000, 0xf15fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) |
| 424 | | AM_RANGE(0xf16000, 0xf17fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 425 | | AM_RANGE(0xf24000, 0xf24003) AM_READWRITE(rbv_ramdac_r, rbv_ramdac_w) |
| 426 | | AM_RANGE(0xf26000, 0xf27fff) AM_READWRITE8(mac_rbv_r, mac_rbv_w, 0xffffffff) // VIA2 (V8) |
| 396 | AM_RANGE(0xa00000, 0xa7ffff) AM_ROM AM_REGION("bootrom", 0) // ROM (in 32-bit mode) |
| 427 | 397 | |
| 428 | | AM_RANGE(0x50f00000, 0x50f01fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) |
| 429 | | AM_RANGE(0x50f04000, 0x50f05fff) AM_READWRITE16(mac_scc_r, mac_scc_2_w, 0xffffffff) |
| 430 | | AM_RANGE(0x50f06000, 0x50f06003) AM_WRITE(macii_scsi_drq_w) AM_MIRROR(0x00f00000) |
| 431 | | AM_RANGE(0x50f10000, 0x50f11fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 432 | | AM_RANGE(0x50f12060, 0x50f12063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 433 | | AM_RANGE(0x50f14000, 0x50f15fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) |
| 434 | | AM_RANGE(0x50f16000, 0x50f17fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 435 | | AM_RANGE(0x50f24000, 0x50f24003) AM_READWRITE(rbv_ramdac_r,rbv_ramdac_w) |
| 436 | | AM_RANGE(0x50f26000, 0x50f27fff) AM_READWRITE8(mac_rbv_r, mac_rbv_w, 0xffffffff) // VIA2 (V8) |
| 437 | | AM_RANGE(0x50f40000, 0x50fbffff) AM_RAM AM_BASE_MEMBER(mac_state, rbv_vram) |
| 438 | | ADDRESS_MAP_END |
| 439 | | /* |
| 440 | | static ADDRESS_MAP_START(macclrclassic_map, ADDRESS_SPACE_PROGRAM, 32) |
| 441 | | AM_RANGE(0x00a00000, 0x00afffff) AM_ROM AM_REGION("bootrom", 0) |
| 442 | | AM_RANGE(0x40a00000, 0x40afffff) AM_ROM AM_REGION("bootrom", 0) |
| 443 | | |
| 444 | 398 | AM_RANGE(0xf00000, 0xf01fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) |
| 445 | 399 | AM_RANGE(0xf04000, 0xf05fff) AM_READWRITE16(mac_scc_r, mac_scc_2_w, 0xffffffff) |
| 446 | 400 | AM_RANGE(0xf06000, 0xf06003) AM_WRITE(macii_scsi_drq_w) AM_MIRROR(0x00f00000) |
| 447 | 401 | AM_RANGE(0xf10000, 0xf11fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 448 | 402 | AM_RANGE(0xf12060, 0xf12063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 449 | | AM_RANGE(0xf14000, 0xf15fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) |
| 403 | AM_RANGE(0xf14000, 0xf15fff) AM_DEVREADWRITE8("asc", asc_device, read, write, 0xffffffff) AM_MIRROR(0x00f00000) |
| 450 | 404 | AM_RANGE(0xf16000, 0xf17fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 451 | 405 | AM_RANGE(0xf24000, 0xf24003) AM_READWRITE(rbv_ramdac_r, rbv_ramdac_w) |
| 452 | 406 | AM_RANGE(0xf26000, 0xf27fff) AM_READWRITE8(mac_rbv_r, mac_rbv_w, 0xffffffff) // VIA2 (V8) |
| 453 | | |
| 454 | | AM_RANGE(0x50f00000, 0x50f01fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) |
| 455 | | AM_RANGE(0x50f04000, 0x50f05fff) AM_READWRITE16(mac_scc_r, mac_scc_2_w, 0xffffffff) |
| 456 | | AM_RANGE(0x50f06000, 0x50f06003) AM_WRITE(macii_scsi_drq_w) AM_MIRROR(0x00f00000) |
| 457 | | AM_RANGE(0x50f10000, 0x50f11fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 458 | | AM_RANGE(0x50f12060, 0x50f12063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 459 | | AM_RANGE(0x50f14000, 0x50f15fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) |
| 460 | | AM_RANGE(0x50f16000, 0x50f17fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 461 | | AM_RANGE(0x50f24000, 0x50f24003) AM_READWRITE(rbv_ramdac_r,rbv_ramdac_w) |
| 462 | | AM_RANGE(0x50f26000, 0x50f27fff) AM_READWRITE8(mac_rbv_r, mac_rbv_w, 0xffffffff) // VIA2 (V8) |
| 463 | | AM_RANGE(0x50f40000, 0x50fbffff) AM_RAM AM_BASE_MEMBER(mac_state, rbv_vram) |
| 407 | AM_RANGE(0xf40000, 0xfbffff) AM_RAM AM_BASE(m_rbv_vram) |
| 464 | 408 | ADDRESS_MAP_END |
| 465 | | */ |
| 466 | | static ADDRESS_MAP_START(maclc3_map, ADDRESS_SPACE_PROGRAM, 32) |
| 409 | |
| 410 | static ADDRESS_MAP_START(maclc3_map, ADDRESS_SPACE_PROGRAM, 32, mac_state ) |
| 467 | 411 | AM_RANGE(0x40000000, 0x400fffff) AM_ROM AM_REGION("bootrom", 0) AM_MIRROR(0x0ff00000) |
| 468 | 412 | |
| 469 | 413 | AM_RANGE(0x50000000, 0x50001fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 470 | 414 | AM_RANGE(0x50004000, 0x50005fff) AM_READWRITE16(mac_scc_r, mac_scc_2_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 471 | | AM_RANGE(0x50014000, 0x50015fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 415 | AM_RANGE(0x50014000, 0x50015fff) AM_DEVREADWRITE8("asc", asc_device, read, write, 0xffffffff) AM_MIRROR(0x00f00000) |
| 472 | 416 | AM_RANGE(0x50016000, 0x50017fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 473 | 417 | AM_RANGE(0x50024000, 0x50024007) AM_WRITE( rbv_ramdac_w ) AM_MIRROR(0x00f00000) |
| 474 | | AM_RANGE(0x50026000, 0x50027fff) AM_READWRITE16(mac_rbv_r, mac_rbv_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 418 | AM_RANGE(0x50026000, 0x50027fff) AM_READWRITE8(mac_rbv_r, mac_rbv_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 475 | 419 | AM_RANGE(0x50028000, 0x50028003) AM_READWRITE8(mac_sonora_vctl_r, mac_sonora_vctl_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 476 | 420 | |
| 477 | 421 | AM_RANGE(0x5ffffffc, 0x5fffffff) AM_READ(mac_read_id) |
| 478 | 422 | |
| 479 | | AM_RANGE(0x60000000, 0x600fffff) AM_RAM AM_MIRROR(0x0ff00000) AM_BASE_MEMBER(mac_state, rbv_vram) |
| 423 | AM_RANGE(0x60000000, 0x600fffff) AM_RAM AM_MIRROR(0x0ff00000) AM_BASE(m_rbv_vram) |
| 480 | 424 | ADDRESS_MAP_END |
| 481 | 425 | |
| 482 | | static ADDRESS_MAP_START(macii_map, ADDRESS_SPACE_PROGRAM, 32) |
| 426 | static ADDRESS_MAP_START(macii_map, ADDRESS_SPACE_PROGRAM, 32, mac_state ) |
| 483 | 427 | AM_RANGE(0x40000000, 0x4003ffff) AM_ROM AM_REGION("bootrom", 0) AM_MIRROR(0x0ffc0000) |
| 484 | 428 | |
| 485 | 429 | // MMU remaps I/O without the F |
| r9489 | r9490 | |
| 490 | 434 | AM_RANGE(0x50006060, 0x50006063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 491 | 435 | AM_RANGE(0x50010000, 0x50011fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 492 | 436 | AM_RANGE(0x50012060, 0x50012063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 493 | | AM_RANGE(0x50014000, 0x50015fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 437 | AM_RANGE(0x50014000, 0x50015fff) AM_DEVREADWRITE8("asc", asc_device, read, write, 0xffffffff) AM_MIRROR(0x00f00000) |
| 494 | 438 | AM_RANGE(0x50016000, 0x50017fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 495 | 439 | AM_RANGE(0x50040000, 0x50041fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 496 | 440 | |
| 497 | 441 | // RasterOps 264 640x480 fixed-res color video card (8, 16, or 24 bit) |
| 498 | | AM_RANGE(0xfe000000, 0xfe1fffff) AM_RAM AM_BASE(&mac_cb264_vram) // supposed to be 1.5 megs of VRAM, but every other word? |
| 442 | AM_RANGE(0xfe000000, 0xfe1fffff) AM_RAM AM_BASE(m_cb264_vram) // supposed to be 1.5 megs of VRAM, but every other word? |
| 499 | 443 | AM_RANGE(0xfeff6000, 0xfeff60ff) AM_READWRITE( mac_cb264_r, mac_cb264_w ) |
| 500 | 444 | AM_RANGE(0xfeff7000, 0xfeff7fff) AM_WRITE( mac_cb264_ramdac_w ) |
| 501 | 445 | AM_RANGE(0xfeff8000, 0xfeffffff) AM_ROM AM_REGION("rops264", 0) |
| 502 | 446 | ADDRESS_MAP_END |
| 503 | 447 | |
| 504 | | static ADDRESS_MAP_START(maciici_map, ADDRESS_SPACE_PROGRAM, 32) |
| 448 | static ADDRESS_MAP_START(maciici_map, ADDRESS_SPACE_PROGRAM, 32, mac_state ) |
| 505 | 449 | AM_RANGE(0x40000000, 0x4007ffff) AM_ROM AM_REGION("bootrom", 0) AM_MIRROR(0x0ff80000) |
| 506 | 450 | |
| 507 | 451 | AM_RANGE(0x50000000, 0x50001fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| r9489 | r9490 | |
| 510 | 454 | AM_RANGE(0x50006060, 0x50006063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 511 | 455 | AM_RANGE(0x50010000, 0x50011fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 512 | 456 | AM_RANGE(0x50012060, 0x50012063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 513 | | AM_RANGE(0x50014000, 0x50015fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 457 | AM_RANGE(0x50014000, 0x50015fff) AM_DEVREADWRITE8("asc", asc_device, read, write, 0xffffffff) AM_MIRROR(0x00f00000) |
| 514 | 458 | AM_RANGE(0x50016000, 0x50017fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 515 | 459 | AM_RANGE(0x50024000, 0x50024007) AM_WRITE( rbv_ramdac_w ) AM_MIRROR(0x00f00000) |
| 516 | | AM_RANGE(0x50026000, 0x50027fff) AM_READWRITE16(mac_rbv_r, mac_rbv_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 460 | AM_RANGE(0x50026000, 0x50027fff) AM_READWRITE8(mac_rbv_r, mac_rbv_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 517 | 461 | AM_RANGE(0x50040000, 0x50041fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 518 | 462 | ADDRESS_MAP_END |
| 519 | 463 | |
| 520 | | static ADDRESS_MAP_START(macse30_map, ADDRESS_SPACE_PROGRAM, 32) |
| 464 | static ADDRESS_MAP_START(macse30_map, ADDRESS_SPACE_PROGRAM, 32, mac_state ) |
| 521 | 465 | AM_RANGE(0x40000000, 0x4003ffff) AM_ROM AM_REGION("bootrom", 0) AM_MIRROR(0x0ffc0000) |
| 522 | 466 | |
| 523 | 467 | AM_RANGE(0x50000000, 0x50001fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| r9489 | r9490 | |
| 527 | 471 | AM_RANGE(0x50006060, 0x50006063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 528 | 472 | AM_RANGE(0x50010000, 0x50011fff) AM_READWRITE16(macplus_scsi_r, macii_scsi_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 529 | 473 | AM_RANGE(0x50012060, 0x50012063) AM_READ(macii_scsi_drq_r) AM_MIRROR(0x00f00000) |
| 530 | | AM_RANGE(0x50014000, 0x50015fff) AM_READ8(mac_asc_r, 0xffffffff) AM_WRITE8(mac_asc_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 474 | AM_RANGE(0x50014000, 0x50015fff) AM_DEVREADWRITE8("asc", asc_device, read, write, 0xffffffff) AM_MIRROR(0x00f00000) |
| 531 | 475 | AM_RANGE(0x50016000, 0x50017fff) AM_READWRITE16(mac_iwm_r, mac_iwm_w, 0xffffffff) AM_MIRROR(0x00f00000) |
| 532 | 476 | AM_RANGE(0x50040000, 0x50041fff) AM_READWRITE16(mac_via_r, mac_via_w, 0xffffffff) AM_MIRROR(0x00f00000) // mirror |
| 533 | 477 | |
| 534 | | AM_RANGE(0xfe000000, 0xfe00ffff) AM_RAM AM_BASE(&mac_se30_vram) |
| 478 | AM_RANGE(0xfe000000, 0xfe00ffff) AM_RAM AM_BASE(m_se30_vram) |
| 535 | 479 | AM_RANGE(0xfeffe000, 0xfeffffff) AM_ROM AM_REGION("se30vrom", 0x0) |
| 536 | 480 | ADDRESS_MAP_END |
| 537 | 481 | |
| 538 | | static ADDRESS_MAP_START(pwrmac_map, ADDRESS_SPACE_PROGRAM, 64) |
| 482 | static ADDRESS_MAP_START(pwrmac_map, ADDRESS_SPACE_PROGRAM, 64, mac_state ) |
| 539 | 483 | AM_RANGE(0x00000000, 0x007fffff) AM_RAM // 8 MB standard |
| 540 | 484 | |
| 541 | 485 | AM_RANGE(0x40000000, 0x403fffff) AM_ROM AM_REGION("bootrom", 0) AM_MIRROR(0x0fc00000) |
| r9489 | r9490 | |
| 621 | 565 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1260)) |
| 622 | 566 | MDRV_QUANTUM_TIME(HZ(60)) |
| 623 | 567 | |
| 624 | | MDRV_MACHINE_START( mac ) |
| 625 | | MDRV_MACHINE_RESET( mac ) |
| 626 | | |
| 627 | 568 | /* video hardware */ |
| 628 | 569 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) |
| 629 | 570 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| r9489 | r9490 | |
| 701 | 642 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1260)) |
| 702 | 643 | MDRV_QUANTUM_TIME(HZ(60)) |
| 703 | 644 | |
| 704 | | MDRV_MACHINE_START( mac ) |
| 705 | | MDRV_MACHINE_RESET( mac ) |
| 706 | | |
| 707 | 645 | /* video hardware */ |
| 708 | 646 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) |
| 709 | 647 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| r9489 | r9490 | |
| 747 | 685 | static MACHINE_CONFIG_START( macii, mac_state ) |
| 748 | 686 | |
| 749 | 687 | /* basic machine hardware */ |
| 750 | | MDRV_CPU_ADD("maincpu", M68020PMMU, 7833600*2) |
| 688 | MDRV_CPU_ADD("maincpu", M68020HMMU, 7833600*2) |
| 751 | 689 | MDRV_CPU_PROGRAM_MAP(macii_map) |
| 752 | 690 | MDRV_CPU_VBLANK_INT("screen", mac_cb264_vbl) |
| 753 | 691 | |
| r9489 | r9490 | |
| 755 | 693 | // dot clock, htotal, hstart, hend, vtotal, vstart, vend |
| 756 | 694 | MDRV_SCREEN_RAW_PARAMS(25175000, 800, 0, 640, 525, 0, 480) |
| 757 | 695 | |
| 758 | | MDRV_MACHINE_START( mac ) |
| 759 | | MDRV_MACHINE_RESET( mac ) |
| 760 | | |
| 761 | 696 | /* video hardware */ |
| 762 | 697 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) |
| 763 | 698 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| r9489 | r9490 | |
| 800 | 735 | |
| 801 | 736 | static MACHINE_CONFIG_DERIVED( maclc, macii ) |
| 802 | 737 | |
| 803 | | MDRV_CPU_REPLACE("maincpu", M68020, 7833600*2) |
| 738 | MDRV_CPU_REPLACE("maincpu", M68020HMMU, 7833600*2) |
| 804 | 739 | MDRV_CPU_PROGRAM_MAP(maclc_map) |
| 805 | 740 | MDRV_CPU_VBLANK_INT("screen", mac_rbv_vbl) |
| 806 | 741 | |
| r9489 | r9490 | |
| 828 | 763 | MDRV_RAM_DEFAULT_SIZE("4M") |
| 829 | 764 | MDRV_RAM_EXTRA_OPTIONS("6M,8M,10M") |
| 830 | 765 | MACHINE_CONFIG_END |
| 831 | | /* |
| 832 | | static MACHINE_CONFIG_DERIVED( maccclas, maclc2 ) |
| 833 | 766 | |
| 834 | | MDRV_CPU_REPLACE("maincpu", M68030, 7833600*2) |
| 835 | | MDRV_CPU_PROGRAM_MAP(macclrclassic_map) |
| 836 | | MDRV_CPU_VBLANK_INT("screen", mac_rbv_vbl) |
| 837 | | |
| 838 | | MDRV_RAM_MODIFY("messram") |
| 839 | | MDRV_RAM_DEFAULT_SIZE("4M") |
| 840 | | MDRV_RAM_EXTRA_OPTIONS("6M,8M,10M") |
| 841 | | MACHINE_CONFIG_END |
| 842 | | */ |
| 843 | 767 | static MACHINE_CONFIG_DERIVED( maclc3, maclc ) |
| 844 | 768 | |
| 845 | 769 | MDRV_CPU_REPLACE("maincpu", M68030, 25000000) |
| r9489 | r9490 | |
| 879 | 803 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1260)) |
| 880 | 804 | MDRV_QUANTUM_TIME(HZ(60)) |
| 881 | 805 | |
| 882 | | MDRV_MACHINE_START( mac ) |
| 883 | | MDRV_MACHINE_RESET( mac ) |
| 884 | | |
| 885 | 806 | /* video hardware */ |
| 886 | 807 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) |
| 887 | 808 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| r9489 | r9490 | |
| 996 | 917 | // dot clock, htotal, hstart, hend, vtotal, vstart, vend |
| 997 | 918 | MDRV_SCREEN_RAW_PARAMS(25175000, 800, 0, 640, 525, 0, 480) |
| 998 | 919 | |
| 999 | | MDRV_MACHINE_START( mac ) |
| 1000 | | MDRV_MACHINE_RESET( mac ) |
| 1001 | | |
| 1002 | 920 | /* video hardware */ |
| 1003 | 921 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) |
| 1004 | 922 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32) |
| r9489 | r9490 | |
| 1450 | 1368 | ROM_REGION16_BE(0x40000, "bootrom", 0) |
| 1451 | 1369 | ROM_LOAD16_WORD( "96645f9c.rom", 0x000000, 0x040000, CRC(29ac7ee9) SHA1(7f3acf40b1f63612de2314a2e9fcfeafca0711fc) ) |
| 1452 | 1370 | ROM_END |
| 1453 | | /* |
| 1371 | |
| 1454 | 1372 | ROM_START( maccclas ) |
| 1455 | 1373 | ROM_REGION32_BE(0x100000, "bootrom", 0) |
| 1456 | 1374 | ROM_LOAD( "ecd99dc0.rom", 0x000000, 0x100000, CRC(c84c3aa5) SHA1(fd9e852e2d77fe17287ba678709b9334d4d74f1e) ) |
| r9489 | r9490 | |
| 1458 | 1376 | ROM_REGION(0x1100, "egret", 0) |
| 1459 | 1377 | ROM_LOAD( "341s0851.bin", 0x000000, 0x001100, CRC(ea9ea6e4) SHA1(8b0dae3ec66cdddbf71567365d2c462688aeb571) ) |
| 1460 | 1378 | ROM_END |
| 1461 | | */ |
| 1379 | |
| 1462 | 1380 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ |
| 1463 | 1381 | COMP( 1984, mac128k, 0, 0, mac128k, macplus, mac128k512k, "Apple Computer", "Macintosh 128k", GAME_NOT_WORKING ) |
| 1464 | 1382 | COMP( 1984, mac512k, mac128k, 0, mac512ke, macplus, mac128k512k, "Apple Computer", "Macintosh 512k", GAME_NOT_WORKING ) |
| r9489 | r9490 | |
| 1479 | 1397 | COMP( 1991, macpb100, 0, 0, macprtb, macadb, macprtb, "Apple Computer", "Macintosh PowerBook 100", GAME_NOT_WORKING ) |
| 1480 | 1398 | COMP( 1991, macclas2, 0, 0, macclas2, macadb, macclassic2, "Apple Computer", "Macintosh Classic II", GAME_NOT_WORKING ) |
| 1481 | 1399 | COMP( 1991, maclc2, 0, 0, maclc2, maciici, maclc2, "Apple Computer", "Macintosh LC II", GAME_NOT_WORKING ) |
| 1482 | | //COMP( 1993, maccclas, 0, 0, maccclas, macadb, maclrcclassic, "Apple Computer", "Macintosh Color Classic", GAME_NOT_WORKING ) |
| 1400 | COMP( 1993, maccclas, 0, 0, maclc2, macadb, maclrcclassic, "Apple Computer", "Macintosh Color Classic", GAME_NOT_WORKING ) |
| 1483 | 1401 | COMP( 1993, maclc3, 0, 0, maclc3, maciici, maclc3, "Apple Computer", "Macintosh LC III", GAME_NOT_WORKING ) |
| 1484 | 1402 | COMP( 1994, pmac6100, 0, 0, pwrmac, macadb, macpm6100, "Apple Computer", "Power Macintosh 6100", GAME_NOT_WORKING | GAME_NO_SOUND ) |
| 1485 | 1403 | |