src/mame/machine/smpc.c
| r12434 | r12435 | |
| 173 | 173 | // if (offset == 0x33) //country code |
| 174 | 174 | // return_data = input_port_read(machine, "FAKE"); |
| 175 | 175 | |
| 176 | | //if(LOG_SMPC) logerror ("cpu %s (PC=%08X) SMPC: Read from Byte Offset %02x Returns %02x\n", space->device().tag(), cpu_get_pc(&space->device()), offset, return_data); |
| 176 | //if(LOG_SMPC) printf ("cpu %s (PC=%08X) SMPC: Read from Byte Offset %02x Returns %02x\n", space->device().tag(), cpu_get_pc(&space->device()), offset, return_data); |
| 177 | 177 | |
| 178 | 178 | |
| 179 | 179 | return return_data; |
| r12434 | r12435 | |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | // /*This is for RTC,cartridge code and similar stuff...*/ |
| 366 | | //if(LOG_SMPC) logerror ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline); |
| 366 | //if(LOG_SMPC) printf ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline); |
| 367 | 367 | if(!(state->m_scu.ism & IRQ_SMPC)) |
| 368 | 368 | device_set_input_line_and_vector(state->m_maincpu, 8, HOLD_LINE, 0x47); |
| 369 | 369 | else |
| 370 | 370 | state->m_scu.ist |= (IRQ_SMPC); |
| 371 | |
| 372 | /* clear hand-shake flag */ |
| 373 | state->m_smpc_ram[0x63] = 0x00; |
| 371 | 374 | } |
| 372 | 375 | |
| 373 | 376 | static void smpc_rtc_write(running_machine &machine) |
| r12434 | r12435 | |
| 413 | 416 | system_time systime; |
| 414 | 417 | space->machine().base_datetime(systime); |
| 415 | 418 | |
| 416 | | // if(LOG_SMPC) logerror ("8-bit SMPC Write to Offset %02x with Data %02x\n", offset, data); |
| 419 | // if(LOG_SMPC) printf ("8-bit SMPC Write to Offset %02x with Data %02x\n", offset, data); |
| 417 | 420 | state->m_smpc_ram[offset] = data; |
| 418 | 421 | |
| 419 | 422 | if(offset == 0x75) |
| r12434 | r12435 | |
| 444 | 447 | */ |
| 445 | 448 | //popmessage("PDR2 = %02x",state->m_smpc_ram[0x77]); |
| 446 | 449 | |
| 447 | | if(LOG_SMPC) logerror("SMPC: M68k %s\n",(state->m_smpc_ram[0x77] & 0x10) ? "off" : "on"); |
| 450 | if(LOG_SMPC) printf("SMPC: M68k %s\n",(state->m_smpc_ram[0x77] & 0x10) ? "off" : "on"); |
| 448 | 451 | cputag_set_input_line(space->machine(), "audiocpu", INPUT_LINE_RESET, (state->m_smpc_ram[0x77] & 0x10) ? ASSERT_LINE : CLEAR_LINE); |
| 449 | 452 | state->m_en_68k = ((state->m_smpc_ram[0x77] & 0x10) >> 4) ^ 1; |
| 450 | 453 | |
| 451 | | //if(LOG_SMPC) logerror("SMPC: ram [0x77] = %02x\n",state->m_smpc_ram[0x77]); |
| 454 | //if(LOG_SMPC) printf("SMPC: ram [0x77] = %02x\n",state->m_smpc_ram[0x77]); |
| 452 | 455 | state->m_smpc.PDR2 = (data & 0x60); |
| 453 | 456 | } |
| 454 | 457 | |
| r12434 | r12435 | |
| 474 | 477 | switch (data) |
| 475 | 478 | { |
| 476 | 479 | case 0x00: |
| 477 | | if(LOG_SMPC) logerror ("SMPC: Master ON\n"); |
| 480 | if(LOG_SMPC) printf ("SMPC: Master ON\n"); |
| 478 | 481 | smpc_master_on(space->machine()); |
| 479 | 482 | break; |
| 480 | 483 | //in theory 0x01 is for Master OFF,but obviously is not used. |
| 481 | 484 | case 0x02: |
| 482 | 485 | case 0x03: |
| 483 | | if(LOG_SMPC) logerror ("SMPC: Slave %s\n",(data & 1) ? "off" : "on"); |
| 486 | if(LOG_SMPC) printf ("SMPC: Slave %s\n",(data & 1) ? "off" : "on"); |
| 484 | 487 | smpc_slave_enable(space->machine(),(data & 1)); |
| 485 | 488 | break; |
| 486 | 489 | case 0x06: |
| 487 | 490 | case 0x07: |
| 488 | | if(LOG_SMPC) logerror ("SMPC: Sound %s, ignored\n",(data & 1) ? "off" : "on"); |
| 491 | if(LOG_SMPC) printf ("SMPC: Sound %s, ignored\n",(data & 1) ? "off" : "on"); |
| 489 | 492 | break; |
| 490 | 493 | /*CD (SH-1) ON/OFF,guess that this is needed for Sports Fishing games...*/ |
| 491 | 494 | //case 0x08: |
| 492 | 495 | //case 0x09: |
| 493 | 496 | case 0x0d: |
| 494 | | if(LOG_SMPC) logerror ("SMPC: System Reset\n"); |
| 497 | if(LOG_SMPC) printf ("SMPC: System Reset\n"); |
| 495 | 498 | smpc_system_reset(space->machine()); |
| 496 | 499 | break; |
| 497 | 500 | case 0x0e: |
| 498 | 501 | case 0x0f: |
| 499 | | if(LOG_SMPC) logerror ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352"); |
| 502 | if(LOG_SMPC) printf ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352"); |
| 500 | 503 | smpc_change_clock(space->machine(),data & 1); |
| 501 | 504 | break; |
| 502 | 505 | /*"Interrupt Back"*/ |
| 503 | 506 | case 0x10: |
| 504 | | if(LOG_SMPC) logerror ("SMPC: Status Acquire\n"); |
| 507 | if(LOG_SMPC) printf ("SMPC: Status Acquire\n"); |
| 505 | 508 | space->machine().scheduler().timer_set(attotime::from_msec(16), FUNC(smpc_intback),1); //TODO: variable time |
| 506 | 509 | break; |
| 507 | 510 | /* RTC write*/ |
| 508 | 511 | case 0x16: |
| 509 | | if(LOG_SMPC) logerror("SMPC: RTC write\n"); |
| 512 | if(LOG_SMPC) printf("SMPC: RTC write\n"); |
| 510 | 513 | smpc_rtc_write(space->machine()); |
| 511 | 514 | break; |
| 512 | 515 | /* SMPC memory setting*/ |
| 513 | 516 | case 0x17: |
| 514 | | if(LOG_SMPC) logerror ("SMPC: memory setting\n"); |
| 517 | if(LOG_SMPC) printf ("SMPC: memory setting\n"); |
| 515 | 518 | //smpc_memory_setting(space->machine()); |
| 516 | 519 | break; |
| 517 | 520 | case 0x18: |
| 518 | | if(LOG_SMPC) logerror ("SMPC: NMI request\n"); |
| 521 | if(LOG_SMPC) printf ("SMPC: NMI request\n"); |
| 519 | 522 | smpc_nmi_req(space->machine()); |
| 520 | 523 | break; |
| 521 | 524 | case 0x19: |
| 522 | 525 | case 0x1a: |
| 523 | | if(LOG_SMPC) logerror ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En"); |
| 526 | if(LOG_SMPC) printf ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En"); |
| 524 | 527 | smpc_nmi_set(space->machine(),data & 1); |
| 525 | 528 | break; |
| 526 | 529 | default: |
| r12434 | r12435 | |
| 650 | 653 | switch (data) |
| 651 | 654 | { |
| 652 | 655 | case 0x00: |
| 653 | | if(LOG_SMPC) logerror ("SMPC: Master ON\n"); |
| 656 | if(LOG_SMPC) printf ("SMPC: Master ON\n"); |
| 654 | 657 | smpc_master_on(space->machine()); |
| 655 | 658 | break; |
| 656 | 659 | //in theory 0x01 is for Master OFF |
| 657 | 660 | case 0x02: |
| 658 | 661 | case 0x03: |
| 659 | | if(LOG_SMPC) logerror ("SMPC: Slave %s\n",(data & 1) ? "off" : "on"); |
| 662 | if(LOG_SMPC) printf ("SMPC: Slave %s\n",(data & 1) ? "off" : "on"); |
| 660 | 663 | smpc_slave_enable(space->machine(),data & 1); |
| 661 | 664 | break; |
| 662 | 665 | case 0x06: |
| 663 | 666 | case 0x07: |
| 664 | | if(LOG_SMPC) logerror ("SMPC: Sound %s\n",(data & 1) ? "off" : "on"); |
| 667 | if(LOG_SMPC) printf ("SMPC: Sound %s\n",(data & 1) ? "off" : "on"); |
| 665 | 668 | smpc_sound_enable(space->machine(),data & 1); |
| 666 | 669 | break; |
| 667 | 670 | /*CD (SH-1) ON/OFF,guess that this is needed for Sports Fishing games...*/ |
| 668 | 671 | //case 0x08: |
| 669 | 672 | //case 0x09: |
| 670 | 673 | case 0x0d: |
| 671 | | if(LOG_SMPC) logerror ("SMPC: System Reset\n"); |
| 674 | if(LOG_SMPC) printf ("SMPC: System Reset\n"); |
| 672 | 675 | smpc_system_reset(space->machine()); |
| 673 | 676 | break; |
| 674 | 677 | case 0x0e: |
| 675 | 678 | case 0x0f: |
| 676 | | if(LOG_SMPC) logerror ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352"); |
| 679 | if(LOG_SMPC) printf ("SMPC: Change Clock to %s\n",data & 1 ? "320" : "352"); |
| 677 | 680 | smpc_change_clock(space->machine(),data & 1); |
| 678 | 681 | break; |
| 679 | 682 | /*"Interrupt Back"*/ |
| 680 | 683 | case 0x10: |
| 681 | | if(LOG_SMPC) logerror ("SMPC: Status Acquire (IntBack)\n"); |
| 684 | if(LOG_SMPC) printf ("SMPC: Status Acquire (IntBack)\n"); |
| 682 | 685 | space->machine().scheduler().timer_set(attotime::from_msec(16), FUNC(smpc_intback),0); //TODO: variable time |
| 683 | 686 | break; |
| 684 | 687 | /* RTC write*/ |
| 685 | 688 | case 0x16: |
| 686 | | if(LOG_SMPC) logerror("SMPC: RTC write\n"); |
| 689 | if(LOG_SMPC) printf("SMPC: RTC write\n"); |
| 687 | 690 | smpc_rtc_write(space->machine()); |
| 688 | 691 | break; |
| 689 | 692 | /* SMPC memory setting*/ |
| 690 | 693 | case 0x17: |
| 691 | | if(LOG_SMPC) logerror ("SMPC: memory setting\n"); |
| 694 | if(LOG_SMPC) printf ("SMPC: memory setting\n"); |
| 692 | 695 | smpc_memory_setting(space->machine()); |
| 693 | 696 | break; |
| 694 | 697 | case 0x18: |
| 695 | | if(LOG_SMPC) logerror ("SMPC: NMI request\n"); |
| 698 | if(LOG_SMPC) printf ("SMPC: NMI request\n"); |
| 696 | 699 | smpc_nmi_req(space->machine()); |
| 697 | 700 | break; |
| 698 | 701 | case 0x19: |
| 699 | 702 | case 0x1a: |
| 700 | | if(LOG_SMPC) logerror ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En"); |
| 703 | if(LOG_SMPC) printf ("SMPC: NMI %sable\n",data & 1 ? "Dis" : "En"); |
| 701 | 704 | smpc_nmi_set(space->machine(),data & 1); |
| 702 | 705 | break; |
| 703 | 706 | default: |
| r12434 | r12435 | |
| 706 | 709 | |
| 707 | 710 | // we've processed the command, clear status flag |
| 708 | 711 | state->m_smpc_ram[0x5f] = data; //read-back for last command issued |
| 709 | | state->m_smpc_ram[0x63] = 0x00; |
| 712 | if(data != 0x10) |
| 713 | state->m_smpc_ram[0x63] = 0x00; //clear hand-shake flag |
| 710 | 714 | /*TODO:emulate the timing of each command...*/ |
| 711 | 715 | } |
| 712 | 716 | } |