trunk/src/mame/machine/snes.c
r17491 | r17492 | |
579 | 579 | |
580 | 580 | case 0x4100: /* NSS Dip-Switches */ |
581 | 581 | { |
582 | | ioport_port *port = state->ioport("DSW"); |
583 | | if (port != NULL) |
| 582 | if (state->m_is_nss) |
584 | 583 | return space->machine().root_device().ioport("DSW")->read(); |
585 | | else |
586 | | return snes_open_bus_r(space, 0); |
| 584 | |
| 585 | return snes_open_bus_r(space, 0); |
587 | 586 | } |
588 | 587 | // case 0x4101: //PC: a104 - a10e - a12a //only nss_actr |
589 | | // case 0x420c: //PC: 9c7d - 8fab //only nss_ssoc |
590 | 588 | |
591 | 589 | default: |
592 | 590 | // mame_printf_debug("snes_r: offset = %x pc = %x\n",offset,cpu_get_pc(&space->device())); |
r17491 | r17492 | |
697 | 695 | state->m_read_idx[0] = 0; |
698 | 696 | state->m_read_idx[1] = 0; |
699 | 697 | } |
| 698 | |
700 | 699 | break; |
701 | 700 | case NMITIMEN: /* Flag for v-blank, timer int. and joy read */ |
702 | 701 | if((data & 0x30) == 0x00) |
r17491 | r17492 | |
1528 | 1527 | // this actually works like reading the first 16bits from oldjoy1/2 in reverse order |
1529 | 1528 | if (snes_ram[NMITIMEN] & 1) |
1530 | 1529 | { |
1531 | | state->m_joy1l = (state->m_data1[0] & 0x00ff) >> 0; |
1532 | | state->m_joy1h = (state->m_data1[0] & 0xff00) >> 8; |
1533 | | state->m_joy2l = (state->m_data1[1] & 0x00ff) >> 0; |
1534 | | state->m_joy2h = (state->m_data1[1] & 0xff00) >> 8; |
1535 | | state->m_joy3l = (state->m_data2[0] & 0x00ff) >> 0; |
1536 | | state->m_joy3h = (state->m_data2[0] & 0xff00) >> 8; |
1537 | | state->m_joy4l = (state->m_data2[1] & 0x00ff) >> 0; |
1538 | | state->m_joy4h = (state->m_data2[1] & 0xff00) >> 8; |
| 1530 | state->m_joy1l = (state->m_is_nss && state->m_input_disabled) ? 0 : (state->m_data1[0] & 0x00ff) >> 0; |
| 1531 | state->m_joy1h = (state->m_is_nss && state->m_input_disabled) ? 0 : (state->m_data1[0] & 0xff00) >> 8; |
| 1532 | state->m_joy2l = (state->m_is_nss && state->m_input_disabled) ? 0 : (state->m_data1[1] & 0x00ff) >> 0; |
| 1533 | state->m_joy2h = (state->m_is_nss && state->m_input_disabled) ? 0 : (state->m_data1[1] & 0xff00) >> 8; |
| 1534 | state->m_joy3l = (state->m_is_nss && state->m_input_disabled) ? 0 : (state->m_data2[0] & 0x00ff) >> 0; |
| 1535 | state->m_joy3h = (state->m_is_nss && state->m_input_disabled) ? 0 : (state->m_data2[0] & 0xff00) >> 8; |
| 1536 | state->m_joy4l = (state->m_is_nss && state->m_input_disabled) ? 0 : (state->m_data2[1] & 0x00ff) >> 0; |
| 1537 | state->m_joy4h = (state->m_is_nss && state->m_input_disabled) ? 0 : (state->m_data2[1] & 0xff00) >> 8; |
1539 | 1538 | |
1540 | 1539 | // make sure read_idx starts returning all 1s because the auto-read reads it :-) |
1541 | 1540 | state->m_read_idx[0] = 16; |
r17491 | r17492 | |
1816 | 1815 | state_save_register_item(machine, "snes_dma", NULL, i, state->m_scope[i].fire_lock); |
1817 | 1816 | state_save_register_item(machine, "snes_dma", NULL, i, state->m_scope[i].offscreen); |
1818 | 1817 | } |
| 1818 | |
| 1819 | state->m_is_nss = 0; |
1819 | 1820 | } |
1820 | 1821 | |
1821 | 1822 | MACHINE_RESET( snes ) |
trunk/src/mame/drivers/nss.c
r17491 | r17492 | |
5 | 5 | driver by Angelo Salese, based off info from Noca$h |
6 | 6 | |
7 | 7 | TODO: |
8 | | - EEPROM |
| 8 | - EEPROM defaults / fix EEPROM hook-up, all games but F-Zero doesn't |
| 9 | boot at current stage |
| 10 | - Fix sound CPU halt / reset lines, particularly needed by this to work |
| 11 | correctly; |
9 | 12 | - Various M50458 bits |
10 | | - Still dies at a cart check, why? |
11 | 13 | - OSD should actually super-impose with the SNES video somehow; |
12 | 14 | |
13 | 15 | *************************************************************************** |
r17491 | r17492 | |
307 | 309 | |
308 | 310 | DECLARE_READ8_MEMBER(spc_ram_100_r); |
309 | 311 | DECLARE_WRITE8_MEMBER(spc_ram_100_w); |
310 | | DECLARE_READ8_MEMBER(port_00_r); |
311 | | DECLARE_WRITE8_MEMBER(port_00_w); |
312 | 312 | DECLARE_READ8_MEMBER(ram_wp_r); |
313 | 313 | DECLARE_WRITE8_MEMBER(ram_wp_w); |
314 | | DECLARE_WRITE8_MEMBER(rtc_osd_w); |
315 | | DECLARE_WRITE8_MEMBER(port_01_w); |
316 | 314 | DECLARE_READ8_MEMBER(nss_prot_r); |
317 | 315 | DECLARE_WRITE8_MEMBER(nss_prot_w); |
318 | 316 | |
| 317 | DECLARE_READ8_MEMBER(port_00_r); |
| 318 | DECLARE_WRITE8_MEMBER(port_00_w); |
| 319 | DECLARE_WRITE8_MEMBER(port_01_w); |
| 320 | DECLARE_WRITE8_MEMBER(port_02_w); |
| 321 | DECLARE_WRITE8_MEMBER(port_03_w); |
| 322 | DECLARE_WRITE8_MEMBER(port_04_w); |
| 323 | |
319 | 324 | DECLARE_DRIVER_INIT(nss); |
320 | 325 | bitmap_rgb32 *m_tmpbitmap; |
321 | 326 | |
r17491 | r17492 | |
427 | 432 | Output |
428 | 433 | 0x00/0x80 NMI Control and RAM protect |
429 | 434 | 0x01/0x81 Unknown and Slot Select |
430 | | 7 Maybe SNES Joypad Enable? (0=Disable/Demo, 1=Enable/Game) |
431 | | 6 Unknown/unused (should be always 0) |
432 | | 5 SNES Sound Mute (0=Normal, 1=Mute) (for optional mute in demo mode) |
433 | | 4 Unknown ;from INST-ROM flag! (Lo/HiROM, 2-player, zapper, volume or so?) |
434 | | 3-2 Slot Select (0..2 for Slot 1..3) (mapping to both SNES and Z80) |
435 | | 1 Maybe SNES CPU pause? (cleared on deposit coin to continue) (1=Run) |
436 | | 0 Maybe SNES CPU/PPU reset? (0=Reset, 1=Run) |
437 | 435 | 0x02/0x82 RTC and OSD |
438 | 436 | 0x03/0x83 Unknown and LED control |
439 | | 7 Layer SNES Enable? (used by token proc, see 7A46h) SNES? |
440 | | 6 Layer OSD Enable? |
441 | | 5-4 Unknown/unused (should be always 0) |
442 | | 3 LED Instructions (0=Off, 1=On) ;-glows in demo (prompt for INST button) |
443 | | 2 LED Game 3 (0=Off, 1=On) ;\ |
444 | | 1 LED Game 2 (0=Off, 1=On) ; blinked when enough credits inserted |
445 | | 0 LED Game 1 (0=Off, 1=On) ;/ |
446 | 437 | 0x84 Coin Counter Outputs |
447 | | 7-2 Unknown/unused (should be always 0) |
448 | | 1 Coin Counter 2 (0=No change, 1=Increment external counter) |
449 | | 0 Coin Counter 1 (0=No change, 1=Increment external counter) |
450 | 438 | 0x05 Unknown |
451 | 439 | 0x07 SNES Watchdog / Acknowledge SNES Joypad Read Flag |
452 | 440 | |
r17491 | r17492 | |
505 | 493 | AM_RANGE(0x9000, 0x9fff) AM_READWRITE(ram_wp_r,ram_wp_w) |
506 | 494 | AM_RANGE(0xa000, 0xa000) AM_READ_PORT("EEPROMIN") |
507 | 495 | AM_RANGE(0xc000, 0xdfff) AM_ROM AM_REGION("ibios_rom", 0x6000 ) |
508 | | AM_RANGE(0xe000, 0xffff) AM_READ(nss_prot_r) |
509 | | AM_RANGE(0xe000, 0xffff) AM_WRITE(nss_prot_w) |
| 496 | AM_RANGE(0xe000, 0xffff) AM_READWRITE(nss_prot_r,nss_prot_w) |
510 | 497 | ADDRESS_MAP_END |
511 | 498 | |
512 | 499 | READ8_MEMBER(nss_state::port_00_r) |
r17491 | r17492 | |
549 | 536 | |
550 | 537 | } |
551 | 538 | |
552 | | WRITE8_MEMBER(nss_state::rtc_osd_w) |
| 539 | WRITE8_MEMBER(nss_state::port_01_w) |
553 | 540 | { |
554 | 541 | /* |
| 542 | x--- ---- Maybe SNES Joypad Enable? (0=Disable/Demo, 1=Enable/Game) |
| 543 | -x-- ---- Unknown/unused (should be always 0) |
| 544 | --x- ---- SNES Sound Mute (0=Normal, 1=Mute) (for optional mute in demo mode) |
| 545 | ---x ---- Unknown ;from INST-ROM flag! (Lo/HiROM, 2-player, zapper, volume or so?) |
| 546 | ---- xx-- Slot Select (0..2 for Slot 1..3) (mapping to both SNES and Z80) |
| 547 | ---- --x- Maybe SNES CPU pause? (cleared on deposit coin to continue) (1=Run) |
| 548 | ---- ---x Maybe SNES CPU/PPU reset? (0=Reset, 1=Run) |
| 549 | */ |
| 550 | m_input_disabled = ((data & 0x80) >> 7) ^ 1; |
| 551 | |
| 552 | m_cart_sel = (data & 0xc) >> 2; |
| 553 | |
| 554 | device_set_input_line(m_maincpu, INPUT_LINE_HALT, (data & 2) ? CLEAR_LINE : ASSERT_LINE); |
| 555 | device_set_input_line(m_soundcpu, INPUT_LINE_HALT, (data & 2) ? CLEAR_LINE : ASSERT_LINE); |
| 556 | device_set_input_line(m_maincpu, INPUT_LINE_RESET, (data & 1) ? CLEAR_LINE : ASSERT_LINE); |
| 557 | device_set_input_line(m_soundcpu, INPUT_LINE_RESET, (data & 1) ? CLEAR_LINE : ASSERT_LINE); |
| 558 | |
| 559 | // printf("%02x\n",data); |
| 560 | } |
| 561 | |
| 562 | WRITE8_MEMBER(nss_state::port_02_w) |
| 563 | { |
| 564 | /* |
555 | 565 | x--- ---- OSD Clock ? (usually same as Bit6) ;\Chip Select when Bit6=Bit7 ? |
556 | 566 | -x-- ---- OSD Clock ? (usually same as Bit7) ;/ |
557 | 567 | --x- ---- OSD Data Out (0=Low=Zero, 1=High=One) |
r17491 | r17492 | |
565 | 575 | ioport("RTC_OSD")->write(data, 0xff); |
566 | 576 | } |
567 | 577 | |
568 | | WRITE8_MEMBER(nss_state::port_01_w) |
| 578 | WRITE8_MEMBER(nss_state::port_03_w) |
569 | 579 | { |
570 | | m_cart_sel = (data & 0xc) >> 2; |
| 580 | /* |
| 581 | x--- ---- Layer SNES Enable? (used by token proc, see 7A46h) SNES? |
| 582 | -x-- ---- Layer OSD Enable? |
| 583 | --xx ---- Unknown/unused (should be always 0) |
| 584 | ---- x--- LED Instructions (0=Off, 1=On) ;-glows in demo (prompt for INST button) |
| 585 | ---- -x-- LED Game 3 (0=Off, 1=On) ;\ |
| 586 | ---- --x- LED Game 2 (0=Off, 1=On) ; blinked when enough credits inserted |
| 587 | ---- ---x LED Game 1 (0=Off, 1=On) ;/ |
| 588 | |
| 589 | */ |
| 590 | // popmessage("%02x",data); |
571 | 591 | } |
572 | 592 | |
| 593 | WRITE8_MEMBER(nss_state::port_04_w) |
| 594 | { |
| 595 | coin_counter_w(machine(), 0, (data >> 0) & 1); |
| 596 | coin_counter_w(machine(), 1, (data >> 1) & 1); |
| 597 | } |
| 598 | |
573 | 599 | static ADDRESS_MAP_START( bios_io_map, AS_IO, 8, nss_state ) |
574 | 600 | ADDRESS_MAP_GLOBAL_MASK(0x7) |
575 | 601 | AM_RANGE(0x00, 0x00) AM_READ(port_00_r) AM_WRITE(port_00_w) |
576 | 602 | AM_RANGE(0x01, 0x01) AM_READ_PORT("FP") AM_WRITE(port_01_w) |
577 | | AM_RANGE(0x02, 0x02) AM_READ_PORT("SYSTEM") AM_WRITE(rtc_osd_w) |
578 | | AM_RANGE(0x03, 0x03) AM_READ_PORT("RTC") |
| 603 | AM_RANGE(0x02, 0x02) AM_READ_PORT("SYSTEM") AM_WRITE(port_02_w) |
| 604 | AM_RANGE(0x03, 0x03) AM_READ_PORT("RTC") AM_WRITE(port_03_w) |
| 605 | AM_RANGE(0x04, 0x04) AM_WRITE(port_04_w) |
| 606 | AM_RANGE(0x07, 0x07) AM_WRITENOP // Pad watchdog |
579 | 607 | ADDRESS_MAP_END |
580 | 608 | |
581 | 609 | /* Mitsubishi M6M80011 */ |
r17491 | r17492 | |
583 | 611 | { |
584 | 612 | 8, /* address bits */ |
585 | 613 | 16, /* data bits */ |
586 | | "10101000", /* read command */ |
587 | | "10100100", /* write command */ |
| 614 | "*10101000", /* read command */ |
| 615 | "*10100100", /* write command */ |
588 | 616 | 0, /* erase command */ |
589 | | "10100000", /* lock command */ |
590 | | "10100011" /* unlock command*/ |
| 617 | "*10100000", /* lock command */ |
| 618 | "*10100011" /* unlock command*/ |
591 | 619 | /* "10101001" TODO: status output? */ |
592 | 620 | }; |
593 | 621 | |
r17491 | r17492 | |
598 | 626 | |
599 | 627 | MACHINE_START_CALL(snes); |
600 | 628 | |
| 629 | state->m_is_nss = 1; |
601 | 630 | state->m_wram = auto_alloc_array_clear(machine, UINT8, 0x1000); |
602 | 631 | state->m_tmpbitmap = auto_bitmap_rgb32_alloc(machine,24*12,12*18); |
603 | 632 | } |
r17491 | r17492 | |
794 | 823 | device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); |
795 | 824 | } |
796 | 825 | |
| 826 | static MACHINE_RESET( nss ) |
| 827 | { |
| 828 | nss_state *state = machine.driver_data<nss_state>(); |
| 829 | |
| 830 | MACHINE_RESET_CALL( snes ); |
| 831 | |
| 832 | /* start with both CPUs disabled */ |
| 833 | device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, ASSERT_LINE); |
| 834 | device_set_input_line(state->m_soundcpu, INPUT_LINE_RESET, ASSERT_LINE); |
| 835 | } |
| 836 | |
797 | 837 | static MACHINE_CONFIG_DERIVED( nss, snes ) |
798 | 838 | |
799 | 839 | MCFG_CPU_ADD("bios", Z80, 4000000) |
r17491 | r17492 | |
808 | 848 | /* TODO: the screen should actually superimpose, but for the time being let's just separate outputs for now */ |
809 | 849 | MCFG_DEFAULT_LAYOUT(layout_dualhsxs) |
810 | 850 | |
| 851 | MCFG_MACHINE_RESET( nss ) |
| 852 | |
811 | 853 | MCFG_SCREEN_ADD("osd", RASTER) |
812 | 854 | MCFG_SCREEN_REFRESH_RATE(60) |
813 | 855 | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
r17491 | r17492 | |
835 | 877 | ROM_LOAD("nss-c.dat" , 0x00000, 0x8000, CRC(a8e202b3) SHA1(b7afcfe4f5cf15df53452dc04be81929ced1efb2) ) /* bios */ \ |
836 | 878 | ROM_LOAD("nss-ic14.02", 0x10000, 0x8000, CRC(e06cb58f) SHA1(62f507e91a2797919a78d627af53f029c7d81477) ) /* bios */ \ |
837 | 879 | ROM_REGION( 0x2000, "dspprg", ROMREGION_ERASEFF) \ |
838 | | ROM_REGION( 0x800, "dspdata", ROMREGION_ERASEFF) \ |
839 | | ROM_REGION( 0x200, "eeprom", ROMREGION_ERASEFF ) |
| 880 | ROM_REGION( 0x800, "dspdata", ROMREGION_ERASEFF) |
840 | 881 | |
841 | 882 | |
842 | 883 | |