mirror of
https://github.com/holub/mame
synced 2025-05-27 16:21:34 +03:00
Added driver_data struct to adp.c, albazc.c and arabian.c
Out of credits, I also added: * save states to adp.c (because part of the struct was already there), but nothing is working => no flag; * save states to albazc.c, but I don't want credit, since no variable needed to be saved (i.e. save states were already there)
This commit is contained in:
parent
68f3c5b386
commit
09cb5b9ffc
@ -150,13 +150,17 @@ Video board has additional chips:
|
||||
#include "machine/microtch.h"
|
||||
#include "machine/68681.h"
|
||||
|
||||
static UINT8 register_active;
|
||||
static UINT8 mux_data;
|
||||
|
||||
static struct
|
||||
typedef struct _adp_state adp_state;
|
||||
struct _adp_state
|
||||
{
|
||||
const device_config *duart68681;
|
||||
} skattv_devices;
|
||||
/* misc */
|
||||
UINT8 mux_data;
|
||||
UINT8 register_active;
|
||||
|
||||
/* devices */
|
||||
const device_config *duart;
|
||||
};
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
@ -164,38 +168,47 @@ static struct
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
static void duart_irq_handler(const device_config *device, UINT8 vector)
|
||||
static void duart_irq_handler( const device_config *device, UINT8 vector )
|
||||
{
|
||||
cputag_set_input_line_and_vector(device->machine, "maincpu", 4, HOLD_LINE, vector);
|
||||
};
|
||||
|
||||
static void duart_tx(const device_config *device, int channel, UINT8 data)
|
||||
static void duart_tx( const device_config *device, int channel, UINT8 data )
|
||||
{
|
||||
if ( channel == 0 )
|
||||
if (channel == 0)
|
||||
{
|
||||
microtouch_rx(1, &data);
|
||||
}
|
||||
};
|
||||
|
||||
static void microtouch_tx(running_machine *machine, UINT8 data)
|
||||
static void microtouch_tx( running_machine *machine, UINT8 data )
|
||||
{
|
||||
duart68681_rx_data(skattv_devices.duart68681, 0, data);
|
||||
adp_state *state = (adp_state *)machine->driver_data;
|
||||
duart68681_rx_data(state->duart, 0, data);
|
||||
}
|
||||
|
||||
static UINT8 duart_input(const device_config *device)
|
||||
static UINT8 duart_input( const device_config *device )
|
||||
{
|
||||
return input_port_read(device->machine, "DSW1");
|
||||
}
|
||||
|
||||
static MACHINE_START( skattv )
|
||||
{
|
||||
adp_state *state = (adp_state *)machine->driver_data;
|
||||
microtouch_init(machine, microtouch_tx, 0);
|
||||
|
||||
state->duart = devtag_get_device(machine, "duart68681");
|
||||
|
||||
state_save_register_global(machine, state->mux_data);
|
||||
state_save_register_global(machine, state->register_active);
|
||||
}
|
||||
|
||||
static MACHINE_RESET( skattv )
|
||||
{
|
||||
skattv_devices.duart68681 = devtag_get_device( machine, "duart68681" );
|
||||
mux_data = 0;
|
||||
adp_state *state = (adp_state *)machine->driver_data;
|
||||
|
||||
state->mux_data = 0;
|
||||
state->register_active = 0;
|
||||
}
|
||||
|
||||
static const duart68681_config skattv_duart68681_config =
|
||||
@ -210,10 +223,9 @@ static PALETTE_INIT( adp )
|
||||
{
|
||||
int i;
|
||||
|
||||
|
||||
for (i = 0;i < machine->config->total_colors;i++)
|
||||
for (i = 0; i < machine->config->total_colors; i++)
|
||||
{
|
||||
int bit0,bit1,bit2,r,g,b;
|
||||
int bit0, bit1, bit2, r, g, b;
|
||||
|
||||
|
||||
// red component
|
||||
@ -232,7 +244,7 @@ static PALETTE_INIT( adp )
|
||||
bit2 = (i >> 2) & 0x01;
|
||||
b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
|
||||
|
||||
palette_set_color(machine,i,MAKE_RGB(r,g,b));
|
||||
palette_set_color(machine, i, MAKE_RGB(r,g,b));
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +262,7 @@ static VIDEO_START(adp)
|
||||
|
||||
static VIDEO_UPDATE(adp)
|
||||
{
|
||||
int x,y,b;
|
||||
int x, y, b;
|
||||
|
||||
b = ((HD63484_reg[0xcc/2] & 0x000f) << 16) + HD63484_reg[0xce/2];
|
||||
#if 0
|
||||
@ -321,11 +333,12 @@ if (!input_code_pressed(screen->machine, KEYCODE_O))
|
||||
return 0;
|
||||
}
|
||||
|
||||
static READ16_HANDLER(test_r)
|
||||
static READ16_HANDLER( test_r )
|
||||
{
|
||||
adp_state *state = (adp_state *)space->machine->driver_data;
|
||||
int value = 0xffff;
|
||||
|
||||
switch(mux_data)
|
||||
switch (state->mux_data)
|
||||
{
|
||||
case 0x00: value = input_port_read(space->machine, "x0"); break;
|
||||
case 0x01: value = input_port_read(space->machine, "x1snd"); break;
|
||||
@ -344,8 +357,9 @@ static READ16_HANDLER(test_r)
|
||||
case 0x0e: value = input_port_read(space->machine, "x14"); break;
|
||||
case 0x0f: value = input_port_read(space->machine, "x15"); break;
|
||||
}
|
||||
mux_data++;
|
||||
mux_data&=0xf;
|
||||
|
||||
state->mux_data++;
|
||||
state->mux_data &= 0xf;
|
||||
|
||||
return value;
|
||||
}
|
||||
@ -353,22 +367,23 @@ static READ16_HANDLER(test_r)
|
||||
/*???*/
|
||||
static WRITE16_HANDLER(wh2_w)
|
||||
{
|
||||
register_active = data;
|
||||
adp_state *state = (adp_state *)space->machine->driver_data;
|
||||
state->register_active = data;
|
||||
}
|
||||
|
||||
static READ16_HANDLER(t2_r)
|
||||
{
|
||||
static UINT16 vblank = 0,hblank = 0;
|
||||
static UINT16 vblank = 0, hblank = 0;
|
||||
|
||||
vblank ^=0x40;
|
||||
hblank ^=0x20;
|
||||
vblank ^=0x40;
|
||||
hblank ^=0x20;
|
||||
|
||||
return mame_rand(space->machine) & 0x00f0;
|
||||
return mame_rand(space->machine) & 0x00f0;
|
||||
|
||||
// FIXME: this code is never executed
|
||||
// popmessage("%08x",cpu_get_pc(space->cpu));
|
||||
// return 0x0000;
|
||||
return 0xff9f | vblank | hblank;
|
||||
return 0xff9f | vblank | hblank;
|
||||
}
|
||||
|
||||
static ADDRESS_MAP_START( skattv_mem, ADDRESS_SPACE_PROGRAM, 16 )
|
||||
@ -514,6 +529,10 @@ static INTERRUPT_GEN( adp_int )
|
||||
}
|
||||
*/
|
||||
static MACHINE_DRIVER_START( quickjac )
|
||||
|
||||
/* driver data */
|
||||
MDRV_DRIVER_DATA(adp_state)
|
||||
|
||||
MDRV_CPU_ADD("maincpu", M68000, 8000000)
|
||||
MDRV_CPU_PROGRAM_MAP(quickjac_mem)
|
||||
// MDRV_CPU_VBLANK_INT("screen", adp_int)
|
||||
@ -542,6 +561,10 @@ static MACHINE_DRIVER_START( quickjac )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( skattv )
|
||||
|
||||
/* driver data */
|
||||
MDRV_DRIVER_DATA(adp_state)
|
||||
|
||||
MDRV_CPU_ADD("maincpu", M68000, 8000000)
|
||||
MDRV_CPU_PROGRAM_MAP(skattv_mem)
|
||||
// MDRV_CPU_VBLANK_INT("screen", adp_int)
|
||||
@ -570,6 +593,10 @@ static MACHINE_DRIVER_START( skattv )
|
||||
MACHINE_DRIVER_END
|
||||
|
||||
static MACHINE_DRIVER_START( backgamn )
|
||||
|
||||
/* driver data */
|
||||
MDRV_DRIVER_DATA(adp_state)
|
||||
|
||||
MDRV_CPU_ADD("maincpu", M68000, 8000000)
|
||||
MDRV_CPU_PROGRAM_MAP(backgamn_mem)
|
||||
|
||||
@ -662,10 +689,9 @@ ROM_START( funlddlx )
|
||||
ROM_LOAD16_BYTE( "flv_f1_ii.bin", 0x00001, 0x80000, CRC(2aa904e6) SHA1(864530b136dd488d619cc95f48e7dce8d93d88e0) )
|
||||
ROM_END
|
||||
|
||||
GAME( 1990, backgamn, 0, backgamn, adp, 0, ROT0, "ADP", "Backgammon", GAME_NOT_WORKING )
|
||||
GAME( 1993, quickjac, 0, quickjac, skattv, 0, ROT0, "ADP", "Quick Jack", GAME_NOT_WORKING )
|
||||
GAME( 1994, skattv, 0, skattv, skattv, 0, ROT0, "ADP", "Skat TV", GAME_NOT_WORKING )
|
||||
GAME( 1995, skattva, skattv, skattv, skattv, 0, ROT0, "ADP", "Skat TV (version TS3)", GAME_NOT_WORKING )
|
||||
GAME( 1997, fashiong, 0, skattv, skattv, 0, ROT0, "ADP", "Fashion Gambler", GAME_NOT_WORKING )
|
||||
GAME( 1999, funlddlx, 0, funland, skattv, 0, ROT0, "Stella", "Funny Land de Luxe", GAME_NOT_WORKING )
|
||||
|
||||
GAME( 1990, backgamn, 0, backgamn, adp, 0, ROT0, "ADP", "Backgammon", GAME_NOT_WORKING )
|
||||
GAME( 1993, quickjac, 0, quickjac, skattv, 0, ROT0, "ADP", "Quick Jack", GAME_NOT_WORKING )
|
||||
GAME( 1994, skattv, 0, skattv, skattv, 0, ROT0, "ADP", "Skat TV", GAME_NOT_WORKING )
|
||||
GAME( 1995, skattva, skattv, skattv, skattv, 0, ROT0, "ADP", "Skat TV (version TS3)", GAME_NOT_WORKING )
|
||||
GAME( 1997, fashiong, 0, skattv, skattv, 0, ROT0, "ADP", "Fashion Gambler", GAME_NOT_WORKING )
|
||||
GAME( 1999, funlddlx, 0, funland, skattv, 0, ROT0, "Stella", "Funny Land de Luxe", GAME_NOT_WORKING )
|
||||
|
@ -14,45 +14,52 @@ TODO:
|
||||
#include "cpu/z80/z80.h"
|
||||
#include "sound/ay8910.h"
|
||||
|
||||
typedef struct _albazc_state albazc_state;
|
||||
struct _albazc_state
|
||||
{
|
||||
/* video-related */
|
||||
UINT8 * spriteram1;
|
||||
UINT8 * spriteram2;
|
||||
UINT8 * spriteram3;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* video */
|
||||
|
||||
static UINT8 *hanaroku_spriteram1;
|
||||
static UINT8 *hanaroku_spriteram2;
|
||||
static UINT8 *hanaroku_spriteram3;
|
||||
|
||||
|
||||
static PALETTE_INIT( hanaroku )
|
||||
{
|
||||
int i;
|
||||
int r,g,b;
|
||||
int r, g, b;
|
||||
|
||||
for (i = 0; i < 0x200; i++)
|
||||
{
|
||||
b = (color_prom[i*2+1] & 0x1f);
|
||||
g = ((color_prom[i*2+1] & 0xe0) | ( (color_prom[i*2+0]& 0x03) <<8) ) >> 5;
|
||||
r = (color_prom[i*2+0]&0x7c) >> 2;
|
||||
b = (color_prom[i * 2 + 1] & 0x1f);
|
||||
g = ((color_prom[i * 2 + 1] & 0xe0) | ((color_prom[i * 2 + 0]& 0x03) <<8)) >> 5;
|
||||
r = (color_prom[i * 2 + 0] & 0x7c) >> 2;
|
||||
|
||||
palette_set_color_rgb(machine,i,pal5bit(r),pal5bit(g),pal5bit(b));
|
||||
palette_set_color_rgb(machine, i, pal5bit(r), pal5bit(g), pal5bit(b));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static VIDEO_START(hanaroku)
|
||||
static VIDEO_START( hanaroku )
|
||||
{
|
||||
}
|
||||
|
||||
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
|
||||
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
|
||||
{
|
||||
albazc_state *state = (albazc_state *)machine->driver_data;
|
||||
int i;
|
||||
|
||||
for (i = 511; i >= 0; i--)
|
||||
{
|
||||
int code = hanaroku_spriteram1[i] | (hanaroku_spriteram2[i] << 8);
|
||||
int color = (hanaroku_spriteram2[i + 0x200] & 0xf8) >> 3;
|
||||
int code = state->spriteram1[i] | (state->spriteram2[i] << 8);
|
||||
int color = (state->spriteram2[i + 0x200] & 0xf8) >> 3;
|
||||
int flipx = 0;
|
||||
int flipy = 0;
|
||||
int sx = hanaroku_spriteram1[i + 0x200] | ((hanaroku_spriteram2[i + 0x200] & 0x07) << 8);
|
||||
int sy = 242 - hanaroku_spriteram3[i];
|
||||
int sx = state->spriteram1[i + 0x200] | ((state->spriteram2[i + 0x200] & 0x07) << 8);
|
||||
int sy = 242 - state->spriteram3[i];
|
||||
|
||||
if (flip_screen_get(machine))
|
||||
{
|
||||
@ -120,9 +127,9 @@ static WRITE8_HANDLER( hanaroku_out_2_w )
|
||||
|
||||
static ADDRESS_MAP_START( hanaroku_map, ADDRESS_SPACE_PROGRAM, 8 )
|
||||
AM_RANGE(0x0000, 0x7fff) AM_ROM
|
||||
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&hanaroku_spriteram1)
|
||||
AM_RANGE(0x9000, 0x97ff) AM_RAM AM_BASE(&hanaroku_spriteram2)
|
||||
AM_RANGE(0xa000, 0xa1ff) AM_RAM AM_BASE(&hanaroku_spriteram3)
|
||||
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE_MEMBER(albazc_state, spriteram1)
|
||||
AM_RANGE(0x9000, 0x97ff) AM_RAM AM_BASE_MEMBER(albazc_state, spriteram2)
|
||||
AM_RANGE(0xa000, 0xa1ff) AM_RAM AM_BASE_MEMBER(albazc_state, spriteram3)
|
||||
AM_RANGE(0xa200, 0xa2ff) AM_WRITENOP // ??? written once during P.O.S.T.
|
||||
AM_RANGE(0xa300, 0xa304) AM_WRITENOP // ???
|
||||
AM_RANGE(0xb000, 0xb000) AM_WRITENOP // ??? always 0x40
|
||||
@ -227,6 +234,10 @@ static const ay8910_interface ay8910_config =
|
||||
|
||||
|
||||
static MACHINE_DRIVER_START( hanaroku )
|
||||
|
||||
/* driver data */
|
||||
MDRV_DRIVER_DATA(albazc_state)
|
||||
|
||||
MDRV_CPU_ADD("maincpu", Z80,6000000) /* ? MHz */
|
||||
MDRV_CPU_PROGRAM_MAP(hanaroku_map)
|
||||
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
|
||||
@ -271,4 +282,4 @@ ROM_START( hanaroku )
|
||||
ROM_END
|
||||
|
||||
|
||||
GAME( 1988, hanaroku, 0, hanaroku, hanaroku, 0, ROT0, "Alba", "Hanaroku", GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_COLORS )
|
||||
GAME( 1988, hanaroku, 0, hanaroku, hanaroku, 0, ROT0, "Alba", "Hanaroku", GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_COLORS | GAME_SUPPORTS_SAVE )
|
||||
|
@ -71,18 +71,10 @@
|
||||
#include "arabian.h"
|
||||
#include "sound/ay8910.h"
|
||||
|
||||
|
||||
/* constants */
|
||||
#define MAIN_OSC 12000000
|
||||
|
||||
|
||||
/* local variables */
|
||||
static UINT8 custom_cpu_reset;
|
||||
static UINT8 custom_cpu_busy;
|
||||
static UINT8 *custom_cpu_ram;
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Audio chip output ports
|
||||
@ -91,6 +83,8 @@ static UINT8 *custom_cpu_ram;
|
||||
|
||||
static WRITE8_DEVICE_HANDLER( ay8910_porta_w )
|
||||
{
|
||||
arabian_state *state = (arabian_state *)device->machine->driver_data;
|
||||
|
||||
/*
|
||||
bit 7 = ENA
|
||||
bit 6 = ENB
|
||||
@ -98,12 +92,14 @@ static WRITE8_DEVICE_HANDLER( ay8910_porta_w )
|
||||
bit 4 = /AGHF
|
||||
bit 3 = /ARHF
|
||||
*/
|
||||
arabian_video_control = data;
|
||||
state->video_control = data;
|
||||
}
|
||||
|
||||
|
||||
static WRITE8_DEVICE_HANDLER( ay8910_portb_w )
|
||||
{
|
||||
arabian_state *state = (arabian_state *)device->machine->driver_data;
|
||||
|
||||
/*
|
||||
bit 5 = /IREQ to custom CPU
|
||||
bit 4 = /SRES to custom CPU
|
||||
@ -112,7 +108,7 @@ static WRITE8_DEVICE_HANDLER( ay8910_portb_w )
|
||||
*/
|
||||
|
||||
/* track the custom CPU reset */
|
||||
custom_cpu_reset = ~data & 0x10;
|
||||
state->custom_cpu_reset = ~data & 0x10;
|
||||
|
||||
/* clock the coin counters */
|
||||
coin_counter_w(1, ~data & 0x02);
|
||||
@ -129,6 +125,8 @@ static WRITE8_DEVICE_HANDLER( ay8910_portb_w )
|
||||
|
||||
static READ8_HANDLER( custom_cpu_r )
|
||||
{
|
||||
arabian_state *state = (arabian_state *)space->machine->driver_data;
|
||||
|
||||
/* since we don't have a simulator for the Fujitsu 8841 4-bit microprocessor */
|
||||
/* we have to simulate its behavior; it looks like Arabian reads out of the */
|
||||
/* alternate CPU's RAM space while the CPU is running. If the CPU is not */
|
||||
@ -137,8 +135,8 @@ static READ8_HANDLER( custom_cpu_r )
|
||||
static const char *const comnames[] = { "COM0", "COM1", "COM2", "COM3", "COM4", "COM5" };
|
||||
|
||||
/* if the CPU reset line is being held down, just return RAM */
|
||||
if (custom_cpu_reset)
|
||||
return custom_cpu_ram[0x7f0 + offset];
|
||||
if (state->custom_cpu_reset)
|
||||
return state->custom_cpu_ram[0x7f0 + offset];
|
||||
|
||||
/* otherwise, assume the custom CPU is live */
|
||||
switch (offset)
|
||||
@ -157,28 +155,32 @@ static READ8_HANDLER( custom_cpu_r )
|
||||
/* it wants. There appears to be a number of different ways to make */
|
||||
/* the custom turn this on. */
|
||||
case 6:
|
||||
return custom_cpu_busy ^= 1;
|
||||
return state->custom_cpu_busy ^= 1;
|
||||
|
||||
/* handshake read; the main CPU writes to the previous memory location */
|
||||
/* and waits for the custom to copy that value here */
|
||||
case 8:
|
||||
return custom_cpu_ram[0x7f0 + offset - 1];
|
||||
return state->custom_cpu_ram[0x7f0 + offset - 1];
|
||||
|
||||
/* error cases */
|
||||
default:
|
||||
logerror("Input Port %04X read. PC=%04X\n", offset+0xd7f0, cpu_get_pc(space->cpu));
|
||||
logerror("Input Port %04X read. PC = %04X\n", offset + 0xd7f0, cpu_get_pc(space->cpu));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static WRITE8_HANDLER( custom_cpu_w )
|
||||
{
|
||||
custom_cpu_ram[0x7f0 + offset] = data;
|
||||
arabian_state *state = (arabian_state *)space->machine->driver_data;
|
||||
|
||||
state->custom_cpu_ram[0x7f0 + offset] = data;
|
||||
}
|
||||
|
||||
|
||||
static void update_flip_state(void)
|
||||
static void update_flip_state( running_machine *machine )
|
||||
{
|
||||
arabian_state *state = (arabian_state *)machine->driver_data;
|
||||
|
||||
/* the custom CPU also controls the video flip control line; unfortunately, */
|
||||
/* it appears that the custom is smart enough to flip the screen itself, based */
|
||||
/* on the information stored at $d400 and $d401. The value at $d400 specifies */
|
||||
@ -187,25 +189,29 @@ static void update_flip_state(void)
|
||||
/* state. */
|
||||
|
||||
/* initial state is based on the flip screen flag */
|
||||
arabian_flip_screen = custom_cpu_ram[0x34b];
|
||||
state->flip_screen = state->custom_cpu_ram[0x34b];
|
||||
|
||||
/* flip if not player 1 and cocktail mode */
|
||||
if (custom_cpu_ram[0x400] != 0 && !(custom_cpu_ram[0x401] & 0x02))
|
||||
arabian_flip_screen = !arabian_flip_screen;
|
||||
if (state->custom_cpu_ram[0x400] != 0 && !(state->custom_cpu_ram[0x401] & 0x02))
|
||||
state->flip_screen = !state->flip_screen;
|
||||
}
|
||||
|
||||
|
||||
static WRITE8_HANDLER( custom_flip_w )
|
||||
{
|
||||
custom_cpu_ram[0x34b + offset] = data;
|
||||
update_flip_state();
|
||||
arabian_state *state = (arabian_state *)space->machine->driver_data;
|
||||
|
||||
state->custom_cpu_ram[0x34b + offset] = data;
|
||||
update_flip_state(space->machine);
|
||||
}
|
||||
|
||||
|
||||
static WRITE8_HANDLER( custom_cocktail_w )
|
||||
{
|
||||
custom_cpu_ram[0x400 + offset] = data;
|
||||
update_flip_state();
|
||||
arabian_state *state = (arabian_state *)space->machine->driver_data;
|
||||
|
||||
state->custom_cpu_ram[0x400 + offset] = data;
|
||||
update_flip_state(space->machine);
|
||||
}
|
||||
|
||||
|
||||
@ -221,9 +227,9 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
|
||||
AM_RANGE(0x8000, 0xbfff) AM_WRITE(arabian_videoram_w)
|
||||
AM_RANGE(0xc000, 0xc000) AM_MIRROR(0x01ff) AM_READ_PORT("IN0")
|
||||
AM_RANGE(0xc200, 0xc200) AM_MIRROR(0x01ff) AM_READ_PORT("DSW1")
|
||||
AM_RANGE(0xd000, 0xd7ef) AM_RAM AM_BASE(&custom_cpu_ram)
|
||||
AM_RANGE(0xd000, 0xd7ef) AM_RAM AM_BASE_MEMBER(arabian_state, custom_cpu_ram)
|
||||
AM_RANGE(0xd7f0, 0xd7ff) AM_READWRITE(custom_cpu_r, custom_cpu_w)
|
||||
AM_RANGE(0xe000, 0xe007) AM_MIRROR(0x0ff8) AM_WRITE(arabian_blitter_w) AM_BASE(&arabian_blitter)
|
||||
AM_RANGE(0xe000, 0xe007) AM_MIRROR(0x0ff8) AM_WRITE(arabian_blitter_w) AM_BASE_MEMBER(arabian_state, blitter)
|
||||
ADDRESS_MAP_END
|
||||
|
||||
|
||||
@ -368,19 +374,35 @@ static const ay8910_interface ay8910_config =
|
||||
|
||||
static MACHINE_START( arabian )
|
||||
{
|
||||
state_save_register_global(machine, custom_cpu_reset);
|
||||
state_save_register_global(machine, custom_cpu_busy);
|
||||
arabian_state *state = (arabian_state *)machine->driver_data;
|
||||
|
||||
state_save_register_global(machine, state->custom_cpu_reset);
|
||||
state_save_register_global(machine, state->custom_cpu_busy);
|
||||
}
|
||||
|
||||
static MACHINE_RESET( arabian )
|
||||
{
|
||||
arabian_state *state = (arabian_state *)machine->driver_data;
|
||||
|
||||
state->custom_cpu_reset = 0;
|
||||
state->custom_cpu_busy = 0;
|
||||
state->video_control = 0;
|
||||
state->flip_screen = 0;
|
||||
}
|
||||
|
||||
static MACHINE_DRIVER_START( arabian )
|
||||
|
||||
/* driver data */
|
||||
MDRV_DRIVER_DATA(arabian_state)
|
||||
|
||||
/* basic machine hardware */
|
||||
MDRV_CPU_ADD("maincpu", Z80, MAIN_OSC/4)
|
||||
MDRV_CPU_PROGRAM_MAP(main_map)
|
||||
MDRV_CPU_IO_MAP(main_io_map)
|
||||
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
|
||||
|
||||
MDRV_MACHINE_START(arabian)
|
||||
MDRV_MACHINE_START(arabian)
|
||||
MDRV_MACHINE_RESET(arabian)
|
||||
|
||||
/* video hardware */
|
||||
MDRV_SCREEN_ADD("screen", RASTER)
|
||||
|
@ -6,15 +6,31 @@
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
typedef struct _arabian_state arabian_state;
|
||||
struct _arabian_state
|
||||
{
|
||||
/* memory pointers */
|
||||
UINT8 * blitter;
|
||||
UINT8 * custom_cpu_ram;
|
||||
|
||||
UINT8 * main_bitmap;
|
||||
UINT8 * converted_gfx;
|
||||
|
||||
/* video-related */
|
||||
UINT8 video_control;
|
||||
UINT8 flip_screen;
|
||||
|
||||
/* misc */
|
||||
UINT8 custom_cpu_reset;
|
||||
UINT8 custom_cpu_busy;
|
||||
};
|
||||
|
||||
|
||||
/*----------- defined in video/arabian.c -----------*/
|
||||
|
||||
extern UINT8 *arabian_blitter;
|
||||
extern UINT8 arabian_video_control;
|
||||
extern UINT8 arabian_flip_screen;
|
||||
WRITE8_HANDLER( arabian_blitter_w );
|
||||
WRITE8_HANDLER( arabian_videoram_w );
|
||||
|
||||
PALETTE_INIT( arabian );
|
||||
VIDEO_START( arabian );
|
||||
VIDEO_UPDATE( arabian );
|
||||
|
||||
WRITE8_HANDLER( arabian_blitter_w );
|
||||
WRITE8_HANDLER( arabian_videoram_w );
|
||||
|
@ -9,24 +9,11 @@
|
||||
#include "driver.h"
|
||||
#include "arabian.h"
|
||||
|
||||
|
||||
/* Constants */
|
||||
#define BITMAP_WIDTH 256
|
||||
#define BITMAP_HEIGHT 256
|
||||
|
||||
|
||||
/* Local variables */
|
||||
static UINT8 *main_bitmap;
|
||||
static UINT8 *converted_gfx;
|
||||
|
||||
|
||||
/* Globals */
|
||||
UINT8 *arabian_blitter;
|
||||
UINT8 arabian_video_control;
|
||||
UINT8 arabian_flip_screen;
|
||||
|
||||
|
||||
|
||||
/*************************************
|
||||
*
|
||||
* Color PROM conversion
|
||||
@ -166,16 +153,17 @@ PALETTE_INIT( arabian )
|
||||
|
||||
VIDEO_START( arabian )
|
||||
{
|
||||
arabian_state *state = (arabian_state *)machine->driver_data;
|
||||
UINT8 *gfxbase = memory_region(machine, "gfx1");
|
||||
int offs;
|
||||
|
||||
/* allocate a common bitmap to use for both planes */
|
||||
/* plane A (top plane with motion objects) is in the upper 4 bits */
|
||||
/* plane B (bottom plane with playfield) is in the lower 4 bits */
|
||||
main_bitmap = auto_alloc_array(machine, UINT8, BITMAP_WIDTH * BITMAP_HEIGHT);
|
||||
state->main_bitmap = auto_alloc_array(machine, UINT8, BITMAP_WIDTH * BITMAP_HEIGHT);
|
||||
|
||||
/* allocate memory for the converted graphics data */
|
||||
converted_gfx = auto_alloc_array(machine, UINT8, 0x8000 * 2);
|
||||
state->converted_gfx = auto_alloc_array(machine, UINT8, 0x8000 * 2);
|
||||
|
||||
/*--------------------------------------------------
|
||||
transform graphics data into more usable format
|
||||
@ -212,16 +200,16 @@ VIDEO_START( arabian )
|
||||
v2 >>= 1;
|
||||
p4 = (v1 & 0x01) | ((v1 & 0x10) >> 3) | ((v2 & 0x01) << 2) | ((v2 & 0x10) >> 1);
|
||||
|
||||
converted_gfx[offs * 4 + 3] = p1;
|
||||
converted_gfx[offs * 4 + 2] = p2;
|
||||
converted_gfx[offs * 4 + 1] = p3;
|
||||
converted_gfx[offs * 4 + 0] = p4;
|
||||
state->converted_gfx[offs * 4 + 3] = p1;
|
||||
state->converted_gfx[offs * 4 + 2] = p2;
|
||||
state->converted_gfx[offs * 4 + 1] = p3;
|
||||
state->converted_gfx[offs * 4 + 0] = p4;
|
||||
}
|
||||
|
||||
state_save_register_global_pointer(machine, main_bitmap, BITMAP_WIDTH * BITMAP_HEIGHT);
|
||||
state_save_register_global_pointer(machine, converted_gfx, 0x8000 * 2);
|
||||
state_save_register_global(machine, arabian_video_control);
|
||||
state_save_register_global(machine, arabian_flip_screen);
|
||||
state_save_register_global_pointer(machine, state->main_bitmap, BITMAP_WIDTH * BITMAP_HEIGHT);
|
||||
state_save_register_global_pointer(machine, state->converted_gfx, 0x8000 * 2);
|
||||
state_save_register_global(machine, state->video_control);
|
||||
state_save_register_global(machine, state->flip_screen);
|
||||
}
|
||||
|
||||
|
||||
@ -232,9 +220,10 @@ VIDEO_START( arabian )
|
||||
*
|
||||
*************************************/
|
||||
|
||||
static void blit_area(UINT8 plane, UINT16 src, UINT8 x, UINT8 y, UINT8 sx, UINT8 sy)
|
||||
static void blit_area( running_machine *machine, UINT8 plane, UINT16 src, UINT8 x, UINT8 y, UINT8 sx, UINT8 sy )
|
||||
{
|
||||
UINT8 *srcdata = &converted_gfx[src * 4];
|
||||
arabian_state *state = (arabian_state *)machine->driver_data;
|
||||
UINT8 *srcdata = &state->converted_gfx[src * 4];
|
||||
int i,j;
|
||||
|
||||
/* loop over X, then Y */
|
||||
@ -248,7 +237,7 @@ static void blit_area(UINT8 plane, UINT16 src, UINT8 x, UINT8 y, UINT8 sx, UINT8
|
||||
UINT8 *base;
|
||||
|
||||
/* get a pointer to the bitmap */
|
||||
base = &main_bitmap[((y + j) & 0xff) * BITMAP_WIDTH + (x & 0xff)];
|
||||
base = &state->main_bitmap[((y + j) & 0xff) * BITMAP_WIDTH + (x & 0xff)];
|
||||
|
||||
/* bit 0 means write to upper plane (upper 4 bits of our bitmap) */
|
||||
if (plane & 0x01)
|
||||
@ -280,22 +269,24 @@ static void blit_area(UINT8 plane, UINT16 src, UINT8 x, UINT8 y, UINT8 sx, UINT8
|
||||
|
||||
WRITE8_HANDLER( arabian_blitter_w )
|
||||
{
|
||||
arabian_state *state = (arabian_state *)space->machine->driver_data;
|
||||
|
||||
/* write the data */
|
||||
arabian_blitter[offset] = data;
|
||||
state->blitter[offset] = data;
|
||||
|
||||
/* watch for a write to offset 6 -- that triggers the blit */
|
||||
if (offset == 6)
|
||||
{
|
||||
/* extract the data */
|
||||
int plane = arabian_blitter[0];
|
||||
int src = arabian_blitter[1] | (arabian_blitter[2] << 8);
|
||||
int x = arabian_blitter[4] << 2;
|
||||
int y = arabian_blitter[3];
|
||||
int sx = arabian_blitter[6];
|
||||
int sy = arabian_blitter[5];
|
||||
int plane = state->blitter[0];
|
||||
int src = state->blitter[1] | (state->blitter[2] << 8);
|
||||
int x = state->blitter[4] << 2;
|
||||
int y = state->blitter[3];
|
||||
int sx = state->blitter[6];
|
||||
int sy = state->blitter[5];
|
||||
|
||||
/* blit it */
|
||||
blit_area(plane, src, x, y, sx, sy);
|
||||
blit_area(space->machine, plane, src, x, y, sx, sy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,6 +300,7 @@ WRITE8_HANDLER( arabian_blitter_w )
|
||||
|
||||
WRITE8_HANDLER( arabian_videoram_w )
|
||||
{
|
||||
arabian_state *state = (arabian_state *)space->machine->driver_data;
|
||||
UINT8 *base;
|
||||
UINT8 x, y;
|
||||
|
||||
@ -317,7 +309,7 @@ WRITE8_HANDLER( arabian_videoram_w )
|
||||
y = offset & 0xff;
|
||||
|
||||
/* get a pointer to the pixels */
|
||||
base = &main_bitmap[y * BITMAP_WIDTH + x];
|
||||
base = &state->main_bitmap[y * BITMAP_WIDTH + x];
|
||||
|
||||
/* the data is written as 4 2-bit values, as follows:
|
||||
|
||||
@ -332,7 +324,7 @@ WRITE8_HANDLER( arabian_videoram_w )
|
||||
*/
|
||||
|
||||
/* enable writes to AZ/AR */
|
||||
if (arabian_blitter[0] & 0x08)
|
||||
if (state->blitter[0] & 0x08)
|
||||
{
|
||||
base[0] = (base[0] & ~0x03) | ((data & 0x10) >> 3) | ((data & 0x01) >> 0);
|
||||
base[1] = (base[1] & ~0x03) | ((data & 0x20) >> 4) | ((data & 0x02) >> 1);
|
||||
@ -341,7 +333,7 @@ WRITE8_HANDLER( arabian_videoram_w )
|
||||
}
|
||||
|
||||
/* enable writes to AG/AB */
|
||||
if (arabian_blitter[0] & 0x04)
|
||||
if (state->blitter[0] & 0x04)
|
||||
{
|
||||
base[0] = (base[0] & ~0x0c) | ((data & 0x10) >> 1) | ((data & 0x01) << 2);
|
||||
base[1] = (base[1] & ~0x0c) | ((data & 0x20) >> 2) | ((data & 0x02) << 1);
|
||||
@ -350,7 +342,7 @@ WRITE8_HANDLER( arabian_videoram_w )
|
||||
}
|
||||
|
||||
/* enable writes to BZ/BR */
|
||||
if (arabian_blitter[0] & 0x02)
|
||||
if (state->blitter[0] & 0x02)
|
||||
{
|
||||
base[0] = (base[0] & ~0x30) | ((data & 0x10) << 1) | ((data & 0x01) << 4);
|
||||
base[1] = (base[1] & ~0x30) | ((data & 0x20) << 0) | ((data & 0x02) << 3);
|
||||
@ -359,7 +351,7 @@ WRITE8_HANDLER( arabian_videoram_w )
|
||||
}
|
||||
|
||||
/* enable writes to BG/BB */
|
||||
if (arabian_blitter[0] & 0x01)
|
||||
if (state->blitter[0] & 0x01)
|
||||
{
|
||||
base[0] = (base[0] & ~0xc0) | ((data & 0x10) << 3) | ((data & 0x01) << 6);
|
||||
base[1] = (base[1] & ~0xc0) | ((data & 0x20) << 2) | ((data & 0x02) << 5);
|
||||
@ -378,15 +370,16 @@ WRITE8_HANDLER( arabian_videoram_w )
|
||||
|
||||
VIDEO_UPDATE( arabian )
|
||||
{
|
||||
const pen_t *pens = &screen->machine->pens[(arabian_video_control >> 3) << 8];
|
||||
arabian_state *state = (arabian_state *)screen->machine->driver_data;
|
||||
const pen_t *pens = &screen->machine->pens[(state->video_control >> 3) << 8];
|
||||
int y;
|
||||
|
||||
/* render the screen from the bitmap */
|
||||
for (y = 0; y < BITMAP_HEIGHT; y++)
|
||||
{
|
||||
/* non-flipped case */
|
||||
if (!arabian_flip_screen)
|
||||
draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &main_bitmap[y * BITMAP_WIDTH], pens);
|
||||
if (!state->flip_screen)
|
||||
draw_scanline8(bitmap, 0, y, BITMAP_WIDTH, &state->main_bitmap[y * BITMAP_WIDTH], pens);
|
||||
|
||||
/* flipped case */
|
||||
else
|
||||
@ -394,7 +387,7 @@ VIDEO_UPDATE( arabian )
|
||||
UINT8 scanline[BITMAP_WIDTH];
|
||||
int x;
|
||||
for (x = 0; x < BITMAP_WIDTH; x++)
|
||||
scanline[BITMAP_WIDTH - 1 - x] = main_bitmap[y * BITMAP_WIDTH + x];
|
||||
scanline[BITMAP_WIDTH - 1 - x] = state->main_bitmap[y * BITMAP_WIDTH + x];
|
||||
draw_scanline8(bitmap, 0, BITMAP_HEIGHT - 1 - y, BITMAP_WIDTH, scanline, pens);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user