Previous 199869 Revisions Next

r34916 Saturday 7th February, 2015 at 22:20:46 UTC by Alex W. Jackson
srmp5.c: cleanup/modernization (nw)
[src/mame/drivers]srmp5.c

trunk/src/mame/drivers/srmp5.c
r243427r243428
6868      : driver_device(mconfig, type, tag),
6969         m_gfxdecode(*this, "gfxdecode"),
7070         m_palette(*this, "palette"),
71      m_maincpu(*this,"maincpu"),
72         m_subcpu(*this, "sub")
73
71         m_maincpu(*this,"maincpu"),
72         m_subcpu(*this, "sub"),
73         m_chrrom(*this, "chr"),
74         m_keys(*this, "KEY"),
75         m_chrbank(0)
7476   { }
77   required_device<gfxdecode_device> m_gfxdecode;
78   required_device<palette_device> m_palette;
79   required_device<st0016_cpu_device> m_maincpu;
80   required_device<cpu_device> m_subcpu;
7581
76   UINT32 m_databank;
82   required_region_ptr<UINT16> m_chrrom;
83
84   required_ioport_array<4> m_keys;
85
86   UINT32 m_chrbank;
7787   UINT16 *m_tileram;
78   UINT16 *m_palram;
7988   UINT16 *m_sprram;
8089
8190   UINT8 m_input_select;
r243427r243428
8897#ifdef DEBUG_CHAR
8998   UINT8 m_tileduty[0x2000];
9099#endif
91   DECLARE_READ32_MEMBER(srmp5_palette_r);
92   DECLARE_WRITE32_MEMBER(srmp5_palette_w);
93100   DECLARE_WRITE32_MEMBER(bank_w);
94101   DECLARE_READ32_MEMBER(tileram_r);
95102   DECLARE_WRITE32_MEMBER(tileram_w);
96103   DECLARE_READ32_MEMBER(spr_r);
97104   DECLARE_WRITE32_MEMBER(spr_w);
98   DECLARE_READ32_MEMBER(data_r);
105   DECLARE_READ32_MEMBER(chrrom_r);
99106   DECLARE_WRITE32_MEMBER(input_select_w);
100107   DECLARE_READ32_MEMBER(srmp5_inputs_r);
101108   DECLARE_WRITE32_MEMBER(cmd1_w);
r243427r243428
109116   DECLARE_READ8_MEMBER(cmd_stat8_r);
110117   DECLARE_DRIVER_INIT(srmp5);
111118   UINT32 screen_update_srmp5(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
112   required_device<gfxdecode_device> m_gfxdecode;
113   required_device<palette_device> m_palette;
114   optional_device<st0016_cpu_device> m_maincpu;
115   optional_device<cpu_device> m_subcpu;
116119
120
117121   DECLARE_WRITE8_MEMBER(st0016_rom_bank_w);
118122};
119123
r243427r243428
124128   UINT16 *sprite_list=m_sprram;
125129   UINT16 *sprite_list_end=&m_sprram[0x4000]; //guess
126130   UINT8 *pixels=(UINT8 *)m_tileram;
131   const pen_t * const pens = m_palette->pens();
127132
128133//Table surface seems to be tiles, but display corrupts when switching the scene if always ON.
129134//Currently the tiles are OFF.
r243427r243428
146151            {
147152               for(x = 0; x < 16; x++)
148153               {
149                  UINT8 pen = pixels[address];
154                  UINT8 pen = pixels[BYTE_XOR_LE(address)];
150155                  if(pen)
151156                  {
152                     UINT16 pixdata=m_palram[pen];
153                     bitmap.pix32(yw * 16 + y, xw * 16 + x) = ((pixdata&0x7c00)>>7) | ((pixdata&0x3e0)<<6) | ((pixdata&0x1f)<<19);
157                     bitmap.pix32(yw * 16 + y, xw * 16 + x) = pens[pen];
154158                  }
155159                  address++;
156160               }
r243427r243428
195199                     ys2 = (sprite_sublist[SPRITE_PALETTE] & 0x4000) ? ys : (sizey - ys);
196200                     for(xs=0;xs<=sizex;xs++)
197201                     {
198                        UINT8 pen=pixels[address&(0x100000-1)];
202                        UINT8 pen=pixels[BYTE_XOR_LE(address)&(0x100000-1)];
199203                        xs2 = (sprite_sublist[SPRITE_PALETTE] & 0x8000) ? (sizex - xs) : xs;
200204                        if(pen)
201205                        {
202206                           if(cliprect.contains(xb+xs2, yb+ys2))
203207                           {
204                              UINT16 pixdata=m_palram[pen+((sprite_sublist[SPRITE_PALETTE]&0xff)<<8)];
205                              bitmap.pix32(yb+ys2, xb+xs2) = ((pixdata&0x7c00)>>7) | ((pixdata&0x3e0)<<6) | ((pixdata&0x1f)<<19);
208                              bitmap.pix32(yb+ys2, xb+xs2) = pens[pen+((sprite_sublist[SPRITE_PALETTE]&0xff)<<8)];
206209                           }
207210                        }
208211                        ++address;
r243427r243428
234237   return 0;
235238}
236239
237READ32_MEMBER(srmp5_state::srmp5_palette_r)
238{
239   return m_palram[offset];
240}
241
242WRITE32_MEMBER(srmp5_state::srmp5_palette_w)
243{
244   COMBINE_DATA(&m_palram[offset]);
245   m_palette->set_pen_color(offset, rgb_t(data << 3 & 0xFF, data >> 2 & 0xFF, data >> 7 & 0xFF));
246}
247240WRITE32_MEMBER(srmp5_state::bank_w)
248241{
249   COMBINE_DATA(&m_databank);
242   m_chrbank = ((data & 0xf0) >> 4) * (0x100000 / sizeof(UINT16));
250243}
251244
252245READ32_MEMBER(srmp5_state::tileram_r)
r243427r243428
272265   m_sprram[offset] = data & 0xFFFF; //lower 16bit only
273266}
274267
275READ32_MEMBER(srmp5_state::data_r)
268READ32_MEMBER(srmp5_state::chrrom_r)
276269{
277   UINT32 data;
278   const UINT8 *usr = memregion("user2")->base();
279
280   data=((m_databank>>4)&0xf)*0x100000; //guess
281   data=usr[data+offset*2]+usr[data+offset*2+1]*256;
282   return data|(data<<16);
270   return m_chrrom[m_chrbank + offset]; // lower 16bit only
283271}
284272
285273WRITE32_MEMBER(srmp5_state::input_select_w)
r243427r243428
294282   switch (m_input_select)
295283   {
296284   case 0x01:
297      ret = ioport("IN0")->read();
285      ret = m_keys[0]->read();
298286      break;
299287   case 0x02:
300      ret = ioport("IN1")->read();
288      ret = m_keys[1]->read();
301289      break;
302290   case 0x04:
303      ret = ioport("IN2")->read();
291      ret = m_keys[2]->read();
304292      break;
305293   case 0x00:
306294   case 0x08:
307      ret = ioport("IN3")->read();
295      ret = m_keys[3]->read();
308296      break;
309297   }
310298   return ret;
r243427r243428
363351   AM_RANGE(0x01802000, 0x01802003) AM_WRITE(cmd1_w)
364352   AM_RANGE(0x01802004, 0x01802007) AM_WRITE(cmd2_w)
365353   AM_RANGE(0x01802008, 0x0180200b) AM_READ(cmd_stat32_r)
366   AM_RANGE(0x01a00000, 0x01bfffff) AM_READ(data_r)
354   AM_RANGE(0x01a00000, 0x01bfffff) AM_READ(chrrom_r)
367355   AM_RANGE(0x01c00000, 0x01c00003) AM_READNOP // debug? 'Toru'
368356
369357   AM_RANGE(0x0a000000, 0x0a0fffff) AM_READWRITE(spr_r, spr_w)
370   AM_RANGE(0x0a100000, 0x0a17ffff) AM_READWRITE(srmp5_palette_r, srmp5_palette_w)
358   AM_RANGE(0x0a100000, 0x0a17ffff) AM_DEVREADWRITE16("palette", palette_device, read, write, 0x0000ffff) AM_SHARE("palette")
371359   //0?N???A?????????i??????????
372360   AM_RANGE(0x0a180000, 0x0a180003) AM_READNOP // write 0x00000400
373361   AM_RANGE(0x0a180000, 0x0a18011f) AM_READWRITE(srmp5_vidregs_r, srmp5_vidregs_w)
r243427r243428
375363
376364   AM_RANGE(0x1eff0000, 0x1eff001f) AM_WRITEONLY
377365   AM_RANGE(0x1eff003c, 0x1eff003f) AM_READ(irq_ack_clear)
378   AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("user1", 0)
379   AM_RANGE(0x2fc00000, 0x2fdfffff) AM_ROM AM_REGION("user1", 0)
366   AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("sub", 0)
367   AM_RANGE(0x2fc00000, 0x2fdfffff) AM_ROM AM_REGION("sub", 0)
380368ADDRESS_MAP_END
381369
382370static ADDRESS_MAP_START( st0016_mem, AS_PROGRAM, 8, srmp5_state )
r243427r243428
477465   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
478466   PORT_BIT ( 0xffffff00, IP_ACTIVE_LOW, IPT_UNUSED )
479467
480   PORT_START("IN0")
468   PORT_START("KEY.0")
481469   PORT_BIT ( 0xfffffff0, IP_ACTIVE_LOW, IPT_UNUSED ) // explicitely discarded
482470   PORT_BIT ( 0x00000001, IP_ACTIVE_LOW, IPT_MAHJONG_D )
483471   PORT_BIT ( 0x00000002, IP_ACTIVE_LOW, IPT_MAHJONG_H )
484472   PORT_BIT ( 0x00000004, IP_ACTIVE_LOW, IPT_MAHJONG_L )
485473   PORT_BIT ( 0x00000008, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
486474
487   PORT_START("IN1")
475   PORT_START("KEY.1")
488476   PORT_BIT ( 0xffffffc0, IP_ACTIVE_LOW, IPT_UNUSED ) // explicitely discarded
489477   PORT_BIT ( 0x00000001, IP_ACTIVE_LOW, IPT_MAHJONG_A )
490478   PORT_BIT ( 0x00000002, IP_ACTIVE_LOW, IPT_MAHJONG_E )
r243427r243428
493481   PORT_BIT ( 0x00000010, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
494482   PORT_BIT ( 0x00000020, IP_ACTIVE_LOW, IPT_START1 )
495483
496   PORT_START("IN2")
484   PORT_START("KEY.2")
497485   PORT_BIT ( 0xffffffe0, IP_ACTIVE_LOW, IPT_UNUSED ) // explicitely discarded
498486   PORT_BIT ( 0x00000001, IP_ACTIVE_LOW, IPT_MAHJONG_B )
499487   PORT_BIT ( 0x00000002, IP_ACTIVE_LOW, IPT_MAHJONG_F )
r243427r243428
501489   PORT_BIT ( 0x00000008, IP_ACTIVE_LOW, IPT_MAHJONG_N )
502490   PORT_BIT ( 0x00000010, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )
503491
504   PORT_START("IN3")
492   PORT_START("KEY.3")
505493   PORT_BIT ( 0xffffff60, IP_ACTIVE_LOW, IPT_UNUSED ) // explicitely discarded
506494   PORT_BIT ( 0x00000001, IP_ACTIVE_LOW, IPT_MAHJONG_C )
507495   PORT_BIT ( 0x00000002, IP_ACTIVE_LOW, IPT_MAHJONG_G )
r243427r243428
568556   MCFG_SCREEN_VISIBLE_AREA(0*8, 42*8-1, 2*8, 32*8-1)
569557   MCFG_SCREEN_UPDATE_DRIVER(srmp5_state, screen_update_srmp5)
570558
571   MCFG_PALETTE_ADD("palette", 0x1800)
559   MCFG_PALETTE_ADD("palette", 0x10000) // 0x20000? only first 0x1800 entries seem to be used outside memory test
560   MCFG_PALETTE_FORMAT(xBBBBBGGGGGRRRRR)
561   MCFG_PALETTE_MEMBITS(16)
562
572563#ifdef DEBUG_CHAR
573564   MCFG_GFXDECODE_ADD("gfxdecode", "palette", srmp5 )
574565#endif
575   //MCFG_VIDEO_START_OVERRIDE(st0016_state,st0016)
576566
577567MACHINE_CONFIG_END
578568
r243427r243428
581571   ROM_LOAD( "sx008-08.bin",   0x000000, 0x200000,   CRC(d4ac54f4) SHA1(c3dc76cd71485796a0b6a960294ea96eae8c946e) )
582572   ROM_LOAD( "sx008-09.bin",   0x200000, 0x200000,   CRC(5a3e6560) SHA1(92ea398f3c5e3035869f0ca5dfe7b05c90095318) )
583573
584   ROM_REGION32_BE( 0x200000, "user1", 0 )
585   ROM_LOAD32_BYTE( "sx008-14.bin",   0x00000, 0x80000,   CRC(b5c55120) SHA1(0a41351c9563b2c6a00709189a917757bd6e0a24) )
586   ROM_LOAD32_BYTE( "sx008-13.bin",   0x00001, 0x80000,   CRC(0af475e8) SHA1(24cddffa0f8c81832ae8870823d772e3b7493194) )
587   ROM_LOAD32_BYTE( "sx008-12.bin",   0x00002, 0x80000,   CRC(43e9bb98) SHA1(e46dd98d2e1babfa12ddf2fa9b31377e8691d3a1) )
588   ROM_LOAD32_BYTE( "sx008-11.bin",   0x00003, 0x80000,   CRC(ca15ff45) SHA1(5ee610e0bb835568c36898210a6f8394902d5b54) )
574   ROM_REGION( 0x200000, "sub", 0 ) // "PRG00" - "PRG03"
575   ROM_LOAD32_BYTE( "sx008-11.bin",   0x00000, 0x80000,   CRC(ca15ff45) SHA1(5ee610e0bb835568c36898210a6f8394902d5b54) )
576   ROM_LOAD32_BYTE( "sx008-12.bin",   0x00001, 0x80000,   CRC(43e9bb98) SHA1(e46dd98d2e1babfa12ddf2fa9b31377e8691d3a1) )
577   ROM_LOAD32_BYTE( "sx008-13.bin",   0x00002, 0x80000,   CRC(0af475e8) SHA1(24cddffa0f8c81832ae8870823d772e3b7493194) )
578   ROM_LOAD32_BYTE( "sx008-14.bin",   0x00003, 0x80000,   CRC(b5c55120) SHA1(0a41351c9563b2c6a00709189a917757bd6e0a24) )
589579
590   ROM_REGION( 0xf00000, "user2",0) /* gfx ? */
580   ROM_REGION16_LE( 0x1000000, "chr",0) // "CHR00" - "CHR06"
591581   ROM_LOAD( "sx008-01.bin",   0x000000, 0x200000,   CRC(82dabf48) SHA1(c53e9ed0056c431eab13ab362936c25d3cc5abba) )
592582   ROM_LOAD( "sx008-02.bin",   0x200000, 0x200000,   CRC(cfd2be0f) SHA1(a21f2928e08047c97443123aceba7ff4e95c6d3d) )
593583   ROM_LOAD( "sx008-03.bin",   0x400000, 0x200000,   CRC(d7323b10) SHA1(94ecc17b6b8b071cf2c61bbef4aec2c6c7693c62) )
r243427r243428
607597
608598   m_tileram = auto_alloc_array(machine(), UINT16, 0x100000/2);
609599   m_sprram  = auto_alloc_array(machine(), UINT16, 0x080000/2);
610   m_palram  = auto_alloc_array(machine(), UINT16, 0x040000/2);
611600#ifdef DEBUG_CHAR
612601   memset(m_tileduty, 1, 0x2000);
613602#endif


Previous 199869 Revisions Next


© 1997-2024 The MAME Team