And now, something worth a mention: added full driver data struct to changela.c, circus.c and circusc.c

This commit is contained in:
Fabio Priuli 2009-11-22 00:15:07 +00:00
parent 2744c3711c
commit 9307f270e5
11 changed files with 677 additions and 516 deletions

1
.gitattributes vendored
View File

@ -2367,6 +2367,7 @@ src/mame/includes/changela.h svneol=native#text/plain
src/mame/includes/cidelsa.h svneol=native#text/plain
src/mame/includes/cinemat.h svneol=native#text/plain
src/mame/includes/circus.h svneol=native#text/plain
src/mame/includes/circusc.h svneol=native#text/plain
src/mame/includes/cischeat.h svneol=native#text/plain
src/mame/includes/cloak.h svneol=native#text/plain
src/mame/includes/cloud9.h svneol=native#text/plain

View File

@ -2,8 +2,6 @@
#include "sound/samples.h"
#include "circus.h"
int circus_game;
static const char *const circus_sample_names[] =
{
"*circus",
@ -174,69 +172,68 @@ DISCRETE_SOUND_END
WRITE8_HANDLER( circus_clown_z_w )
{
const device_config *samples = devtag_get_device(space->machine, "samples");
const device_config *discrete = devtag_get_device(space->machine, "discrete");
circus_state *state = (circus_state *)space->machine->driver_data;
state->clown_z = (data & 0x0f);
*(memory_region(space->machine, "maincpu") + 0x8000) = data; logerror("Z:%02x\n",data); //DEBUG
clown_z = (data & 0x0f);
*(memory_region(space->machine, "maincpu")+0x8000)=data; logerror("Z:%02x\n",data); //DEBUG
/* Bits 4-6 enable/disable trigger different events */
switch (circus_game)
switch (state->game_id)
{
case 1: /* circus */
case 4: /* ripcord */
switch ((data & 0x70) >> 4)
{
case 0 : /* All Off */
discrete_sound_w(discrete, CIRCUS_MUSIC_BIT, 0);
discrete_sound_w(state->discrete, CIRCUS_MUSIC_BIT, 0);
break;
case 1 : /* Music */
discrete_sound_w(discrete, CIRCUS_MUSIC_BIT, 1);
discrete_sound_w(state->discrete, CIRCUS_MUSIC_BIT, 1);
break;
case 2 : /* Circus = Pop; Rip Cord = Splash */
sample_start (samples, 0, 0, 0);
sample_start(state->samples, 0, 0, 0);
break;
case 3 : /* Normal Video */
break;
case 4 : /* Circus = Miss; Rip Cord = Scream */
sample_start (samples, 1, 1, 0);
sample_start(state->samples, 1, 1, 0);
break;
case 5 : /* Invert Video */
break;
case 6 : /* Circus = Bounce; Rip Cord = Chute Open */
sample_start (samples, 2, 2, 0);
sample_start(state->samples, 2, 2, 0);
break;
case 7 : /* Circus = not used; Rip Cord = Whistle */
if GAME_IS_RIPCORD
sample_start (samples, 3, 3, 0);
sample_start(state->samples, 3, 3, 0);
break;
}
break;
case 2: /* robotbwl */
discrete_sound_w(discrete, ROBOTBWL_MUSIC_BIT, data & 0x08); /* Footsteps */
discrete_sound_w(state->discrete, ROBOTBWL_MUSIC_BIT, data & 0x08); /* Footsteps */
if (data & 0x40) /* Hit */
sample_start (samples, 0, 0, 0);
sample_start(state->samples, 0, 0, 0);
if (data & 0x20) /* Roll */
sample_start (samples, 1, 1, 0);
sample_start(state->samples, 1, 1, 0);
if (data & 0x10) /* Ball Drop */
sample_start (samples, 2, 2, 0);
sample_start(state->samples, 2, 2, 0);
if (data & 0x02) /* Demerit */
sample_start (samples, 3, 3, 0);
sample_start(state->samples, 3, 3, 0);
if (data & 0x01) /* Reward */
sample_start (samples, 4, 4, 0);
sample_start(state->samples, 4, 4, 0);
// if (data & 0x04) /* Invert */
break;
@ -246,26 +243,26 @@ WRITE8_HANDLER( circus_clown_z_w )
switch ((data & 0x70) >> 4)
{
case 0 : /* All Off */
discrete_sound_w(discrete, CRASH_MUSIC_BIT, 0);
discrete_sound_w(state->discrete, CRASH_MUSIC_BIT, 0);
break;
case 1 : /* Music */
discrete_sound_w(discrete, CRASH_MUSIC_BIT, 1);
discrete_sound_w(state->discrete, CRASH_MUSIC_BIT, 1);
break;
case 2 : /* Crash */
sample_start (samples, 0, 0, 0);
sample_start(state->samples, 0, 0, 0);
break;
case 3 : /* Normal Video and Beep */
discrete_sound_w(discrete, CRASH_BEEPER_EN, 0);
discrete_sound_w(state->discrete, CRASH_BEEPER_EN, 0);
break;
case 4 : /* Skid */
break;
case 5 : /* Invert Video and Beep */
discrete_sound_w(discrete, CRASH_BEEPER_EN, 0);
discrete_sound_w(state->discrete, CRASH_BEEPER_EN, 0);
break;
case 6 : /* Hi Motor */

View File

@ -18,127 +18,101 @@ Tomasz Slanina
#include "changela.lh"
static UINT8 portA_in,portA_out,ddrA;
static UINT8 portB_out,ddrB;
static UINT8 portC_in,portC_out,ddrC;
static UINT8 mcu_out;
static UINT8 mcu_in;
static UINT8 mcu_PC1;
static UINT8 mcu_PC0;
UINT8 changela_tree0_col;
UINT8 changela_tree1_col;
UINT8 changela_left_bank_col;
UINT8 changela_right_bank_col;
UINT8 changela_boat_shore_col;
UINT8 changela_collision_reset;
UINT8 changela_tree_collision_reset;
static MACHINE_RESET (changela)
{
mcu_PC1=0;
mcu_PC0=0;
changela_tree0_col = 0;
changela_tree1_col = 0;
changela_left_bank_col = 0;
changela_right_bank_col = 0;
changela_boat_shore_col = 0;
changela_collision_reset = 0;
changela_tree_collision_reset = 0;
}
static READ8_HANDLER( mcu_r )
{
//mame_printf_debug("Z80 MCU R = %x\n",mcu_out);
return mcu_out;
changela_state *state = (changela_state *)space->machine->driver_data;
//mame_printf_debug("Z80 MCU R = %x\n", state->mcu_out);
return state->mcu_out;
}
/* latch LS374 at U39 */
static WRITE8_HANDLER( mcu_w )
{
mcu_in = data;
changela_state *state = (changela_state *)space->machine->driver_data;
state->mcu_in = data;
}
/*********************************
MCU
*********************************/
static READ8_HANDLER( changela_68705_portA_r )
static READ8_HANDLER( changela_68705_port_a_r )
{
return (portA_out & ddrA) | (portA_in & ~ddrA);
changela_state *state = (changela_state *)space->machine->driver_data;
return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
}
static WRITE8_HANDLER( changela_68705_portA_w )
static WRITE8_HANDLER( changela_68705_port_a_w )
{
portA_out = data;
changela_state *state = (changela_state *)space->machine->driver_data;
state->port_a_out = data;
}
static WRITE8_HANDLER( changela_68705_ddrA_w )
static WRITE8_HANDLER( changela_68705_ddr_a_w )
{
ddrA = data;
changela_state *state = (changela_state *)space->machine->driver_data;
state->ddr_a = data;
}
static READ8_HANDLER( changela_68705_portB_r )
static READ8_HANDLER( changela_68705_port_b_r )
{
return (portB_out & ddrB) | (input_port_read(space->machine, "MCU") & ~ddrB);
changela_state *state = (changela_state *)space->machine->driver_data;
return (state->port_b_out & state->ddr_b) | (input_port_read(space->machine, "MCU") & ~state->ddr_b);
}
static WRITE8_HANDLER( changela_68705_portB_w )
static WRITE8_HANDLER( changela_68705_port_b_w )
{
portB_out = data;
changela_state *state = (changela_state *)space->machine->driver_data;
state->port_b_out = data;
}
static WRITE8_HANDLER( changela_68705_ddrB_w )
static WRITE8_HANDLER( changela_68705_ddr_b_w )
{
ddrB = data;
changela_state *state = (changela_state *)space->machine->driver_data;
state->ddr_b = data;
}
static READ8_HANDLER( changela_68705_portC_r )
static READ8_HANDLER( changela_68705_port_c_r )
{
return (portC_out & ddrC) | (portC_in & ~ddrC);
changela_state *state = (changela_state *)space->machine->driver_data;
return (state->port_c_out & state->ddr_c) | (state->port_c_in & ~state->ddr_c);
}
static WRITE8_HANDLER( changela_68705_portC_w )
static WRITE8_HANDLER( changela_68705_port_c_w )
{
changela_state *state = (changela_state *)space->machine->driver_data;
/* PC3 is connected to the CLOCK input of the LS374,
so we latch the data on positive going edge of the clock */
/* this is strange because if we do this corectly - it just doesn't work */
if( (data&8) /*& (!(portC_out&8))*/ )
mcu_out = portA_out;
if ((data & 8) /*& (!(state->port_c_out & 8))*/ )
state->mcu_out = state->port_a_out;
/* PC2 is connected to the /OE input of the LS374 */
if (!(data & 4))
state->port_a_in = state->mcu_in;
if(!(data&4))
portA_in = mcu_in;
portC_out = data;
state->port_c_out = data;
}
static WRITE8_HANDLER( changela_68705_ddrC_w )
static WRITE8_HANDLER( changela_68705_ddr_c_w )
{
ddrC = data;
changela_state *state = (changela_state *)space->machine->driver_data;
state->ddr_c = data;
}
static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7ff)
AM_RANGE(0x0000, 0x0000) AM_READWRITE(changela_68705_portA_r, changela_68705_portA_w)
AM_RANGE(0x0001, 0x0001) AM_READWRITE(changela_68705_portB_r, changela_68705_portB_w)
AM_RANGE(0x0002, 0x0002) AM_READWRITE(changela_68705_portC_r, changela_68705_portC_w)
AM_RANGE(0x0000, 0x0000) AM_READWRITE(changela_68705_port_a_r, changela_68705_port_a_w)
AM_RANGE(0x0001, 0x0001) AM_READWRITE(changela_68705_port_b_r, changela_68705_port_b_w)
AM_RANGE(0x0002, 0x0002) AM_READWRITE(changela_68705_port_c_r, changela_68705_port_c_w)
AM_RANGE(0x0004, 0x0004) AM_WRITE(changela_68705_ddrA_w)
AM_RANGE(0x0005, 0x0005) AM_WRITE(changela_68705_ddrB_w)
AM_RANGE(0x0006, 0x0006) AM_WRITE(changela_68705_ddrC_w)
AM_RANGE(0x0004, 0x0004) AM_WRITE(changela_68705_ddr_a_w)
AM_RANGE(0x0005, 0x0005) AM_WRITE(changela_68705_ddr_b_w)
AM_RANGE(0x0006, 0x0006) AM_WRITE(changela_68705_ddr_c_w)
AM_RANGE(0x0000, 0x007f) AM_RAM
AM_RANGE(0x0080, 0x07ff) AM_ROM
@ -149,13 +123,15 @@ ADDRESS_MAP_END
/* U30 */
static READ8_HANDLER( changela_24_r )
{
return ((portC_out&2)<<2) | 7; /* bits 2,1,0-N/C inputs */
changela_state *state = (changela_state *)space->machine->driver_data;
return ((state->port_c_out & 2) << 2) | 7; /* bits 2,1,0-N/C inputs */
}
static READ8_HANDLER( changela_25_r )
{
changela_state *state = (changela_state *)space->machine->driver_data;
//collisions on bits 3,2, bits 1,0-N/C inputs
return (changela_tree1_col << 3) | (changela_tree0_col << 2) | 0x03;
return (state->tree1_col << 3) | (state->tree0_col << 2) | 0x03;
}
static READ8_HANDLER( changela_30_r )
@ -165,31 +141,30 @@ static READ8_HANDLER( changela_30_r )
static READ8_HANDLER( changela_31_r )
{
changela_state *state = (changela_state *)space->machine->driver_data;
/* If the new value is less than the old value, and it did not wrap around,
or if the new value is greater than the old value, and it did wrap around,
then we are moving LEFT. */
static UINT8 prev_value = 0;
UINT8 curr_value = input_port_read(space->machine, "WHEEL");
static int dir = 0;
if( (curr_value < prev_value && (prev_value - curr_value) < 0x80)
|| (curr_value > prev_value && (curr_value - prev_value) > 0x80) )
dir = 1;
if( (prev_value < curr_value && (curr_value - prev_value) < 0x80)
|| (prev_value > curr_value && (prev_value - curr_value) > 0x80) )
dir = 0;
if ((curr_value < state->prev_value_31 && (state->prev_value_31 - curr_value) < 0x80)
|| (curr_value > state->prev_value_31 && (curr_value - state->prev_value_31) > 0x80))
state->dir_31 = 1;
if ((state->prev_value_31 < curr_value && (curr_value - state->prev_value_31) < 0x80)
|| (state->prev_value_31 > curr_value && (state->prev_value_31 - curr_value) > 0x80))
state->dir_31 = 0;
prev_value = curr_value;
state->prev_value_31 = curr_value;
//wheel UP/DOWN control signal on bit 3, collisions on bits:2,1,0
return (dir << 3) | (changela_left_bank_col << 2) | (changela_right_bank_col << 1) | changela_boat_shore_col;
return (state->dir_31 << 3) | (state->left_bank_col << 2) | (state->right_bank_col << 1) | state->boat_shore_col;
}
static READ8_HANDLER( changela_2c_r )
{
int val = input_port_read(space->machine, "IN0");
val = (val&0x30) | ((val&1)<<7) | (((val&1)^1)<<6);
val = (val & 0x30) | ((val & 1) << 7) | (((val & 1) ^ 1) << 6);
return val;
}
@ -200,11 +175,11 @@ static READ8_HANDLER( changela_2d_r )
int v8 = 0;
int gas;
if ((video_screen_get_vpos(space->machine->primary_screen) & 0xf8)==0xf8)
if ((video_screen_get_vpos(space->machine->primary_screen) & 0xf8) == 0xf8)
v8 = 1;
/* Gas pedal is made up of 2 switches, 1 active low, 1 active high */
switch(input_port_read(space->machine, "IN1") & 0x03)
switch (input_port_read(space->machine, "IN1") & 0x03)
{
case 0x02:
gas = 0x80;
@ -217,35 +192,38 @@ static READ8_HANDLER( changela_2d_r )
break;
}
return (input_port_read(space->machine, "IN1") & 0x20) | gas | (v8<<4);
return (input_port_read(space->machine, "IN1") & 0x20) | gas | (v8 << 4);
}
static WRITE8_HANDLER( mcu_PC0_w )
static WRITE8_HANDLER( mcu_pc_0_w )
{
portC_in = (portC_in&0xfe) | (data&1);
changela_state *state = (changela_state *)space->machine->driver_data;
state->port_c_in = (state->port_c_in & 0xfe) | (data & 1);
}
static WRITE8_HANDLER( changela_collision_reset_0 )
{
changela_collision_reset = data & 0x01;
changela_state *state = (changela_state *)space->machine->driver_data;
state->collision_reset = data & 0x01;
}
static WRITE8_HANDLER( changela_collision_reset_1 )
{
changela_tree_collision_reset = data & 0x01;
changela_state *state = (changela_state *)space->machine->driver_data;
state->tree_collision_reset = data & 0x01;
}
static WRITE8_HANDLER( changela_coin_counter_w )
{
coin_counter_w(offset,data);
coin_counter_w(offset, data);
}
static ADDRESS_MAP_START( changela_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE(&spriteram) /* OBJ0 RAM */
AM_RANGE(0x9000, 0x97ff) AM_RAM AM_BASE(&videoram) /* OBJ1 RAM */
AM_RANGE(0xa000, 0xa07f) AM_WRITE(changela_colors_w) AM_BASE(&colorram) /* Color 93419 RAM 64x9(nine!!!) bits A0-used as the 8-th bit data input (d0-d7->normal, a0->d8) */
AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE_MEMBER(changela_state, spriteram) /* OBJ0 RAM */
AM_RANGE(0x9000, 0x97ff) AM_RAM AM_BASE_MEMBER(changela_state, videoram) /* OBJ1 RAM */
AM_RANGE(0xa000, 0xa07f) AM_WRITE(changela_colors_w) AM_BASE_MEMBER(changela_state, colorram) /* Color 93419 RAM 64x9(nine!!!) bits A0-used as the 8-th bit data input (d0-d7->normal, a0->d8) */
AM_RANGE(0xb000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(changela_mem_device_r, changela_mem_device_w) /* RAM4 (River Bed RAM); RAM5 (Tree RAM) */
@ -265,7 +243,7 @@ static ADDRESS_MAP_START( changela_map, ADDRESS_SPACE_PROGRAM, 8 )
//AM_RANGE(0xd023, 0xd023) AM_WRITENOP
/* LS139 - U24 */
AM_RANGE(0xd024, 0xd024) AM_READWRITE(changela_24_r, mcu_PC0_w)
AM_RANGE(0xd024, 0xd024) AM_READWRITE(changela_24_r, mcu_pc_0_w)
AM_RANGE(0xd025, 0xd025) AM_READWRITE(changela_25_r, changela_collision_reset_1)
AM_RANGE(0xd026, 0xd026) AM_WRITENOP
AM_RANGE(0xd028, 0xd028) AM_READ(mcu_r)
@ -458,8 +436,92 @@ static INTERRUPT_GEN( chl_interrupt )
}
static MACHINE_START(changela)
{
changela_state *state = (changela_state *)machine->driver_data;
/* video */
state_save_register_global(machine, state->slopeROM_bank);
state_save_register_global(machine, state->tree_en);
state_save_register_global(machine, state->horizon);
state_save_register_global(machine, state->mem_dev_selected);
state_save_register_global(machine, state->v_count_river);
state_save_register_global(machine, state->v_count_tree);
state_save_register_global_array(machine, state->tree_on);
/* mcu */
state_save_register_global(machine, state->port_a_in);
state_save_register_global(machine, state->port_a_out);
state_save_register_global(machine, state->ddr_a);
state_save_register_global(machine, state->port_b_out);
state_save_register_global(machine, state->ddr_b);
state_save_register_global(machine, state->port_c_in);
state_save_register_global(machine, state->port_c_out);
state_save_register_global(machine, state->ddr_c);
state_save_register_global(machine, state->mcu_out);
state_save_register_global(machine, state->mcu_in);
state_save_register_global(machine, state->mcu_pc_1);
state_save_register_global(machine, state->mcu_pc_0);
/* misc */
state_save_register_global(machine, state->tree0_col);
state_save_register_global(machine, state->tree1_col);
state_save_register_global(machine, state->left_bank_col);
state_save_register_global(machine, state->right_bank_col);
state_save_register_global(machine, state->boat_shore_col);
state_save_register_global(machine, state->collision_reset);
state_save_register_global(machine, state->tree_collision_reset);
state_save_register_global(machine, state->prev_value_31);
state_save_register_global(machine, state->dir_31);
}
static MACHINE_RESET (changela)
{
changela_state *state = (changela_state *)machine->driver_data;
/* video */
state->slopeROM_bank = 0;
state->tree_en = 0;
state->horizon = 0;
state->mem_dev_selected = 0;
state->v_count_river = 0;
state->v_count_tree = 0;
state->tree_on[0] = 0;
state->tree_on[1] = 0;
/* mcu */
state->mcu_pc_1 = 0;
state->mcu_pc_0 = 0;
state->port_a_in = 0;
state->port_a_out = 0;
state->ddr_a = 0;
state->port_b_out = 0;
state->ddr_b = 0;
state->port_c_in = 0;
state->port_c_out = 0;
state->ddr_c = 0;
state->mcu_out = 0;
state->mcu_in = 0;
/* misc */
state->tree0_col = 0;
state->tree1_col = 0;
state->left_bank_col = 0;
state->right_bank_col = 0;
state->boat_shore_col = 0;
state->collision_reset = 0;
state->tree_collision_reset = 0;
state->prev_value_31 = 0;
state->dir_31 = 0;
}
static MACHINE_DRIVER_START( changela )
/* driver data */
MDRV_DRIVER_DATA(changela_state)
MDRV_CPU_ADD("maincpu", Z80,5000000)
MDRV_CPU_PROGRAM_MAP(changela_map)
MDRV_CPU_VBLANK_INT_HACK(chl_interrupt,4)
@ -467,9 +529,9 @@ static MACHINE_DRIVER_START( changela )
MDRV_CPU_ADD("mcu", M68705,2500000)
MDRV_CPU_PROGRAM_MAP(mcu_map)
MDRV_MACHINE_START(changela)
MDRV_MACHINE_RESET(changela)
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
@ -528,29 +590,4 @@ ROM_START( changela )
ROM_LOAD( "cl88", 0x0000, 0x0020, CRC(da4d6625) SHA1(2d9a268973518252eb36f479ab650af8c16c885c) ) /* math train state machine */
ROM_END
static DRIVER_INIT(changela)
{
state_save_register_global(machine, portA_in);
state_save_register_global(machine, portA_out);
state_save_register_global(machine, ddrA);
state_save_register_global(machine, portB_out);
state_save_register_global(machine, ddrB);
state_save_register_global(machine, portC_in);
state_save_register_global(machine, portC_out);
state_save_register_global(machine, ddrC);
state_save_register_global(machine, mcu_out);
state_save_register_global(machine, mcu_in);
state_save_register_global(machine, mcu_PC1);
state_save_register_global(machine, mcu_PC0);
state_save_register_global(machine, changela_tree0_col);
state_save_register_global(machine, changela_tree1_col);
state_save_register_global(machine, changela_left_bank_col);
state_save_register_global(machine, changela_right_bank_col);
state_save_register_global(machine, changela_boat_shore_col);
state_save_register_global(machine, changela_collision_reset);
state_save_register_global(machine, changela_tree_collision_reset);
}
GAMEL( 1983, changela, 0, changela, changela, changela, ROT180, "Taito Corporation", "Change Lanes", GAME_SUPPORTS_SAVE, layout_changela )
GAMEL( 1983, changela, 0, changela, changela, 0, ROT180, "Taito Corporation", "Change Lanes", GAME_SUPPORTS_SAVE, layout_changela )

View File

@ -43,12 +43,11 @@ D000 Paddle Position and Interrupt Reset
#include "crash.lh"
#if 0
static int circus_interrupt;
static READ8_HANDLER( ripcord_IN2_r )
{
circus_interrupt ++;
logerror("circus_int: %02x\n", circus_interrupt);
circus_state *state = (circus_state *)space->machine->driver_data;
state->interrupt++;
logerror("circus_int: %02x\n", state->interrupt);
return readinputport (2);
}
#endif
@ -60,7 +59,7 @@ static ADDRESS_MAP_START( circus_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1000, 0x1fff) AM_ROM
AM_RANGE(0x2000, 0x2000) AM_WRITE(circus_clown_x_w)
AM_RANGE(0x3000, 0x3000) AM_WRITE(circus_clown_y_w)
AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(circus_videoram_w) AM_BASE(&videoram)
AM_RANGE(0x4000, 0x43ff) AM_RAM_WRITE(circus_videoram_w) AM_BASE_MEMBER(circus_state, videoram)
AM_RANGE(0x8000, 0x8000) AM_RAM_WRITE(circus_clown_z_w)
AM_RANGE(0xa000, 0xa000) AM_READ_PORT("INPUTS")
AM_RANGE(0xc000, 0xc000) AM_READ_PORT("DSW")
@ -261,17 +260,45 @@ GFXDECODE_END
#if 0
static INTERRUPT_GEN( ripcord_interrupt )
{
circus_interrupt = 0;
state->interrupt = 0;
}
#endif
static MACHINE_START( circus )
{
circus_state *state = (circus_state *)machine->driver_data;
state->samples = devtag_get_device(machine, "samples");
state->discrete = devtag_get_device(machine, "discrete");
state_save_register_global(machine, state->clown_x);
state_save_register_global(machine, state->clown_y);
state_save_register_global(machine, state->clown_z);
}
static MACHINE_RESET( circus )
{
circus_state *state = (circus_state *)machine->driver_data;
state->clown_x = 0;
state->clown_y = 0;
state->clown_z = 0;
}
static MACHINE_DRIVER_START( circus )
/* driver data */
MDRV_DRIVER_DATA(circus_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, XTAL_11_289MHz / 16) /* 705.562kHz */
MDRV_CPU_PROGRAM_MAP(circus_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(circus)
MDRV_MACHINE_RESET(circus)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(57)
@ -304,9 +331,15 @@ static MACHINE_DRIVER_START( robotbwl )
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, XTAL_11_289MHz / 16) /* 705.562kHz */
/* driver data */
MDRV_DRIVER_DATA(circus_state)
MDRV_CPU_PROGRAM_MAP(circus_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(circus)
MDRV_MACHINE_RESET(circus)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(57)
@ -336,11 +369,17 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( crash )
/* driver data */
MDRV_DRIVER_DATA(circus_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, XTAL_11_289MHz / 16) /* 705.562kHz */
MDRV_CPU_PROGRAM_MAP(circus_map)
MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,2)
MDRV_MACHINE_START(circus)
MDRV_MACHINE_RESET(circus)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(57)
@ -370,11 +409,17 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( ripcord )
/* driver data */
MDRV_DRIVER_DATA(circus_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, XTAL_11_289MHz / 16) /* 705.562kHz */
MDRV_CPU_PROGRAM_MAP(circus_map)
//MDRV_CPU_VBLANK_INT("screen", ripcord_interrupt) //AT
MDRV_MACHINE_START(circus)
MDRV_MACHINE_RESET(circus)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(57)
@ -516,20 +561,24 @@ ROM_END
static DRIVER_INIT( circus )
{
circus_game = 1;
circus_state *state = (circus_state *)machine->driver_data;
state->game_id = 1;
}
static DRIVER_INIT( robotbwl )
{
circus_game = 2;
circus_state *state = (circus_state *)machine->driver_data;
state->game_id = 2;
}
static DRIVER_INIT( crash )
{
circus_game = 3;
circus_state *state = (circus_state *)machine->driver_data;
state->game_id = 3;
}
static DRIVER_INIT( ripcord )
{
circus_game = 4;
circus_state *state = (circus_state *)machine->driver_data;
state->game_id = 4;
}

View File

@ -54,31 +54,25 @@ To enter service mode, keep 1&2 pressed on reset
#include "sound/dac.h"
#include "sound/sn76496.h"
#include "sound/discrete.h"
extern UINT8 *circusc_spritebank;
extern UINT8 *circusc_scroll;
extern UINT8 *circusc_videoram,*circusc_colorram;
static UINT8 sn_latch;
WRITE8_HANDLER( circusc_videoram_w );
WRITE8_HANDLER( circusc_colorram_w );
VIDEO_START( circusc );
WRITE8_HANDLER( circusc_flipscreen_w );
PALETTE_INIT( circusc );
VIDEO_UPDATE( circusc );
#include "circusc.h"
static MACHINE_START( circusc )
{
state_save_register_global(machine, sn_latch);
circusc_state *state = (circusc_state *)machine->driver_data;
state->sn1 = devtag_get_device(machine, "sn1");
state->sn2 = devtag_get_device(machine, "sn2");
state->dac = devtag_get_device(machine, "dac");
state->discrete = devtag_get_device(machine, "fltdisc");
state_save_register_global(machine, state->sn_latch);
}
static MACHINE_RESET( circusc )
{
sn_latch = 0;
circusc_state *state = (circusc_state *)machine->driver_data;
state->sn_latch = 0;
}
static READ8_HANDLER( circusc_sh_timer_r )
@ -108,45 +102,40 @@ static WRITE8_HANDLER( circusc_sh_irqtrigger_w )
static WRITE8_HANDLER( circusc_coin_counter_w )
{
coin_counter_w(offset,data);
coin_counter_w(offset, data);
}
static WRITE8_HANDLER(circusc_sound_w)
{
const device_config *device;
//int c;
circusc_state *state = (circusc_state *)space->machine->driver_data;
switch (offset & 7)
{
/* CS2 */
case 0:
sn_latch = data;
state->sn_latch = data;
break;
/* CS3 */
case 1:
device = devtag_get_device(space->machine, "sn1");
sn76496_w(device, 0, sn_latch);
sn76496_w(state->sn1, 0, state->sn_latch);
break;
/* CS4 */
case 2:
device = devtag_get_device(space->machine, "sn2");
sn76496_w(device, 0, sn_latch);
sn76496_w(state->sn2, 0, state->sn_latch);
break;
/* CS5 */
case 3:
device = devtag_get_device(space->machine, "dac");
dac_w(device, 0, data);
dac_w(state->dac, 0, data);
break;
/* CS6 */
case 4:
device = devtag_get_device(space->machine, "fltdisc");
discrete_sound_w(device, NODE_05, (offset & 0x20) >> 5);
discrete_sound_w(device, NODE_06, (offset & 0x18) >> 3);
discrete_sound_w(device, NODE_07, (offset & 0x40) >> 6);
discrete_sound_w(state->discrete, NODE_05, (offset & 0x20) >> 5);
discrete_sound_w(state->discrete, NODE_06, (offset & 0x18) >> 3);
discrete_sound_w(state->discrete, NODE_07, (offset & 0x40) >> 6);
break;
}
}
@ -158,7 +147,7 @@ static ADDRESS_MAP_START( circusc_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0001, 0x0001) AM_MIRROR(0x03f8) AM_WRITE(interrupt_enable_w) /* INTST */
// AM_RANGE(0x0002, 0x0002) AM_MIRROR(0x03f8) AM_WRITENOP /* MUT - not used /*
AM_RANGE(0x0003, 0x0004) AM_MIRROR(0x03f8) AM_WRITE(circusc_coin_counter_w) /* COIN1, COIN2 */
AM_RANGE(0x0005, 0x0005) AM_MIRROR(0x03f8) AM_WRITE(SMH_RAM) AM_BASE(&circusc_spritebank) /* OBJ CHENG */
AM_RANGE(0x0005, 0x0005) AM_MIRROR(0x03f8) AM_WRITE(SMH_RAM) AM_BASE_MEMBER(circusc_state, spritebank) /* OBJ CHENG */
AM_RANGE(0x0400, 0x0400) AM_MIRROR(0x03ff) AM_WRITE(watchdog_reset_w) /* WDOG */
AM_RANGE(0x0800, 0x0800) AM_MIRROR(0x03ff) AM_WRITE(soundlatch_w) /* SOUND DATA */
AM_RANGE(0x0c00, 0x0c00) AM_MIRROR(0x03ff) AM_WRITE(circusc_sh_irqtrigger_w) /* SOUND-ON causes interrupt on audio CPU */
@ -168,12 +157,12 @@ static ADDRESS_MAP_START( circusc_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1003, 0x1003) AM_MIRROR(0x03fc) AM_READNOP /* unpopulated DIPSW 3*/
AM_RANGE(0x1400, 0x1400) AM_MIRROR(0x03ff) AM_READ_PORT("DSW1")
AM_RANGE(0x1800, 0x1800) AM_MIRROR(0x03ff) AM_READ_PORT("DSW2")
AM_RANGE(0x1c00, 0x1c00) AM_MIRROR(0x03ff) AM_WRITE(SMH_RAM) AM_BASE(&circusc_scroll) /* VGAP */
AM_RANGE(0x1c00, 0x1c00) AM_MIRROR(0x03ff) AM_WRITE(SMH_RAM) AM_BASE_MEMBER(circusc_state, scroll) /* VGAP */
AM_RANGE(0x2000, 0x2fff) AM_RAM
AM_RANGE(0x3000, 0x33ff) AM_RAM_WRITE(circusc_colorram_w) AM_BASE(&circusc_colorram) /* colorram */
AM_RANGE(0x3400, 0x37ff) AM_RAM_WRITE(circusc_videoram_w) AM_BASE(&circusc_videoram) /* videoram */
AM_RANGE(0x3800, 0x38ff) AM_RAM AM_BASE(&spriteram_2) /* spriteram2 */
AM_RANGE(0x3900, 0x39ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) /* spriteram */
AM_RANGE(0x3000, 0x33ff) AM_RAM_WRITE(circusc_colorram_w) AM_BASE_MEMBER(circusc_state, colorram) /* colorram */
AM_RANGE(0x3400, 0x37ff) AM_RAM_WRITE(circusc_videoram_w) AM_BASE_MEMBER(circusc_state, videoram) /* videoram */
AM_RANGE(0x3800, 0x38ff) AM_RAM AM_BASE_MEMBER(circusc_state, spriteram_2) /* spriteram2 */
AM_RANGE(0x3900, 0x39ff) AM_RAM AM_BASE_MEMBER(circusc_state, spriteram) AM_SIZE(&spriteram_size) /* spriteram */
AM_RANGE(0x3a00, 0x3fff) AM_RAM
AM_RANGE(0x6000, 0xffff) AM_ROM
ADDRESS_MAP_END
@ -341,6 +330,9 @@ DISCRETE_SOUND_END
static MACHINE_DRIVER_START( circusc )
/* driver data */
MDRV_DRIVER_DATA(circusc_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6809, 2048000) /* 2 MHz */
MDRV_CPU_PROGRAM_MAP(circusc_map)

View File

@ -1,13 +1,47 @@
/*----------- defined in drivers/changela.c -----------*/
extern UINT8 changela_tree0_col;
extern UINT8 changela_tree1_col;
extern UINT8 changela_left_bank_col;
extern UINT8 changela_right_bank_col;
extern UINT8 changela_boat_shore_col;
extern UINT8 changela_collision_reset;
extern UINT8 changela_tree_collision_reset;
typedef struct _changela_state changela_state;
struct _changela_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * colorram;
UINT8 * spriteram;
/* video-related */
bitmap_t *obj0_bitmap, *river_bitmap, *tree0_bitmap, *tree1_bitmap;
UINT8* tree_ram;
UINT8* memory_devices;
UINT32 mem_dev_selected; /* an offset within memory_devices area */
UINT32 slopeROM_bank;
UINT8 tree_en;
UINT8 horizon;
UINT8 v_count_river;
UINT8 v_count_tree;
int tree_on[2];
emu_timer* scanline_timer;
/* misc */
UINT8 tree0_col;
UINT8 tree1_col;
UINT8 left_bank_col;
UINT8 right_bank_col;
UINT8 boat_shore_col;
UINT8 collision_reset;
UINT8 tree_collision_reset;
UINT8 prev_value_31;
int dir_31;
/* mcu-related */
UINT8 port_a_in, port_a_out, ddr_a;
UINT8 port_b_out, ddr_b;
UINT8 port_c_in, port_c_out, ddr_c;
UINT8 mcu_out;
UINT8 mcu_in;
UINT8 mcu_pc_1;
UINT8 mcu_pc_0;
};
/*----------- defined in video/changela.c -----------*/

View File

@ -1,13 +1,36 @@
#include "sound/discrete.h"
#define GAME_IS_CIRCUS (circus_game == 1)
#define GAME_IS_ROBOTBWL (circus_game == 2)
#define GAME_IS_CRASH (circus_game == 3)
#define GAME_IS_RIPCORD (circus_game == 4)
#define GAME_IS_CIRCUS (state->game_id == 1)
#define GAME_IS_ROBOTBWL (state->game_id == 2)
#define GAME_IS_CRASH (state->game_id == 3)
#define GAME_IS_RIPCORD (state->game_id == 4)
typedef struct _circus_state circus_state;
struct _circus_state
{
/* memory pointers */
UINT8 * videoram;
/* video-related */
tilemap *bg_tilemap;
int clown_x, clown_y, clown_z;
/* devices */
const device_config *samples;
const device_config *discrete;
/* game id */
int game_id;
#if 0
int interrupt; // dead code for ripcord. shall we remove it?
#endif
};
/*----------- defined in audio/circus.c -----------*/
extern int circus_game;
extern WRITE8_HANDLER( circus_clown_z_w );
DISCRETE_SOUND_EXTERN( circus );
@ -20,8 +43,6 @@ extern const samples_interface robotbwl_samples_interface;
/*----------- defined in video/circus.c -----------*/
extern int clown_z;
extern WRITE8_HANDLER( circus_clown_x_w );
extern WRITE8_HANDLER( circus_clown_y_w );

View File

@ -0,0 +1,40 @@
/*************************************************************************
Circus Charlie
*************************************************************************/
typedef struct _circusc_state circusc_state;
struct _circusc_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * colorram;
UINT8 * spriteram;
UINT8 * spriteram_2;
UINT8 * spritebank;
UINT8 * scroll;
/* video-related */
tilemap *bg_tilemap;
/* sound-related */
UINT8 sn_latch;
/* devices */
const device_config *sn1;
const device_config *sn2;
const device_config *dac;
const device_config *discrete;
};
/*----------- defined in video/circusc.c -----------*/
WRITE8_HANDLER( circusc_videoram_w );
WRITE8_HANDLER( circusc_colorram_w );
VIDEO_START( circusc );
WRITE8_HANDLER( circusc_flipscreen_w );
PALETTE_INIT( circusc );
VIDEO_UPDATE( circusc );

View File

@ -15,39 +15,25 @@ Todo: Priority between tree0 and tree1.
#include "includes/changela.h"
static UINT32 slopeROM_bank;
static UINT8 tree_en;
static UINT8 horizon;
static UINT8* memory_devices;
static UINT8* tree_ram;
static UINT32 mem_dev_selected; /* an offset within memory_devices area */
static bitmap_t *obj0_bitmap, *river_bitmap, *tree0_bitmap, *tree1_bitmap;
static emu_timer* changela_scanline_timer;
static TIMER_CALLBACK( changela_scanline_callback );
VIDEO_START( changela )
{
memory_devices = auto_alloc_array(machine, UINT8, 4 * 0x800); /* 0 - not connected, 1,2,3 - RAMs*/
tree_ram = auto_alloc_array(machine, UINT8, 2 * 0x20);
changela_state *state = (changela_state *)machine->driver_data;
obj0_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
river_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
tree0_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
tree1_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
state->memory_devices = auto_alloc_array(machine, UINT8, 4 * 0x800); /* 0 - not connected, 1,2,3 - RAMs*/
state->tree_ram = auto_alloc_array(machine, UINT8, 2 * 0x20);
changela_scanline_timer = timer_alloc(machine, changela_scanline_callback, NULL);
timer_adjust_oneshot(changela_scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 30, 0), 30);
state->obj0_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
state->river_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
state->tree0_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
state->tree1_bitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
state_save_register_global(machine, slopeROM_bank);
state_save_register_global(machine, tree_en);
state_save_register_global(machine, horizon);
state_save_register_global(machine, mem_dev_selected);
state->scanline_timer = timer_alloc(machine, changela_scanline_callback, NULL);
timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, 30, 0), 30);
state_save_register_global_pointer(machine, memory_devices, 4*0x800);
state_save_register_global_pointer(machine, tree_ram, 2*0x20);
state_save_register_global_pointer(machine, state->memory_devices, 4 * 0x800);
state_save_register_global_pointer(machine, state->tree_ram, 2 * 0x20);
}
/**************************************************************************
@ -55,56 +41,58 @@ VIDEO_START( changela )
Obj 0 - Sprite Layer
***************************************************************************/
static void draw_obj0(running_machine *machine, bitmap_t *bitmap, int sy)
static void draw_obj0( running_machine *machine, bitmap_t *bitmap, int sy )
{
changela_state *state = (changela_state *)machine->driver_data;
int sx, i;
UINT8* ROM = memory_region(machine, "user1");
UINT8* RAM = spriteram;
UINT8* RAM = state->spriteram;
for(sx = 0; sx < 256; sx++)
for (sx = 0; sx < 256; sx++)
{
int vr = (RAM[sx*4 + 0] & 0x80) >> 7;
int hr = (RAM[sx*4 + 0] & 0x40) >> 6;
int hs = (RAM[sx*4 + 0] & 0x20) >> 5;
UINT32 vsize = RAM[sx*4 + 0] & 0x1f;
UINT8 ypos = ~RAM[sx*4 + 1];
UINT8 tile = RAM[sx*4 + 2];
UINT8 xpos = RAM[sx*4 + 3];
int vr = (RAM[sx * 4 + 0] & 0x80) >> 7;
int hr = (RAM[sx * 4 + 0] & 0x40) >> 6;
int hs = (RAM[sx * 4 + 0] & 0x20) >> 5;
UINT32 vsize = RAM[sx * 4 + 0] & 0x1f;
UINT8 ypos = ~RAM[sx * 4 + 1];
UINT8 tile = RAM[sx * 4 + 2];
UINT8 xpos = RAM[sx * 4 + 3];
if(sy - ypos <= vsize)
if (sy - ypos <= vsize)
{
for(i = 0; i < 16; i++)
for (i = 0; i < 16; i++)
{
UINT32 A7, A8, rom_addr;
UINT8 counter, data;
UINT8 sum = sy - ypos;
counter = i;
if(hr) counter ^= 0x0f;
if (hr) counter ^= 0x0f;
A8 = ((tile & 0x02) >> 1) ^ ((hr & hs) ^ hs);
A7 = ( (((vr ^ ((sum & 0x10) >> 4)) & ((vsize & 0x10) >> 4)) ^ 0x01) & (tile & 0x01) ) ^ 0x01;
A7 = ((((vr ^ ((sum & 0x10) >> 4)) & ((vsize & 0x10) >> 4)) ^ 0x01) & (tile & 0x01) ) ^ 0x01;
rom_addr = (counter >> 1) | ((sum & 0x0f) << 3) | (A7 << 7) | (A8 << 8) | ((tile >> 2) << 9);
if(vr) rom_addr ^= (0x0f << 3);
if (vr) rom_addr ^= (0x0f << 3);
if(counter & 1)
if (counter & 1)
data = ROM[rom_addr] & 0x0f;
else
data = (ROM[rom_addr] & 0xf0) >> 4;
if((data != 0x0f) && (data != 0))
*BITMAP_ADDR16(bitmap, sy, xpos+i) = data | 0x10;
if ((data != 0x0f) && (data != 0))
*BITMAP_ADDR16(bitmap, sy, xpos + i) = data | 0x10;
if(hs)
if (hs)
{
if(counter & 1)
if (counter & 1)
data = ROM[rom_addr ^ 0x100] & 0x0f;
else
data = (ROM[rom_addr ^ 0x100] & 0xf0) >> 4;
if((data != 0x0f) && (data != 0))
*BITMAP_ADDR16(bitmap, sy, xpos+i+16) = data | 0x10;
if ((data != 0x0f) && (data != 0))
*BITMAP_ADDR16(bitmap, sy, xpos + i + 16) = data | 0x10;
}
}
}
@ -116,21 +104,23 @@ static void draw_obj0(running_machine *machine, bitmap_t *bitmap, int sy)
Obj 1 - Text Layer
***************************************************************************/
static void draw_obj1(running_machine *machine, bitmap_t *bitmap)
static void draw_obj1( running_machine *machine, bitmap_t *bitmap )
{
changela_state *state = (changela_state *)machine->driver_data;
int sx, sy;
UINT8* ROM = memory_region(machine, "gfx2");
UINT8* RAM = videoram;
UINT8* RAM = state->videoram;
UINT8 reg[4] = { 0 }; /* 4x4-bit registers (U58, U59) */
UINT8 tile;
UINT8 attrib = 0;
for(sy = 0; sy < 256; sy++)
for (sy = 0; sy < 256; sy++)
{
for(sx = 0; sx < 256; sx++)
for (sx = 0; sx < 256; sx++)
{
int c0, c1, col, sum;
@ -138,25 +128,25 @@ static void draw_obj1(running_machine *machine, bitmap_t *bitmap)
int ram_addr = ((sx & 0xf8) >> 2) | ((sy & 0xf8) << 3);
int tile_addr = RAM[ram_addr];
if(!(RAM[ram_addr+1] & 0x10) && (sx & 0x04)) /* D4=0 enables latch at U32 */
attrib = RAM[ram_addr+1];
if (!(RAM[ram_addr + 1] & 0x10) && (sx & 0x04)) /* D4=0 enables latch at U32 */
attrib = RAM[ram_addr + 1];
tile = ROM[(tile_addr << 4) | ((sx & 0x04) >> 2) | ((sy & 0x07) << 1)];
reg[(sx & 0x0c) >> 2] = tile;
sum = (sx & 0x0f) + (attrib & 0x0f); /* 4-bit adder (U45) */
/* Multiplexors (U57) */
if((sum & 0x03) == 0)
if ((sum & 0x03) == 0)
{
c0 = (reg[(sum & 0x0c) >> 2] & 0x08) >> 3;
c1 = (reg[(sum & 0x0c) >> 2] & 0x80) >> 7;
}
else if((sum & 0x03) == 1)
else if ((sum & 0x03) == 1)
{
c0 = (reg[(sum & 0x0c) >> 2] & 0x04) >> 2;
c1 = (reg[(sum & 0x0c) >> 2] & 0x40) >> 6;
}
else if((sum & 0x03) == 2)
else if ((sum & 0x03) == 2)
{
c0 = (reg[(sum & 0x0c) >> 2] & 0x02) >> 1;
c1 = (reg[(sum & 0x0c) >> 2] & 0x20) >> 5;
@ -168,7 +158,7 @@ static void draw_obj1(running_machine *machine, bitmap_t *bitmap)
}
col = c0 | (c1 << 1) | ((attrib & 0xc0) >> 4);
if((col & 0x07) != 0x07)
if ((col & 0x07) != 0x07)
*BITMAP_ADDR16(bitmap, sy, sx) = col | 0x20;
}
}
@ -179,24 +169,24 @@ static void draw_obj1(running_machine *machine, bitmap_t *bitmap)
River Video Generator
***************************************************************************/
static void draw_river(running_machine *machine, bitmap_t *bitmap, int sy)
static void draw_river( running_machine *machine, bitmap_t *bitmap, int sy )
{
changela_state *state = (changela_state *)machine->driver_data;
int sx, i, j;
UINT8* ROM = memory_region(machine, "user2");
UINT8* RAM = memory_devices + 0x800;
UINT8* RAM = state->memory_devices + 0x800;
UINT8* TILE_ROM = memory_region(machine, "gfx1");
UINT8* TILE_RAM = memory_devices + 0x1000;
UINT8* TILE_RAM = state->memory_devices + 0x1000;
UINT8* PROM = memory_region(machine, "proms");
static UINT8 v_count = 0;
int preload = ((sy < 32) ? 1 : 0);
UINT8 math_train[10] = { 0 };
UINT8 pre_train[3] = { 0 };
UINT8 state = 0;
UINT8 curr_state = 0;
UINT8 prev_state = 0;
UINT8 ram_count = 0;
@ -206,49 +196,49 @@ static void draw_river(running_machine *machine, bitmap_t *bitmap, int sy)
int carry = 0;
/* Update Counters */
if(sy == 30) v_count = horizon;
v_count = (v_count+1) & 0xff;
if (sy == 30) state->v_count_river = state->horizon;
state->v_count_river = (state->v_count_river + 1) & 0xff;
/* ----- STATE MACHINE ----- */
for(i = 0; i < 0x20; i++)
for (i = 0; i < 0x20; i++)
{
int rom_addr, ram_addr, ram_a5;
int mux45, mux61;
state = PROM[i];
curr_state = PROM[i];
/* Update Counters */
if(prev_state & 0x80)
ram_count = (ram_count+1) & 0x0f;
if((state & 0x40) && !(prev_state & 0x40))
rom_count = (rom_count+1) & 0x0f;
if (prev_state & 0x80)
ram_count = (ram_count + 1) & 0x0f;
if ((curr_state & 0x40) && !(prev_state & 0x40))
rom_count = (rom_count + 1) & 0x0f;
if(prev_state & 0x02)
if (prev_state & 0x02)
carry = (((pre_train[1] + pre_train[2] + carry) > 0x0f) ? 1 : 0);
if(!(state & 0x08))
if (!(curr_state & 0x08))
carry = 0;
if(prev_state & 0x10)
if (prev_state & 0x10)
hosc = (math_train[8] << 4) | math_train[9];
rom_addr = slopeROM_bank | ((v_count & 0x7e) << 2) | ((rom_count & 0x0e) >> 1);
ram_a5 = ((state & 0x01) & ((state & 0x40) >> 6) & preload) ^ 0x01;
ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((state & 0x20) >> 5);
rom_addr = state->slopeROM_bank | ((state->v_count_river & 0x7e) << 2) | ((rom_count & 0x0e) >> 1);
ram_a5 = ((curr_state & 0x01) & ((curr_state & 0x40) >> 6) & preload) ^ 0x01;
ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((curr_state & 0x20) >> 5);
mux45 = rom_count & 0x01;
mux61 = v_count & 0x01;
mux61 = state->v_count_river & 0x01;
switch(state)
switch (curr_state)
{
case 0x01:
case 0x09:
case 0x19:
case 0x0d:
case 0x8d:
pre_train[0] = ( mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f) );
pre_train[0] = (mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f));
break;
case 0x0f:
case 0x2f:
math_train[0] = RAM[ram_addr] = ( mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f) );
math_train[0] = RAM[ram_addr] = (mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f));
break;
case 0x4d:
case 0x69:
@ -259,18 +249,18 @@ static void draw_river(running_machine *machine, bitmap_t *bitmap, int sy)
break;
case 0xea:
case 0xee:
math_train[0] = RAM[ram_addr] = ( mux61 ? (pre_train[1]) : ((pre_train[1] + pre_train[2] + carry) & 0x0f) );
math_train[0] = RAM[ram_addr] = (mux61 ? (pre_train[1]) : ((pre_train[1] + pre_train[2] + carry) & 0x0f));
break;
default:
break;
}
/* Shift each item down the train */
if(state & 0x02)
if (curr_state & 0x02)
{
for(j = 9; j > 0; j--)
for (j = 9; j > 0; j--)
{
math_train[j] = math_train[j-1];
math_train[j] = math_train[j - 1];
}
}
else
@ -279,30 +269,30 @@ static void draw_river(running_machine *machine, bitmap_t *bitmap, int sy)
pre_train[1] = pre_train[0];
}
prev_state = state;
prev_state = curr_state;
}
if(!(v_count & 0x80))
if (!(state->v_count_river & 0x80))
{
int h_count = 0x80 | (hosc >> 1);
int tile_v = ((math_train[3] & 0x0c) >> 2) | ((math_train[2] & 0x0f) << 2) | ((math_train[1] & 0x07) << 6);
int tile_h = (math_train[7] & 0x0f) | ((math_train[6] & 0x0f) << 4) | ((math_train[5] & 0x01) << 8);
/* Burst of 16 10Mhz Clocks */
for(sx = 0; sx < 16; sx++)
for (sx = 0; sx < 16; sx++)
{
int ram_addr, rom_addr;
int col;
for(i = 0; i < 2; i++)
for (i = 0; i < 2; i++)
{
if(h_count > 0xff)
if (h_count > 0xff)
{
h_count = ((math_train[9] & 0x0f) >> 1) | ((math_train[8] & 0x0f) << 3) | 0x80;
tile_h = (tile_h+1) & 0xfff;
/* Skip one count if LSB is high */
if(((math_train[9] & 0x01) && (tile_h & 0x01)))
if (((math_train[9] & 0x01) && (tile_h & 0x01)))
h_count--;
}
else
@ -312,7 +302,7 @@ static void draw_river(running_machine *machine, bitmap_t *bitmap, int sy)
ram_addr = ((tile_h & 0x1f8) >> 3) | ((tile_v & 0x1f0) << 2);
rom_addr = ((tile_h & 0x06) >> 1) | ((tile_v & 0x0f) << 2) | ((TILE_RAM[ram_addr] & 0x7f) << 6);
if(tile_h & 0x01)
if (tile_h & 0x01)
col = TILE_ROM[rom_addr] & 0x0f;
else
col = (TILE_ROM[rom_addr] & 0xf0) >> 4;
@ -320,20 +310,20 @@ static void draw_river(running_machine *machine, bitmap_t *bitmap, int sy)
*BITMAP_ADDR16(bitmap, sy, sx) = col;
}
for(sx = 16; sx < 256; sx++)
for (sx = 16; sx < 256; sx++)
{
int ram_addr, rom_addr;
int col;
for(i = 0; i < 4; i++)
for (i = 0; i < 4; i++)
{
if(h_count > 0xff)
if (h_count > 0xff)
{
h_count = ((math_train[9] & 0x0f) >> 1) | ((math_train[8] & 0x0f) << 3) | 0x80;
tile_h = (tile_h+1) & 0xfff;
/* Skip one count if LSB is high */
if(((math_train[9] & 0x01) && (tile_h & 0x01)))
if (((math_train[9] & 0x01) && (tile_h & 0x01)))
h_count--;
}
else
@ -343,7 +333,7 @@ static void draw_river(running_machine *machine, bitmap_t *bitmap, int sy)
ram_addr = ((tile_h & 0x1f8) >> 3) | ((tile_v & 0x1f0) << 2);
rom_addr = ((tile_h & 0x06) >> 1) | ((tile_v & 0x0f) << 2) | ((TILE_RAM[ram_addr] & 0x7f) << 6);
if(tile_h & 0x01)
if (tile_h & 0x01)
col = TILE_ROM[rom_addr] & 0x0f;
else
col = (TILE_ROM[rom_addr] & 0xf0) >> 4;
@ -358,22 +348,21 @@ static void draw_river(running_machine *machine, bitmap_t *bitmap, int sy)
Tree Generators
***************************************************************************/
static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tree_num)
static void draw_tree( running_machine *machine, bitmap_t *bitmap, int sy, int tree_num )
{
changela_state *state = (changela_state *)machine->driver_data;
int sx, i, j;
/* State machine */
UINT8* ROM = memory_region(machine, "user2");
UINT8* RAM = memory_devices + 0x840 + 0x40*tree_num;
UINT8* RAM = state->memory_devices + 0x840 + 0x40 * tree_num;
UINT8* PROM = memory_region(machine, "proms");
/* Tree Data */
UINT8* RAM2 = tree_ram + 0x20*tree_num;
UINT8* TILE_ROM = ( tree_num ? (memory_region(machine, "user3") + 0x1000) : (memory_region(machine, "gfx1") + 0x2000) );
UINT8* TILE_RAM = ( tree_num ? (memory_region(machine, "user3")) : (memory_devices + 0x1800) );
static UINT8 v_count = 0;
static int tree_on[2] = { 0 };
UINT8* RAM2 = state->tree_ram + 0x20 * tree_num;
UINT8* TILE_ROM = (tree_num ? (memory_region(machine, "user3") + 0x1000) : (memory_region(machine, "gfx1") + 0x2000));
UINT8* TILE_RAM = (tree_num ? (memory_region(machine, "user3")) : (state->memory_devices + 0x1800));
int preload = ((sy < 32) ? 1 : 0);
@ -381,7 +370,7 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
UINT8 pre_train[3] = { 0 };
UINT8 tree_train[3] = { 0 };
UINT8 state = 0;
UINT8 curr_state = 0;
UINT8 prev_state = 0;
UINT8 ram_count = 0;
@ -395,48 +384,48 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
int all_ff;
/* Update Counters */
if(sy == 30)
if (sy == 30)
{
tree_on[tree_num] = 0;
if(tree_num == 0)
v_count = horizon;
state->tree_on[tree_num] = 0;
if (tree_num == 0)
state->v_count_tree = state->horizon;
}
if(tree_num == 0)
v_count = (v_count+1) & 0xff;
if (tree_num == 0)
state->v_count_tree = (state->v_count_tree + 1) & 0xff;
/* ----- STATE MACHINE ----- */
for(i = 0; i < 0x20; i++)
for (i = 0; i < 0x20; i++)
{
int rom_addr, ram_addr, ram_a5, ram2_addr;
int mux45, mux61;
state = PROM[i];
curr_state = PROM[i];
/* Update Counters */
if(prev_state & 0x80)
ram_count = (ram_count+1) & 0x0f;
if((state & 0x40) && !(prev_state & 0x40))
rom_count = (rom_count+1) & 0x0f;
if (prev_state & 0x80)
ram_count = (ram_count + 1) & 0x0f;
if ((curr_state & 0x40) && !(prev_state & 0x40))
rom_count = (rom_count + 1) & 0x0f;
if(prev_state & 0x02)
if (prev_state & 0x02)
{
carry = (((pre_train[1] + pre_train[2] + carry) > 0x0f) ? 1 : 0);
tree_carry = (((tree_train[1] + tree_train[2] + tree_carry) > 0x0f) ? 1 : 0);
}
if(!(state & 0x08))
if (!(curr_state & 0x08))
carry = tree_carry = 0;
if(prev_state & 0x10)
if (prev_state & 0x10)
hosc = (math_train[8] << 4) | math_train[9];
rom_addr = slopeROM_bank | ((v_count & 0x7e) << 2) | ((rom_count & 0x0e) >> 1);
ram_a5 = ((state & 0x01) & ((state & 0x40) >> 6) & preload) ^ 0x01;
ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((state & 0x20) >> 5);
ram2_addr = (ram_count << 1) | ((state & 0x20) >> 5);
rom_addr = state->slopeROM_bank | ((state->v_count_tree & 0x7e) << 2) | ((rom_count & 0x0e) >> 1);
ram_a5 = ((curr_state & 0x01) & ((curr_state & 0x40) >> 6) & preload) ^ 0x01;
ram_addr = (ram_a5 << 5) | (ram_count << 1) | ((curr_state & 0x20) >> 5);
ram2_addr = (ram_count << 1) | ((curr_state & 0x20) >> 5);
mux45 = rom_count & 0x01;
mux61 = v_count & 0x01;
mux61 = state->v_count_tree & 0x01;
switch(state)
switch(curr_state)
{
case 0x01: case 0x09: case 0x19: case 0x0d: case 0x8d:
pre_train[0] = ( mux45 ? ((ROM[rom_addr] & 0xf0) >> 4) : (ROM[rom_addr] & 0x0f) );
@ -454,11 +443,11 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
break;
}
if(!tree_on[tree_num])
if (!state->tree_on[tree_num])
{
int mux82 = (v_count & 0x01) ^ 0x01;
int mux82 = (state->v_count_tree & 0x01) ^ 0x01;
switch(state)
switch(curr_state)
{
case 0x01: case 0x09: case 0x19: case 0x0d: case 0x8d:
tree_train[0] = RAM2[ram2_addr] = pre_train[0];
@ -478,9 +467,9 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
}
else
{
int mux82 = ((state & 0x04) ? 0 : 1);
int mux82 = ((curr_state & 0x04) ? 0 : 1);
switch(state)
switch(curr_state)
{
case 0x01: case 0x09: case 0x19: case 0x0d: case 0x8d:
tree_train[0] = RAM2[ram2_addr];
@ -492,7 +481,7 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
tree_train[0] = RAM2[ram2_addr];
break;
case 0xea: case 0xee:
math_train[0] = RAM2[ram2_addr] = ( mux82 ? ((tree_train[1] + tree_train[2] + tree_carry) & 0x0f) : (tree_train[1]) );
math_train[0] = RAM2[ram2_addr] = (mux82 ? ((tree_train[1] + tree_train[2] + tree_carry) & 0x0f) : (tree_train[1]));
break;
default:
break;
@ -500,9 +489,9 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
}
/* Shift each item down the train */
if(state & 0x02)
if (curr_state & 0x02)
{
for(j = 9; j > 0; j--)
for (j = 9; j > 0; j--)
math_train[j] = math_train[j-1];
}
else
@ -513,7 +502,7 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
tree_train[1] = tree_train[0];
}
prev_state = state;
prev_state = curr_state;
}
h_count = 0x80 | (hosc >> 1);
@ -522,19 +511,19 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
all_ff = 1;
/* Burst of 16 10Mhz clocks */
for(sx = 0; sx < 16; sx++)
for (sx = 0; sx < 16; sx++)
{
int ram_addr, rom_addr, col;
for(i = 0; i < 2; i++)
for (i = 0; i < 2; i++)
{
if(h_count > 0xff)
if (h_count > 0xff)
{
h_count = ((math_train[9] & 0x0f) >> 1) | ((math_train[8] & 0x0f) << 3) | 0x80;
tile_h = (tile_h+1) & 0xfff;
/* Skip one count if LSB is high */
if(((math_train[9] & 0x01) && (tile_h & 0x01)))
if (((math_train[9] & 0x01) && (tile_h & 0x01)))
h_count--;
}
else
@ -544,37 +533,37 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
ram_addr = ((tile_h & 0x1f8) >> 3) | ((tile_v & 0x1f0) << 2);
rom_addr = ((tile_h & 0x06) >> 1) | ((tile_v & 0x0f) << 2) | ((TILE_RAM[ram_addr] & 0x7f) << 6);
if(!(v_count & 0x80) && (tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0))
tree_on[tree_num] = 1;
if (!(state->v_count_tree & 0x80) && (state->tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0))
state->tree_on[tree_num] = 1;
if(tree_on[tree_num])
if (state->tree_on[tree_num])
{
if(tile_h & 0x01)
if (tile_h & 0x01)
col = TILE_ROM[rom_addr] & 0x0f;
else
col = (TILE_ROM[rom_addr] & 0xf0) >> 4;
if(col != 0x0f)
if (col != 0x0f)
all_ff = 0;
if(col != 0x0f && col != 0x00)
if (col != 0x0f && col != 0x00)
*BITMAP_ADDR16(bitmap, sy, sx) = col | 0x30;
}
}
for(sx = 16; sx < 256; sx++)
for (sx = 16; sx < 256; sx++)
{
int ram_addr, rom_addr, col;
for(i = 0; i < 4; i++)
for (i = 0; i < 4; i++)
{
if(h_count > 0xff)
if (h_count > 0xff)
{
h_count = ((math_train[9] & 0x0f) >> 1) | ((math_train[8] & 0x0f) << 3) | 0x80;
tile_h = (tile_h+1) & 0xfff;
/* Skip one count if LSB is high */
if(((math_train[9] & 0x01) && (tile_h & 0x01)))
if (((math_train[9] & 0x01) && (tile_h & 0x01)))
h_count--;
}
else
@ -584,27 +573,27 @@ static void draw_tree(running_machine *machine, bitmap_t *bitmap, int sy, int tr
ram_addr = ((tile_h & 0x1f8) >> 3) | ((tile_v & 0x1f0) << 2);
rom_addr = ((tile_h & 0x06) >> 1) | ((tile_v & 0x0f) << 2) | ((TILE_RAM[ram_addr] & 0x7f) << 6);
if(!(v_count & 0x80) && (tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0))
tree_on[tree_num] = 1;
if (!(state->v_count_tree & 0x80) && (state->tree_en & (0x01 << tree_num)) && ((TILE_ROM[rom_addr] & 0xf0) == 0))
state->tree_on[tree_num] = 1;
if(tree_on[tree_num])
if (state->tree_on[tree_num])
{
if(tile_h & 0x01)
if (tile_h & 0x01)
col = TILE_ROM[rom_addr] & 0x0f;
else
col = (TILE_ROM[rom_addr] & 0xf0) >> 4;
if(col != 0x0f)
if (col != 0x0f)
all_ff = 0;
if(col != 0x0f && col != 0x00)
if (col != 0x0f && col != 0x00)
*BITMAP_ADDR16(bitmap, sy, sx) = col | 0x30;
}
}
/* Tree on only stays high if a pixel that is not 0xf is encountered,
because any non 0xf pixel sets U56 high */
if(all_ff) tree_on[tree_num] = 0;
if (all_ff) state->tree_on[tree_num] = 0;
}
/*
@ -658,86 +647,88 @@ e:|7 6 5 4 3 2 1 0 Hex|/RAMw /RAMr /ROM /AdderOutput AdderInput TrainInputs|
static TIMER_CALLBACK( changela_scanline_callback )
{
changela_state *state = (changela_state *)machine->driver_data;
int sy = param;
int sx;
/* clear the current scanline first */
rectangle rect = { 0, 255, sy, sy };
bitmap_fill(river_bitmap, &rect, 0x00);
bitmap_fill(obj0_bitmap, &rect, 0x00);
bitmap_fill(tree0_bitmap, &rect, 0x00);
bitmap_fill(tree1_bitmap, &rect, 0x00);
bitmap_fill(state->river_bitmap, &rect, 0x00);
bitmap_fill(state->obj0_bitmap, &rect, 0x00);
bitmap_fill(state->tree0_bitmap, &rect, 0x00);
bitmap_fill(state->tree1_bitmap, &rect, 0x00);
draw_river(machine, river_bitmap, sy);
draw_obj0(machine, obj0_bitmap, sy);
draw_tree(machine, tree0_bitmap, sy, 0);
draw_tree(machine, tree1_bitmap, sy, 1);
draw_river(machine, state->river_bitmap, sy);
draw_obj0(machine, state->obj0_bitmap, sy);
draw_tree(machine, state->tree0_bitmap, sy, 0);
draw_tree(machine, state->tree1_bitmap, sy, 1);
/* Collision Detection */
for(sx = 1; sx < 256; sx++)
for (sx = 1; sx < 256; sx++)
{
int riv_col, prev_col;
if((*BITMAP_ADDR16(river_bitmap, sy, sx) == 0x08)
|| (*BITMAP_ADDR16(river_bitmap, sy, sx) == 0x09)
|| (*BITMAP_ADDR16(river_bitmap, sy, sx) == 0x0a))
if ((*BITMAP_ADDR16(state->river_bitmap, sy, sx) == 0x08)
|| (*BITMAP_ADDR16(state->river_bitmap, sy, sx) == 0x09)
|| (*BITMAP_ADDR16(state->river_bitmap, sy, sx) == 0x0a))
riv_col = 1;
else
riv_col = 0;
if((*BITMAP_ADDR16(river_bitmap, sy, sx-1) == 0x08)
|| (*BITMAP_ADDR16(river_bitmap, sy, sx-1) == 0x09)
|| (*BITMAP_ADDR16(river_bitmap, sy, sx-1) == 0x0a))
if ((*BITMAP_ADDR16(state->river_bitmap, sy, sx-1) == 0x08)
|| (*BITMAP_ADDR16(state->river_bitmap, sy, sx-1) == 0x09)
|| (*BITMAP_ADDR16(state->river_bitmap, sy, sx-1) == 0x0a))
prev_col = 1;
else
prev_col = 0;
if(*BITMAP_ADDR16(obj0_bitmap, sy, sx) == 0x14) /* Car Outline Color */
if (*BITMAP_ADDR16(state->obj0_bitmap, sy, sx) == 0x14) /* Car Outline Color */
{
/* Tree 0 Collision */
if(*BITMAP_ADDR16(tree0_bitmap, sy, sx) != 0)
changela_tree0_col = 1;
if (*BITMAP_ADDR16(state->tree0_bitmap, sy, sx) != 0)
state->tree0_col = 1;
/* Tree 1 Collision */
if(*BITMAP_ADDR16(tree1_bitmap, sy, sx) != 0)
changela_tree1_col = 1;
if (*BITMAP_ADDR16(state->tree1_bitmap, sy, sx) != 0)
state->tree1_col = 1;
/* Hit Right Bank */
if(riv_col == 0 && prev_col == 1)
changela_right_bank_col = 1;
if (riv_col == 0 && prev_col == 1)
state->right_bank_col = 1;
/* Hit Left Bank */
if(riv_col == 1 && prev_col == 0)
changela_left_bank_col = 1;
if (riv_col == 1 && prev_col == 0)
state->left_bank_col = 1;
/* Boat Hit Shore */
if(riv_col == 1)
changela_boat_shore_col = 1;
if (riv_col == 1)
state->boat_shore_col = 1;
}
}
if(!changela_tree_collision_reset)
if (!state->tree_collision_reset)
{
changela_tree0_col = 0;
changela_tree1_col = 0;
state->tree0_col = 0;
state->tree1_col = 0;
}
if(!changela_collision_reset)
if (!state->collision_reset)
{
changela_left_bank_col = 0;
changela_right_bank_col = 0;
changela_boat_shore_col = 0;
state->left_bank_col = 0;
state->right_bank_col = 0;
state->boat_shore_col = 0;
}
sy++;
if(sy > 256) sy = 30;
timer_adjust_oneshot(changela_scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, sy, 0), sy);
if (sy > 256) sy = 30;
timer_adjust_oneshot(state->scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, sy, 0), sy);
}
VIDEO_UPDATE( changela )
{
copybitmap (bitmap, river_bitmap, 0, 0, 0, 0, cliprect);
copybitmap_trans(bitmap, obj0_bitmap, 0, 0, 0, 0, cliprect, 0);
copybitmap_trans(bitmap, tree0_bitmap, 0, 0, 0, 0, cliprect, 0);
copybitmap_trans(bitmap, tree1_bitmap, 0, 0, 0, 0, cliprect, 0);
changela_state *state = (changela_state *)screen->machine->driver_data;
copybitmap(bitmap, state->river_bitmap, 0, 0, 0, 0, cliprect);
copybitmap_trans(bitmap, state->obj0_bitmap, 0, 0, 0, 0, cliprect, 0);
copybitmap_trans(bitmap, state->tree0_bitmap, 0, 0, 0, 0, cliprect, 0);
copybitmap_trans(bitmap, state->tree1_bitmap, 0, 0, 0, 0, cliprect, 0);
draw_obj1(screen->machine, bitmap);
return 0;
@ -782,9 +773,9 @@ WRITE8_HANDLER( changela_colors_w )
WRITE8_HANDLER( changela_mem_device_select_w )
{
mem_dev_selected = (data & 0x07) * 0x800;
tree_en = (data & 0x30) >> 4;
changela_state *state = (changela_state *)space->machine->driver_data;
state->mem_dev_selected = (data & 0x07) * 0x800;
state->tree_en = (data & 0x30) >> 4;
/*
(data & 0x07) possible settings:
@ -799,30 +790,34 @@ WRITE8_HANDLER( changela_mem_device_select_w )
WRITE8_HANDLER( changela_mem_device_w )
{
memory_devices[mem_dev_selected + offset] = data;
changela_state *state = (changela_state *)space->machine->driver_data;
state->memory_devices[state->mem_dev_selected + offset] = data;
if(mem_dev_selected == 0x800)
if (state->mem_dev_selected == 0x800)
{
memory_devices[mem_dev_selected + 0x40 + offset] = data;
memory_devices[mem_dev_selected + 0x80 + offset] = data;
state->memory_devices[state->mem_dev_selected + 0x40 + offset] = data;
state->memory_devices[state->mem_dev_selected + 0x80 + offset] = data;
}
}
READ8_HANDLER( changela_mem_device_r )
{
return memory_devices[mem_dev_selected + offset];
changela_state *state = (changela_state *)space->machine->driver_data;
return state->memory_devices[state->mem_dev_selected + offset];
}
WRITE8_HANDLER( changela_slope_rom_addr_hi_w )
{
slopeROM_bank = (data & 0x03) << 9;
changela_state *state = (changela_state *)space->machine->driver_data;
state->slopeROM_bank = (data & 0x03) << 9;
}
WRITE8_HANDLER( changela_slope_rom_addr_lo_w )
{
horizon = data;
changela_state *state = (changela_state *)space->machine->driver_data;
state->horizon = data;
}

View File

@ -14,55 +14,46 @@
#include "sound/samples.h"
#include "circus.h"
static int clown_x=0,clown_y=0;
int clown_z=0;
static tilemap *bg_tilemap;
/***************************************************************************
***************************************************************************/
WRITE8_HANDLER( circus_videoram_w )
{
videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
circus_state *state = (circus_state *)space->machine->driver_data;
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( circus_clown_x_w )
{
clown_x = 240-data;
circus_state *state = (circus_state *)space->machine->driver_data;
state->clown_x = 240 - data;
}
WRITE8_HANDLER( circus_clown_y_w )
{
clown_y = 240-data;
circus_state *state = (circus_state *)space->machine->driver_data;
state->clown_y = 240 - data;
}
static TILE_GET_INFO( get_bg_tile_info )
{
int code = videoram[tile_index];
circus_state *state = (circus_state *)machine->driver_data;
int code = state->videoram[tile_index];
SET_TILE_INFO(0, code, 0, 0);
}
VIDEO_START( circus )
{
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
8, 8, 32, 32);
state_save_register_global(machine, clown_x);
state_save_register_global(machine, clown_y);
state_save_register_global(machine, clown_z);
circus_state *state = (circus_state *)machine->driver_data;
state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
}
static void draw_line(bitmap_t *bitmap, const rectangle *cliprect, int x1, int y1, int x2, int y2, int dotted)
static void draw_line( bitmap_t *bitmap, const rectangle *cliprect, int x1, int y1, int x2, int y2, int dotted )
{
/* Draws horizontal and Vertical lines only! */
int count, skip;
/* Draw the Line */
if (dotted > 0)
skip = 2;
else
@ -76,126 +67,132 @@ static void draw_line(bitmap_t *bitmap, const rectangle *cliprect, int x1, int y
*BITMAP_ADDR16(bitmap, y1, count) = 1;
}
static void draw_robot_box(bitmap_t *bitmap, const rectangle *cliprect, int x, int y)
static void draw_robot_box( bitmap_t *bitmap, const rectangle *cliprect, int x, int y )
{
/* Box */
int ex = x + 24;
int ey = y + 26;
draw_line(bitmap,cliprect,x,y,ex,y,0); /* Top */
draw_line(bitmap,cliprect,x,ey,ex,ey,0); /* Bottom */
draw_line(bitmap,cliprect,x,y,x,ey,0); /* Left */
draw_line(bitmap,cliprect,ex,y,ex,ey,0); /* Right */
draw_line(bitmap, cliprect, x, y, ex, y, 0); /* Top */
draw_line(bitmap, cliprect, x, ey, ex, ey, 0); /* Bottom */
draw_line(bitmap, cliprect, x, y, x, ey, 0); /* Left */
draw_line(bitmap, cliprect, ex, y, ex, ey, 0); /* Right */
/* Score Grid */
ey = y + 10;
draw_line(bitmap,cliprect,x+8,ey,ex,ey,0); /* Horizontal Divide Line */
draw_line(bitmap,cliprect,x+8,y,x+8,ey,0);
draw_line(bitmap,cliprect,x+16,y,x+16,ey,0);
draw_line(bitmap, cliprect, x + 8, ey, ex, ey, 0); /* Horizontal Divide Line */
draw_line(bitmap, cliprect, x + 8, y, x + 8, ey, 0);
draw_line(bitmap, cliprect, x + 16, y, x + 16, ey, 0);
}
static void circus_draw_fg(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
static void circus_draw_fg( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
circus_state *state = (circus_state *)machine->driver_data;
/* The sync generator hardware is used to */
/* draw the border and diving boards */
draw_line (bitmap,cliprect,0,18,255,18,0);
draw_line (bitmap,cliprect,0,249,255,249,1);
draw_line (bitmap,cliprect,0,18,0,248,0);
draw_line (bitmap,cliprect,247,18,247,248,0);
draw_line(bitmap, cliprect, 0, 18, 255, 18, 0);
draw_line(bitmap, cliprect, 0, 249, 255, 249, 1);
draw_line(bitmap, cliprect, 0, 18, 0, 248, 0);
draw_line(bitmap, cliprect, 247, 18, 247, 248, 0);
draw_line (bitmap,cliprect,0,137,17,137,0);
draw_line (bitmap,cliprect,231,137,248,137,0);
draw_line (bitmap,cliprect,0,193,17,193,0);
draw_line (bitmap,cliprect,231,193,248,193,0);
draw_line(bitmap, cliprect, 0, 137, 17, 137, 0);
draw_line(bitmap, cliprect, 231, 137, 248, 137, 0);
draw_line(bitmap, cliprect, 0, 193, 17, 193, 0);
draw_line(bitmap, cliprect, 231, 193, 248, 193, 0);
drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
clown_z,
state->clown_z,
0,
0,0,
clown_y,clown_x,0);
state->clown_y, state->clown_x, 0);
}
VIDEO_UPDATE( circus )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
circus_state *state = (circus_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
circus_draw_fg(screen->machine, bitmap, cliprect);
return 0;
}
static void robotbwl_draw_scoreboard(bitmap_t *bitmap, const rectangle *cliprect)
static void robotbwl_draw_scoreboard( bitmap_t *bitmap, const rectangle *cliprect )
{
int offs;
/* The sync generator hardware is used to */
/* draw the bowling alley & scorecards */
for(offs=15;offs<=63;offs+=24)
for (offs = 15; offs <= 63; offs += 24)
{
draw_robot_box(bitmap, cliprect, offs, 31);
draw_robot_box(bitmap, cliprect, offs, 63);
draw_robot_box(bitmap, cliprect, offs, 95);
draw_robot_box(bitmap, cliprect, offs+152, 31);
draw_robot_box(bitmap, cliprect, offs+152, 63);
draw_robot_box(bitmap, cliprect, offs+152, 95);
draw_robot_box(bitmap, cliprect, offs + 152, 31);
draw_robot_box(bitmap, cliprect, offs + 152, 63);
draw_robot_box(bitmap, cliprect, offs + 152, 95);
}
draw_robot_box(bitmap, cliprect, 39, 127); /* 10th Frame */
draw_line(bitmap, cliprect, 39,137,47,137,0); /* Extra digit box */
draw_robot_box(bitmap, cliprect, 39, 127); /* 10th Frame */
draw_line(bitmap, cliprect, 39, 137, 47, 137, 0); /* Extra digit box */
draw_robot_box(bitmap, cliprect, 39+152, 127);
draw_line(bitmap, cliprect, 39+152,137,47+152,137,0);
draw_robot_box(bitmap, cliprect, 39 + 152, 127);
draw_line(bitmap, cliprect, 39 + 152, 137, 47 + 152, 137, 0);
}
static void robotbwl_draw_bowling_alley(bitmap_t *bitmap, const rectangle *cliprect)
static void robotbwl_draw_bowling_alley( bitmap_t *bitmap, const rectangle *cliprect )
{
draw_line(bitmap, cliprect, 103,17,103,205,0);
draw_line(bitmap, cliprect, 111,17,111,203,1);
draw_line(bitmap, cliprect, 152,17,152,205,0);
draw_line(bitmap, cliprect, 144,17,144,203,1);
draw_line(bitmap, cliprect, 103, 17, 103, 205, 0);
draw_line(bitmap, cliprect, 111, 17, 111, 203, 1);
draw_line(bitmap, cliprect, 152, 17, 152, 205, 0);
draw_line(bitmap, cliprect, 144, 17, 144, 203, 1);
}
static void robotbwl_draw_ball(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
static void robotbwl_draw_ball( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
circus_state *state = (circus_state *)machine->driver_data;
drawgfx_transpen(bitmap,/* Y is horizontal position */
cliprect,machine->gfx[1],
clown_z,
state->clown_z,
0,
0,0,
clown_y+8,clown_x+8,0);
state->clown_y + 8, state->clown_x + 8, 0);
}
VIDEO_UPDATE( robotbwl )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
circus_state *state = (circus_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
robotbwl_draw_scoreboard(bitmap, cliprect);
robotbwl_draw_bowling_alley(bitmap, cliprect);
robotbwl_draw_ball(screen->machine, bitmap, cliprect);
return 0;
}
static void crash_draw_car(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
static void crash_draw_car( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
circus_state *state = (circus_state *)machine->driver_data;
drawgfx_transpen(bitmap,/* Y is horizontal position */
cliprect,machine->gfx[1],
clown_z,
state->clown_z,
0,
0,0,
clown_y,clown_x,0);
state->clown_y, state->clown_x, 0);
}
VIDEO_UPDATE( crash )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
circus_state *state = (circus_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
crash_draw_car(screen->machine, bitmap, cliprect);
return 0;
}
static void ripcord_draw_skydiver(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
static void ripcord_draw_skydiver( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
circus_state *state = (circus_state *)machine->driver_data;
const gfx_element *gfx;
const UINT8 *src_lineptr, *src_pixptr;
UINT16 *dst_lineptr, *dst_lineend;
@ -206,10 +203,10 @@ static void ripcord_draw_skydiver(running_machine *machine, bitmap_t *bitmap, co
gfx = machine->gfx[0];
code = clown_z;
code = state->clown_z;
sx = clown_y;
sy = clown_x - 1;
sx = state->clown_y;
sy = state->clown_x - 1;
dst_width = 16;
dst_height = 16;
edx = 1;
@ -233,7 +230,7 @@ static void ripcord_draw_skydiver(running_machine *machine, bitmap_t *bitmap, co
do
{
eax = *src_pixptr;
src_pixptr ++;
src_pixptr++;
if (eax)
{
eax = machine->pens[eax];
@ -249,7 +246,7 @@ static void ripcord_draw_skydiver(running_machine *machine, bitmap_t *bitmap, co
} while((dst_lineptr += dst_pitch) != dst_lineend);
// report collision only when the character is not blank and within display area
if (collision && code!=0xf && clown_x>0 && clown_x<240 && clown_y>-12 && clown_y<240)
if (collision && code != 0xf && state->clown_x > 0 && state->clown_x < 240 && state->clown_y > -12 && state->clown_y < 240)
{
cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); // interrupt accuracy is critical in Ripcord
cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
@ -258,7 +255,8 @@ static void ripcord_draw_skydiver(running_machine *machine, bitmap_t *bitmap, co
VIDEO_UPDATE( ripcord )
{
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
circus_state *state = (circus_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
ripcord_draw_skydiver(screen->machine, bitmap, cliprect);
return 0;
}

View File

@ -8,15 +8,7 @@
#include "driver.h"
#include "video/resnet.h"
UINT8 *circusc_videoram,*circusc_colorram;
static tilemap *bg_tilemap;
UINT8 *circusc_spritebank;
UINT8 *circusc_scroll;
#include "circusc.h"
/***************************************************************************
@ -108,11 +100,12 @@ PALETTE_INIT( circusc )
static TILE_GET_INFO( get_tile_info )
{
UINT8 attr = circusc_colorram[tile_index];
circusc_state *state = (circusc_state *)machine->driver_data;
UINT8 attr = state->colorram[tile_index];
tileinfo->category = (attr & 0x10) >> 4;
SET_TILE_INFO(0,
circusc_videoram[tile_index] + ((attr & 0x20) << 3),
state->videoram[tile_index] + ((attr & 0x20) << 3),
attr & 0x0f,
TILE_FLIPYX((attr & 0xc0) >> 6));
}
@ -127,9 +120,10 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( circusc )
{
bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
circusc_state *state = (circusc_state *)machine->driver_data;
state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_scroll_cols(bg_tilemap,32);
tilemap_set_scroll_cols(state->bg_tilemap, 32);
}
@ -142,14 +136,16 @@ VIDEO_START( circusc )
WRITE8_HANDLER( circusc_videoram_w )
{
circusc_videoram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset);
circusc_state *state = (circusc_state *)space->machine->driver_data;
state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( circusc_colorram_w )
{
circusc_colorram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap,offset);
circusc_state *state = (circusc_state *)space->machine->driver_data;
state->colorram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
WRITE8_HANDLER( circusc_flipscreen_w )
@ -165,18 +161,18 @@ WRITE8_HANDLER( circusc_flipscreen_w )
***************************************************************************/
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 )
{
circusc_state *state = (circusc_state *)machine->driver_data;
int offs;
UINT8 *sr;
if ((*circusc_spritebank & 0x01) != 0)
sr = spriteram;
if ((*state->spritebank & 0x01) != 0)
sr = state->spriteram;
else
sr = spriteram_2;
sr = state->spriteram_2;
for (offs = 0; offs < spriteram_size;offs += 4)
for (offs = 0; offs < spriteram_size; offs += 4)
{
int code = sr[offs + 0] + 8 * (sr[offs + 1] & 0x20);
int color = sr[offs + 1] & 0x0f;
@ -204,16 +200,17 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( circusc )
{
circusc_state *state = (circusc_state *)screen->machine->driver_data;
int i;
for (i = 0;i < 10;i++)
tilemap_set_scrolly(bg_tilemap,i,0);
for (i = 10;i < 32;i++)
tilemap_set_scrolly(bg_tilemap,i,*circusc_scroll);
for (i = 0; i < 10; i++)
tilemap_set_scrolly(state->bg_tilemap, i, 0);
for (i = 10; i < 32; i++)
tilemap_set_scrolly(state->bg_tilemap, i, *state->scroll);
bitmap_fill(bitmap, cliprect, 0);
tilemap_draw(bitmap,cliprect,bg_tilemap,1,0);
draw_sprites(screen->machine,bitmap,cliprect);
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 1, 0);
draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
return 0;
}