Previous 199869 Revisions Next

r20918 Sunday 10th February, 2013 at 22:18:41 UTC by Wilbert Pol
nightgal.c: Reduce tagmap lookups (nw)
[src/mame/drivers]nightgal.c

trunk/src/mame/drivers/nightgal.c
r20917r20918
3131{
3232public:
3333   nightgal_state(const machine_config &mconfig, device_type type, const char *tag)
34      : driver_device(mconfig, type, tag) ,
35      m_comms_ram(*this, "comms_ram"){ }
34      : driver_device(mconfig, type, tag)
35      , m_comms_ram(*this, "comms_ram")
36      , m_region_gfx1(*this, "gfx1")
37      , m_io_cr_clear(*this, "CR_CLEAR")
38      , m_io_coins(*this, "COINS")
39      , m_io_pl1_1(*this, "PL1_1")
40      , m_io_pl1_2(*this, "PL1_2")
41      , m_io_pl1_3(*this, "PL1_3")
42      , m_io_pl1_4(*this, "PL1_4")
43      , m_io_pl1_5(*this, "PL1_5")
44      , m_io_pl1_6(*this, "PL1_6")
45      , m_io_pl2_1(*this, "PL2_1")
46      , m_io_pl2_2(*this, "PL2_2")
47      , m_io_pl2_3(*this, "PL2_3")
48      , m_io_pl2_4(*this, "PL2_4")
49      , m_io_pl2_5(*this, "PL2_5")
50      , m_io_pl2_6(*this, "PL2_6")
51      , m_io_system(*this, "SYSTEM")
52      , m_io_sysa(*this, "SYSA")
53      , m_io_dswa(*this, "DSWA")
54      , m_io_dswb(*this, "DSWB")
55      , m_io_dswc(*this, "DSWC")
3656
57   { }
58
3759   /* video-related */
3860   UINT8 m_blit_raw_data[3];
3961   UINT8 m_true_blit[7];
r20917r20918
81103   virtual void video_start();
82104   virtual void palette_init();
83105   UINT32 screen_update_nightgal(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
106
107protected:
108   required_memory_region m_region_gfx1;
109   required_ioport m_io_cr_clear;
110   required_ioport m_io_coins;
111   required_ioport m_io_pl1_1;
112   required_ioport m_io_pl1_2;
113   required_ioport m_io_pl1_3;
114   required_ioport m_io_pl1_4;
115   required_ioport m_io_pl1_5;
116   required_ioport m_io_pl1_6;
117   required_ioport m_io_pl2_1;
118   required_ioport m_io_pl2_2;
119   required_ioport m_io_pl2_3;
120   required_ioport m_io_pl2_4;
121   required_ioport m_io_pl2_5;
122   required_ioport m_io_pl2_6;
123   required_ioport m_io_system;
124   required_ioport m_io_sysa;
125   required_ioport m_io_dswa;
126   required_ioport m_io_dswb;
127   required_ioport m_io_dswc;
128
129   UINT8 nightgal_gfx_nibble( int niboffset );
84130};
85131
86132
r20917r20918
116162   return 0;
117163}
118164
119static UINT8 nightgal_gfx_nibble( running_machine &machine, int niboffset )
165UINT8 nightgal_state::nightgal_gfx_nibble( int niboffset )
120166{
121   UINT8 *blit_rom = machine.root_device().memregion("gfx1")->base();
167   UINT8 *blit_rom = m_region_gfx1->base();
122168
123169   if (niboffset & 1)
124170   {
r20917r20918
178224            {
179225               int drawx = (x + xcount) & 0xff;
180226               int drawy = (y + ycount) & 0xff;
181               UINT8 dat = nightgal_gfx_nibble(machine(), src + count);
227               UINT8 dat = nightgal_gfx_nibble(src + count);
182228               UINT8 cur_pen_hi = m_pen_data[(dat & 0xf0) >> 4];
183229               UINT8 cur_pen_lo = m_pen_data[(dat & 0x0f) >> 0];
184230
r20917r20918
233279            {
234280               int drawx = (x + xcount) & 0xff;
235281               int drawy = (y + ycount) & 0xff;
236               UINT8 dat = nightgal_gfx_nibble(machine(), src + count);
282               UINT8 dat = nightgal_gfx_nibble(src + count);
237283               UINT8 cur_pen_hi = m_pen_data[(dat & 0xf0) >> 4];
238284               UINT8 cur_pen_lo = m_pen_data[(dat & 0x0f) >> 0];
239285
r20917r20918
421467
422468READ8_MEMBER(nightgal_state::input_1p_r)
423469{
424   UINT8 cr_clear = ioport("CR_CLEAR")->read();
470   UINT8 cr_clear = m_io_cr_clear->read();
425471
426472   switch (m_mux_data)
427473   {
428      case 0x01: return ioport("PL1_1")->read() | cr_clear;
429      case 0x02: return ioport("PL1_2")->read() | cr_clear;
430      case 0x04: return ioport("PL1_3")->read() | cr_clear;
431      case 0x08: return ioport("PL1_4")->read() | cr_clear;
432      case 0x10: return ioport("PL1_5")->read() | cr_clear;
433      case 0x20: return ioport("PL1_6")->read() | cr_clear;
474      case 0x01: return m_io_pl1_1->read() | cr_clear;
475      case 0x02: return m_io_pl1_2->read() | cr_clear;
476      case 0x04: return m_io_pl1_3->read() | cr_clear;
477      case 0x08: return m_io_pl1_4->read() | cr_clear;
478      case 0x10: return m_io_pl1_5->read() | cr_clear;
479      case 0x20: return m_io_pl1_6->read() | cr_clear;
434480   }
435481   //printf("%04x\n", m_mux_data);
436482
437   return (ioport("PL1_1")->read() & ioport("PL1_2")->read() & ioport("PL1_3")->read() &
438         ioport("PL1_4")->read() & ioport("PL1_5")->read() & ioport("PL1_6")->read()) | cr_clear;
483   return (m_io_pl1_1->read() & m_io_pl1_2->read() & m_io_pl1_3->read() &
484         m_io_pl1_4->read() & m_io_pl1_5->read() & m_io_pl1_6->read()) | cr_clear;
439485}
440486
441487READ8_MEMBER(nightgal_state::input_2p_r)
442488{
443   UINT8 coin_port = ioport("COINS")->read();
489   UINT8 coin_port = m_io_coins->read();
444490
445491   switch (m_mux_data)
446492   {
447      case 0x01: return ioport("PL2_1")->read() | coin_port;
448      case 0x02: return ioport("PL2_2")->read() | coin_port;
449      case 0x04: return ioport("PL2_3")->read() | coin_port;
450      case 0x08: return ioport("PL2_4")->read() | coin_port;
451      case 0x10: return ioport("PL2_5")->read() | coin_port;
452      case 0x20: return ioport("PL2_6")->read() | coin_port;
493      case 0x01: return m_io_pl2_1->read() | coin_port;
494      case 0x02: return m_io_pl2_2->read() | coin_port;
495      case 0x04: return m_io_pl2_3->read() | coin_port;
496      case 0x08: return m_io_pl2_4->read() | coin_port;
497      case 0x10: return m_io_pl2_5->read() | coin_port;
498      case 0x20: return m_io_pl2_6->read() | coin_port;
453499   }
454500   //printf("%04x\n", m_mux_data);
455501
456   return (ioport("PL2_1")->read() & ioport("PL2_2")->read() & ioport("PL2_3")->read() &
457         ioport("PL2_4")->read() & ioport("PL2_5")->read() & ioport("PL2_6")->read()) | coin_port;
502   return (m_io_pl2_1->read() & m_io_pl2_2->read() & m_io_pl2_3->read() &
503         m_io_pl2_4->read() & m_io_pl2_5->read() & m_io_pl2_6->read()) | coin_port;
458504}
459505
460506/********************************************

Previous 199869 Revisions Next


© 1997-2024 The MAME Team