trunk/src/mame/machine/snes.c
r17505 | r17506 | |
561 | 561 | case RDMPYH: /* Product/Remainder of mult/div result (high) */ |
562 | 562 | return snes_ram[offset]; |
563 | 563 | case JOY1L: /* Joypad 1 status register (low) */ |
| 564 | if(state->m_is_nss && state->m_input_disabled) |
| 565 | return 0; |
| 566 | |
564 | 567 | return state->m_joy1l; |
565 | 568 | case JOY1H: /* Joypad 1 status register (high) */ |
| 569 | if(state->m_is_nss && state->m_input_disabled) |
| 570 | return 0; |
| 571 | |
566 | 572 | return state->m_joy1h; |
567 | 573 | case JOY2L: /* Joypad 2 status register (low) */ |
| 574 | if(state->m_is_nss && state->m_input_disabled) |
| 575 | return 0; |
| 576 | |
568 | 577 | return state->m_joy2l; |
569 | 578 | case JOY2H: /* Joypad 2 status register (high) */ |
| 579 | if(state->m_is_nss && state->m_input_disabled) |
| 580 | return 0; |
| 581 | |
570 | 582 | return state->m_joy2h; |
571 | 583 | case JOY3L: /* Joypad 3 status register (low) */ |
| 584 | if(state->m_is_nss && state->m_input_disabled) |
| 585 | return 0; |
| 586 | |
572 | 587 | return state->m_joy3l; |
573 | 588 | case JOY3H: /* Joypad 3 status register (high) */ |
| 589 | if(state->m_is_nss && state->m_input_disabled) |
| 590 | return 0; |
| 591 | |
574 | 592 | return state->m_joy3h; |
575 | 593 | case JOY4L: /* Joypad 4 status register (low) */ |
| 594 | if(state->m_is_nss && state->m_input_disabled) |
| 595 | return 0; |
| 596 | |
576 | 597 | return state->m_joy4l; |
577 | 598 | case JOY4H: /* Joypad 4 status register (high) */ |
| 599 | if(state->m_is_nss && state->m_input_disabled) |
| 600 | return 0; |
| 601 | |
578 | 602 | return state->m_joy4h; |
579 | 603 | |
580 | 604 | case 0x4100: /* NSS Dip-Switches */ |
r17505 | r17506 | |
584 | 608 | |
585 | 609 | return snes_open_bus_r(space, 0); |
586 | 610 | } |
587 | | // case 0x4101: //PC: a104 - a10e - a12a //only nss_actr |
| 611 | // case 0x4101: //PC: a104 - a10e - a12a //only nss_actr (DSW actually reads in word units ...) |
588 | 612 | |
589 | 613 | default: |
590 | 614 | // mame_printf_debug("snes_r: offset = %x pc = %x\n",offset,cpu_get_pc(&space->device())); |
r17505 | r17506 | |
592 | 616 | break; |
593 | 617 | } |
594 | 618 | |
595 | | //printf("unsupported read: offset == %08x\n", offset); |
| 619 | // printf("unsupported read: offset == %08x\n", offset); |
596 | 620 | |
597 | 621 | /* Unsupported reads returns open bus */ |
598 | 622 | // printf("%02x %02x\n",offset,snes_open_bus_r(space, 0)); |
r17505 | r17506 | |
695 | 719 | state->m_read_idx[0] = 0; |
696 | 720 | state->m_read_idx[1] = 0; |
697 | 721 | } |
698 | | |
| 722 | if(state->m_is_nss) |
| 723 | { |
| 724 | state->m_game_over_flag = (data & 4) >> 2; |
| 725 | } |
699 | 726 | break; |
700 | 727 | case NMITIMEN: /* Flag for v-blank, timer int. and joy read */ |
701 | 728 | if((data & 0x30) == 0x00) |
r17505 | r17506 | |
1527 | 1554 | // this actually works like reading the first 16bits from oldjoy1/2 in reverse order |
1528 | 1555 | if (snes_ram[NMITIMEN] & 1) |
1529 | 1556 | { |
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; |
| 1557 | state->m_joy1l = (state->m_data1[0] & 0x00ff) >> 0; |
| 1558 | state->m_joy1h = (state->m_data1[0] & 0xff00) >> 8; |
| 1559 | state->m_joy2l = (state->m_data1[1] & 0x00ff) >> 0; |
| 1560 | state->m_joy2h = (state->m_data1[1] & 0xff00) >> 8; |
| 1561 | state->m_joy3l = (state->m_data2[0] & 0x00ff) >> 0; |
| 1562 | state->m_joy3h = (state->m_data2[0] & 0xff00) >> 8; |
| 1563 | state->m_joy4l = (state->m_data2[1] & 0x00ff) >> 0; |
| 1564 | state->m_joy4h = (state->m_data2[1] & 0xff00) >> 8; |
1538 | 1565 | |
1539 | 1566 | // make sure read_idx starts returning all 1s because the auto-read reads it :-) |
1540 | 1567 | state->m_read_idx[0] = 16; |
1541 | 1568 | state->m_read_idx[1] = 16; |
1542 | 1569 | } |
1543 | 1570 | |
| 1571 | if(state->m_is_nss) |
| 1572 | state->m_joy_flag = 0; |
1544 | 1573 | } |
1545 | 1574 | |
| 1575 | /* |
| 1576 | if(state->m_is_nss) |
| 1577 | state->m_joy_flag = 0; |
| 1578 | |
| 1579 | */ |
| 1580 | |
1546 | 1581 | static UINT8 nss_oldjoy1_read( running_machine &machine ) |
1547 | 1582 | { |
1548 | 1583 | snes_state *state = machine.driver_data<snes_state>(); |
trunk/src/mame/drivers/nss.c
r17505 | r17506 | |
7 | 7 | TODO: |
8 | 8 | - Fix sound CPU halt / reset lines, particularly needed by this to work |
9 | 9 | correctly; |
| 10 | - Fix continue behaviour, might be the same issue as the one above. |
10 | 11 | - Various M50458 bits |
11 | 12 | - OSD should actually super-impose with the SNES video somehow; |
12 | 13 | |
r17505 | r17506 | |
322 | 323 | DECLARE_WRITE8_MEMBER(port_02_w); |
323 | 324 | DECLARE_WRITE8_MEMBER(port_03_w); |
324 | 325 | DECLARE_WRITE8_MEMBER(port_04_w); |
| 326 | DECLARE_WRITE8_MEMBER(port_07_w); |
325 | 327 | |
326 | 328 | DECLARE_DRIVER_INIT(nss); |
327 | | bitmap_rgb32 *m_tmpbitmap; |
328 | 329 | |
| 330 | DECLARE_CUSTOM_INPUT_MEMBER(game_over_flag_r); |
329 | 331 | }; |
330 | 332 | |
331 | 333 | |
r17505 | r17506 | |
333 | 335 | UINT32 nss_state::screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect ) |
334 | 336 | { |
335 | 337 | m_m50458->screen_update(screen,bitmap,cliprect); |
336 | | |
337 | 338 | return 0; |
338 | 339 | } |
339 | 340 | |
r17505 | r17506 | |
518 | 519 | */ |
519 | 520 | UINT8 res; |
520 | 521 | |
521 | | res = 0 << 7; |
| 522 | res = (m_joy_flag) << 7; |
522 | 523 | res|= (machine().primary_screen->vblank() & 1) << 6; |
523 | 524 | res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x80) >> 7) << 5); |
524 | 525 | res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x80) >> 7) << 4); |
525 | | res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x08) >> 3) << 3); |
526 | | res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x04) >> 2) << 2); |
527 | | res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x02) >> 1) << 1); |
528 | | res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x01) >> 0) << 0); |
| 526 | res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x04) >> 2) << 3); |
| 527 | res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x08) >> 3) << 2); |
| 528 | res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x02) >> 1) << 1); |
| 529 | res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x01) >> 0) << 0); |
529 | 530 | |
530 | 531 | return res; |
531 | 532 | } |
r17505 | r17506 | |
604 | 605 | coin_counter_w(machine(), 1, (data >> 1) & 1); |
605 | 606 | } |
606 | 607 | |
| 608 | WRITE8_MEMBER(nss_state::port_07_w) |
| 609 | { |
| 610 | m_joy_flag = 1; |
| 611 | } |
| 612 | |
607 | 613 | static ADDRESS_MAP_START( bios_io_map, AS_IO, 8, nss_state ) |
608 | 614 | ADDRESS_MAP_GLOBAL_MASK(0x7) |
609 | 615 | AM_RANGE(0x00, 0x00) AM_READ(port_00_r) AM_WRITE(port_00_w) |
r17505 | r17506 | |
611 | 617 | AM_RANGE(0x02, 0x02) AM_READ_PORT("SYSTEM") AM_WRITE(port_02_w) |
612 | 618 | AM_RANGE(0x03, 0x03) AM_READ_PORT("RTC") AM_WRITE(port_03_w) |
613 | 619 | AM_RANGE(0x04, 0x04) AM_WRITE(port_04_w) |
614 | | AM_RANGE(0x07, 0x07) AM_WRITENOP // Pad watchdog |
| 620 | AM_RANGE(0x07, 0x07) AM_WRITE(port_07_w) |
615 | 621 | ADDRESS_MAP_END |
616 | 622 | |
617 | 623 | static MACHINE_START( nss ) |
r17505 | r17506 | |
622 | 628 | |
623 | 629 | state->m_is_nss = 1; |
624 | 630 | state->m_wram = auto_alloc_array_clear(machine, UINT8, 0x1000); |
625 | | state->m_tmpbitmap = auto_bitmap_rgb32_alloc(machine,24*12,12*18); |
626 | 631 | } |
627 | 632 | |
| 633 | |
| 634 | CUSTOM_INPUT_MEMBER(nss_state::game_over_flag_r) |
| 635 | { |
| 636 | return m_game_over_flag; |
| 637 | } |
| 638 | |
628 | 639 | static INPUT_PORTS_START( snes ) |
629 | 640 | PORT_START("SYSTEM") |
630 | 641 | PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNKNOWN ) |
r17505 | r17506 | |
633 | 644 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) |
634 | 645 | |
635 | 646 | PORT_START("FP") |
636 | | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // Game Over Flag, TODO |
| 647 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM_MEMBER(DEVICE_SELF, nss_state,game_over_flag_r, NULL) |
637 | 648 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON13 ) PORT_NAME("Restart Button") |
638 | 649 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("Page Up Button") |
639 | 650 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON11 ) PORT_NAME("Page Down Button") |
r17505 | r17506 | |
826 | 837 | /* start with both CPUs disabled */ |
827 | 838 | device_set_input_line(state->m_maincpu, INPUT_LINE_RESET, ASSERT_LINE); |
828 | 839 | device_set_input_line(state->m_soundcpu, INPUT_LINE_RESET, ASSERT_LINE); |
| 840 | |
| 841 | state->m_game_over_flag = 1; |
| 842 | state->m_joy_flag = 1; |
829 | 843 | } |
830 | 844 | |
831 | 845 | static MACHINE_CONFIG_DERIVED( nss, snes ) |