ooops... forgot that I added driver data struct to cheekyms.c as well. here it is.

This commit is contained in:
Fabio Priuli 2009-11-25 01:14:45 +00:00
parent c2d537c3dd
commit 9b5b396d06
4 changed files with 103 additions and 70 deletions

1
.gitattributes vendored
View File

@ -2375,6 +2375,7 @@ src/mame/includes/centiped.h svneol=native#text/plain
src/mame/includes/chaknpop.h svneol=native#text/plain
src/mame/includes/champbas.h svneol=native#text/plain
src/mame/includes/changela.h svneol=native#text/plain
src/mame/includes/cheekyms.h svneol=native#text/plain
src/mame/includes/cidelsa.h svneol=native#text/plain
src/mame/includes/cinemat.h svneol=native#text/plain
src/mame/includes/circus.h svneol=native#text/plain

View File

@ -1,26 +1,15 @@
/*************************************************************************
Universal Cheeky Mouse Driver
(c)Lee Taylor May/June 1998, All rights reserved.
Universal Cheeky Mouse Driver
(c)Lee Taylor May/June 1998, All rights reserved.
For use only in offical MAME releases.
Not to be distributed as part of any commerical work.
For use only in offical MAME releases.
Not to be distributed as part of any commerical work.
**************************************************************************/
#include "driver.h"
#include "cpu/z80/z80.h"
#include "sound/dac.h"
extern UINT8 *cheekyms_videoram;
extern UINT8 *cheekyms_spriteram;
extern UINT8 *cheekyms_port_80;
PALETTE_INIT( cheekyms );
VIDEO_START( cheekyms );
VIDEO_UPDATE( cheekyms );
WRITE8_HANDLER( cheekyms_port_40_w );
WRITE8_HANDLER( cheekyms_port_80_w );
#include "cheekyms.h"
static INPUT_CHANGED( coin_inserted )
@ -34,16 +23,16 @@ static INPUT_CHANGED( coin_inserted )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x1fff) AM_ROM
AM_RANGE(0x3000, 0x33ff) AM_RAM
AM_RANGE(0x3800, 0x3bff) AM_RAM AM_BASE(&cheekyms_videoram)
AM_RANGE(0x3800, 0x3bff) AM_RAM AM_BASE_MEMBER(cheekyms_state, videoram)
ADDRESS_MAP_END
static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_GLOBAL_MASK(0xff)
AM_RANGE(0x00, 0x00) AM_READ_PORT("DSW")
AM_RANGE(0x01, 0x01) AM_READ_PORT("INPUTS")
AM_RANGE(0x20, 0x3f) AM_WRITEONLY AM_BASE(&cheekyms_spriteram)
AM_RANGE(0x20, 0x3f) AM_WRITEONLY AM_BASE_MEMBER(cheekyms_state, spriteram)
AM_RANGE(0x40, 0x40) AM_WRITE(cheekyms_port_40_w)
AM_RANGE(0x80, 0x80) AM_WRITE(cheekyms_port_80_w) AM_BASE(&cheekyms_port_80)
AM_RANGE(0x80, 0x80) AM_WRITE(cheekyms_port_80_w) AM_BASE_MEMBER(cheekyms_state, port_80)
ADDRESS_MAP_END
@ -58,7 +47,7 @@ static INPUT_PORTS_START( cheekyms )
PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) )
PORT_DIPSETTING( 0x04, DEF_STR( 1C_1C ) )
PORT_DIPSETTING( 0x00, DEF_STR( 1C_2C ) )
//PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) )
//PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) )
PORT_DIPNAME( 0x10, 0x10, DEF_STR( Cabinet ) )
PORT_DIPSETTING( 0x10, DEF_STR( Upright ) )
PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) )
@ -118,14 +107,26 @@ static GFXDECODE_START( cheekyms )
GFXDECODE_END
static MACHINE_START( cheekyms )
{
cheekyms_state *state = (cheekyms_state *)machine->driver_data;
state->dac = devtag_get_device(machine, "dac");
}
static MACHINE_DRIVER_START( cheekyms )
/* driver data */
MDRV_DRIVER_DATA(cheekyms_state)
/* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80,5000000/2) /* 2.5 MHz */
MDRV_CPU_PROGRAM_MAP(main_map)
MDRV_CPU_IO_MAP(io_map)
MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
MDRV_MACHINE_START(cheekyms)
/* video hardware */
MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60)

View File

@ -0,0 +1,31 @@
/*************************************************************************
Cheeky Mouse
*************************************************************************/
typedef struct _cheekyms_state cheekyms_state;
struct _cheekyms_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * spriteram;
UINT8 * port_80;
/* video-related */
tilemap *cm_tilemap;
bitmap_t *bitmap_buffer;
/* devices */
const device_config *dac;
};
/*----------- defined in video/cheekyms.c -----------*/
PALETTE_INIT( cheekyms );
VIDEO_START( cheekyms );
VIDEO_UPDATE( cheekyms );
WRITE8_HANDLER( cheekyms_port_40_w );
WRITE8_HANDLER( cheekyms_port_80_w );

