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

    1  /*************************************************************************************************************
    2  
    3                                       -= Sigma B-98 Hardware / Sammy Medal Games =-
    4  
    5                                                   driver by Luca Elia
    6  
    7  CPU     :   TAXAN KY-80 (Yamaha)
    8  Custom  :   TAXAN KY-3211
    9  Sound   :   YMZ280B
   10  NVRAM   :   93C46, Battery
   11  
   12  Graphics are made of sprites only.
   13  Each sprite is composed of X x Y tiles and can be zoomed / shrunk.
   14  Tiles can be 16x16x4 or 16x16x8.
   15  
   16  ----------------------------------------------------------------
   17  
   18  Sammy Kids Medal Series
   19  
   20  CPU     :   KL5C80A120FP (Z80 Compatible High Speed Microcontroller)
   21  Custom  :   TAXAN KY-3211 ?
   22  Sound   :   OKI M9810B
   23  NVRAM   :   93C46, Battery
   24  
   25  Cartridge based system. Carts contain just some 16Mb flash eeproms.
   26  
   27  Info from Tatsuya Fujita:
   28  
   29  According to some news articles for the AOU show 2002 and 2003 the correct system name
   30  is "Treasure Fall" (despite the cart label is "Treasure Hall").
   31  
   32  Dumped games:
   33  
   34  Animal Catch
   35  Itazura Monkey
   36  Taihou de Doboon
   37  Pye-nage Taikai
   38  Hae Hae Ka Ka Ka
   39  
   40  Games with the same cabinet which might be on the same hardware:
   41  
   42  1999 Shatekids
   43  1999 Otakara Locomo
   44  1999 Dokidoki Kingyosukui
   45  2000 Taihou de Doboon
   46  2000 Pye-nage Taikai
   47  2000 Animal Catch
   48  2000 Itazura Monkey
   49  2000 Otoshicha Ottotto
   50  2000 Go Go Cowboy
   51  2001 Mushitori Meijin
   52  2001 Morino Dodgeball Senshuken
   53  2001 Waiwai Wanage
   54  2001 Hae Hae Ka Ka Ka
   55  2001 Zarigani Tsuri
   56  2001 Kotekitai Slot
   57  2002 Shateki Yokochou
   58  2002 Ipponzuri Slot
   59  2002 Karateman
   60  2002 One-touchable
   61  2003 Gun Kids
   62  2003 Kurukuru Train
   63  2003 Zakuzaku Kaizokudan
   64  2004 Animal Punch
   65  2004 Dotabata Zaurus
   66  2004 Ninchuu Densetsu
   67  
   68  from:
   69  http://www.tsc-acnet.com/index.php?sort=8&action=cataloglist&s=1&mode=3&genre_id=40&freeword=%25A5%25B5%25A5%25DF%25A1%25BC
   70  
   71  To Do:
   72  
   73  - KL5C80 emulation is needed to consolidate the sammymdl games in one memory map and to run the BIOS
   74  - Remove ROM patches from gegege, pepsiman
   75  - gegege checks the EEPROM output after reset, and wants a timed 0->1 transition or locks up while
   76    saving setting in service mode. Using a reset_delay of 7 works, unless when "play style" is set
   77    to "coin" (it probably changes the number of reads from port $C0).
   78    I guess the reset_delay mechanism should be implemented with a timer in eeprom.c.
   79  - animalc needs a green backgound during part of the intro (floating animals in and out of the screen).
   80    This can be achieved using either pen 0 or ff as background color, but messes up the other games.
   81  - pyenaget intro: when the theater scrolls out to the left, the train should scroll in from the right,
   82    with no visible gaps. It currently leaves the screen empty instead, for several seconds.
   83  
   84  Notes:
   85  
   86  - "BACKUP RAM NG" error: in test mode, choose "SET MODE" -> "RAM CLEAR" and keep the button pressed for long.
   87  
   88  *************************************************************************************************************/
   89  
   90  #include "emu.h"
   91  #include "cpu/z80/z80.h"
   92  #include "sound/okim9810.h"
   93  #include "sound/ymz280b.h"
   94  #include "machine/eeprom.h"
   95  #include "machine/nvram.h"
   96  #include "machine/ticket.h"
   97  
   98  
   99  class sigmab98_state : public driver_device
  100  {
  101  public:
  102      sigmab98_state(const machine_config &mconfig, device_type type, const char *tag)
  103          : driver_device(mconfig, type, tag),
  104          m_maincpu(*this,"maincpu"),
  105          m_spriteram(*this, "spriteram"),
  106          m_nvram(*this, "nvram"){ }
  107  
  108      required_device<cpu_device> m_maincpu;
  109      optional_shared_ptr<UINT8> m_spriteram;
  110      required_shared_ptr<UINT8> m_nvram;
  111  
  112      UINT8 m_reg;
  113      UINT8 m_rombank;
  114      UINT8 m_reg2;
  115      UINT8 m_rambank;
  116      UINT8 m_c0;
  117      UINT8 m_c4;
  118      UINT8 m_c6;
  119      UINT8 m_c8;
  120      UINT8 m_vblank;
  121      UINT8 m_out[3];
  122  
  123      UINT8 m_vblank_vector;
  124      UINT8 m_timer0_vector;
  125      UINT8 m_timer1_vector;
  126      DECLARE_WRITE8_MEMBER(regs_w);
  127      DECLARE_READ8_MEMBER(regs_r);
  128      DECLARE_WRITE8_MEMBER(regs2_w);
  129      DECLARE_READ8_MEMBER(regs2_r);
  130      DECLARE_WRITE8_MEMBER(c4_w);
  131      DECLARE_WRITE8_MEMBER(c6_w);
  132      DECLARE_WRITE8_MEMBER(c8_w);
  133      DECLARE_WRITE8_MEMBER(animalc_rombank_w);
  134      DECLARE_READ8_MEMBER(animalc_rombank_r);
  135      DECLARE_WRITE8_MEMBER(animalc_rambank_w);
  136      DECLARE_READ8_MEMBER(animalc_rambank_r);
  137      DECLARE_READ8_MEMBER(unk_34_r);
  138      DECLARE_READ8_MEMBER(vblank_r);
  139      DECLARE_WRITE8_MEMBER(vblank_w);
  140      DECLARE_WRITE8_MEMBER(sammymdl_coin_w);
  141      DECLARE_WRITE8_MEMBER(sammymdl_leds_w);
  142      DECLARE_WRITE8_MEMBER(sammymdl_hopper_w);
  143      DECLARE_READ8_MEMBER(sammymdl_coin_hopper_r);
  144      DECLARE_WRITE8_MEMBER(haekaka_rombank_w);
  145      DECLARE_READ8_MEMBER(haekaka_rombank_r);
  146      DECLARE_WRITE8_MEMBER(haekaka_rambank_w);
  147      DECLARE_READ8_MEMBER(haekaka_rambank_r);
  148      DECLARE_READ8_MEMBER(haekaka_vblank_r);
  149      DECLARE_READ8_MEMBER(haekaka_b000_r);
  150      DECLARE_WRITE8_MEMBER(haekaka_b000_w);
  151      DECLARE_WRITE8_MEMBER(haekaka_leds_w);
  152      DECLARE_WRITE8_MEMBER(haekaka_coin_w);
  153      DECLARE_WRITE8_MEMBER(itazuram_rombank_w);
  154      DECLARE_READ8_MEMBER(itazuram_rombank_r);
  155      DECLARE_WRITE8_MEMBER(itazuram_rambank_w);
  156      DECLARE_READ8_MEMBER(itazuram_rambank_r);
  157      DECLARE_WRITE8_MEMBER(itazuram_nvram_palette_w);
  158      DECLARE_WRITE8_MEMBER(itazuram_palette_w);
  159      DECLARE_READ8_MEMBER(itazuram_palette_r);
  160      DECLARE_WRITE8_MEMBER(tdoboon_rombank_w);
  161      DECLARE_READ8_MEMBER(tdoboon_rombank_r);
  162      DECLARE_WRITE8_MEMBER(tdoboon_rambank_w);
  163      DECLARE_READ8_MEMBER(tdoboon_rambank_r);
  164      DECLARE_READ8_MEMBER(tdoboon_c000_r);
  165      DECLARE_WRITE8_MEMBER(tdoboon_c000_w);
  166      void show_outputs();
  167      void show_3_outputs();
  168      DECLARE_WRITE8_MEMBER(eeprom_w);
  169      DECLARE_READ8_MEMBER(sammymdl_eeprom_r);
  170      DECLARE_WRITE8_MEMBER(sammymdl_eeprom_w);
  171      DECLARE_DRIVER_INIT(gegege);
  172      DECLARE_DRIVER_INIT(pepsiman);
  173      DECLARE_DRIVER_INIT(itazuram);
  174      DECLARE_DRIVER_INIT(animalc);
  175      DECLARE_DRIVER_INIT(ucytokyu);
  176      DECLARE_DRIVER_INIT(haekaka);
  177      DECLARE_MACHINE_RESET(sammymdl);
  178      UINT32 screen_update_sigmab98(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
  179      void screen_eof_sammymdl(screen_device &screen, bool state);
  180      INTERRUPT_GEN_MEMBER(gegege_vblank_interrupt);
  181      TIMER_DEVICE_CALLBACK_MEMBER(sammymd1_irq);
  182  };
  183  
  184  
  185  /***************************************************************************
  186  
  187      Video
  188  
  189  ***************************************************************************/
  190  
  191  /***************************************************************************
  192  
  193      Sprites
  194  
  195      Offset:     Bits:         Value:
  196  
  197      0           7654 ----
  198                  ---- 3210     Color
  199      1           7--- ----
  200                  -6-- ----     256 Color Sprite
  201                  --5- ----
  202                  ---4 ----     Flip X
  203                  ---- 3---     Flip Y
  204                  ---- -2--     Draw Sprite
  205                  ---- --10     Priority (0 = Front .. 3 = Back)
  206      2                         Tile Code (High)
  207      3                         Tile Code (Low)
  208      4           7654 3---     Number of X Tiles - 1
  209                  ---- -210     X (High)
  210      5                         X (Low)
  211      6           7654 3---     Number of Y Tiles - 1
  212                  ---- -210     Y (High)
  213      7                         Y (Low)
  214      8                         Shrink Factor (<< 8, High)
  215      9                         Shrink Factor (<< 8, Low)
  216      a
  217      b
  218      c           7654 3---
  219                  ---- -210     Delta X (High)
  220      d                         Delta X (Low)
  221      e           7654 3---
  222                  ---- -210     Delta Y (High)
  223      f                         Delta Y (Low)
  224  
  225  ***************************************************************************/
  226  
  227  static void draw_sprites(running_machine &machine, bitmap_ind16 &bitmap, const rectangle &cliprect, int pri_mask)
  228  {
  229      sigmab98_state *state = machine.driver_data<sigmab98_state>();
  230      UINT8 *end      =   state->m_spriteram - 0x10;
  231      UINT8 *s        =   end + state->m_spriteram.bytes();
  232  
  233      for ( ; s != end; s -= 0x10 )
  234      {
  235          int gfx, code, color, zoom, dim, scale;
  236          int sx, nx, x, x0, x1, dx, flipx;
  237          int sy, ny, y, y0, y1, dy, flipy;
  238  
  239          if ( (s[ 0x01 ] & 0x04) == 0)
  240              continue;
  241  
  242          if ( ((1 << (s[ 0x01 ] & 0x03)) & pri_mask) == 0 )
  243              continue;
  244  
  245          color   =   s[ 0x00 ] & 0xf;
  246  
  247          gfx     =   (s[ 0x01 ] & 0x40 ) ? 1 : 0;
  248  
  249          code    =   s[ 0x02 ] * 256 + s[ 0x03 ];
  250  
  251          nx      =   ((s[ 0x04 ] & 0xf8) >> 3) + 1;
  252  
  253          sx      =   (s[ 0x04 ] & 0x03) * 256 + s[ 0x05 ];
  254  
  255          ny      =   ((s[ 0x06 ] & 0xf8) >> 3) + 1;
  256  
  257          sy      =   (s[ 0x06 ] & 0x03) * 256 + s[ 0x07 ];
  258  
  259          zoom    =   (s[ 0x08 ] & 0xff) * 256 + s[ 0x09 ];
  260  
  261          dx      =   (s[ 0x0c ] & 0x03) * 256 + s[ 0x0d ];
  262          dy      =   (s[ 0x0e ] & 0x03) * 256 + s[ 0x0f ];
  263  
  264          // Sign extend the position
  265          sx      =   (sx & 0x1ff) - (sx & 0x200);
  266          sy      =   (sy & 0x1ff) - (sy & 0x200);
  267          dx      =   (dx & 0x1ff) - (dx & 0x200);
  268          dy      =   (dy & 0x1ff) - (dy & 0x200);
  269  
  270          // Add shift (negated, as it seems more correct in haekaka)
  271          sx      -=  dx;
  272          sy      -=  dy;
  273  
  274          // Use fixed point values (16.16), for accuracy
  275          sx      <<= 16;
  276          sy      <<= 16;
  277  
  278          zoom    =   (1 << 16) / (zoom ? zoom : 1);
  279          dim     =   (0x10 << 8) * zoom;
  280          scale   =   dim / 0x10;
  281  
  282          // Let's approximate to the nearest greater integer value
  283          // to avoid holes in between tiles
  284          if (scale & 0xffff) scale += (1<<16) / 0x10;
  285  
  286          flipx   =   s[ 0x01 ] & 0x10;
  287          flipy   =   s[ 0x01 ] & 0x08;
  288  
  289          if ( flipx )    {   x0 = nx - 1;    x1 = -1;    dx = -1;    }
  290          else            {   x0 = 0;         x1 = nx;    dx = +1;    }
  291  
  292          if ( flipy )    {   y0 = ny - 1;    y1 = -1;    dy = -1;    }
  293          else            {   y0 = 0;         y1 = ny;    dy = +1;    }
  294  
  295          for (y = y0; y != y1; y += dy)
  296          {
  297              for (x = x0; x != x1; x += dx)
  298              {
  299                  drawgfxzoom_transpen(   bitmap, cliprect, machine.gfx[gfx],
  300                                          code++, color,
  301                                          flipx, flipy,
  302                                          (sx + x * dim) / 0x10000, (sy + y * dim) / 0x10000,
  303                                          scale, scale, 0 );
  304              }
  305          }
  306      }
  307  }
  308  
  309  UINT32 sigmab98_state::screen_update_sigmab98(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
  310  {
  311      int layers_ctrl = -1;
  312  
  313  #ifdef MAME_DEBUG
  314      if (machine().input().code_pressed(KEYCODE_Z))
  315      {
  316          int msk = 0;
  317          if (machine().input().code_pressed(KEYCODE_Q))  msk |= 1;
  318          if (machine().input().code_pressed(KEYCODE_W))  msk |= 2;
  319          if (machine().input().code_pressed(KEYCODE_E))  msk |= 4;
  320          if (machine().input().code_pressed(KEYCODE_R))  msk |= 8;
  321          if (msk != 0) layers_ctrl &= msk;
  322      }
  323  #endif
  324  
  325      bitmap.fill(get_black_pen(machine()), cliprect);
  326  
  327      // Draw from priority 3 (bottom, converted to a bitmask) to priority 0 (top)
  328      draw_sprites(machine(), bitmap, cliprect, layers_ctrl & 8);
  329      draw_sprites(machine(), bitmap, cliprect, layers_ctrl & 4);
  330      draw_sprites(machine(), bitmap, cliprect, layers_ctrl & 2);
  331      draw_sprites(machine(), bitmap, cliprect, layers_ctrl & 1);
  332  
  333      return 0;
  334  }
  335  
  336  
  337  /***************************************************************************
  338  
  339      Memory Maps
  340  
  341  ***************************************************************************/
  342  
  343  
  344  /***************************************************************************
  345                          GeGeGe no Kitarou Youkai Slot
  346  ***************************************************************************/
  347  
  348  // rombank
  349  WRITE8_MEMBER(sigmab98_state::regs_w)
  350  {
  351      if (offset == 0)
  352      {
  353          m_reg = data;
  354          return;
  355      }
  356  
  357      switch ( m_reg )
  358      {
  359          case 0x1f:
  360              m_rombank = data;
  361              if (data >= 0x18)
  362                  logerror("%s: unknown rom bank = %02x\n", machine().describe_context(), data);
  363              else
  364                  membank("rombank")->set_entry(data);
  365              break;
  366  
  367          default:
  368              logerror("%s: unknown reg written: %02x = %02x\n", machine().describe_context(), m_reg, data);
  369      }
  370  }
  371  READ8_MEMBER(sigmab98_state::regs_r)
  372  {
  373      if (offset == 0)
  374          return m_reg;
  375  
  376      switch ( m_reg )
  377      {
  378          case 0x1f:
  379              return m_rombank;
  380  
  381          default:
  382              logerror("%s: unknown reg read: %02x\n", machine().describe_context(), m_reg);
  383              return 0x00;
  384      }
  385  }
  386  
  387  // rambank
  388  WRITE8_MEMBER(sigmab98_state::regs2_w)
  389  {
  390      if (offset == 0)
  391      {
  392          m_reg2 = data;
  393          return;
  394      }
  395  
  396      switch ( m_reg2 )
  397      {
  398          case 0xb5:
  399              m_rambank = data;
  400              switch (data)
  401              {
  402                  case 0x32:
  403                      membank("rambank")->set_entry(0);
  404                      break;
  405                  case 0x36:
  406                      membank("rambank")->set_entry(1);
  407                      break;
  408                  default:
  409                      logerror("%s: unknown ram bank = %02x\n", machine().describe_context(), data);
  410              }
  411              break;
  412  
  413          default:
  414              logerror("%s: unknown reg2 written: %02x = %02x\n", machine().describe_context(), m_reg2, data);
  415      }
  416  }
  417  READ8_MEMBER(sigmab98_state::regs2_r)
  418  {
  419      if (offset == 0)
  420          return m_reg2;
  421  
  422      switch ( m_reg2 )
  423      {
  424          case 0xb5:
  425              return m_rambank;
  426  
  427          default:
  428              logerror("%s: unknown reg2 read: %02x\n", machine().describe_context(), m_reg2);
  429              return 0x00;
  430      }
  431  }
  432  
  433  
  434  // Outputs
  435  
  436  void sigmab98_state::show_outputs()
  437  {
  438  #ifdef MAME_DEBUG
  439  //  popmessage("0: %02X  4: %02X  6: %02X  8: %02X",m_c0,m_c4,m_c6,m_c8);
  440  #endif
  441  }
  442  
  443  // Port c0
  444  WRITE8_MEMBER(sigmab98_state::eeprom_w)
  445  {
  446      device_t *device = machine().device("eeprom");
  447      // latch the bit
  448      eeprom_device *eeprom = downcast<eeprom_device *>(device);
  449      eeprom->write_bit(data & 0x40);
  450  
  451      // reset line asserted: reset.
  452  //  if ((m_c0 ^ data) & 0x20)
  453          eeprom->set_cs_line((data & 0x20) ? CLEAR_LINE : ASSERT_LINE);
  454  
  455      // clock line asserted: write latch or select next bit to read
  456      eeprom->set_clock_line((data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
  457  
  458      m_c0 = data;
  459      //show_outputs(state);
  460  }
  461  
  462  // Port c4
  463  // 10 led?
  464  WRITE8_MEMBER(sigmab98_state::c4_w)
  465  {
  466      set_led_status(machine(), 0, (data & 0x10));
  467  
  468      m_c4 = data;
  469      show_outputs();
  470  }
  471  
  472  // Port c6
  473  // 03 lockout (active low, 02 is cleared when reaching 99 credits)
  474  // 04 pulsed on coin in
  475  // 08 always blinks
  476  // 10 led?
  477  // 20 blinks after coin up
  478  WRITE8_MEMBER(sigmab98_state::c6_w)
  479  {
  480      coin_lockout_w(machine(), 0, (~data) & 0x02);
  481  
  482      coin_counter_w(machine(), 0,   data  & 0x04);
  483  
  484      set_led_status(machine(), 1,   data  & 0x08);
  485      set_led_status(machine(), 2,   data  & 0x10);
  486      set_led_status(machine(), 3,   data  & 0x20);   //
  487  
  488      m_c6 = data;
  489      show_outputs();
  490  }
  491  
  492  // Port c8
  493  // 01 hopper enable?
  494  // 02 hopper motor on (active low)?
  495  WRITE8_MEMBER(sigmab98_state::c8_w)
  496  {
  497      machine().device<ticket_dispenser_device>("hopper")->write(space, 0, (!(data & 0x02) && (data & 0x01)) ? 0x00 : 0x80);
  498  
  499      m_c8 = data;
  500      show_outputs();
  501  }
  502  
  503  static ADDRESS_MAP_START( gegege_mem_map, AS_PROGRAM, 8, sigmab98_state )
  504      AM_RANGE( 0x0000, 0x7fff ) AM_ROM
  505      AM_RANGE( 0x8000, 0x9fff ) AM_ROMBANK("rombank")
  506  
  507      AM_RANGE( 0xa000, 0xafff ) AM_RAM AM_SHARE("spriteram")
  508  
  509      AM_RANGE( 0xc000, 0xc1ff ) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_byte_be_w) AM_SHARE("paletteram")
  510  
  511      AM_RANGE( 0xc800, 0xc87f ) AM_RAM
  512  
  513  //  AM_RANGE( 0xd001, 0xd021 ) AM_RAM
  514      AM_RANGE( 0xd800, 0xdfff ) AM_RAMBANK("rambank")
  515  
  516      AM_RANGE( 0xe000, 0xefff ) AM_RAM AM_SHARE("nvram") // battery
  517  
  518      AM_RANGE( 0xf000, 0xffff ) AM_RAM
  519  ADDRESS_MAP_END
  520  
  521  static ADDRESS_MAP_START( gegege_io_map, AS_IO, 8, sigmab98_state )
  522      ADDRESS_MAP_GLOBAL_MASK(0xff)
  523  
  524      AM_RANGE( 0x00, 0x01 ) AM_DEVWRITE_LEGACY("ymz", ymz280b_w )
  525  
  526      AM_RANGE( 0xa0, 0xa1 ) AM_READWRITE(regs_r,  regs_w )
  527  //  AM_RANGE( 0xa2, 0xa3 )
  528      AM_RANGE( 0xa4, 0xa5 ) AM_READWRITE(regs2_r, regs2_w )
  529  
  530      AM_RANGE( 0xc0, 0xc0 ) AM_READ_PORT( "EEPROM" )
  531      AM_RANGE( 0xc0, 0xc0 ) AM_WRITE(eeprom_w)
  532  
  533      AM_RANGE( 0xc2, 0xc2 ) AM_READ_PORT( "IN1" )
  534  
  535      AM_RANGE( 0xc4, 0xc4 ) AM_READ_PORT( "IN2" )
  536      AM_RANGE( 0xc4, 0xc4 ) AM_WRITE(c4_w )
  537  
  538      AM_RANGE( 0xc6, 0xc6 ) AM_WRITE(c6_w )
  539  
  540      AM_RANGE( 0xc8, 0xc8 ) AM_WRITE(c8_w )
  541  
  542      AM_RANGE( 0xe5, 0xe5 ) AM_READNOP   // during irq
  543  ADDRESS_MAP_END
  544  
  545  
  546  /***************************************************************************
  547                                   Animal Catch
  548  ***************************************************************************/
  549  
  550  // rombank
  551  WRITE8_MEMBER(sigmab98_state::animalc_rombank_w)
  552  {
  553      if (offset == 0)
  554      {
  555          m_reg = data;
  556          return;
  557      }
  558  
  559      UINT8 *rom = memregion("maincpu")->base();
  560      switch ( m_reg )
  561      {
  562          case 0x0f:
  563              m_rombank = data;
  564              switch (data)
  565              {
  566                  case 0x10:  membank("rombank")->set_base(rom + 0x400 + 0x4000); break;
  567                  case 0x14:  membank("rombank")->set_base(rom + 0x400 + 0x8000); break;
  568                  case 0x18:  membank("rombank")->set_base(rom + 0x400 + 0xc000); break;
  569                  default:
  570                      logerror("%s: unknown rom bank = %02x, reg = %02x\n", machine().describe_context(), data, m_reg);
  571              }
  572              break;
  573  
  574          default:
  575              logerror("%s: unknown reg written: %02x = %02x\n", machine().describe_context(), m_reg, data);
  576      }
  577  }
  578  READ8_MEMBER(sigmab98_state::animalc_rombank_r)
  579  {
  580      if (offset == 0)
  581          return m_reg;
  582  
  583      switch ( m_reg )
  584      {
  585          case 0x0f:
  586              return m_rombank;
  587  
  588          default:
  589              logerror("%s: unknown reg read: %02x\n", machine().describe_context(), m_reg);
  590              return 0x00;
  591      }
  592  }
  593  
  594  // rambank
  595  WRITE8_MEMBER(sigmab98_state::animalc_rambank_w)
  596  {
  597      if (offset == 0)
  598      {
  599          m_reg2 = data;
  600          return;
  601      }
  602  
  603      int bank = 0;
  604      switch ( m_reg2 )
  605      {
  606          case 0x1f:
  607              m_rambank = data;
  608              switch (data)
  609              {
  610                  case 0x58:  bank = 0;   break;
  611                  case 0x62:  bank = 1;   break;
  612                  case 0x63:  bank = 2;   break;
  613                  case 0x64:  bank = 3;   break;
  614                  case 0x65:  bank = 4;   break;
  615                  default:
  616                      logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", machine().describe_context(), data, m_reg2);
  617                      return;
  618              }
  619              membank("rambank")->set_entry(bank);
  620              if ( (bank == 1) || (bank == 2) || (bank == 3) )
  621                  membank("sprbank")->set_entry(bank-1);
  622              break;
  623  
  624          default:
  625              logerror("%s: unknown reg2 written: %02x = %02x\n", machine().describe_context(), m_reg2, data);
  626      }
  627  }
  628  READ8_MEMBER(sigmab98_state::animalc_rambank_r)
  629  {
  630      if (offset == 0)
  631          return m_reg2;
  632  
  633      switch ( m_reg2 )
  634      {
  635          case 0x1f:
  636              return m_rambank;
  637  
  638          default:
  639              logerror("%s: unknown reg2 read: %02x\n", machine().describe_context(), m_reg2);
  640              return 0x00;
  641      }
  642  }
  643  
  644  
  645  READ8_MEMBER(sigmab98_state::sammymdl_eeprom_r)
  646  {
  647      device_t *device = machine().device("eeprom");
  648      eeprom_device *eeprom = downcast<eeprom_device *>(device);
  649      return eeprom->read_bit() ? 0x80 : 0;
  650  }
  651  
  652  WRITE8_MEMBER(sigmab98_state::sammymdl_eeprom_w)
  653  {
  654      device_t *device = machine().device("eeprom");
  655      // latch the bit
  656      eeprom_device *eeprom = downcast<eeprom_device *>(device);
  657      eeprom->write_bit(data & 0x40);
  658  
  659      // reset line asserted: reset.
  660      eeprom->set_cs_line((data & 0x20) ? CLEAR_LINE : ASSERT_LINE);
  661  
  662      // clock line asserted: write latch or select next bit to read
  663      eeprom->set_clock_line((data & 0x10) ? ASSERT_LINE : CLEAR_LINE);
  664  
  665      if (data & 0x8f)
  666          logerror("%s: unknown eeeprom bits written %02x\n", machine().describe_context(), data);
  667  }
  668  
  669  READ8_MEMBER(sigmab98_state::unk_34_r)
  670  {
  671      // mask 0x01?
  672      return 0x01;
  673  }
  674  
  675  READ8_MEMBER(sigmab98_state::vblank_r)
  676  {
  677      // mask 0x04 must be set before writing sprite list
  678      // mask 0x10 must be set or irq/00 hangs?
  679      return  m_vblank | 0x14;
  680  }
  681  
  682  WRITE8_MEMBER(sigmab98_state::vblank_w)
  683  {
  684      m_vblank = (m_vblank & ~0x03) | (data & 0x03);
  685  }
  686  
  687  void sigmab98_state::screen_eof_sammymdl(screen_device &screen, bool state)
  688  {
  689      // rising edge
  690      if (state)
  691      {
  692          m_vblank &= ~0x01;
  693      }
  694  }
  695  
  696  void sigmab98_state::show_3_outputs()
  697  {
  698  #ifdef MAME_DEBUG
  699  //  popmessage("COIN: %02X  LED: %02X  HOP: %02X", m_out[0], m_out[1], m_out[2]);
  700  #endif
  701  }
  702  // Port 31
  703  WRITE8_MEMBER(sigmab98_state::sammymdl_coin_w)
  704  {
  705      coin_counter_w(machine(), 0,   data  & 0x01 );  // coin1 in
  706      coin_counter_w(machine(), 1,   data  & 0x02 );  // coin2 in
  707      coin_counter_w(machine(), 2,   data  & 0x04 );  // medal in
  708  
  709  //  coin_lockout_w(machine(), 1, (~data) & 0x08 ); // coin2 lockout?
  710  //  coin_lockout_w(machine(), 0, (~data) & 0x10 ); // coin1 lockout
  711  //  coin_lockout_w(machine(), 2, (~data) & 0x20 ); // medal lockout?
  712  
  713      m_out[0] = data;
  714      show_3_outputs();
  715  }
  716  
  717  // Port 32
  718  WRITE8_MEMBER(sigmab98_state::sammymdl_leds_w)
  719  {
  720      set_led_status(machine(), 0,    data & 0x01);   // button
  721  
  722      m_out[1] = data;
  723      show_3_outputs();
  724  }
  725  
  726  // Port b0
  727  // 02 hopper enable?
  728  // 01 hopper motor on (active low)?
  729  WRITE8_MEMBER(sigmab98_state::sammymdl_hopper_w)
  730  {
  731      machine().device<ticket_dispenser_device>("hopper")->write(space, 0, (!(data & 0x01) && (data & 0x02)) ? 0x00 : 0x80);
  732  
  733      m_out[2] = data;
  734      show_3_outputs();
  735  }
  736  
  737  READ8_MEMBER(sigmab98_state::sammymdl_coin_hopper_r)
  738  {
  739      UINT8 ret = ioport("COIN")->read();
  740  
  741  //  if ( !machine().device<ticket_dispenser_device>("hopper")->read(0) )
  742  //      ret &= ~0x01;
  743  
  744      return ret;
  745  }
  746  
  747  static ADDRESS_MAP_START( animalc_map, AS_PROGRAM, 8, sigmab98_state )
  748      AM_RANGE( 0x0000, 0x3fff ) AM_ROM
  749      AM_RANGE( 0x4000, 0x7fff ) AM_ROMBANK( "rombank" )
  750      AM_RANGE( 0x8000, 0x8fff ) AM_RAMBANK( "rambank" ) AM_SHARE( "nvram" )
  751  
  752      AM_RANGE( 0x9000, 0x9fff ) AM_RAM
  753      AM_RANGE( 0xa000, 0xafff ) AM_RAM
  754      AM_RANGE( 0xb000, 0xbfff ) AM_RAMBANK("sprbank")
  755  
  756      AM_RANGE( 0xd000, 0xd1ff ) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_byte_be_w ) AM_SHARE("paletteram")
  757      AM_RANGE( 0xd800, 0xd87f ) AM_RAM   // table?
  758  
  759      AM_RANGE( 0xe011, 0xe011 ) AM_WRITENOP  // IRQ Enable? Screen disable?
  760      AM_RANGE( 0xe013, 0xe013 ) AM_READWRITE(vblank_r, vblank_w )    // IRQ Ack?
  761  
  762      AM_RANGE( 0xfe00, 0xffff ) AM_RAM   // High speed internal RAM
  763  ADDRESS_MAP_END
  764  
  765  static ADDRESS_MAP_START( animalc_io, AS_IO, 8, sigmab98_state )
  766      ADDRESS_MAP_GLOBAL_MASK(0xff)
  767      AM_RANGE( 0x02, 0x03 ) AM_READWRITE(animalc_rombank_r, animalc_rombank_w )
  768      AM_RANGE( 0x04, 0x05 ) AM_READWRITE(animalc_rambank_r, animalc_rambank_w )
  769  
  770      AM_RANGE( 0x2c, 0x2c ) AM_READWRITE(sammymdl_eeprom_r, sammymdl_eeprom_w )
  771      AM_RANGE( 0x2e, 0x2e ) AM_READ(sammymdl_coin_hopper_r )
  772      AM_RANGE( 0x30, 0x30 ) AM_READ_PORT( "BUTTON" )
  773      AM_RANGE( 0x31, 0x31 ) AM_WRITE(sammymdl_coin_w )
  774      AM_RANGE( 0x32, 0x32 ) AM_WRITE(sammymdl_leds_w )
  775      AM_RANGE( 0x34, 0x34 ) AM_READ(unk_34_r )
  776      AM_RANGE( 0x90, 0x90 ) AM_DEVWRITE("oki", okim9810_device, write )
  777      AM_RANGE( 0x91, 0x91 ) AM_DEVWRITE("oki", okim9810_device, write_TMP_register )
  778      AM_RANGE( 0x92, 0x92 ) AM_DEVREAD("oki", okim9810_device, read )
  779      AM_RANGE( 0xb0, 0xb0 ) AM_WRITE(sammymdl_hopper_w )
  780      AM_RANGE( 0xc0, 0xc0 ) AM_WRITE(watchdog_reset_w )  // 1
  781  ADDRESS_MAP_END
  782  
  783  /***************************************************************************
  784                               Hae Hae Ka Ka Ka
  785  ***************************************************************************/
  786  
  787  // rombank
  788  WRITE8_MEMBER(sigmab98_state::haekaka_rombank_w)
  789  {
  790      if (offset == 0)
  791      {
  792          m_reg = data;
  793          return;
  794      }
  795  
  796      switch ( m_reg )
  797      {
  798          case 0x2b:
  799              m_rombank = data;
  800              switch (data)
  801              {
  802                  case 0x10:  // ROM
  803                  case 0x11:
  804                  case 0x12:
  805                  case 0x13:
  806                  case 0x14:
  807                  case 0x15:
  808                  case 0x16:
  809                  case 0x17:
  810                  case 0x18:
  811                  case 0x19:
  812                  case 0x1a:
  813                  case 0x1b:
  814                  case 0x1c:
  815                  case 0x1d:
  816                  case 0x1e:
  817                  case 0x1f:
  818  
  819                  case 0x65:  // SPRITERAM
  820                  case 0x67:  // PALETTE RAM + TABLE + REGS
  821                      break;
  822  
  823                  default:
  824                      logerror("%s: unknown rom bank = %02x, reg = %02x\n", machine().describe_context(), data, m_reg);
  825              }
  826              break;
  827  
  828          default:
  829              logerror("%s: unknown reg written: %02x = %02x\n", machine().describe_context(), m_reg, data);
  830      }
  831  }
  832  READ8_MEMBER(sigmab98_state::haekaka_rombank_r)
  833  {
  834      if (offset == 0)
  835          return m_reg;
  836  
  837      switch ( m_reg )
  838      {
  839          case 0x2b:
  840              return m_rombank;
  841  
  842          default:
  843              logerror("%s: unknown reg read: %02x\n", machine().describe_context(), m_reg);
  844              return 0x00;
  845      }
  846  }
  847  
  848  // rambank
  849  WRITE8_MEMBER(sigmab98_state::haekaka_rambank_w)
  850  {
  851      if (offset == 0)
  852      {
  853          m_reg2 = data;
  854          return;
  855      }
  856  
  857      switch ( m_reg2 )
  858      {
  859          case 0x33:
  860              m_rambank = data;
  861              switch (data)
  862              {
  863                  case 0x53:
  864                      break;
  865  
  866                  default:
  867                      logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", machine().describe_context(), data, m_reg2);
  868              }
  869              break;
  870  
  871          default:
  872              logerror("%s: unknown reg2 written: %02x = %02x\n", machine().describe_context(), m_reg2, data);
  873      }
  874  }
  875  READ8_MEMBER(sigmab98_state::haekaka_rambank_r)
  876  {
  877      if (offset == 0)
  878          return m_reg2;
  879  
  880      switch ( m_reg2 )
  881      {
  882          case 0x33:
  883              return m_rambank;
  884  
  885          default:
  886              logerror("%s: unknown reg2 read: %02x\n", machine().describe_context(), m_reg2);
  887              return 0x00;
  888      }
  889  }
  890  
  891  READ8_MEMBER(sigmab98_state::haekaka_vblank_r)
  892  {
  893      return machine().primary_screen->vblank() ? 0 : 0x1c;
  894  }
  895  
  896  READ8_MEMBER(sigmab98_state::haekaka_b000_r)
  897  {
  898      switch (m_rombank)
  899      {
  900          case 0x10:  // ROM
  901          case 0x11:
  902          case 0x12:
  903          case 0x13:
  904          case 0x14:
  905          case 0x15:
  906          case 0x16:
  907          case 0x17:
  908          case 0x18:
  909          case 0x19:
  910          case 0x1a:
  911          case 0x1b:
  912          case 0x1c:
  913          case 0x1d:
  914          case 0x1e:
  915          case 0x1f:
  916              return memregion("maincpu")->base()[offset + 0xb400 + 0x1000 * (m_rombank-0x10)];
  917  
  918          case 0x65:  // SPRITERAM
  919              if (offset < 0x1000)
  920                  return m_spriteram[offset];
  921  
  922          case 0x67:  // PALETTERAM + TABLE? + REGS
  923              if (offset < 0x200)
  924                  return m_generic_paletteram_8[offset];
  925              else if (offset == (0xc013-0xb000))
  926                  return haekaka_vblank_r(space, offset);
  927              break;
  928      }
  929  
  930      logerror("%s: unknown read from %02x with rombank = %02x\n", machine().describe_context(), offset+0xb000, m_rombank);
  931      return 0x00;
  932  }
  933  
  934  WRITE8_MEMBER(sigmab98_state::haekaka_b000_w)
  935  {
  936      switch (m_rombank)
  937      {
  938          case 0x65:  // SPRITERAM
  939              if (offset < 0x1000)
  940              {
  941                  m_spriteram[offset] = data;
  942                  return;
  943              }
  944              break;
  945  
  946          case 0x67:  // PALETTERAM + TABLE? + REGS
  947              if (offset < 0x200)
  948              {
  949                  paletteram_xRRRRRGGGGGBBBBB_byte_be_w(space, offset, data);
  950  //              m_generic_paletteram_8[offset] = data;
  951                  return;
  952              }
  953              else if ((offset >= 0x800) && (offset < 0x880))
  954              {
  955                  // table?
  956                  return;
  957              }
  958              break;
  959      }
  960  
  961      logerror("%s: unknown write to %02x = %02x with rombank = %02x\n", machine().describe_context(), offset+0xb000, data, m_rombank);
  962  }
  963  
  964  WRITE8_MEMBER(sigmab98_state::haekaka_leds_w)
  965  {
  966      // All used
  967      set_led_status(machine(), 0,    data & 0x01);
  968      set_led_status(machine(), 1,    data & 0x02);
  969      set_led_status(machine(), 2,    data & 0x04);
  970      set_led_status(machine(), 3,    data & 0x08);
  971      set_led_status(machine(), 4,    data & 0x10);
  972      set_led_status(machine(), 5,    data & 0x20);
  973      set_led_status(machine(), 6,    data & 0x40);
  974      set_led_status(machine(), 7,    data & 0x80);
  975  
  976      m_out[1] = data;
  977      show_3_outputs();
  978  }
  979  
  980  WRITE8_MEMBER(sigmab98_state::haekaka_coin_w)
  981  {
  982      coin_counter_w(machine(), 0,   data & 0x01 );   // medal out
  983  //                                      data & 0x02 ?
  984  //                                      data & 0x04 ?
  985  //                                      data & 0x10 ?
  986  
  987      m_out[0] = data;
  988      show_3_outputs();
  989  }
  990  
  991  static ADDRESS_MAP_START( haekaka_map, AS_PROGRAM, 8, sigmab98_state )
  992      AM_RANGE( 0x0000, 0x7fff ) AM_ROM
  993      AM_RANGE( 0xb000, 0xcfff ) AM_READWRITE(haekaka_b000_r, haekaka_b000_w )
  994      AM_RANGE( 0xd000, 0xefff ) AM_RAM AM_SHARE( "nvram" )
  995      AM_RANGE( 0xfe00, 0xffff ) AM_RAM   // High speed internal RAM
  996  ADDRESS_MAP_END
  997  
  998  static ADDRESS_MAP_START( haekaka_io, AS_IO, 8, sigmab98_state )
  999      ADDRESS_MAP_GLOBAL_MASK(0xff)
 1000      AM_RANGE( 0x02, 0x03 ) AM_READWRITE(haekaka_rombank_r, haekaka_rombank_w )
 1001      AM_RANGE( 0x04, 0x05 ) AM_READWRITE(haekaka_rambank_r, haekaka_rambank_w )
 1002  
 1003      AM_RANGE( 0x2c, 0x2c ) AM_READWRITE(sammymdl_eeprom_r, sammymdl_eeprom_w )
 1004      AM_RANGE( 0x2e, 0x2e ) AM_READ(sammymdl_coin_hopper_r )
 1005      AM_RANGE( 0x30, 0x30 ) AM_READ_PORT( "BUTTON" )
 1006      AM_RANGE( 0x31, 0x31 ) AM_WRITE(haekaka_coin_w )
 1007      AM_RANGE( 0x32, 0x32 ) AM_WRITE(haekaka_leds_w )
 1008      AM_RANGE( 0x90, 0x90 ) AM_DEVWRITE("oki", okim9810_device, write )
 1009      AM_RANGE( 0x91, 0x91 ) AM_DEVWRITE("oki", okim9810_device, write_TMP_register )
 1010      AM_RANGE( 0x92, 0x92 ) AM_DEVREAD("oki", okim9810_device, read )
 1011      AM_RANGE( 0xb0, 0xb0 ) AM_WRITE(sammymdl_hopper_w )
 1012      AM_RANGE( 0xc0, 0xc0 ) AM_WRITE(watchdog_reset_w )  // 1
 1013  ADDRESS_MAP_END
 1014  
 1015  /***************************************************************************
 1016                                Itazura Monkey
 1017  ***************************************************************************/
 1018  
 1019  // rombank
 1020  WRITE8_MEMBER(sigmab98_state::itazuram_rombank_w)
 1021  {
 1022      if (offset == 0)
 1023      {
 1024          m_reg = data;
 1025          return;
 1026      }
 1027  
 1028      UINT8 *rom = memregion("maincpu")->base();
 1029      switch ( m_reg )
 1030      {
 1031          case 0x0d:
 1032              m_rombank = data;
 1033              switch (data)
 1034              {
 1035                  case 0x11:  // 3800 IS ROM
 1036                      membank("rombank0")->set_base(rom + 0x4c00);
 1037                      membank("rombank1")->set_base(rom + 0x5c00);
 1038                      membank("sprbank0")->set_base(m_spriteram + 0x1000*4);  // scratch
 1039                      membank("sprbank1")->set_base(m_spriteram + 0x1000*4);  // scratch
 1040                      break;
 1041  
 1042                  default:
 1043                      logerror("%s: unknown rom bank = %02x, reg = %02x\n", machine().describe_context(), data, m_reg);
 1044              }
 1045              break;
 1046  
 1047          case 0x4d:
 1048              m_rombank = data;
 1049              switch (data)
 1050              {
 1051                  case 0x14:  // 3800 IS ROM
 1052                      membank("rombank0")->set_base(rom + 0x8000);
 1053                      membank("rombank1")->set_base(rom + 0x9000);
 1054                      membank("sprbank0")->set_base(m_spriteram + 0x1000*4);  // scratch
 1055                      membank("sprbank1")->set_base(m_spriteram + 0x1000*4);  // scratch
 1056                      break;
 1057  
 1058                  default:
 1059                      logerror("%s: unknown rom bank = %02x, reg = %02x\n", machine().describe_context(), data, m_reg);
 1060              }
 1061              break;
 1062  
 1063          case 0x8d:
 1064              m_rombank = data;
 1065              switch (data)
 1066              {
 1067                  case 0x0f:  // 3800 IS ROM
 1068                      membank("rombank0")->set_base(rom + 0x3400);
 1069                      membank("rombank1")->set_base(rom + 0x4400);
 1070                      membank("sprbank0")->set_base(m_spriteram + 0x1000*4);  // scratch
 1071                      membank("sprbank1")->set_base(m_spriteram + 0x1000*4);  // scratch
 1072                      break;
 1073  
 1074                  case 0x12:  // 3800 IS ROM
 1075                      membank("rombank0")->set_base(rom + 0x6400);
 1076                      membank("rombank1")->set_base(rom + 0x7400);
 1077                      membank("sprbank0")->set_base(m_spriteram + 0x1000*4);  // scratch
 1078                      membank("sprbank1")->set_base(m_spriteram + 0x1000*4);  // scratch
 1079                      break;
 1080  
 1081                  // used in test mode:
 1082  //              case 0x5c:  membank("rombank")->set_base(rom + 0x400 + 0x0000);    break;  // 3800 IS RAM! (8000 bytes)
 1083  
 1084                  case 0x5e:  // 3800 IS RAM! (1404 bytes)
 1085                      membank("rombank0")->set_base(m_spriteram + 0x1000*1);
 1086                      membank("sprbank0")->set_base(m_spriteram + 0x1000*1);
 1087                      membank("rombank1")->set_base(m_spriteram + 0x1000*2);
 1088                      membank("sprbank1")->set_base(m_spriteram + 0x1000*2);
 1089                      break;
 1090  
 1091                  case 0x6c:  // 3800 IS RAM! (1000 bytes) - SPRITERAM
 1092                      membank("rombank0")->set_base(m_spriteram);
 1093                      membank("sprbank0")->set_base(m_spriteram);
 1094  //                  membank("sprbank1")->set_base(m_spriteram + 0x1000*4);    // scratch
 1095                      break;
 1096  
 1097                  default:
 1098                      logerror("%s: unknown rom bank = %02x, reg = %02x\n", machine().describe_context(), data, m_reg);
 1099              }
 1100              break;
 1101  
 1102          case 0xcd:
 1103              m_rombank = data;
 1104              switch (data)
 1105              {
 1106                  case 0x14:  // 3800 IS ROM
 1107                      membank("rombank0")->set_base(rom + 0x8800);
 1108                      membank("rombank1")->set_base(rom + 0x9800);
 1109                      membank("sprbank0")->set_base(m_spriteram + 0x1000*4);  // scratch
 1110                      membank("sprbank1")->set_base(m_spriteram + 0x1000*4);  // scratch
 1111                      break;
 1112  
 1113                  default:
 1114                      logerror("%s: unknown rom bank = %02x, reg = %02x\n", machine().describe_context(), data, m_reg);
 1115              }
 1116              break;
 1117  
 1118          default:
 1119              logerror("%s: unknown reg written: %02x = %02x\n", machine().describe_context(), m_reg, data);
 1120      }
 1121  }
 1122  READ8_MEMBER(sigmab98_state::itazuram_rombank_r)
 1123  {
 1124      if (offset == 0)
 1125          return m_reg;
 1126  
 1127      switch ( m_reg )
 1128      {
 1129          // FIXME different registers
 1130          case 0x0d:
 1131          case 0x4d:
 1132          case 0x8d:
 1133          case 0xcd:
 1134              return m_rombank;
 1135  
 1136          default:
 1137              logerror("%s: unknown reg read: %02x\n", machine().describe_context(), m_reg);
 1138              return 0x00;
 1139      }
 1140  }
 1141  
 1142  // rambank
 1143  WRITE8_MEMBER(sigmab98_state::itazuram_rambank_w)
 1144  {
 1145      if (offset == 0)
 1146      {
 1147          m_reg2 = data;
 1148          return;
 1149      }
 1150  
 1151      switch ( m_reg2 )
 1152      {
 1153          case 0x76:
 1154              m_rambank = data;
 1155              switch (data)
 1156              {
 1157                  case 0x52:  membank("palbank")->set_base(m_nvram);                                  break;
 1158                  case 0x64:  membank("palbank")->set_base(m_generic_paletteram_8);   break;
 1159                  default:
 1160                      logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", machine().describe_context(), data, m_reg2);
 1161                      return;
 1162              }
 1163              break;
 1164  
 1165          default:
 1166              logerror("%s: unknown reg2 written: %02x = %02x\n", machine().describe_context(), m_reg2, data);
 1167      }
 1168  }
 1169  
 1170  READ8_MEMBER(sigmab98_state::itazuram_rambank_r)
 1171  {
 1172      if (offset == 0)
 1173          return m_reg2;
 1174  
 1175      switch ( m_reg2 )
 1176      {
 1177          case 0x76:
 1178              return m_rambank;
 1179  
 1180          default:
 1181              logerror("%s: unknown reg2 read: %02x\n", machine().describe_context(), m_reg2);
 1182              return 0x00;
 1183      }
 1184  }
 1185  
 1186  WRITE8_MEMBER(sigmab98_state::itazuram_nvram_palette_w)
 1187  {
 1188      if (m_rambank == 0x64)
 1189      {
 1190          paletteram_xRRRRRGGGGGBBBBB_byte_be_w(space, offset, data);
 1191  //      m_generic_paletteram_8[offset] = data;
 1192      }
 1193      else if (m_rambank == 0x52)
 1194      {
 1195          m_nvram[offset] = data;
 1196      }
 1197      else
 1198      {
 1199          logerror("%s: itazuram_nvram_palette_w offset = %03x with unknown bank = %02x\n", machine().describe_context(), offset, m_rambank);
 1200      }
 1201  }
 1202  
 1203  WRITE8_MEMBER(sigmab98_state::itazuram_palette_w)
 1204  {
 1205      if (m_rombank == 0x6c)
 1206      {
 1207          if (offset < 0x200)
 1208              paletteram_xRRRRRGGGGGBBBBB_byte_be_w(space, offset, data);
 1209  //          m_generic_paletteram_8[offset] = data;
 1210      }
 1211      else
 1212      {
 1213          logerror("%s: itazuram_palette_w offset = %03x with unknown bank = %02x\n", machine().describe_context(), offset, m_rombank);
 1214      }
 1215  }
 1216  
 1217  READ8_MEMBER(sigmab98_state::itazuram_palette_r)
 1218  {
 1219      return m_generic_paletteram_8[offset];
 1220  }
 1221  
 1222  static ADDRESS_MAP_START( itazuram_map, AS_PROGRAM, 8, sigmab98_state )
 1223      AM_RANGE( 0x0000, 0x37ff ) AM_ROM
 1224      AM_RANGE( 0x3800, 0x47ff ) AM_READ_BANK( "rombank0" ) AM_WRITE_BANK( "sprbank0" )
 1225      AM_RANGE( 0x4800, 0x57ff ) AM_READ_BANK( "rombank1" ) AM_WRITE_BANK( "sprbank1" )
 1226  
 1227      AM_RANGE( 0x5800, 0x59ff ) AM_READWRITE(itazuram_palette_r, itazuram_palette_w )
 1228      AM_RANGE( 0x6000, 0x607f ) AM_RAM   // table?
 1229  
 1230      AM_RANGE( 0x6811, 0x6811 ) AM_WRITENOP  // IRQ Enable? Screen disable?
 1231      AM_RANGE( 0x6813, 0x6813 ) AM_WRITENOP  // IRQ Ack?
 1232      AM_RANGE( 0xdc00, 0xfdff ) AM_READ_BANK( "palbank" ) AM_WRITE(itazuram_nvram_palette_w ) AM_SHARE( "nvram" )    // nvram | paletteram
 1233  
 1234      AM_RANGE( 0xfe00, 0xffff ) AM_RAM   // High speed internal RAM
 1235  ADDRESS_MAP_END
 1236  
 1237  static ADDRESS_MAP_START( itazuram_io, AS_IO, 8, sigmab98_state )
 1238      ADDRESS_MAP_GLOBAL_MASK(0xff)
 1239      AM_RANGE( 0x02, 0x03 ) AM_READWRITE(itazuram_rombank_r, itazuram_rombank_w )
 1240      AM_RANGE( 0x04, 0x05 ) AM_READWRITE(itazuram_rambank_r, itazuram_rambank_w )
 1241  
 1242      AM_RANGE( 0x2c, 0x2c ) AM_READWRITE(sammymdl_eeprom_r, sammymdl_eeprom_w )
 1243      AM_RANGE( 0x2e, 0x2e ) AM_READ(sammymdl_coin_hopper_r )
 1244      AM_RANGE( 0x30, 0x30 ) AM_READ_PORT( "BUTTON" )
 1245      AM_RANGE( 0x31, 0x31 ) AM_WRITE(sammymdl_coin_w )
 1246      AM_RANGE( 0x32, 0x32 ) AM_WRITE(sammymdl_leds_w )
 1247      AM_RANGE( 0x90, 0x90 ) AM_DEVWRITE("oki", okim9810_device, write )
 1248      AM_RANGE( 0x91, 0x91 ) AM_DEVWRITE("oki", okim9810_device, write_TMP_register )
 1249      AM_RANGE( 0x92, 0x92 ) AM_DEVREAD("oki", okim9810_device, read )
 1250      AM_RANGE( 0xb0, 0xb0 ) AM_WRITE(sammymdl_hopper_w )
 1251      AM_RANGE( 0xc0, 0xc0 ) AM_WRITE(watchdog_reset_w )  // 1
 1252  ADDRESS_MAP_END
 1253  
 1254  /***************************************************************************
 1255                               Pye-nage Taikai
 1256  ***************************************************************************/
 1257  
 1258  static ADDRESS_MAP_START( pyenaget_io, AS_IO, 8, sigmab98_state )
 1259      AM_RANGE( 0x31, 0x31 ) AM_WRITE(sammymdl_coin_w )
 1260      AM_IMPORT_FROM( haekaka_io )
 1261  ADDRESS_MAP_END
 1262  
 1263  /***************************************************************************
 1264                               Taihou de Doboon
 1265  ***************************************************************************/
 1266  
 1267  // rombank
 1268  WRITE8_MEMBER(sigmab98_state::tdoboon_rombank_w)
 1269  {
 1270      if (offset == 0)
 1271      {
 1272          m_reg = data;
 1273          return;
 1274      }
 1275  
 1276      switch ( m_reg )
 1277      {
 1278          case 0x2f:
 1279              m_rombank = data;
 1280              switch (data)
 1281              {
 1282                  case 0x10:  // ROM
 1283                  case 0x11:
 1284                  case 0x12:
 1285                  case 0x13:
 1286                  case 0x14:
 1287                  case 0x15:
 1288                  case 0x16:
 1289                  case 0x17:
 1290                  case 0x18:
 1291                  case 0x19:
 1292                  case 0x1a:
 1293                  case 0x1b:
 1294                  case 0x1c:
 1295                  case 0x1d:
 1296                  case 0x1e:
 1297                  case 0x1f:
 1298  
 1299                  case 0x64:  // SPRITERAM
 1300                  case 0x66:  // PALETTE RAM + TABLE
 1301                  case 0x67:  // REGS
 1302                      break;
 1303  
 1304                  default:
 1305                      logerror("%s: unknown rom bank = %02x, reg = %02x\n", machine().describe_context(), data, m_reg);
 1306              }
 1307              break;
 1308  
 1309          default:
 1310              logerror("%s: unknown reg written: %02x = %02x\n", machine().describe_context(), m_reg, data);
 1311      }
 1312  }
 1313  READ8_MEMBER(sigmab98_state::tdoboon_rombank_r)
 1314  {
 1315      if (offset == 0)
 1316          return m_reg;
 1317  
 1318      switch ( m_reg )
 1319      {
 1320          case 0x2f:
 1321              return m_rombank;
 1322  
 1323          default:
 1324              logerror("%s: unknown reg read: %02x\n", machine().describe_context(), m_reg);
 1325              return 0x00;
 1326      }
 1327  }
 1328  
 1329  // rambank
 1330  WRITE8_MEMBER(sigmab98_state::tdoboon_rambank_w)
 1331  {
 1332      if (offset == 0)
 1333      {
 1334          m_reg2 = data;
 1335          return;
 1336      }
 1337  
 1338      switch ( m_reg2 )
 1339      {
 1340          case 0x33:
 1341              m_rambank = data;
 1342              switch (data)
 1343              {
 1344                  case 0x53:
 1345                      break;
 1346  
 1347                  default:
 1348                      logerror("%s: unknown ram bank = %02x, reg2 = %02x\n", machine().describe_context(), data, m_reg2);
 1349              }
 1350              break;
 1351  
 1352          default:
 1353              logerror("%s: unknown reg2 written: %02x = %02x\n", machine().describe_context(), m_reg2, data);
 1354      }
 1355  }
 1356  READ8_MEMBER(sigmab98_state::tdoboon_rambank_r)
 1357  {
 1358      if (offset == 0)
 1359          return m_reg2;
 1360  
 1361      switch ( m_reg2 )
 1362      {
 1363          case 0x33:
 1364              return m_rambank;
 1365  
 1366          default:
 1367              logerror("%s: unknown reg2 read: %02x\n", machine().describe_context(), m_reg2);
 1368              return 0x00;
 1369      }
 1370  }
 1371  
 1372  READ8_MEMBER(sigmab98_state::tdoboon_c000_r)
 1373  {
 1374      switch (m_rombank)
 1375      {
 1376          case 0x10:  // ROM
 1377          case 0x11:
 1378          case 0x12:
 1379          case 0x13:
 1380          case 0x14:
 1381          case 0x15:
 1382          case 0x16:
 1383          case 0x17:
 1384          case 0x18:
 1385          case 0x19:
 1386          case 0x1a:
 1387          case 0x1b:
 1388          case 0x1c:
 1389          case 0x1d:
 1390          case 0x1e:
 1391          case 0x1f:
 1392              return memregion("maincpu")->base()[offset + 0xc400 + 0x1000 * (m_rombank-0x10)];
 1393  
 1394          case 0x64:  // SPRITERAM
 1395              if (offset < 0x1000)
 1396                  return m_spriteram[offset];
 1397              break;
 1398  
 1399          case 0x66:  // PALETTERAM + TABLE?
 1400              if (offset < 0x200)
 1401                  return m_generic_paletteram_8[offset];
 1402              break;
 1403  
 1404          case 0x67:  // REGS
 1405              if (offset == (0xc013-0xc000))
 1406                  return haekaka_vblank_r(space, offset);
 1407              break;
 1408      }
 1409  
 1410      logerror("%s: unknown read from %02x with rombank = %02x\n", machine().describe_context(), offset+0xc000, m_rombank);
 1411      return 0x00;
 1412  }
 1413  
 1414  WRITE8_MEMBER(sigmab98_state::tdoboon_c000_w)
 1415  {
 1416      switch (m_rombank)
 1417      {
 1418          case 0x64:  // SPRITERAM
 1419              if (offset < 0x1000)
 1420              {
 1421                  m_spriteram[offset] = data;
 1422                  return;
 1423              }
 1424              break;
 1425  
 1426          case 0x66:  // PALETTERAM + TABLE?
 1427              if (offset < 0x200)
 1428              {
 1429                  paletteram_xRRRRRGGGGGBBBBB_byte_be_w(space, offset, data);
 1430  //              m_generic_paletteram_8[offset] = data;
 1431                  return;
 1432              }
 1433              else if ((offset >= 0x800) && (offset < 0x880))
 1434              {
 1435                  // table?
 1436                  return;
 1437              }
 1438              break;
 1439      }
 1440  
 1441      logerror("%s: unknown write to %02x = %02x with rombank = %02x\n", machine().describe_context(), offset+0xc000, data, m_rombank);
 1442  }
 1443  
 1444  static ADDRESS_MAP_START( tdoboon_map, AS_PROGRAM, 8, sigmab98_state )
 1445      AM_RANGE( 0x0000, 0xbfff ) AM_ROM
 1446      AM_RANGE( 0xc000, 0xcfff ) AM_READWRITE(tdoboon_c000_r, tdoboon_c000_w )
 1447      AM_RANGE( 0xd000, 0xefff ) AM_RAM AM_SHARE( "nvram" )
 1448      AM_RANGE( 0xfe00, 0xffff ) AM_RAM   // High speed internal RAM
 1449  ADDRESS_MAP_END
 1450  
 1451  static ADDRESS_MAP_START( tdoboon_io, AS_IO, 8, sigmab98_state )
 1452      ADDRESS_MAP_GLOBAL_MASK(0xff)
 1453      AM_RANGE( 0x02, 0x03 ) AM_READWRITE(tdoboon_rombank_r, tdoboon_rombank_w )
 1454      AM_RANGE( 0x04, 0x05 ) AM_READWRITE(tdoboon_rambank_r, tdoboon_rambank_w )
 1455  
 1456      AM_RANGE( 0x2c, 0x2c ) AM_READWRITE(sammymdl_eeprom_r, sammymdl_eeprom_w )
 1457      AM_RANGE( 0x2e, 0x2e ) AM_READ(sammymdl_coin_hopper_r )
 1458      AM_RANGE( 0x30, 0x30 ) AM_READ_PORT( "BUTTON" )
 1459      AM_RANGE( 0x31, 0x31 ) AM_WRITE(sammymdl_coin_w )
 1460      AM_RANGE( 0x32, 0x32 ) AM_WRITE(sammymdl_leds_w )
 1461      AM_RANGE( 0x90, 0x90 ) AM_DEVWRITE("oki", okim9810_device, write )
 1462      AM_RANGE( 0x91, 0x91 ) AM_DEVWRITE("oki", okim9810_device, write_TMP_register )
 1463      AM_RANGE( 0x92, 0x92 ) AM_DEVREAD("oki", okim9810_device, read )
 1464      AM_RANGE( 0xb0, 0xb0 ) AM_WRITE(sammymdl_hopper_w )
 1465      AM_RANGE( 0xc0, 0xc0 ) AM_WRITE(watchdog_reset_w )  // 1
 1466  ADDRESS_MAP_END
 1467  
 1468  
 1469  /***************************************************************************
 1470  
 1471      Graphics Layout
 1472  
 1473  ***************************************************************************/
 1474  
 1475  static const gfx_layout sigmab98_16x16x4_layout =
 1476  {
 1477      16,16,
 1478      RGN_FRAC(1,1),
 1479      4,
 1480      { STEP4(0,1) },
 1481      { 4*1,4*0, 4*3,4*2, 4*5,4*4, 4*7,4*6, 4*9,4*8, 4*11,4*10, 4*13,4*12, 4*15,4*14 },
 1482      { STEP16(0,16*4) },
 1483      16*16*4
 1484  };
 1485  
 1486  static const gfx_layout sigmab98_16x16x8_layout =
 1487  {
 1488      16,16,
 1489      RGN_FRAC(1,1),
 1490      8,
 1491      { STEP8(0,1) },
 1492      { STEP16(0,8) },
 1493      { STEP16(0,16*8) },
 1494      16*16*8
 1495  };
 1496  
 1497  static GFXDECODE_START( sigmab98 )
 1498      GFXDECODE_ENTRY( "sprites", 0, sigmab98_16x16x4_layout, 0, 0x100/16  )
 1499      GFXDECODE_ENTRY( "sprites", 0, sigmab98_16x16x8_layout, 0, 0x100/256 )
 1500  GFXDECODE_END
 1501  
 1502  
 1503  /***************************************************************************
 1504  
 1505      Input Ports
 1506  
 1507  ***************************************************************************/
 1508  
 1509  /***************************************************************************
 1510                          GeGeGe no Kitarou Youkai Slot
 1511  ***************************************************************************/
 1512  
 1513  static INPUT_PORTS_START( gegege )
 1514  
 1515      PORT_START("EEPROM")
 1516      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL )   // protection? checks. Must be 0
 1517      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_CUSTOM  ) PORT_VBLANK("screen") // protection? checks. Must be 0
 1518      PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1519      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1520      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1521      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1522      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1523      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL )   PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_device, read_bit)
 1524  
 1525      PORT_START("IN1")
 1526      PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_COIN2   ) PORT_IMPULSE(5)   // ? (coin error, pulses mask 4 of port c6)
 1527      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_COIN1   ) PORT_IMPULSE(5) PORT_NAME("Medal")    // coin/medal in (coin error)
 1528      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("hopper", ticket_dispenser_device, line_r)
 1529      PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
 1530      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_BUTTON2 ) PORT_NAME("Bet")  // bet / select in test menu
 1531      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_BUTTON1 ) PORT_NAME("Play") // play game / select in test menu
 1532      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1533      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1534  
 1535      PORT_START("IN2")
 1536      PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_BUTTON3 ) PORT_NAME("Pay Out")  // pay out / change option in test menu
 1537      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1538      PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1539      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1540      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1541      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1542      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1543      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1544  
 1545  INPUT_PORTS_END
 1546  
 1547  /***************************************************************************
 1548                                  PEPSI Man
 1549  ***************************************************************************/
 1550  
 1551  static INPUT_PORTS_START( pepsiman )
 1552  
 1553      PORT_START("EEPROM")
 1554      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL )   // protection? checks. Must be 0
 1555      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_CUSTOM  ) PORT_VBLANK("screen") // protection? checks. Must be 0
 1556      PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1557      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1558      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1559      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1560      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1561      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL )   PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_device, read_bit)
 1562  
 1563      PORT_START("IN1")
 1564      PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_COIN2   ) PORT_IMPULSE(5)   // ? (coin error, pulses mask 4 of port c6)
 1565      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_COIN1   ) PORT_IMPULSE(5) PORT_NAME("Medal")    // coin/medal in (coin error)
 1566      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("hopper", ticket_dispenser_device, line_r)
 1567      PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
 1568      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_GAMBLE_BET ) PORT_CODE(KEYCODE_1)   // bet / select in test menu
 1569      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_BUTTON1 ) PORT_NAME("Rock (Gu)")
 1570      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_BUTTON2 ) PORT_NAME("Scissors (Choki)")
 1571      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_BUTTON3 ) PORT_NAME("Paper (Par)")
 1572  
 1573      PORT_START("IN2")
 1574      PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_GAMBLE_PAYOUT ) // pay out / enter in test menu
 1575      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1576      PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1577      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1578      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1579      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1580      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1581      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1582  
 1583  INPUT_PORTS_END
 1584  
 1585  /***************************************************************************
 1586                               Uchuu Tokkyuu Medalian
 1587  ***************************************************************************/
 1588  
 1589  static INPUT_PORTS_START( ucytokyu )
 1590  
 1591      PORT_START("EEPROM")
 1592      PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL )   // protection? checks. Must be 0
 1593      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_CUSTOM  ) PORT_VBLANK("screen") // protection? checks. Must be 0
 1594      PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1595      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1596      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1597      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1598      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1599      PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL )   PORT_READ_LINE_DEVICE_MEMBER("eeprom", eeprom_device, read_bit)
 1600  
 1601      PORT_START("IN1")
 1602      PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_COIN2   ) PORT_IMPULSE(10)  // ? (coin error, pulses mask 4 of port c6)
 1603      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_COIN1   ) PORT_IMPULSE(10) PORT_NAME("Medal")   // coin/medal in (coin error)
 1604      PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("hopper", ticket_dispenser_device, line_r)
 1605      PORT_SERVICE( 0x08, IP_ACTIVE_LOW )
 1606      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_GAMBLE_BET ) PORT_CODE(KEYCODE_1)   // bet / enter in test menu
 1607      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_JOYSTICK_DOWN  )
 1608      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_JOYSTICK_UP    )
 1609      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_JOYSTICK_RIGHT )
 1610  
 1611      PORT_START("IN2")
 1612      PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_GAMBLE_PAYOUT ) // pay out / back in test menu
 1613      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_JOYSTICK_LEFT )
 1614      PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1615      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1616      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1617      PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1618      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1619      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1620  
 1621  INPUT_PORTS_END
 1622  
 1623  /***************************************************************************
 1624                               Sammy Medal Games
 1625  ***************************************************************************/
 1626  
 1627  static INPUT_PORTS_START( sammymdl )
 1628      PORT_START("BUTTON")
 1629      PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) // shot
 1630      PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) // freeze (itazuram)
 1631      PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1632      PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1633      PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1634      PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1635      PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1636      PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1637  
 1638      PORT_START("COIN")
 1639      PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_COIN1   ) PORT_IMPULSE(5)   // coin1 in
 1640      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_COIN2   ) PORT_IMPULSE(5)   // coin2 in
 1641      PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_COIN3   ) PORT_IMPULSE(5) PORT_NAME("Medal")    // medal in
 1642      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_SERVICE )   // test sw
 1643      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1644      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_READ_LINE_DEVICE_MEMBER("hopper", ticket_dispenser_device, line_r)
 1645      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1646      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN )
 1647  INPUT_PORTS_END
 1648  
 1649  static INPUT_PORTS_START( haekaka )
 1650      PORT_START("BUTTON")
 1651      PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1   ) PORT_IMPULSE(5) PORT_NAME( "Medal" )   // medal in ("chacker")
 1652      PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1653      PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1654      PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1655      PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1656      PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1657      PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1658      PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
 1659  
 1660      PORT_START("COIN")
 1661      PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
 1662      PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
 1663      PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
 1664      PORT_BIT( 0x08, IP_ACTIVE_LOW,  IPT_SERVICE  )  // test sw
 1665      PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_BUTTON1  )  // button
 1666      PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_SPECIAL  ) PORT_READ_LINE_DEVICE_MEMBER("hopper", ticket_dispenser_device, line_r)
 1667      PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_SERVICE1 )  // service coin / set in test mode
 1668      PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN  )
 1669  INPUT_PORTS_END
 1670  
 1671  
 1672  /***************************************************************************
 1673  
 1674      Machine Drivers
 1675  
 1676  ***************************************************************************/
 1677  
 1678  /***************************************************************************
 1679                          GeGeGe no Kitarou Youkai Slot
 1680  ***************************************************************************/
 1681  
 1682  const eeprom_interface eeprom_intf =
 1683  {
 1684      6,              // address bits 6
 1685      16,             // data bits    16
 1686      "*110",         // read         1 10 aaaaaa
 1687      "*101",         // write        1 01 aaaaaa dddddddddddddddd
 1688      "*111",         // erase        1 11 aaaaaa
 1689      "*10000xxxx",   // lock         1 00 00xxxx
 1690      "*10011xxxx",   // unlock       1 00 11xxxx
 1691      0,              // enable_multi_read
 1692      7               // reset_delay (otherwise gegege will hang when saving settings)
 1693  };
 1694  
 1695  INTERRUPT_GEN_MEMBER(sigmab98_state::gegege_vblank_interrupt)
 1696  {
 1697      device.execute().set_input_line_and_vector(0, HOLD_LINE, 0x5a);
 1698  }
 1699  
 1700  static MACHINE_CONFIG_START( gegege, sigmab98_state )
 1701      MCFG_CPU_ADD("maincpu", Z80, 10000000)  // !! TAXAN KY-80, clock @X1? !!
 1702      MCFG_CPU_PROGRAM_MAP(gegege_mem_map)
 1703      MCFG_CPU_IO_MAP(gegege_io_map)
 1704      MCFG_CPU_VBLANK_INT_DRIVER("screen", sigmab98_state,  gegege_vblank_interrupt)
 1705  
 1706      MCFG_NVRAM_ADD_0FILL("nvram")
 1707      MCFG_EEPROM_ADD("eeprom", eeprom_intf)
 1708  
 1709      MCFG_TICKET_DISPENSER_ADD("hopper", attotime::from_msec(200), TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_LOW )
 1710  
 1711      MCFG_SCREEN_ADD("screen", RASTER)
 1712      MCFG_SCREEN_REFRESH_RATE(60)                    // ?
 1713      MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)   // game reads vblank state
 1714      MCFG_SCREEN_SIZE(0x200, 0x200)
 1715      MCFG_SCREEN_VISIBLE_AREA(0,0x140-1, 0,0xf0-1)
 1716      MCFG_SCREEN_UPDATE_DRIVER(sigmab98_state, screen_update_sigmab98)
 1717  
 1718      MCFG_GFXDECODE(sigmab98)
 1719      MCFG_PALETTE_LENGTH(0x100)
 1720  
 1721      // sound hardware
 1722      MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
 1723  
 1724      MCFG_SOUND_ADD("ymz", YMZ280B, 16934400)    // clock @X2?
 1725      MCFG_SOUND_ROUTE(0, "lspeaker", 1.0)
 1726      MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
 1727  MACHINE_CONFIG_END
 1728  
 1729  /***************************************************************************
 1730                               Sammy Medal Games
 1731  ***************************************************************************/
 1732  
 1733  static const eeprom_interface eeprom_interface_93C46_8bit_delay =
 1734  {
 1735      7,              // address bits 6
 1736      8,              // data bits    8
 1737      "*110",         // read         1 10 aaaaaa
 1738      "*101",         // write        1 01 aaaaaa dddddddd
 1739      "*111",         // erase        1 11 aaaaaa
 1740      "*10000xxxx",   // lock         1 00 00xxxx
 1741      "*10011xxxx",   // unlock       1 00 11xxxx
 1742      0,              // enable_multi_read
 1743      1               // reset_delay (needed by animalc)
 1744  //  "*10001xxxx"    // write all    1 00 01xxxx dddddddd
 1745  //  "*10010xxxx"    // erase all    1 00 10xxxx
 1746  };
 1747  
 1748  MACHINE_RESET_MEMBER(sigmab98_state,sammymdl)
 1749  {
 1750      machine().device("maincpu")->state().set_state_int(Z80_PC, 0x400);  // code starts at 400 ??? (000 = cart header)
 1751  }
 1752  
 1753  static MACHINE_CONFIG_START( sammymdl, sigmab98_state )
 1754      MCFG_CPU_ADD("maincpu", Z80, XTAL_20MHz / 2)    // !! KL5C80A120FP @ 10MHz? (actually 4 times faster than Z80) !!
 1755      MCFG_CPU_PROGRAM_MAP( animalc_map )
 1756      MCFG_CPU_IO_MAP( animalc_io )
 1757  
 1758      MCFG_MACHINE_RESET_OVERRIDE(sigmab98_state, sammymdl )
 1759  
 1760      MCFG_NVRAM_ADD_0FILL("nvram")   // battery
 1761      MCFG_EEPROM_ADD("eeprom", eeprom_interface_93C46_8bit_delay)
 1762  
 1763      MCFG_TICKET_DISPENSER_ADD("hopper", attotime::from_msec(200), TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_LOW )
 1764  
 1765      // video hardware
 1766      MCFG_SCREEN_ADD("screen", RASTER)
 1767      MCFG_SCREEN_REFRESH_RATE(60)
 1768      MCFG_SCREEN_SIZE(0x140, 0x100)
 1769      MCFG_SCREEN_VISIBLE_AREA(0, 0x140-1, 0, 0xf0-1)
 1770      MCFG_SCREEN_UPDATE_DRIVER(sigmab98_state, screen_update_sigmab98)
 1771      MCFG_SCREEN_VBLANK_DRIVER(sigmab98_state, screen_eof_sammymdl)
 1772  
 1773      MCFG_GFXDECODE(sigmab98)
 1774      MCFG_PALETTE_LENGTH(0x100)
 1775  
 1776      // sound hardware
 1777      MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
 1778  
 1779      MCFG_OKIM9810_ADD("oki", XTAL_4_096MHz)
 1780      MCFG_SOUND_ROUTE(0, "lspeaker", 0.80)
 1781      MCFG_SOUND_ROUTE(1, "rspeaker", 0.80)
 1782  MACHINE_CONFIG_END
 1783  
 1784  
 1785  /***************************************************************************
 1786                                   Animal Catch
 1787  ***************************************************************************/
 1788  
 1789  TIMER_DEVICE_CALLBACK_MEMBER(sigmab98_state::sammymd1_irq)
 1790  {
 1791      int scanline = param;
 1792  
 1793      if(scanline == 240)
 1794          m_maincpu->set_input_line_and_vector(0,HOLD_LINE, m_vblank_vector);
 1795  
 1796      if(scanline == 128)
 1797          m_maincpu->set_input_line_and_vector(0,HOLD_LINE, m_timer0_vector);
 1798  
 1799      if(scanline == 32)
 1800          m_maincpu->set_input_line_and_vector(0,HOLD_LINE, m_timer1_vector);
 1801  }
 1802  
 1803  static MACHINE_CONFIG_DERIVED( animalc, sammymdl )
 1804      MCFG_CPU_MODIFY("maincpu")
 1805      MCFG_CPU_PROGRAM_MAP( animalc_map )
 1806      MCFG_CPU_IO_MAP( animalc_io )
 1807      MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", sigmab98_state, sammymd1_irq, "screen", 0, 1)
 1808  MACHINE_CONFIG_END
 1809  
 1810  /***************************************************************************
 1811                               Hae Hae Ka Ka Ka
 1812  ***************************************************************************/
 1813  
 1814  static MACHINE_CONFIG_DERIVED( haekaka, sammymdl )
 1815      MCFG_CPU_MODIFY("maincpu")
 1816      MCFG_CPU_PROGRAM_MAP( haekaka_map )
 1817      MCFG_CPU_IO_MAP( haekaka_io )
 1818      MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", sigmab98_state, sammymd1_irq, "screen", 0, 1)
 1819  MACHINE_CONFIG_END
 1820  
 1821  /***************************************************************************
 1822                                Itazura Monkey
 1823  ***************************************************************************/
 1824  
 1825  static MACHINE_CONFIG_DERIVED( itazuram, sammymdl )
 1826      MCFG_CPU_MODIFY("maincpu")
 1827      MCFG_CPU_PROGRAM_MAP( itazuram_map )
 1828      MCFG_CPU_IO_MAP( itazuram_io )
 1829      MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", sigmab98_state, sammymd1_irq, "screen", 0, 1)
 1830  MACHINE_CONFIG_END
 1831  
 1832  /***************************************************************************
 1833                               Pye-nage Taikai
 1834  ***************************************************************************/
 1835  
 1836  static MACHINE_CONFIG_DERIVED( pyenaget, sammymdl )
 1837      MCFG_CPU_MODIFY("maincpu")
 1838      MCFG_CPU_PROGRAM_MAP( haekaka_map )
 1839      MCFG_CPU_IO_MAP( pyenaget_io )
 1840      MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", sigmab98_state, sammymd1_irq, "screen", 0, 1)
 1841  MACHINE_CONFIG_END
 1842  
 1843  /***************************************************************************
 1844                               Taihou de Doboon
 1845  ***************************************************************************/
 1846  
 1847  static MACHINE_CONFIG_DERIVED( tdoboon, sammymdl )
 1848      MCFG_CPU_MODIFY("maincpu")
 1849      MCFG_CPU_PROGRAM_MAP( tdoboon_map )
 1850      MCFG_CPU_IO_MAP( tdoboon_io )
 1851      MCFG_TIMER_DRIVER_ADD_SCANLINE("scantimer", sigmab98_state, sammymd1_irq, "screen", 0, 1)
 1852  
 1853      MCFG_SCREEN_MODIFY("screen")
 1854      MCFG_SCREEN_VISIBLE_AREA(0,0x140-1, 0+4,0xf0+4-1)
 1855  MACHINE_CONFIG_END
 1856  
 1857  
 1858  /***************************************************************************
 1859  
 1860      ROMs Loading
 1861  
 1862  ***************************************************************************/
 1863  
 1864  /***************************************************************************
 1865  
 1866    GeGeGe no Kitarou Youkai Slot
 1867  
 1868    (C) 1997 Banpresto, Sigma
 1869  
 1870    PCB:
 1871  
 1872      (c) 1997 Sigma B-98-1 MAIN PCB
 1873      970703 (Sticker)
 1874  
 1875    CPU:
 1876  
 1877      TAXAN KY-80 YAMAHA 9650 AZGC (@IC1)
 1878      XTAL ?? (@X1)
 1879  
 1880    Video:
 1881  
 1882      TAXAN KY-3211 9722 AZGC (@IC11)
 1883      XTAL 27.000 MHz (@XOSC1)
 1884      M548262-60 (@IC24) - 262144-Word x 8-Bit Multiport DRAM
 1885  
 1886    Sound:
 1887  
 1888      YAMAHA YMZ280B-F (@IC14)
 1889      XTAL ?? (@X2)
 1890      Trimmer
 1891  
 1892    Other:
 1893  
 1894      93C46AN EEPROM (@IC5)
 1895      MAX232CPE (@IC6)
 1896      Battery (@BAT)
 1897  
 1898  ***************************************************************************/
 1899  
 1900  ROM_START( gegege )
 1901      ROM_REGION( 0x20000, "maincpu", 0 )
 1902      ROM_LOAD( "b9804-1.ic7", 0x00000, 0x20000, CRC(f8b4f855) SHA1(598bd9f91123e9ab539ce3f33779bff2d072e731) )
 1903  
 1904      ROM_REGION( 0x100000, "sprites", 0 )
 1905      ROM_LOAD( "b9804-2.ic12", 0x00000, 0x80000, CRC(4211079d) SHA1(d601c623fb909f1346fd02b8fb37b67956e2cd4e) )
 1906      ROM_LOAD( "b9804-3.ic13", 0x80000, 0x80000, CRC(54aeb2aa) SHA1(ccf939111f6288a889846d51bab47ff4e992c542) )
 1907  
 1908      ROM_REGION( 0x80000, "ymz", 0 )
 1909      ROM_LOAD( "b9804-5.ic16", 0x00000, 0x80000, CRC(ddd7984c) SHA1(3558c495776671ffd3cd5c665b87827b3959b360) )
 1910  ROM_END
 1911  
 1912  DRIVER_INIT_MEMBER(sigmab98_state,gegege)
 1913  {
 1914      UINT8 *rom = machine().root_device().memregion("maincpu")->base();
 1915  
 1916      // Protection?
 1917      rom[0x0bdd] = 0xc9;
 1918  
 1919      rom[0x0bf9] = 0xc9;
 1920  
 1921      rom[0x0dec] = 0x00;
 1922      rom[0x0ded] = 0x00;
 1923  
 1924      // EEPROM timing checks
 1925      rom[0x8138] = 0x00;
 1926      rom[0x8139] = 0x00;
 1927  
 1928      rom[0x8164] = 0x00;
 1929      rom[0x8165] = 0x00;
 1930  
 1931      // ROM banks
 1932      machine().root_device().membank("rombank")->configure_entries(0, 0x18, rom + 0x8000, 0x1000);
 1933      machine().root_device().membank("rombank")->set_entry(0);
 1934  
 1935      // RAM banks
 1936      UINT8 *bankedram = auto_alloc_array(machine(), UINT8, 0x800 * 2);
 1937  
 1938      machine().root_device().membank("rambank")->configure_entries(0, 2, bankedram, 0x800);
 1939      machine().root_device().membank("rambank")->set_entry(0);
 1940  }
 1941  
 1942  
 1943  /***************************************************************************
 1944  
 1945    PEPSI Man
 1946  
 1947  ***************************************************************************/
 1948  
 1949  ROM_START( pepsiman )
 1950      ROM_REGION( 0x20000, "maincpu", 0 )
 1951      ROM_LOAD( "b9806-1a.ic7", 0x00000, 0x20000, CRC(3152fe90) SHA1(98a8ae1bd3a4381cec11ba8b3e9cdad71c7bd05a) )
 1952  
 1953      ROM_REGION( 0x100000, "sprites", 0 )
 1954      ROM_LOAD( "b9806-2.ic12", 0x00000, 0x80000, CRC(82f650ea) SHA1(c0b214fdc39329e2136707bc195d470d4b613509) )
 1955      ROM_LOAD( "b9806-3.ic13", 0x80000, 0x80000, CRC(07dc548e) SHA1(9419c0cac289a9894cce1a10924f40e146e2ff8a) )
 1956  
 1957      ROM_REGION( 0x80000, "ymz", 0 )
 1958      ROM_LOAD( "b9806-5.ic16", 0x00000, 0x80000, CRC(6d405dfb) SHA1(e65ffe1279680097894754e379d7ad638657eb49) )
 1959  ROM_END
 1960  
 1961  DRIVER_INIT_MEMBER(sigmab98_state,pepsiman)
 1962  {
 1963      UINT8 *rom = machine().root_device().memregion("maincpu")->base();
 1964  
 1965      // Protection?
 1966      rom[0x058a] = 0xc9;
 1967  
 1968      rom[0x05a6] = 0xc9;
 1969  
 1970      rom[0xa00e] = 0x00;
 1971      rom[0xa00f] = 0x00;
 1972  
 1973      // EEPROM timing checks
 1974      rom[0x8138] = 0x00;
 1975      rom[0x8139] = 0x00;
 1976  
 1977      rom[0x8164] = 0x00;
 1978      rom[0x8165] = 0x00;
 1979  
 1980      // ROM banks
 1981      machine().root_device().membank("rombank")->configure_entries(0, 0x18, rom + 0x8000, 0x1000);
 1982      machine().root_device().membank("rombank")->set_entry(0);
 1983  
 1984      // RAM banks
 1985      UINT8 *bankedram = auto_alloc_array(machine(), UINT8, 0x800 * 2);
 1986  
 1987      machine().root_device().membank("rambank")->configure_entries(0, 2, bankedram, 0x800);
 1988      machine().root_device().membank("rambank")->set_entry(0);
 1989  }
 1990  
 1991  
 1992  /***************************************************************************
 1993  
 1994    Uchuu Tokkyuu Medalian
 1995  
 1996  ***************************************************************************/
 1997  
 1998  ROM_START( ucytokyu )
 1999      ROM_REGION( 0x20000, "maincpu", 0 )
 2000      ROM_LOAD( "b9809-1.ic7", 0x00000, 0x20000, CRC(5be6adff) SHA1(7248157111be2ae23df7d51f5d071cc3b9fd79b4) )
 2001  
 2002      ROM_REGION( 0x180000, "sprites", 0 )
 2003      ROM_LOAD( "b9809-2.ic12", 0x000000, 0x80000, CRC(18f342b3) SHA1(09d62bb3597259e0fbae2c0f4ed163685a4a9dd9) )
 2004      ROM_LOAD( "b9809-3.ic13", 0x080000, 0x80000, CRC(88a2a52a) SHA1(0dd10d4fa88d1a54150729026495a70dbe67bae0) )
 2005      ROM_LOAD( "b9809-4.ic17", 0x100000, 0x80000, CRC(ea74eacd) SHA1(279fa1d2bc7bfafbafecd0e0758a47345ca95140) )
 2006  
 2007      ROM_REGION( 0x100000, "ymz", 0 )
 2008      ROM_LOAD( "b9809-5.ic16", 0x00000, 0x80000, CRC(470006e6) SHA1(34c82fae7364eb5288de5c8128d72d7e5772c526) )
 2009      ROM_LOAD( "b9809-6.ic26", 0x80000, 0x80000, CRC(4e2d5fdf) SHA1(af1357b0f6a407890ecad26a18d2b4e223802693) )
 2010  ROM_END
 2011  
 2012  DRIVER_INIT_MEMBER(sigmab98_state,ucytokyu)
 2013  {
 2014      UINT8 *rom = machine().root_device().memregion("maincpu")->base();
 2015  
 2016      // Protection?
 2017      rom[0x0bfa] = 0xc9;
 2018  
 2019      rom[0x0c16] = 0xc9;
 2020  
 2021      rom[0xa43a] = 0x00;
 2022      rom[0xa43b] = 0x00;
 2023  
 2024      // EEPROM timing checks
 2025      rom[0x8138] = 0x00;
 2026      rom[0x8139] = 0x00;
 2027  
 2028      rom[0x8164] = 0x00;
 2029      rom[0x8165] = 0x00;
 2030  
 2031      // ROM banks
 2032      machine().root_device().membank("rombank")->configure_entries(0, 0x18, rom + 0x8000, 0x1000);
 2033      machine().root_device().membank("rombank")->set_entry(0);
 2034  
 2035      // RAM banks
 2036      UINT8 *bankedram = auto_alloc_array(machine(), UINT8, 0x800 * 2);
 2037  
 2038      machine().root_device().membank("rambank")->configure_entries(0, 2, bankedram, 0x800);
 2039      machine().root_device().membank("rambank")->set_entry(0);
 2040  }
 2041  
 2042  
 2043  /***************************************************************************
 2044  
 2045    Sammy Medal Games
 2046  
 2047    PCB:
 2048  
 2049      Sammy AM3AHF-01 SC MAIN PCB VER2 (Etched)
 2050      MAIN PCB VER2 VM12-6001-0 (Sticker)
 2051  
 2052    CPU:
 2053  
 2054      KAWASAKI KL5C80A120FP (@U1) - Z80 Compatible High Speed Microcontroller
 2055      XTAL 20 MHz  (@X1)
 2056      MX29F040TC-12 VM1211L01 (@U2) - 4M-bit [512kx8] CMOS Equal Sector Flash Memory
 2057      BSI BS62LV256SC-70      (@U4) - Very Low Power/Voltage CMOS SRAM 32K X 8 bit
 2058  
 2059    Video:
 2060  
 2061      TAXAN KY-3211 ? (@U17)
 2062      M548262-60 (@U18) - 262144-Word x 8-Bit Multiport DRAM
 2063      XTAL 27 MHz (@X3)
 2064  
 2065    Sound:
 2066  
 2067      OKI M9810B (@U11)
 2068      XTAL 4.09 MHz (@X2)
 2069      Trimmer (@VR1)
 2070      Toshiba TA7252AP (@U16) - 5.9W Audio Power Amplifier
 2071  
 2072    Other:
 2073  
 2074      Xilinx XC9536 VM1212F01 (@U5) - In-System Programmable CPLD
 2075      MX29F0??C (@U3) - Empty 32 Pin ROM Socket
 2076      M93C46MN6T (@U11?) - Serial EEPROM
 2077      Cell Battery (@BAT)
 2078      25 Pin Edge Connector
 2079      56 Pin Cartridge Connector
 2080      6 Pin Connector
 2081  
 2082  ***************************************************************************/
 2083  
 2084  #define SAMMYMDL_BIOS                                                                                               \
 2085      ROM_REGION( 0x80000, "mainbios", 0 )                                                                            \
 2086      ROM_SYSTEM_BIOS( 0, "v5", "IPL Ver. 5.0" )                                                                      \
 2087      ROM_LOAD( "vm1211l01.u2", 0x000000, 0x080000, CRC(c3c74dc5) SHA1(07352e6dba7514214e778ba39e1ca773e4698858) )
 2088  
 2089  ROM_START( sammymdl )
 2090      SAMMYMDL_BIOS
 2091  
 2092      ROM_REGION( 0x1000000, "oki", ROMREGION_ERASEFF )
 2093  
 2094      ROM_REGION( 0x40000, "maincpu", ROMREGION_ERASEFF )
 2095  
 2096      ROM_REGION( 0x200000, "sprites", ROMREGION_ERASEFF )
 2097  ROM_END
 2098  
 2099  /***************************************************************************
 2100  
 2101    Animal Catch ( VX2002L02 ANIMALCAT 200011211536 SAMMY CORP. AM )
 2102  
 2103    Sammy AM3ADT-01 Memory Card Type 3:
 2104    1 x MX29F1610ATC-12 (@U021)
 2105    1 x MX29F1610TC-12  (@U016)
 2106  
 2107  ***************************************************************************/
 2108  
 2109  ROM_START( animalc )
 2110      SAMMYMDL_BIOS
 2111  
 2112      ROM_REGION( 0x1000000, "oki", 0 )
 2113      ROM_LOAD( "vx2302l01.u021", 0x00000, 0x200000, CRC(84cf123b) SHA1(d8b425c93ff1a560e3f92c70d7eb93a05c3581af) )
 2114  
 2115      ROM_REGION( 0x40000, "maincpu", 0 )
 2116      ROM_COPY( "oki", 0x1c0000, 0x00000, 0x40000 )
 2117  
 2118      ROM_REGION( 0x200000, "sprites", 0 )
 2119      ROM_LOAD( "vx2301l01.u016", 0x00000, 0x200000, CRC(4ae14ff9) SHA1(1273d15ea642452fecacff572655cd3ab47a5884) )   // 1xxxxxxxxxxxxxxxxxxxx = 0x00
 2120  ROM_END
 2121  
 2122  DRIVER_INIT_MEMBER(sigmab98_state,animalc)
 2123  {
 2124      // RAM banks
 2125      UINT8 *bankedram = auto_alloc_array(machine(), UINT8, 0x1000 * 5);
 2126      membank("rambank")->configure_entry(0, m_nvram);
 2127      membank("rambank")->configure_entries(1, 4, bankedram, 0x1000);
 2128      membank("rambank")->set_entry(0);
 2129  
 2130      m_spriteram.allocate(0x1000 * 5);
 2131      memset(m_spriteram, 0, 0x1000 * 5);
 2132      membank("sprbank")->configure_entries(0, 5, m_spriteram, 0x1000);
 2133      membank("sprbank")->set_entry(0);
 2134  
 2135      m_vblank_vector = 0x00; // increment counter
 2136      m_timer0_vector = 0x1c; // read hopper state
 2137      m_timer1_vector = 0x1e; // drive hopper motor
 2138  }
 2139  
 2140  /***************************************************************************
 2141  
 2142    Itazura Monkey ( VX1902L02 ITZRMONKY 200011211639 SAMMY CORP. AM )
 2143  
 2144    Sammy AM3ADT-01 Memory Card Type 3:
 2145    2 x MX29F1610ATC-12
 2146  
 2147  ***************************************************************************/
 2148  
 2149  ROM_START( itazuram )
 2150      SAMMYMDL_BIOS
 2151  
 2152      ROM_REGION( 0x1000000, "oki", 0 )
 2153      ROM_LOAD( "vx2002l01.u021", 0x00000, 0x200000, CRC(ddbdd2f3) SHA1(91f67a938929be0261442e066e3d2c03b5e9f06a) )
 2154  
 2155      ROM_REGION( 0x40000, "maincpu", 0 )
 2156      ROM_COPY( "oki", 0x1c0000, 0x00000, 0x40000 )
 2157  
 2158      ROM_REGION( 0x200000, "sprites", 0 )
 2159      ROM_LOAD( "vx2001l01.u016", 0x00000, 0x200000, CRC(9ee95222) SHA1(7154d43ef312a48a882207ca37e1c61e8b215a9b) )
 2160  ROM_END
 2161  
 2162  DRIVER_INIT_MEMBER(sigmab98_state,itazuram)
 2163  {
 2164      // ROM banks
 2165      UINT8 *rom = memregion("maincpu")->base();
 2166      membank("rombank0")->set_base(rom + 0x3400);
 2167      membank("rombank1")->set_base(rom + 0x4400);
 2168      m_rombank = 0x0f;
 2169  
 2170      // RAM banks
 2171      m_generic_paletteram_8.allocate(0x3000);
 2172      memset(m_generic_paletteram_8, 0, 0x3000);
 2173      membank("palbank")->set_base(m_generic_paletteram_8);
 2174      m_rambank = 0x64;
 2175  
 2176      m_spriteram.allocate(0x1000 * 5);
 2177      memset(m_spriteram, 0, 0x1000 * 5);
 2178      membank("sprbank0")->set_base(m_spriteram + 0x1000*4);  // scratch
 2179      membank("sprbank1")->set_base(m_spriteram + 0x1000*4);  // scratch
 2180  
 2181      m_vblank_vector = 0x00;
 2182      m_timer0_vector = 0x02;
 2183      m_timer1_vector = 0x16;
 2184  }
 2185  
 2186  /***************************************************************************
 2187  
 2188    Taihou de Doboon ( EM4210L01 PUSHERDBN 200203151028 SAMMY CORP. AM )
 2189  
 2190    Sammy AM3ADT-01 Memory Card Type 3:
 2191    2 x MX29F1610ATC-12
 2192  
 2193    The flash roms found in the cart are labeled:
 2194  
 2195    vx1801l01.u016
 2196    vx1802l01.u021
 2197  
 2198    which correspond to "Pye-nage Taikai". But they were reflashed with the
 2199    software noted in the sticker on the back of the cart (rom names reflect that):
 2200  
 2201    System: Treasure Hall
 2202    Soft: Taihou de Doboon
 2203    2003.02.14
 2204    Char Rev: EM4209L01
 2205    Pro  Rev: EM4210L01
 2206  
 2207  ***************************************************************************/
 2208  
 2209  ROM_START( tdoboon )
 2210      SAMMYMDL_BIOS
 2211  
 2212      ROM_REGION( 0x1000000, "oki", 0 )
 2213      ROM_LOAD( "em4210l01.u021.bin", 0x00000, 0x200000, CRC(3523e314) SHA1(d07c5d17d3f285be4cde810547f427e84f98968f) )
 2214  
 2215      ROM_REGION( 0x40000, "maincpu", 0 )
 2216      ROM_COPY( "oki", 0x1c0000, 0x00000, 0x40000 )
 2217  
 2218      ROM_REGION( 0x200000, "sprites", 0 )
 2219      ROM_LOAD( "em4209l01.u016.bin", 0x00000, 0x200000, CRC(aca220fa) SHA1(7db441add16af554700e597fd9926b6ccd19d628) )   // 1xxxxxxxxxxxxxxxxxxxx = 0xFF
 2220  ROM_END
 2221  
 2222  /***************************************************************************
 2223  
 2224    Pye-nage Taikai ( VX1802L01 PAINAGETK 200011021216 SAMMY CORP. AM. )
 2225  
 2226    Sammy AM3ADT-01 Memory Card Type 3:
 2227    2 x MX29F1610ATC-12
 2228  
 2229  ***************************************************************************/
 2230  
 2231  ROM_START( pyenaget )
 2232      SAMMYMDL_BIOS
 2233  
 2234      ROM_REGION( 0x1000000, "oki", 0 )
 2235      ROM_LOAD( "vx1802l01.u021", 0x00000, 0x200000, CRC(7a22a657) SHA1(2a98085862fd958209253c5401e41eae4f7c06ea) )
 2236  
 2237      ROM_REGION( 0x40000, "maincpu", 0 )
 2238      ROM_COPY( "oki", 0x1c0000, 0x00000, 0x40000 )
 2239  
 2240      ROM_REGION( 0x200000, "sprites", 0 )
 2241      ROM_LOAD( "vx1801l01.u016", 0x00000, 0x200000, CRC(c4607403) SHA1(f4f4699442afccc5ed4354447f91b1bee36ae3e5) )
 2242  ROM_END
 2243  
 2244  /***************************************************************************
 2245  
 2246    Hae Hae Ka Ka Ka ( EM4208L01 PUSHERHAEHAE 200203151032 SAMMY CORP. AM )
 2247  
 2248    Sammy AM3ADT-01 Memory Card Type 3:
 2249    2 x MX29F1610ATC-12
 2250  
 2251    The flash roms found in the cart are labeled:
 2252  
 2253    vx1801l01.u016
 2254    vx1802l01.u021
 2255  
 2256    which correspond to "Pye-nage Taikai". But they were reflashed with the
 2257    software noted in the sticker on the back of the cart (rom names reflect that):
 2258  
 2259    System: Treasure Hall
 2260    Soft: Hae Hae Ka Ka Ka
 2261    2003.02.14
 2262    Char Rev: EM4207L01
 2263    Pro  Rev: EM4208L01
 2264  
 2265  ***************************************************************************/
 2266  
 2267  ROM_START( haekaka )
 2268      SAMMYMDL_BIOS
 2269  
 2270      ROM_REGION( 0x1000000, "oki", 0 )
 2271      ROM_LOAD( "em4208l01.u021.bin", 0x00000, 0x200000, CRC(d23bb748) SHA1(38d5b6c4b2cd470b3a68574aeca3f9fa9032245e) )
 2272  
 2273      ROM_REGION( 0x40000, "maincpu", 0 )
 2274      ROM_COPY( "oki", 0x1c0000, 0x00000, 0x40000 )
 2275  
 2276      ROM_REGION( 0x200000, "sprites", 0 )
 2277      ROM_LOAD( "em4207l01.u016.bin", 0x00000, 0x200000, CRC(3876961c) SHA1(3d842c1f63ea5aa7e799967928b86c5fabb4e65e) )
 2278  ROM_END
 2279  
 2280  DRIVER_INIT_MEMBER(sigmab98_state,haekaka)
 2281  {
 2282      // RAM banks
 2283      m_generic_paletteram_8.allocate(0x200);
 2284      memset(m_generic_paletteram_8, 0, 0x200);
 2285  
 2286      m_spriteram.allocate(0x1000);
 2287      memset(m_spriteram, 0, 0x1000);
 2288  
 2289      m_rombank = 0x65;
 2290      m_rambank = 0x53;
 2291  
 2292      m_vblank_vector = 0x04;
 2293      m_timer0_vector = 0x1a;
 2294      m_timer1_vector = 0x1c;
 2295  }
 2296  
 2297  
 2298  /***************************************************************************
 2299  
 2300      Game Drivers
 2301  
 2302  ***************************************************************************/
 2303  
 2304  GAME( 1997, gegege,   0,        gegege,   gegege, sigmab98_state,   gegege,   ROT0, "Banpresto / Sigma", "GeGeGe no Kitarou Youkai Slot", 0 )
 2305  GAME( 1997, pepsiman, 0,        gegege,   pepsiman, sigmab98_state, pepsiman, ROT0, "Sigma",             "PEPSI Man",                     0 )
 2306  GAME( 1997, ucytokyu, 0,        gegege,   ucytokyu, sigmab98_state, ucytokyu, ROT0, "Sigma",             "Uchuu Tokkyuu Medalian",        0 )   // Banpresto + others in the ROM
 2307  // Sammy Medal Games:
 2308  GAME( 2000, sammymdl, 0,        sammymdl, sammymdl, driver_device, 0,        ROT0, "Sammy",             "Sammy Medal Game System Bios",  GAME_IS_BIOS_ROOT )
 2309  GAME( 2000, animalc,  sammymdl, animalc,  sammymdl, sigmab98_state, animalc,  ROT0, "Sammy",             "Animal Catch",                  0 )
 2310  GAME( 2000, itazuram, sammymdl, itazuram, sammymdl, sigmab98_state, itazuram, ROT0, "Sammy",             "Itazura Monkey",                0 )
 2311  GAME( 2000, pyenaget, sammymdl, pyenaget, sammymdl, sigmab98_state, haekaka,  ROT0, "Sammy",             "Pye-nage Taikai",               0 )
 2312  GAME( 2000, tdoboon,  sammymdl, tdoboon,  haekaka, sigmab98_state,  haekaka,  ROT0, "Sammy",             "Taihou de Doboon",              0 )
 2313  GAME( 2001, haekaka,  sammymdl, haekaka,  haekaka, sigmab98_state,  haekaka,  ROT0, "Sammy",             "Hae Hae Ka Ka Ka",              0 )