Viewing File: <root>/src/mame/drivers/sfcbox.c

    1  /***************************************************************************
    2  
    3    sfcbox.c
    4    Preliminary driver file to handle emulation of the
    5    Nintendo Super Famicom Box.
    6  
    7  The Super Famicom Box was used in hotels in Japan, with its installed Coin
    8  Box, makes it a pay-for-play system.  It accepted 100 yen coins and gave 5
    9  minutes of playtime.  The interesting part of this system is that it used
   10  special multicarts that contained two or three games as part of a larger Cart,
   11  for which the system holds two at once.
   12  
   13  The "To Do" list:
   14  -----------------
   15  -Main CPU banks cartridges via ports $c0/$c1
   16  -Consider moving the 3 cartridges of the slot 2 in a software list since they are interchangable
   17   (that's bs, since that pss61 should always be there anyway ... -AS)
   18  -Hook the z180 clone, the DSP 1A/1B and the Super FX
   19  -Add the missing GROM4-1
   20  -Add the possibly alternate revision of the attract ROM, with Kirby holding a coin
   21   (unless it is unlocked with some DIP switch)
   22  
   23  Specific Model Number information
   24  ---------------------------------
   25  
   26  Hardware:
   27                                      _
   28                                     | |--------------------------------------| GS 0871-102
   29                                     | |--------------------------------------| GS 0871-102
   30                         GD 0871-103 ||
   31                                     ||   |-----------------------------------| PU 0871-101
   32                                     ||     |_|
   33   |---------------------------------||-----|_|-------------------------------| MAIN 0871-100A
   34      __________________________________________
   35     |------------------------------------------|    GS 0871-102
   36     |------------------------------------------|    GS 0871-102
   37    ___|__________________________            |
   38   |------------------------------|           |      PU 0871-101
   39   _|______________________|__________________|____
   40  |------------------------------------------------| MAIN 0871-100A
   41  
   42  
   43  PSS-001 - SUPER FAMICOM BOX - Main Unit
   44  This unit contains the three boards:
   45  the main board, the BIOS board and a passive board.
   46  
   47  1. The main board (MAIN 0871-100A) contains the Super Famicom core hardware as follow:
   48  CPU: S-CPU B (5A22-02 3MB 83)
   49  Video Controller: S-PPU1 (5C77-01 4AU 9L)
   50  Video Controller: S-PPU2 C (5C78-03 3MB 9V)
   51  Working CPU RAM: S-WRAM A (9442 T94 F)
   52  Sound CPU: S-SMP (SONY Nintendo'89 JAPAN 3WK4V)
   53  Sound DSP: S-DSP A (SONY'89 347AB7VZ)
   54  D/A converter: NEC D6376 - PDIF output model can be modified
   55  Slave (?) CPU: Hitachi 3M3R1 HD64180RF6X (Z180 clone)
   56  S-ENC A (9504 BA)
   57  MB90082 001 (9351 M02)
   58  
   59  2. The BIOS board (PU 0871-101) must be inserted into the main board.
   60  BIOS ROM: KROM 1, 512Kibit
   61  SRAM: SRM20257LM12 F27K 256 (S-MOS Systems) - SRAM accounting and control circuits are
   62        self-diagnostic features that set time and operational status of the
   63        game(s) that are installed.
   64  Battery: C2032
   65  Decoders: 74HC139A, 74HC237D, 74LS641, RTC S-3520CF (Seiko S3520CF2 C4446 J18)
   66            and two other unreadable chips
   67  MB3790 (9413 M32)
   68  
   69  3. The passive board (GD 0871-103) to be inserted into the main board, has two cartridge slots.
   70  
   71  PSS-002 - SUPER FAMICOM BOX - Cartridge
   72  
   73  PSS-003 - SUPER FAMICOM BOX - Coin Box
   74  
   75  Software/Cartridge:
   76  The PSS-61 cartridge is required on the slot 1 for the machine to operate.
   77  The slot 2 may be free or contain PSS-62, PSS-63 or PSS-64 interchangably.
   78  
   79  PSS-61  - SUPER FAMICOM BOX Commercial Regular Cart
   80  WARNING: This cartridge is required for the machine to operate.
   81  This game board (GS 0871-102) contains various chips in addition to the game ROMs:
   82  Attraction ROM: ATROM-4S-0, 4Mibit (is called Slave ProgramROM in BIOS menu ?)
   83                  Menu to select one of the 3 games (or 5, if a cartridge is inserted in slot 2)
   84  GameData ROM: GROM1-1, 256Kibit, most likely contains the graphics used by the attract menu
   85                May also contain the extra text layers added to the game graphics
   86  Upper ROM: Super Mario Kart ROM (Nintendo), SHVC-MK-0, 4Mibit
   87  Upper ROM: Super Mario Collection ROM (Nintendo), SHVC-4M-1, 16Mibit
   88  Upper ROM: Star Fox ROM (Nintendo), SHVC-FO-1, 8Mibit
   89  DSP 1 B coprocessor: (DSP 1 A in earlier SFBOX units) it is needed to operate Super Mario Kart
   90  MARIO CHIP 1 coprocessor: Also known as "Super FX", it is needed to operate Star Fox
   91  Static RAM: 1Mibit
   92  Static RAM: 256 Kibit
   93  
   94  PSS-62  - SUPER FAMICOM BOX Commercial Optional Cart
   95  GameData ROM: GROM2-1, 256Kibit
   96  Lower ROM: New Super 3D Golf Simulation - Waialae No Kiseki (Waialae Golf) (T&E SOFT), SHVC-GC-0, 4Mibit
   97  Lower ROM: Super Mahjong 2 (I'MAX), SHVC-2A-1, 8Mibit
   98  
   99  PSS-63  - SUPER FAMICOM BOX Commercial Optional Cart
  100  GameData ROM: GROM3-1, 256Kibit
  101  Lower ROM: Super Donkey Kong (Nintendo), SHVC-8X-1, 32Mibit
  102  Lower ROM: Super Tetris 2 + Bombliss (BPS), SHVC-T2-1, 8Mibit
  103  
  104  PSS-64  - SUPER FAMICOM BOX Commercial Optional Cart
  105  GameData ROM: GROM4-1, undumped
  106  Lower ROM: Super Donkey Kong (Nintendo), SHVC-8X-1, 32Mibit
  107  Lower ROM: Super Bomberman 2 (Hudson Soft), SHVC-M4-0, 8Mibit
  108  
  109  How does the Super Famicom Box operates
  110  ---------------------------------------
  111  -Operate with a key, goes into BIOS, does automated checks, PSS-61 must be inserted for system to operate.
  112  -Goes into the attraction ROM, there is a graphical menu to select a game.
  113   Apparently the menu graphics are imported from the GROMs.
  114  -Goes into selected game, can go back to attraction ROM menu.
  115  
  116  ***************************************************************************/
  117  
  118  #include "emu.h"
  119  #include "cpu/spc700/spc700.h"
  120  #include "cpu/g65816/g65816.h"
  121  #include "cpu/z180/z180.h"
  122  #include "machine/s3520cf.h"
  123  #include "video/mb90082.h"
  124  #include "includes/snes.h"
  125  #include "audio/snes_snd.h"
  126  #include "rendlay.h"
  127  
  128  class sfcbox_state : public snes_state
  129  {
  130  public:
  131      sfcbox_state(const machine_config &mconfig, device_type type, const char *tag)
  132          : snes_state(mconfig, type, tag),
  133          m_bios(*this, "bios"),
  134          m_mb90082(*this,"mb90082"),
  135          m_s3520cf(*this, "s3520cf")
  136          { }
  137  
  138      required_device<cpu_device> m_bios;
  139      required_device<mb90082_device> m_mb90082;
  140      required_device<s3520cf_device> m_s3520cf;
  141  
  142      UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
  143  
  144      DECLARE_READ8_MEMBER( port_81_r );
  145      DECLARE_READ8_MEMBER( port_83_r );
  146      DECLARE_WRITE8_MEMBER( port_80_w );
  147      DECLARE_WRITE8_MEMBER( port_81_w );
  148      DECLARE_WRITE8_MEMBER( port_83_w );
  149      DECLARE_WRITE8_MEMBER( snes_map_0_w );
  150      DECLARE_WRITE8_MEMBER( snes_map_1_w );
  151      DECLARE_MACHINE_START(sfcbox);
  152      DECLARE_MACHINE_RESET(sfcbox);
  153      DECLARE_READ8_MEMBER(spc_ram_100_r);
  154      DECLARE_WRITE8_MEMBER(spc_ram_100_w);
  155  };
  156  
  157  UINT32 sfcbox_state::screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect )
  158  {
  159      m_mb90082->screen_update(screen,bitmap,cliprect);
  160      return 0;
  161  }
  162  
  163  static ADDRESS_MAP_START( snes_map, AS_PROGRAM, 8, sfcbox_state )
  164      AM_RANGE(0x000000, 0x2fffff) AM_READWRITE_LEGACY(snes_r_bank1, snes_w_bank1)    /* I/O and ROM (repeats for each bank) */
  165      AM_RANGE(0x300000, 0x3fffff) AM_READWRITE_LEGACY(snes_r_bank2, snes_w_bank2)    /* I/O and ROM (repeats for each bank) */
  166      AM_RANGE(0x400000, 0x5fffff) AM_READ_LEGACY(snes_r_bank3)                       /* ROM (and reserved in Mode 20) */
  167      AM_RANGE(0x600000, 0x6fffff) AM_READWRITE_LEGACY(snes_r_bank4, snes_w_bank4)    /* used by Mode 20 DSP-1 */
  168      AM_RANGE(0x700000, 0x7dffff) AM_READWRITE_LEGACY(snes_r_bank5, snes_w_bank5)
  169      AM_RANGE(0x7e0000, 0x7fffff) AM_RAM                 /* 8KB Low RAM, 24KB High RAM, 96KB Expanded RAM */
  170      AM_RANGE(0x800000, 0xbfffff) AM_READWRITE_LEGACY(snes_r_bank6, snes_w_bank6)    /* Mirror and ROM */
  171      AM_RANGE(0xc00000, 0xffffff) AM_READWRITE_LEGACY(snes_r_bank7, snes_w_bank7)    /* Mirror and ROM */
  172  ADDRESS_MAP_END
  173  
  174  READ8_MEMBER(sfcbox_state::spc_ram_100_r)
  175  {
  176      device_t *device = machine().device("spc700");
  177      return spc_ram_r(device, space, offset + 0x100);
  178  }
  179  
  180  WRITE8_MEMBER(sfcbox_state::spc_ram_100_w)
  181  {
  182      device_t *device = machine().device("spc700");
  183      spc_ram_w(device, space, offset + 0x100, data);
  184  }
  185  
  186  static ADDRESS_MAP_START( spc_mem, AS_PROGRAM, 8, sfcbox_state )
  187      AM_RANGE(0x0000, 0x00ef) AM_DEVREADWRITE_LEGACY("spc700", spc_ram_r, spc_ram_w) /* lower 32k ram */
  188      AM_RANGE(0x00f0, 0x00ff) AM_DEVREADWRITE_LEGACY("spc700", spc_io_r, spc_io_w)   /* spc io */
  189      AM_RANGE(0x0100, 0xffff) AM_READWRITE(spc_ram_100_r, spc_ram_100_w)
  190  ADDRESS_MAP_END
  191  
  192  static ADDRESS_MAP_START( sfcbox_map, AS_PROGRAM, 8, sfcbox_state )
  193      AM_RANGE(0x00000, 0x0ffff) AM_ROM AM_REGION("krom", 0)
  194      AM_RANGE(0x20000, 0x27fff) AM_RAM
  195      AM_RANGE(0x40000, 0x47fff) AM_ROM AM_REGION("grom1", 0)
  196      AM_RANGE(0x60000, 0x67fff) AM_ROM AM_REGION("grom2", 0)
  197  ADDRESS_MAP_END
  198  
  199  
  200  WRITE8_MEMBER( sfcbox_state::port_80_w )
  201  {
  202  /*
  203      x--- ----   (often same as bit5)
  204      -x-- ----   Unknown/unused
  205      --x- ----     ??         PLENTY used (often same as bit7)
  206      ---x ----   ?? pulsed while [C094] is nonzero (0370h timer0 steps)
  207      ---- x---   Unknown/unused
  208      ---- -x--   SNES Transfer DATA to SNES  (Bit1 of WRIO/RDIO on SNES side)
  209      ---- --x-   SNES Transfer CLOCK to SNES (Bit5 of WRIO/RDIO on SNES side)
  210      ---- ---x   SNES Transfer STAT to SNES  (Bit2 of WRIO/RDIO on SNES side)
  211  */
  212      snes_ram[WRIO] = ((data & 4) >> 1) | (snes_ram[WRIO] & ~0x02); // DATA
  213      snes_ram[WRIO] = ((data & 2) << 4) | (snes_ram[WRIO] & ~0x20); // CLOCK
  214      snes_ram[WRIO] = ((data & 1) << 2) | (snes_ram[WRIO] & ~0x04); // STAT
  215  }
  216  
  217  
  218  READ8_MEMBER( sfcbox_state::port_81_r )
  219  {
  220  /*
  221      x--- ----   Vblank, Vsync, or Whatever flag (must toggle on/off at whatever speed)
  222      -x-- ----   Int1 Request (Joypad is/was accessed by SNES or so?) (0=IRQ, 1=No)
  223      --x- ----   Unknown/unused  ;/(for "joy2/slot1" or so, use [A0].4-5)
  224      ---x ----   Unknown/unused  ;\joy1/slot0 or so, used by an UNUSED function (08A0h)
  225      ---- x---   Boot mode or so (maybe a jumper, or watchdog-flag, or Bit0 of WRIO/RDIO?)
  226      ---- -x--   SNES Transfer DATA from SNES (Bit4 of WRIO/RDIO on SNES side)
  227      ---- --x-   SNES Transfer ACK from SNES  (Bit3 of WRIO/RDIO on SNES side)
  228      ---- ---x   Int0 Request (Coin-Input, Low for 44ms..80ms) (0=IRQ, 1=No)
  229  */
  230      UINT8 res;
  231  
  232      res = (machine().primary_screen->vblank() & 1) << 7;
  233      res = 1 << 6;
  234      res = 0 << 5;
  235      res = 0 << 4;
  236      res = 0 << 3;
  237      res |= ((snes_ram[WRIO] & 0x10) >> 4) << 2; // DATA to main
  238      res |= ((snes_ram[WRIO] & 0x08) >> 3) << 1; // ACK to main
  239      res = 1 << 0;
  240  
  241      return res;
  242  }
  243  
  244  WRITE8_MEMBER( sfcbox_state::port_81_w )
  245  {
  246      m_maincpu->set_input_line(INPUT_LINE_RESET, (data & 1) ? CLEAR_LINE : ASSERT_LINE);
  247      m_soundcpu->set_input_line(INPUT_LINE_RESET, (data & 1) ? CLEAR_LINE : ASSERT_LINE);
  248  
  249      ioport("OSD_CS")->write(data, 0xff);
  250  }
  251  
  252  READ8_MEMBER( sfcbox_state::port_83_r )
  253  {
  254      return 0xff;
  255  }
  256  
  257  WRITE8_MEMBER( sfcbox_state::port_83_w )
  258  {
  259  }
  260  
  261  WRITE8_MEMBER( sfcbox_state::snes_map_0_w )
  262  {
  263      const char *const rom_socket[4] = { "ROM5", "ROM1/7/12", "ROM3/9", "IC23" };
  264  
  265      printf("%s ROM Socket\n",rom_socket[data & 3]);
  266      printf("%02x ROM Slot\n",(data & 4) >> 2);
  267      printf("%02x SRAM Enable\n",(data & 8) >> 3);
  268      printf("%02x SRAM Slot\n",(data & 0x10) >> 4);
  269      printf("%02x DSP Enable\n",(data & 0x20) >> 5);
  270      printf("%02x DSP Slot\n",(data & 0x40) >> 6);
  271      printf("%s ROM / DSP / SRAM maps\n",(data & 0x80) ? "HiROM" : "LoROM");
  272  }
  273  
  274  WRITE8_MEMBER( sfcbox_state::snes_map_1_w )
  275  {
  276      /* Reserved for ROM DSP SRAM probably means bank ATROM */
  277      const char *const rom_dsp_sram[4] = {   "Reserved?", "GSU", "LoROM", "HiROM" };
  278      const char *const sram_size[4] = {  "2K", "8K", "Reserved?", "32K" };
  279  
  280      printf("%s ROM / DSP SRAM map 2\n",rom_dsp_sram[data & 3]);
  281      printf("%08x SRAM base\n",((data & 0xc) >> 2)*0x8000);
  282      printf("%02x GSU Slot\n",((data & 0x10) >> 4));
  283      printf("%s SRAM Size\n",sram_size[((data & 0xc0) >> 6)]);
  284  }
  285  
  286  static ADDRESS_MAP_START( sfcbox_io, AS_IO, 8, sfcbox_state )
  287      AM_RANGE(0x0b, 0x0b) AM_DEVWRITE("mb90082",mb90082_device,write)
  288      AM_RANGE(0x00, 0x3f) AM_RAM // internal i/o
  289      AM_RANGE(0x80, 0x80) AM_READ_PORT("KEY") AM_WRITE(port_80_w) // Keyswitch and Button Inputs / SNES Transfer and Misc Output
  290      AM_RANGE(0x81, 0x81) AM_READWRITE(port_81_r,port_81_w) // SNES Transfer and Misc Input / Misc Output
  291  //  AM_RANGE(0x82, 0x82) // Unknown/unused
  292      AM_RANGE(0x83, 0x83) AM_READWRITE(port_83_r,port_83_w) // Joypad Input/Status / Joypad Output/Control
  293  //  AM_RANGE(0x84, 0x84) // Joypad 1, MSB (1st 8 bits) (eg. Bit7=ButtonB, 0=Low=Pressed)
  294  //  AM_RANGE(0x85, 0x85) // Joypad 1, LSB (2nd 8 bits) (eg. Bit0=LSB of ID, 0=Low=One)
  295  //  AM_RANGE(0x86, 0x86) // Joypad 2, MSB (1st 8 bits) (eg. Bit7=ButtonB, 0=Low=Pressed)
  296  //  AM_RANGE(0x87, 0x87) // Joypad 2, LSB (2nd 8 bits) (eg. Bit0=LSB of ID, 0=Low=One)
  297      AM_RANGE(0xa0, 0xa0) AM_READ_PORT("RTC_R") AM_WRITE_PORT("RTC_W") //  Real Time Clock
  298      AM_RANGE(0xc0, 0xc0) AM_WRITE(snes_map_0_w) // SNES Mapping Register 0
  299      AM_RANGE(0xc1, 0xc1) AM_WRITE(snes_map_1_w) // SNES Mapping Register 1
  300  ADDRESS_MAP_END
  301  
  302  
  303  static INPUT_PORTS_START( snes )
  304      PORT_START("RTC_R")
  305      PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, read_bit)
  306  
  307      PORT_START("RTC_W")
  308      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, set_clock_line)
  309      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, write_bit)
  310      PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, set_dir_line)
  311      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("s3520cf", s3520cf_device, set_cs_line)
  312  
  313      /* TODO: verify these */
  314      PORT_START("KEY")
  315      PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON14 ) PORT_NAME("Reset Button")
  316      PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON13 ) PORT_NAME("TV/GAME Button")
  317      PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON12 ) PORT_NAME("Relay Off Button")
  318      PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON7 )  PORT_NAME("Options Button")
  319      PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON11 ) PORT_NAME("Self-Test Button")
  320      PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON10 ) PORT_NAME("Play Mode 3 Button")
  321      PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON9 )  PORT_NAME("Play Mode 2 Button")
  322      PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON8 )  PORT_NAME("Play Mode 1 Button")
  323  
  324      PORT_START("OSD_CS")
  325      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_OUTPUT ) PORT_WRITE_LINE_DEVICE_MEMBER("mb90082", mb90082_device, set_cs_line)
  326  
  327      PORT_START("SERIAL1_DATA1_L")
  328      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P1 Button A") PORT_PLAYER(1)
  329      PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P1 Button X") PORT_PLAYER(1)
  330      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P1 Button L") PORT_PLAYER(1)
  331      PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P1 Button R") PORT_PLAYER(1)
  332      PORT_START("SERIAL1_DATA1_H")
  333      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P1 Button B") PORT_PLAYER(1)
  334      PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P1 Button Y") PORT_PLAYER(1)
  335      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE1 ) PORT_NAME("P1 Select")
  336      PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("P1 Start")
  337      PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
  338      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
  339      PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
  340      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
  341  
  342      PORT_START("SERIAL2_DATA1_L")
  343      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("P2 Button A") PORT_PLAYER(2)
  344      PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("P2 Button X") PORT_PLAYER(2)
  345      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("P2 Button L") PORT_PLAYER(2)
  346      PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("P2 Button R") PORT_PLAYER(2)
  347      PORT_START("SERIAL2_DATA1_H")
  348      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("P2 Button B") PORT_PLAYER(2)
  349      PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("P2 Button Y") PORT_PLAYER(2)
  350      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SERVICE2 ) PORT_NAME("P2 Select")
  351      PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("P2 Start")
  352      PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
  353      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
  354      PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
  355      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
  356  
  357      PORT_START("SERIAL1_DATA2_L")
  358      PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
  359      PORT_START("SERIAL1_DATA2_H")
  360      PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
  361  
  362      PORT_START("SERIAL2_DATA2_L")
  363      PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
  364      PORT_START("SERIAL2_DATA2_H")
  365      PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
  366  
  367      PORT_START("DSW")
  368      PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
  369      PORT_DIPSETTING(    0x00, DEF_STR( Normal ) )
  370      PORT_DIPSETTING(    0x03, DEF_STR( Hard )  )
  371      PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )
  372      PORT_DIPSETTING(    0x0c, "2" )
  373      PORT_DIPSETTING(    0x08, "3" )
  374      PORT_DIPSETTING(    0x04, "4" )
  375      PORT_DIPSETTING(    0x00, "5" )
  376      PORT_DIPNAME( 0x30, 0x00, "Time limit per level?" ) // taken from the scan of nss_adam
  377      PORT_DIPSETTING(    0x10, "104 sec." )
  378      PORT_DIPSETTING(    0x20, "112 sec." )
  379      PORT_DIPSETTING(    0x00, "120 sec." )
  380      PORT_DIPSETTING(    0x30, "? sec." )
  381      PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
  382      PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  383      PORT_DIPSETTING(    0x40, DEF_STR( On ) )
  384      PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
  385      PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  386      PORT_DIPSETTING(    0x80, DEF_STR( On ) )
  387  
  388  #if SNES_LAYER_DEBUG
  389      PORT_START("DEBUG1")
  390      PORT_CONFNAME( 0x03, 0x00, "Select BG1 priority" )
  391      PORT_CONFSETTING(    0x00, "All" )
  392      PORT_CONFSETTING(    0x01, "BG1B (lower) only" )
  393      PORT_CONFSETTING(    0x02, "BG1A (higher) only" )
  394      PORT_CONFNAME( 0x0c, 0x00, "Select BG2 priority" )
  395      PORT_CONFSETTING(    0x00, "All" )
  396      PORT_CONFSETTING(    0x04, "BG2B (lower) only" )
  397      PORT_CONFSETTING(    0x08, "BG2A (higher) only" )
  398      PORT_CONFNAME( 0x30, 0x00, "Select BG3 priority" )
  399      PORT_CONFSETTING(    0x00, "All" )
  400      PORT_CONFSETTING(    0x10, "BG3B (lower) only" )
  401      PORT_CONFSETTING(    0x20, "BG3A (higher) only" )
  402      PORT_CONFNAME( 0xc0, 0x00, "Select BG4 priority" )
  403      PORT_CONFSETTING(    0x00, "All" )
  404      PORT_CONFSETTING(    0x40, "BG4B (lower) only" )
  405      PORT_CONFSETTING(    0x80, "BG4A (higher) only" )
  406  
  407      PORT_START("DEBUG2")
  408      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle BG 1") PORT_CODE(KEYCODE_1_PAD) PORT_TOGGLE
  409      PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle BG 2") PORT_CODE(KEYCODE_2_PAD) PORT_TOGGLE
  410      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle BG 3") PORT_CODE(KEYCODE_3_PAD) PORT_TOGGLE
  411      PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle BG 4") PORT_CODE(KEYCODE_4_PAD) PORT_TOGGLE
  412      PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Objects") PORT_CODE(KEYCODE_5_PAD) PORT_TOGGLE
  413      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Main/Sub") PORT_CODE(KEYCODE_6_PAD) PORT_TOGGLE
  414      PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Color Math") PORT_CODE(KEYCODE_7_PAD) PORT_TOGGLE
  415      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Windows") PORT_CODE(KEYCODE_8_PAD) PORT_TOGGLE
  416  
  417      PORT_START("DEBUG3")
  418      PORT_BIT( 0x4, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mosaic") PORT_CODE(KEYCODE_9_PAD) PORT_TOGGLE
  419      PORT_CONFNAME( 0x70, 0x00, "Select OAM priority" )
  420      PORT_CONFSETTING(    0x00, "All" )
  421      PORT_CONFSETTING(    0x10, "OAM0 only" )
  422      PORT_CONFSETTING(    0x20, "OAM1 only" )
  423      PORT_CONFSETTING(    0x30, "OAM2 only" )
  424      PORT_CONFSETTING(    0x40, "OAM3 only" )
  425      PORT_CONFNAME( 0x80, 0x00, "Draw sprite in reverse order" )
  426      PORT_CONFSETTING(    0x00, DEF_STR( Off ) )
  427      PORT_CONFSETTING(    0x80, DEF_STR( On ) )
  428  
  429      PORT_START("DEBUG4")
  430      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mode 0 draw") PORT_TOGGLE
  431      PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mode 1 draw") PORT_TOGGLE
  432      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mode 2 draw") PORT_TOGGLE
  433      PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mode 3 draw") PORT_TOGGLE
  434      PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mode 4 draw") PORT_TOGGLE
  435      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mode 5 draw") PORT_TOGGLE
  436      PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mode 6 draw") PORT_TOGGLE
  437      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Toggle Mode 7 draw") PORT_TOGGLE
  438  #endif
  439  INPUT_PORTS_END
  440  
  441  static MACHINE_CONFIG_START( snes, sfcbox_state )
  442  
  443      /* basic machine hardware */
  444      MCFG_CPU_ADD("maincpu", _5A22, 3580000*6)   /* 2.68Mhz, also 3.58Mhz */
  445      MCFG_CPU_PROGRAM_MAP(snes_map)
  446  
  447      MCFG_CPU_ADD("soundcpu", SPC700, 2048000/2) /* 2.048 Mhz, but internal divider */
  448      MCFG_CPU_PROGRAM_MAP(spc_mem)
  449  
  450      MCFG_QUANTUM_PERFECT_CPU("maincpu")
  451  
  452      MCFG_MACHINE_START( snes )
  453      MCFG_MACHINE_RESET( snes )
  454  
  455      /* video hardware */
  456      MCFG_VIDEO_START( snes )
  457  
  458      MCFG_SCREEN_ADD("screen", RASTER)
  459      MCFG_SCREEN_RAW_PARAMS(DOTCLK_NTSC, SNES_HTOTAL, 0, SNES_SCR_WIDTH, SNES_VTOTAL_NTSC, 0, SNES_SCR_HEIGHT_NTSC)
  460      MCFG_SCREEN_UPDATE_DRIVER( snes_state, snes_screen_update )
  461  
  462      /* sound hardware */
  463      MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
  464      MCFG_SOUND_ADD("spc700", SNES, 0)
  465      MCFG_SOUND_ROUTE(0, "lspeaker", 1.00)
  466      MCFG_SOUND_ROUTE(1, "rspeaker", 1.00)
  467  MACHINE_CONFIG_END
  468  
  469  
  470  MACHINE_START_MEMBER(sfcbox_state,sfcbox)
  471  {
  472      MACHINE_START_CALL_LEGACY(snes);
  473  
  474      m_is_sfcbox = 1;
  475  }
  476  
  477  MACHINE_RESET_MEMBER(sfcbox_state,sfcbox)
  478  {
  479      MACHINE_RESET_CALL_LEGACY( snes );
  480  
  481      /* start with both CPUs disabled */
  482      m_maincpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
  483      m_soundcpu->set_input_line(INPUT_LINE_RESET, ASSERT_LINE);
  484  }
  485  
  486  static MACHINE_CONFIG_DERIVED( sfcbox, snes )
  487  
  488      MCFG_CPU_ADD("bios", Z180, XTAL_12MHz / 2)  /* HD64180RF6X */
  489      MCFG_CPU_PROGRAM_MAP(sfcbox_map)
  490      MCFG_CPU_IO_MAP(sfcbox_io)
  491  
  492      MCFG_MB90082_ADD("mb90082",XTAL_12MHz / 2) /* TODO: correct clock */
  493      MCFG_S3520CF_ADD("s3520cf") /* RTC */
  494  
  495      MCFG_MACHINE_START_OVERRIDE(sfcbox_state, sfcbox )
  496      MCFG_MACHINE_RESET_OVERRIDE(sfcbox_state, sfcbox )
  497  
  498      /* TODO: the screen should actually superimpose, but for the time being let's just separate outputs */
  499      MCFG_DEFAULT_LAYOUT(layout_dualhsxs)
  500  
  501      MCFG_SCREEN_ADD("osd", RASTER)
  502      MCFG_SCREEN_REFRESH_RATE(60)
  503      MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500))
  504  //  MCFG_SCREEN_SIZE(24*12+22, 12*18+22)
  505  //  MCFG_SCREEN_VISIBLE_AREA(0*8, 24*12-1, 0*8, 12*18-1)
  506      MCFG_SCREEN_SIZE(24*16+22, 12*16+22)
  507      MCFG_SCREEN_VISIBLE_AREA(0*8, 24*16-1, 0*8, 12*16-1)
  508      MCFG_SCREEN_UPDATE_DRIVER(sfcbox_state,screen_update)
  509  MACHINE_CONFIG_END
  510  
  511  /***************************************************************************
  512  
  513    Game driver(s)
  514  
  515  ***************************************************************************/
  516  
  517  #define SFCBOX_BIOS \
  518      ROM_REGION( 0x1000000, "maincpu", ROMREGION_ERASE00 ) \
  519      ROM_REGION( 0x100, "sound_ipl", 0 ) \
  520      ROM_LOAD( "spc700.rom", 0x00, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) ) \
  521      ROM_REGION( 0x10000, "krom", 0 ) \
  522      ROM_LOAD( "krom1.ic1", 0x00000, 0x10000, CRC(c9010002) SHA1(f4c74086a83b728b1c1af3a021a60efa80eff5a4) ) \
  523      ROM_REGION( 0x100000, "user3", 0 ) \
  524      ROM_LOAD( "atrom-4s-0.rom5", 0x00000, 0x80000, CRC(ad3ec05c) SHA1(a3d336db585fe02a37c323422d9db6a33fd489a6) )
  525  
  526  ROM_START( sfcbox )
  527      SFCBOX_BIOS
  528  
  529      ROM_REGION( 0x8000, "grom1", ROMREGION_ERASEFF )
  530  
  531      ROM_REGION( 0x8000, "grom2", ROMREGION_ERASEFF )
  532  ROM_END
  533  
  534  ROM_START( pss61 )
  535      SFCBOX_BIOS
  536  
  537      ROM_REGION( 0x8000, "grom1", 0 )
  538      ROM_LOAD( "grom1-1.ic1", 0x0000, 0x8000, CRC(333bf9a7) SHA1(5d0cd9ca29e5580c3eebe9f136839987c879f979) )
  539  
  540      ROM_REGION( 0x8000, "grom2", ROMREGION_ERASEFF )
  541  
  542      ROM_REGION( 0x380000, "game", 0 )
  543      ROM_LOAD( "shvc-mk-0.rom12", 0x000000, 0x080000, CRC(c8002453) SHA1(cbb853bf911255c1d8eb27cd34fc7855a0dda218) )
  544      ROM_LOAD( "shvc-4m-1.rom3", 0x080000, 0x200000, CRC(91b28d56) SHA1(b83dd73d3d6049450bb8092d73c3af879804f58c) )
  545      ROM_LOAD( "shvc-fo-1.ic20", 0x280000, 0x100000, CRC(ad668a41) SHA1(39ff7354a7fa02295c899b7a7ec3556998ac2636) ) /* TODO: Super FX hook needed for Star Fox */
  546  ROM_END
  547  
  548  ROM_START( pss62 )
  549      SFCBOX_BIOS
  550  
  551      ROM_REGION( 0x8000, "grom1", 0 )
  552      ROM_LOAD( "grom2-1.ic1", 0x0000, 0x8000, CRC(bcfc5642) SHA1(a96e52685bd3dcdf09d1b7acd6e1c1ab7726a640) )
  553  
  554      ROM_REGION( 0x8000, "grom2", ROMREGION_ERASEFF )
  555  
  556      ROM_REGION( 0x180000, "game", 0 )
  557      ROM_LOAD( "shvc-gc-0.rom1", 0x000000, 0x100000, CRC(b4fd7aff) SHA1(eb553b77418dedba25fc4d5dddcb04f424b0f6a9) )
  558      ROM_LOAD( "shvc-2a-1.rom3", 0x100000, 0x080000, CRC(6b23e2e4) SHA1(684123a12ca1e31115bd6221d96f82461066877f) )
  559  ROM_END
  560  
  561  ROM_START( pss63 )
  562      SFCBOX_BIOS
  563  
  564      ROM_REGION( 0x8000, "grom1", 0 )
  565      ROM_LOAD( "grom3-1.ic1", 0x0000, 0x8000, CRC(ebec4c1c) SHA1(d638ef1486b4c0b3d4d5b666929ca7947e16efad) )
  566  
  567      ROM_REGION( 0x8000, "grom2", ROMREGION_ERASEFF )
  568  
  569      ROM_REGION( 0x500000, "game", 0 )
  570      ROM_LOAD( "shvc-t2-1.rom3", 0x000000, 0x100000, CRC(4ae93c10) SHA1(5fa25d027940907b769578d7bf85a9d5ba94911a) )
  571      ROM_LOAD( "shvc-8x-1.rom1", 0x100000, 0x400000, CRC(3adef543) SHA1(df02860e691fbee453e345dd343c08b6da08d4ea) )
  572  ROM_END
  573  
  574  ROM_START( pss64 )
  575      SFCBOX_BIOS
  576  
  577      ROM_REGION( 0x8000, "grom1", ROMREGION_ERASEFF )
  578      ROM_LOAD( "grom4-1.ic1", 0x0000, 0x8000, NO_DUMP )
  579  
  580      ROM_REGION( 0x8000, "grom2", ROMREGION_ERASEFF )
  581  
  582      ROM_REGION( 0x500000, "game", 0 )
  583      ROM_LOAD( "shvc-m4-0.rom3", 0x000000, 0x100000, CRC(fb259f4f) SHA1(8faeb56f80e82dd042bdc84d19c526a979c6de8f) )
  584      ROM_LOAD( "shvc-8x-1.rom1", 0x100000, 0x400000, CRC(3adef543) SHA1(df02860e691fbee453e345dd343c08b6da08d4ea) )
  585  //  Possibly reverse order :
  586  //  ROM_LOAD( "shvc-8x-1.rom1", 0x000000, 0x400000, CRC(3adef543) SHA1(df02860e691fbee453e345dd343c08b6da08d4ea) )
  587  //  ROM_LOAD( "shvc-m4-0.rom3", 0x400000, 0x100000, CRC(fb259f4f) SHA1(8faeb56f80e82dd042bdc84d19c526a979c6de8f) )
  588  ROM_END
  589  
  590  
  591  GAME( 1994, sfcbox,      0,     sfcbox,      snes, snes_state,    snes,    ROT0, "Nintendo",                   "Super Famicom Box BIOS", GAME_IS_BIOS_ROOT | GAME_NOT_WORKING )
  592  GAME( 1994, pss61, sfcbox, sfcbox, snes, snes_state, snes, ROT0, "Nintendo", "Super Mario Kart / Super Mario Collection / Star Fox (Super Famicom Box)", GAME_NOT_WORKING )
  593  GAME( 1994, pss62, sfcbox, sfcbox, snes, snes_state, snes, ROT0, "T&E Soft / I'Max", "New Super 3D Golf Simulation - Waialae No Kiseki / Super Mahjong 2 (Super Famicom Box)", GAME_NOT_WORKING )
  594  GAME( 1994, pss63, sfcbox, sfcbox, snes, snes_state, snes, ROT0, "Nintendo / BPS", "Super Donkey Kong / Super Tetris 2 + Bombliss (Super Famicom Box)", GAME_NOT_WORKING )
  595  GAME( 199?, pss64, sfcbox, sfcbox, snes, snes_state, snes, ROT0, "Nintendo / Hudson Soft", "Super Donkey Kong / Super Bomberman 2 (Super Famicom Box)", GAME_NOT_WORKING )