summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Fabio Priuli <etabeta78@users.noreply.github.com>2009-11-18 23:26:26 +0000
committer Fabio Priuli <etabeta78@users.noreply.github.com>2009-11-18 23:26:26 +0000
commit69e98c3a1eb619f4ecbc29be95137451edfd137b (patch)
tree582aa1ae061510b8e7b31d1d9892bee25ed46a41
parentdf5e77518308a9d6d215350d48a93e89e1dd027f (diff)
Forgot to commit this: Added driver_data struct to aeroboto.c
-rw-r--r--.gitattributes1
-rw-r--r--src/mame/drivers/aeroboto.c92
-rw-r--r--src/mame/includes/aeroboto.h45
-rw-r--r--src/mame/video/aeroboto.c147
4 files changed, 183 insertions, 102 deletions
diff --git a/.gitattributes b/.gitattributes
index 3e45c395c0f..944b22d8093 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2294,6 +2294,7 @@ src/mame/includes/1943.h svneol=native#text/plain
src/mame/includes/20pacgal.h svneol=native#text/plain
src/mame/includes/4enraya.h svneol=native#text/plain
src/mame/includes/8080bw.h svneol=native#text/plain
+src/mame/includes/aeroboto.h svneol=native#text/plain
src/mame/includes/aerofgt.h svneol=native#text/plain
src/mame/includes/ajax.h svneol=native#text/plain
src/mame/includes/amiga.h svneol=native#text/plain
diff --git a/src/mame/drivers/aeroboto.c b/src/mame/drivers/aeroboto.c
index 54316f1cb34..1d6793f167b 100644
--- a/src/mame/drivers/aeroboto.c
+++ b/src/mame/drivers/aeroboto.c
@@ -25,74 +25,67 @@ Revisions:
#include "driver.h"
#include "cpu/m6809/m6809.h"
#include "sound/ay8910.h"
-
-
-extern UINT8 *aeroboto_videoram;
-extern UINT8 *aeroboto_hscroll, *aeroboto_vscroll, *aeroboto_tilecolor;
-extern UINT8 *aeroboto_starx, *aeroboto_stary, *aeroboto_bgcolor;
-
-VIDEO_START( aeroboto );
-VIDEO_UPDATE( aeroboto );
-
-READ8_HANDLER( aeroboto_in0_r );
-WRITE8_HANDLER( aeroboto_3000_w );
-WRITE8_HANDLER( aeroboto_videoram_w );
-WRITE8_HANDLER( aeroboto_tilecolor_w );
-
-static UINT8 *aeroboto_mainram;
-static int disable_irq = 0;
+#include "aeroboto.h"
static READ8_HANDLER( aeroboto_201_r )
{
+ aeroboto_state *state = (aeroboto_state *)space->machine->driver_data;
/* if you keep a button pressed during boot, the game will expect this */
/* serie of values to be returned from 3004, and display "PASS 201" if it is */
- static const UINT8 res[4] = { 0xff,0x9f,0x1b,0x03};
- static int count;
- logerror("PC %04x: read 3004\n",cpu_get_pc(space->cpu));
- return res[(count++)&3];
+ static const UINT8 res[4] = { 0xff, 0x9f, 0x1b, 0x03 };
+
+ logerror("PC %04x: read 3004\n", cpu_get_pc(space->cpu));
+ return res[(state->count++) & 3];
}
static INTERRUPT_GEN( aeroboto_interrupt )
{
- if (!disable_irq)
+ aeroboto_state *state = (aeroboto_state *)device->machine->driver_data;
+
+ if (!state->disable_irq)
cpu_set_input_line(device, 0, HOLD_LINE);
else
- disable_irq--;
+ state->disable_irq--;
}
static READ8_HANDLER( aeroboto_2973_r )
{
- aeroboto_mainram[0x02be] = 0;
- return(0xff);
+ aeroboto_state *state = (aeroboto_state *)space->machine->driver_data;
+
+ state->mainram[0x02be] = 0;
+ return 0xff;
}
static WRITE8_HANDLER ( aeroboto_1a2_w )
{
- aeroboto_mainram[0x01a2] = data;
- if (data) disable_irq = 1;
+ aeroboto_state *state = (aeroboto_state *)space->machine->driver_data;
+
+ state->mainram[0x01a2] = data;
+ if (data)
+ state->disable_irq = 1;
}
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x01a2, 0x01a2) AM_WRITE(aeroboto_1a2_w) // affects IRQ line (more protection?)
- AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&aeroboto_mainram) // main RAM
+ AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(aeroboto_state, mainram) // main RAM
AM_RANGE(0x0800, 0x08ff) AM_RAM // tile color buffer; copied to 0x2000
AM_RANGE(0x0900, 0x09ff) AM_WRITEONLY // a backup of default tile colors
- AM_RANGE(0x1000, 0x17ff) AM_RAM_WRITE(aeroboto_videoram_w) AM_BASE(&aeroboto_videoram) // tile RAM
- AM_RANGE(0x1800, 0x183f) AM_RAM AM_BASE(&aeroboto_hscroll) // horizontal scroll regs
- AM_RANGE(0x2000, 0x20ff) AM_RAM_WRITE(aeroboto_tilecolor_w) AM_BASE(&aeroboto_tilecolor) // tile color RAM
+ AM_RANGE(0x1000, 0x17ff) AM_RAM_WRITE(aeroboto_videoram_w) AM_BASE_MEMBER(aeroboto_state, videoram) // tile RAM
+ AM_RANGE(0x1800, 0x183f) AM_RAM AM_BASE_MEMBER(aeroboto_state, hscroll) // horizontal scroll regs
+ AM_RANGE(0x2000, 0x20ff) AM_RAM_WRITE(aeroboto_tilecolor_w) AM_BASE_MEMBER(aeroboto_state, tilecolor) // tile color RAM
AM_RANGE(0x1840, 0x27ff) AM_WRITENOP // cleared during custom LSI test
- AM_RANGE(0x2800, 0x28ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) // sprite RAM
+ AM_RANGE(0x2800, 0x28ff) AM_RAM AM_BASE_MEMBER(aeroboto_state, spriteram) AM_SIZE(&spriteram_size) // sprite RAM
AM_RANGE(0x2900, 0x2fff) AM_WRITENOP // cleared along with sprite RAM
AM_RANGE(0x2973, 0x2973) AM_READ(aeroboto_2973_r) // protection read
AM_RANGE(0x3000, 0x3000) AM_READWRITE(aeroboto_in0_r, aeroboto_3000_w)
AM_RANGE(0x3001, 0x3001) AM_READ_PORT("DSW1") AM_WRITE(soundlatch_w)
AM_RANGE(0x3002, 0x3002) AM_READ_PORT("DSW2") AM_WRITE(soundlatch2_w)
- AM_RANGE(0x3003, 0x3003) AM_WRITEONLY AM_BASE(&aeroboto_vscroll)
- AM_RANGE(0x3004, 0x3004) AM_READ(aeroboto_201_r) AM_WRITEONLY AM_BASE(&aeroboto_starx)
- AM_RANGE(0x3005, 0x3005) AM_WRITEONLY AM_BASE(&aeroboto_stary) // usable but probably wrong
- AM_RANGE(0x3006, 0x3006) AM_WRITEONLY AM_BASE(&aeroboto_bgcolor)
+ AM_RANGE(0x3003, 0x3003) AM_WRITEONLY AM_BASE_MEMBER(aeroboto_state, vscroll)
+ AM_RANGE(0x3004, 0x3004) AM_READ(aeroboto_201_r) AM_WRITEONLY AM_BASE_MEMBER(aeroboto_state, starx)
+ AM_RANGE(0x3005, 0x3005) AM_WRITEONLY AM_BASE_MEMBER(aeroboto_state, stary) // usable but probably wrong
+ AM_RANGE(0x3006, 0x3006) AM_WRITEONLY AM_BASE_MEMBER(aeroboto_state, bgcolor)
AM_RANGE(0x3800, 0x3800) AM_READNOP // watchdog or IRQ ack
AM_RANGE(0x4000, 0xffff) AM_ROM // main ROM
ADDRESS_MAP_END
@@ -229,11 +222,35 @@ static const ay8910_interface ay8910_config =
static MACHINE_START( formatz )
{
- state_save_register_global(machine, disable_irq);
+ aeroboto_state *state = (aeroboto_state *)machine->driver_data;
+
+ state->stars_rom = memory_region(machine, "gfx2");
+ state->stars_length = memory_region_length(machine, "gfx2");
+
+ state_save_register_global(machine, state->disable_irq);
+ state_save_register_global(machine, state->count);
+}
+
+static MACHINE_RESET( formatz )
+{
+ aeroboto_state *state = (aeroboto_state *)machine->driver_data;
+
+ state->disable_irq = 0;
+ state->count = 0;
+
+ state->charbank = 0;
+ state->starsoff = 0;
+ state->ox = 0;
+ state->oy = 0;
+ state->sx = 0;
+ state->sy = 0;
}
static MACHINE_DRIVER_START( formatz )
+ /* driver data */
+ MDRV_DRIVER_DATA(aeroboto_state)
+
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6809, XTAL_10MHz/8) /* verified on pcb */
MDRV_CPU_PROGRAM_MAP(main_map)
@@ -243,7 +260,8 @@ static MACHINE_DRIVER_START( formatz )
MDRV_CPU_PROGRAM_MAP(sound_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
- MDRV_MACHINE_START(formatz)
+ MDRV_MACHINE_START(formatz)
+ MDRV_MACHINE_RESET(formatz)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
diff --git a/src/mame/includes/aeroboto.h b/src/mame/includes/aeroboto.h
new file mode 100644
index 00000000000..70a0dad6741
--- /dev/null
+++ b/src/mame/includes/aeroboto.h
@@ -0,0 +1,45 @@
+/***************************************************************************
+
+ Aeroboto
+
+***************************************************************************/
+
+typedef struct _aeroboto_state aeroboto_state;
+struct _aeroboto_state
+{
+ /* memory pointers */
+ UINT8 * mainram;
+ UINT8 * spriteram;
+ UINT8 * videoram;
+ UINT8 * hscroll;
+ UINT8 * vscroll;
+ UINT8 * tilecolor;
+ UINT8 * starx;
+ UINT8 * stary;
+ UINT8 * bgcolor;
+
+ /* stars layout */
+ UINT8 * stars_rom;
+ int stars_length;
+
+ /* video-related */
+ tilemap *bg_tilemap;
+ int charbank, starsoff;
+ int sx, sy;
+ UINT8 ox, oy;
+
+ /* misc */
+ int count;
+ int disable_irq;
+};
+
+
+/*----------- defined in video/aeroboto.c -----------*/
+
+VIDEO_START( aeroboto );
+VIDEO_UPDATE( aeroboto );
+
+READ8_HANDLER( aeroboto_in0_r );
+WRITE8_HANDLER( aeroboto_3000_w );
+WRITE8_HANDLER( aeroboto_videoram_w );
+WRITE8_HANDLER( aeroboto_tilecolor_w );
diff --git a/src/mame/video/aeroboto.c b/src/mame/video/aeroboto.c
index b823ad8dc82..5fe54fad1f1 100644
--- a/src/mame/video/aeroboto.c
+++ b/src/mame/video/aeroboto.c
@@ -1,4 +1,12 @@
+/***************************************************************************
+
+ video/aeroboto.c
+
+***************************************************************************/
+
+
#include "driver.h"
+#include "aeroboto.h"
// how the starfield ROM is interpreted: 0=256x256x1 linear bitmap, 1=8x8x1x1024 tilemap
@@ -7,15 +15,6 @@
// scroll speed of the stars: 1=normal, 2=half, 3=one-third...etc.(possitive integers only)
#define SCROLL_SPEED 1
-
-UINT8 *aeroboto_videoram;
-UINT8 *aeroboto_hscroll, *aeroboto_vscroll, *aeroboto_tilecolor;
-UINT8 *aeroboto_starx, *aeroboto_stary, *aeroboto_bgcolor;
-
-static int aeroboto_charbank, aeroboto_starsoff;
-
-static tilemap *bg_tilemap;
-
/***************************************************************************
Callbacks for the TileMap code
@@ -24,12 +23,13 @@ static tilemap *bg_tilemap;
static TILE_GET_INFO( get_tile_info )
{
- UINT8 code = aeroboto_videoram[tile_index];
+ aeroboto_state *state = (aeroboto_state *)machine->driver_data;
+ UINT8 code = state->videoram[tile_index];
SET_TILE_INFO(
0,
- code + (aeroboto_charbank << 8),
- aeroboto_tilecolor[code],
- (aeroboto_tilecolor[code] >= 0x33) ? 0 : TILE_FORCE_LAYER0);
+ code + (state->charbank << 8),
+ state->tilecolor[code],
+ (state->tilecolor[code] >= 0x33) ? 0 : TILE_FORCE_LAYER0);
}
// transparency should only affect tiles with color 0x33 or higher
@@ -42,26 +42,29 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( aeroboto )
{
- bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,64);
-
- tilemap_set_transparent_pen(bg_tilemap,0);
+ aeroboto_state *state = (aeroboto_state *)machine->driver_data;
- tilemap_set_scroll_rows(bg_tilemap,64);
+ state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 64);
+ tilemap_set_transparent_pen(state->bg_tilemap, 0);
+ tilemap_set_scroll_rows(state->bg_tilemap, 64);
- state_save_register_global(machine, aeroboto_charbank);
- state_save_register_global(machine, aeroboto_starsoff);
+ state_save_register_global(machine, state->charbank);
+ state_save_register_global(machine, state->starsoff);
+ state_save_register_global(machine, state->sx);
+ state_save_register_global(machine, state->sy);
+ state_save_register_global(machine, state->ox);
+ state_save_register_global(machine, state->oy);
#if STARS_LAYOUT
{
- UINT8 *rom, *temp;
- int i, length;
+ UINT8 *temp;
+ int i;
- rom = memory_region(machine, "gfx2");
- length = memory_region_length(machine, "gfx2");
- temp = alloc_array_or_die(UINT8, length);
- memcpy(temp, rom, length);
+ temp = alloc_array_or_die(UINT8, state->stars_length);
+ memcpy(temp, state->stars_rom, state->stars_length);
- for (i=0; i<length; i++) rom[(i&~0xff)+(i<<5&0xe0)+(i>>3&0x1f)] = temp[i];
+ for (i = 0; i < state->stars_length; i++)
+ state->stars_rom[(i & ~0xff) + (i << 5 & 0xe0) + (i >> 3 & 0x1f)] = temp[i];
free(temp);
}
@@ -83,32 +86,38 @@ READ8_HANDLER( aeroboto_in0_r )
WRITE8_HANDLER( aeroboto_3000_w )
{
+ aeroboto_state *state = (aeroboto_state *)space->machine->driver_data;
+
/* bit 0 selects both flip screen and player1/player2 controls */
flip_screen_set(space->machine, data & 0x01);
/* bit 1 = char bank select */
- if (aeroboto_charbank != ((data & 0x02) >> 1))
+ if (state->charbank != ((data & 0x02) >> 1))
{
- tilemap_mark_all_tiles_dirty(bg_tilemap);
- aeroboto_charbank = (data & 0x02) >> 1;
+ tilemap_mark_all_tiles_dirty(state->bg_tilemap);
+ state->charbank = (data & 0x02) >> 1;
}
/* bit 2 = disable star field? */
- aeroboto_starsoff = data & 0x4;
+ state->starsoff = data & 0x4;
}
WRITE8_HANDLER( aeroboto_videoram_w )
{
- aeroboto_videoram[offset] = data;
- tilemap_mark_tile_dirty(bg_tilemap,offset);
+ aeroboto_state *state = (aeroboto_state *)space->machine->driver_data;
+
+ state->videoram[offset] = data;
+ tilemap_mark_tile_dirty(state->bg_tilemap,offset);
}
WRITE8_HANDLER( aeroboto_tilecolor_w )
{
- if (aeroboto_tilecolor[offset] != data)
+ aeroboto_state *state = (aeroboto_state *)space->machine->driver_data;
+
+ if (state->tilecolor[offset] != data)
{
- aeroboto_tilecolor[offset] = data;
- tilemap_mark_all_tiles_dirty(bg_tilemap);
+ state->tilecolor[offset] = data;
+ tilemap_mark_all_tiles_dirty(state->bg_tilemap);
}
}
@@ -120,14 +129,15 @@ WRITE8_HANDLER( aeroboto_tilecolor_w )
***************************************************************************/
-static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
+static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{
+ aeroboto_state *state = (aeroboto_state *)machine->driver_data;
int offs;
- for (offs = 0;offs < spriteram_size;offs += 4)
+ for (offs = 0; offs < spriteram_size; offs += 4)
{
- int x = spriteram[offs+3];
- int y = 240 - spriteram[offs];
+ int x = state->spriteram[offs + 3];
+ int y = 240 - state->spriteram[offs];
if (flip_screen_get(machine))
{
@@ -136,8 +146,8 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
}
drawgfx_transpen(bitmap, cliprect, machine->gfx[1],
- spriteram[offs+1],
- spriteram[offs+2] & 0x07,
+ state->spriteram[offs + 1],
+ state->spriteram[offs + 2] & 0x07,
flip_screen_get(machine), flip_screen_get(machine),
((x + 8) & 0xff) - 8, y, 0);
}
@@ -146,35 +156,41 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( aeroboto )
{
+ aeroboto_state *state = (aeroboto_state *)screen->machine->driver_data;
+
static const rectangle splitrect1 = { 0, 255, 0, 39 };
static const rectangle splitrect2 = { 0, 255, 40, 255 };
- static int sx=0, sy=0;
- static UINT8 ox=0, oy=0;
UINT8 *src_base, *src_colptr, *src_rowptr;
int src_offsx, src_colmask, sky_color, star_color, x, y, i, j, pen;
- sky_color = star_color = *aeroboto_bgcolor << 2;
+ sky_color = star_color = *state->bgcolor << 2;
// the star field is supposed to be seen through tile pen 0 when active
- if (!aeroboto_starsoff)
+ if (!state->starsoff)
{
- if (star_color < 0xd0) { star_color = 0xd0; sky_color = 0; }
+ if (star_color < 0xd0)
+ {
+ star_color = 0xd0;
+ sky_color = 0;
+ }
+
star_color += 2;
bitmap_fill(bitmap, cliprect, sky_color);
// actual scroll speed is unknown but it can be adjusted by changing the SCROLL_SPEED constant
- sx += (char)(*aeroboto_starx - ox);
- ox = *aeroboto_starx;
- x = sx / SCROLL_SPEED;
+ state->sx += (char)(*state->starx - state->ox);
+ state->ox = *state->starx;
+ x = state->sx / SCROLL_SPEED;
- if (*aeroboto_vscroll != 0xff) sy += (char)(*aeroboto_stary - oy);
- oy = *aeroboto_stary;
- y = sy / SCROLL_SPEED;
+ if (*state->vscroll != 0xff)
+ state->sy += (char)(*state->stary - state->oy);
+ state->oy = *state->stary;
+ y = state->sy / SCROLL_SPEED;
- src_base = memory_region(screen->machine, "gfx2");
+ src_base = state->stars_rom;
- for (i=0; i<256; i++)
+ for (i = 0; i < 256; i++)
{
src_offsx = (x + i) & 0xff;
src_colmask = 1 << (src_offsx & 7);
@@ -182,31 +198,32 @@ VIDEO_UPDATE( aeroboto )
src_colptr = src_base + src_offsx;
pen = star_color + ((i + 8) >> 4 & 1);
- for (j=0; j<256; j++)
+ for (j = 0; j < 256; j++)
{
src_rowptr = src_colptr + (((y + j) & 0xff) << 5 );
- if (!((unsigned)*src_rowptr & src_colmask)) *BITMAP_ADDR16(bitmap, j, i) = pen;
+ if (!((unsigned)*src_rowptr & src_colmask))
+ *BITMAP_ADDR16(bitmap, j, i) = pen;
}
}
}
else
{
- sx = ox = *aeroboto_starx;
- sy = oy = *aeroboto_stary;
+ state->sx = state->ox = *state->starx;
+ state->sy = state->oy = *state->stary;
bitmap_fill(bitmap, cliprect, sky_color);
}
- for (y = 0;y < 64; y++)
- tilemap_set_scrollx(bg_tilemap,y,aeroboto_hscroll[y]);
+ for (y = 0; y < 64; y++)
+ tilemap_set_scrollx(state->bg_tilemap, y, state->hscroll[y]);
// the playfield is part of a splitscreen and should not overlap with status display
- tilemap_set_scrolly(bg_tilemap,0,*aeroboto_vscroll);
- tilemap_draw(bitmap,&splitrect2,bg_tilemap,0,0);
+ tilemap_set_scrolly(state->bg_tilemap, 0, *state->vscroll);
+ tilemap_draw(bitmap, &splitrect2, state->bg_tilemap, 0, 0);
- draw_sprites(screen->machine,bitmap,cliprect);
+ draw_sprites(screen->machine, bitmap, cliprect);
// the status display behaves more closely to a 40-line splitscreen than an overlay
- tilemap_set_scrolly(bg_tilemap,0,0);
- tilemap_draw(bitmap,&splitrect1,bg_tilemap,0,0);
+ tilemap_set_scrolly(state->bg_tilemap, 0, 0);
+ tilemap_draw(bitmap, &splitrect1, state->bg_tilemap, 0, 0);
return 0;
}