mirror of
https://github.com/holub/mame
synced 2025-04-20 15:32:45 +03:00
ladybug: move zerohour stars to its own file (redclash driver now doesn't weirdly include ladybug_v anymore)
This commit is contained in:
parent
1596c89b59
commit
179afe2036
@ -47,6 +47,9 @@ Coin insertion in left slot generates a NMI, in right slot an IRQ.
|
||||
TODO:
|
||||
- Coin lockouts are missing. The game only accepts 9 coins, so there has to be
|
||||
a lockout call somewhere.
|
||||
- split into 2 drivers (ladybug, mrsdyna/sraider), not much common code since
|
||||
the bg/sprites are already in a device. ladybug_video device can be put into
|
||||
a separate file.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -67,7 +70,7 @@ decode cpu#2 writes to port 0x28-0x2f - ???
|
||||
examine other bits from cpu#2 write to 0xe800
|
||||
unknown dips
|
||||
|
||||
***************************************************************************/
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "ladybug.h"
|
||||
@ -1182,12 +1185,12 @@ void dorodon_state::init_dorodon()
|
||||
}
|
||||
|
||||
|
||||
GAME( 1981, cavenger, 0, ladybug, cavenger, ladybug_state, empty_init, ROT0, "Universal", "Cosmic Avenger", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1981, ladybug, 0, ladybug, ladybug, ladybug_state, empty_init, ROT270, "Universal", "Lady Bug", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1981, ladybugb, ladybug, ladybug, ladybug, ladybug_state, empty_init, ROT270, "bootleg", "Lady Bug (bootleg set 1)", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1981, ladybugb2, ladybug, ladybug, ladybug, ladybug_state, empty_init, ROT270, "bootleg (Model Racing)", "Coccinelle (bootleg of Lady Bug, set 2)", MACHINE_SUPPORTS_SAVE ) // title removed, but manual names it Coccinelle
|
||||
GAME( 1981, snapjack, 0, ladybug, snapjack, ladybug_state, empty_init, ROT0, "Universal", "Snap Jack", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1982, dorodon, 0, dorodon, dorodon, dorodon_state, init_dorodon, ROT270, "UPL (Falcon license?)", "Dorodon (set 1)", MACHINE_SUPPORTS_SAVE ) // license or bootleg?
|
||||
GAME( 1982, dorodon2, dorodon, dorodon, dorodon, dorodon_state, init_dorodon, ROT270, "UPL (Falcon license?)", "Dorodon (set 2)", MACHINE_SUPPORTS_SAVE ) // "
|
||||
GAME( 1982, mrsdyna, 0, mrsdyna, mrsdyna, mrsdyna_state, empty_init, ROT270, "Universal", "Mrs. Dynamite", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1982, sraider, 0, sraider, sraider, sraider_state, empty_init, ROT270, "Universal", "Space Raider", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1981, cavenger, 0, ladybug, cavenger, ladybug_state, empty_init, ROT0, "Universal", "Cosmic Avenger", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1981, ladybug, 0, ladybug, ladybug, ladybug_state, empty_init, ROT270, "Universal", "Lady Bug", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1981, ladybugb, ladybug, ladybug, ladybug, ladybug_state, empty_init, ROT270, "bootleg", "Lady Bug (bootleg)", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1981, ladybugb2, ladybug, ladybug, ladybug, ladybug_state, empty_init, ROT270, "bootleg (Model Racing)", "Coccinelle (bootleg of Lady Bug)", MACHINE_SUPPORTS_SAVE ) // title removed, but manual names it Coccinelle
|
||||
GAME( 1981, snapjack, 0, ladybug, snapjack, ladybug_state, empty_init, ROT0, "Universal", "Snap Jack", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1982, dorodon, 0, dorodon, dorodon, dorodon_state, init_dorodon, ROT270, "UPL (Falcon license?)", "Dorodon (set 1)", MACHINE_SUPPORTS_SAVE ) // license or bootleg?
|
||||
GAME( 1982, dorodon2, dorodon, dorodon, dorodon, dorodon_state, init_dorodon, ROT270, "UPL (Falcon license?)", "Dorodon (set 2)", MACHINE_SUPPORTS_SAVE ) // "
|
||||
GAME( 1982, mrsdyna, 0, mrsdyna, mrsdyna, mrsdyna_state, empty_init, ROT270, "Universal", "Mrs. Dynamite", MACHINE_SUPPORTS_SAVE )
|
||||
GAME( 1982, sraider, 0, sraider, sraider, sraider_state, empty_init, ROT270, "Universal", "Space Raider", MACHINE_SUPPORTS_SAVE )
|
||||
|
@ -11,6 +11,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "ladybug_v.h"
|
||||
#include "zerohour_stars.h"
|
||||
#include "emupal.h"
|
||||
#include "tilemap.h"
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
|
||||
|
||||
DEFINE_DEVICE_TYPE(LADYBUG_VIDEO, ladybug_video_device, "ladybug_video", "Lady Bug/Space Raider background")
|
||||
DEFINE_DEVICE_TYPE(ZEROHOUR_STARS, zerohour_stars_device, "zerohour_stars", "Zero Hour/Red Clash/Space Raider starfield")
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@ -118,141 +117,6 @@ TILE_GET_INFO_MEMBER(ladybug_video_device::get_bg_tile_info)
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
zerohour/redclash/sraider stars
|
||||
|
||||
These functions emulate the star generator board
|
||||
All this comes from the schematics for Zero Hour
|
||||
|
||||
It has a 17-bit LFSR which has a period of 2^17-1 clocks
|
||||
(This is one pixel shy of "two screens" worth.)
|
||||
So, there are two starfields drawn on alternate frames
|
||||
These will scroll at a rate controlled by the speed register
|
||||
|
||||
I'm basically doing the same thing by drawing each
|
||||
starfield on alternate frames, and then offseting them
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
zerohour_stars_device::zerohour_stars_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock)
|
||||
: device_t(mconfig, ZEROHOUR_STARS, tag, owner, clock)
|
||||
, m_enable(0)
|
||||
, m_speed(0)
|
||||
, m_offset(0)
|
||||
, m_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
// This line can reset the LFSR to zero and disables the star generator
|
||||
void zerohour_stars_device::set_enable(bool on)
|
||||
{
|
||||
if (!m_enable && on)
|
||||
m_offset = 0;
|
||||
|
||||
m_enable = on ? 1 : 0;
|
||||
}
|
||||
|
||||
// This sets up which starfield to draw and the offset, to be called from screen_vblank_*()
|
||||
void zerohour_stars_device::update_state()
|
||||
{
|
||||
if (m_enable)
|
||||
{
|
||||
m_count = m_count ? 0 : 1;
|
||||
if (!m_count)
|
||||
{
|
||||
m_offset += ((m_speed * 2) - 0x09);
|
||||
m_offset %= 256 * 256;
|
||||
m_state = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_state = 0x1fc71;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the speed register (3 bits)
|
||||
void zerohour_stars_device::set_speed(u8 speed, u8 mask)
|
||||
{
|
||||
// 0 left/down fastest (-9/2 pix per frame)
|
||||
// 1 left/down faster (-7/2 pix per frame)
|
||||
// 2 left/down fast (-5/2 pix per frame)
|
||||
// 3 left/down medium (-3/2 pix per frame)
|
||||
// 4 left/down slow (-1/2 pix per frame)
|
||||
// 5 right/up slow (+1/2 pix per frame)
|
||||
// 6 right/up medium (+3/2 pix per frame)
|
||||
// 7 right/up fast (+5/2 pix per frame)
|
||||
m_speed = (m_speed & ~mask) | (speed & mask);
|
||||
}
|
||||
|
||||
// Draw the stars
|
||||
// Space Raider doesn't use the Va bit, and it is also set up to window the stars to a certain x range
|
||||
void zerohour_stars_device::draw(bitmap_ind16 &bitmap, rectangle const &cliprect, u8 pal_offs, bool has_va, u8 firstx, u8 lastx)
|
||||
{
|
||||
if (m_enable)
|
||||
{
|
||||
u32 state(m_state);
|
||||
for (int i = 0; (256 * 256) > i; ++i)
|
||||
{
|
||||
u8 const xloc((m_offset + i) & 0x00ff);
|
||||
u8 const yloc(((m_offset + i) >> 8) & 0x00ff);
|
||||
|
||||
bool const tempbit(!(state & 0x10000));
|
||||
bool const feedback((state & 0x00020) ? !tempbit : tempbit);
|
||||
|
||||
bool const hcond(BIT(xloc + 8, 4));
|
||||
bool const vcond(!has_va || BIT(yloc, 0));
|
||||
|
||||
if (cliprect.contains(xloc, yloc) && (hcond == vcond))
|
||||
{
|
||||
if (((state & 0x000ff) == 0x000ff) && !feedback && (xloc >= firstx) && (xloc <= lastx))
|
||||
bitmap.pix(yloc, xloc) = pal_offs + ((state >> 9) & 0x1f);
|
||||
}
|
||||
|
||||
// update LFSR state
|
||||
state = ((state << 1) & 0x1fffe) | (feedback ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void zerohour_stars_device::device_start()
|
||||
{
|
||||
save_item(NAME(m_enable));
|
||||
save_item(NAME(m_speed));
|
||||
save_item(NAME(m_state));
|
||||
save_item(NAME(m_offset));
|
||||
save_item(NAME(m_count));
|
||||
}
|
||||
|
||||
void zerohour_stars_device::device_reset()
|
||||
{
|
||||
m_enable = 0;
|
||||
m_speed = 0;
|
||||
m_state = 0;
|
||||
m_offset = 0;
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
Convert the color PROMs into a more useable format.
|
||||
|
||||
Lady Bug has a 32 bytes palette PROM and a 32 bytes sprite color lookup
|
||||
table PROM.
|
||||
The palette PROM is connected to the RGB output this way:
|
||||
|
||||
bit 7 -- inverter -- 220 ohm resistor -- BLUE
|
||||
-- inverter -- 220 ohm resistor -- GREEN
|
||||
-- inverter -- 220 ohm resistor -- RED
|
||||
-- inverter -- 470 ohm resistor -- BLUE
|
||||
-- unused
|
||||
-- inverter -- 470 ohm resistor -- GREEN
|
||||
-- unused
|
||||
bit 0 -- inverter -- 470 ohm resistor -- RED
|
||||
|
||||
***************************************************************************/
|
||||
/***************************************************************************
|
||||
|
||||
Convert the color PROMs into a more useable format.
|
||||
|
@ -37,31 +37,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
// used by zerohour, redclash and sraider
|
||||
class zerohour_stars_device : public device_t
|
||||
{
|
||||
public:
|
||||
zerohour_stars_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock);
|
||||
|
||||
void set_enable(bool on);
|
||||
void update_state();
|
||||
void set_speed(u8 speed, u8 mask);
|
||||
void draw(bitmap_ind16 &bitmap, rectangle const &cliprect, u8 pal_offs, bool has_va, u8 firstx, u8 lastx);
|
||||
|
||||
protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
|
||||
private:
|
||||
u8 m_enable;
|
||||
u8 m_speed;
|
||||
u32 m_state = 0;
|
||||
u16 m_offset;
|
||||
u8 m_count;
|
||||
};
|
||||
|
||||
|
||||
DECLARE_DEVICE_TYPE(LADYBUG_VIDEO, ladybug_video_device)
|
||||
DECLARE_DEVICE_TYPE(ZEROHOUR_STARS, zerohour_stars_device)
|
||||
|
||||
#endif // MAME_VIDEO_LADYBUG_H
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ladybug_v.h"
|
||||
#include "zerohour_stars.h"
|
||||
#include "emupal.h"
|
||||
#include "tilemap.h"
|
||||
|
||||
|
125
src/mame/universal/zerohour_stars.cpp
Normal file
125
src/mame/universal/zerohour_stars.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Frank Palazzolo
|
||||
/***************************************************************************
|
||||
|
||||
zerohour/redclash/sraider stars
|
||||
|
||||
These functions emulate the star generator board
|
||||
All this comes from the schematics for Zero Hour
|
||||
|
||||
It has a 17-bit LFSR which has a period of 2^17-1 clocks
|
||||
(This is one pixel shy of "two screens" worth.)
|
||||
So, there are two starfields drawn on alternate frames
|
||||
These will scroll at a rate controlled by the speed register
|
||||
|
||||
I'm basically doing the same thing by drawing each
|
||||
starfield on alternate frames, and then offseting them
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "zerohour_stars.h"
|
||||
|
||||
|
||||
DEFINE_DEVICE_TYPE(ZEROHOUR_STARS, zerohour_stars_device, "zerohour_stars", "Zero Hour/Red Clash/Space Raider starfield")
|
||||
|
||||
|
||||
zerohour_stars_device::zerohour_stars_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock)
|
||||
: device_t(mconfig, ZEROHOUR_STARS, tag, owner, clock)
|
||||
, m_enable(0)
|
||||
, m_speed(0)
|
||||
, m_state(0)
|
||||
, m_offset(0)
|
||||
, m_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
void zerohour_stars_device::device_start()
|
||||
{
|
||||
save_item(NAME(m_enable));
|
||||
save_item(NAME(m_speed));
|
||||
save_item(NAME(m_state));
|
||||
save_item(NAME(m_offset));
|
||||
save_item(NAME(m_count));
|
||||
}
|
||||
|
||||
void zerohour_stars_device::device_reset()
|
||||
{
|
||||
m_enable = 0;
|
||||
m_speed = 0;
|
||||
m_state = 0;
|
||||
m_offset = 0;
|
||||
m_count = 0;
|
||||
}
|
||||
|
||||
// This line can reset the LFSR to zero and disables the star generator
|
||||
void zerohour_stars_device::set_enable(bool on)
|
||||
{
|
||||
if (!m_enable && on)
|
||||
m_offset = 0;
|
||||
|
||||
m_enable = on ? 1 : 0;
|
||||
}
|
||||
|
||||
// This sets up which starfield to draw and the offset, to be called from screen_vblank_*()
|
||||
void zerohour_stars_device::update_state()
|
||||
{
|
||||
if (m_enable)
|
||||
{
|
||||
m_count = m_count ? 0 : 1;
|
||||
if (!m_count)
|
||||
{
|
||||
m_offset += ((m_speed * 2) - 0x09);
|
||||
m_offset %= 256 * 256;
|
||||
m_state = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_state = 0x1fc71;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the speed register (3 bits)
|
||||
void zerohour_stars_device::set_speed(u8 speed, u8 mask)
|
||||
{
|
||||
// 0 left/down fastest (-9/2 pix per frame)
|
||||
// 1 left/down faster (-7/2 pix per frame)
|
||||
// 2 left/down fast (-5/2 pix per frame)
|
||||
// 3 left/down medium (-3/2 pix per frame)
|
||||
// 4 left/down slow (-1/2 pix per frame)
|
||||
// 5 right/up slow (+1/2 pix per frame)
|
||||
// 6 right/up medium (+3/2 pix per frame)
|
||||
// 7 right/up fast (+5/2 pix per frame)
|
||||
m_speed = (m_speed & ~mask) | (speed & mask);
|
||||
}
|
||||
|
||||
// Draw the stars
|
||||
// Space Raider doesn't use the Va bit, and it is also set up to window the stars to a certain x range
|
||||
void zerohour_stars_device::draw(bitmap_ind16 &bitmap, rectangle const &cliprect, u8 pal_offs, bool has_va, u8 firstx, u8 lastx)
|
||||
{
|
||||
if (m_enable)
|
||||
{
|
||||
u32 state(m_state);
|
||||
for (int i = 0; (256 * 256) > i; ++i)
|
||||
{
|
||||
u8 const xloc((m_offset + i) & 0x00ff);
|
||||
u8 const yloc(((m_offset + i) >> 8) & 0x00ff);
|
||||
|
||||
bool const tempbit(!(state & 0x10000));
|
||||
bool const feedback((state & 0x00020) ? !tempbit : tempbit);
|
||||
|
||||
bool const hcond(BIT(xloc + 8, 4));
|
||||
bool const vcond(!has_va || BIT(yloc, 0));
|
||||
|
||||
if (cliprect.contains(xloc, yloc) && (hcond == vcond))
|
||||
{
|
||||
if (((state & 0x000ff) == 0x000ff) && !feedback && (xloc >= firstx) && (xloc <= lastx))
|
||||
bitmap.pix(yloc, xloc) = pal_offs + ((state >> 9) & 0x1f);
|
||||
}
|
||||
|
||||
// update LFSR state
|
||||
state = ((state << 1) & 0x1fffe) | (feedback ? 1 : 0);
|
||||
}
|
||||
}
|
||||
}
|
35
src/mame/universal/zerohour_stars.h
Normal file
35
src/mame/universal/zerohour_stars.h
Normal file
@ -0,0 +1,35 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:Frank Palazzolo
|
||||
#ifndef MAME_VIDEO_ZEROHOUR_STARS_H
|
||||
#define MAME_VIDEO_ZEROHOUR_STARS_H
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
// used by zerohour, redclash and sraider
|
||||
class zerohour_stars_device : public device_t
|
||||
{
|
||||
public:
|
||||
zerohour_stars_device(machine_config const &mconfig, char const *tag, device_t *owner, u32 clock);
|
||||
|
||||
void set_enable(bool on);
|
||||
void update_state();
|
||||
void set_speed(u8 speed, u8 mask);
|
||||
void draw(bitmap_ind16 &bitmap, rectangle const &cliprect, u8 pal_offs, bool has_va, u8 firstx, u8 lastx);
|
||||
|
||||
protected:
|
||||
virtual void device_start() override;
|
||||
virtual void device_reset() override;
|
||||
|
||||
private:
|
||||
u8 m_enable;
|
||||
u8 m_speed;
|
||||
u32 m_state;
|
||||
u16 m_offset;
|
||||
u8 m_count;
|
||||
};
|
||||
|
||||
|
||||
DECLARE_DEVICE_TYPE(ZEROHOUR_STARS, zerohour_stars_device)
|
||||
|
||||
#endif // MAME_VIDEO_ZEROHOUR_STARS_H
|
Loading…
Reference in New Issue
Block a user