Added driver_data class and save states to the following drivers: oneshot.c, onetwo.c, orbit.c, othello.c and othldrby.c

Added driver_data class to the following drivers: nemesis.c and nyny.c
This commit is contained in:
Fabio Priuli 2010-03-01 09:10:49 +00:00
parent bb91514d13
commit 19723cecd0
16 changed files with 1456 additions and 962 deletions

1
.gitattributes vendored
View File

@ -2705,6 +2705,7 @@ src/mame/includes/ojankohs.h svneol=native#text/plain
src/mame/includes/oneshot.h svneol=native#text/plain
src/mame/includes/opwolf.h svneol=native#text/plain
src/mame/includes/orbit.h svneol=native#text/plain
src/mame/includes/othldrby.h svneol=native#text/plain
src/mame/includes/othunder.h svneol=native#text/plain
src/mame/includes/overdriv.h svneol=native#text/plain
src/mame/includes/pacman.h svneol=native#text/plain

File diff suppressed because it is too large Load Diff

View File

@ -72,26 +72,43 @@
#include "sound/dac.h"
#define MAIN_CPU_MASTER_CLOCK (XTAL_11_2MHz)
#define PIXEL_CLOCK (MAIN_CPU_MASTER_CLOCK / 2)
#define CRTC_CLOCK (MAIN_CPU_MASTER_CLOCK / 16)
#define AUDIO_1_MASTER_CLOCK (XTAL_4MHz)
#define AUDIO_CPU_1_CLOCK (AUDIO_1_MASTER_CLOCK)
#define AUDIO_2_MASTER_CLOCK (XTAL_4MHz)
#define AUDIO_CPU_2_CLOCK (AUDIO_2_MASTER_CLOCK)
#define MAIN_CPU_MASTER_CLOCK XTAL_11_2MHz
#define PIXEL_CLOCK (MAIN_CPU_MASTER_CLOCK / 2)
#define CRTC_CLOCK (MAIN_CPU_MASTER_CLOCK / 16)
#define AUDIO_1_MASTER_CLOCK XTAL_4MHz
#define AUDIO_CPU_1_CLOCK AUDIO_1_MASTER_CLOCK
#define AUDIO_2_MASTER_CLOCK XTAL_4MHz
#define AUDIO_CPU_2_CLOCK AUDIO_2_MASTER_CLOCK
static UINT8 *nyny_videoram_1;
static UINT8 *nyny_videoram_2;
static UINT8 *nyny_colorram_1;
static UINT8 *nyny_colorram_2;
static UINT8 flipscreen;
class nyny_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nyny_state(machine)); }
static UINT8 star_enable;
static UINT16 star_delay_counter;
static UINT16 star_shift_reg;
nyny_state(running_machine &machine) { }
/* memory pointers */
UINT8 * videoram1;
UINT8 * videoram2;
UINT8 * colorram1;
UINT8 * colorram2;
/* video-related */
int flipscreen;
UINT8 star_enable;
UINT16 star_delay_counter;
UINT16 star_shift_reg;
/* devices */
running_device *maincpu;
running_device *audiocpu;
running_device *audiocpu2;
running_device *ic48_1;
running_device *mc6845;
running_device *pia1;
running_device *pia2;
};
/*************************************
@ -104,7 +121,6 @@ static WRITE_LINE_DEVICE_HANDLER( flipscreen_w );
static WRITE8_HANDLER( audio_2_command_w );
/*************************************
*
* Interrupt generation
@ -113,17 +129,17 @@ static WRITE8_HANDLER( audio_2_command_w );
static WRITE_LINE_DEVICE_HANDLER( main_cpu_irq )
{
running_device *pia1 = devtag_get_device(device->machine, "pia1");
running_device *pia2 = devtag_get_device(device->machine, "pia2");
int combined_state = pia6821_get_irq_a(pia1) | pia6821_get_irq_b(pia1) | pia6821_get_irq_b(pia2);
nyny_state *driver_state = (nyny_state *)device->machine->driver_data;
int combined_state = pia6821_get_irq_a(driver_state->pia1) | pia6821_get_irq_b(driver_state->pia1) | pia6821_get_irq_b(driver_state->pia2);
cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
cpu_set_input_line(driver_state->maincpu, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
}
static WRITE_LINE_DEVICE_HANDLER( main_cpu_firq )
{
cputag_set_input_line(device->machine, "maincpu", M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
nyny_state *driver_state = (nyny_state *)device->machine->driver_data;
cpu_set_input_line(driver_state->maincpu, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
}
@ -136,17 +152,18 @@ static WRITE_LINE_DEVICE_HANDLER( main_cpu_firq )
static INTERRUPT_GEN( update_pia_1 )
{
running_device *pia1 = devtag_get_device(device->machine, "pia1");
nyny_state *state = (nyny_state *)device->machine->driver_data;
/* update the different PIA pins from the input ports */
/* CA1 - copy of PA0 (COIN1) */
pia6821_ca1_w(pia1, 0, input_port_read(device->machine, "IN0") & 0x01);
pia6821_ca1_w(state->pia1, 0, input_port_read(device->machine, "IN0") & 0x01);
/* CA2 - copy of PA1 (SERVICE1) */
pia6821_ca2_w(pia1, 0, input_port_read(device->machine, "IN0") & 0x02);
pia6821_ca2_w(state->pia1, 0, input_port_read(device->machine, "IN0") & 0x02);
/* CB1 - (crosshatch) */
pia6821_cb1_w(pia1, 0, input_port_read(device->machine, "CROSS"));
pia6821_cb1_w(state->pia1, 0, input_port_read(device->machine, "CROSS"));
/* CB2 - NOT CONNECTED */
}
@ -178,20 +195,23 @@ static const pia6821_interface pia_1_intf =
static WRITE8_DEVICE_HANDLER( pia_2_port_a_w )
{
star_delay_counter = (star_delay_counter & 0x0f00) | data;
nyny_state *state = (nyny_state *)device->machine->driver_data;
state->star_delay_counter = (state->star_delay_counter & 0x0f00) | data;
}
static WRITE8_DEVICE_HANDLER( pia_2_port_b_w )
{
nyny_state *state = (nyny_state *)device->machine->driver_data;
/* bits 0-3 go to bits 8-11 of the star delay counter */
star_delay_counter = (star_delay_counter & 0x00ff) | ((data & 0x0f) << 8);
state->star_delay_counter = (state->star_delay_counter & 0x00ff) | ((data & 0x0f) << 8);
/* bit 4 is star field enable */
star_enable = data & 0x10;
state->star_enable = data & 0x10;
/* bits 5-7 go to the music board connector */
audio_2_command_w(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, data & 0xe0);
audio_2_command_w(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0, data & 0xe0);
}
@ -225,10 +245,10 @@ static const pia6821_interface pia_2_intf =
*
*************************************/
static WRITE8_DEVICE_HANDLER(ic48_1_74123_output_changed)
static WRITE8_DEVICE_HANDLER( ic48_1_74123_output_changed )
{
running_device *pia2 = devtag_get_device(device->machine, "pia2");
pia6821_ca1_w(pia2, 0, data);
nyny_state *state = (nyny_state *)device->machine->driver_data;
pia6821_ca1_w(state->pia2, 0, data);
}
@ -245,35 +265,19 @@ static const ttl74123_config ic48_1_config =
/*************************************
*
* Machine start
*
*************************************/
static MACHINE_START( nyny )
{
/* setup for save states */
state_save_register_global(machine, flipscreen);
state_save_register_global(machine, star_enable);
state_save_register_global(machine, star_delay_counter);
state_save_register_global(machine, star_shift_reg);
}
/*************************************
*
* Video system
*
*************************************/
#define NUM_PENS (8)
#define NUM_PENS 8
static WRITE_LINE_DEVICE_HANDLER( flipscreen_w )
{
flipscreen = state ? 0 : 1;
nyny_state *driver_state = (nyny_state *)device->machine->driver_data;
driver_state->flipscreen = state ? 0 : 1;
}
@ -294,8 +298,8 @@ static MC6845_BEGIN_UPDATE( begin_update )
static MC6845_UPDATE_ROW( update_row )
{
nyny_state *state = (nyny_state *)device->machine->driver_data;
UINT8 cx;
pen_t *pens = (pen_t *)param;
UINT8 x = 0;
@ -310,30 +314,30 @@ static MC6845_UPDATE_ROW( update_row )
((ra << 5) & 0x00e0) |
((ma << 0) & 0x001f);
if (flipscreen)
if (state->flipscreen)
offs = offs ^ 0x9fff;
data1 = nyny_videoram_1[offs];
data2 = nyny_videoram_2[offs];
color1 = nyny_colorram_1[offs] & 0x07;
color2 = nyny_colorram_2[offs] & 0x07;
data1 = state->videoram1[offs];
data2 = state->videoram2[offs];
color1 = state->colorram1[offs] & 0x07;
color2 = state->colorram2[offs] & 0x07;
for (i = 0; i < 8; i++)
{
UINT8 bit1, bit2, color;
if (flipscreen)
if (state->flipscreen)
{
bit1 = data1 & 0x80;
bit2 = data2 & 0x80;
bit1 = BIT(data1, 7);
bit2 = BIT(data2, 7);
data1 = data1 << 1;
data2 = data2 << 1;
}
else
{
bit1 = data1 & 0x01;
bit2 = data2 & 0x01;
bit1 = BIT(data1, 0);
bit2 = BIT(data2, 0);
data1 = data1 >> 1;
data2 = data2 >> 1;
@ -347,27 +351,30 @@ static MC6845_UPDATE_ROW( update_row )
*BITMAP_ADDR32(bitmap, y, x) = pens[color];
x = x + 1;
x += 1;
}
ma = ma + 1;
ma += 1;
}
}
INLINE void shift_star_generator(void)
INLINE void shift_star_generator( running_machine *machine )
{
star_shift_reg = (star_shift_reg << 1) | (((~star_shift_reg >> 15) & 0x01) ^ ((star_shift_reg >> 2) & 0x01));
nyny_state *state = (nyny_state *)machine->driver_data;
state->star_shift_reg = (state->star_shift_reg << 1) | (((~state->star_shift_reg >> 15) & 0x01) ^ ((state->star_shift_reg >> 2) & 0x01));
}
static MC6845_END_UPDATE( end_update )
{
nyny_state *state = (nyny_state *)device->machine->driver_data;
/* draw the star field into the bitmap */
int y;
pen_t *pens = (pen_t *)param;
UINT16 delay_counter = star_delay_counter;
UINT16 delay_counter = state->star_delay_counter;
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
{
@ -376,20 +383,20 @@ static MC6845_END_UPDATE( end_update )
for (x = cliprect->min_x; x <= cliprect->max_x; x++)
{
/* check if the star status */
if (star_enable &&
if (state->star_enable &&
(*BITMAP_ADDR32(bitmap, y, x) == 0) &&
((star_shift_reg & 0x80ff) == 0x00ff) &&
(((y & 0x01) ^ flipscreen) ^ (((x & 0x08) >> 3) ^ flipscreen)))
((state->star_shift_reg & 0x80ff) == 0x00ff) &&
(((y & 0x01) ^ state->flipscreen) ^ (((x & 0x08) >> 3) ^ state->flipscreen)))
{
UINT8 color = ((star_shift_reg & 0x0100) >> 8) | /* R */
((star_shift_reg & 0x0400) >> 9) | /* G */
((star_shift_reg & 0x1000) >> 10); /* B */
UINT8 color = ((state->star_shift_reg & 0x0100) >> 8) | /* R */
((state->star_shift_reg & 0x0400) >> 9) | /* G */
((state->star_shift_reg & 0x1000) >> 10); /* B */
*BITMAP_ADDR32(bitmap, y, x) = pens[color];
}
if (delay_counter == 0)
shift_star_generator();
shift_star_generator(device->machine);
else
delay_counter = delay_counter - 1;
}
@ -399,7 +406,8 @@ static MC6845_END_UPDATE( end_update )
static WRITE_LINE_DEVICE_HANDLER( display_enable_changed )
{
ttl74123_a_w(devtag_get_device(device->machine, "ic48_1"), 0, state);
nyny_state *driver_state = (nyny_state *)device->machine->driver_data;
ttl74123_a_w(driver_state->ic48_1, 0, state);
}
@ -420,8 +428,9 @@ static const mc6845_interface mc6845_intf =
static VIDEO_UPDATE( nyny )
{
running_device *mc6845 = devtag_get_device(screen->machine, "crtc");
mc6845_update(mc6845, bitmap, cliprect);
nyny_state *state = (nyny_state *)screen->machine->driver_data;
mc6845_update(state->mc6845, bitmap, cliprect);
return 0;
}
@ -436,15 +445,19 @@ static VIDEO_UPDATE( nyny )
static WRITE8_HANDLER( audio_1_command_w )
{
nyny_state *state = (nyny_state *)space->machine->driver_data;
soundlatch_w(space, 0, data);
cputag_set_input_line(space->machine, "audiocpu", M6800_IRQ_LINE, HOLD_LINE);
cpu_set_input_line(state->audiocpu, M6800_IRQ_LINE, HOLD_LINE);
}
static WRITE8_HANDLER( audio_1_answer_w )
{
nyny_state *state = (nyny_state *)space->machine->driver_data;
soundlatch3_w(space, 0, data);
cputag_set_input_line(space->machine, "maincpu", M6809_IRQ_LINE, HOLD_LINE);
cpu_set_input_line(state->maincpu, M6809_IRQ_LINE, HOLD_LINE);
}
@ -487,8 +500,10 @@ static const ay8910_interface ay8910_64_interface =
static WRITE8_HANDLER( audio_2_command_w )
{
nyny_state *state = (nyny_state *)space->machine->driver_data;
soundlatch2_w(space, 0, (data & 0x60) >> 5);
cputag_set_input_line(space->machine, "audio2", M6800_IRQ_LINE, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
cpu_set_input_line(state->audiocpu2, M6800_IRQ_LINE, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
}
@ -501,13 +516,12 @@ static WRITE8_HANDLER( audio_2_command_w )
static READ8_HANDLER( nyny_pia_1_2_r )
{
running_device *pia1 = devtag_get_device(space->machine, "pia1");
running_device *pia2 = devtag_get_device(space->machine, "pia2");
nyny_state *state = (nyny_state *)space->machine->driver_data;
UINT8 ret = 0;
/* the address bits are directly connected to the chip selects */
if (offset & 0x04) ret = pia6821_r(pia1, offset & 0x03);
if (offset & 0x08) ret = pia6821_alt_r(pia2, offset & 0x03);
if (BIT(offset, 2)) ret = pia6821_r(state->pia1, offset & 0x03);
if (BIT(offset, 3)) ret = pia6821_alt_r(state->pia2, offset & 0x03);
return ret;
}
@ -515,20 +529,19 @@ static READ8_HANDLER( nyny_pia_1_2_r )
static WRITE8_HANDLER( nyny_pia_1_2_w )
{
running_device *pia1 = devtag_get_device(space->machine, "pia1");
running_device *pia2 = devtag_get_device(space->machine, "pia2");
nyny_state *state = (nyny_state *)space->machine->driver_data;
/* the address bits are directly connected to the chip selects */
if (offset & 0x04) pia6821_w(pia1, offset & 0x03, data);
if (offset & 0x08) pia6821_alt_w(pia2, offset & 0x03, data);
if (BIT(offset, 2)) pia6821_w(state->pia1, offset & 0x03, data);
if (BIT(offset, 3)) pia6821_alt_w(state->pia2, offset & 0x03, data);
}
static ADDRESS_MAP_START( nyny_main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&nyny_videoram_1)
AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&nyny_colorram_1)
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&nyny_videoram_2)
AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE(&nyny_colorram_2)
AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(nyny_state, videoram1)
AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_MEMBER(nyny_state, colorram1)
AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(nyny_state, videoram2)
AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE_MEMBER(nyny_state, colorram2)
AM_RANGE(0x8000, 0x9fff) AM_RAM
AM_RANGE(0xa000, 0xa0ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) /* SRAM (coin counter, shown when holding F2) */
AM_RANGE(0xa100, 0xa100) AM_MIRROR(0x00fe) AM_DEVWRITE("crtc", mc6845_address_w)
@ -587,16 +600,16 @@ static INPUT_PORTS_START( nyny )
PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL /* PIA0 PA4 */
PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 ) /* PIA0 PA5 */
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 ) /* PIA0 PA6 */
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL /* PIA0 PB0 */
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL /* PIA0 PB1 */
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY /* PIA0 PB2 */
PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY /* PIA0 PB3 */
PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
PORT_START("SW1") /* port 2 */
PORT_START("SW1")
PORT_DIPNAME( 0x03, 0x03, "Bombs from UFO (Screens 3+)" ) PORT_DIPLOCATION("SW1:1,2")
PORT_DIPSETTING( 0x01, "3" )
PORT_DIPSETTING( 0x00, "6" )
@ -609,7 +622,7 @@ static INPUT_PORTS_START( nyny )
PORT_DIPSETTING( 0x00, DEF_STR( Low ) )
PORT_DIPSETTING( 0x80, DEF_STR( High ) )
PORT_START("SW2") /* port 3 */
PORT_START("SW2")
PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW2:1,2")
PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) )
@ -627,7 +640,7 @@ static INPUT_PORTS_START( nyny )
PORT_DIPSETTING( 0x00, DEF_STR( No ) )
PORT_DIPSETTING( 0x80, DEF_STR( Yes ) )
PORT_START("SW3") /* port 4 */
PORT_START("SW3")
PORT_DIPNAME( 0x01, 0x00, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW3:1")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x01, DEF_STR( On ) )
@ -651,13 +664,48 @@ static INPUT_PORTS_START( nyny )
PORT_DIPSETTING( 0x40, "+2" )
PORT_DIPSETTING( 0x20, "+3" )
PORT_START("CROSS") /* connected to PIA1 CB1 input */
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("PS1 (Crosshatch)") PORT_CODE(KEYCODE_F1)
PORT_START("CROSS") /* connected to PIA1 CB1 input */
PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("PS1 (Crosshatch)") PORT_CODE(KEYCODE_F1)
INPUT_PORTS_END
/*************************************
*
* Machine start & reset
*
*************************************/
static MACHINE_START( nyny )
{
nyny_state *state = (nyny_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state->audiocpu2 = devtag_get_device(machine, "audio2");
state->ic48_1 = devtag_get_device(machine, "ic48_1");
state->mc6845 = devtag_get_device(machine, "crtc");
state->pia1 = devtag_get_device(machine, "pia1");
state->pia2 = devtag_get_device(machine, "pia2");
/* setup for save states */
state_save_register_global(machine, state->flipscreen);
state_save_register_global(machine, state->star_enable);
state_save_register_global(machine, state->star_delay_counter);
state_save_register_global(machine, state->star_shift_reg);
}
static MACHINE_RESET( nyny )
{
nyny_state *state = (nyny_state *)machine->driver_data;
state->flipscreen = 0;
state->star_enable = 0;
state->star_delay_counter = 0;
state->star_shift_reg = 0;
}
/*************************************
*
* Machine driver
@ -666,6 +714,9 @@ INPUT_PORTS_END
static MACHINE_DRIVER_START( nyny )
/* driver data */
MDRV_DRIVER_DATA(nyny_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6809, 1400000) /* 1.40 MHz? The clock signal is generated by analog chips */
MDRV_CPU_PROGRAM_MAP(nyny_main_map)
@ -678,6 +729,7 @@ static MACHINE_DRIVER_START( nyny )
MDRV_CPU_PROGRAM_MAP(nyny_audio_2_map)
MDRV_MACHINE_START(nyny)
MDRV_MACHINE_RESET(nyny)
MDRV_NVRAM_HANDLER(generic_0fill)
/* video hardware */

View File

@ -32,37 +32,28 @@ TO DO :
#include "emu.h"
#include "cpu/z80/z80.h"
#include "cpu/m68000/m68000.h"
#include "includes/oneshot.h"
#include "sound/okim6295.h"
#include "sound/3812intf.h"
#include "includes/oneshot.h"
UINT16 *oneshot_sprites;
UINT16 *oneshot_bg_videoram;
UINT16 *oneshot_mid_videoram;
UINT16 *oneshot_fg_videoram;
UINT16 *oneshot_scroll;
int gun_x_p1,gun_y_p1,gun_x_p2,gun_y_p2;
int gun_x_shift;
static READ16_HANDLER( oneshot_in0_word_r )
{
oneshot_state *state = (oneshot_state *)space->machine->driver_data;
int data = input_port_read(space->machine, "DSW1");
switch (data & 0x0c)
{
case 0x00 :
gun_x_shift = 35;
state->gun_x_shift = 35;
break;
case 0x04 :
gun_x_shift = 30;
state->gun_x_shift = 30;
break;
case 0x08 :
gun_x_shift = 40;
state->gun_x_shift = 40;
break;
case 0x0c :
gun_x_shift = 50;
state->gun_x_shift = 50;
break;
}
@ -71,30 +62,34 @@ static READ16_HANDLER( oneshot_in0_word_r )
static READ16_HANDLER( oneshot_gun_x_p1_r )
{
/* shots must be in a different location to register */
static int wobble = 0;
wobble ^= 1;
oneshot_state *state = (oneshot_state *)space->machine->driver_data;
return gun_x_p1 ^ wobble;
/* shots must be in a different location to register */
state->p1_wobble ^= 1;
return state->gun_x_p1 ^ state->p1_wobble;
}
static READ16_HANDLER( oneshot_gun_y_p1_r )
{
return gun_y_p1;
oneshot_state *state = (oneshot_state *)space->machine->driver_data;
return state->gun_y_p1;
}
static READ16_HANDLER( oneshot_gun_x_p2_r )
{
/* shots must be in a different location to register */
static int wobble = 0;
wobble ^= 1;
oneshot_state *state = (oneshot_state *)space->machine->driver_data;
return gun_x_p2 ^ wobble;
/* shots must be in a different location to register */
state->p2_wobble ^= 1;
return state->gun_x_p2 ^ state->p2_wobble;
}
static READ16_HANDLER( oneshot_gun_y_p2_r )
{
return gun_y_p2;
oneshot_state *state = (oneshot_state *)space->machine->driver_data;
return state->gun_y_p2;
}
static WRITE16_DEVICE_HANDLER( soundbank_w )
@ -111,11 +106,11 @@ static ADDRESS_MAP_START( oneshot_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x03ffff) AM_ROM
AM_RANGE(0x080000, 0x087fff) AM_RAM
AM_RANGE(0x0c0000, 0x0c07ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x120000, 0x120fff) AM_RAM AM_BASE(&oneshot_sprites)
AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(oneshot_mid_videoram_w) AM_BASE(&oneshot_mid_videoram) // some people , girl etc.
AM_RANGE(0x181000, 0x181fff) AM_RAM_WRITE(oneshot_fg_videoram_w) AM_BASE(&oneshot_fg_videoram) // credits etc.
AM_RANGE(0x182000, 0x182fff) AM_RAM_WRITE(oneshot_bg_videoram_w) AM_BASE(&oneshot_bg_videoram) // credits etc.
AM_RANGE(0x188000, 0x18800f) AM_WRITEONLY AM_BASE(&oneshot_scroll) // scroll registers
AM_RANGE(0x120000, 0x120fff) AM_RAM AM_BASE_MEMBER(oneshot_state, sprites)
AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(oneshot_mid_videoram_w) AM_BASE_MEMBER(oneshot_state, mid_videoram) // some people , girl etc.
AM_RANGE(0x181000, 0x181fff) AM_RAM_WRITE(oneshot_fg_videoram_w) AM_BASE_MEMBER(oneshot_state, fg_videoram) // credits etc.
AM_RANGE(0x182000, 0x182fff) AM_RAM_WRITE(oneshot_bg_videoram_w) AM_BASE_MEMBER(oneshot_state, bg_videoram) // credits etc.
AM_RANGE(0x188000, 0x18800f) AM_WRITEONLY AM_BASE_MEMBER(oneshot_state, scroll) // scroll registers
AM_RANGE(0x190002, 0x190003) AM_READ(soundlatch_word_r)
AM_RANGE(0x190010, 0x190011) AM_WRITE(soundlatch_word_w)
AM_RANGE(0x190018, 0x190019) AM_DEVWRITE("oki", soundbank_w)
@ -140,7 +135,7 @@ ADDRESS_MAP_END
static INPUT_PORTS_START( oneshot )
PORT_START("DSW1") /* DSW 1 (0x19c020.l -> 0x08006c.l) */
PORT_START("DSW1") /* 0x19c020.l -> 0x08006c.l */
PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) ) // 0x080084.l : credits (00-09)
PORT_DIPSETTING( 0x03, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) )
@ -162,7 +157,7 @@ static INPUT_PORTS_START( oneshot )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x80, DEF_STR( On ) )
PORT_START("DSW2") /* DSW 2 (0x19c024.l -> 0x08006e.l) */
PORT_START("DSW2") /* 0x19c024.l -> 0x08006e.l */
PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) // 0x082500.l
PORT_DIPSETTING( 0x01, "1" )
PORT_DIPSETTING( 0x02, "2" )
@ -182,7 +177,7 @@ static INPUT_PORTS_START( oneshot )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x80, DEF_STR( On ) )
PORT_START("CREDITS") /* Credits (0x19c02c.l -> 0x08007a.l) */
PORT_START("CREDITS") /* 0x19c02c.l -> 0x08007a.l */
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
@ -227,7 +222,7 @@ static INPUT_PORTS_START( oneshot )
INPUT_PORTS_END
static INPUT_PORTS_START( maddonna )
PORT_START("DSW1") /* DSW A */
PORT_START("DSW1")
PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) )
PORT_DIPSETTING( 0x03, DEF_STR( 3C_1C ) )
PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) )
@ -250,7 +245,7 @@ static INPUT_PORTS_START( maddonna )
PORT_DIPSETTING( 0x40, DEF_STR( On ) )
PORT_SERVICE( 0x80, IP_ACTIVE_HIGH )
PORT_START("DSW2") /* DSW B */
PORT_START("DSW2")
PORT_DIPNAME( 0x03, 0x02, DEF_STR( Difficulty ) )
PORT_DIPSETTING( 0x00, DEF_STR( Easy ) ) // 2 Monsters at start, but "dumber"??
PORT_DIPSETTING( 0x01, DEF_STR( Normal ) ) // 2 Monsters at start
@ -273,7 +268,7 @@ static INPUT_PORTS_START( maddonna )
PORT_DIPSETTING( 0x80, "On - 01" )
PORT_DIPSETTING( 0xc0, "On - 11" )
PORT_START("CREDITS") /* Credits */
PORT_START("CREDITS")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
@ -283,7 +278,7 @@ static INPUT_PORTS_START( maddonna )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("P1") /* Player 1 */
PORT_START("P1")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
@ -293,7 +288,7 @@ static INPUT_PORTS_START( maddonna )
PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
PORT_START("P2") /* Player 1 */
PORT_START("P2")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
@ -337,7 +332,8 @@ GFXDECODE_END
static void irq_handler(running_device *device, int irq)
{
cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
oneshot_state *state = (oneshot_state *)device->machine->driver_data;
cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
}
static const ym3812_interface ym3812_config =
@ -345,8 +341,40 @@ static const ym3812_interface ym3812_config =
irq_handler
};
static MACHINE_START( oneshot )
{
oneshot_state *state = (oneshot_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state_save_register_global(machine, state->gun_x_p1);
state_save_register_global(machine, state->gun_y_p1);
state_save_register_global(machine, state->gun_x_p2);
state_save_register_global(machine, state->gun_y_p2);
state_save_register_global(machine, state->gun_x_shift);
state_save_register_global(machine, state->p1_wobble);
state_save_register_global(machine, state->p2_wobble);
}
static MACHINE_RESET( oneshot )
{
oneshot_state *state = (oneshot_state *)machine->driver_data;
state->gun_x_p1 = 0;
state->gun_y_p1 = 0;
state->gun_x_p2 = 0;
state->gun_y_p2 = 0;
state->gun_x_shift = 0;
state->p1_wobble = 0;
state->p2_wobble = 0;
}
static MACHINE_DRIVER_START( oneshot )
/* driver data */
MDRV_DRIVER_DATA(oneshot_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, 12000000)
MDRV_CPU_PROGRAM_MAP(oneshot_map)
@ -355,7 +383,8 @@ static MACHINE_DRIVER_START( oneshot )
MDRV_CPU_ADD("audiocpu", Z80, 5000000)
MDRV_CPU_PROGRAM_MAP(oneshot_sound_map)
MDRV_GFXDECODE(oneshot)
MDRV_MACHINE_START(oneshot)
MDRV_MACHINE_RESET(oneshot)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
@ -365,6 +394,7 @@ static MACHINE_DRIVER_START( oneshot )
MDRV_SCREEN_SIZE(32*16, 32*16)
MDRV_SCREEN_VISIBLE_AREA(0*16, 20*16-1, 0*16, 15*16-1)
MDRV_GFXDECODE(oneshot)
MDRV_PALETTE_LENGTH(0x400)
MDRV_VIDEO_START(oneshot)
@ -470,8 +500,6 @@ ROM_END
GAME( 199?, oneshot, 0, oneshot, oneshot , 0, ROT0, "<unknown>", "One Shot One Kill", GAME_IMPERFECT_GRAPHICS )
GAME( 1995, maddonna, 0, maddonna, maddonna, 0, ROT0, "Tuning", "Mad Donna (set 1)", 0 )
GAME( 1995, maddonnb, maddonna, maddonna, maddonna, 0, ROT0, "Tuning", "Mad Donna (set 2)", GAME_NOT_WORKING )
GAME( 199?, oneshot, 0, oneshot, oneshot , 0, ROT0, "<unknown>", "One Shot One Kill", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
GAME( 1995, maddonna, 0, maddonna, maddonna, 0, ROT0, "Tuning", "Mad Donna (set 1)", GAME_SUPPORTS_SAVE )
GAME( 1995, maddonnb, maddonna, maddonna, maddonna, 0, ROT0, "Tuning", "Mad Donna (set 2)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )

View File

@ -44,76 +44,129 @@ Note: this is quite clearly a 'Korean bootleg' of Shisensho - Joshiryo-Hen / Mat
#include "sound/okim6295.h"
#include "sound/3812intf.h"
static tilemap_t *fg_tilemap;
static UINT8 *fgram;
#define MASTER_CLOCK XTAL_4MHz
#define MASTER_CLOCK (XTAL_4MHz)
class onetwo_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, onetwo_state(machine)); }
onetwo_state(running_machine &machine) { }
/* memory pointers */
UINT8 * fgram;
UINT8 * paletteram;
UINT8 * paletteram2;
/* video-related */
tilemap_t *fg_tilemap;
/* devices */
running_device *maincpu;
running_device *audiocpu;
};
/*************************************
*
* Video emulation
*
*************************************/
static TILE_GET_INFO( get_fg_tile_info )
{
int code = (fgram[tile_index*2+1]<<8) | fgram[tile_index*2];
int color = (fgram[tile_index*2+1] & 0x80) >> 7;
onetwo_state *state = (onetwo_state *)machine->driver_data;
int code = (state->fgram[tile_index * 2 + 1] << 8) | state->fgram[tile_index * 2];
int color = (state->fgram[tile_index * 2 + 1] & 0x80) >> 7;
code &= 0x7fff;
SET_TILE_INFO(0, code, color, 0);
}
static VIDEO_START( onetwo )
{
onetwo_state *state = (onetwo_state *)machine->driver_data;
state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
}
static VIDEO_UPDATE( onetwo )
{
onetwo_state *state = (onetwo_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0;
}
/*************************************
*
* Memory handlers
*
*************************************/
static WRITE8_HANDLER( onetwo_fgram_w )
{
fgram[offset] = data;
tilemap_mark_tile_dirty(fg_tilemap, offset / 2);
onetwo_state *state = (onetwo_state *)space->machine->driver_data;
state->fgram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
}
static WRITE8_HANDLER( onetwo_cpubank_w )
{
UINT8 *RAM = memory_region(space->machine, "maincpu") + 0x10000;
memory_set_bankptr(space->machine, "bank1", &RAM[data * 0x4000]);
memory_set_bank(space->machine, "bank1", data);
}
static WRITE8_HANDLER( onetwo_coin_counters_w )
{
watchdog_reset(space->machine);
coin_counter_w(space->machine, 0, data & 0x02);
coin_counter_w(space->machine, 1, data & 0x04);
coin_counter_w(space->machine, 0, BIT(data, 1));
coin_counter_w(space->machine, 1, BIT(data, 2));
}
static WRITE8_HANDLER( onetwo_soundlatch_w )
{
onetwo_state *state = (onetwo_state *)space->machine->driver_data;
soundlatch_w(space, 0, data);
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
}
static void setColor(running_machine *machine, int offset)
static void set_color(running_machine *machine, int offset)
{
int r, g, b;
r = machine->generic.paletteram.u8[offset] & 0x1f;
g = machine->generic.paletteram2.u8[offset] & 0x1f;
b = ((machine->generic.paletteram.u8[offset] & 0x60) >> 2) | ((machine->generic.paletteram2.u8[offset] & 0xe0) >> 5);
palette_set_color_rgb(machine, offset, pal5bit(r), pal5bit(g), pal5bit(b));
onetwo_state *state = (onetwo_state *)machine->driver_data;
int r, g, b;
r = state->paletteram[offset] & 0x1f;
g = state->paletteram2[offset] & 0x1f;
b = ((state->paletteram[offset] & 0x60) >> 2) | ((state->paletteram2[offset] & 0xe0) >> 5);
palette_set_color_rgb(machine, offset, pal5bit(r), pal5bit(g), pal5bit(b));
}
static WRITE8_HANDLER(palette1_w)
{
space->machine->generic.paletteram.u8[offset] = data;
setColor(space->machine, offset);
onetwo_state *state = (onetwo_state *)space->machine->driver_data;
state->paletteram[offset] = data;
set_color(space->machine, offset);
}
static WRITE8_HANDLER(palette2_w)
{
space->machine->generic.paletteram2.u8[offset] = data;
setColor(space->machine, offset);
onetwo_state *state = (onetwo_state *)space->machine->driver_data;
state->paletteram2[offset] = data;
set_color(space->machine, offset);
}
/* Main CPU */
/*************************************
*
* Address maps
*
*************************************/
static ADDRESS_MAP_START( main_cpu, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_REGION("maincpu", 0x10000)
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc800, 0xc87f) AM_RAM_WRITE(palette1_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xc900, 0xc97f) AM_RAM_WRITE(palette2_w) AM_BASE_GENERIC(paletteram2)
AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(onetwo_fgram_w) AM_BASE(&fgram)
AM_RANGE(0xc800, 0xc87f) AM_RAM_WRITE(palette1_w) AM_BASE_MEMBER(onetwo_state, paletteram)
AM_RANGE(0xc900, 0xc97f) AM_RAM_WRITE(palette2_w) AM_BASE_MEMBER(onetwo_state, paletteram2)
AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(onetwo_fgram_w) AM_BASE_MEMBER(onetwo_state, fgram)
AM_RANGE(0xe000, 0xffff) AM_RAM
ADDRESS_MAP_END
@ -126,8 +179,6 @@ static ADDRESS_MAP_START( main_cpu_io, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x04, 0x04) AM_READ_PORT("SYSTEM")
ADDRESS_MAP_END
/* Sound CPU */
static ADDRESS_MAP_START( sound_cpu, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x5fff) AM_ROM
AM_RANGE(0xf000, 0xf7ff) AM_RAM
@ -142,6 +193,12 @@ static ADDRESS_MAP_START( sound_cpu_io, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0xc0, 0xc0) AM_WRITE(soundlatch_clear_w)
ADDRESS_MAP_END
/*************************************
*
* Input ports
*
*************************************/
static INPUT_PORTS_START( onetwo )
PORT_START("DSW1")
PORT_DIPNAME( 0x03, 0x03, "Timer" ) PORT_DIPLOCATION("SW1:1,2")
@ -240,6 +297,12 @@ static INPUT_PORTS_START( onetwo )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
INPUT_PORTS_END
/*************************************
*
* Graphics definitions
*
*************************************/
static const gfx_layout tiles8x8x6_layout =
{
8,8,
@ -255,20 +318,16 @@ static GFXDECODE_START( onetwo )
GFXDECODE_ENTRY( "gfx1", 0, tiles8x8x6_layout, 0, 2 )
GFXDECODE_END
static VIDEO_START( onetwo )
{
fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
}
static VIDEO_UPDATE( onetwo )
{
tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
return 0;
}
/*************************************
*
* Sound interface
*
*************************************/
static void irqhandler(running_device *device, int linestate)
{
cputag_set_input_line(device->machine, "audiocpu", 0, linestate);
onetwo_state *state = (onetwo_state *)device->machine->driver_data;
cpu_set_input_line(state->audiocpu, 0, linestate);
}
static const ym3812_interface ym3812_config =
@ -276,7 +335,28 @@ static const ym3812_interface ym3812_config =
irqhandler /* IRQ Line */
};
/*************************************
*
* Machine driver
*
*************************************/
static MACHINE_START( onetwo )
{
onetwo_state *state = (onetwo_state *)machine->driver_data;
UINT8 *ROM = memory_region(machine, "maincpu");
memory_configure_bank(machine, "bank1", 0, 8, &ROM[0x10000], 0x4000);
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
}
static MACHINE_DRIVER_START( onetwo )
/* driver data */
MDRV_DRIVER_DATA(onetwo_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,MASTER_CLOCK) /* 4 MHz */
MDRV_CPU_PROGRAM_MAP(main_cpu)
@ -287,6 +367,8 @@ static MACHINE_DRIVER_START( onetwo )
MDRV_CPU_PROGRAM_MAP(sound_cpu)
MDRV_CPU_IO_MAP(sound_cpu_io)
MDRV_MACHINE_START(onetwo)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@ -313,6 +395,12 @@ static MACHINE_DRIVER_START( onetwo )
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
MACHINE_DRIVER_END
/*************************************
*
* ROM definition(s)
*
*************************************/
ROM_START( onetwo )
ROM_REGION( 0x30000, "maincpu", 0 ) /* main z80 */
ROM_LOAD( "maincpu", 0x10000, 0x20000, CRC(83431e6e) SHA1(61ab386a1d0af050f091f5df28c55ad5ad1a0d4b) )
@ -345,5 +433,11 @@ ROM_START( onetwoe )
ROM_LOAD( "sample", 0x000000, 0x40000, CRC(b10d3132) SHA1(42613e17b6a1300063b8355596a2dc7bcd903777) )
ROM_END
GAME( 1997, onetwo, 0, onetwo, onetwo, 0, ROT0, "Barko", "One + Two", 0 )
GAME( 1997, onetwoe, onetwo, onetwo, onetwo, 0, ROT0, "Barko", "One + Two (earlier)", 0 )
/*************************************
*
* Game driver(s)
*
*************************************/
GAME( 1997, onetwo, 0, onetwo, onetwo, 0, ROT0, "Barko", "One + Two", GAME_SUPPORTS_SAVE )
GAME( 1997, onetwoe, onetwo, onetwo, onetwo, 0, ROT0, "Barko", "One + Two (earlier)", GAME_SUPPORTS_SAVE )

View File

@ -25,11 +25,6 @@ Atari Orbit Driver
#define MASTER_CLOCK XTAL_12_096MHz
static UINT8 orbit_misc_flags;
/*************************************
*
* Interrupts and timing
@ -38,15 +33,17 @@ static UINT8 orbit_misc_flags;
static TIMER_DEVICE_CALLBACK( nmi_32v )
{
orbit_state *state = (orbit_state *)timer->machine->driver_data;
int scanline = param;
int nmistate = (scanline & 32) && (orbit_misc_flags & 4);
cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, nmistate ? ASSERT_LINE : CLEAR_LINE);
int nmistate = (scanline & 32) && (state->misc_flags & 4);
cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, nmistate ? ASSERT_LINE : CLEAR_LINE);
}
static TIMER_CALLBACK( irq_off )
{
cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
orbit_state *state = (orbit_state *)machine->driver_data;
cpu_set_input_line(state->maincpu, 0, CLEAR_LINE);
}
@ -66,9 +63,9 @@ static INTERRUPT_GEN( orbit_interrupt )
static void update_misc_flags(running_machine *machine, UINT8 val)
{
running_device *discrete = devtag_get_device(machine, "discrete");
orbit_state *state = (orbit_state *)machine->driver_data;
orbit_misc_flags = val;
state->misc_flags = val;
/* BIT0 => UNUSED */
/* BIT1 => LOCKOUT */
@ -79,37 +76,25 @@ static void update_misc_flags(running_machine *machine, UINT8 val)
/* BIT6 => HYPER LED */
/* BIT7 => WARNING SND */
discrete_sound_w(discrete, ORBIT_WARNING_EN, orbit_misc_flags & 0x80);
discrete_sound_w(state->discrete, ORBIT_WARNING_EN, BIT(state->misc_flags, 7));
set_led_status(machine, 0, orbit_misc_flags & 0x08);
set_led_status(machine, 1, orbit_misc_flags & 0x40);
set_led_status(machine, 0, BIT(state->misc_flags, 3));
set_led_status(machine, 1, BIT(state->misc_flags, 6));
coin_lockout_w(machine, 0, !(orbit_misc_flags & 0x02));
coin_lockout_w(machine, 1, !(orbit_misc_flags & 0x02));
coin_lockout_w(machine, 0, !BIT(state->misc_flags, 1));
coin_lockout_w(machine, 1, !BIT(state->misc_flags, 1));
}
static WRITE8_HANDLER( orbit_misc_w )
{
orbit_state *state = (orbit_state *)space->machine->driver_data;
UINT8 bit = offset >> 1;
if (offset & 1)
update_misc_flags(space->machine, orbit_misc_flags | (1 << bit));
update_misc_flags(space->machine, state->misc_flags | (1 << bit));
else
update_misc_flags(space->machine, orbit_misc_flags & ~(1 << bit));
}
/*************************************
*
* Machine setup
*
*************************************/
static MACHINE_RESET( orbit )
{
update_misc_flags(machine, 0);
update_misc_flags(space->machine, state->misc_flags & ~(1 << bit));
}
@ -128,8 +113,8 @@ static ADDRESS_MAP_START( orbit_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x1800, 0x1800) AM_MIRROR(0x07ff) AM_READ_PORT("DSW1")
AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x07ff) AM_READ_PORT("DSW2")
AM_RANGE(0x2800, 0x2800) AM_MIRROR(0x07ff) AM_READ_PORT("BUTTONS")
AM_RANGE(0x3000, 0x33bf) AM_MIRROR(0x0400) AM_RAM_WRITE(orbit_playfield_w) AM_BASE(&orbit_playfield_ram)
AM_RANGE(0x33c0, 0x33ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&orbit_sprite_ram)
AM_RANGE(0x3000, 0x33bf) AM_MIRROR(0x0400) AM_RAM_WRITE(orbit_playfield_w) AM_BASE_MEMBER(orbit_state, playfield_ram)
AM_RANGE(0x33c0, 0x33ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(orbit_state, sprite_ram)
AM_RANGE(0x3800, 0x3800) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_note_w)
AM_RANGE(0x3900, 0x3900) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_noise_amp_w)
AM_RANGE(0x3a00, 0x3a00) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_note_amp_w)
@ -281,6 +266,32 @@ GFXDECODE_END
/*************************************
*
* Machine setup
*
*************************************/
static MACHINE_START( orbit )
{
orbit_state *state = (orbit_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->discrete = devtag_get_device(machine, "discrete");
state_save_register_global(machine, state->misc_flags);
state_save_register_global(machine, state->flip_screen);
}
static MACHINE_RESET( orbit )
{
orbit_state *state = (orbit_state *)machine->driver_data;
update_misc_flags(machine, 0);
state->flip_screen = 0;
}
/*************************************
*
* Machine drivers
@ -289,6 +300,9 @@ GFXDECODE_END
static MACHINE_DRIVER_START( orbit )
/* driver data */
MDRV_DRIVER_DATA(orbit_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6800, MASTER_CLOCK / 16)
MDRV_CPU_PROGRAM_MAP(orbit_map)
@ -296,6 +310,7 @@ static MACHINE_DRIVER_START( orbit )
MDRV_TIMER_ADD_SCANLINE("32v", nmi_32v, "screen", 0, 32)
MDRV_MACHINE_START(orbit)
MDRV_MACHINE_RESET(orbit)
/* video hardware */
@ -362,4 +377,4 @@ ROM_END
*
*************************************/
GAME( 1978, orbit, 0, orbit, orbit, 0, 0, "Atari", "Orbit", 0 )
GAME( 1978, orbit, 0, orbit, orbit, 0, 0, "Atari", "Orbit", GAME_SUPPORTS_SAVE )

View File

@ -37,42 +37,64 @@ Limit for help/undo (matta):
#include "emu.h"
#include "cpu/z80/z80.h"
#include "cpu/mcs48/mcs48.h"
#include "machine/i8243.h"
#include "sound/dac.h"
#include "sound/ay8910.h"
#include "video/mc6845.h"
#include "machine/i8243.h"
#include "cpu/mcs48/mcs48.h"
#include "sound/dac.h"
static int ay_select=0;
static int ack_data=0;
static UINT8 n7751_command;
//static UINT32 n7751_rom_address;
static int tile_bank=0;
static int sound_addr;
static int n7751_busy;
#define TILE_WIDTH 6
class othello_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, othello_state(machine)); }
othello_state(running_machine &machine) { }
/* memory pointers */
UINT8 * videoram;
/* video-related */
int tile_bank;
/* misc */
int ay_select;
int ack_data;
UINT8 n7751_command;
// UINT32 n7751_rom_address;
int sound_addr;
int n7751_busy;
/* devices */
running_device *maincpu;
running_device *mc6845;
running_device *n7751;
running_device *ay1;
running_device *ay2;
};
static MC6845_UPDATE_ROW( update_row )
{
int cx,x;
othello_state *state = (othello_state *)device->machine->driver_data;
int cx, x;
UINT32 data_address;
UINT32 tmp;
const UINT8 *gfx = memory_region(device->machine, "gfx");
for(cx=0;cx<x_count;++cx)
for(cx = 0; cx < x_count; ++cx)
{
data_address=((device->machine->generic.videoram.u8[ma+cx]+tile_bank)<<4)|ra;
tmp=gfx[data_address]|(gfx[data_address+0x2000]<<8)|(gfx[data_address+0x4000]<<16);
data_address = ((state->videoram[ma + cx] + state->tile_bank) << 4) | ra;
tmp = gfx[data_address] | (gfx[data_address + 0x2000] << 8) | (gfx[data_address + 0x4000] << 16);
for(x=0;x<TILE_WIDTH;++x)
for(x = 0; x < TILE_WIDTH; ++x)
{
*BITMAP_ADDR16(bitmap, y, (cx*TILE_WIDTH+x)^1) = tmp&0x0f;
tmp>>=4;
*BITMAP_ADDR16(bitmap, y, (cx * TILE_WIDTH + x) ^ 1) = tmp & 0x0f;
tmp >>= 4;
}
}
}
@ -80,32 +102,33 @@ static MC6845_UPDATE_ROW( update_row )
static PALETTE_INIT( othello )
{
int i;
for (i = 0;i < machine->config->total_colors;i++)
{
palette_set_color(machine,i,MAKE_RGB(0xff,0x00,0xff));
}
for (i = 0; i < machine->config->total_colors; i++)
{
palette_set_color(machine, i, MAKE_RGB(0xff, 0x00, 0xff));
}
/* only colors 2,3,7,9,c,d,f are used */
palette_set_color(machine,0x02,MAKE_RGB(0x00,0xff,0x00));
palette_set_color(machine,0x03,MAKE_RGB(0xff,0x7f,0x00));
palette_set_color(machine,0x07,MAKE_RGB(0x00,0x00,0x00));
palette_set_color(machine,0x09,MAKE_RGB(0xff,0x00,0x00));
palette_set_color(machine,0x0c,MAKE_RGB(0x00,0x00,0xff));
palette_set_color(machine,0x0d,MAKE_RGB(0x7f,0x7f,0x00));
palette_set_color(machine,0x0f,MAKE_RGB(0xff,0xff,0xff));
/* only colors 2,3,7,9,c,d,f are used */
palette_set_color(machine, 0x02, MAKE_RGB(0x00, 0xff, 0x00));
palette_set_color(machine, 0x03, MAKE_RGB(0xff, 0x7f, 0x00));
palette_set_color(machine, 0x07, MAKE_RGB(0x00, 0x00, 0x00));
palette_set_color(machine, 0x09, MAKE_RGB(0xff, 0x00, 0x00));
palette_set_color(machine, 0x0c, MAKE_RGB(0x00, 0x00, 0xff));
palette_set_color(machine, 0x0d, MAKE_RGB(0x7f, 0x7f, 0x00));
palette_set_color(machine, 0x0f, MAKE_RGB(0xff, 0xff, 0xff));
}
static VIDEO_UPDATE( othello )
{
running_device *mc6845 = devtag_get_device(screen->machine, "crtc");
mc6845_update(mc6845, bitmap, cliprect);
othello_state *state = (othello_state *)screen->machine->driver_data;
mc6845_update(state->mc6845, bitmap, cliprect);
return 0;
}
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x8000, 0x97ff) AM_NOP /* not populated */
AM_RANGE(0x9800, 0x9fff) AM_RAM AM_BASE_GENERIC(videoram)
AM_RANGE(0x9800, 0x9fff) AM_RAM AM_BASE_MEMBER(othello_state, videoram)
AM_RANGE(0xf000, 0xffff) AM_RAM
ADDRESS_MAP_END
@ -115,21 +138,23 @@ static READ8_HANDLER( unk_87_r )
return mame_rand(space->machine);
}
static WRITE8_HANDLER(unk_8a_w)
static WRITE8_HANDLER( unk_8a_w )
{
/*
n7751_command = (data & 0x07);
cputag_set_input_line(space->machine, "n7751", 0, ((data & 0x08) == 0) ? ASSERT_LINE : CLEAR_LINE);
//cputag_set_input_line(device->machine, "n7751", 0, (data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
othello_state *state = (othello_state *)space->machine->driver_data;
state->n7751_command = (data & 0x07);
cpu_set_input_line(state->n7751, 0, ((data & 0x08) == 0) ? ASSERT_LINE : CLEAR_LINE);
//cpu_set_input_line(state->n7751, 0, (data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(100));
*/
logerror("8a -> %x\n",data);
logerror("8a -> %x\n", data);
}
static WRITE8_HANDLER(unk_8c_w)
static WRITE8_HANDLER( unk_8c_w )
{
logerror("8c -> %x\n",data);
logerror("8c -> %x\n", data);
}
static READ8_HANDLER( unk_8c_r )
@ -137,20 +162,22 @@ static READ8_HANDLER( unk_8c_r )
return mame_rand(space->machine);
}
static READ8_HANDLER(sound_ack_r)
static READ8_HANDLER( sound_ack_r )
{
return ack_data;
othello_state *state = (othello_state *)space->machine->driver_data;
return state->ack_data;
}
static WRITE8_HANDLER(unk_8f_w)
static WRITE8_HANDLER( unk_8f_w )
{
logerror("8f -> %x\n",data);
logerror("8f -> %x\n", data);
}
static WRITE8_HANDLER(tilebank_w)
static WRITE8_HANDLER( tilebank_w )
{
tile_bank=data==0x0f?0x100:0x00;
logerror("tilebank -> %x\n",data);
othello_state *state = (othello_state *)space->machine->driver_data;
state->tile_bank = (data == 0x0f) ? 0x100 : 0x00;
logerror("tilebank -> %x\n", data);
}
static ADDRESS_MAP_START( main_portmap, ADDRESS_SPACE_IO, 8 )
@ -168,34 +195,39 @@ static ADDRESS_MAP_START( main_portmap, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x8f, 0x8f) AM_WRITE(unk_8f_w)
ADDRESS_MAP_END
static READ8_HANDLER(latch_r)
static READ8_HANDLER( latch_r )
{
int retval=soundlatch_r(space,0);
soundlatch_clear_w(space,0,0);
int retval = soundlatch_r(space, 0);
soundlatch_clear_w(space, 0, 0);
return retval;
}
static WRITE8_HANDLER(ay_select_w)
static WRITE8_HANDLER( ay_select_w )
{
ay_select=data;
othello_state *state = (othello_state *)space->machine->driver_data;
state->ay_select = data;
}
static WRITE8_HANDLER(ack_w)
static WRITE8_HANDLER( ack_w )
{
ack_data=data;
othello_state *state = (othello_state *)space->machine->driver_data;
state->ack_data = data;
}
static WRITE8_HANDLER(ay_address_w)
static WRITE8_HANDLER( ay_address_w )
{
if(ay_select&1) ay8910_address_w(devtag_get_device(space->machine, "ay1"),0,data);
if(ay_select&2) ay8910_address_w(devtag_get_device(space->machine, "ay2"),0,data);
othello_state *state = (othello_state *)space->machine->driver_data;
if (state->ay_select & 1) ay8910_address_w(state->ay1, 0, data);
if (state->ay_select & 2) ay8910_address_w(state->ay2, 0, data);
}
static WRITE8_HANDLER(ay_data_w)
static WRITE8_HANDLER( ay_data_w )
{
if(ay_select&1) ay8910_data_w(devtag_get_device(space->machine, "ay1"),0,data);
if(ay_select&2) ay8910_data_w(devtag_get_device(space->machine, "ay2"),0,data);
othello_state *state = (othello_state *)space->machine->driver_data;
if (state->ay_select & 1) ay8910_data_w(state->ay1, 0, data);
if (state->ay_select & 2) ay8910_data_w(state->ay2, 0, data);
}
static ADDRESS_MAP_START( audio_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -214,6 +246,8 @@ ADDRESS_MAP_END
static WRITE8_DEVICE_HANDLER( n7751_rom_control_w )
{
othello_state *state = (othello_state *)device->machine->driver_data;
/* P4 - address lines 0-3 */
/* P5 - address lines 4-7 */
/* P6 - address lines 8-11 */
@ -221,25 +255,25 @@ static WRITE8_DEVICE_HANDLER( n7751_rom_control_w )
switch (offset)
{
case 0:
sound_addr = (sound_addr & ~0x00f) | ((data & 0x0f) << 0);
state->sound_addr = (state->sound_addr & ~0x00f) | ((data & 0x0f) << 0);
break;
case 1:
sound_addr = (sound_addr & ~0x0f0) | ((data & 0x0f) << 4);
state->sound_addr = (state->sound_addr & ~0x0f0) | ((data & 0x0f) << 4);
break;
case 2:
sound_addr = (sound_addr & ~0xf00) | ((data & 0x0f) << 8);
state->sound_addr = (state->sound_addr & ~0xf00) | ((data & 0x0f) << 8);
break;
case 3:
sound_addr &= 0xfff;
state->sound_addr &= 0xfff;
{
if (!(data & 0x01) ) sound_addr |= 0x0000;
if (!(data & 0x02) ) sound_addr |= 0x1000;
if (!(data & 0x04) ) sound_addr |= 0x2000;
if (!(data & 0x08) ) sound_addr |= 0x3000;
if (!BIT(data, 0)) state->sound_addr |= 0x0000;
if (!BIT(data, 1)) state->sound_addr |= 0x1000;
if (!BIT(data, 2)) state->sound_addr |= 0x2000;
if (!BIT(data, 3)) state->sound_addr |= 0x3000;
}
break;
}
@ -247,22 +281,26 @@ static WRITE8_DEVICE_HANDLER( n7751_rom_control_w )
static READ8_HANDLER( n7751_rom_r )
{
return memory_region(space->machine, "n7751data")[sound_addr];
othello_state *state = (othello_state *)space->machine->driver_data;
return memory_region(space->machine, "n7751data")[state->sound_addr];
}
static READ8_HANDLER( n7751_command_r )
{
return 0x80 | ((n7751_command & 0x07) << 4);
othello_state *state = (othello_state *)space->machine->driver_data;
return 0x80 | ((state->n7751_command & 0x07) << 4);
}
static WRITE8_DEVICE_HANDLER( n7751_p2_w )
{
othello_state *state = (othello_state *)device->machine->driver_data;
/* write to P2; low 4 bits go to 8243 */
i8243_p2_w(device, offset, data & 0x0f);
/* output of bit $80 indicates we are ready (1) or busy (0) */
/* no other outputs are used */
n7751_busy = data;
state->n7751_busy = data;
}
static READ8_HANDLER( n7751_t1_r )
@ -340,8 +378,42 @@ static const mc6845_interface h46505_intf =
NULL /* update address callback */
};
static MACHINE_START( othello )
{
othello_state *state = (othello_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->mc6845 = devtag_get_device(machine, "crtc");
state->n7751 = devtag_get_device(machine, "n7751");
state->ay1 = devtag_get_device(machine, "ay1");
state->ay2 = devtag_get_device(machine, "ay2");
state_save_register_global(machine, state->tile_bank);
state_save_register_global(machine, state->ay_select);
state_save_register_global(machine, state->ack_data);
state_save_register_global(machine, state->n7751_command);
state_save_register_global(machine, state->sound_addr);
state_save_register_global(machine, state->n7751_busy);
}
static MACHINE_RESET( othello )
{
othello_state *state = (othello_state *)machine->driver_data;
state->tile_bank = 0;
state->ay_select = 0;
state->ack_data = 0;
state->n7751_command = 0;
state->sound_addr = 0;
state->n7751_busy = 0;
}
static MACHINE_DRIVER_START( othello )
/* driver data */
MDRV_DRIVER_DATA(othello_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu",Z80,XTAL_8MHz/2)
MDRV_CPU_PROGRAM_MAP(main_map)
@ -357,6 +429,8 @@ static MACHINE_DRIVER_START( othello )
MDRV_I8243_ADD("n7751_8243", NULL, n7751_rom_control_w)
MDRV_MACHINE_START(othello)
MDRV_MACHINE_RESET(othello)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
@ -406,4 +480,4 @@ ROM_START( othello )
ROM_LOAD( "7.ic42", 0x4000, 0x2000, CRC(a76705f7) SHA1(b7d2a65d65d065732ddd0b3b738749369b382b48))
ROM_END
GAME( 1984, othello, 0, othello, othello, 0, ROT0, "Success", "Othello (version 3.0)", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND )
GAME( 1984, othello, 0, othello, othello, 0, ROT0, "Success", "Othello (version 3.0)", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )

View File

@ -17,24 +17,13 @@ Notes:
#include "emu.h"
#include "cpu/m68000/m68000.h"
#include "sound/okim6295.h"
WRITE16_HANDLER( othldrby_videoram_addr_w );
READ16_HANDLER( othldrby_videoram_r );
WRITE16_HANDLER( othldrby_videoram_w );
WRITE16_HANDLER( othldrby_vreg_addr_w );
WRITE16_HANDLER( othldrby_vreg_w );
VIDEO_START( othldrby );
VIDEO_EOF( othldrby );
VIDEO_UPDATE( othldrby );
static int toggle;
#include "includes/othldrby.h"
static READ16_HANDLER( pip )
{
return toggle ^= 1;
othldrby_state *state = (othldrby_state *)space->machine->driver_data;
return state->toggle ^= 1;
}
static READ16_HANDLER( pap )
@ -53,10 +42,10 @@ static WRITE16_HANDLER( coinctrl_w )
{
if (ACCESSING_BITS_0_7)
{
coin_counter_w(space->machine, 0,data & 1);
coin_counter_w(space->machine, 1,data & 2);
coin_lockout_w(space->machine, 0,~data & 4);
coin_lockout_w(space->machine, 1,~data & 8);
coin_counter_w(space->machine, 0, data & 1);
coin_counter_w(space->machine, 1, data & 2);
coin_lockout_w(space->machine, 0, ~data & 4);
coin_lockout_w(space->machine, 1, ~data & 8);
}
}
@ -93,18 +82,17 @@ static READ16_HANDLER( calendar_r )
}
static ADDRESS_MAP_START( othldrby_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x07ffff) AM_ROM
AM_RANGE(0x100000, 0x10ffff) AM_RAM
AM_RANGE(0x200000, 0x20000f) AM_READWRITE(calendar_r,calendar_w)
AM_RANGE(0x200000, 0x20000f) AM_READWRITE(calendar_r, calendar_w)
AM_RANGE(0x300000, 0x300001) AM_WRITE(othldrby_videoram_addr_w)
AM_RANGE(0x300004, 0x300007) AM_READWRITE(othldrby_videoram_r,othldrby_videoram_w)
AM_RANGE(0x300004, 0x300007) AM_READWRITE(othldrby_videoram_r, othldrby_videoram_w)
AM_RANGE(0x300008, 0x300009) AM_WRITE(othldrby_vreg_addr_w)
AM_RANGE(0x30000c, 0x30000d) AM_READ(pip) // vblank?
AM_RANGE(0x30000c, 0x30000f) AM_WRITE(othldrby_vreg_w)
AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_r,okim6295_w, 0x00ff)
AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff)
AM_RANGE(0x700000, 0x700001) AM_READ(pap) // scanline???
AM_RANGE(0x700004, 0x700005) AM_READ_PORT("DSW1")
AM_RANGE(0x700008, 0x700009) AM_READ_PORT("DSW2")
@ -228,13 +216,40 @@ GFXDECODE_END
static MACHINE_START( othldrby )
{
othldrby_state *state = (othldrby_state *)machine->driver_data;
state_save_register_global(machine, state->toggle);
state_save_register_global(machine, state->vram_addr);
state_save_register_global(machine, state->vreg_addr);
state_save_register_global_array(machine, state->vreg);
}
static MACHINE_RESET( othldrby )
{
othldrby_state *state = (othldrby_state *)machine->driver_data;
state->toggle = 0xff;
state->vram_addr = 0;
state->vreg_addr = 0;
memset(state->vreg, 0, ARRAY_LENGTH(state->vreg));
}
static MACHINE_DRIVER_START( othldrby )
/* driver data */
MDRV_DRIVER_DATA(othldrby_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M68000, 16000000)
MDRV_CPU_PROGRAM_MAP(othldrby_map)
MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
MDRV_MACHINE_START(othldrby)
MDRV_MACHINE_RESET(othldrby)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)
@ -278,9 +293,4 @@ ROM_START( othldrby )
ROM_LOAD( "db0.4", 0x00000, 0x80000, CRC(a9701868) SHA1(9ee89556666d358e8d3915622573b3ba660048b8) )
ROM_END
static DRIVER_INIT( othldrby )
{
toggle = 0xff;
}
GAME( 1995, othldrby, 0, othldrby, othldrby, othldrby, ROT0, "Sunwise", "Othello Derby (Japan)", 0 )
GAME( 1995, othldrby, 0, othldrby, othldrby, 0, ROT0, "Sunwise", "Othello Derby (Japan)", GAME_SUPPORTS_SAVE )

