Skip to content

Commit a5ec778

Browse files
authored
taito/minivadr.cpp: Cleaned up code: (#13397)
Restrict drawing to clipping rectangle, reduced literal tag usage, improved member names.
1 parent 72daadc commit a5ec778

File tree

1 file changed

+26
-30
lines changed

1 file changed

+26
-30
lines changed

src/mame/taito/minivadr.cpp

+26-30
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
/***************************************************************************
44
55
Mini Vaders (Space Invaders's mini game)
6-
(c)1990 Taito Corporation
6+
(c) 1990 Taito Corporation
77
88
Driver by Takahiro Nogi 1999/12/19 -
99
10-
This is a test board sold together with the cabinet (as required by law in
11-
Japan). It has no sound.
10+
This is a test board sold together with cabinets (as required by law in
11+
Japan). It has no sound.
1212
1313
PCB Layout
1414
----------
@@ -45,18 +45,20 @@ class minivadr_state : public driver_device
4545
{
4646
public:
4747
minivadr_state(const machine_config &mconfig, device_type type, const char *tag)
48-
: driver_device(mconfig, type, tag),
49-
m_videoram(*this, "videoram"),
50-
m_maincpu(*this, "maincpu") { }
48+
: driver_device(mconfig, type, tag)
49+
, m_videoram(*this, "videoram")
50+
, m_maincpu(*this, "maincpu")
51+
{}
5152

52-
void minivadr(machine_config &config);
53+
void minivadr(machine_config &config) ATTR_COLD;
5354

5455
private:
55-
/* memory pointers */
5656
required_shared_ptr<uint8_t> m_videoram;
57-
uint32_t screen_update_minivadr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
5857
required_device<cpu_device> m_maincpu;
59-
void minivadr_map(address_map &map) ATTR_COLD;
58+
59+
uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
60+
61+
void main_map(address_map &map) ATTR_COLD;
6062
};
6163

6264
/*************************************
@@ -65,32 +67,26 @@ class minivadr_state : public driver_device
6567
*
6668
*************************************/
6769

68-
uint32_t minivadr_state::screen_update_minivadr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
70+
uint32_t minivadr_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
6971
{
70-
for (offs_t offs = 0; offs < m_videoram.bytes(); offs++)
72+
for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
7173
{
72-
uint8_t x = offs << 3;
73-
const int y = offs >> 5;
74-
uint8_t data = m_videoram[offs];
75-
76-
for (int i = 0; i < 8; i++)
74+
uint8_t const *const src = &m_videoram[y << 5];
75+
uint32_t *const dst = &bitmap.pix(y);
76+
for (int x = cliprect.left(); x <= cliprect.right(); x++)
7777
{
78-
pen_t pen = (data & 0x80) ? rgb_t::white() : rgb_t::black();
79-
bitmap.pix(y, x) = pen;
80-
81-
data <<= 1;
82-
x++;
78+
dst[x] = BIT(src[x >> 3], ~x & 7) ? rgb_t::white() : rgb_t::black();
8379
}
8480
}
8581

8682
return 0;
8783
}
8884

8985

90-
void minivadr_state::minivadr_map(address_map &map)
86+
void minivadr_state::main_map(address_map &map)
9187
{
9288
map(0x0000, 0x1fff).rom();
93-
map(0xa000, 0xbfff).ram().share("videoram");
89+
map(0xa000, 0xbfff).ram().share(m_videoram);
9490
map(0xe008, 0xe008).portr("INPUTS").nopw(); // W - ???
9591
}
9692

@@ -110,20 +106,20 @@ INPUT_PORTS_END
110106

111107
void minivadr_state::minivadr(machine_config &config)
112108
{
113-
/* basic machine hardware */
114-
Z80(config, m_maincpu, XTAL(24'000'000) / 6);
115-
m_maincpu->set_addrmap(AS_PROGRAM, &minivadr_state::minivadr_map);
109+
// basic machine hardware
110+
Z80(config, m_maincpu, 24_MHz_XTAL / 6);
111+
m_maincpu->set_addrmap(AS_PROGRAM, &minivadr_state::main_map);
116112
m_maincpu->set_vblank_int("screen", FUNC(minivadr_state::irq0_line_hold));
117113

118-
/* video hardware */
114+
// video hardware
119115
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
120116
screen.set_refresh_hz(60);
121117
screen.set_vblank_time(ATTOSECONDS_IN_USEC(0));
122118
screen.set_size(256, 256);
123119
screen.set_visarea(0, 256-1, 16, 240-1);
124-
screen.set_screen_update(FUNC(minivadr_state::screen_update_minivadr));
120+
screen.set_screen_update(FUNC(minivadr_state::screen_update));
125121

126-
/* the board has no sound hardware */
122+
// the board has no sound hardware
127123
}
128124

129125

0 commit comments

Comments
 (0)