Modernized liberator driver, added save state support.

Moved generalized EAROM handling to atarigen.

Added new (modern) address map macros for referencing member
functions in base classes: AM_READ_BASE(_class, _member),
AM_WRITE_BASE, AM_READWRITE_BASE, etc.

Added BSD licenses to atarigen and er2055.
This commit is contained in:
Aaron Giles 2010-09-22 08:12:01 +00:00
parent bf5dfbe9b4
commit 442e1a2ccf
8 changed files with 433 additions and 221 deletions

View File

@ -856,6 +856,48 @@ void ADDRESS_MAP_NAME(_name)(address_map &map, const device_config &devconfig) \
curentry->set_handler(devconfig, _tag, _rhandler, #_rhandler, _whandler, #_whandler, _unitmask); \
// driver data base reads
#define AM_READ_BASE(_class, _handler) \
curentry->set_handler(devconfig, NULL, read_proto_delegate::_create_member<_class, &_class::_handler>("driver_data::" #_handler)); \
#define AM_READ8_BASE(_class, _handler, _unitmask) \
curentry->set_handler(devconfig, NULL, read8_proto_delegate::_create_member<_class, &_class::_handler>("driver_data::" #_handler), _unitmask); \
#define AM_READ16_BASE(_class, _handler, _unitmask) \
curentry->set_handler(devconfig, NULL, read16_proto_delegate::_create_member<_class, &_class::_handler>("driver_data::" #_handler), _unitmask); \
#define AM_READ32_BASE(_class, _handler, _unitmask) \
curentry->set_handler(devconfig, NULL, read32_proto_delegate::_create_member<_class, &_class::_handler>("driver_data::" #_handler), _unitmask); \
// driver data base writes
#define AM_WRITE_BASE(_class, _handler) \
curentry->set_handler(devconfig, NULL, write_proto_delegate::_create_member<_class, &_class::_handler>("driver_data::" #_handler)); \
#define AM_WRITE8_BASE(_class, _handler, _unitmask) \
curentry->set_handler(devconfig, NULL, write8_proto_delegate::_create_member<_class, &_class::_handler>("driver_data::" #_handler), _unitmask); \
#define AM_WRITE16_BASE(_class, _handler, _unitmask) \
curentry->set_handler(devconfig, NULL, write16_proto_delegate::_create_member<_class, &_class::_handler>("driver_data::" #_handler), _unitmask); \
#define AM_WRITE32_BASE(_class, _handler, _unitmask) \
curentry->set_handler(devconfig, NULL, write32_proto_delegate::_create_member<_class, &_class::_handler>("driver_data::" #_handler), _unitmask); \
// driver data base reads/writes
#define AM_READWRITE_BASE(_class, _rhandler, _whandler) \
curentry->set_handler(devconfig, NULL, read_proto_delegate::_create_member<_class, &_class::_rhandler>("driver_data::" #_rhandler), write_proto_delegate::_create_member<_class, &_class::_whandler>("driver_data::" #_whandler)); \
#define AM_READWRITE8_BASE(_class, _rhandler, _whandler, _unitmask) \
curentry->set_handler(devconfig, NULL, read8_proto_delegate::_create_member<_class, &_class::_rhandler>("driver_data::" #_rhandler), write8_proto_delegate::_create_member<_class, &_class::_whandler>("driver_data::" #_whandler), _unitmask); \
#define AM_READWRITE16_BASE(_class, _rhandler, _whandler, _unitmask) \
curentry->set_handler(devconfig, NULL, read16_proto_delegate::_create_member<_class, &_class::_rhandler>("driver_data::" #_rhandler), write16_proto_delegate::_create_member<_class, &_class::_whandler>("driver_data::" #_whandler), _unitmask); \
#define AM_READWRITE32_BASE(_class, _rhandler, _whandler, _unitmask) \
curentry->set_handler(devconfig, NULL, read32_proto_delegate::_create_member<_class, &_class::_rhandler>("driver_data::" #_rhandler), write32_proto_delegate::_create_member<_class, &_class::_whandler>("driver_data::" #_whandler), _unitmask); \
// driver data reads
#define AM_READ(_handler) \
curentry->set_handler(devconfig, NULL, read_proto_delegate::_create_member<drivdata_class, &drivdata_class::_handler>("driver_data::" #_handler)); \

View File

@ -4,6 +4,37 @@
GI 512 bit electrically alterable read-only memory.
****************************************************************************
Copyright Aaron Giles
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
#include "emu.h"

View File

@ -4,6 +4,37 @@
GI 512 bit electrically alterable read-only memory.
****************************************************************************
Copyright Aaron Giles
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
#pragma once

View File

@ -133,82 +133,41 @@
******************************************************************************************/
#define ADDRESS_MAP_MODERN
#include "emu.h"
#include "cpu/m6502/m6502.h"
#include "deprecat.h"
#include "machine/er2055.h"
#include "sound/pokey.h"
#include "includes/liberatr.h"
#define MASTER_CLOCK 20000000 /* 20Mhz Main Clock Xtal */
static UINT8 trackball_offset;
static UINT8 ctrld;
static UINT8 earom_data;
static UINT8 earom_control;
static MACHINE_RESET( liberatr )
void liberatr_state::machine_start()
{
er2055_device *earom = machine->device<er2055_device>("earom");
earom->set_control(0, 1, 1, 0, 0);
atarigen_state::machine_start();
state_save_register_device_item(this, 0, m_trackball_offset);
state_save_register_device_item(this, 0, m_ctrld);
state_save_register_device_item_array(this, 0, m_videoram);
}
/*************************************
*
* Output ports
*
*************************************/
static WRITE8_HANDLER( liberatr_led_w )
WRITE8_MEMBER( liberatr_state::led_w )
{
set_led_status(space->machine, offset, ~data & 0x10);
set_led_status(&m_machine, offset, ~data & 0x10);
}
static WRITE8_HANDLER( liberatr_coin_counter_w )
WRITE8_MEMBER( liberatr_state::coin_counter_w )
{
coin_counter_w(space->machine, offset ^ 0x01, data & 0x10);
}
/*************************************
*
* EAROM interface
*
*************************************/
static READ8_HANDLER( earom_r )
{
er2055_device *earom = space->machine->device<er2055_device>("earom");
return earom->data();
}
static WRITE8_HANDLER( earom_w )
{
er2055_device *earom = space->machine->device<er2055_device>("earom");
earom_data = data;
// output latch only enabled if control bit 2 is set
if (earom_control & 4)
earom->set_data(earom_data);
earom->set_address(offset);
}
static WRITE8_HANDLER( earom_control_w )
{
er2055_device *earom = space->machine->device<er2055_device>("earom");
earom_control = data;
// ensure ouput data is put on data lines prior to updating controls
if (earom_control & 4)
earom->set_data(earom_data);
earom->set_control(data & 8, 1, ~data & 4, data & 2, data & 1);
::coin_counter_w(&m_machine, offset ^ 0x01, data & 0x10);
}
@ -219,32 +178,32 @@ static WRITE8_HANDLER( earom_control_w )
*
*************************************/
static WRITE8_HANDLER( liberatr_trackball_reset_w )
WRITE8_MEMBER( liberatr_state::trackball_reset_w )
{
/* on the rising edge of /ctrld, the /ld signal on the LS191 is released and the value of the switches */
/* input becomes the starting point for the trackball counters */
if (((data ^ ctrld) & 0x10) && (data & 0x10))
if (((data ^ m_ctrld) & 0x10) && (data & 0x10))
{
UINT8 trackball = input_port_read(space->machine, "FAKE");
UINT8 switches = input_port_read(space->machine, "IN0");
trackball_offset = ((trackball & 0xf0) - (switches & 0xf0)) | ((trackball - switches) & 0x0f);
UINT8 trackball = input_port_read(&m_machine, "FAKE");
UINT8 switches = input_port_read(&m_machine, "IN0");
m_trackball_offset = ((trackball & 0xf0) - (switches & 0xf0)) | ((trackball - switches) & 0x0f);
}
ctrld = data & 0x10;
m_ctrld = data & 0x10;
}
static READ8_HANDLER( liberatr_input_port_0_r )
READ8_MEMBER( liberatr_state::port0_r )
{
/* if ctrld is high, the /ld signal on the LS191 is NOT set, meaning that the trackball is counting */
if (ctrld)
if (m_ctrld)
{
UINT8 trackball = input_port_read(space->machine, "FAKE");
return ((trackball & 0xf0) - (trackball_offset & 0xf0)) | ((trackball - trackball_offset) & 0x0f);
UINT8 trackball = input_port_read(&m_machine, "FAKE");
return ((trackball & 0xf0) - (m_trackball_offset & 0xf0)) | ((trackball - m_trackball_offset) & 0x0f);
}
/* otherwise, the LS191 is simply passing through the raw switch inputs */
else
return input_port_read(space->machine, "IN0");
return input_port_read(&m_machine, "IN0");
}
@ -255,27 +214,27 @@ static READ8_HANDLER( liberatr_input_port_0_r )
*
*************************************/
static ADDRESS_MAP_START( liberatr_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x0000) AM_RAM AM_BASE(&liberatr_x)
AM_RANGE(0x0001, 0x0001) AM_RAM AM_BASE(&liberatr_y)
AM_RANGE(0x0002, 0x0002) AM_READWRITE(liberatr_bitmap_xy_r, liberatr_bitmap_xy_w)
AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(liberatr_bitmap_w) AM_BASE(&liberatr_bitmapram) /* overlapping for my convenience */
AM_RANGE(0x4000, 0x403f) AM_READ(earom_r)
AM_RANGE(0x5000, 0x5000) AM_READ(liberatr_input_port_0_r)
static ADDRESS_MAP_START( liberatr_map, ADDRESS_SPACE_PROGRAM, 8, liberatr_state )
AM_RANGE(0x0000, 0x0000) AM_RAM AM_SHARE("xcoord")
AM_RANGE(0x0001, 0x0001) AM_RAM AM_SHARE("ycoord")
AM_RANGE(0x0002, 0x0002) AM_READWRITE(bitmap_xy_r, bitmap_xy_w)
AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(bitmap_w) AM_SHARE("bitmapram") /* overlapping for my convenience */
AM_RANGE(0x4000, 0x403f) AM_READ_BASE(atarigen_state, earom_r)
AM_RANGE(0x5000, 0x5000) AM_READ(port0_r)
AM_RANGE(0x5001, 0x5001) AM_READ_PORT("IN1")
AM_RANGE(0x6000, 0x600f) AM_WRITEONLY AM_BASE(&liberatr_base_ram)
AM_RANGE(0x6200, 0x621f) AM_WRITEONLY AM_BASE(&liberatr_colorram)
AM_RANGE(0x6000, 0x600f) AM_WRITEONLY AM_SHARE("base_ram")
AM_RANGE(0x6200, 0x621f) AM_WRITEONLY AM_SHARE("colorram")
AM_RANGE(0x6400, 0x6400) AM_WRITENOP
AM_RANGE(0x6600, 0x6600) AM_WRITE(earom_control_w)
AM_RANGE(0x6800, 0x6800) AM_WRITEONLY AM_BASE(&liberatr_planet_frame)
AM_RANGE(0x6a00, 0x6a00) AM_WRITE(watchdog_reset_w)
AM_RANGE(0x6c00, 0x6c01) AM_WRITE(liberatr_led_w)
AM_RANGE(0x6c04, 0x6c04) AM_WRITE(liberatr_trackball_reset_w)
AM_RANGE(0x6c05, 0x6c06) AM_WRITE(liberatr_coin_counter_w)
AM_RANGE(0x6c07, 0x6c07) AM_WRITEONLY AM_BASE(&liberatr_planet_select)
AM_RANGE(0x6e00, 0x6e3f) AM_WRITE(earom_w)
AM_RANGE(0x7000, 0x701f) AM_DEVREADWRITE("pokey2", pokey_r, pokey_w)
AM_RANGE(0x7800, 0x781f) AM_DEVREADWRITE("pokey1", pokey_r, pokey_w)
AM_RANGE(0x6600, 0x6600) AM_WRITE_BASE(atarigen_state, earom_control_w)
AM_RANGE(0x6800, 0x6800) AM_WRITEONLY AM_SHARE("planet_frame")
AM_RANGE(0x6a00, 0x6a00) AM_WRITE_LEGACY(watchdog_reset_w)
AM_RANGE(0x6c00, 0x6c01) AM_WRITE(led_w)
AM_RANGE(0x6c04, 0x6c04) AM_WRITE(trackball_reset_w)
AM_RANGE(0x6c05, 0x6c06) AM_WRITE(coin_counter_w)
AM_RANGE(0x6c07, 0x6c07) AM_WRITEONLY AM_SHARE("planet_select")
AM_RANGE(0x6e00, 0x6e3f) AM_WRITE_BASE(atarigen_state, earom_w)
AM_RANGE(0x7000, 0x701f) AM_DEVREADWRITE_LEGACY("pokey2", pokey_r, pokey_w)
AM_RANGE(0x7800, 0x781f) AM_DEVREADWRITE_LEGACY("pokey1", pokey_r, pokey_w)
AM_RANGE(0x8000, 0xefff) AM_ROM
AM_RANGE(0xfffa, 0xffff) AM_ROM
ADDRESS_MAP_END
@ -288,27 +247,27 @@ ADDRESS_MAP_END
*
*************************************/
static ADDRESS_MAP_START( liberat2_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x0000) AM_RAM AM_BASE(&liberatr_x)
AM_RANGE(0x0001, 0x0001) AM_RAM AM_BASE(&liberatr_y)
AM_RANGE(0x0002, 0x0002) AM_READWRITE(liberatr_bitmap_xy_r, liberatr_bitmap_xy_w)
AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(liberatr_bitmap_w) AM_BASE(&liberatr_bitmapram) /* overlapping for my convenience */
AM_RANGE(0x4000, 0x4000) AM_READ(liberatr_input_port_0_r)
static ADDRESS_MAP_START( liberat2_map, ADDRESS_SPACE_PROGRAM, 8, liberatr_state )
AM_RANGE(0x0000, 0x0000) AM_RAM AM_SHARE("xcoord")
AM_RANGE(0x0001, 0x0001) AM_RAM AM_SHARE("ycoord")
AM_RANGE(0x0002, 0x0002) AM_READWRITE(bitmap_xy_r, bitmap_xy_w)
AM_RANGE(0x0000, 0x3fff) AM_RAM_WRITE(bitmap_w) AM_SHARE("bitmapram") /* overlapping for my convenience */
AM_RANGE(0x4000, 0x4000) AM_READ(port0_r)
AM_RANGE(0x4001, 0x4001) AM_READ_PORT("IN1")
AM_RANGE(0x4000, 0x400f) AM_WRITEONLY AM_BASE(&liberatr_base_ram)
AM_RANGE(0x4200, 0x421f) AM_WRITEONLY AM_BASE(&liberatr_colorram)
AM_RANGE(0x4000, 0x400f) AM_WRITEONLY AM_SHARE("base_ram")
AM_RANGE(0x4200, 0x421f) AM_WRITEONLY AM_SHARE("colorram")
AM_RANGE(0x4400, 0x4400) AM_WRITENOP
AM_RANGE(0x4600, 0x4600) AM_WRITE(earom_control_w)
AM_RANGE(0x4800, 0x483f) AM_READ(earom_r)
AM_RANGE(0x4800, 0x4800) AM_WRITEONLY AM_BASE(&liberatr_planet_frame)
AM_RANGE(0x4a00, 0x4a00) AM_WRITE(watchdog_reset_w)
AM_RANGE(0x4c00, 0x4c01) AM_WRITE(liberatr_led_w)
AM_RANGE(0x4c04, 0x4c04) AM_WRITE(liberatr_trackball_reset_w)
AM_RANGE(0x4c05, 0x4c06) AM_WRITE(liberatr_coin_counter_w)
AM_RANGE(0x4c07, 0x4c07) AM_WRITEONLY AM_BASE(&liberatr_planet_select)
AM_RANGE(0x4e00, 0x4e3f) AM_WRITE(earom_w)
AM_RANGE(0x5000, 0x501f) AM_DEVREADWRITE("pokey2", pokey_r, pokey_w)
AM_RANGE(0x5800, 0x581f) AM_DEVREADWRITE("pokey1", pokey_r, pokey_w)
AM_RANGE(0x4600, 0x4600) AM_WRITE_BASE(atarigen_state, earom_control_w)
AM_RANGE(0x4800, 0x483f) AM_READ_BASE(atarigen_state, earom_r)
AM_RANGE(0x4800, 0x4800) AM_WRITEONLY AM_SHARE("planet_frame")
AM_RANGE(0x4a00, 0x4a00) AM_WRITE_LEGACY(watchdog_reset_w)
AM_RANGE(0x4c00, 0x4c01) AM_WRITE(led_w)
AM_RANGE(0x4c04, 0x4c04) AM_WRITE(trackball_reset_w)
AM_RANGE(0x4c05, 0x4c06) AM_WRITE(coin_counter_w)
AM_RANGE(0x4c07, 0x4c07) AM_WRITEONLY AM_SHARE("planet_select")
AM_RANGE(0x4e00, 0x4e3f) AM_WRITE_BASE(atarigen_state, earom_w)
AM_RANGE(0x5000, 0x501f) AM_DEVREADWRITE_LEGACY("pokey2", pokey_r, pokey_w)
AM_RANGE(0x5800, 0x581f) AM_DEVREADWRITE_LEGACY("pokey1", pokey_r, pokey_w)
//AM_RANGE(0x6000, 0x601f) AM_WRITE(pokey1_w) /* bug ??? */
AM_RANGE(0x6000, 0xbfff) AM_ROM
AM_RANGE(0xfffa, 0xffff) AM_ROM
@ -427,14 +386,13 @@ static const pokey_interface pokey_interface_2 =
*
*************************************/
static MACHINE_CONFIG_START( liberatr, driver_device )
static MACHINE_CONFIG_START( liberatr, liberatr_state )
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, MASTER_CLOCK/16) /* 1.25Mhz divided from 20Mhz master clock */
MDRV_CPU_PROGRAM_MAP(liberatr_map)
MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4)
MDRV_MACHINE_RESET(liberatr)
MDRV_ER2055_ADD("earom")
/* video hardware */
@ -445,9 +403,6 @@ static MACHINE_CONFIG_START( liberatr, driver_device )
MDRV_SCREEN_SIZE(256,256)
MDRV_SCREEN_VISIBLE_AREA(8, 247, 13, 244)
MDRV_VIDEO_START(liberatr)
MDRV_VIDEO_UPDATE(liberatr)
/* sound hardware */
MDRV_SPEAKER_STANDARD_MONO("mono")
@ -544,6 +499,6 @@ ROM_END
*
*************************************/
GAME( 1982, liberatr, 0, liberatr, liberatr, 0, ROT0, "Atari", "Liberator (set 1)", GAME_NO_COCKTAIL )
GAME( 1982, liberatr2,liberatr, liberat2, liberatr, 0, ROT0, "Atari", "Liberator (set 2)", GAME_NO_COCKTAIL )
GAME( 1982, liberatr, 0, liberatr, liberatr, 0, ROT0, "Atari", "Liberator (set 1)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
GAME( 1982, liberatr2,liberatr, liberat2, liberatr, 0, ROT0, "Atari", "Liberator (set 2)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )

View File

@ -4,19 +4,90 @@
*************************************************************************/
/*----------- defined in video/liberatr.c -----------*/
#include "cpu/m6502/m6502.h"
#include "machine/atarigen.h"
#include "sound/pokey.h"
extern UINT8 *liberatr_base_ram;
extern UINT8 *liberatr_planet_frame;
extern UINT8 *liberatr_planet_select;
extern UINT8 *liberatr_x;
extern UINT8 *liberatr_y;
extern UINT8 *liberatr_bitmapram;
extern UINT8 *liberatr_colorram;
class liberatr_state : public atarigen_state
{
public:
liberatr_state(running_machine &machine, const driver_device_config_base &config)
: atarigen_state(machine, config),
m_base_ram(*this, "base_ram"),
m_planet_frame(*this, "planet_frame"),
m_planet_select(*this, "planet_select"),
m_xcoord(*this, "xcoord"),
m_ycoord(*this, "ycoord"),
m_bitmapram(*this, "bitmapram"),
m_colorram(*this, "colorram") { }
VIDEO_START( liberatr );
VIDEO_UPDATE( liberatr );
DECLARE_WRITE8_MEMBER( led_w );
DECLARE_WRITE8_MEMBER( coin_counter_w );
WRITE8_HANDLER( liberatr_bitmap_w );
READ8_HANDLER( liberatr_bitmap_xy_r );
WRITE8_HANDLER( liberatr_bitmap_xy_w );
DECLARE_WRITE8_MEMBER( trackball_reset_w );
DECLARE_READ8_MEMBER( port0_r );
DECLARE_WRITE8_MEMBER( bitmap_w );
DECLARE_READ8_MEMBER( bitmap_xy_r );
DECLARE_WRITE8_MEMBER( bitmap_xy_w );
protected:
struct planet;
virtual void machine_start();
virtual void video_start();
virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
void init_planet(planet &liberatr_planet, UINT8 *planet_rom);
void get_pens(pen_t *pens);
void draw_planet(bitmap_t &bitmap, pen_t *pens);
void draw_bitmap(bitmap_t &bitmap, pen_t *pens);
required_shared_ptr<UINT8> m_base_ram;
required_shared_ptr<UINT8> m_planet_frame;
required_shared_ptr<UINT8> m_planet_select;
required_shared_ptr<UINT8> m_xcoord;
required_shared_ptr<UINT8> m_ycoord;
required_shared_ptr<UINT8> m_bitmapram;
required_shared_ptr<UINT8> m_colorram;
UINT8 m_trackball_offset;
UINT8 m_ctrld;
UINT8 m_videoram[0x10000];
// The following structure describes the (up to 32) line segments
// that make up one horizontal line (latitude) for one display frame of the planet.
// Note: this and the following structure is only used to collect the
// data before it is packed for actual use.
struct planet_frame_line
{
UINT8 segment_count; // the number of segments on this line
UINT8 max_x; // the maximum value of x_array for this line
UINT8 color_array[32]; // the color values
UINT8 x_array[32]; // and maximum x values for each segment
};
// The following structure describes the lines (latitudes)
// that make up one complete display frame of the planet.
// Note: this and the previous structure is only used to collect the
// data before it is packed for actual use.
struct planet_frame
{
planet_frame_line lines[0x80];
};
// The following structure collects the 256 frames of the
// planet (one per value of longitude).
// The data is packed segment_count,segment_start,color,length,color,length,... then
// segment_count,segment_start,color,length,color,length... for the next line, etc
// for the 128 lines.
struct planet
{
UINT8 *frames[256];
};
// The following array collects the 2 different planet
// descriptions, which are selected by planetbit
planet m_planets[2];
};

View File

@ -2,7 +2,38 @@
atarigen.c
General functions for Atari raster games.
General functions for Atari games.
****************************************************************************
Copyright Aaron Giles
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
@ -1521,3 +1552,69 @@ void atarigen_blend_gfx(running_machine *machine, int gfx0, int gfx1, int mask0,
/* make the assembled data our new source data */
gfx_element_set_source(gx0, srcdata);
}
//**************************************************************************
// VECTOR AND EARLY RASTER EAROM INTERFACE
//**************************************************************************
void atarigen_state::machine_start()
{
// until everyone is converted to modern devices, call our parent
driver_device::machine_start();
state_save_register_device_item(this, 0, m_earom_data);
state_save_register_device_item(this, 0, m_earom_control);
}
void atarigen_state::machine_reset()
{
// until everyone is converted to modern devices, call our parent
driver_device::machine_reset();
// reset the control latch on the EAROM, if present
if (m_earom != NULL)
m_earom->set_control(0, 1, 1, 0, 0);
}
//**************************************************************************
// VECTOR AND EARLY RASTER EAROM INTERFACE
//**************************************************************************
READ8_MEMBER( atarigen_state::earom_r )
{
// return data latched from previous clock
return m_earom->data();
}
WRITE8_MEMBER( atarigen_state::earom_w )
{
// remember the value written
m_earom_data = data;
// output latch only enabled if control bit 2 is set
if (m_earom_control & 4)
m_earom->set_data(m_earom_data);
// always latch the address
m_earom->set_address(offset);
}
WRITE8_MEMBER( atarigen_state::earom_control_w )
{
// remember the control state
m_earom_control = data;
// ensure ouput data is put on data lines prior to updating controls
if (m_earom_control & 4)
m_earom->set_data(m_earom_data);
// set the control lines; /CS2 is always held low
m_earom->set_control(data & 8, 1, ~data & 4, data & 2, data & 1);
}

View File

@ -2,16 +2,48 @@
atarigen.h
General functions for Atari raster games.
General functions for Atari games.
****************************************************************************
Copyright Aaron Giles
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
* Neither the name 'MAME' nor the names of its contributors may be
used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY AARON GILES ''AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL AARON GILES BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
***************************************************************************/
#ifndef __MACHINE_ATARIGEN__
#define __MACHINE_ATARIGEN__
#include "machine/nvram.h"
#include "video/atarimo.h"
#include "video/atarirle.h"
#ifndef __MACHINE_ATARIGEN__
#define __MACHINE_ATARIGEN__
#include "machine/er2055.h"
/***************************************************************************
@ -66,9 +98,24 @@ class atarigen_state : public driver_device
public:
atarigen_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config),
m_earom(*this, "earom"),
eeprom(*this, "eeprom"),
eeprom_size(*this, "eeprom") { }
// users must call through to these
virtual void machine_start();
virtual void machine_reset();
// vector and early raster EAROM interface
DECLARE_READ8_MEMBER( earom_r );
DECLARE_WRITE8_MEMBER( earom_w );
DECLARE_WRITE8_MEMBER( earom_control_w );
// vector and early raster EAROM interface
optional_device<er2055_device> m_earom;
UINT8 m_earom_data;
UINT8 m_earom_control;
optional_shared_ptr<UINT16> eeprom;
optional_shared_size eeprom_size;
@ -115,7 +162,7 @@ public:
offs_t slapstic_base;
offs_t slapstic_mirror;
running_device * sound_cpu;
running_device * sound_cpu;
UINT8 cpu_to_sound;
UINT8 sound_to_cpu;
UINT8 timed_int;

View File

@ -20,91 +20,35 @@
#define NUM_PENS (0x18)
UINT8 *liberatr_base_ram;
UINT8 *liberatr_planet_frame;
UINT8 *liberatr_planet_select;
UINT8 *liberatr_x;
UINT8 *liberatr_y;
UINT8 *liberatr_bitmapram;
UINT8 *liberatr_colorram;
static UINT8 *liberatr_videoram;
/*
The following structure describes the (up to 32) line segments
that make up one horizontal line (latitude) for one display frame of the planet.
Note: this and the following structure is only used to collect the
data before it is packed for actual use.
*/
typedef struct
WRITE8_MEMBER( liberatr_state::bitmap_xy_w )
{
UINT8 segment_count; /* the number of segments on this line */
UINT8 max_x; /* the maximum value of x_array for this line */
UINT8 color_array[32]; /* the color values */
UINT8 x_array[32]; /* and maximum x values for each segment */
} planet_frame_line;
/*
The following structure describes the lines (latitudes)
that make up one complete display frame of the planet.
Note: this and the previous structure is only used to collect the
data before it is packed for actual use.
*/
typedef struct
{
planet_frame_line lines[0x80];
} planet_frame;
/*
The following structure collects the 256 frames of the
planet (one per value of longitude).
The data is packed segment_count,segment_start,color,length,color,length,... then
segment_count,segment_start,color,length,color,length... for the next line, etc
for the 128 lines.
*/
typedef struct
{
UINT8 *frames[256];
} planet;
/*
The following array collects the 2 different planet
descriptions, which are selected by liberatr_planetbit
*/
static planet *liberatr_planets[2];
WRITE8_HANDLER( liberatr_bitmap_xy_w )
{
liberatr_videoram[(*liberatr_y << 8) | *liberatr_x] = data & 0xe0;
m_videoram[(*m_ycoord << 8) | *m_xcoord] = data & 0xe0;
}
READ8_HANDLER( liberatr_bitmap_xy_r )
READ8_MEMBER( liberatr_state::bitmap_xy_r )
{
return liberatr_videoram[(*liberatr_y << 8) | *liberatr_x];
return m_videoram[(*m_ycoord << 8) | *m_xcoord];
}
WRITE8_HANDLER( liberatr_bitmap_w )
WRITE8_MEMBER( liberatr_state::bitmap_w )
{
UINT8 x, y;
liberatr_bitmapram[offset] = data;
m_bitmapram[offset] = data;
x = (offset & 0x3f) << 2;
y = offset >> 6;
data = data & 0xe0;
liberatr_videoram[(y << 8) | x | 0] = data;
liberatr_videoram[(y << 8) | x | 1] = data;
liberatr_videoram[(y << 8) | x | 2] = data;
liberatr_videoram[(y << 8) | x | 3] = data;
m_videoram[(y << 8) | x | 0] = data;
m_videoram[(y << 8) | x | 1] = data;
m_videoram[(y << 8) | x | 2] = data;
m_videoram[(y << 8) | x | 3] = data;
}
@ -120,7 +64,7 @@ WRITE8_HANDLER( liberatr_bitmap_w )
as it might be, but this is not realtime stuff, so who cares...
********************************************************************************************/
static void liberatr_init_planet(running_machine *machine, planet *liberatr_planet, UINT8 *planet_rom)
void liberatr_state::init_planet(planet &liberatr_planet, UINT8 *planet_rom)
{
UINT16 longitude;
@ -229,7 +173,7 @@ static void liberatr_init_planet(running_machine *machine, planet *liberatr_plan
*/
buffer = auto_alloc_array(machine, UINT8, 2*(128 + total_segment_count));
liberatr_planet->frames[longitude] = buffer;
liberatr_planet.frames[longitude] = buffer;
for (latitude = 0; latitude < 0x80; latitude++)
{
@ -265,21 +209,15 @@ static void liberatr_init_planet(running_machine *machine, planet *liberatr_plan
***************************************************************************/
VIDEO_START( liberatr )
void liberatr_state::video_start()
{
liberatr_videoram = auto_alloc_array(machine, UINT8, 0x10000);
/* allocate the planet descriptor structure */
liberatr_planets[0] = auto_alloc(machine, planet);
liberatr_planets[1] = auto_alloc(machine, planet);
/* for each planet in the planet ROMs */
liberatr_init_planet(machine, liberatr_planets[0], &memory_region(machine, "gfx1")[0x2000]);
liberatr_init_planet(machine, liberatr_planets[1], &memory_region(machine, "gfx1")[0x0000]);
// for each planet in the planet ROMs
init_planet(m_planets[0], &memory_region(machine, "gfx1")[0x2000]);
init_planet(m_planets[1], &memory_region(machine, "gfx1")[0x0000]);
}
static void get_pens(pen_t *pens)
void liberatr_state::get_pens(pen_t *pens)
{
offs_t i;
@ -293,7 +231,7 @@ static void get_pens(pen_t *pens)
0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00,
0x10, 0x12, 0x14, 0x16, 0x11, 0x13, 0x15, 0x17 };
UINT8 data = liberatr_colorram[i];
UINT8 data = m_colorram[i];
/* scale it from 0x00-0xff */
r = ((~data >> 3) & 0x07) * 0x24 + 3; if (r == 3) r = 0;
@ -305,11 +243,11 @@ static void get_pens(pen_t *pens)
}
static void liberatr_draw_planet(bitmap_t *bitmap, pen_t *pens)
void liberatr_state::draw_planet(bitmap_t &bitmap, pen_t *pens)
{
UINT8 latitude;
UINT8 *buffer = liberatr_planets[(*liberatr_planet_select >> 4) & 0x01]->frames[*liberatr_planet_frame];
UINT8 *buffer = m_planets[(*m_planet_select >> 4) & 0x01].frames[*m_planet_frame];
/* for each latitude */
for (latitude = 0; latitude < 0x80; latitude++)
@ -317,7 +255,7 @@ static void liberatr_draw_planet(bitmap_t *bitmap, pen_t *pens)
UINT8 segment;
/* grab the color value for the base (if any) at this latitude */
UINT8 base_color = liberatr_base_ram[latitude >> 3] ^ 0x0f;
UINT8 base_color = m_base_ram[latitude >> 3] ^ 0x0f;
UINT8 segment_count = *buffer++;
UINT8 x = *buffer++;
@ -335,37 +273,37 @@ static void liberatr_draw_planet(bitmap_t *bitmap, pen_t *pens)
color = base_color;
for (i = 0; i < segment_length; i++, x++)
*BITMAP_ADDR32(bitmap, y, x) = pens[color];
*BITMAP_ADDR32(&bitmap, y, x) = pens[color];
}
}
}
static void liberatr_draw_bitmap(bitmap_t *bitmap, pen_t *pens)
void liberatr_state::draw_bitmap(bitmap_t &bitmap, pen_t *pens)
{
offs_t offs;
for (offs = 0; offs < 0x10000; offs++)
{
UINT8 data = liberatr_videoram[offs];
UINT8 data = m_videoram[offs];
UINT8 y = offs >> 8;
UINT8 x = offs & 0xff;
if (data)
*BITMAP_ADDR32(bitmap, y, x) = pens[(data >> 5) | 0x10];
*BITMAP_ADDR32(&bitmap, y, x) = pens[(data >> 5) | 0x10];
}
}
VIDEO_UPDATE( liberatr )
bool liberatr_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
{
pen_t pens[NUM_PENS];
get_pens(pens);
bitmap_fill(bitmap, cliprect, RGB_BLACK);
liberatr_draw_planet(bitmap, pens);
liberatr_draw_bitmap(bitmap, pens);
bitmap_fill(&bitmap, &cliprect, RGB_BLACK);
draw_planet(bitmap, pens);
draw_bitmap(bitmap, pens);
return 0;
return false;
}