View File

@ -1,30 +1,64 @@
/*----------- defined in drivers/nemesis.c -----------*/
class nemesis_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nemesis_state(machine)); }
nemesis_state(running_machine &machine) { }
/* memory pointers */
UINT16 * videoram1;
UINT16 * videoram2;
UINT16 * colorram1;
UINT16 * colorram2;
UINT16 * charram;
UINT16 * spriteram;
UINT16 * paletteram;
UINT16 * xscroll1;
UINT16 * xscroll2;
UINT16 * yscroll1;
UINT16 * yscroll2;
UINT8 * gx400_shared_ram;
size_t charram_size;
size_t spriteram_size;
/* video-related */
tilemap_t *background, *foreground;
int spriteram_words;
int tilemap_flip;
int flipscreen;
UINT8 irq_port_last;
UINT8 blank_tile[8*8];
/* misc */
int irq_on;
int irq1_on;
int irq2_on;
int irq4_on;
UINT16 selected_ip; /* Copied from WEC Le Mans 24 driver, explicity needed for Hyper Crash */
int gx400_irq1_cnt;
UINT8 frame_counter;
/* devices */
running_device *maincpu;
running_device *audiocpu;
running_device *vlm;
};
extern int nemesis_irq_on;
extern int nemesis_irq2_on;
extern UINT16 hcrash_selected_ip;
/*----------- defined in video/nemesis.c -----------*/
extern UINT16 *nemesis_videoram1;
extern UINT16 *nemesis_videoram2;
extern UINT16 *nemesis_colorram1;
extern UINT16 *nemesis_colorram2;
extern UINT16 *nemesis_characterram;
extern size_t nemesis_characterram_size;
extern UINT16 *nemesis_xscroll1, *nemesis_xscroll2;
extern UINT16 *nemesis_yscroll1, *nemesis_yscroll2;
WRITE16_HANDLER( nemesis_videoram1_word_w );
WRITE16_HANDLER( nemesis_videoram2_word_w );
WRITE16_HANDLER( nemesis_colorram1_word_w );
WRITE16_HANDLER( nemesis_colorram2_word_w );
WRITE16_HANDLER( nemesis_characterram_word_w );
VIDEO_START( nemesis );
VIDEO_UPDATE( nemesis );
WRITE16_HANDLER( nemesis_gfx_flipx_word_w );
WRITE16_HANDLER( nemesis_gfx_flipy_word_w );
WRITE16_HANDLER( salamand_control_port_word_w );
WRITE16_HANDLER( salamander_palette_word_w );
WRITE16_HANDLER( nemesis_palette_word_w );
WRITE16_HANDLER( nemesis_videoram1_word_w );
WRITE16_HANDLER( nemesis_videoram2_word_w );
WRITE16_HANDLER( nemesis_colorram1_word_w );
WRITE16_HANDLER( nemesis_colorram2_word_w );
WRITE16_HANDLER( nemesis_charram_word_w );
VIDEO_START( nemesis );
VIDEO_UPDATE( nemesis );