View File

@ -1,46 +1,39 @@
/*************************************************************************
Universal Cheeky Mouse Driver
(c)Lee Taylor May 1998, All rights reserved.
Universal Cheeky Mouse Driver
(c)Lee Taylor May 1998, All rights reserved.
For use only in offical MAME releases.
Not to be distrabuted as part of any commerical work.
For use only in offical MAME releases.
Not to be distrabuted as part of any commerical work.
***************************************************************************
Functions to emulate the video hardware of the machine.
***************************************************************************/
#include "driver.h"
#include "sound/dac.h"
UINT8 *cheekyms_videoram;
UINT8 *cheekyms_spriteram;
UINT8 *cheekyms_port_80;
static tilemap *cheekyms_tilemap;
static bitmap_t *bitmap_buffer;
#include "cheekyms.h"
/* bit 3 and 7 of the char color PROMs are used for something -- not currently emulated -
thus GAME_IMPERFECT_GRAPHICS */
PALETTE_INIT( cheekyms )
{
int i,j,bit,r,g,b;
int i, j, bit, r, g, b;
for (i = 0; i < 6; i++)
{
for (j = 0;j < 0x20;j++)
for (j = 0; j < 0x20; j++)
{
/* red component */
bit = (color_prom[0x20*(i/2)+j] >> ((4*(i&1))+0)) & 0x01;
bit = (color_prom[0x20 * (i / 2) + j] >> ((4 * (i & 1)) + 0)) & 0x01;
r = 0xff * bit;
/* green component */
bit = (color_prom[0x20*(i/2)+j] >> ((4*(i&1))+1)) & 0x01;
bit = (color_prom[0x20 * (i / 2) + j] >> ((4 * (i & 1)) + 1)) & 0x01;
g = 0xff * bit;
/* blue component */
bit = (color_prom[0x20*(i/2)+j] >> ((4*(i&1))+2)) & 0x01;
bit = (color_prom[0x20 * (i / 2) + j] >> ((4 * (i & 1)) + 2)) & 0x01;
b = 0xff * bit;
palette_set_color(machine,(i*0x20)+j,MAKE_RGB(r,g,b));
palette_set_color(machine, (i * 0x20) + j, MAKE_RGB(r,g,b));
}
}
}
@ -48,19 +41,22 @@ PALETTE_INIT( cheekyms )
WRITE8_HANDLER( cheekyms_port_40_w )
{
/* the lower bits probably trigger sound samples */
cheekyms_state *state = (cheekyms_state *)space->machine->driver_data;
dac_data_w(devtag_get_device(space->machine, "dac"), data ? 0x80 : 0);
/* the lower bits probably trigger sound samples */
dac_data_w(state->dac, data ? 0x80 : 0);
}
WRITE8_HANDLER( cheekyms_port_80_w )
{
cheekyms_state *state = (cheekyms_state *)space->machine->driver_data;
/* d0-d1 - sound enables, not sure which bit is which */
/* d3-d5 - man scroll amount */
/* d6 - palette select (selects either 0 = PROM M9, 1 = PROM M8) */
/* d7 - screen flip */
*cheekyms_port_80 = data;
*state->port_80 = data;
/* d2 - interrupt enable */
interrupt_enable_w(space, offset, data & 0x04);
@ -70,12 +66,13 @@ WRITE8_HANDLER( cheekyms_port_80_w )
static TILE_GET_INFO( cheekyms_get_tile_info )
{
cheekyms_state *state = (cheekyms_state *)machine->driver_data;
int color;
int x = tile_index & 0x1f;
int y = tile_index >> 5;
int code = cheekyms_videoram[tile_index];
int palette = (*cheekyms_port_80 >> 2) & 0x10;
int code = state->videoram[tile_index];
int palette = (*state->port_80 >> 2) & 0x10;
if (x >= 0x1e)
{
@ -99,33 +96,35 @@ static TILE_GET_INFO( cheekyms_get_tile_info )
VIDEO_START( cheekyms )
{
cheekyms_state *state = (cheekyms_state *)machine->driver_data;
int width, height;
width = video_screen_get_width(machine->primary_screen);
height = video_screen_get_height(machine->primary_screen);
bitmap_buffer = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16);
state->bitmap_buffer = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16);
cheekyms_tilemap = tilemap_create(machine, cheekyms_get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(cheekyms_tilemap, 0);
state->cm_tilemap = tilemap_create(machine, cheekyms_get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
tilemap_set_transparent_pen(state->cm_tilemap, 0);
}
static void draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, int flip)
static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const gfx_element *gfx, int flip )
{
cheekyms_state *state = (cheekyms_state *)machine->driver_data;
offs_t offs;
for (offs = 0; offs < 0x20; offs += 4)
{
int x, y, code, color;
if ((cheekyms_spriteram[offs + 3] & 0x08) == 0x00) continue;
if ((state->spriteram[offs + 3] & 0x08) == 0x00) continue;
x = 256 - cheekyms_spriteram[offs + 2];
y = cheekyms_spriteram[offs + 1];
code = (~cheekyms_spriteram[offs + 0] & 0x0f) << 1;
color = (~cheekyms_spriteram[offs + 3] & 0x07);
x = 256 - state->spriteram[offs + 2];
y = state->spriteram[offs + 1];
code = (~state->spriteram[offs + 0] & 0x0f) << 1;
color = (~state->spriteram[offs + 3] & 0x07);
if (cheekyms_spriteram[offs + 0] & 0x80)
if (state->spriteram[offs + 0] & 0x80)
{
if (!flip)
code++;
@ -134,7 +133,7 @@ static void draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_
}
else
{
if (cheekyms_spriteram[offs + 0] & 0x02)
if (state->spriteram[offs + 0] & 0x02)
{
drawgfx_transpen(bitmap, cliprect, gfx, code | 0x20, color, 0, 0, x, y, 0);
drawgfx_transpen(bitmap, cliprect, gfx, code | 0x21, color, 0, 0, 0x10 + x, y, 0);
@ -151,47 +150,48 @@ static void draw_sprites(bitmap_t *bitmap, const rectangle *cliprect, const gfx_
VIDEO_UPDATE( cheekyms )
{
int y,x;
int scrolly = ((*cheekyms_port_80 >> 3) & 0x07);
int flip = *cheekyms_port_80 & 0x80;
cheekyms_state *state = (cheekyms_state *)screen->machine->driver_data;
int y, x;
int scrolly = ((*state->port_80 >> 3) & 0x07);
int flip = *state->port_80 & 0x80;
tilemap_mark_all_tiles_dirty_all(screen->machine);
tilemap_set_flip_all(screen->machine, flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
bitmap_fill(bitmap, cliprect, 0);
bitmap_fill(bitmap_buffer, cliprect, 0);
bitmap_fill(state->bitmap_buffer, cliprect, 0);
/* sprites go under the playfield */
draw_sprites(bitmap, cliprect, screen->machine->gfx[1], flip);
draw_sprites(screen->machine, bitmap, cliprect, screen->machine->gfx[1], flip);
/* draw the tilemap to a temp bitmap */
tilemap_draw(bitmap_buffer, cliprect, cheekyms_tilemap, 0, 0);
tilemap_draw(state->bitmap_buffer, cliprect, state->cm_tilemap, 0, 0);
/* draw the tilemap to the final bitmap applying the scroll to the man character */
for(y = cliprect->min_y; y <= cliprect->max_y; y++)
for (y = cliprect->min_y; y <= cliprect->max_y; y++)
{
for(x = cliprect->min_x; x <= cliprect->max_x; x++)
for (x = cliprect->min_x; x <= cliprect->max_x; x++)
{
int in_man_area;
if(flip)
if (flip)
{
in_man_area = (x >= (32-12-1)*8 && x < (32-8)*8 && y > 5*8 && y < 27*8);
in_man_area = (x >= (32 - 12 - 1) * 8 && x < (32 - 8) * 8 && y > 5 * 8 && y < 27 * 8);
}
else
{
in_man_area = (x >= 8*8 && x < 12*8 && y > 5*8 && y < 27*8);
in_man_area = (x >= 8 * 8 && x < 12 * 8 && y > 5 * 8 && y < 27 * 8);
}
if(in_man_area)
if (in_man_area)
{
if ((y + scrolly) < 27*8 && *BITMAP_ADDR16(bitmap_buffer, y + scrolly, x) != 0)
*BITMAP_ADDR16(bitmap, y, x) = *BITMAP_ADDR16(bitmap_buffer, y + scrolly, x);
if ((y + scrolly) < 27 * 8 && *BITMAP_ADDR16(state->bitmap_buffer, y + scrolly, x) != 0)
*BITMAP_ADDR16(bitmap, y, x) = *BITMAP_ADDR16(state->bitmap_buffer, y + scrolly, x);
}
else
{
if(*BITMAP_ADDR16(bitmap_buffer, y, x) != 0)
*BITMAP_ADDR16(bitmap, y, x) = *BITMAP_ADDR16(bitmap_buffer, y, x);
if(*BITMAP_ADDR16(state->bitmap_buffer, y, x) != 0)
*BITMAP_ADDR16(bitmap, y, x) = *BITMAP_ADDR16(state->bitmap_buffer, y, x);
}
}
}