5959#include " speaker.h"
6060#include " tilemap.h"
6161
62+ #include < algorithm>
63+
6264
6365namespace {
6466
@@ -68,10 +70,11 @@ class mole_state : public driver_device
6870 mole_state (const machine_config &mconfig, device_type type, const char *tag) :
6971 driver_device (mconfig, type, tag),
7072 m_maincpu (*this , " maincpu" ),
71- m_gfxdecode (*this , " gfxdecode" )
73+ m_gfxdecode (*this , " gfxdecode" ),
74+ m_tileram (*this , " tileram" , 0x400 *2 , ENDIANNESS_LITTLE)
7275 { }
7376
74- void mole (machine_config &config);
77+ void mole (machine_config &config) ATTR_COLD ;
7578
7679protected:
7780 virtual void video_start () override ATTR_COLD;
@@ -80,21 +83,21 @@ class mole_state : public driver_device
8083 required_device<cpu_device> m_maincpu;
8184 required_device<gfxdecode_device> m_gfxdecode;
8285
86+ memory_share_creator<uint16_t > m_tileram;
87+
8388 /* video-related */
8489 tilemap_t *m_bg_tilemap = nullptr ;
8590 uint8_t m_tile_bank = 0 ;
8691
87- /* memory */
88- uint16_t m_tileram[0x400 ];
89-
90- void mole_tileram_w (offs_t offset, uint8_t data);
91- void mole_tilebank_w (uint8_t data);
92- void mole_irqack_w (uint8_t data);
93- void mole_flipscreen_w (uint8_t data);
94- uint8_t mole_protection_r (offs_t offset);
92+ void tileram_w (offs_t offset, uint8_t data);
93+ void tilebank_w (uint8_t data);
94+ void irqack_w (uint8_t data);
95+ void flipscreen_w (uint8_t data);
96+ uint8_t protection_r (offs_t offset);
9597 TILE_GET_INFO_MEMBER (get_bg_tile_info);
96- uint32_t screen_update_mole (screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
97- void mole_map (address_map &map) ATTR_COLD;
98+ uint32_t screen_update (screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
99+
100+ void main_map (address_map &map) ATTR_COLD;
98101};
99102
100103
@@ -106,42 +109,41 @@ class mole_state : public driver_device
106109
107110TILE_GET_INFO_MEMBER (mole_state::get_bg_tile_info)
108111{
109- uint16_t code = m_tileram[tile_index];
112+ uint16_t const code = m_tileram[tile_index];
110113
111- tileinfo.set ((code & 0x200 ) ? 1 : 0 , code & 0x1ff , 0 , 0 );
114+ tileinfo.set (BIT (code, 9 ) , code & 0x1ff , 0 , 0 );
112115}
113116
114117void mole_state::video_start ()
115118{
116- memset ( m_tileram, 0 , sizeof ( m_tileram) );
119+ std::fill_n (& m_tileram[ 0 ], m_tileram. length (), 0 );
117120 m_bg_tilemap = &machine ().tilemap ().create (*m_gfxdecode, tilemap_get_info_delegate (*this , FUNC (mole_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8 , 8 , 40 , 25 );
118121
119- save_item (NAME (m_tileram));
120122 save_item (NAME (m_tile_bank));
121123}
122124
123- void mole_state::mole_tileram_w (offs_t offset, uint8_t data)
125+ void mole_state::tileram_w (offs_t offset, uint8_t data)
124126{
125127 m_tileram[offset] = data | (m_tile_bank << 8 );
126128 m_bg_tilemap->mark_tile_dirty (offset);
127129}
128130
129- void mole_state::mole_tilebank_w (uint8_t data)
131+ void mole_state::tilebank_w (uint8_t data)
130132{
131133 m_tile_bank = data;
132134}
133135
134- void mole_state::mole_irqack_w (uint8_t data)
136+ void mole_state::irqack_w (uint8_t data)
135137{
136138 m_maincpu->set_input_line (0 , CLEAR_LINE);
137139}
138140
139- void mole_state::mole_flipscreen_w (uint8_t data)
141+ void mole_state::flipscreen_w (uint8_t data)
140142{
141- flip_screen_set (data & 0x01 );
143+ flip_screen_set (BIT ( data, 0 ) );
142144}
143145
144- uint32_t mole_state::screen_update_mole (screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
146+ uint32_t mole_state::screen_update (screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
145147{
146148 m_bg_tilemap->draw (screen, bitmap, cliprect, 0 , 0 );
147149 return 0 ;
@@ -154,7 +156,7 @@ uint32_t mole_state::screen_update_mole(screen_device &screen, bitmap_ind16 &bit
154156 *
155157 *************************************/
156158
157- uint8_t mole_state::mole_protection_r (offs_t offset)
159+ uint8_t mole_state::protection_r (offs_t offset)
158160{
159161 /* Following are all known examples of Mole Attack
160162 ** code reading from the protection circuitry:
@@ -209,23 +211,23 @@ uint8_t mole_state::mole_protection_r(offs_t offset)
209211 *
210212 *************************************/
211213
212- void mole_state::mole_map (address_map &map)
214+ void mole_state::main_map (address_map &map)
213215{
214216 map (0x0000 , 0x03ff ).ram ();
215- map (0x0800 , 0x08ff ).r (FUNC (mole_state::mole_protection_r ));
217+ map (0x0800 , 0x08ff ).r (FUNC (mole_state::protection_r ));
216218 map (0x0800 , 0x0800 ).nopw (); // ???
217219 map (0x0820 , 0x0820 ).nopw (); // ???
218220 map (0x5000 , 0x7fff ).mirror (0x8000 ).rom ();
219- map (0x8000 , 0x83ff ).w (FUNC (mole_state::mole_tileram_w )).nopr ();
220- map (0x8400 , 0x8400 ).w (FUNC (mole_state::mole_tilebank_w ));
221+ map (0x8000 , 0x83ff ).w (FUNC (mole_state::tileram_w )).nopr ();
222+ map (0x8400 , 0x8400 ).w (FUNC (mole_state::tilebank_w ));
221223 map (0x8c00 , 0x8c01 ).w (" aysnd" , FUNC (ay8910_device::data_address_w));
222224 map (0x8c40 , 0x8c40 ).nopw (); // ???
223225 map (0x8c80 , 0x8c80 ).nopw (); // ???
224226 map (0x8c81 , 0x8c81 ).nopw (); // ???
225- map (0x8d00 , 0x8d00 ).portr (" DSW" ).w (FUNC (mole_state::mole_irqack_w ));
227+ map (0x8d00 , 0x8d00 ).portr (" DSW" ).w (FUNC (mole_state::irqack_w ));
226228 map (0x8d40 , 0x8d40 ).portr (" IN0" );
227229 map (0x8d80 , 0x8d80 ).portr (" IN1" );
228- map (0x8dc0 , 0x8dc0 ).portr (" IN2" ).w (FUNC (mole_state::mole_flipscreen_w ));
230+ map (0x8dc0 , 0x8dc0 ).portr (" IN2" ).w (FUNC (mole_state::flipscreen_w ));
229231}
230232
231233
@@ -307,8 +309,8 @@ static const gfx_layout tile_layout =
307309
308310
309311static GFXDECODE_START ( gfx_mole )
310- GFXDECODE_ENTRY( " gfx1 " , 0x0000 , tile_layout, 0x00 , 1 )
311- GFXDECODE_ENTRY( " gfx1 " , 0x3000 , tile_layout, 0x00 , 1 )
312+ GFXDECODE_ENTRY( " gfx " , 0x0000 , tile_layout, 0x00 , 1 )
313+ GFXDECODE_ENTRY( " gfx " , 0x3000 , tile_layout, 0x00 , 1 )
312314GFXDECODE_END
313315
314316
@@ -321,8 +323,8 @@ GFXDECODE_END
321323void mole_state::mole(machine_config &config)
322324{
323325 /* basic machine hardware */
324- M6502 (config, m_maincpu, 2000000 ); // ???
325- m_maincpu->set_addrmap (AS_PROGRAM, &mole_state::mole_map );
326+ M6502 (config, m_maincpu, 2'000'000 ); // ???
327+ m_maincpu->set_addrmap (AS_PROGRAM, &mole_state::main_map );
326328 m_maincpu->set_vblank_int (" screen" , FUNC (mole_state::irq0_line_assert));
327329
328330 /* video hardware */
@@ -331,7 +333,7 @@ void mole_state::mole(machine_config &config)
331333 screen.set_vblank_time (ATTOSECONDS_IN_USEC (2500 ));
332334 screen.set_size (40 *8 , 25 *8 );
333335 screen.set_visarea (0 *8 , 40 *8 -1 , 0 *8 , 25 *8 -1 );
334- screen.set_screen_update (FUNC (mole_state::screen_update_mole ));
336+ screen.set_screen_update (FUNC (mole_state::screen_update ));
335337 screen.set_palette (" palette" );
336338
337339 GFXDECODE (config, m_gfxdecode, " palette" , gfx_mole);
@@ -356,7 +358,7 @@ ROM_START( mole ) // ALL ROMS ARE 2732
356358 ROM_LOAD ( " m2a.7h" , 0x6000 , 0x1000 , CRC(f2a90642) SHA1(da6887725d70924fc4b9cca83172276976f5020c) )
357359 ROM_LOAD ( " m1a.8h" , 0x7000 , 0x1000 , CRC(cff0119a) SHA1(48fc81b8c68e977680e7b8baf1193f0e7e0cd013) )
358360
359- ROM_REGION ( 0x6000 , " gfx1 " , 0 )
361+ ROM_REGION ( 0x6000 , " gfx " , 0 )
360362 ROM_LOAD ( " mea.4a" , 0x0000 , 0x1000 , CRC(49d89116) SHA1(aa4cde07e10624072e50ba5bd209acf93092cf78) )
361363 ROM_LOAD ( " mca.6a" , 0x1000 , 0x1000 , CRC(04e90300 ) SHA1(c908a3a651e50428eedc2974160cdbf2ed946abc) )
362364 ROM_LOAD ( " maa.9a" , 0x2000 , 0x1000 , CRC(6ce9442b) SHA1(c08bf0911f1dfd4a3f9452efcbb3fd3688c4bf8c) )
0 commit comments