View File

@ -1,20 +1,37 @@
/*----------- defined in drivers/oneshot.c -----------*/
extern UINT16 *oneshot_sprites;
extern UINT16 *oneshot_bg_videoram;
extern UINT16 *oneshot_mid_videoram;
extern UINT16 *oneshot_fg_videoram;
extern UINT16 *oneshot_scroll;
class oneshot_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, oneshot_state(machine)); }
extern int gun_x_p1,gun_y_p1,gun_x_p2,gun_y_p2;
extern int gun_x_shift;
oneshot_state(running_machine &machine) { }
/* memory pointers */
UINT16 * sprites;
UINT16 * bg_videoram;
UINT16 * mid_videoram;
UINT16 * fg_videoram;
UINT16 * scroll;
/* video-related */
tilemap_t *bg_tilemap, *mid_tilemap, *fg_tilemap;
/* misc */
int gun_x_p1, gun_y_p1, gun_x_p2, gun_y_p2;
int gun_x_shift;
int p1_wobble, p2_wobble;
/* devices */
running_device *maincpu;
running_device *audiocpu;
};
/*----------- defined in video/oneshot.c -----------*/
WRITE16_HANDLER( oneshot_bg_videoram_w );
WRITE16_HANDLER( oneshot_mid_videoram_w );
WRITE16_HANDLER( oneshot_fg_videoram_w );
VIDEO_START( oneshot );
VIDEO_UPDATE( oneshot );
VIDEO_UPDATE( maddonna );

