tutankhm: small cleanup (nw)

This commit is contained in:
hap 2019-05-30 13:54:26 +02:00
parent 209f56e182
commit 23ab51f538
3 changed files with 22 additions and 46 deletions

View File

@ -250,7 +250,6 @@ static INPUT_PORTS_START( tutankhm )
PORT_CONFNAME( 0x01, 0x01, "Starfield selection" )
PORT_CONFSETTING( 0x00, "Konami HW bootleg (6MHz stars)" )
PORT_CONFSETTING( 0x01, "Scramble implementation" )
INPUT_PORTS_END
@ -313,7 +312,6 @@ void tutankhm_state::tutankhm(machine_config &config)
/* blinking frequency is determined by 555 counter with Ra=100k, Rb=10k, C=10uF */
TIMER(config, "stars").configure_periodic(FUNC(tutankhm_state::scramble_stars_blink_timer), PERIOD_OF_555_ASTABLE(100000, 10000, 0.00001));
}

View File

@ -34,7 +34,8 @@ public:
m_maincpu(*this, "maincpu"),
m_palette(*this, "palette"),
m_screen(*this, "screen"),
m_timeplt_audio(*this, "timeplt_audio")
m_timeplt_audio(*this, "timeplt_audio"),
m_stars_config(*this, "STARS")
{
}
@ -77,10 +78,12 @@ protected:
required_device<palette_device> m_palette;
required_device<screen_device> m_screen;
optional_device<timeplt_audio_device> m_timeplt_audio;
optional_ioport m_stars_config;
TIMER_DEVICE_CALLBACK_MEMBER(scramble_stars_blink_timer);
DECLARE_WRITE8_MEMBER(galaxian_stars_enable_w);
void stars_init();
void stars_init_scramble();
void stars_init_bootleg();
void stars_draw_row(bitmap_rgb32 &bitmap, int maxx, int y, uint32_t star_offs);
void scramble_draw_stars(bitmap_rgb32 &bitmap, const rectangle &cliprect, int maxx);
@ -91,7 +94,6 @@ protected:
std::unique_ptr<uint8_t[]> m_stars;
uint8_t m_stars_enabled;
uint8_t m_stars_blink_state;
};
#endif // MAME_INCLUDES_TUTANKHM_H

View File

@ -124,30 +124,17 @@ uint32_t tutankhm_state::screen_update_tutankhm_scramble(screen_device &screen,
uint32_t tutankhm_state::screen_update_tutankhm(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
ioport_port *port = ioport("STARS");
if (port != nullptr)
u8 mode = m_stars_config.read_safe(m_star_mode);
if (mode != m_star_mode)
{
int newset = port->read();
if (newset != m_star_mode)
{
m_star_mode = newset;
switch (newset)
{
case 0:
stars_init_bootleg();
break;
case 1:
stars_init();
break;
}
}
m_star_mode = mode;
stars_init();
}
if (m_star_mode)
return screen_update_tutankhm_scramble(screen, bitmap, cliprect);
else
return screen_update_tutankhm_bootleg(screen, bitmap, cliprect);
}
/*************************************
@ -270,42 +257,38 @@ void tutankhm_state::galaxian_palette(palette_device &palette)
// set the RGB color
m_star_color[i] = rgb_t(r, g, b);
}
}
void tutankhm_state::video_start()
{
/* initialize globals */
m_flipscreen_x = 0;
m_flipscreen_y = 0;
/* initialize stars */
m_stars_enabled = 0;
m_stars_blink_state = 0;
/* initialize stars */
if (m_star_mode)
stars_init();
else
stars_init_bootleg();
stars_init();
galaxian_palette(*m_palette);
}
void tutankhm_state::stars_init()
{
(m_star_mode) ? stars_init_scramble() : stars_init_bootleg();
}
void tutankhm_state::stars_init_bootleg()
{
uint32_t shiftreg;
int i;
/* reset the blink and enabled states */
m_stars_enabled = false;
m_stars_blink_state = 0;
/* precalculate the RNG */
m_stars = std::make_unique<uint8_t[]>(STAR_RNG_PERIOD);
shiftreg = 0;
for (i = 0; i < STAR_RNG_PERIOD; i++)
uint32_t shiftreg = 0;
for (int i = 0; i < STAR_RNG_PERIOD; i++)
{
int newbit = ((shiftreg >> 12) ^ ~shiftreg) & 1;
@ -324,16 +307,12 @@ void tutankhm_state::stars_init_bootleg()
}
}
void tutankhm_state::stars_init()
void tutankhm_state::stars_init_scramble()
{
uint32_t shiftreg;
int i;
/* precalculate the RNG */
m_stars = std::make_unique<uint8_t[]>(STAR_RNG_PERIOD);
shiftreg = 0;
for (i = 0; i < STAR_RNG_PERIOD; i++)
uint32_t shiftreg = 0;
for (int i = 0; i < STAR_RNG_PERIOD; i++)
{
const uint8_t shift = 12;
/* stars are enabled if the upper 8 bits are 1 and the low bit is 0 */
@ -366,14 +345,13 @@ TIMER_DEVICE_CALLBACK_MEMBER(tutankhm_state::scramble_stars_blink_timer)
void tutankhm_state::stars_draw_row(bitmap_rgb32 &bitmap, int maxx, int y, uint32_t star_offs)
{
int x;
uint8_t flipxor = (m_flipscreen_x ? 0xC0 : 0x00);
/* ensure our star offset is valid */
star_offs %= STAR_RNG_PERIOD;
/* iterate over the specified number of 6MHz pixels */
for (x = 0; x < maxx; x++)
for (int x = 0; x < maxx; x++)
{
uint8_t h8q = ((x>>3) & 1) ^ 1; // H8 signal is inverted.
/* stars are suppressed unless V1 ^ H8 == 1 */
@ -436,10 +414,8 @@ void tutankhm_state::scramble_draw_stars(bitmap_rgb32 &bitmap, const rectangle &
/* render stars if enabled */
if (m_stars_enabled)
{
int y;
/* iterate over scanlines */
for (y = cliprect.min_y; y <= cliprect.max_y; y++)
for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
{
stars_draw_row(bitmap, maxx, y, y * 512);
}