Previous 199869 Revisions Next

r17458 Saturday 25th August, 2012 at 00:51:15 UTC by Angelo Salese
Various hook-ups, presumably dies at the EEPROM/RTC check and throws an error (enables the OSD layer bit)
[src/mame/drivers]nss.c

trunk/src/mame/drivers/nss.c
r17457r17458
295295
296296#include "emu.h"
297297#include "cpu/z80/z80.h"
298#include "machine/eeprom.h"
298299#include "includes/snes.h"
299300
300301
r17457r17458
302303{
303304public:
304305   nss_state(const machine_config &mconfig, device_type type, const char *tag)
305      : snes_state(mconfig, type, tag) { }
306      : snes_state(mconfig, type, tag)
307      { }
306308
309   UINT8 m_wram_wp_flag;
310   UINT8 *m_wram;
311   UINT8 m_nmi_enable;
312
307313   DECLARE_READ8_MEMBER(spc_ram_100_r);
308314   DECLARE_WRITE8_MEMBER(spc_ram_100_w);
315   DECLARE_READ8_MEMBER(port_00_r);
316   DECLARE_WRITE8_MEMBER(port_00_w);
317   DECLARE_READ8_MEMBER(ram_wp_r);
318   DECLARE_WRITE8_MEMBER(ram_wp_w);
319   DECLARE_WRITE8_MEMBER(rtc_osd_w);
320   DECLARE_WRITE8_MEMBER(eeprom_w);
309321};
310322
311323
r17457r17458
3693810x8000 - 0x8fff RAM
3703820x9000 - 0x9fff RAM with write protection
3713830xa000          EEPROM Read
372  7   EEPROM Data In (0=Low=Zero, 1=High=One)
373  6   EEPROM Ready   (0=Low=Busy, 1=High=Ready)
374  5-0 Unknown/unused
3753840xc000 - 0xdfff instruction ROM
3763850xe000          EEPROM Write
377  7   Unknown/set     (should be always 1)
378  6-5 Unknown/unused  (should be always 0)
379  4   EEPROM Clock    (0=Low=Clock, 1=High=Idle) ;(Data In/Out must be stable
380  3   EEPROM Data Out (0=Low=Zero, 1=High=One)   ;on raising CLK edge)
381  2-1 Unknown/unused  (should be always 0)       ;(and updated on falling edge)
382  0   EEPROM Select   (0=High=No, 1=Low=Select)
3833860xe000 - 0xffff PROM Input & Output & Program Code (protection RP5H01, used also in earlier Nintendo systems)
384387Data Write:
385388  7-5  Unknown/unused
r17457r17458
398401i/o
399402Input
4004030x00 Joypad
401  7   SNES Watchdog (0=SNES did read Joypads, 1=Didn't do so) (ack via 07h.W)
402  6   Vblank or Vsync or so       (0=What, 1=What?)
403  5   Button "Joypad Button B?"   (0=Released, 1=Pressed)
404  4   Button "Joypad Button A"    (0=Released, 1=Pressed)
405  3   Button "Joypad Down"        (0=Released, 1=Pressed)
406  2   Button "Joypad Up"          (0=Released, 1=Pressed)
407  1   Button "Joypad Left"        (0=Released, 1=Pressed)
408  0   Button "Joypad Right"       (0=Released, 1=Pressed)
4094040x01 Front-Panel Buttons and Game Over Flag
410405  7   From SNES Port 4016h.W.Bit2 (0=Game Over Flag, 1=Normal) (Inverted!)
411  6   Button "Restart"            (0=Released, 1=Pressed) ;-also resets SNES?
412  5   Button "Page Up"            (0=Released, 1=Pressed)
413  4   Button "Page Down"          (0=Released, 1=Pressed)
414  3   Button "Instructions"       (0=Released, 1=Pressed)
415  2   Button "Game 3"             (0=Released, 1=Pressed) ;\if present (single
416  1   Button "Game 2"             (0=Released, 1=Pressed) ; cartridge mode does
417  0   Button "Game 1"             (0=Released, 1=Pressed) ;/without them)
4184060x02 Coin and Service Button Inputs
419407  7-3 Unknown/unused (maybe the (unused) Test button hides here)
420408  2   Service Button (1=Pressed: Add Credit; with INST button: Config)
r17457r17458
4234110x03 RTC
424412Output
4254130x00/0x80 NMI Control and RAM protect
426  7-4 Unknown/unused      (should be always 0)
427  3     Maybe SNES CPU/PPU reset (usually same as Port 01h.W.Bit1)
428  2   RAM at 9000h-9FFFh  (0=Disable/Protect, 1=Enable/Unlock)
429  1   Looks like maybe somehow NMI Related ?    ;\or one of these is PC10-style
430  0   Looks like NMI Enable                     ;/hardware-watchdog reload?
4314140x01/0x81 Unknown and Slot Select
432415  7     Maybe SNES Joypad Enable? (0=Disable/Demo, 1=Enable/Game)
433416  6   Unknown/unused        (should be always 0)
r17457r17458
461444
462445*/
463446
447READ8_MEMBER(nss_state::ram_wp_r)
448{
449   return m_wram[offset];
450}
451
452WRITE8_MEMBER(nss_state::ram_wp_w)
453{
454   if(m_wram_wp_flag)
455      m_wram[offset] = data;
456}
457
458WRITE8_MEMBER(nss_state::eeprom_w)
459{
460/*
461   x--- ----   Unknown/set     (should be always 1) (EEPROM Reset (active low)?)
462   -xx- ---- Unknown/unused  (should be always 0)
463   ---x ----   EEPROM Clock    (0=Low=Clock, 1=High=Idle) ;(Data In/Out must be stable
464   ---- x---   EEPROM Data Out (0=Low=Zero, 1=High=One)   ;on raising CLK edge)
465   ---- -xx- Unknown/unused  (should be always 0)       ;(and updated on falling edge)
466   ---- ---x   EEPROM Select   (0=High=No, 1=Low=Select)
467*/
468   ioport("EEPROMOUT")->write(data, 0xff);
469}
470
464471static ADDRESS_MAP_START( bios_map, AS_PROGRAM, 8, nss_state )
465472   AM_RANGE(0x0000, 0x7fff) AM_ROM
473   AM_RANGE(0x8000, 0x8fff) AM_RAM
474   AM_RANGE(0x9000, 0x9fff) AM_READWRITE(ram_wp_r,ram_wp_w)
475   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("EEPROMIN")
476   AM_RANGE(0xc000, 0xdfff) AM_ROM AM_REGION("ibios_rom", 0x6000 )
477   AM_RANGE(0xe000, 0xe000) AM_WRITE(eeprom_w)
466478ADDRESS_MAP_END
467479
480READ8_MEMBER(nss_state::port_00_r)
481{
482/*
483   x--- ----   SNES Watchdog (0=SNES did read Joypads, 1=Didn't do so) (ack via 07h.W)
484   -x-- ----   Vblank or Vsync or so       (0=What, 1=What?)
485   --x- ----   Button "Joypad Button B?"   (0=Released, 1=Pressed)
486   ---x ----   Button "Joypad Button A"    (0=Released, 1=Pressed)
487   ---- x---   Button "Joypad Down"        (0=Released, 1=Pressed)
488   ---- -x--   Button "Joypad Up"          (0=Released, 1=Pressed)
489   ---- --x-   Button "Joypad Left"        (0=Released, 1=Pressed)
490   ---- ---x   Button "Joypad Right"       (0=Released, 1=Pressed)
491*/
492   UINT8 res;
468493
494   res = (machine().primary_screen->vblank() & 1) << 6;
495   res|= (((ioport("SERIAL1_DATA1_H")->read() & 0x80) >> 7) << 5);
496   res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x80) >> 7) << 4);
497   res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x08) >> 3) << 3);
498   res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x04) >> 2) << 2);
499   res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x02) >> 1) << 1);
500   res|= (((ioport("SERIAL1_DATA1_L")->read() & 0x01) >> 0) << 0);
469501
502   return res;
503}
504
505WRITE8_MEMBER(nss_state::port_00_w)
506{
507/*
508   xxxx ---- Unknown/unused      (should be always 0)
509    ---- x--- Maybe SNES CPU/PPU reset (usually same as Port 01h.W.Bit1)
510   ---- -x-- RAM at 9000h-9FFFh  (0=Disable/Protect, 1=Enable/Unlock)
511   ---- --x- Looks like maybe somehow NMI Related ?    ;\or one of these is PC10-style
512   ---- ---x Looks like NMI Enable                     ;/hardware-watchdog reload?
513*/
514   m_wram_wp_flag = (data & 4) >> 2;
515   m_nmi_enable = data & 1;
516
517}
518
519WRITE8_MEMBER(nss_state::rtc_osd_w)
520{
521/*
522   x--- ----  OSD Clock ?       (usually same as Bit6)  ;\Chip Select when Bit6=Bit7 ?
523   -x-- ----  OSD Clock ?       (usually same as Bit7)  ;/
524   --x- ----  OSD Data Out      (0=Low=Zero, 1=High=One)
525   ---x ----  OSD Special       (?)  ... or just /CS ? (or software index DC3F/DD3F?)
526   ---- x---  RTC /CLK          (0=Low=Clock,  1=High=Idle)              ;S-3520
527   ---- -x--  RTC Data Out      (0=Low=Zero,   1=High=One)
528   ---- --x-  RTC Direction     (0=Low=Write,  1=High=Read)
529   ---- ---x  RTC /CS           (0=Low/Select, 1=High/No)
530*/
531   /* TODO */
532}
533
470534static ADDRESS_MAP_START( bios_io_map, AS_IO, 8, nss_state )
535   /* TODO: I think that this actually masks to 0x7? */
471536   ADDRESS_MAP_GLOBAL_MASK(0xff)
537   AM_RANGE(0x00, 0x00) AM_READ(port_00_r) AM_WRITE(port_00_w)
538   AM_RANGE(0x01, 0x01) AM_READ_PORT("FP")
539   AM_RANGE(0x02, 0x02) AM_READ_PORT("SYSTEM") AM_WRITE(rtc_osd_w)
472540
541   AM_RANGE(0x72, 0x72) AM_WRITE(rtc_osd_w)
542   AM_RANGE(0x80, 0x80) AM_WRITE(port_00_w)
543   AM_RANGE(0x82, 0x82) AM_WRITE(rtc_osd_w)
544   AM_RANGE(0xea, 0xea) AM_WRITE(rtc_osd_w)
473545ADDRESS_MAP_END
474546
547/* Mitsubishi M6M80011 */
548static const eeprom_interface nss_eeprom_intf =
549{
550   8,            /* address bits */
551   16,            /* data bits */
552   "10101000",      /*  read command */
553   "10100100",      /* write command */
554   0,            /* erase command */
555   "10100000",      /*  lock command */
556   "10100011"      /* unlock command*/
557   /* "10101001" TODO: status output? */
558};
559
560
475561static MACHINE_START( nss )
476562{
477//   nss_state *state = machine.driver_data<nss_state>();
563   nss_state *state = machine.driver_data<nss_state>();
478564
479565   MACHINE_START_CALL(snes);
566
567   state->m_wram = auto_alloc_array_clear(machine, UINT8, 0x1000);
480568}
481569
482570static INPUT_PORTS_START( snes )
571   PORT_START("SYSTEM")
572   PORT_BIT( 0xf8, IP_ACTIVE_HIGH, IPT_UNKNOWN )
573   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE1 )
574   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
575   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
576
577   PORT_START("FP")
578   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) // Game Over Flag, TODO
579   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON13 ) PORT_NAME("Restart Button")
580   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("Page Up Button")
581   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON11 ) PORT_NAME("Page Down Button")
582   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("Instructions Button")
583   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("Game 3 Button")
584   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("Game 2 Button")
585   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("Game 1 Button")
586
587   PORT_START("EEPROMIN")
588   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_device, read_bit)
589   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) // EEPROM Ready
590   PORT_BIT( 0x3f, IP_ACTIVE_HIGH, IPT_UNKNOWN )
591
592   PORT_START("EEPROMOUT")
593   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_device, set_clock_line)
594   PORT_BIT( 0x08, IP_ACTIVE_HIGH,IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_device, write_bit)
595   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("eeprom", eeprom_device, set_cs_line)
596
483597   PORT_START("SERIAL1_DATA1_L")
484598   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
485599   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button X") PORT_PLAYER(1)
r17457r17458
652766   MCFG_SOUND_ROUTE(1, "rspeaker", 1.00)
653767MACHINE_CONFIG_END
654768
769static INTERRUPT_GEN ( nss_vblank_irq )
770{
771   nss_state *state = device->machine().driver_data<nss_state>();
772
773   if(state->m_nmi_enable)
774      device_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
775}
776
655777static MACHINE_CONFIG_DERIVED( nss, snes )
656778
657779   MCFG_CPU_ADD("bios", Z80, 4000000)
658780   MCFG_CPU_PROGRAM_MAP(bios_map)
659781   MCFG_CPU_IO_MAP(bios_io_map)
660   MCFG_CPU_VBLANK_INT("screen", nmi_line_pulse)
661//  MCFG_CPU_FLAGS(CPU_DISABLE)
782   MCFG_CPU_VBLANK_INT("screen", nss_vblank_irq)
662783
784   MCFG_EEPROM_ADD("eeprom", nss_eeprom_intf)
785
663786   MCFG_GFXDECODE( nss )
664787   MCFG_PALETTE_LENGTH(2)
665788   MCFG_MACHINE_START( nss )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team