View File

@ -7,13 +7,36 @@
#include "sound/discrete.h"
/* Discrete Sound Input Nodes */
#define ORBIT_NOTE_FREQ NODE_01
#define ORBIT_ANOTE1_AMP NODE_02
#define ORBIT_ANOTE2_AMP NODE_03
#define ORBIT_NOISE1_AMP NODE_04
#define ORBIT_NOISE2_AMP NODE_05
#define ORBIT_WARNING_EN NODE_06
#define ORBIT_NOISE_EN NODE_07
#define ORBIT_NOTE_FREQ NODE_01
#define ORBIT_ANOTE1_AMP NODE_02
#define ORBIT_ANOTE2_AMP NODE_03
#define ORBIT_NOISE1_AMP NODE_04
#define ORBIT_NOISE2_AMP NODE_05
#define ORBIT_WARNING_EN NODE_06
#define ORBIT_NOISE_EN NODE_07
class orbit_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, orbit_state(machine)); }
orbit_state(running_machine &machine) { }
/* memory pointers */
UINT8 * playfield_ram;
UINT8 * sprite_ram;
/* video-related */
tilemap_t *bg_tilemap;
int flip_screen;
/* misc */
UINT8 misc_flags;
/* devices */
running_device *maincpu;
running_device *discrete;
};
/*----------- defined in audio/orbit.c -----------*/
@ -30,7 +53,4 @@ DISCRETE_SOUND_EXTERN( orbit );
VIDEO_START( orbit );
VIDEO_UPDATE( orbit );
extern UINT8* orbit_playfield_ram;
extern UINT8* orbit_sprite_ram;
extern WRITE8_HANDLER( orbit_playfield_w );

View File

@ -0,0 +1,41 @@
/*************************************************************************
Othello Derby
*************************************************************************/
#define OTHLDRBY_VREG_SIZE 18
class othldrby_state
{
public:
static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, othldrby_state(machine)); }
othldrby_state(running_machine &machine) { }
/* memory pointers */
UINT16 * vram;
UINT16 * buf_spriteram;
UINT16 * buf_spriteram2;
/* video-related */
tilemap_t *bg_tilemap[3];
UINT16 vreg[OTHLDRBY_VREG_SIZE];
UINT32 vram_addr, vreg_addr;
/* misc */
int toggle;
};
/*----------- defined in video/othldrby.c -----------*/
WRITE16_HANDLER( othldrby_videoram_addr_w );
READ16_HANDLER( othldrby_videoram_r );
WRITE16_HANDLER( othldrby_videoram_w );
WRITE16_HANDLER( othldrby_vreg_addr_w );
WRITE16_HANDLER( othldrby_vreg_w );
VIDEO_START( othldrby );
VIDEO_EOF( othldrby );
VIDEO_UPDATE( othldrby );

View File

@ -8,22 +8,6 @@
#include "includes/nemesis.h"
UINT16 *nemesis_videoram1;
UINT16 *nemesis_videoram2;
UINT16 *nemesis_colorram1;
UINT16 *nemesis_colorram2;
UINT16 *nemesis_characterram;
size_t nemesis_characterram_size;
UINT16 *nemesis_xscroll1, *nemesis_xscroll2;
UINT16 *nemesis_yscroll1, *nemesis_yscroll2;
static int spriteram_words;
static int tilemap_flip;
static int flipscreen;
static UINT8 irq_port_last;
static tilemap_t *background, *foreground;
static const struct
{
UINT8 width;
@ -36,26 +20,33 @@ sprite_data[8] =
{ 8, 8, 0 }, { 16, 8, 6 }, { 8, 16, 3 }, { 16, 16, 1 }
};
static UINT8 blank_tile[8*8];
static TILE_GET_INFO( get_bg_tile_info )
{
int code,color,flags,mask,layer;
nemesis_state *state = (nemesis_state *)machine->driver_data;
int code, color, flags, mask, layer;
code = nemesis_videoram2[tile_index];
color = nemesis_colorram2[tile_index];
code = state->videoram2[tile_index];
color = state->colorram2[tile_index];
flags = 0;
if (color & 0x80) flags |= TILE_FLIPX;
if (code & 0x0800) flags |= TILE_FLIPY;
if (color & 0x80)
flags |= TILE_FLIPX;
if (code & 0x0800)
flags |= TILE_FLIPY;
if ((~code & 0x2000) || ((code & 0xc000) == 0x4000))
flags |= TILE_FORCE_LAYER0; /* no transparency */
if (code & 0xf800) {
if (code & 0xf800)
{
SET_TILE_INFO( 0, code & 0x7ff, color & 0x7f, flags );
} else {
}
else
{
SET_TILE_INFO( 0, 0, 0x00, 0 );
tileinfo->pen_data = blank_tile;
tileinfo->pen_data = state->blank_tile;
}
mask = (code & 0x1000) >> 12;
@ -68,21 +59,30 @@ static TILE_GET_INFO( get_bg_tile_info )
static TILE_GET_INFO( get_fg_tile_info )
{
int code,color,flags,mask,layer;
nemesis_state *state = (nemesis_state *)machine->driver_data;
int code, color, flags, mask, layer;
code = nemesis_videoram1[tile_index];
color = nemesis_colorram1[tile_index];
code = state->videoram1[tile_index];
color = state->colorram1[tile_index];
flags = 0;
if (color & 0x80) flags |= TILE_FLIPX;
if (code & 0x0800) flags |= TILE_FLIPY;
if (color & 0x80)
flags |= TILE_FLIPX;
if (code & 0x0800)
flags |= TILE_FLIPY;
if ((~code & 0x2000) || ((code & 0xc000) == 0x4000))
flags |= TILE_FORCE_LAYER0; /* no transparency */
if (code & 0xf800) {
if (code & 0xf800)
{
SET_TILE_INFO( 0, code & 0x7ff, color & 0x7f, flags );
} else {
}
else
{
SET_TILE_INFO( 0, 0, 0x00, 0 );
tileinfo->pen_data = blank_tile;
tileinfo->pen_data = state->blank_tile;
}
mask = (code & 0x1000) >> 12;
@ -96,63 +96,69 @@ static TILE_GET_INFO( get_fg_tile_info )
WRITE16_HANDLER( nemesis_gfx_flipx_word_w )
{
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
if (ACCESSING_BITS_0_7)
{
flipscreen = data & 0x01;
state->flipscreen = data & 0x01;
if (data & 0x01)
tilemap_flip |= TILEMAP_FLIPX;
state->tilemap_flip |= TILEMAP_FLIPX;
else
tilemap_flip &= ~TILEMAP_FLIPX;
state->tilemap_flip &= ~TILEMAP_FLIPX;
tilemap_set_flip_all(space->machine, tilemap_flip);
tilemap_set_flip_all(space->machine, state->tilemap_flip);
}
if (ACCESSING_BITS_8_15)
{
if (data & 0x0100)
cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff);
}
}
WRITE16_HANDLER( nemesis_gfx_flipy_word_w )
{
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
if (ACCESSING_BITS_0_7)
{
if (data & 0x01)
tilemap_flip |= TILEMAP_FLIPY;
state->tilemap_flip |= TILEMAP_FLIPY;
else
tilemap_flip &= ~TILEMAP_FLIPY;
state->tilemap_flip &= ~TILEMAP_FLIPY;
tilemap_set_flip_all(space->machine, tilemap_flip);
tilemap_set_flip_all(space->machine, state->tilemap_flip);
}
}
WRITE16_HANDLER( salamand_control_port_word_w )
{
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
if (ACCESSING_BITS_0_7)
{
UINT8 accessing_bits = data ^ irq_port_last;
UINT8 accessing_bits = data ^ state->irq_port_last;
nemesis_irq_on = data & 0x01;
nemesis_irq2_on = data & 0x02;
flipscreen = data & 0x04;
state->irq_on = data & 0x01;
state->irq2_on = data & 0x02;
state->flipscreen = data & 0x04;
if (data & 0x04)
tilemap_flip |= TILEMAP_FLIPX;
state->tilemap_flip |= TILEMAP_FLIPX;
else
tilemap_flip &= ~TILEMAP_FLIPX;
state->tilemap_flip &= ~TILEMAP_FLIPX;
if (data & 0x08)
tilemap_flip |= TILEMAP_FLIPY;
state->tilemap_flip |= TILEMAP_FLIPY;
else
tilemap_flip &= ~TILEMAP_FLIPY;
state->tilemap_flip &= ~TILEMAP_FLIPY;
if (accessing_bits & 0x0c)
tilemap_set_flip_all(space->machine, tilemap_flip);
tilemap_set_flip_all(space->machine, state->tilemap_flip);
irq_port_last = data;
state->irq_port_last = data;
}
if (ACCESSING_BITS_8_15)
@ -161,19 +167,20 @@ WRITE16_HANDLER( salamand_control_port_word_w )
coin_lockout_w(space->machine, 1, data & 0x0400);
if (data & 0x0800)
cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
hcrash_selected_ip = (~data & 0x1000) >> 12; /* citybomb steering & accel */
state->selected_ip = (~data & 0x1000) >> 12; /* citybomb steering & accel */
}
}
WRITE16_HANDLER( nemesis_palette_word_w )
{
int r,g,b,bit1,bit2,bit3,bit4,bit5;
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
int r, g, b, bit1, bit2, bit3, bit4, bit5;
COMBINE_DATA(space->machine->generic.paletteram.u16 + offset);
data = space->machine->generic.paletteram.u16[offset];
COMBINE_DATA(state->paletteram + offset);
data = state->paletteram[offset];
/* Mish, 30/11/99 - Schematics show the resistor values are:
300 Ohms
@ -187,77 +194,89 @@ WRITE16_HANDLER( nemesis_palette_word_w )
#define MULTIPLIER 8 * bit1 + 17 * bit2 + 33 * bit3 + 67 * bit4 + 130 * bit5
bit1=(data >> 0)&1;
bit2=(data >> 1)&1;
bit3=(data >> 2)&1;
bit4=(data >> 3)&1;
bit5=(data >> 4)&1;
bit1 = BIT(data, 0);
bit2 = BIT(data, 1);
bit3 = BIT(data, 2);
bit4 = BIT(data, 3);
bit5 = BIT(data, 4);
r = MULTIPLIER;
r = pow (r/255.0, 2)*255;
bit1=(data >> 5)&1;
bit2=(data >> 6)&1;
bit3=(data >> 7)&1;
bit4=(data >> 8)&1;
bit5=(data >> 9)&1;
r = pow(r/255.0, 2)*255;
bit1 = BIT(data, 5);
bit2 = BIT(data, 6);
bit3 = BIT(data, 7);
bit4 = BIT(data, 8);
bit5 = BIT(data, 9);
g = MULTIPLIER;
g = pow (g/255.0, 2)*255;
bit1=(data >> 10)&1;
bit2=(data >> 11)&1;
bit3=(data >> 12)&1;
bit4=(data >> 13)&1;
bit5=(data >> 14)&1;
g = pow(g/255.0, 2)*255;
bit1 = BIT(data, 10);
bit2 = BIT(data, 11);
bit3 = BIT(data, 12);
bit4 = BIT(data, 13);
bit5 = BIT(data, 14);
b = MULTIPLIER;
b = pow (b/255.0, 2)*255;
b = pow(b/255.0, 2)*255;
palette_set_color(space->machine,offset,MAKE_RGB(r,g,b));
palette_set_color(space->machine, offset, MAKE_RGB(r, g, b));
}
WRITE16_HANDLER( salamander_palette_word_w )
{
COMBINE_DATA(space->machine->generic.paletteram.u16 + offset);
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
COMBINE_DATA(state->paletteram + offset);
offset &= ~1;
data = ((space->machine->generic.paletteram.u16[offset] << 8) & 0xff00) | (space->machine->generic.paletteram.u16[offset+1] & 0xff);
palette_set_color_rgb(space->machine,offset / 2,pal5bit(data >> 0),pal5bit(data >> 5),pal5bit(data >> 10));
data = ((state->paletteram[offset] << 8) & 0xff00) | (state->paletteram[offset + 1] & 0xff);
palette_set_color_rgb(space->machine, offset / 2, pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
}
WRITE16_HANDLER( nemesis_videoram1_word_w )
{
COMBINE_DATA(nemesis_videoram1 + offset);
tilemap_mark_tile_dirty( foreground, offset );
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
COMBINE_DATA(state->videoram1 + offset);
tilemap_mark_tile_dirty(state->foreground, offset);
}
WRITE16_HANDLER( nemesis_videoram2_word_w )
{
COMBINE_DATA(nemesis_videoram2 + offset);
tilemap_mark_tile_dirty( background, offset );
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
COMBINE_DATA(state->videoram2 + offset);
tilemap_mark_tile_dirty(state->background, offset);
}
WRITE16_HANDLER( nemesis_colorram1_word_w )
{
COMBINE_DATA(nemesis_colorram1 + offset);
tilemap_mark_tile_dirty( foreground, offset );
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
COMBINE_DATA(state->colorram1 + offset);
tilemap_mark_tile_dirty(state->foreground, offset);
}
WRITE16_HANDLER( nemesis_colorram2_word_w )
{
COMBINE_DATA(nemesis_colorram2 + offset);
tilemap_mark_tile_dirty( background, offset );
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
COMBINE_DATA(state->colorram2 + offset);
tilemap_mark_tile_dirty(state->background, offset);
}
/* we have to straighten out the 16-bit word into bytes for gfxdecode() to work */
WRITE16_HANDLER( nemesis_characterram_word_w )
WRITE16_HANDLER( nemesis_charram_word_w )
{
UINT16 oldword = nemesis_characterram[offset];
COMBINE_DATA(nemesis_characterram + offset);
data = nemesis_characterram[offset];
nemesis_state *state = (nemesis_state *)space->machine->driver_data;
UINT16 oldword = state->charram[offset];
COMBINE_DATA(state->charram + offset);
data = state->charram[offset];
if (oldword != data)
{
int i;
for (i=0; i<8; i++)
for (i = 0; i < 8; i++)
{
int w = sprite_data[i].width;
int h = sprite_data[i].height;
@ -269,63 +288,56 @@ WRITE16_HANDLER( nemesis_characterram_word_w )
static STATE_POSTLOAD( nemesis_postload )
{
int i,offs;
nemesis_state *state = (nemesis_state *)machine->driver_data;
int i, offs;
for (offs=0; offs<nemesis_characterram_size; offs++)
for (offs = 0; offs < state->charram_size; offs++)
{
for (i=0; i<8; i++)
for (i = 0; i < 8; i++)
{
int w = sprite_data[i].width;
int h = sprite_data[i].height;
gfx_element_mark_dirty(machine->gfx[sprite_data[i].char_type], offs * 4 / (w * h));
}
}
tilemap_mark_all_tiles_dirty(background);
tilemap_mark_all_tiles_dirty(foreground);
tilemap_mark_all_tiles_dirty(state->background);
tilemap_mark_all_tiles_dirty(state->foreground);
}
/* claim a palette dirty array */
VIDEO_START( nemesis )
{
spriteram_words = machine->generic.spriteram_size / 2;
nemesis_state *state = (nemesis_state *)machine->driver_data;
background = tilemap_create(machine,
get_bg_tile_info, tilemap_scan_rows, 8,8, 64,32 );
state->spriteram_words = state->spriteram_size / 2;
foreground = tilemap_create(machine,
get_fg_tile_info, tilemap_scan_rows, 8,8, 64,32 );
state->background = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
state->foreground = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
tilemap_set_transparent_pen( background, 0 );
tilemap_set_transparent_pen( foreground, 0 );
tilemap_set_scroll_rows( background, 256 );
tilemap_set_scroll_rows( foreground, 256 );
tilemap_set_transparent_pen(state->background, 0);
tilemap_set_transparent_pen(state->foreground, 0);
tilemap_set_scroll_rows(state->background, 256);
tilemap_set_scroll_rows(state->foreground, 256);
memset(nemesis_characterram, 0, nemesis_characterram_size);
memset(state->charram, 0, state->charram_size);
memset(state->blank_tile, 0, ARRAY_LENGTH(state->blank_tile));
gfx_element_set_source(machine->gfx[0], (UINT8 *)nemesis_characterram);
gfx_element_set_source(machine->gfx[1], (UINT8 *)nemesis_characterram);
gfx_element_set_source(machine->gfx[2], (UINT8 *)nemesis_characterram);
gfx_element_set_source(machine->gfx[3], (UINT8 *)nemesis_characterram);
gfx_element_set_source(machine->gfx[4], (UINT8 *)nemesis_characterram);
gfx_element_set_source(machine->gfx[5], (UINT8 *)nemesis_characterram);
gfx_element_set_source(machine->gfx[6], (UINT8 *)nemesis_characterram);
gfx_element_set_source(machine->gfx[7], (UINT8 *)nemesis_characterram);
flipscreen = 0;
tilemap_flip = 0;
irq_port_last = 0;
gfx_element_set_source(machine->gfx[0], (UINT8 *)state->charram);
gfx_element_set_source(machine->gfx[1], (UINT8 *)state->charram);
gfx_element_set_source(machine->gfx[2], (UINT8 *)state->charram);
gfx_element_set_source(machine->gfx[3], (UINT8 *)state->charram);
gfx_element_set_source(machine->gfx[4], (UINT8 *)state->charram);
gfx_element_set_source(machine->gfx[5], (UINT8 *)state->charram);
gfx_element_set_source(machine->gfx[6], (UINT8 *)state->charram);
gfx_element_set_source(machine->gfx[7], (UINT8 *)state->charram);
/* Set up save state */
state_save_register_global(machine, spriteram_words);
state_save_register_global(machine, tilemap_flip);
state_save_register_global(machine, flipscreen);
state_save_register_global(machine, irq_port_last);
state_save_register_postload(machine, nemesis_postload, NULL);
}
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 )
{
/*
* 16 bytes per sprite, in memory from 56000-56fff
@ -342,7 +354,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
* byte E : not used.
*/
UINT16 *spriteram16 = machine->generic.spriteram.u16;
nemesis_state *state = (nemesis_state *)machine->driver_data;
UINT16 *spriteram = state->spriteram;
int adress; /* start of sprite in spriteram */
int sx; /* sprite X-pos */
int sy; /* sprite Y-pos */
@ -356,30 +369,32 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int w,h;
int idx;
for (priority=256-1; priority>=0; priority--)
for (priority = 256 - 1; priority >= 0; priority--)
{
for (adress = spriteram_words-8; adress >= 0; adress -= 8)
for (adress = state->spriteram_words - 8; adress >= 0; adress -= 8)
{
if((spriteram16[adress] & 0xff)!=priority) continue;
if((spriteram[adress] & 0xff) != priority)
continue;
zoom = spriteram16[adress+2] & 0xff;
if (!(spriteram16[adress+2] & 0xff00) && ((spriteram16[adress+3] & 0xff00) != 0xff00))
code = spriteram16[adress+3] + ((spriteram16[adress+4] & 0xc0) << 2);
zoom = spriteram[adress + 2] & 0xff;
if (!(spriteram[adress + 2] & 0xff00) && ((spriteram[adress + 3] & 0xff00) != 0xff00))
code = spriteram[adress + 3] + ((spriteram[adress + 4] & 0xc0) << 2);
else
code = (spriteram16[adress+3] & 0xff) + ((spriteram16[adress+4] & 0xc0) << 2);
code = (spriteram[adress + 3] & 0xff) + ((spriteram[adress + 4] & 0xc0) << 2);
if (zoom != 0xFF || code!=0)
if (zoom != 0xff || code != 0)
{
size = spriteram16[adress+1];
size = spriteram[adress + 1];
zoom += (size & 0xc0) << 2;
sx = spriteram16[adress+5] & 0xff;
sy = spriteram16[adress+6] & 0xff;
if (spriteram16[adress+4] & 0x01)
sx = spriteram[adress + 5] & 0xff;
sy = spriteram[adress + 6] & 0xff;
if (spriteram[adress + 4] & 0x01)
sx-=0x100; /* fixes left side clip */
color = (spriteram16[adress+4] & 0x1e) >> 1;
flipx = spriteram16[adress+1] & 0x01;
flipy = spriteram16[adress+4] & 0x20;
color = (spriteram[adress + 4] & 0x1e) >> 1;
flipx = spriteram[adress + 1] & 0x01;
flipy = spriteram[adress + 4] & 0x20;
idx = (size >> 3) & 7;
w = sprite_data[idx].width;
@ -387,16 +402,17 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
code = code * 8 * 16 / (w * h);
char_type = sprite_data[idx].char_type;
if( zoom )
if (zoom)
{
zoom = ((1<<16) * 0x80 / zoom) + 0x02ab;
if (flipscreen)
zoom = ((1 << 16) * 0x80 / zoom) + 0x02ab;
if (state->flipscreen)
{
sx = 256 - ((zoom * w) >> 16) - sx;
sy = 256 - ((zoom * h) >> 16) - sy;
flipx = !flipx;
flipy = !flipy;
}
pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[char_type],
code,
color,
@ -405,38 +421,39 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
zoom,zoom,
machine->priority_bitmap,0xffcc,0 );
}
} /* if sprite */
} /* for loop */
} /* priority */
}
}
}
}
/******************************************************************************/
VIDEO_UPDATE( nemesis )
{
nemesis_state *state = (nemesis_state *)screen->machine->driver_data;
int offs;
rectangle clip;
bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
bitmap_fill(bitmap,cliprect,0);
bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
bitmap_fill(bitmap, cliprect, 0);
clip.min_x = 0;
clip.max_x = 255;
tilemap_set_scroll_cols( background, 64 );
tilemap_set_scroll_cols( foreground, 64 );
tilemap_set_scroll_rows( background, 1 );
tilemap_set_scroll_rows( foreground, 1 );
tilemap_set_scroll_cols(state->background, 64);
tilemap_set_scroll_cols(state->foreground, 64);
tilemap_set_scroll_rows(state->background, 1);
tilemap_set_scroll_rows(state->foreground, 1);
for (offs = 0; offs < 64; offs++)
{
int offset_x = offs;
if (flipscreen)
if (state->flipscreen)
offset_x = (offs + 0x20) & 0x3f;
tilemap_set_scrolly( background, offs, nemesis_yscroll2[offset_x] );
tilemap_set_scrolly( foreground, offs, nemesis_yscroll1[offset_x] );
tilemap_set_scrolly(state->background, offs, state->yscroll2[offset_x]);
tilemap_set_scrolly(state->foreground, offs, state->yscroll1[offset_x]);
}
for (offs = cliprect->min_y; offs <= cliprect->max_y; offs++)
@ -447,18 +464,18 @@ VIDEO_UPDATE( nemesis )
clip.min_y = offs;
clip.max_y = offs;
if (flipscreen)
if (state->flipscreen)
offset_y = 255 - offs;
tilemap_set_scrollx( background, 0, (nemesis_xscroll2[offset_y] & 0xff) + ((nemesis_xscroll2[0x100 + offset_y] & 0x01) << 8) - (flipscreen ? 0x107 : 0) );
tilemap_set_scrollx( foreground, 0, (nemesis_xscroll1[offset_y] & 0xff) + ((nemesis_xscroll1[0x100 + offset_y] & 0x01) << 8) - (flipscreen ? 0x107 : 0) );
tilemap_set_scrollx(state->background, 0, (state->xscroll2[offset_y] & 0xff) + ((state->xscroll2[0x100 + offset_y] & 0x01) << 8) - (state->flipscreen ? 0x107 : 0));
tilemap_set_scrollx(state->foreground, 0, (state->xscroll1[offset_y] & 0xff) + ((state->xscroll1[0x100 + offset_y] & 0x01) << 8) - (state->flipscreen ? 0x107 : 0));
for (i=0; i<4; i+=2)
for (i = 0; i < 4; i += 2)
{
tilemap_draw(bitmap, &clip, background, TILEMAP_DRAW_CATEGORY(i+0), 1);
tilemap_draw(bitmap, &clip, background, TILEMAP_DRAW_CATEGORY(i+1), 2);
tilemap_draw(bitmap, &clip, foreground, TILEMAP_DRAW_CATEGORY(i+0), 1);
tilemap_draw(bitmap, &clip, foreground, TILEMAP_DRAW_CATEGORY(i+1), 2);
tilemap_draw(bitmap, &clip, state->background, TILEMAP_DRAW_CATEGORY(i + 0), 1);
tilemap_draw(bitmap, &clip, state->background, TILEMAP_DRAW_CATEGORY(i + 1), 2);
tilemap_draw(bitmap, &clip, state->foreground, TILEMAP_DRAW_CATEGORY(i + 0), 1);
tilemap_draw(bitmap, &clip, state->foreground, TILEMAP_DRAW_CATEGORY(i + 1), 2);
}
}

View File

@ -3,114 +3,117 @@
#include "emu.h"
#include "includes/oneshot.h"
static tilemap_t *oneshot_bg_tilemap;
static tilemap_t *oneshot_mid_tilemap;
static tilemap_t *oneshot_fg_tilemap;
/* bg tilemap */
static TILE_GET_INFO( get_oneshot_bg_tile_info )
{
int tileno;
oneshot_state *state = (oneshot_state *)machine->driver_data;
int tileno = state->bg_videoram[tile_index * 2 + 1];
tileno = oneshot_bg_videoram[tile_index*2+1];
SET_TILE_INFO(0,tileno,0,0);
SET_TILE_INFO(0, tileno, 0, 0);
}
WRITE16_HANDLER( oneshot_bg_videoram_w )
{
COMBINE_DATA(&oneshot_bg_videoram[offset]);
tilemap_mark_tile_dirty(oneshot_bg_tilemap,offset/2);
oneshot_state *state = (oneshot_state *)space->machine->driver_data;
COMBINE_DATA(&state->bg_videoram[offset]);
tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
}
/* mid tilemap */
static TILE_GET_INFO( get_oneshot_mid_tile_info )
{
int tileno;
oneshot_state *state = (oneshot_state *)machine->driver_data;
int tileno = state->mid_videoram[tile_index * 2 + 1];
tileno = oneshot_mid_videoram[tile_index*2+1];
SET_TILE_INFO(0,tileno,2,0);
SET_TILE_INFO(0, tileno, 2, 0);
}
WRITE16_HANDLER( oneshot_mid_videoram_w )
{
COMBINE_DATA(&oneshot_mid_videoram[offset]);
tilemap_mark_tile_dirty(oneshot_mid_tilemap,offset/2);
oneshot_state *state = (oneshot_state *)space->machine->driver_data;
COMBINE_DATA(&state->mid_videoram[offset]);
tilemap_mark_tile_dirty(state->mid_tilemap, offset / 2);
}
/* fg tilemap */
static TILE_GET_INFO( get_oneshot_fg_tile_info )
{
int tileno;
oneshot_state *state = (oneshot_state *)machine->driver_data;
int tileno = state->fg_videoram[tile_index * 2 + 1];
tileno = oneshot_fg_videoram[tile_index*2+1];
SET_TILE_INFO(0,tileno,3,0);
SET_TILE_INFO(0, tileno, 3, 0);
}
WRITE16_HANDLER( oneshot_fg_videoram_w )
{
COMBINE_DATA(&oneshot_fg_videoram[offset]);
tilemap_mark_tile_dirty(oneshot_fg_tilemap,offset/2);
oneshot_state *state = (oneshot_state *)space->machine->driver_data;
COMBINE_DATA(&state->fg_videoram[offset]);
tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
}
VIDEO_START( oneshot )
{
oneshot_bg_tilemap = tilemap_create(machine, get_oneshot_bg_tile_info,tilemap_scan_rows, 16, 16,32,32);
oneshot_mid_tilemap = tilemap_create(machine, get_oneshot_mid_tile_info,tilemap_scan_rows, 16, 16,32,32);
oneshot_fg_tilemap = tilemap_create(machine, get_oneshot_fg_tile_info,tilemap_scan_rows, 16, 16,32,32);
oneshot_state *state = (oneshot_state *)machine->driver_data;
tilemap_set_transparent_pen(oneshot_bg_tilemap,0);
tilemap_set_transparent_pen(oneshot_mid_tilemap,0);
tilemap_set_transparent_pen(oneshot_fg_tilemap,0);
state->bg_tilemap = tilemap_create(machine, get_oneshot_bg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
state->mid_tilemap = tilemap_create(machine, get_oneshot_mid_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
state->fg_tilemap = tilemap_create(machine, get_oneshot_fg_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
tilemap_set_transparent_pen(state->bg_tilemap, 0);
tilemap_set_transparent_pen(state->mid_tilemap, 0);
tilemap_set_transparent_pen(state->fg_tilemap, 0);
}
static void draw_crosshairs( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
int xpos,ypos;
/* get gun raw coordonates (player 1) */
gun_x_p1 = (input_port_read(machine, "LIGHT0_X") & 0xff) * 320 / 256;
gun_y_p1 = (input_port_read(machine, "LIGHT0_Y") & 0xff) * 240 / 256;
/* compute the coordonates for drawing (from routine at 0x009ab0) */
xpos = gun_x_p1;
ypos = gun_y_p1;
gun_x_p1+=gun_x_shift;
gun_y_p1 -= 0x0a;
if (gun_y_p1 < 0)
gun_y_p1=0;
/* get gun raw coordonates (player 2) */
gun_x_p2 = (input_port_read(machine, "LIGHT1_X") & 0xff) * 320 / 256;
gun_y_p2 = (input_port_read(machine, "LIGHT1_Y") & 0xff) * 240 / 256;
/* compute the coordonates for drawing (from routine at 0x009b6e) */
xpos = gun_x_p2;
ypos = gun_y_p2;
gun_x_p2 += gun_x_shift-0x0a;
if (gun_x_p2 < 0)
gun_x_p2=0;
}
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{
const UINT16 *source = oneshot_sprites;
const UINT16 *finish = source+(0x1000/2);
const gfx_element *gfx = machine->gfx[1];
oneshot_state *state = (oneshot_state *)machine->driver_data;
int xpos,ypos;
while( source<finish )
/* get gun raw coordinates (player 1) */
state->gun_x_p1 = (input_port_read(machine, "LIGHT0_X") & 0xff) * 320 / 256;
state->gun_y_p1 = (input_port_read(machine, "LIGHT0_Y") & 0xff) * 240 / 256;
/* compute the coordinates for drawing (from routine at 0x009ab0) */
xpos = state->gun_x_p1;
ypos = state->gun_y_p1;
state->gun_x_p1 += state->gun_x_shift;
state->gun_y_p1 -= 0x0a;
if (state->gun_y_p1 < 0)
state->gun_y_p1 = 0;
/* get gun raw coordinates (player 2) */
state->gun_x_p2 = (input_port_read(machine, "LIGHT1_X") & 0xff) * 320 / 256;
state->gun_y_p2 = (input_port_read(machine, "LIGHT1_Y") & 0xff) * 240 / 256;
/* compute the coordinates for drawing (from routine at 0x009b6e) */
xpos = state->gun_x_p2;
ypos = state->gun_y_p2;
state->gun_x_p2 += state->gun_x_shift - 0x0a;
if (state->gun_x_p2 < 0)
state->gun_x_p2 = 0;
}
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
oneshot_state *state = (oneshot_state *)machine->driver_data;
const UINT16 *source = state->sprites;
const UINT16 *finish = source + (0x1000 / 2);
const gfx_element *gfx = machine->gfx[1];
int xpos, ypos;
while (source < finish)
{
int blockx,blocky;
int blockx, blocky;
int num = source[1] & 0xffff;
int xsize = (source[2] & 0x000f)+1;
int ysize = (source[3] & 0x000f)+1;
int xsize = (source[2] & 0x000f) + 1;
int ysize = (source[3] & 0x000f) + 1;
ypos = source[3] & 0xff80;
xpos = source[2] & 0xff80;
@ -119,35 +122,33 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
xpos = xpos >> 7;
if (source[0] == 0x0001) break;
if (source[0] == 0x0001)
break;
xpos -= 8;
ypos -= 6;
for (blockx = 0; blockx<xsize;blockx++) {
for (blocky = 0; blocky<ysize;blocky++) {
for (blockx = 0; blockx < xsize; blockx++)
{
for (blocky = 0; blocky < ysize; blocky++)
{
drawgfx_transpen(
bitmap,
cliprect,
gfx,
num + (blocky * xsize) + blockx,
1,
0,0,
xpos + blockx * 8, ypos + blocky * 8, 0);
drawgfx_transpen(
bitmap,
cliprect,
gfx,
num+(blocky*xsize)+blockx,
num + (blocky * xsize) + blockx,
1,
0,0,
xpos+blockx*8,ypos+blocky*8,0
);
drawgfx_transpen(
bitmap,
cliprect,
gfx,
num+(blocky*xsize)+blockx,
1,
0,0,
xpos+blockx*8-0x200,ypos+blocky*8,0
);
xpos + blockx * 8 - 0x200, ypos + blocky * 8, 0);
}
}
source += 0x4;
@ -157,31 +158,34 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( oneshot )
{
oneshot_state *state = (oneshot_state *)screen->machine->driver_data;
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
tilemap_set_scrollx(oneshot_mid_tilemap,0, oneshot_scroll[0]-0x1f5);
tilemap_set_scrolly(oneshot_mid_tilemap,0, oneshot_scroll[1]);
tilemap_set_scrollx(state->mid_tilemap, 0, state->scroll[0] - 0x1f5);
tilemap_set_scrolly(state->mid_tilemap, 0, state->scroll[1]);
tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0);
tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0);
draw_sprites(screen->machine,bitmap,cliprect);
tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0);
draw_crosshairs(screen->machine,bitmap,cliprect);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->mid_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
draw_crosshairs(screen->machine, bitmap, cliprect);
return 0;
}
VIDEO_UPDATE( maddonna )
{
oneshot_state *state = (oneshot_state *)screen->machine->driver_data;
bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
tilemap_set_scrolly(oneshot_mid_tilemap,0, oneshot_scroll[1]); // other registers aren't used so we don't know which layers they relate to
tilemap_set_scrolly(state->mid_tilemap, 0, state->scroll[1]); // other registers aren't used so we don't know which layers they relate to
tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0);
tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0);
tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0);
draw_sprites(screen->machine,bitmap,cliprect);
// draw_crosshairs(screen->machine,bitmap,cliprect); // not a gun game
tilemap_draw(bitmap, cliprect, state->mid_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
// popmessage ("%04x %04x %04x %04x %04x %04x %04x %04x", oneshot_scroll[0],oneshot_scroll[1],oneshot_scroll[2],oneshot_scroll[3],oneshot_scroll[4],oneshot_scroll[5],oneshot_scroll[6],oneshot_scroll[7]);
// popmessage ("%04x %04x %04x %04x %04x %04x %04x %04x", state->scroll[0], state->scroll[1], state->scroll[2], state->scroll[3], state->scroll[4], state->scroll[5], state->scroll[6], state->scroll[7]);
return 0;
}

View File

@ -7,30 +7,23 @@ Atari Orbit video emulation
#include "emu.h"
#include "includes/orbit.h"
UINT8* orbit_playfield_ram;
UINT8* orbit_sprite_ram;
static tilemap_t* bg_tilemap;
static int orbit_flip_screen;
WRITE8_HANDLER( orbit_playfield_w )
{
orbit_playfield_ram[offset] = data;
tilemap_mark_tile_dirty(bg_tilemap, offset);
orbit_state *state = (orbit_state *)space->machine->driver_data;
state->playfield_ram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
}
static TILE_GET_INFO( get_tile_info )
{
UINT8 code = orbit_playfield_ram[tile_index];
orbit_state *state = (orbit_state *)machine->driver_data;
UINT8 code = state->playfield_ram[tile_index];
int flags = 0;
if (code & 0x40)
if (BIT(code, 6))
flags |= TILE_FLIPX;
if (orbit_flip_screen)
if (state->flip_screen)
flags |= TILE_FLIPY;
SET_TILE_INFO(3, code & 0x3f, 0, flags);
@ -39,13 +32,15 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( orbit )
{
bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 16, 32, 30);
orbit_state *state = (orbit_state *)machine->driver_data;
state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 16, 32, 30);
}
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 )
{
const UINT8* p = orbit_sprite_ram;
orbit_state *state = (orbit_state *)machine->driver_data;
const UINT8* p = state->sprite_ram;
int i;
@ -60,8 +55,8 @@ static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const recta
((flag & 0xc0) == 0x80) ? 1 :
((flag & 0xc0) == 0xc0) ? 2 : 0;
int flip_x = code & 0x40;
int flip_y = code & 0x80;
int flip_x = BIT(code, 6);
int flip_y = BIT(code, 7);
int zoom_x = 0x10000;
int zoom_y = 0x10000;
@ -86,9 +81,11 @@ static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const recta
VIDEO_UPDATE( orbit )
{
orbit_flip_screen = input_port_read(screen->machine, "DSW2") & 8;
orbit_state *state = (orbit_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
state->flip_screen = input_port_read(screen->machine, "DSW2") & 8;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect);
return 0;

View File

@ -1,17 +1,10 @@
#include "emu.h"
#include "includes/othldrby.h"
#define VIDEORAM_SIZE 0x1c00
#define SPRITERAM_START 0x1800
#define SPRITERAM_SIZE (VIDEORAM_SIZE-SPRITERAM_START)
static UINT16 *vram,*buf_spriteram,*buf_spriteram2;
#define VREG_SIZE 18
static UINT16 vreg[VREG_SIZE];
static tilemap_t *bg_tilemap[3];
#define VIDEORAM_SIZE 0x1c00
#define SPRITERAM_START 0x1800
#define SPRITERAM_SIZE (VIDEORAM_SIZE - SPRITERAM_START)
/***************************************************************************
@ -20,15 +13,16 @@ static tilemap_t *bg_tilemap[3];
***************************************************************************/
INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int plane)
INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int plane )
{
othldrby_state *state = (othldrby_state *)machine->driver_data;
UINT16 attr;
tile_index = 2*tile_index + 0x800*plane;
attr = vram[tile_index];
tile_index = 2 * tile_index + 0x800 * plane;
attr = state->vram[tile_index];
SET_TILE_INFO(
1,
vram[tile_index+1],
state->vram[tile_index + 1],
attr & 0x7f,
0);
tileinfo->category = (attr & 0x0600) >> 9;
@ -36,17 +30,17 @@ INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_
static TILE_GET_INFO( get_tile_info0 )
{
get_tile_info(machine,tileinfo,tile_index,0);
get_tile_info(machine, tileinfo, tile_index, 0);
}
static TILE_GET_INFO( get_tile_info1 )
{
get_tile_info(machine,tileinfo,tile_index,1);
get_tile_info(machine, tileinfo, tile_index, 1);
}
static TILE_GET_INFO( get_tile_info2 )
{
get_tile_info(machine,tileinfo,tile_index,2);
get_tile_info(machine, tileinfo, tile_index, 2);
}
@ -59,18 +53,22 @@ static TILE_GET_INFO( get_tile_info2 )
VIDEO_START( othldrby )
{
bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,16,16,32,32);
bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,32,32);
bg_tilemap[2] = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,32,32);
othldrby_state *state = (othldrby_state *)machine->driver_data;
vram = auto_alloc_array(machine, UINT16, VIDEORAM_SIZE);
buf_spriteram = auto_alloc_array(machine, UINT16, 2*SPRITERAM_SIZE);
state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 16, 16, 32, 32);
state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 16, 16, 32, 32);
state->bg_tilemap[2] = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 16, 16, 32, 32);
buf_spriteram2 = buf_spriteram + SPRITERAM_SIZE;
state->vram = auto_alloc_array(machine, UINT16, VIDEORAM_SIZE);
state->buf_spriteram = auto_alloc_array(machine, UINT16, 2 * SPRITERAM_SIZE);
state->buf_spriteram2 = state->buf_spriteram + SPRITERAM_SIZE;
tilemap_set_transparent_pen(bg_tilemap[0],0);
tilemap_set_transparent_pen(bg_tilemap[1],0);
tilemap_set_transparent_pen(bg_tilemap[2],0);
tilemap_set_transparent_pen(state->bg_tilemap[0], 0);
tilemap_set_transparent_pen(state->bg_tilemap[1], 0);
tilemap_set_transparent_pen(state->bg_tilemap[2], 0);
state_save_register_global_pointer(machine, state->vram, VIDEORAM_SIZE);
state_save_register_global_pointer(machine, state->buf_spriteram, 2 * SPRITERAM_SIZE);
}
@ -81,47 +79,53 @@ VIDEO_START( othldrby )
***************************************************************************/
static UINT32 vram_addr,vreg_addr;
WRITE16_HANDLER( othldrby_videoram_addr_w )
{
vram_addr = data;
othldrby_state *state = (othldrby_state *)space->machine->driver_data;
state->vram_addr = data;
}
READ16_HANDLER( othldrby_videoram_r )
{
if (vram_addr < VIDEORAM_SIZE)
return vram[vram_addr++];
othldrby_state *state = (othldrby_state *)space->machine->driver_data;
if (state->vram_addr < VIDEORAM_SIZE)
return state->vram[state->vram_addr++];
else
{
popmessage("GFXRAM OUT OF BOUNDS %04x",vram_addr);
popmessage("GFXRAM OUT OF BOUNDS %04x", state->vram_addr);
return 0;
}
}
WRITE16_HANDLER( othldrby_videoram_w )
{
if (vram_addr < VIDEORAM_SIZE)
othldrby_state *state = (othldrby_state *)space->machine->driver_data;
if (state->vram_addr < VIDEORAM_SIZE)
{
if (vram_addr < SPRITERAM_START)
tilemap_mark_tile_dirty(bg_tilemap[vram_addr/0x800],(vram_addr&0x7ff)/2);
vram[vram_addr++] = data;
if (state->vram_addr < SPRITERAM_START)
tilemap_mark_tile_dirty(state->bg_tilemap[state->vram_addr / 0x800], (state->vram_addr & 0x7ff) / 2);
state->vram[state->vram_addr++] = data;
}
else
popmessage("GFXRAM OUT OF BOUNDS %04x",vram_addr);
popmessage("GFXRAM OUT OF BOUNDS %04x", state->vram_addr);
}
WRITE16_HANDLER( othldrby_vreg_addr_w )
{
vreg_addr = data & 0x7f; /* bit 7 is set when screen is flipped */
othldrby_state *state = (othldrby_state *)space->machine->driver_data;
state->vreg_addr = data & 0x7f; /* bit 7 is set when screen is flipped */
}
WRITE16_HANDLER( othldrby_vreg_w )
{
if (vreg_addr < VREG_SIZE)
vreg[vreg_addr++] = data;
othldrby_state *state = (othldrby_state *)space->machine->driver_data;
if (state->vreg_addr < OTHLDRBY_VREG_SIZE)
state->vreg[state->vreg_addr++] = data;
else
popmessage("%06x: VREG OUT OF BOUNDS %04x",cpu_get_pc(space->cpu),vreg_addr);
popmessage("%06x: VREG OUT OF BOUNDS %04x", cpu_get_pc(space->cpu), state->vreg_addr);
}
@ -132,26 +136,27 @@ WRITE16_HANDLER( othldrby_vreg_w )
***************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int priority)
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority )
{
othldrby_state *state = (othldrby_state *)machine->driver_data;
int offs;
for (offs = 0;offs < SPRITERAM_SIZE;offs += 4)
for (offs = 0; offs < SPRITERAM_SIZE; offs += 4)
{
int x,y,color,code,sx,sy,flipx,flipy,sizex,sizey,pri;
int x, y, color, code, sx, sy, flipx, flipy, sizex, sizey, pri;
pri = (state->buf_spriteram[offs] & 0x0600) >> 9;
if (pri != priority)
continue;
pri = (buf_spriteram[offs] & 0x0600) >> 9;
if (pri != priority) continue;
flipx = buf_spriteram[offs] & 0x1000;
flipx = state->buf_spriteram[offs] & 0x1000;
flipy = 0;
color = (buf_spriteram[offs] & 0x01fc) >> 2;
code = buf_spriteram[offs+1] | ((buf_spriteram[offs] & 0x0003) << 16);
sx = (buf_spriteram[offs+2] >> 7);
sy = (buf_spriteram[offs+3] >> 7);
sizex = (buf_spriteram[offs+2] & 0x000f) + 1;
sizey = (buf_spriteram[offs+3] & 0x000f) + 1;
color = (state->buf_spriteram[offs] & 0x01fc) >> 2;
code = state->buf_spriteram[offs + 1] | ((state->buf_spriteram[offs] & 0x0003) << 16);
sx = (state->buf_spriteram[offs + 2] >> 7);
sy = (state->buf_spriteram[offs + 3] >> 7);
sizex = (state->buf_spriteram[offs + 2] & 0x000f) + 1;
sizey = (state->buf_spriteram[offs + 3] & 0x000f) + 1;
if (flip_screen_get(machine))
{
@ -161,15 +166,15 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
sy = 16 - sy;
}
for (y = 0;y < sizey;y++)
for (y = 0; y < sizey; y++)
{
for (x = 0;x < sizex;x++)
for (x = 0; x < sizex; x++)
{
drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
code + x + sizex * y,
color,
flipx,flipy,
(sx + (flipx ? (-8*(x+1)+1) : 8*x) - vreg[6]+44) & 0x1ff,(sy + (flipy ? (-8*(y+1)+1) : 8*y) - vreg[7]-9) & 0x1ff,0);
(sx + (flipx ? (-8*(x+1)+1) : 8*x) - state->vreg[6]+44) & 0x1ff,(sy + (flipy ? (-8*(y+1)+1) : 8*y) - state->vreg[7]-9) & 0x1ff,0);
}
}
}
@ -177,47 +182,53 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan
VIDEO_UPDATE( othldrby )
{
othldrby_state *state = (othldrby_state *)screen->machine->driver_data;
int layer;
flip_screen_set(screen->machine, state->vreg[0x0f] & 0x80);
flip_screen_set(screen->machine, vreg[0x0f] & 0x80);
for (layer = 0;layer < 3;layer++)
for (layer = 0; layer < 3; layer++)
{
if (flip_screen_get(screen->machine))
{
tilemap_set_scrollx(bg_tilemap[layer],0,vreg[2*layer]+59);
tilemap_set_scrolly(bg_tilemap[layer],0,vreg[2*layer+1]+248);
tilemap_set_scrollx(state->bg_tilemap[layer], 0, state->vreg[2 * layer] + 59);
tilemap_set_scrolly(state->bg_tilemap[layer], 0, state->vreg[2 * layer + 1] + 248);
}
else
{
tilemap_set_scrollx(bg_tilemap[layer],0,vreg[2*layer]-58);
tilemap_set_scrolly(bg_tilemap[layer],0,vreg[2*layer+1]+9);
tilemap_set_scrollx(state->bg_tilemap[layer], 0, state->vreg[2 * layer] - 58);
tilemap_set_scrolly(state->bg_tilemap[layer], 0, state->vreg[2 * layer+1] + 9);
}
}
bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
bitmap_fill(bitmap,cliprect,0);
bitmap_fill(bitmap, cliprect, 0);
for (layer = 0; layer < 3; layer++)
tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 0, 0);
draw_sprites(screen->machine, bitmap, cliprect, 0);
for (layer = 0; layer < 3; layer++)
tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 1, 0);
draw_sprites(screen->machine, bitmap, cliprect, 1);
for (layer = 0; layer < 3; layer++)
tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 2, 0);
draw_sprites(screen->machine, bitmap, cliprect, 2);
for (layer = 0; layer < 3; layer++)
tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 3, 0);
draw_sprites(screen->machine, bitmap, cliprect, 3);
for (layer = 0;layer < 3;layer++)
tilemap_draw(bitmap,cliprect,bg_tilemap[layer],0,0);
draw_sprites(screen->machine,bitmap,cliprect,0);
for (layer = 0;layer < 3;layer++)
tilemap_draw(bitmap,cliprect,bg_tilemap[layer],1,0);
draw_sprites(screen->machine,bitmap,cliprect,1);
for (layer = 0;layer < 3;layer++)
tilemap_draw(bitmap,cliprect,bg_tilemap[layer],2,0);
draw_sprites(screen->machine,bitmap,cliprect,2);
for (layer = 0;layer < 3;layer++)
tilemap_draw(bitmap,cliprect,bg_tilemap[layer],3,0);
draw_sprites(screen->machine,bitmap,cliprect,3);
return 0;
}
VIDEO_EOF( othldrby )
{
othldrby_state *state = (othldrby_state *)machine->driver_data;
/* sprites need to be delayed two frames */
memcpy(buf_spriteram,buf_spriteram2,SPRITERAM_SIZE*sizeof(buf_spriteram[0]));
memcpy(buf_spriteram2,&vram[SPRITERAM_START],SPRITERAM_SIZE*sizeof(buf_spriteram[0]));
memcpy(state->buf_spriteram, state->buf_spriteram2, SPRITERAM_SIZE * sizeof(state->buf_spriteram[0]));
memcpy(state->buf_spriteram2, &state->vram[SPRITERAM_START], SPRITERAM_SIZE * sizeof(state->buf_spriteram[0]));
}