Eliminated global/static variables in a number of Konami/Sega drivers

by introducing/using driver_device classes. [Atari Ace]
This commit is contained in:
Aaron Giles 2011-02-12 18:06:00 +00:00
parent b1fda0923f
commit 6d8a9362a8
75 changed files with 6047 additions and 5107 deletions

View File

@ -14,7 +14,6 @@
#include "includes/88games.h" #include "includes/88games.h"
static UINT8 *paletteram_1000;
/************************************* /*************************************
@ -137,7 +136,7 @@ static WRITE8_HANDLER( k052109_051960_w )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE_MEMBER(_88games_state, banked_rom) /* banked ROM + palette RAM */ AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE_MEMBER(_88games_state, banked_rom) /* banked ROM + palette RAM */
AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE(&paletteram_1000) /* banked ROM + palette RAM */ AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE_MEMBER(_88games_state, paletteram_1000) /* banked ROM + palette RAM */
AM_RANGE(0x2000, 0x2fff) AM_RAM AM_RANGE(0x2000, 0x2fff) AM_RAM
AM_RANGE(0x3000, 0x37ff) AM_RAM AM_SHARE("nvram") AM_RANGE(0x3000, 0x37ff) AM_RAM AM_SHARE("nvram")
AM_RANGE(0x3800, 0x3fff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE_MEMBER(_88games_state, ram) AM_RANGE(0x3800, 0x3fff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE_MEMBER(_88games_state, ram)
@ -287,10 +286,10 @@ static KONAMI_SETLINES_CALLBACK( k88games_banking )
memcpy(state->banked_rom, &RAM[offs], 0x1000); memcpy(state->banked_rom, &RAM[offs], 0x1000);
if (lines & 0x08) if (lines & 0x08)
{ {
if (device->machine->generic.paletteram.u8 != paletteram_1000) if (device->machine->generic.paletteram.u8 != state->paletteram_1000)
{ {
memcpy(paletteram_1000, device->machine->generic.paletteram.u8, 0x1000); memcpy(state->paletteram_1000, device->machine->generic.paletteram.u8, 0x1000);
device->machine->generic.paletteram.u8 = paletteram_1000; device->machine->generic.paletteram.u8 = state->paletteram_1000;
} }
} }
else else
@ -300,7 +299,7 @@ static KONAMI_SETLINES_CALLBACK( k88games_banking )
memcpy(&RAM[0x20000], device->machine->generic.paletteram.u8, 0x1000); memcpy(&RAM[0x20000], device->machine->generic.paletteram.u8, 0x1000);
device->machine->generic.paletteram.u8 = &RAM[0x20000]; device->machine->generic.paletteram.u8 = &RAM[0x20000];
} }
memcpy(paletteram_1000, &RAM[offs+0x1000], 0x1000); memcpy(state->paletteram_1000, &RAM[offs+0x1000], 0x1000);
} }
state->videobank = lines & 0x10; state->videobank = lines & 0x10;

View File

@ -134,15 +134,14 @@ static WRITE16_HANDLER( protection_w )
} }
#endif #endif
static UINT16 prot[2];
static WRITE16_HANDLER( protection_w ) static WRITE16_HANDLER( protection_w )
{ {
COMBINE_DATA(prot + offset); asterix_state *state = space->machine->driver_data<asterix_state>();
COMBINE_DATA(state->prot + offset);
if (offset == 1) if (offset == 1)
{ {
UINT32 cmd = (prot[0] << 16) | prot[1]; UINT32 cmd = (state->prot[0] << 16) | state->prot[1];
switch (cmd >> 24) switch (cmd >> 24)
{ {
case 0x64: case 0x64:

View File

@ -13,9 +13,6 @@
#include "sound/dac.h" #include "sound/dac.h"
#include "includes/beezer.h" #include "includes/beezer.h"
extern const via6522_interface b_via_0_interface;
extern const via6522_interface b_via_1_interface;
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xbfff) AM_RAM AM_BASE_MEMBER(beezer_state, videoram) AM_RANGE(0x0000, 0xbfff) AM_RAM AM_BASE_MEMBER(beezer_state, videoram)
AM_RANGE(0xc000, 0xcfff) AM_ROMBANK("bank1") AM_RANGE(0xc000, 0xcfff) AM_ROMBANK("bank1")

View File

@ -33,6 +33,17 @@ SOUND : YM2151 uPD7759C
#include "sound/2151intf.h" #include "sound/2151intf.h"
#include "sound/upd7759.h" #include "sound/upd7759.h"
class bingoc_state : public driver_device
{
public:
bingoc_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 x;
};
#define SOUND_TEST 0 #define SOUND_TEST 0
static VIDEO_START(bingoc) static VIDEO_START(bingoc)
@ -59,19 +70,19 @@ static READ16_HANDLER( bingoc_rand_r )
*/ */
static READ8_HANDLER( sound_test_r ) static READ8_HANDLER( sound_test_r )
{ {
static UINT8 x; bingoc_state *state = space->machine->driver_data<bingoc_state>();
if(input_code_pressed_once(space->machine, KEYCODE_Z)) if(input_code_pressed_once(space->machine, KEYCODE_Z))
x++; state->x++;
if(input_code_pressed_once(space->machine, KEYCODE_X)) if(input_code_pressed_once(space->machine, KEYCODE_X))
x--; state->x--;
if(input_code_pressed_once(space->machine, KEYCODE_A)) if(input_code_pressed_once(space->machine, KEYCODE_A))
return 0xff; return 0xff;
popmessage("%02x",x); popmessage("%02x",state->x);
return x; return state->x;
} }
#else #else
static WRITE16_HANDLER( main_sound_latch_w ) static WRITE16_HANDLER( main_sound_latch_w )
@ -125,7 +136,7 @@ static INPUT_PORTS_START( bingoc )
INPUT_PORTS_END INPUT_PORTS_END
static MACHINE_CONFIG_START( bingoc, driver_device ) static MACHINE_CONFIG_START( bingoc, bingoc_state )
MCFG_CPU_ADD("maincpu", M68000,8000000) /* ? MHz */ MCFG_CPU_ADD("maincpu", M68000,8000000) /* ? MHz */
MCFG_CPU_PROGRAM_MAP(main_map) MCFG_CPU_PROGRAM_MAP(main_map)

View File

@ -251,61 +251,86 @@ Note: This hardware appears to have been designed as a test-bed for a new RLE ba
#include "deprecat.h" #include "deprecat.h"
#include "sound/scsp.h" #include "sound/scsp.h"
static UINT32* sysh1_workram_h,*framebuffer_vram, *h1_unk, *h1_charram, *h1_vram;
static UINT32* sysh1_txt_blit; class coolridr_state : public driver_device
static UINT32* txt_vram; {
static bitmap_t* temp_bitmap_sprites; public:
coolridr_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT32* sysh1_workram_h;
UINT32* framebuffer_vram;
UINT32* h1_unk;
UINT32* h1_charram;
UINT32* h1_vram;
UINT32* sysh1_txt_blit;
UINT32* txt_vram;
bitmap_t* temp_bitmap_sprites;
UINT32 test_offs;
int color;
UINT8 vblank;
UINT16 cmd;
UINT16 param;
UINT32 dst_addr;
UINT32 txt_buff[0x10];
UINT32 attr_buff[0x10];
UINT8 txt_index;
UINT8 attr_index;
};
/* video */ /* video */
static VIDEO_START(coolridr) static VIDEO_START(coolridr)
{ {
coolridr_state *state = machine->driver_data<coolridr_state>();
int width = machine->primary_screen->width(); int width = machine->primary_screen->width();
int height = machine->primary_screen->height(); int height = machine->primary_screen->height();
temp_bitmap_sprites = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_RGB32); state->temp_bitmap_sprites = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_RGB32);
state->test_offs = 0x2000;
} }
static VIDEO_UPDATE(coolridr) static VIDEO_UPDATE(coolridr)
{ {
coolridr_state *state = screen->machine->driver_data<coolridr_state>();
/* planes seems to basically be at 0x8000 and 0x28000... */ /* planes seems to basically be at 0x8000 and 0x28000... */
const gfx_element *gfx = screen->machine->gfx[2]; const gfx_element *gfx = screen->machine->gfx[2];
UINT32 count; UINT32 count;
int y,x; int y,x;
static int color;
static UINT32 test_offs = 0x2000;
if(input_code_pressed(screen->machine,KEYCODE_Z)) if(input_code_pressed(screen->machine,KEYCODE_Z))
test_offs+=4; state->test_offs+=4;
if(input_code_pressed(screen->machine,KEYCODE_X)) if(input_code_pressed(screen->machine,KEYCODE_X))
test_offs-=4; state->test_offs-=4;
if(input_code_pressed(screen->machine,KEYCODE_C)) if(input_code_pressed(screen->machine,KEYCODE_C))
test_offs+=0x40; state->test_offs+=0x40;
if(input_code_pressed(screen->machine,KEYCODE_V)) if(input_code_pressed(screen->machine,KEYCODE_V))
test_offs-=0x40; state->test_offs-=0x40;
if(input_code_pressed(screen->machine,KEYCODE_B)) if(input_code_pressed(screen->machine,KEYCODE_B))
test_offs+=0x400; state->test_offs+=0x400;
if(input_code_pressed(screen->machine,KEYCODE_N)) if(input_code_pressed(screen->machine,KEYCODE_N))
test_offs-=0x400; state->test_offs-=0x400;
if(input_code_pressed_once(screen->machine,KEYCODE_A)) if(input_code_pressed_once(screen->machine,KEYCODE_A))
color++; state->color++;
if(input_code_pressed_once(screen->machine,KEYCODE_S)) if(input_code_pressed_once(screen->machine,KEYCODE_S))
color--; state->color--;
if(test_offs > 0x100000*4) if(state->test_offs > 0x100000*4)
test_offs = 0; state->test_offs = 0;
count = test_offs/4; count = state->test_offs/4;
popmessage("%08x %04x",test_offs,color); popmessage("%08x %04x",state->test_offs,state->color);
for (y=0;y<64;y++) for (y=0;y<64;y++)
{ {
@ -313,18 +338,18 @@ static VIDEO_UPDATE(coolridr)
{ {
int tile; int tile;
tile = (h1_vram[count] & 0x0fff0000) >> 16; tile = (state->h1_vram[count] & 0x0fff0000) >> 16;
drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,(x+0)*16,y*16); drawgfx_opaque(bitmap,cliprect,gfx,tile,state->color,0,0,(x+0)*16,y*16);
tile = (h1_vram[count] & 0x00000fff) >> 0; tile = (state->h1_vram[count] & 0x00000fff) >> 0;
drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,(x+1)*16,y*16); drawgfx_opaque(bitmap,cliprect,gfx,tile,state->color,0,0,(x+1)*16,y*16);
count++; count++;
} }
} }
copybitmap_trans(bitmap, temp_bitmap_sprites, 0, 0, 0, 0, cliprect, 0); copybitmap_trans(bitmap, state->temp_bitmap_sprites, 0, 0, 0, 0, cliprect, 0);
bitmap_fill(temp_bitmap_sprites, cliprect, 0); bitmap_fill(state->temp_bitmap_sprites, cliprect, 0);
return 0; return 0;
@ -335,27 +360,28 @@ static VIDEO_UPDATE(coolridr)
/* unknown purpose */ /* unknown purpose */
static READ32_HANDLER(sysh1_unk_r) static READ32_HANDLER(sysh1_unk_r)
{ {
coolridr_state *state = space->machine->driver_data<coolridr_state>();
switch(offset) switch(offset)
{ {
case 0x08/4: case 0x08/4:
{ {
static UINT8 vblank = 0;
vblank^=1; state->vblank^=1;
return (h1_unk[offset] & 0xfdffffff) | (vblank<<25); return (state->h1_unk[offset] & 0xfdffffff) | (state->vblank<<25);
} }
case 0x14/4: case 0x14/4:
return h1_unk[offset]; return state->h1_unk[offset];
//case 0x20/4: //case 0x20/4:
} }
return 0xffffffff;//h1_unk[offset]; return 0xffffffff;//state->h1_unk[offset];
} }
static WRITE32_HANDLER(sysh1_unk_w) static WRITE32_HANDLER(sysh1_unk_w)
{ {
COMBINE_DATA(&h1_unk[offset]); coolridr_state *state = space->machine->driver_data<coolridr_state>();
COMBINE_DATA(&state->h1_unk[offset]);
} }
/* According to Guru, this is actually the same I/O chip of Sega Model 2 HW */ /* According to Guru, this is actually the same I/O chip of Sega Model 2 HW */
@ -403,77 +429,74 @@ CMD = ac90 PARAM = 0001 DATA = 03f40170
/* this looks like an exotic I/O-based tilemap / sprite blitter, very unusual from Sega... */ /* this looks like an exotic I/O-based tilemap / sprite blitter, very unusual from Sega... */
static WRITE32_HANDLER( sysh1_txt_blit_w ) static WRITE32_HANDLER( sysh1_txt_blit_w )
{ {
static UINT16 cmd,param; coolridr_state *state = space->machine->driver_data<coolridr_state>();
static UINT32 dst_addr;
static UINT32 txt_buff[0x10],attr_buff[0x10];
static UINT8 txt_index,attr_index;
COMBINE_DATA(&sysh1_txt_blit[offset]); COMBINE_DATA(&state->sysh1_txt_blit[offset]);
switch(offset) switch(offset)
{ {
case 0x10/4: //cmd + param? case 0x10/4: //state->cmd + state->param?
cmd = (sysh1_txt_blit[offset] & 0xffff0000) >> 16; state->cmd = (state->sysh1_txt_blit[offset] & 0xffff0000) >> 16;
param = (sysh1_txt_blit[offset] & 0x0000ffff) >> 0; state->param = (state->sysh1_txt_blit[offset] & 0x0000ffff) >> 0;
dst_addr = 0x3f40000; state->dst_addr = 0x3f40000;
txt_index = 0; state->txt_index = 0;
attr_index = 0; state->attr_index = 0;
break; break;
case 0x14/4: //data case 0x14/4: //data
/* "THIS MACHINE IS STAND-ALONE." / disclaimer written with this CMD */ /* "THIS MACHINE IS STAND-ALONE." / disclaimer written with this CMD */
if((cmd & 0xff) == 0xf4) if((state->cmd & 0xff) == 0xf4)
{ {
txt_buff[txt_index++] = data; state->txt_buff[state->txt_index++] = data;
//printf("CMD = %04x PARAM = %04x | %c%c%c%c\n",cmd,param,(data >> 24) & 0xff,(data >> 16) & 0xff,(data >> 8) & 0xff,(data >> 0) & 0xff); //printf("CMD = %04x PARAM = %04x | %c%c%c%c\n",state->cmd,state->param,(data >> 24) & 0xff,(data >> 16) & 0xff,(data >> 8) & 0xff,(data >> 0) & 0xff);
} }
else if((cmd & 0xff) == 0x90 || (cmd & 0xff) == 0x30) else if((state->cmd & 0xff) == 0x90 || (state->cmd & 0xff) == 0x30)
{ {
attr_buff[attr_index++] = data; state->attr_buff[state->attr_index++] = data;
if(attr_index == 0xa) if(state->attr_index == 0xa)
{ {
static UINT16 x,y; UINT16 x,y;
y = (attr_buff[9] & 0x01f00000) >> 20; y = (state->attr_buff[9] & 0x01f00000) >> 20;
x = (attr_buff[9] & 0x1f0) >> 4; x = (state->attr_buff[9] & 0x1f0) >> 4;
dst_addr = 0x3f40000 | y*0x40 | x; state->dst_addr = 0x3f40000 | y*0x40 | x;
{ {
int x2,y2; int x2,y2;
const gfx_element *gfx = space->machine->gfx[1]; const gfx_element *gfx = space->machine->gfx[1];
rectangle clip; rectangle clip;
y2 = (attr_buff[9] & 0x01ff0000) >> 16; y2 = (state->attr_buff[9] & 0x01ff0000) >> 16;
x2 = (attr_buff[9] & 0x000001ff); x2 = (state->attr_buff[9] & 0x000001ff);
clip.min_x = 0; clip.min_x = 0;
clip.max_x = temp_bitmap_sprites->width; clip.max_x = state->temp_bitmap_sprites->width;
clip.min_y = 0; clip.min_y = 0;
clip.max_y = temp_bitmap_sprites->height; clip.max_y = state->temp_bitmap_sprites->height;
drawgfx_opaque(temp_bitmap_sprites,&clip,gfx,1,1,0,0,x2,y2); drawgfx_opaque(state->temp_bitmap_sprites,&clip,gfx,1,1,0,0,x2,y2);
} }
} }
if(attr_index == 0xc) if(state->attr_index == 0xc)
{ {
static UINT8 size; UINT8 size;
size = (attr_buff[6] / 4)+1; size = (state->attr_buff[6] / 4)+1;
for(txt_index = 0;txt_index < size; txt_index++) for(state->txt_index = 0;state->txt_index < size; state->txt_index++)
{ {
space->write_dword((dst_addr),txt_buff[txt_index]); space->write_dword((state->dst_addr),state->txt_buff[state->txt_index]);
dst_addr+=4; state->dst_addr+=4;
} }
} }
} }
else if((cmd & 0xff) == 0x10) else if((state->cmd & 0xff) == 0x10)
{ {
static UINT32 clear_vram; UINT32 clear_vram;
for(clear_vram=0x3f40000;clear_vram < 0x3f4ffff;clear_vram+=4) for(clear_vram=0x3f40000;clear_vram < 0x3f4ffff;clear_vram+=4)
space->write_dword((clear_vram),0x00000000); space->write_dword((clear_vram),0x00000000);
} }
//else //else
// printf("CMD = %04x PARAM = %04x DATA = %08x\n",cmd,param,data); // printf("CMD = %04x PARAM = %04x DATA = %08x\n",state->cmd,state->param,data);
break; break;
} }
} }
@ -498,16 +521,17 @@ static WRITE32_HANDLER( sysh1_pal_w )
/* FIXME: this seems to do a hell lot of stuff, it's not ST-V SCU but still somewhat complex :/ */ /* FIXME: this seems to do a hell lot of stuff, it's not ST-V SCU but still somewhat complex :/ */
static void sysh1_dma_transfer( address_space *space, UINT16 dma_index ) static void sysh1_dma_transfer( address_space *space, UINT16 dma_index )
{ {
static UINT32 src,dst,size,type,s_i; coolridr_state *state = space->machine->driver_data<coolridr_state>();
static UINT8 end_dma_mark; UINT32 src,dst,size,type,s_i;
UINT8 end_dma_mark;
end_dma_mark = 0; end_dma_mark = 0;
do{ do{
src = (framebuffer_vram[(0+dma_index)/4] & 0x0fffffff); src = (state->framebuffer_vram[(0+dma_index)/4] & 0x0fffffff);
dst = (framebuffer_vram[(4+dma_index)/4]); dst = (state->framebuffer_vram[(4+dma_index)/4]);
size = framebuffer_vram[(8+dma_index)/4]; size = state->framebuffer_vram[(8+dma_index)/4];
type = (framebuffer_vram[(0+dma_index)/4] & 0xf0000000) >> 28; type = (state->framebuffer_vram[(0+dma_index)/4] & 0xf0000000) >> 28;
#if 0 #if 0
if(type == 0xc || type == 0xd || type == 0xe) if(type == 0xc || type == 0xd || type == 0xe)
@ -518,7 +542,7 @@ static void sysh1_dma_transfer( address_space *space, UINT16 dma_index )
if(type == 0x3 || type == 0x4) if(type == 0x3 || type == 0x4)
{ {
//type 3 sets a DMA param, type 4 sets some kind of table? Skip it for now //type 3 sets a DMA state->param, type 4 sets some kind of table? Skip it for now
dma_index+=4; dma_index+=4;
continue; continue;
} }
@ -573,26 +597,28 @@ static void sysh1_dma_transfer( address_space *space, UINT16 dma_index )
static WRITE32_HANDLER( sysh1_dma_w ) static WRITE32_HANDLER( sysh1_dma_w )
{ {
COMBINE_DATA(&framebuffer_vram[offset]); coolridr_state *state = space->machine->driver_data<coolridr_state>();
COMBINE_DATA(&state->framebuffer_vram[offset]);
if(offset*4 == 0x000) if(offset*4 == 0x000)
{ {
if((framebuffer_vram[offset] & 0xff00000) == 0xfe00000) if((state->framebuffer_vram[offset] & 0xff00000) == 0xfe00000)
sysh1_dma_transfer(space, framebuffer_vram[offset] & 0xffff); sysh1_dma_transfer(space, state->framebuffer_vram[offset] & 0xffff);
} }
} }
static WRITE32_HANDLER( sysh1_char_w ) static WRITE32_HANDLER( sysh1_char_w )
{ {
COMBINE_DATA(&h1_charram[offset]); coolridr_state *state = space->machine->driver_data<coolridr_state>();
COMBINE_DATA(&state->h1_charram[offset]);
{ {
UINT8 *gfx = space->machine->region("ram_gfx")->base(); UINT8 *gfx = space->machine->region("ram_gfx")->base();
gfx[offset*4+0] = (h1_charram[offset] & 0xff000000) >> 24; gfx[offset*4+0] = (state->h1_charram[offset] & 0xff000000) >> 24;
gfx[offset*4+1] = (h1_charram[offset] & 0x00ff0000) >> 16; gfx[offset*4+1] = (state->h1_charram[offset] & 0x00ff0000) >> 16;
gfx[offset*4+2] = (h1_charram[offset] & 0x0000ff00) >> 8; gfx[offset*4+2] = (state->h1_charram[offset] & 0x0000ff00) >> 8;
gfx[offset*4+3] = (h1_charram[offset] & 0x000000ff) >> 0; gfx[offset*4+3] = (state->h1_charram[offset] & 0x000000ff) >> 0;
gfx_element_mark_dirty(space->machine->gfx[2], offset/64); //*4/256 gfx_element_mark_dirty(space->machine->gfx[2], offset/64); //*4/256
} }
@ -602,15 +628,15 @@ static ADDRESS_MAP_START( system_h1_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x00000000, 0x001fffff) AM_ROM AM_SHARE("share1") AM_WRITENOP AM_RANGE(0x00000000, 0x001fffff) AM_ROM AM_SHARE("share1") AM_WRITENOP
AM_RANGE(0x01000000, 0x01ffffff) AM_ROM AM_REGION("gfx_data",0x0000000) AM_RANGE(0x01000000, 0x01ffffff) AM_ROM AM_REGION("gfx_data",0x0000000)
AM_RANGE(0x03000000, 0x030fffff) AM_RAM AM_BASE(&h1_vram)//bg vram AM_RANGE(0x03000000, 0x030fffff) AM_RAM AM_BASE_MEMBER(coolridr_state, h1_vram)//bg vram
AM_RANGE(0x03c00000, 0x03c0ffff) AM_RAM_WRITE(sysh1_pal_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x03c00000, 0x03c0ffff) AM_RAM_WRITE(sysh1_pal_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x03d00000, 0x03dfffff) AM_RAM_WRITE(sysh1_char_w) AM_BASE(&h1_charram) //FIXME: half size AM_RANGE(0x03d00000, 0x03dfffff) AM_RAM_WRITE(sysh1_char_w) AM_BASE_MEMBER(coolridr_state, h1_charram) //FIXME: half size
AM_RANGE(0x03e00000, 0x03efffff) AM_RAM_WRITE(sysh1_dma_w) AM_BASE(&framebuffer_vram) //FIXME: not all of it AM_RANGE(0x03e00000, 0x03efffff) AM_RAM_WRITE(sysh1_dma_w) AM_BASE_MEMBER(coolridr_state, framebuffer_vram) //FIXME: not all of it
AM_RANGE(0x03f00000, 0x03f0ffff) AM_RAM AM_SHARE("share3") /*Communication area RAM*/ AM_RANGE(0x03f00000, 0x03f0ffff) AM_RAM AM_SHARE("share3") /*Communication area RAM*/
AM_RANGE(0x03f40000, 0x03f4ffff) AM_RAM AM_BASE(&txt_vram)//text tilemap + "lineram" AM_RANGE(0x03f40000, 0x03f4ffff) AM_RAM AM_BASE_MEMBER(coolridr_state, txt_vram)//text tilemap + "lineram"
AM_RANGE(0x04000000, 0x0400003f) AM_RAM_WRITE(sysh1_txt_blit_w) AM_BASE(&sysh1_txt_blit) AM_RANGE(0x04000000, 0x0400003f) AM_RAM_WRITE(sysh1_txt_blit_w) AM_BASE_MEMBER(coolridr_state, sysh1_txt_blit)
AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE(&sysh1_workram_h) AM_RANGE(0x06000000, 0x060fffff) AM_RAM AM_BASE_MEMBER(coolridr_state, sysh1_workram_h)
AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share1") AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share1")
AM_RANGE(0x60000000, 0x600003ff) AM_WRITENOP AM_RANGE(0x60000000, 0x600003ff) AM_WRITENOP
@ -628,7 +654,7 @@ static ADDRESS_MAP_START( coolridr_submap, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x03208900, 0x03208903) AM_RAM /*???*/ AM_RANGE(0x03208900, 0x03208903) AM_RAM /*???*/
AM_RANGE(0x03300400, 0x03300403) AM_RAM /*irq enable?*/ AM_RANGE(0x03300400, 0x03300403) AM_RAM /*irq enable?*/
AM_RANGE(0x04000000, 0x0400003f) AM_READWRITE(sysh1_unk_r,sysh1_unk_w) AM_BASE(&h1_unk) AM_RANGE(0x04000000, 0x0400003f) AM_READWRITE(sysh1_unk_r,sysh1_unk_w) AM_BASE_MEMBER(coolridr_state, h1_unk)
AM_RANGE(0x04200000, 0x0420003f) AM_RAM /*???*/ AM_RANGE(0x04200000, 0x0420003f) AM_RAM /*???*/
AM_RANGE(0x05000000, 0x05000fff) AM_RAM AM_RANGE(0x05000000, 0x05000fff) AM_RAM
@ -1067,7 +1093,7 @@ static MACHINE_RESET ( coolridr )
cputag_set_input_line(machine, "soundcpu", INPUT_LINE_HALT, ASSERT_LINE); cputag_set_input_line(machine, "soundcpu", INPUT_LINE_HALT, ASSERT_LINE);
} }
static MACHINE_CONFIG_START( coolridr, driver_device ) static MACHINE_CONFIG_START( coolridr, coolridr_state )
MCFG_CPU_ADD("maincpu", SH2, 28000000) // 28 mhz MCFG_CPU_ADD("maincpu", SH2, 28000000) // 28 mhz
MCFG_CPU_PROGRAM_MAP(system_h1_map) MCFG_CPU_PROGRAM_MAP(system_h1_map)
MCFG_CPU_VBLANK_INT("screen",system_h1) MCFG_CPU_VBLANK_INT("screen",system_h1)
@ -1140,21 +1166,23 @@ ROM_END
#if 0 #if 0
static READ32_HANDLER( coolridr_hack1_r ) static READ32_HANDLER( coolridr_hack1_r )
{ {
coolridr_state *state = space->machine->driver_data<coolridr_state>();
offs_t pc = downcast<cpu_device *>(space->cpu)->pc(); offs_t pc = downcast<cpu_device *>(space->cpu)->pc();
if(pc == 0x6012374 || pc == 0x6012392) if(pc == 0x6012374 || pc == 0x6012392)
return 0; return 0;
return sysh1_workram_h[0xd88a4/4]; return state->sysh1_workram_h[0xd88a4/4];
} }
#endif #endif
static READ32_HANDLER( coolridr_hack2_r ) static READ32_HANDLER( coolridr_hack2_r )
{ {
coolridr_state *state = space->machine->driver_data<coolridr_state>();
offs_t pc = downcast<cpu_device *>(space->cpu)->pc(); offs_t pc = downcast<cpu_device *>(space->cpu)->pc();
if(pc == 0x6002cba || pc == 0x6002d42) if(pc == 0x6002cba || pc == 0x6002d42)
return 0; return 0;
return sysh1_workram_h[0xd8894/4]; return state->sysh1_workram_h[0xd8894/4];
} }
static DRIVER_INIT( coolridr ) static DRIVER_INIT( coolridr )

View File

@ -71,21 +71,11 @@ hard drive 3.5 adapter long 3.5 IDE cable 3.5 adapter PCB
#include "video/konicdev.h" #include "video/konicdev.h"
#include "includes/djmain.h" #include "includes/djmain.h"
static int sndram_bank;
static UINT8 *sndram;
static int turntable_select;
static UINT8 turntable_last_pos[2];
static UINT16 turntable_pos[2];
static UINT8 pending_vb_int;
static UINT16 v_ctrl;
static UINT32 obj_regs[0xa0/4];
static const UINT8 *ide_user_password;
static const UINT8 *ide_master_password;
#define DISABLE_VB_INT (!(v_ctrl & 0x8000)) #define DISABLE_VB_INT (!(state->v_ctrl & 0x8000))
@ -114,50 +104,54 @@ static WRITE32_HANDLER( paletteram32_w )
static void sndram_set_bank(running_machine *machine) static void sndram_set_bank(running_machine *machine)
{ {
sndram = machine->region("shared")->base() + 0x80000 * sndram_bank; djmain_state *state = machine->driver_data<djmain_state>();
state->sndram = machine->region("shared")->base() + 0x80000 * state->sndram_bank;
} }
static WRITE32_HANDLER( sndram_bank_w ) static WRITE32_HANDLER( sndram_bank_w )
{ {
djmain_state *state = space->machine->driver_data<djmain_state>();
if (ACCESSING_BITS_16_31) if (ACCESSING_BITS_16_31)
{ {
sndram_bank = (data >> 16) & 0x1f; state->sndram_bank = (data >> 16) & 0x1f;
sndram_set_bank(space->machine); sndram_set_bank(space->machine);
} }
} }
static READ32_HANDLER( sndram_r ) static READ32_HANDLER( sndram_r )
{ {
djmain_state *state = space->machine->driver_data<djmain_state>();
UINT32 data = 0; UINT32 data = 0;
if (ACCESSING_BITS_24_31) if (ACCESSING_BITS_24_31)
data |= sndram[offset * 4] << 24; data |= state->sndram[offset * 4] << 24;
if (ACCESSING_BITS_16_23) if (ACCESSING_BITS_16_23)
data |= sndram[offset * 4 + 1] << 16; data |= state->sndram[offset * 4 + 1] << 16;
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
data |= sndram[offset * 4 + 2] << 8; data |= state->sndram[offset * 4 + 2] << 8;
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
data |= sndram[offset * 4 + 3]; data |= state->sndram[offset * 4 + 3];
return data; return data;
} }
static WRITE32_HANDLER( sndram_w ) static WRITE32_HANDLER( sndram_w )
{ {
djmain_state *state = space->machine->driver_data<djmain_state>();
if (ACCESSING_BITS_24_31) if (ACCESSING_BITS_24_31)
sndram[offset * 4] = data >> 24; state->sndram[offset * 4] = data >> 24;
if (ACCESSING_BITS_16_23) if (ACCESSING_BITS_16_23)
sndram[offset * 4 + 1] = data >> 16; state->sndram[offset * 4 + 1] = data >> 16;
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
sndram[offset * 4 + 2] = data >> 8; state->sndram[offset * 4 + 2] = data >> 8;
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
sndram[offset * 4 + 3] = data; state->sndram[offset * 4 + 3] = data;
} }
@ -188,23 +182,26 @@ static WRITE16_HANDLER( dual539_w )
static READ32_HANDLER( obj_ctrl_r ) static READ32_HANDLER( obj_ctrl_r )
{ {
// read obj_regs[0x0c/4]: unknown djmain_state *state = space->machine->driver_data<djmain_state>();
// read obj_regs[0x24/4]: unknown // read state->obj_regs[0x0c/4]: unknown
// read state->obj_regs[0x24/4]: unknown
return obj_regs[offset]; return state->obj_regs[offset];
} }
static WRITE32_HANDLER( obj_ctrl_w ) static WRITE32_HANDLER( obj_ctrl_w )
{ {
// write obj_regs[0x28/4]: bank for rom readthrough djmain_state *state = space->machine->driver_data<djmain_state>();
// write state->obj_regs[0x28/4]: bank for rom readthrough
COMBINE_DATA(&obj_regs[offset]); COMBINE_DATA(&state->obj_regs[offset]);
} }
static READ32_HANDLER( obj_rom_r ) static READ32_HANDLER( obj_rom_r )
{ {
djmain_state *state = space->machine->driver_data<djmain_state>();
UINT8 *mem8 = space->machine->region("gfx1")->base(); UINT8 *mem8 = space->machine->region("gfx1")->base();
int bank = obj_regs[0x28/4] >> 16; int bank = state->obj_regs[0x28/4] >> 16;
offset += bank * 0x200; offset += bank * 0x200;
offset *= 4; offset *= 4;
@ -223,15 +220,16 @@ static READ32_HANDLER( obj_rom_r )
static WRITE32_HANDLER( v_ctrl_w ) static WRITE32_HANDLER( v_ctrl_w )
{ {
djmain_state *state = space->machine->driver_data<djmain_state>();
if (ACCESSING_BITS_16_31) if (ACCESSING_BITS_16_31)
{ {
data >>= 16; data >>= 16;
mem_mask >>= 16; mem_mask >>= 16;
COMBINE_DATA(&v_ctrl); COMBINE_DATA(&state->v_ctrl);
if (pending_vb_int && !DISABLE_VB_INT) if (state->pending_vb_int && !DISABLE_VB_INT)
{ {
pending_vb_int = 0; state->pending_vb_int = 0;
cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_4, HOLD_LINE); cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_4, HOLD_LINE);
} }
} }
@ -239,6 +237,7 @@ static WRITE32_HANDLER( v_ctrl_w )
static READ32_HANDLER( v_rom_r ) static READ32_HANDLER( v_rom_r )
{ {
djmain_state *state = space->machine->driver_data<djmain_state>();
device_t *k056832 = space->machine->device("k056832"); device_t *k056832 = space->machine->device("k056832");
UINT8 *mem8 = space->machine->region("gfx2")->base(); UINT8 *mem8 = space->machine->region("gfx2")->base();
int bank = k056832_word_r(k056832, 0x34/2, 0xffff); int bank = k056832_word_r(k056832, 0x34/2, 0xffff);
@ -250,7 +249,7 @@ static READ32_HANDLER( v_rom_r )
offset += bank * 0x800 * 4; offset += bank * 0x800 * 4;
if (v_ctrl & 0x020) if (state->v_ctrl & 0x020)
offset += 0x800 * 2; offset += 0x800 * 2;
return mem8[offset] * 0x01010000; return mem8[offset] * 0x01010000;
@ -273,6 +272,7 @@ static READ8_HANDLER( inp2_r )
static READ32_HANDLER( turntable_r ) static READ32_HANDLER( turntable_r )
{ {
djmain_state *state = space->machine->driver_data<djmain_state>();
UINT32 result = 0; UINT32 result = 0;
static const char *const ttnames[] = { "TT1", "TT2" }; static const char *const ttnames[] = { "TT1", "TT2" };
@ -281,17 +281,17 @@ static READ32_HANDLER( turntable_r )
UINT8 pos; UINT8 pos;
int delta; int delta;
pos = input_port_read_safe(space->machine, ttnames[turntable_select], 0); pos = input_port_read_safe(space->machine, ttnames[state->turntable_select], 0);
delta = pos - turntable_last_pos[turntable_select]; delta = pos - state->turntable_last_pos[state->turntable_select];
if (delta < -128) if (delta < -128)
delta += 256; delta += 256;
if (delta > 128) if (delta > 128)
delta -= 256; delta -= 256;
turntable_pos[turntable_select] += delta * 70; state->turntable_pos[state->turntable_select] += delta * 70;
turntable_last_pos[turntable_select] = pos; state->turntable_last_pos[state->turntable_select] = pos;
result |= turntable_pos[turntable_select] & 0xff00; result |= state->turntable_pos[state->turntable_select] & 0xff00;
} }
return result; return result;
@ -299,8 +299,9 @@ static READ32_HANDLER( turntable_r )
static WRITE32_HANDLER( turntable_select_w ) static WRITE32_HANDLER( turntable_select_w )
{ {
djmain_state *state = space->machine->driver_data<djmain_state>();
if (ACCESSING_BITS_16_23) if (ACCESSING_BITS_16_23)
turntable_select = (data >> 19) & 1; state->turntable_select = (data >> 19) & 1;
} }
@ -427,11 +428,12 @@ static WRITE32_HANDLER( unknownc02000_w )
static INTERRUPT_GEN( vb_interrupt ) static INTERRUPT_GEN( vb_interrupt )
{ {
pending_vb_int = 0; djmain_state *state = device->machine->driver_data<djmain_state>();
state->pending_vb_int = 0;
if (DISABLE_VB_INT) if (DISABLE_VB_INT)
{ {
pending_vb_int = 1; state->pending_vb_int = 1;
return; return;
} }
@ -481,7 +483,7 @@ static ADDRESS_MAP_START( memory_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x5d6000, 0x5d6003) AM_WRITE(sndram_bank_w) // SOUND RAM bank AM_RANGE(0x5d6000, 0x5d6003) AM_WRITE(sndram_bank_w) // SOUND RAM bank
AM_RANGE(0x5e0000, 0x5e0003) AM_READWRITE(turntable_r, turntable_select_w) // input port control (turn tables) AM_RANGE(0x5e0000, 0x5e0003) AM_READWRITE(turntable_r, turntable_select_w) // input port control (turn tables)
AM_RANGE(0x600000, 0x601fff) AM_READ(v_rom_r) // VIDEO ROM readthrough (for POST) AM_RANGE(0x600000, 0x601fff) AM_READ(v_rom_r) // VIDEO ROM readthrough (for POST)
AM_RANGE(0x801000, 0x8017ff) AM_RAM AM_BASE(&djmain_obj_ram) // OBJECT RAM AM_RANGE(0x801000, 0x8017ff) AM_RAM AM_BASE_MEMBER(djmain_state, obj_ram) // OBJECT RAM
AM_RANGE(0x802000, 0x802fff) AM_WRITE(unknown802000_w) // ?? AM_RANGE(0x802000, 0x802fff) AM_WRITE(unknown802000_w) // ??
AM_RANGE(0x803000, 0x80309f) AM_READWRITE(obj_ctrl_r, obj_ctrl_w) // OBJECT REGS AM_RANGE(0x803000, 0x80309f) AM_READWRITE(obj_ctrl_r, obj_ctrl_w) // OBJECT REGS
AM_RANGE(0x803800, 0x803fff) AM_READ(obj_rom_r) // OBJECT ROM readthrough (for POST) AM_RANGE(0x803800, 0x803fff) AM_READ(obj_rom_r) // OBJECT ROM readthrough (for POST)
@ -1430,17 +1432,18 @@ static STATE_POSTLOAD( djmain_postload )
static MACHINE_START( djmain ) static MACHINE_START( djmain )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
device_t *ide = machine->device("ide"); device_t *ide = machine->device("ide");
if (ide != NULL && ide_master_password != NULL) if (ide != NULL && state->ide_master_password != NULL)
ide_set_master_password(ide, ide_master_password); ide_set_master_password(ide, state->ide_master_password);
if (ide != NULL && ide_user_password != NULL) if (ide != NULL && state->ide_user_password != NULL)
ide_set_user_password(ide, ide_user_password); ide_set_user_password(ide, state->ide_user_password);
state_save_register_global(machine, sndram_bank); state_save_register_global(machine, state->sndram_bank);
state_save_register_global(machine, pending_vb_int); state_save_register_global(machine, state->pending_vb_int);
state_save_register_global(machine, v_ctrl); state_save_register_global(machine, state->v_ctrl);
state_save_register_global_array(machine, obj_regs); state_save_register_global_array(machine, state->obj_regs);
machine->state().register_postload(djmain_postload, NULL); machine->state().register_postload(djmain_postload, NULL);
} }
@ -1448,8 +1451,9 @@ static MACHINE_START( djmain )
static MACHINE_RESET( djmain ) static MACHINE_RESET( djmain )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
/* reset sound ram bank */ /* reset sound ram bank */
sndram_bank = 0; state->sndram_bank = 0;
sndram_set_bank(machine); sndram_set_bank(machine);
/* reset the IDE controller */ /* reset the IDE controller */
@ -1478,7 +1482,7 @@ static const k056832_interface djmain_k056832_intf =
djmain_tile_callback, "none" djmain_tile_callback, "none"
}; };
static MACHINE_CONFIG_START( djmain, driver_device ) static MACHINE_CONFIG_START( djmain, djmain_state )
/* basic machine hardware */ /* basic machine hardware */
// popn3 works 9.6 MHz or slower in some songs */ // popn3 works 9.6 MHz or slower in some songs */
@ -2032,8 +2036,9 @@ ROM_END
static DRIVER_INIT( beatmania ) static DRIVER_INIT( beatmania )
{ {
ide_master_password = NULL; djmain_state *state = machine->driver_data<djmain_state>();
ide_user_password = NULL; state->ide_master_password = NULL;
state->ide_user_password = NULL;
} }
static const UINT8 beatmania_master_password[2 + 32] = static const UINT8 beatmania_master_password[2 + 32] =
@ -2047,6 +2052,7 @@ static const UINT8 beatmania_master_password[2 + 32] =
static DRIVER_INIT( hmcompmx ) static DRIVER_INIT( hmcompmx )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 hmcompmx_user_password[2 + 32] = static const UINT8 hmcompmx_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2058,12 +2064,13 @@ static DRIVER_INIT( hmcompmx )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = hmcompmx_user_password; state->ide_user_password = hmcompmx_user_password;
} }
static DRIVER_INIT( bm4thmix ) static DRIVER_INIT( bm4thmix )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bm4thmix_user_password[2 + 32] = static const UINT8 bm4thmix_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2075,11 +2082,12 @@ static DRIVER_INIT( bm4thmix )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_user_password = bm4thmix_user_password; state->ide_user_password = bm4thmix_user_password;
} }
static DRIVER_INIT( bm5thmix ) static DRIVER_INIT( bm5thmix )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bm5thmix_user_password[2 + 32] = static const UINT8 bm5thmix_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2091,12 +2099,13 @@ static DRIVER_INIT( bm5thmix )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = bm5thmix_user_password; state->ide_user_password = bm5thmix_user_password;
} }
static DRIVER_INIT( bmclubmx ) static DRIVER_INIT( bmclubmx )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bmclubmx_user_password[2 + 32] = static const UINT8 bmclubmx_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2108,13 +2117,14 @@ static DRIVER_INIT( bmclubmx )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = bmclubmx_user_password; state->ide_user_password = bmclubmx_user_password;
} }
static DRIVER_INIT( bmcompm2 ) static DRIVER_INIT( bmcompm2 )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bmcompm2_user_password[2 + 32] = static const UINT8 bmcompm2_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2126,12 +2136,13 @@ static DRIVER_INIT( bmcompm2 )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = bmcompm2_user_password; state->ide_user_password = bmcompm2_user_password;
} }
static DRIVER_INIT( hmcompm2 ) static DRIVER_INIT( hmcompm2 )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 hmcompm2_user_password[2 + 32] = static const UINT8 hmcompm2_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2143,12 +2154,13 @@ static DRIVER_INIT( hmcompm2 )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = hmcompm2_user_password; state->ide_user_password = hmcompm2_user_password;
} }
static DRIVER_INIT( bmdct ) static DRIVER_INIT( bmdct )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bmdct_user_password[2 + 32] = static const UINT8 bmdct_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2160,12 +2172,13 @@ static DRIVER_INIT( bmdct )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = bmdct_user_password; state->ide_user_password = bmdct_user_password;
} }
static DRIVER_INIT( bmcorerm ) static DRIVER_INIT( bmcorerm )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bmcorerm_user_password[2 + 32] = static const UINT8 bmcorerm_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2177,12 +2190,13 @@ static DRIVER_INIT( bmcorerm )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = bmcorerm_user_password; state->ide_user_password = bmcorerm_user_password;
} }
static DRIVER_INIT( bm6thmix ) static DRIVER_INIT( bm6thmix )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bm6thmix_user_password[2 + 32] = static const UINT8 bm6thmix_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2194,12 +2208,13 @@ static DRIVER_INIT( bm6thmix )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = bm6thmix_user_password; state->ide_user_password = bm6thmix_user_password;
} }
static DRIVER_INIT( bm7thmix ) static DRIVER_INIT( bm7thmix )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bm7thmix_user_password[2 + 32] = static const UINT8 bm7thmix_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2211,12 +2226,13 @@ static DRIVER_INIT( bm7thmix )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = bm7thmix_user_password; state->ide_user_password = bm7thmix_user_password;
} }
static DRIVER_INIT( bmfinal ) static DRIVER_INIT( bmfinal )
{ {
djmain_state *state = machine->driver_data<djmain_state>();
static const UINT8 bmfinal_user_password[2 + 32] = static const UINT8 bmfinal_user_password[2 + 32] =
{ {
0x00, 0x00, 0x00, 0x00,
@ -2228,8 +2244,8 @@ static DRIVER_INIT( bmfinal )
DRIVER_INIT_CALL(beatmania); DRIVER_INIT_CALL(beatmania);
ide_master_password = beatmania_master_password; state->ide_master_password = beatmania_master_password;
ide_user_password = bmfinal_user_password; state->ide_user_password = bmfinal_user_password;
} }

View File

@ -121,13 +121,11 @@ static READ8_HANDLER( boggy84_custom_io_r )
Imago sprites DMA Imago sprites DMA
*/ */
static UINT8 imago_sprites[0x800*3];
static UINT16 imago_sprites_address;
static UINT8 imago_sprites_bank = 0;
static MACHINE_START( imago ) static MACHINE_START( imago )
{ {
gfx_element_set_source(machine->gfx[1], imago_sprites); fastfred_state *state = machine->driver_data<fastfred_state>();
gfx_element_set_source(machine->gfx[1], state->imago_sprites);
} }
static WRITE8_HANDLER( imago_dma_irq_w ) static WRITE8_HANDLER( imago_dma_irq_w )
@ -137,40 +135,43 @@ static WRITE8_HANDLER( imago_dma_irq_w )
static WRITE8_HANDLER( imago_sprites_bank_w ) static WRITE8_HANDLER( imago_sprites_bank_w )
{ {
imago_sprites_bank = (data & 2) >> 1; fastfred_state *state = space->machine->driver_data<fastfred_state>();
state->imago_sprites_bank = (data & 2) >> 1;
} }
static WRITE8_HANDLER( imago_sprites_dma_w ) static WRITE8_HANDLER( imago_sprites_dma_w )
{ {
fastfred_state *state = space->machine->driver_data<fastfred_state>();
UINT8 *rom = (UINT8 *)space->machine->region("gfx2")->base(); UINT8 *rom = (UINT8 *)space->machine->region("gfx2")->base();
UINT8 sprites_data; UINT8 sprites_data;
sprites_data = rom[imago_sprites_address + 0x2000*0 + imago_sprites_bank * 0x1000]; sprites_data = rom[state->imago_sprites_address + 0x2000*0 + state->imago_sprites_bank * 0x1000];
imago_sprites[offset + 0x800*0] = sprites_data; state->imago_sprites[offset + 0x800*0] = sprites_data;
sprites_data = rom[imago_sprites_address + 0x2000*1 + imago_sprites_bank * 0x1000]; sprites_data = rom[state->imago_sprites_address + 0x2000*1 + state->imago_sprites_bank * 0x1000];
imago_sprites[offset + 0x800*1] = sprites_data; state->imago_sprites[offset + 0x800*1] = sprites_data;
sprites_data = rom[imago_sprites_address + 0x2000*2 + imago_sprites_bank * 0x1000]; sprites_data = rom[state->imago_sprites_address + 0x2000*2 + state->imago_sprites_bank * 0x1000];
imago_sprites[offset + 0x800*2] = sprites_data; state->imago_sprites[offset + 0x800*2] = sprites_data;
gfx_element_mark_dirty(space->machine->gfx[1], offset/32); gfx_element_mark_dirty(space->machine->gfx[1], offset/32);
} }
static READ8_HANDLER( imago_sprites_offset_r ) static READ8_HANDLER( imago_sprites_offset_r )
{ {
imago_sprites_address = offset; fastfred_state *state = space->machine->driver_data<fastfred_state>();
state->imago_sprites_address = offset;
return 0xff; //not really used return 0xff; //not really used
} }
static ADDRESS_MAP_START( fastfred_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( fastfred_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xbfff) AM_ROM AM_RANGE(0x0000, 0xbfff) AM_ROM
AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_RANGE(0xc000, 0xc7ff) AM_RAM
AM_RANGE(0xd000, 0xd3ff) AM_MIRROR(0x400) AM_RAM_WRITE(fastfred_videoram_w) AM_BASE(&fastfred_videoram) AM_RANGE(0xd000, 0xd3ff) AM_MIRROR(0x400) AM_RAM_WRITE(fastfred_videoram_w) AM_BASE_MEMBER(fastfred_state, videoram)
AM_RANGE(0xd800, 0xd83f) AM_RAM_WRITE(fastfred_attributes_w) AM_BASE(&fastfred_attributesram) AM_RANGE(0xd800, 0xd83f) AM_RAM_WRITE(fastfred_attributes_w) AM_BASE_MEMBER(fastfred_state, attributesram)
AM_RANGE(0xd840, 0xd85f) AM_RAM AM_BASE(&fastfred_spriteram) AM_SIZE(&fastfred_spriteram_size) AM_RANGE(0xd840, 0xd85f) AM_RAM AM_BASE_MEMBER(fastfred_state, spriteram) AM_SIZE_MEMBER(fastfred_state, spriteram_size)
AM_RANGE(0xd860, 0xdbff) AM_RAM // Unused, but initialized AM_RANGE(0xd860, 0xdbff) AM_RAM // Unused, but initialized
AM_RANGE(0xe000, 0xe000) AM_READ_PORT("BUTTONS") AM_WRITEONLY AM_BASE(&fastfred_background_color) AM_RANGE(0xe000, 0xe000) AM_READ_PORT("BUTTONS") AM_WRITEONLY AM_BASE_MEMBER(fastfred_state, background_color)
AM_RANGE(0xe800, 0xe800) AM_READ_PORT("JOYS") AM_RANGE(0xe800, 0xe800) AM_READ_PORT("JOYS")
AM_RANGE(0xf000, 0xf000) AM_READ_PORT("DSW") AM_WRITENOP AM_RANGE(0xf000, 0xf000) AM_READ_PORT("DSW") AM_WRITENOP
AM_RANGE(0xf001, 0xf001) AM_WRITE(interrupt_enable_w) AM_RANGE(0xf001, 0xf001) AM_WRITE(interrupt_enable_w)
@ -189,11 +190,11 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( jumpcoas_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( jumpcoas_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_RANGE(0xc000, 0xc7ff) AM_RAM
AM_RANGE(0xd000, 0xd03f) AM_RAM_WRITE(fastfred_attributes_w) AM_BASE(&fastfred_attributesram) AM_RANGE(0xd000, 0xd03f) AM_RAM_WRITE(fastfred_attributes_w) AM_BASE_MEMBER(fastfred_state, attributesram)
AM_RANGE(0xd040, 0xd05f) AM_RAM AM_BASE(&fastfred_spriteram) AM_SIZE(&fastfred_spriteram_size) AM_RANGE(0xd040, 0xd05f) AM_RAM AM_BASE_MEMBER(fastfred_state, spriteram) AM_SIZE_MEMBER(fastfred_state, spriteram_size)
AM_RANGE(0xd060, 0xd3ff) AM_RAM AM_RANGE(0xd060, 0xd3ff) AM_RAM
AM_RANGE(0xd800, 0xdbff) AM_MIRROR(0x400) AM_RAM_WRITE(fastfred_videoram_w) AM_BASE(&fastfred_videoram) AM_RANGE(0xd800, 0xdbff) AM_MIRROR(0x400) AM_RAM_WRITE(fastfred_videoram_w) AM_BASE_MEMBER(fastfred_state, videoram)
AM_RANGE(0xe000, 0xe000) AM_WRITEONLY AM_BASE(&fastfred_background_color) AM_RANGE(0xe000, 0xe000) AM_WRITEONLY AM_BASE_MEMBER(fastfred_state, background_color)
AM_RANGE(0xe800, 0xe800) AM_READ_PORT("DSW1") AM_RANGE(0xe800, 0xe800) AM_READ_PORT("DSW1")
AM_RANGE(0xe801, 0xe801) AM_READ_PORT("DSW2") AM_RANGE(0xe801, 0xe801) AM_READ_PORT("DSW2")
AM_RANGE(0xe802, 0xe802) AM_READ_PORT("BUTTONS") AM_RANGE(0xe802, 0xe802) AM_READ_PORT("BUTTONS")
@ -220,10 +221,10 @@ static ADDRESS_MAP_START( imago_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xb000, 0xb3ff) AM_RAM // same fg videoram (which one of the 2 is really used?) AM_RANGE(0xb000, 0xb3ff) AM_RAM // same fg videoram (which one of the 2 is really used?)
AM_RANGE(0xb800, 0xbfff) AM_RAM_WRITE(imago_sprites_dma_w) AM_RANGE(0xb800, 0xbfff) AM_RAM_WRITE(imago_sprites_dma_w)
AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_RANGE(0xc000, 0xc7ff) AM_RAM
AM_RANGE(0xc800, 0xcbff) AM_RAM_WRITE(imago_fg_videoram_w) AM_BASE(&imago_fg_videoram) AM_RANGE(0xc800, 0xcbff) AM_RAM_WRITE(imago_fg_videoram_w) AM_BASE_MEMBER(fastfred_state, imago_fg_videoram)
AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(fastfred_videoram_w) AM_BASE(&fastfred_videoram) AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(fastfred_videoram_w) AM_BASE_MEMBER(fastfred_state, videoram)
AM_RANGE(0xd800, 0xd83f) AM_RAM_WRITE(fastfred_attributes_w) AM_BASE(&fastfred_attributesram) AM_RANGE(0xd800, 0xd83f) AM_RAM_WRITE(fastfred_attributes_w) AM_BASE_MEMBER(fastfred_state, attributesram)
AM_RANGE(0xd840, 0xd85f) AM_RAM AM_BASE(&fastfred_spriteram) AM_SIZE(&fastfred_spriteram_size) AM_RANGE(0xd840, 0xd85f) AM_RAM AM_BASE_MEMBER(fastfred_state, spriteram) AM_SIZE_MEMBER(fastfred_state, spriteram_size)
AM_RANGE(0xd860, 0xd8ff) AM_RAM // Unused, but initialized AM_RANGE(0xd860, 0xd8ff) AM_RAM // Unused, but initialized
AM_RANGE(0xe000, 0xe000) AM_READ_PORT("BUTTONS") AM_RANGE(0xe000, 0xe000) AM_READ_PORT("BUTTONS")
AM_RANGE(0xe800, 0xe800) AM_READ_PORT("JOYS") AM_RANGE(0xe800, 0xe800) AM_READ_PORT("JOYS")
@ -616,7 +617,7 @@ GFXDECODE_END
#define CLOCK 18432000 /* The crystal is 18.432MHz */ #define CLOCK 18432000 /* The crystal is 18.432MHz */
static MACHINE_CONFIG_START( fastfred, driver_device ) static MACHINE_CONFIG_START( fastfred, fastfred_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, CLOCK/6) /* 3.072 MHz */ MCFG_CPU_ADD("maincpu", Z80, CLOCK/6) /* 3.072 MHz */
@ -976,48 +977,55 @@ ROM_END
static DRIVER_INIT( flyboy ) static DRIVER_INIT( flyboy )
{ {
fastfred_state *state = machine->driver_data<fastfred_state>();
memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc085, 0xc099, 0, 0, flyboy_custom1_io_r); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc085, 0xc099, 0, 0, flyboy_custom1_io_r);
memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc8fb, 0xc900, 0, 0, flyboy_custom2_io_r); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc8fb, 0xc900, 0, 0, flyboy_custom2_io_r);
fastfred_hardware_type = 1; state->hardware_type = 1;
} }
static DRIVER_INIT( flyboyb ) static DRIVER_INIT( flyboyb )
{ {
fastfred_hardware_type = 1; fastfred_state *state = machine->driver_data<fastfred_state>();
state->hardware_type = 1;
} }
static DRIVER_INIT( fastfred ) static DRIVER_INIT( fastfred )
{ {
fastfred_state *state = machine->driver_data<fastfred_state>();
memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0, fastfred_custom_io_r); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0, fastfred_custom_io_r);
memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0); memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0);
fastfred_hardware_type = 1; state->hardware_type = 1;
} }
static DRIVER_INIT( jumpcoas ) static DRIVER_INIT( jumpcoas )
{ {
fastfred_state *state = machine->driver_data<fastfred_state>();
memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0, jumpcoas_custom_io_r); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0, jumpcoas_custom_io_r);
memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0); memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0);
fastfred_hardware_type = 0; state->hardware_type = 0;
} }
static DRIVER_INIT( boggy84b ) static DRIVER_INIT( boggy84b )
{ {
fastfred_state *state = machine->driver_data<fastfred_state>();
memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0, jumpcoas_custom_io_r); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0, jumpcoas_custom_io_r);
memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0); memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0);
fastfred_hardware_type = 2; state->hardware_type = 2;
} }
static DRIVER_INIT( boggy84 ) static DRIVER_INIT( boggy84 )
{ {
fastfred_state *state = machine->driver_data<fastfred_state>();
memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0, boggy84_custom_io_r); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0, boggy84_custom_io_r);
memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0); memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc800, 0xcfff, 0, 0);
fastfred_hardware_type = 2; state->hardware_type = 2;
} }
static DRIVER_INIT( imago ) static DRIVER_INIT( imago )
{ {
fastfred_hardware_type = 3; fastfred_state *state = machine->driver_data<fastfred_state>();
state->hardware_type = 3;
} }
GAME( 1982, flyboy, 0, fastfred, flyboy, flyboy, ROT90, "Kaneko", "Fly-Boy", 0 ) GAME( 1982, flyboy, 0, fastfred, flyboy, flyboy, ROT90, "Kaneko", "Fly-Boy", 0 )

File diff suppressed because it is too large Load Diff

View File

@ -43,25 +43,36 @@ Dumping Notes:
#include "cpu/z80/z80.h" #include "cpu/z80/z80.h"
#include "machine/laserdsc.h" #include "machine/laserdsc.h"
class gpworld_state : public driver_device
{
public:
gpworld_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 nmi_enable;
UINT8 start_lamp;
UINT8 ldp_read_latch;
UINT8 ldp_write_latch;
UINT8 brake_gas;
UINT8* tile_RAM;
UINT8* sprite_RAM;
UINT8* palette_RAM;
device_t *laserdisc;
};
/* Assumed to be the same as segald hardware */ /* Assumed to be the same as segald hardware */
#define GUESSED_CLOCK (5000000) #define GUESSED_CLOCK (5000000)
static UINT8 nmi_enable;
static UINT8 start_lamp;
static UINT8 ldp_read_latch;
static UINT8 ldp_write_latch;
static UINT8 brake_gas;
static UINT8* tile_RAM;
static UINT8* sprite_RAM;
static UINT8* palette_RAM;
static device_t *laserdisc;
/* VIDEO GOODS */ /* VIDEO GOODS */
static void gpworld_draw_tiles(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) static void gpworld_draw_tiles(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
{ {
gpworld_state *state = machine->driver_data<gpworld_state>();
UINT8 characterX, characterY; UINT8 characterX, characterY;
/* Temporarily set to 64 wide to accommodate two screens */ /* Temporarily set to 64 wide to accommodate two screens */
@ -71,7 +82,7 @@ static void gpworld_draw_tiles(running_machine *machine, bitmap_t *bitmap,const
{ {
int current_screen_character = (characterY*64) + characterX; int current_screen_character = (characterY*64) + characterX;
drawgfx_transpen(bitmap, cliprect, machine->gfx[0], tile_RAM[current_screen_character], drawgfx_transpen(bitmap, cliprect, machine->gfx[0], state->tile_RAM[current_screen_character],
characterY, 0, 0, characterX*8, characterY*8, 0); characterY, 0, 0, characterX*8, characterY*8, 0);
} }
} }
@ -96,6 +107,7 @@ INLINE void draw_pixel(bitmap_t *bitmap,const rectangle *cliprect,int x,int y,in
static void gpworld_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void gpworld_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{ {
gpworld_state *state = machine->driver_data<gpworld_state>();
const int SPR_Y_TOP = 0; const int SPR_Y_TOP = 0;
const int SPR_Y_BOTTOM = 1; const int SPR_Y_BOTTOM = 1;
const int SPR_X_LO = 2; const int SPR_X_LO = 2;
@ -113,7 +125,7 @@ static void gpworld_draw_sprites(running_machine *machine, bitmap_t *bitmap, con
/* Heisted from Daphne which heisted it from MAME */ /* Heisted from Daphne which heisted it from MAME */
for (i = 0; i < 0x800; i += 8) for (i = 0; i < 0x800; i += 8)
{ {
UINT8 *spr_reg = sprite_RAM + i; UINT8 *spr_reg = state->sprite_RAM + i;
if (spr_reg[SPR_Y_BOTTOM] && spr_reg[SPR_X_LO] != 0xff) if (spr_reg[SPR_Y_BOTTOM] && spr_reg[SPR_X_LO] != 0xff)
{ {
@ -217,7 +229,8 @@ static VIDEO_UPDATE( gpworld )
static MACHINE_START( gpworld ) static MACHINE_START( gpworld )
{ {
laserdisc = machine->device("laserdisc"); gpworld_state *state = machine->driver_data<gpworld_state>();
state->laserdisc = machine->device("laserdisc");
} }
@ -225,12 +238,14 @@ static MACHINE_START( gpworld )
/* READS */ /* READS */
static READ8_HANDLER( ldp_read ) static READ8_HANDLER( ldp_read )
{ {
return ldp_read_latch; gpworld_state *state = space->machine->driver_data<gpworld_state>();
return state->ldp_read_latch;
} }
static READ8_HANDLER( pedal_in ) static READ8_HANDLER( pedal_in )
{ {
if (brake_gas) gpworld_state *state = space->machine->driver_data<gpworld_state>();
if (state->brake_gas)
return input_port_read(space->machine, "INACCEL"); return input_port_read(space->machine, "INACCEL");
return input_port_read(space->machine, "INBRAKE"); return input_port_read(space->machine, "INBRAKE");
@ -240,37 +255,41 @@ static READ8_HANDLER( pedal_in )
/* WRITES */ /* WRITES */
static WRITE8_HANDLER( ldp_write ) static WRITE8_HANDLER( ldp_write )
{ {
ldp_write_latch = data; gpworld_state *state = space->machine->driver_data<gpworld_state>();
state->ldp_write_latch = data;
} }
static WRITE8_HANDLER( misc_io_write ) static WRITE8_HANDLER( misc_io_write )
{ {
start_lamp = (data & 0x04) >> 1; gpworld_state *state = space->machine->driver_data<gpworld_state>();
nmi_enable = (data & 0x40) >> 6; state->start_lamp = (data & 0x04) >> 1;
state->nmi_enable = (data & 0x40) >> 6;
/* dunno = (data & 0x80) >> 7; */ //coin counter??? /* dunno = (data & 0x80) >> 7; */ //coin counter???
logerror("NMI : %x (0x%x)\n", nmi_enable, data); logerror("NMI : %x (0x%x)\n", state->nmi_enable, data);
} }
static WRITE8_HANDLER( brake_gas_write ) static WRITE8_HANDLER( brake_gas_write )
{ {
brake_gas = data & 0x01; gpworld_state *state = space->machine->driver_data<gpworld_state>();
state->brake_gas = data & 0x01;
} }
static WRITE8_HANDLER( palette_write ) static WRITE8_HANDLER( palette_write )
{ {
gpworld_state *state = space->machine->driver_data<gpworld_state>();
/* This is all just a (bad) guess */ /* This is all just a (bad) guess */
int pal_index, r, g, b, a; int pal_index, r, g, b, a;
palette_RAM[offset] = data; state->palette_RAM[offset] = data;
/* "Round down" to the nearest palette entry */ /* "Round down" to the nearest palette entry */
pal_index = offset & 0xffe; pal_index = offset & 0xffe;
g = (palette_RAM[pal_index] & 0xf0) << 0; g = (state->palette_RAM[pal_index] & 0xf0) << 0;
b = (palette_RAM[pal_index] & 0x0f) << 4; b = (state->palette_RAM[pal_index] & 0x0f) << 4;
r = (palette_RAM[pal_index+1] & 0x0f) << 4; r = (state->palette_RAM[pal_index+1] & 0x0f) << 4;
a = (palette_RAM[pal_index+1] & 0x80) ? 0 : 255; /* guess */ a = (state->palette_RAM[pal_index+1] & 0x80) ? 0 : 255; /* guess */
/* logerror("PAL WRITE index : %x rgb : %d %d %d (real %x) at %x\n", pal_index, r,g,b, data, offset); */ /* logerror("PAL WRITE index : %x rgb : %d %d %d (real %x) at %x\n", pal_index, r,g,b, data, offset); */
@ -280,9 +299,9 @@ static WRITE8_HANDLER( palette_write )
/* PROGRAM MAP */ /* PROGRAM MAP */
static ADDRESS_MAP_START( mainmem, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mainmem, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000,0xbfff) AM_ROM AM_RANGE(0x0000,0xbfff) AM_ROM
AM_RANGE(0xc000,0xc7ff) AM_RAM AM_BASE(&sprite_RAM) AM_RANGE(0xc000,0xc7ff) AM_RAM AM_BASE_MEMBER(gpworld_state, sprite_RAM)
AM_RANGE(0xc800,0xcfff) AM_WRITE(palette_write) AM_BASE(&palette_RAM) /* The memory test reads at 0xc800 */ AM_RANGE(0xc800,0xcfff) AM_WRITE(palette_write) AM_BASE_MEMBER(gpworld_state, palette_RAM) /* The memory test reads at 0xc800 */
AM_RANGE(0xd000,0xd7ff) AM_RAM AM_BASE(&tile_RAM) AM_RANGE(0xd000,0xd7ff) AM_RAM AM_BASE_MEMBER(gpworld_state, tile_RAM)
AM_RANGE(0xd800,0xd800) AM_READWRITE(ldp_read,ldp_write) AM_RANGE(0xd800,0xd800) AM_READWRITE(ldp_read,ldp_write)
/* AM_RANGE(0xd801,0xd801) AM_READ(???) */ /* AM_RANGE(0xd801,0xd801) AM_READ(???) */
AM_RANGE(0xda00,0xda00) AM_READ_PORT("INWHEEL") //8255 here.... AM_RANGE(0xda00,0xda00) AM_READ_PORT("INWHEEL") //8255 here....
@ -412,11 +431,12 @@ static TIMER_CALLBACK( irq_stop )
static INTERRUPT_GEN( vblank_callback_gpworld ) static INTERRUPT_GEN( vblank_callback_gpworld )
{ {
gpworld_state *state = device->machine->driver_data<gpworld_state>();
/* Do an NMI if the enabled bit is set */ /* Do an NMI if the enabled bit is set */
if (nmi_enable) if (state->nmi_enable)
{ {
laserdisc_data_w(laserdisc,ldp_write_latch); laserdisc_data_w(state->laserdisc,state->ldp_write_latch);
ldp_read_latch = laserdisc_data_r(laserdisc); state->ldp_read_latch = laserdisc_data_r(state->laserdisc);
cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE); cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
} }
@ -441,7 +461,7 @@ static GFXDECODE_START( gpworld )
GFXDECODE_END GFXDECODE_END
/* DRIVER */ /* DRIVER */
static MACHINE_CONFIG_START( gpworld, driver_device ) static MACHINE_CONFIG_START( gpworld, gpworld_state )
/* main cpu */ /* main cpu */
MCFG_CPU_ADD("maincpu", Z80, GUESSED_CLOCK) MCFG_CPU_ADD("maincpu", Z80, GUESSED_CLOCK)
@ -507,10 +527,11 @@ ROM_END
static DRIVER_INIT( gpworld ) static DRIVER_INIT( gpworld )
{ {
nmi_enable = 0; gpworld_state *state = machine->driver_data<gpworld_state>();
start_lamp = 0; state->nmi_enable = 0;
brake_gas = 0; state->start_lamp = 0;
ldp_write_latch = ldp_read_latch = 0; state->brake_gas = 0;
state->ldp_write_latch = state->ldp_read_latch = 0;
} }

View File

@ -237,9 +237,6 @@ Hang Pilot (uses an unknown but similar video board) 12W
static UINT32 *work_ram; static UINT32 *work_ram;
UINT8 gticlub_led_reg0;
UINT8 gticlub_led_reg1;
static WRITE32_HANDLER( paletteram32_w ) static WRITE32_HANDLER( paletteram32_w )
{ {
@ -258,39 +255,6 @@ static void voodoo_vblank_1(device_t *device, int param)
cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_IRQ1, param ? ASSERT_LINE : CLEAR_LINE); cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_IRQ1, param ? ASSERT_LINE : CLEAR_LINE);
} }
static VIDEO_UPDATE( hangplt )
{
bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
if (strcmp(screen->tag(), "lscreen") == 0)
{
device_t *k001604 = screen->machine->device("k001604_1");
device_t *voodoo = screen->machine->device("voodoo0");
// k001604_draw_back_layer(k001604, bitmap, cliprect);
voodoo_update(voodoo, bitmap, cliprect);
k001604_draw_front_layer(k001604, bitmap, cliprect);
}
else if (strcmp(screen->tag(), "rscreen") == 0)
{
device_t *k001604 = screen->machine->device("k001604_2");
device_t *voodoo = screen->machine->device("voodoo1");
// k001604_draw_back_layer(k001604, bitmap, cliprect);
voodoo_update(voodoo, bitmap, cliprect);
k001604_draw_front_layer(k001604, bitmap, cliprect);
}
draw_7segment_led(bitmap, 3, 3, gticlub_led_reg0);
draw_7segment_led(bitmap, 9, 3, gticlub_led_reg1);
return 0;
}
static READ32_HANDLER( gticlub_k001604_tile_r ) static READ32_HANDLER( gticlub_k001604_tile_r )
{ {
device_t *k001604 = space->machine->device(get_cgboard_id() ? "k001604_2" : "k001604_1"); device_t *k001604 = space->machine->device(get_cgboard_id() ? "k001604_2" : "k001604_1");
@ -389,11 +353,8 @@ static WRITE8_HANDLER( sysreg_w )
switch (offset) switch (offset)
{ {
case 0: case 0:
gticlub_led_reg0 = data;
break;
case 1: case 1:
gticlub_led_reg1 = data; gticlub_led_setreg(offset, data);
break; break;
case 3: case 3:
@ -1182,7 +1143,6 @@ static DRIVER_INIT(gticlub)
init_konami_cgboard(machine, 1, CGBOARD_TYPE_GTICLUB); init_konami_cgboard(machine, 1, CGBOARD_TYPE_GTICLUB);
sharc_dataram_0 = auto_alloc_array(machine, UINT32, 0x100000/4); sharc_dataram_0 = auto_alloc_array(machine, UINT32, 0x100000/4);
gticlub_led_reg0 = gticlub_led_reg1 = 0x7f;
K001005_preprocess_texture_data(machine->region("gfx1")->base(), machine->region("gfx1")->bytes(), 1); K001005_preprocess_texture_data(machine->region("gfx1")->base(), machine->region("gfx1")->bytes(), 1);
} }
@ -1195,7 +1155,6 @@ static DRIVER_INIT(hangplt)
sharc_dataram_0 = auto_alloc_array(machine, UINT32, 0x100000/4); sharc_dataram_0 = auto_alloc_array(machine, UINT32, 0x100000/4);
sharc_dataram_1 = auto_alloc_array(machine, UINT32, 0x100000/4); sharc_dataram_1 = auto_alloc_array(machine, UINT32, 0x100000/4);
gticlub_led_reg0 = gticlub_led_reg1 = 0x7f;
} }
/*************************************************************************/ /*************************************************************************/

View File

@ -218,7 +218,7 @@ static INTERRUPT_GEN( hexion_interrupt )
cpu_set_input_line(device, 0, HOLD_LINE); cpu_set_input_line(device, 0, HOLD_LINE);
} }
static MACHINE_CONFIG_START( hexion, driver_device ) static MACHINE_CONFIG_START( hexion, hexion_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80,24000000/4) /* Z80B 6 MHz */ MCFG_CPU_ADD("maincpu", Z80,24000000/4) /* Z80B 6 MHz */

View File

@ -322,13 +322,27 @@
#include "video/konicdev.h" #include "video/konicdev.h"
#include "rendlay.h" #include "rendlay.h"
static UINT8 led_reg0, led_reg1;
static UINT32 *workram;
static UINT32 *sharc_dataram[2];
static UINT8 *jvs_sdata;
static UINT32 jvs_sdata_ptr = 0;
static emu_timer *sound_irq_timer; class hornet_state : public driver_device
{
public:
hornet_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 led_reg0;
UINT8 led_reg1;
UINT32 *workram;
UINT32 *sharc_dataram[2];
UINT8 *jvs_sdata;
UINT32 jvs_sdata_ptr;
emu_timer *sound_irq_timer;
UINT16 gn680_latch;
UINT16 gn680_ret0;
UINT16 gn680_ret1;
};
static READ32_HANDLER( hornet_k037122_sram_r ) static READ32_HANDLER( hornet_k037122_sram_r )
{ {
@ -379,6 +393,7 @@ static void voodoo_vblank_1(device_t *device, int param)
static VIDEO_UPDATE( hornet ) static VIDEO_UPDATE( hornet )
{ {
hornet_state *state = screen->machine->driver_data<hornet_state>();
device_t *voodoo = screen->machine->device("voodoo0"); device_t *voodoo = screen->machine->device("voodoo0");
device_t *k037122 = screen->machine->device("k037122_1"); device_t *k037122 = screen->machine->device("k037122_1");
@ -386,13 +401,14 @@ static VIDEO_UPDATE( hornet )
k037122_tile_draw(k037122, bitmap, cliprect); k037122_tile_draw(k037122, bitmap, cliprect);
draw_7segment_led(bitmap, 3, 3, led_reg0); draw_7segment_led(bitmap, 3, 3, state->led_reg0);
draw_7segment_led(bitmap, 9, 3, led_reg1); draw_7segment_led(bitmap, 9, 3, state->led_reg1);
return 0; return 0;
} }
static VIDEO_UPDATE( hornet_2board ) static VIDEO_UPDATE( hornet_2board )
{ {
hornet_state *state = screen->machine->driver_data<hornet_state>();
if (strcmp(screen->tag(), "lscreen") == 0) if (strcmp(screen->tag(), "lscreen") == 0)
{ {
device_t *k037122 = screen->machine->device("k037122_1"); device_t *k037122 = screen->machine->device("k037122_1");
@ -412,8 +428,8 @@ static VIDEO_UPDATE( hornet_2board )
k037122_tile_draw(k037122, bitmap, cliprect); k037122_tile_draw(k037122, bitmap, cliprect);
} }
draw_7segment_led(bitmap, 3, 3, led_reg0); draw_7segment_led(bitmap, 3, 3, state->led_reg0);
draw_7segment_led(bitmap, 9, 3, led_reg1); draw_7segment_led(bitmap, 9, 3, state->led_reg1);
return 0; return 0;
} }
@ -457,16 +473,17 @@ static READ8_HANDLER( sysreg_r )
static WRITE8_HANDLER( sysreg_w ) static WRITE8_HANDLER( sysreg_w )
{ {
hornet_state *state = space->machine->driver_data<hornet_state>();
device_t *adc12138 = space->machine->device("adc12138"); device_t *adc12138 = space->machine->device("adc12138");
switch (offset) switch (offset)
{ {
case 0: /* LED Register 0 */ case 0: /* LED Register 0 */
led_reg0 = data; state->led_reg0 = data;
break; break;
case 1: /* LED Register 1 */ case 1: /* LED Register 1 */
led_reg1 = data; state->led_reg1 = data;
break; break;
case 2: /* Parallel data register */ case 2: /* Parallel data register */
@ -568,18 +585,19 @@ static READ32_HANDLER( comm0_unk_r )
return 0xffffffff; return 0xffffffff;
} }
static UINT16 gn680_latch, gn680_ret0, gn680_ret1;
static READ32_HANDLER(gun_r) static READ32_HANDLER(gun_r)
{ {
return gn680_ret0<<16 | gn680_ret1; hornet_state *state = space->machine->driver_data<hornet_state>();
return state->gn680_ret0<<16 | state->gn680_ret1;
} }
static WRITE32_HANDLER(gun_w) static WRITE32_HANDLER(gun_w)
{ {
hornet_state *state = space->machine->driver_data<hornet_state>();
if (mem_mask == 0xffff0000) if (mem_mask == 0xffff0000)
{ {
gn680_latch = data>>16; state->gn680_latch = data>>16;
cputag_set_input_line(space->machine, "gn680", M68K_IRQ_6, HOLD_LINE); cputag_set_input_line(space->machine, "gn680", M68K_IRQ_6, HOLD_LINE);
} }
} }
@ -587,7 +605,7 @@ static WRITE32_HANDLER(gun_w)
/*****************************************************************************/ /*****************************************************************************/
static ADDRESS_MAP_START( hornet_map, ADDRESS_SPACE_PROGRAM, 32 ) static ADDRESS_MAP_START( hornet_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE(&workram) /* Work RAM */ AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE_MEMBER(hornet_state, workram) /* Work RAM */
AM_RANGE(0x74000000, 0x740000ff) AM_READWRITE(hornet_k037122_reg_r, hornet_k037122_reg_w) AM_RANGE(0x74000000, 0x740000ff) AM_READWRITE(hornet_k037122_reg_r, hornet_k037122_reg_w)
AM_RANGE(0x74020000, 0x7403ffff) AM_READWRITE(hornet_k037122_sram_r, hornet_k037122_sram_w) AM_RANGE(0x74020000, 0x7403ffff) AM_READWRITE(hornet_k037122_sram_r, hornet_k037122_sram_w)
AM_RANGE(0x74040000, 0x7407ffff) AM_READWRITE(hornet_k037122_char_r, hornet_k037122_char_w) AM_RANGE(0x74040000, 0x7407ffff) AM_READWRITE(hornet_k037122_char_r, hornet_k037122_char_w)
@ -631,20 +649,22 @@ static WRITE16_HANDLER(gn680_sysctrl)
static READ16_HANDLER(gn680_latch_r) static READ16_HANDLER(gn680_latch_r)
{ {
hornet_state *state = space->machine->driver_data<hornet_state>();
cputag_set_input_line(space->machine, "gn680", M68K_IRQ_6, CLEAR_LINE); cputag_set_input_line(space->machine, "gn680", M68K_IRQ_6, CLEAR_LINE);
return gn680_latch; return state->gn680_latch;
} }
static WRITE16_HANDLER(gn680_latch_w) static WRITE16_HANDLER(gn680_latch_w)
{ {
hornet_state *state = space->machine->driver_data<hornet_state>();
if (offset) if (offset)
{ {
gn680_ret1 = data; state->gn680_ret1 = data;
} }
else else
{ {
gn680_ret0 = data; state->gn680_ret0 = data;
} }
} }
@ -664,27 +684,31 @@ ADDRESS_MAP_END
static READ32_HANDLER( dsp_dataram0_r ) static READ32_HANDLER( dsp_dataram0_r )
{ {
return sharc_dataram[0][offset] & 0xffff; hornet_state *state = space->machine->driver_data<hornet_state>();
return state->sharc_dataram[0][offset] & 0xffff;
} }
static WRITE32_HANDLER( dsp_dataram0_w ) static WRITE32_HANDLER( dsp_dataram0_w )
{ {
sharc_dataram[0][offset] = data; hornet_state *state = space->machine->driver_data<hornet_state>();
state->sharc_dataram[0][offset] = data;
} }
static READ32_HANDLER( dsp_dataram1_r ) static READ32_HANDLER( dsp_dataram1_r )
{ {
return sharc_dataram[1][offset] & 0xffff; hornet_state *state = space->machine->driver_data<hornet_state>();
return state->sharc_dataram[1][offset] & 0xffff;
} }
static WRITE32_HANDLER( dsp_dataram1_w ) static WRITE32_HANDLER( dsp_dataram1_w )
{ {
sharc_dataram[1][offset] = data; hornet_state *state = space->machine->driver_data<hornet_state>();
state->sharc_dataram[1][offset] = data;
} }
static ADDRESS_MAP_START( sharc0_map, ADDRESS_SPACE_DATA, 32 ) static ADDRESS_MAP_START( sharc0_map, ADDRESS_SPACE_DATA, 32 )
AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_0_shared_sharc_r, cgboard_0_shared_sharc_w) AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_0_shared_sharc_r, cgboard_0_shared_sharc_w)
AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram0_r, dsp_dataram0_w) AM_BASE(&sharc_dataram[0]) AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram0_r, dsp_dataram0_w) AM_BASE_MEMBER(hornet_state, sharc_dataram[0])
AM_RANGE(0x1400000, 0x14fffff) AM_RAM AM_RANGE(0x1400000, 0x14fffff) AM_RAM
AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE("voodoo0", voodoo_r, voodoo_w) AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE("voodoo0", voodoo_r, voodoo_w)
AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_0_comm_sharc_r, cgboard_0_comm_sharc_w) AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_0_comm_sharc_r, cgboard_0_comm_sharc_w)
@ -694,7 +718,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( sharc1_map, ADDRESS_SPACE_DATA, 32 ) static ADDRESS_MAP_START( sharc1_map, ADDRESS_SPACE_DATA, 32 )
AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_1_shared_sharc_r, cgboard_1_shared_sharc_w) AM_RANGE(0x0400000, 0x041ffff) AM_READWRITE(cgboard_1_shared_sharc_r, cgboard_1_shared_sharc_w)
AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram1_r, dsp_dataram1_w) AM_BASE(&sharc_dataram[1]) AM_RANGE(0x0500000, 0x05fffff) AM_READWRITE(dsp_dataram1_r, dsp_dataram1_w) AM_BASE_MEMBER(hornet_state, sharc_dataram[1])
AM_RANGE(0x1400000, 0x14fffff) AM_RAM AM_RANGE(0x1400000, 0x14fffff) AM_RAM
AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE("voodoo1", voodoo_r, voodoo_w) AM_RANGE(0x2400000, 0x27fffff) AM_DEVREADWRITE("voodoo1", voodoo_r, voodoo_w)
AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_1_comm_sharc_r, cgboard_1_comm_sharc_w) AM_RANGE(0x3400000, 0x34000ff) AM_READWRITE(cgboard_1_comm_sharc_r, cgboard_1_comm_sharc_w)
@ -834,21 +858,22 @@ static TIMER_CALLBACK( irq_off );
static MACHINE_START( hornet ) static MACHINE_START( hornet )
{ {
jvs_sdata_ptr = 0; hornet_state *state = machine->driver_data<hornet_state>();
jvs_sdata = auto_alloc_array_clear(machine, UINT8, 1024); state->jvs_sdata_ptr = 0;
state->jvs_sdata = auto_alloc_array_clear(machine, UINT8, 1024);
/* set conservative DRC options */ /* set conservative DRC options */
ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS); ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS);
/* configure fast RAM regions for DRC */ /* configure fast RAM regions for DRC */
ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x003fffff, FALSE, workram); ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x003fffff, FALSE, state->workram);
state_save_register_global(machine, led_reg0); state_save_register_global(machine, state->led_reg0);
state_save_register_global(machine, led_reg1); state_save_register_global(machine, state->led_reg1);
state_save_register_global_pointer(machine, jvs_sdata, 1024); state_save_register_global_pointer(machine, state->jvs_sdata, 1024);
state_save_register_global(machine, jvs_sdata_ptr); state_save_register_global(machine, state->jvs_sdata_ptr);
sound_irq_timer = machine->scheduler().timer_alloc(FUNC(irq_off)); state->sound_irq_timer = machine->scheduler().timer_alloc(FUNC(irq_off));
} }
static MACHINE_RESET( hornet ) static MACHINE_RESET( hornet )
@ -883,10 +908,11 @@ static TIMER_CALLBACK( irq_off )
static void sound_irq_callback( running_machine *machine, int irq ) static void sound_irq_callback( running_machine *machine, int irq )
{ {
hornet_state *state = machine->driver_data<hornet_state>();
int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2; int line = (irq == 0) ? INPUT_LINE_IRQ1 : INPUT_LINE_IRQ2;
cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE); cputag_set_input_line(machine, "audiocpu", line, ASSERT_LINE);
sound_irq_timer->adjust(attotime::from_usec(1), line); state->sound_irq_timer->adjust(attotime::from_usec(1), line);
} }
static const k056800_interface hornet_k056800_interface = static const k056800_interface hornet_k056800_interface =
@ -919,7 +945,7 @@ static const k037122_interface hornet_k037122_intf_r =
"rscreen", 1 "rscreen", 1
}; };
static MACHINE_CONFIG_START( hornet, driver_device ) static MACHINE_CONFIG_START( hornet, hornet_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */ MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */
@ -1063,12 +1089,13 @@ static void jamma_jvs_cmd_exec(running_machine *machine);
static void jamma_jvs_w(device_t *device, UINT8 data) static void jamma_jvs_w(device_t *device, UINT8 data)
{ {
if (jvs_sdata_ptr == 0 && data != 0xe0) hornet_state *state = device->machine->driver_data<hornet_state>();
if (state->jvs_sdata_ptr == 0 && data != 0xe0)
return; return;
jvs_sdata[jvs_sdata_ptr] = data; state->jvs_sdata[state->jvs_sdata_ptr] = data;
jvs_sdata_ptr++; state->jvs_sdata_ptr++;
if (jvs_sdata_ptr >= 3 && jvs_sdata_ptr >= 3 + jvs_sdata[2]) if (state->jvs_sdata_ptr >= 3 && state->jvs_sdata_ptr >= 3 + state->jvs_sdata[2])
jamma_jvs_cmd_exec(device->machine); jamma_jvs_cmd_exec(device->machine);
} }
@ -1125,6 +1152,7 @@ static int jvs_decode_data(UINT8 *in, UINT8 *out, int length)
static void jamma_jvs_cmd_exec(running_machine *machine) static void jamma_jvs_cmd_exec(running_machine *machine)
{ {
hornet_state *state = machine->driver_data<hornet_state>();
UINT8 sync, node, byte_num; UINT8 sync, node, byte_num;
UINT8 data[1024], rdata[1024]; UINT8 data[1024], rdata[1024];
#if 0 #if 0
@ -1133,19 +1161,19 @@ static void jamma_jvs_cmd_exec(running_machine *machine)
int rdata_ptr; int rdata_ptr;
int sum; int sum;
sync = jvs_sdata[0]; sync = state->jvs_sdata[0];
node = jvs_sdata[1]; node = state->jvs_sdata[1];
byte_num = jvs_sdata[2]; byte_num = state->jvs_sdata[2];
#if 0 #if 0
length = length =
#endif #endif
jvs_decode_data(&jvs_sdata[3], data, byte_num-1); jvs_decode_data(&state->jvs_sdata[3], data, byte_num-1);
#if 0 #if 0
printf("jvs input data:\n"); printf("jvs input data:\n");
for (i=0; i < byte_num; i++) for (i=0; i < byte_num; i++)
{ {
printf("%02X ", jvs_sdata[3+i]); printf("%02X ", state->jvs_sdata[3+i]);
} }
printf("\n"); printf("\n");
@ -1194,7 +1222,7 @@ static void jamma_jvs_cmd_exec(running_machine *machine)
sum += jvs_encode_data(machine, rdata, rdata_ptr); sum += jvs_encode_data(machine, rdata, rdata_ptr);
ppc4xx_spu_receive_byte(machine->device("maincpu"), sum - 1); // checksum ppc4xx_spu_receive_byte(machine->device("maincpu"), sum - 1); // checksum
jvs_sdata_ptr = 0; state->jvs_sdata_ptr = 0;
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1202,21 +1230,23 @@ static void jamma_jvs_cmd_exec(running_machine *machine)
static DRIVER_INIT(hornet) static DRIVER_INIT(hornet)
{ {
hornet_state *state = machine->driver_data<hornet_state>();
init_konami_cgboard(machine, 1, CGBOARD_TYPE_HORNET); init_konami_cgboard(machine, 1, CGBOARD_TYPE_HORNET);
set_cgboard_texture_bank(machine, 0, "bank5", machine->region("user5")->base()); set_cgboard_texture_bank(machine, 0, "bank5", machine->region("user5")->base());
led_reg0 = led_reg1 = 0x7f; state->led_reg0 = state->led_reg1 = 0x7f;
ppc4xx_spu_set_tx_handler(machine->device("maincpu"), jamma_jvs_w); ppc4xx_spu_set_tx_handler(machine->device("maincpu"), jamma_jvs_w);
} }
static DRIVER_INIT(hornet_2board) static DRIVER_INIT(hornet_2board)
{ {
hornet_state *state = machine->driver_data<hornet_state>();
init_konami_cgboard(machine, 2, CGBOARD_TYPE_HORNET); init_konami_cgboard(machine, 2, CGBOARD_TYPE_HORNET);
set_cgboard_texture_bank(machine, 0, "bank5", machine->region("user5")->base()); set_cgboard_texture_bank(machine, 0, "bank5", machine->region("user5")->base());
set_cgboard_texture_bank(machine, 1, "bank6", machine->region("user5")->base()); set_cgboard_texture_bank(machine, 1, "bank6", machine->region("user5")->base());
led_reg0 = led_reg1 = 0x7f; state->led_reg0 = state->led_reg1 = 0x7f;
ppc4xx_spu_set_tx_handler(machine->device("maincpu"), jamma_jvs_w); ppc4xx_spu_set_tx_handler(machine->device("maincpu"), jamma_jvs_w);
} }

View File

@ -190,13 +190,44 @@ Notes:
#include "cdrom.h" #include "cdrom.h"
#include "cpu/powerpc/ppc.h" #include "cpu/powerpc/ppc.h"
static UINT64 *main_ram;
static UINT32 vdl0_address; typedef struct
static UINT32 vdl1_address; {
UINT32 dst_addr;
int length;
UINT32 next_dst_addr;
int next_length;
int dma_done;
} CDE_DMA;
class konamim2_state : public driver_device
{
public:
konamim2_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT64 *main_ram;
UINT32 vdl0_address;
UINT32 vdl1_address;
UINT32 irq_enable;
UINT32 irq_active;
UINT64 unk3;
UINT32 unk20004;
int counter1;
int cde_num_status_bytes;
UINT32 cde_status_bytes[16];
int cde_status_byte_ptr;
UINT32 cde_command_bytes[16];
int cde_command_byte_ptr;
int cde_response;
int cde_drive_state;
int cde_enable_qchannel_reports;
int cde_enable_seek_reports;
int cde_qchannel_offset;
cdrom_toc cde_toc;
CDE_DMA cde_dma[2];
};
static UINT32 irq_enable;
static UINT32 irq_active;
static VIDEO_START( m2 ) static VIDEO_START( m2 )
{ {
@ -204,17 +235,18 @@ static VIDEO_START( m2 )
static VIDEO_UPDATE( m2 ) static VIDEO_UPDATE( m2 )
{ {
konamim2_state *state = screen->machine->driver_data<konamim2_state>();
int i, j; int i, j;
UINT32 fb_start = 0xffffffff; UINT32 fb_start = 0xffffffff;
if (vdl0_address != 0) if (state->vdl0_address != 0)
{ {
fb_start = *(UINT32*)&main_ram[(vdl0_address - 0x40000000) / 8] - 0x40000000; fb_start = *(UINT32*)&state->main_ram[(state->vdl0_address - 0x40000000) / 8] - 0x40000000;
} }
if (fb_start <= 0x800000) if (fb_start <= 0x800000)
{ {
UINT16 *frame = (UINT16*)&main_ram[fb_start/8]; UINT16 *frame = (UINT16*)&state->main_ram[fb_start/8];
for (j=0; j < 384; j++) for (j=0; j < 384; j++)
{ {
UINT16 *fb = &frame[(j*512)]; UINT16 *fb = &frame[(j*512)];
@ -234,11 +266,12 @@ static VIDEO_UPDATE( m2 )
static READ64_HANDLER(irq_enable_r) static READ64_HANDLER(irq_enable_r)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
UINT64 r = 0; UINT64 r = 0;
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
r |= (UINT64)(irq_enable) << 32; r |= (UINT64)(state->irq_enable) << 32;
} }
return r; return r;
@ -246,19 +279,21 @@ static READ64_HANDLER(irq_enable_r)
static WRITE64_HANDLER(irq_enable_w) static WRITE64_HANDLER(irq_enable_w)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
irq_enable |= (UINT32)(data >> 32); state->irq_enable |= (UINT32)(data >> 32);
} }
} }
static READ64_HANDLER(irq_active_r) static READ64_HANDLER(irq_active_r)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
UINT64 r = 0; UINT64 r = 0;
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
r |= (UINT64)(irq_active) << 32; r |= (UINT64)(state->irq_active) << 32;
} }
return r; return r;
@ -283,16 +318,16 @@ static READ64_HANDLER(unk2_r)
} }
#endif #endif
static UINT64 unk3;
static READ64_HANDLER(unk3_r) static READ64_HANDLER(unk3_r)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
//return U64(0xffffffffffffffff); //return U64(0xffffffffffffffff);
return unk3; return state->unk3;
} }
static UINT32 unk20004 = 0;
static READ64_HANDLER(unk4_r) static READ64_HANDLER(unk4_r)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
UINT64 r = 0; UINT64 r = 0;
// logerror("unk4_r: %08X, %08X%08X at %08X\n", offset, (UINT32)(mem_mask>>32), (UINT32)(mem_mask), cpu_get_pc(space->cpu)); // logerror("unk4_r: %08X, %08X%08X at %08X\n", offset, (UINT32)(mem_mask>>32), (UINT32)(mem_mask), cpu_get_pc(space->cpu));
@ -303,13 +338,14 @@ static READ64_HANDLER(unk4_r)
} }
if (ACCESSING_BITS_0_31) if (ACCESSING_BITS_0_31)
{ {
r |= unk20004 & ~0x800000; r |= state->unk20004 & ~0x800000;
} }
return r; return r;
} }
static WRITE64_HANDLER(unk4_w) static WRITE64_HANDLER(unk4_w)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
// logerror("unk4_w: %08X%08X, %08X, %08X%08X at %08X\n", (UINT32)(data >> 32), (UINT32)(data), // logerror("unk4_w: %08X%08X, %08X, %08X%08X at %08X\n", (UINT32)(data >> 32), (UINT32)(data),
// offset, (UINT32)(mem_mask>>32), (UINT32)(mem_mask), cpu_get_pc(space->cpu)); // offset, (UINT32)(mem_mask>>32), (UINT32)(mem_mask), cpu_get_pc(space->cpu));
@ -321,16 +357,16 @@ static WRITE64_HANDLER(unk4_w)
cputag_set_input_line(space->machine, "sub", INPUT_LINE_IRQ0, ASSERT_LINE); cputag_set_input_line(space->machine, "sub", INPUT_LINE_IRQ0, ASSERT_LINE);
} }
unk20004 = (UINT32)(data); state->unk20004 = (UINT32)(data);
return; return;
} }
} }
static int counter1 = 0;
static READ64_HANDLER(unk30000_r) static READ64_HANDLER(unk30000_r)
{ {
counter1++; konamim2_state *state = space->machine->driver_data<konamim2_state>();
return (UINT64)(counter1 & 0x7f) << 32; state->counter1++;
return (UINT64)(state->counter1 & 0x7f) << 32;
} }
static READ64_HANDLER(unk30030_r) static READ64_HANDLER(unk30030_r)
@ -344,23 +380,25 @@ static READ64_HANDLER(unk30030_r)
static WRITE64_HANDLER(video_w) static WRITE64_HANDLER(video_w)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
vdl0_address = (UINT32)(data >> 32); state->vdl0_address = (UINT32)(data >> 32);
} }
if (ACCESSING_BITS_0_31) if (ACCESSING_BITS_0_31)
{ {
vdl1_address = (UINT32)(data); state->vdl1_address = (UINT32)(data);
} }
} }
static WRITE64_HANDLER(video_irq_ack_w) static WRITE64_HANDLER(video_irq_ack_w)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
if ((data >> 32) & 0x8000) if ((data >> 32) & 0x8000)
{ {
irq_active &= ~0x800000; state->irq_active &= ~0x800000;
} }
} }
} }
@ -409,12 +447,13 @@ static WRITE64_HANDLER(unk4000418_w)
static WRITE64_HANDLER(reset_w) static WRITE64_HANDLER(reset_w)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
if (data & U64(0x100000000)) if (data & U64(0x100000000))
{ {
cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE); cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE);
unk3 = 0; state->unk3 = 0;
} }
} }
} }
@ -423,46 +462,26 @@ static WRITE64_HANDLER(reset_w)
/*****************************************************************************/ /*****************************************************************************/
/* CDE */ /* CDE */
typedef struct
{
UINT32 dst_addr;
int length;
UINT32 next_dst_addr;
int next_length;
int dma_done;
} CDE_DMA;
#define CDE_DRIVE_STATE_PAUSED 0x02 #define CDE_DRIVE_STATE_PAUSED 0x02
#define CDE_DRIVE_STATE_SEEK_DONE 0x03 #define CDE_DRIVE_STATE_SEEK_DONE 0x03
static int cde_num_status_bytes = 0;
static UINT32 cde_status_bytes[16];
static int cde_status_byte_ptr = 0;
static UINT32 cde_command_bytes[16];
static int cde_command_byte_ptr = 0;
static int cde_response = 0;
static int cde_drive_state = 0;
static int cde_enable_qchannel_reports = 0;
static int cde_enable_seek_reports = 0;
static int cde_qchannel_offset = 0;
static cdrom_toc cde_toc;
static CDE_DMA cde_dma[2];
static void cde_init(running_machine *machine) static void cde_init(running_machine *machine)
{ {
konamim2_state *state = machine->driver_data<konamim2_state>();
cdrom_file *cd = cdrom_open(get_disk_handle(machine, "cdrom")); cdrom_file *cd = cdrom_open(get_disk_handle(machine, "cdrom"));
const cdrom_toc *toc = cdrom_get_toc(cd); const cdrom_toc *toc = cdrom_get_toc(cd);
if (cd) if (cd)
{ {
memcpy(&cde_toc, toc, sizeof(cdrom_toc)); memcpy(&state->cde_toc, toc, sizeof(cdrom_toc));
} }
/* /*
@ -480,208 +499,210 @@ static void cde_init(running_machine *machine)
cdrom_close(cd); cdrom_close(cd);
} }
cde_drive_state = CDE_DRIVE_STATE_PAUSED; state->cde_drive_state = CDE_DRIVE_STATE_PAUSED;
cde_num_status_bytes = 0; state->cde_num_status_bytes = 0;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
cde_command_byte_ptr = 0; state->cde_command_byte_ptr = 0;
cde_response = 0; state->cde_response = 0;
cde_enable_qchannel_reports = 0; state->cde_enable_qchannel_reports = 0;
cde_enable_seek_reports = 0; state->cde_enable_seek_reports = 0;
cde_qchannel_offset = 0; state->cde_qchannel_offset = 0;
} }
static void cde_handle_command(void) static void cde_handle_command(running_machine *machine)
{ {
switch (cde_command_bytes[0]) konamim2_state *state = machine->driver_data<konamim2_state>();
switch (state->cde_command_bytes[0])
{ {
case 0x04: // Set Speed case 0x04: // Set Speed
{ {
cde_num_status_bytes = 1; state->cde_num_status_bytes = 1;
cde_status_bytes[0] = 0x04; state->cde_status_bytes[0] = 0x04;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
mame_printf_debug("CDE: SET SPEED %02X, %02X\n", cde_command_bytes[1], cde_command_bytes[2]); mame_printf_debug("CDE: SET SPEED %02X, %02X\n", state->cde_command_bytes[1], state->cde_command_bytes[2]);
break; break;
} }
case 0x06: // Audio Format / Data Format case 0x06: // Audio Format / Data Format
{ {
cde_num_status_bytes = 1; state->cde_num_status_bytes = 1;
cde_status_bytes[0] = 0x06; state->cde_status_bytes[0] = 0x06;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
if (cde_command_bytes[1] == 0x00) // Audio Format if (state->cde_command_bytes[1] == 0x00) // Audio Format
{ {
mame_printf_debug("CDE: AUDIO FORMAT\n"); mame_printf_debug("CDE: AUDIO FORMAT\n");
} }
else if (cde_command_bytes[1] == 0x78) // Data Format else if (state->cde_command_bytes[1] == 0x78) // Data Format
{ {
mame_printf_debug("CDE: DATA FORMAT\n"); mame_printf_debug("CDE: DATA FORMAT\n");
} }
else else
{ {
fatalerror("CDE: unknown command %02X, %02X\n", cde_command_bytes[0], cde_command_bytes[1]); fatalerror("CDE: unknown command %02X, %02X\n", state->cde_command_bytes[0], state->cde_command_bytes[1]);
} }
break; break;
} }
case 0x08: // Pause / Eject / Play case 0x08: // Pause / Eject / Play
{ {
cde_num_status_bytes = 1; state->cde_num_status_bytes = 1;
cde_status_bytes[0] = 0x08; state->cde_status_bytes[0] = 0x08;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
if (cde_command_bytes[1] == 0x00) // Eject if (state->cde_command_bytes[1] == 0x00) // Eject
{ {
mame_printf_debug("CDE: EJECT command\n"); mame_printf_debug("CDE: EJECT command\n");
} }
else if (cde_command_bytes[1] == 0x02) // Pause else if (state->cde_command_bytes[1] == 0x02) // Pause
{ {
mame_printf_debug("CDE: PAUSE command\n"); mame_printf_debug("CDE: PAUSE command\n");
cde_drive_state = CDE_DRIVE_STATE_PAUSED; state->cde_drive_state = CDE_DRIVE_STATE_PAUSED;
} }
else if (cde_command_bytes[1] == 0x03) // Play else if (state->cde_command_bytes[1] == 0x03) // Play
{ {
mame_printf_debug("CDE: PLAY command\n"); mame_printf_debug("CDE: PLAY command\n");
} }
else else
{ {
fatalerror("CDE: unknown command %02X, %02X\n", cde_command_bytes[0], cde_command_bytes[1]); fatalerror("CDE: unknown command %02X, %02X\n", state->cde_command_bytes[0], state->cde_command_bytes[1]);
} }
break; break;
} }
case 0x09: // Seek case 0x09: // Seek
{ {
cde_num_status_bytes = 1; state->cde_num_status_bytes = 1;
cde_status_bytes[0] = 0x1b; state->cde_status_bytes[0] = 0x1b;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
cde_drive_state = CDE_DRIVE_STATE_SEEK_DONE; state->cde_drive_state = CDE_DRIVE_STATE_SEEK_DONE;
mame_printf_debug("CDE: SEEK %08X\n", (cde_command_bytes[1] << 16) | (cde_command_bytes[2] << 8) | (cde_command_bytes[3])); mame_printf_debug("CDE: SEEK %08X\n", (state->cde_command_bytes[1] << 16) | (state->cde_command_bytes[2] << 8) | (state->cde_command_bytes[3]));
break; break;
} }
case 0x0b: // Get Drive State case 0x0b: // Get Drive State
{ {
cde_num_status_bytes = 0x3; state->cde_num_status_bytes = 0x3;
cde_status_bytes[0] = 0x0b; state->cde_status_bytes[0] = 0x0b;
cde_status_bytes[1] = 0x1b; state->cde_status_bytes[1] = 0x1b;
cde_status_bytes[2] = cde_drive_state; state->cde_status_bytes[2] = state->cde_drive_state;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
if (cde_command_bytes[1] & 0x02) if (state->cde_command_bytes[1] & 0x02)
{ {
cde_enable_seek_reports = 1; state->cde_enable_seek_reports = 1;
} }
else else
{ {
cde_enable_seek_reports = 0; state->cde_enable_seek_reports = 0;
} }
mame_printf_debug("CDE: GET DRIVE STATE %02X\n", cde_command_bytes[1]); mame_printf_debug("CDE: GET DRIVE STATE %02X\n", state->cde_command_bytes[1]);
break; break;
} }
case 0x0c: // ? case 0x0c: // ?
{ {
cde_num_status_bytes = 1; state->cde_num_status_bytes = 1;
cde_status_bytes[0] = 0x0c; state->cde_status_bytes[0] = 0x0c;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
if (cde_command_bytes[1] == 0x02) if (state->cde_command_bytes[1] == 0x02)
{ {
cde_enable_qchannel_reports = 1; state->cde_enable_qchannel_reports = 1;
cde_drive_state = CDE_DRIVE_STATE_PAUSED; state->cde_drive_state = CDE_DRIVE_STATE_PAUSED;
} }
else if (cde_command_bytes[0] == 0x00) else if (state->cde_command_bytes[0] == 0x00)
{ {
cde_enable_qchannel_reports = 0; state->cde_enable_qchannel_reports = 0;
} }
mame_printf_debug("CDE: UNKNOWN CMD 0x0c %02X\n", cde_command_bytes[1]); mame_printf_debug("CDE: UNKNOWN CMD 0x0c %02X\n", state->cde_command_bytes[1]);
break; break;
} }
case 0x0d: // Get Switch State case 0x0d: // Get Switch State
{ {
cde_num_status_bytes = 0x4; state->cde_num_status_bytes = 0x4;
cde_status_bytes[0] = 0x0d; state->cde_status_bytes[0] = 0x0d;
cde_status_bytes[1] = 0x1d; state->cde_status_bytes[1] = 0x1d;
cde_status_bytes[2] = 0x02; state->cde_status_bytes[2] = 0x02;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
mame_printf_debug("CDE: GET SWITCH STATE %02X\n", cde_command_bytes[1]); mame_printf_debug("CDE: GET SWITCH STATE %02X\n", state->cde_command_bytes[1]);
break; break;
} }
case 0x21: // Mech type case 0x21: // Mech type
{ {
cde_num_status_bytes = 0x8; state->cde_num_status_bytes = 0x8;
cde_status_bytes[0] = 0x21; state->cde_status_bytes[0] = 0x21;
cde_status_bytes[1] = 0xff; state->cde_status_bytes[1] = 0xff;
cde_status_bytes[2] = 0x08; // Max Speed state->cde_status_bytes[2] = 0x08; // Max Speed
cde_status_bytes[3] = 0xff; state->cde_status_bytes[3] = 0xff;
cde_status_bytes[4] = 0xff; state->cde_status_bytes[4] = 0xff;
cde_status_bytes[5] = 0xff; state->cde_status_bytes[5] = 0xff;
cde_status_bytes[6] = 0xff; state->cde_status_bytes[6] = 0xff;
cde_status_bytes[7] = 0xff; state->cde_status_bytes[7] = 0xff;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
mame_printf_debug("CDE: MECH TYPE %02X, %02X, %02X\n", cde_command_bytes[1], cde_command_bytes[2], cde_command_bytes[3]); mame_printf_debug("CDE: MECH TYPE %02X, %02X, %02X\n", state->cde_command_bytes[1], state->cde_command_bytes[2], state->cde_command_bytes[3]);
break; break;
} }
case 0x83: // Read ID case 0x83: // Read ID
{ {
cde_num_status_bytes = 0xc; state->cde_num_status_bytes = 0xc;
cde_status_bytes[0] = 0x03; state->cde_status_bytes[0] = 0x03;
cde_status_bytes[1] = 0xff; state->cde_status_bytes[1] = 0xff;
cde_status_bytes[2] = 0xff; state->cde_status_bytes[2] = 0xff;
cde_status_bytes[3] = 0xff; state->cde_status_bytes[3] = 0xff;
cde_status_bytes[4] = 0xff; state->cde_status_bytes[4] = 0xff;
cde_status_bytes[5] = 0xff; state->cde_status_bytes[5] = 0xff;
cde_status_bytes[6] = 0xff; state->cde_status_bytes[6] = 0xff;
cde_status_bytes[7] = 0xff; state->cde_status_bytes[7] = 0xff;
cde_status_bytes[8] = 0xff; state->cde_status_bytes[8] = 0xff;
cde_status_bytes[9] = 0xff; state->cde_status_bytes[9] = 0xff;
cde_status_bytes[10] = 0xff; state->cde_status_bytes[10] = 0xff;
cde_status_bytes[11] = 0xff; state->cde_status_bytes[11] = 0xff;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
mame_printf_debug("CDE: READ ID\n"); mame_printf_debug("CDE: READ ID\n");
break; break;
} }
default: default:
{ {
fatalerror("CDE: unknown command %08X\n", cde_command_bytes[0]); fatalerror("CDE: unknown command %08X\n", state->cde_command_bytes[0]);
break; break;
} }
} }
} }
static void cde_handle_reports(void) static void cde_handle_reports(running_machine *machine)
{ {
switch (cde_command_bytes[0]) konamim2_state *state = machine->driver_data<konamim2_state>();
switch (state->cde_command_bytes[0])
{ {
case 0x09: case 0x09:
{ {
if (cde_enable_seek_reports) if (state->cde_enable_seek_reports)
{ {
cde_num_status_bytes = 0x2; state->cde_num_status_bytes = 0x2;
cde_status_bytes[0] = 0x02; state->cde_status_bytes[0] = 0x02;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
cde_command_bytes[0] = 0x0c; state->cde_command_bytes[0] = 0x0c;
mame_printf_debug("CDE: SEEK REPORT\n"); mame_printf_debug("CDE: SEEK REPORT\n");
} }
@ -690,94 +711,94 @@ static void cde_handle_reports(void)
case 0x0b: case 0x0b:
{ {
if (cde_enable_qchannel_reports) if (state->cde_enable_qchannel_reports)
{ {
int track, num_tracks; int track, num_tracks;
num_tracks = cde_toc.numtrks; num_tracks = state->cde_toc.numtrks;
track = cde_qchannel_offset % (num_tracks+3); track = state->cde_qchannel_offset % (num_tracks+3);
cde_num_status_bytes = 0xb; state->cde_num_status_bytes = 0xb;
cde_status_bytes[0] = 0x1c; state->cde_status_bytes[0] = 0x1c;
/* /*
cde_status_bytes[1] = 0x0; // q-Mode state->cde_status_bytes[1] = 0x0; // q-Mode
cde_status_bytes[2] = 0x0; // TNO state->cde_status_bytes[2] = 0x0; // TNO
cde_status_bytes[3] = 0x0; // Index / Pointer state->cde_status_bytes[3] = 0x0; // Index / Pointer
cde_status_bytes[4] = 0x0; // Min state->cde_status_bytes[4] = 0x0; // Min
cde_status_bytes[5] = 0x0; // Sec state->cde_status_bytes[5] = 0x0; // Sec
cde_status_bytes[6] = 0x0; // Frac state->cde_status_bytes[6] = 0x0; // Frac
cde_status_bytes[7] = 0x0; // Zero state->cde_status_bytes[7] = 0x0; // Zero
cde_status_bytes[8] = 0x0; // A-Min state->cde_status_bytes[8] = 0x0; // A-Min
cde_status_bytes[9] = 0x0; // A-Sec state->cde_status_bytes[9] = 0x0; // A-Sec
cde_status_bytes[10] = 0x0; // A-Frac state->cde_status_bytes[10] = 0x0; // A-Frac
*/ */
if (track < num_tracks) if (track < num_tracks)
{ {
int time = lba_to_msf(cde_toc.tracks[track].physframeofs); int time = lba_to_msf(state->cde_toc.tracks[track].physframeofs);
cde_status_bytes[1] = 0x41; // q-Mode state->cde_status_bytes[1] = 0x41; // q-Mode
cde_status_bytes[2] = 0x0; // TNO (Lead-in track) state->cde_status_bytes[2] = 0x0; // TNO (Lead-in track)
cde_status_bytes[3] = track+1; // Pointer state->cde_status_bytes[3] = track+1; // Pointer
cde_status_bytes[4] = 0x0; // Min state->cde_status_bytes[4] = 0x0; // Min
cde_status_bytes[5] = 0x0; // Sec state->cde_status_bytes[5] = 0x0; // Sec
cde_status_bytes[6] = 0x0; // Frac state->cde_status_bytes[6] = 0x0; // Frac
cde_status_bytes[7] = 0x0; // Zero state->cde_status_bytes[7] = 0x0; // Zero
cde_status_bytes[8] = (time >> 16) & 0xff; // P-Min state->cde_status_bytes[8] = (time >> 16) & 0xff; // P-Min
cde_status_bytes[9] = (time >> 8) & 0xff; // P-Sec state->cde_status_bytes[9] = (time >> 8) & 0xff; // P-Sec
cde_status_bytes[10] = time & 0xff; // P-Frac state->cde_status_bytes[10] = time & 0xff; // P-Frac
} }
else else
{ {
if (track == num_tracks+0) if (track == num_tracks+0)
{ {
cde_status_bytes[1] = 0x41; // q-Mode / Control state->cde_status_bytes[1] = 0x41; // q-Mode / Control
cde_status_bytes[2] = 0x0; // TNO (Lead-in track) state->cde_status_bytes[2] = 0x0; // TNO (Lead-in track)
cde_status_bytes[3] = 0xa0; // Pointer state->cde_status_bytes[3] = 0xa0; // Pointer
cde_status_bytes[4] = 0x0; // Min state->cde_status_bytes[4] = 0x0; // Min
cde_status_bytes[5] = 0x0; // Sec state->cde_status_bytes[5] = 0x0; // Sec
cde_status_bytes[6] = 0x0; // Frac state->cde_status_bytes[6] = 0x0; // Frac
cde_status_bytes[7] = 0x0; // Zero state->cde_status_bytes[7] = 0x0; // Zero
cde_status_bytes[8] = 1; // P-Min state->cde_status_bytes[8] = 1; // P-Min
cde_status_bytes[9] = 0x0; // P-Sec state->cde_status_bytes[9] = 0x0; // P-Sec
cde_status_bytes[10] = 0x0; // P-Frac state->cde_status_bytes[10] = 0x0; // P-Frac
} }
else if (track == num_tracks+1) else if (track == num_tracks+1)
{ {
cde_status_bytes[1] = 0x41; // q-Mode / Control state->cde_status_bytes[1] = 0x41; // q-Mode / Control
cde_status_bytes[2] = 0x0; // TNO (Lead-in track) state->cde_status_bytes[2] = 0x0; // TNO (Lead-in track)
cde_status_bytes[3] = 0xa1; // Pointer state->cde_status_bytes[3] = 0xa1; // Pointer
cde_status_bytes[4] = 0x0; // Min state->cde_status_bytes[4] = 0x0; // Min
cde_status_bytes[5] = 0x0; // Sec state->cde_status_bytes[5] = 0x0; // Sec
cde_status_bytes[6] = 0x0; // Frac state->cde_status_bytes[6] = 0x0; // Frac
cde_status_bytes[7] = 0x0; // Zero state->cde_status_bytes[7] = 0x0; // Zero
cde_status_bytes[8] = num_tracks; // P-Min state->cde_status_bytes[8] = num_tracks; // P-Min
cde_status_bytes[9] = 0x0; // P-Sec state->cde_status_bytes[9] = 0x0; // P-Sec
cde_status_bytes[10] = 0x0; // P-Frac state->cde_status_bytes[10] = 0x0; // P-Frac
} }
else else
{ {
int leadout_lba = cde_toc.tracks[num_tracks-1].physframeofs + cde_toc.tracks[num_tracks-1].frames; int leadout_lba = state->cde_toc.tracks[num_tracks-1].physframeofs + state->cde_toc.tracks[num_tracks-1].frames;
int leadout_time = lba_to_msf(leadout_lba); int leadout_time = lba_to_msf(leadout_lba);
cde_status_bytes[1] = 0x41; // q-Mode / Control state->cde_status_bytes[1] = 0x41; // q-Mode / Control
cde_status_bytes[2] = 0x0; // TNO (Lead-in track) state->cde_status_bytes[2] = 0x0; // TNO (Lead-in track)
cde_status_bytes[3] = 0xa2; // Pointer state->cde_status_bytes[3] = 0xa2; // Pointer
cde_status_bytes[4] = 0x0; // Min state->cde_status_bytes[4] = 0x0; // Min
cde_status_bytes[5] = 0x0; // Sec state->cde_status_bytes[5] = 0x0; // Sec
cde_status_bytes[6] = 0x0; // Frac state->cde_status_bytes[6] = 0x0; // Frac
cde_status_bytes[7] = 0x0; // Zero state->cde_status_bytes[7] = 0x0; // Zero
cde_status_bytes[8] = (leadout_time >> 16) & 0xff; // P-Min state->cde_status_bytes[8] = (leadout_time >> 16) & 0xff; // P-Min
cde_status_bytes[9] = (leadout_time >> 8) & 0xff; // P-Sec state->cde_status_bytes[9] = (leadout_time >> 8) & 0xff; // P-Sec
cde_status_bytes[10] = leadout_time & 0xff; // P-Frac state->cde_status_bytes[10] = leadout_time & 0xff; // P-Frac
} }
} }
cde_qchannel_offset++; state->cde_qchannel_offset++;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
cde_command_bytes[0] = 0x0c; state->cde_command_bytes[0] = 0x0c;
mame_printf_debug("CDE: QCHANNEL REPORT\n"); mame_printf_debug("CDE: QCHANNEL REPORT\n");
break; break;
@ -788,22 +809,23 @@ static void cde_handle_reports(void)
static void cde_dma_transfer(address_space *space, int channel, int next) static void cde_dma_transfer(address_space *space, int channel, int next)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
UINT32 address; UINT32 address;
//int length; //int length;
int i; int i;
if (next) if (next)
{ {
address = cde_dma[channel].next_dst_addr; address = state->cde_dma[channel].next_dst_addr;
//length = cde_dma[channel].next_length; //length = state->cde_dma[channel].next_length;
} }
else else
{ {
address = cde_dma[channel].dst_addr; address = state->cde_dma[channel].dst_addr;
//length = cde_dma[channel].length; //length = state->cde_dma[channel].length;
} }
for (i=0; i < cde_dma[channel].next_length; i++) for (i=0; i < state->cde_dma[channel].next_length; i++)
{ {
space->write_byte(address, 0xff); // TODO: do the real transfer... space->write_byte(address, 0xff); // TODO: do the real transfer...
address++; address++;
@ -812,6 +834,7 @@ static void cde_dma_transfer(address_space *space, int channel, int next)
static READ64_HANDLER(cde_r) static READ64_HANDLER(cde_r)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
UINT32 r = 0; UINT32 r = 0;
int reg = offset * 2; int reg = offset * 2;
@ -829,36 +852,36 @@ static READ64_HANDLER(cde_r)
{ {
r = 0x100038; r = 0x100038;
r |= cde_dma[0].dma_done ? 0x400 : 0; r |= state->cde_dma[0].dma_done ? 0x400 : 0;
r |= cde_dma[1].dma_done ? 0x800 : 0; r |= state->cde_dma[1].dma_done ? 0x800 : 0;
break; break;
} }
case 0x02c/4: case 0x02c/4:
{ {
r = cde_status_bytes[cde_status_byte_ptr++]; r = state->cde_status_bytes[state->cde_status_byte_ptr++];
if (cde_status_byte_ptr <= cde_num_status_bytes) if (state->cde_status_byte_ptr <= state->cde_num_status_bytes)
{ {
r |= 0x100; r |= 0x100;
} }
else else
{ {
//if (cde_enable_reports && //if (cde_enable_reports &&
// !cde_response && // !state->cde_response &&
// cde_command_bytes[0] != ((cde_report_type >> 8) & 0xff)) // state->cde_command_bytes[0] != ((cde_report_type >> 8) & 0xff))
if (!cde_response) if (!state->cde_response)
{ {
cde_handle_reports(); cde_handle_reports(space->machine);
// cde_command_byte_ptr = 0; // state->cde_command_byte_ptr = 0;
// cde_command_bytes[cde_command_byte_ptr++] = 0x1c; // state->cde_command_bytes[state->cde_command_byte_ptr++] = 0x1c;
// cde_response = 1; // state->cde_response = 1;
} }
} }
// printf("status byte %d\n", cde_status_byte_ptr); // printf("status byte %d\n", state->cde_status_byte_ptr);
break; break;
} }
@ -887,6 +910,7 @@ static READ64_HANDLER(cde_r)
static WRITE64_HANDLER(cde_w) static WRITE64_HANDLER(cde_w)
{ {
konamim2_state *state = space->machine->driver_data<konamim2_state>();
int reg = offset * 2; int reg = offset * 2;
UINT32 d; UINT32 d;
@ -908,28 +932,28 @@ static WRITE64_HANDLER(cde_w)
if (d == 0x0180) if (d == 0x0180)
{ {
if (cde_response) if (state->cde_response)
{ {
cde_handle_command(); cde_handle_command(space->machine);
cde_response = 0; state->cde_response = 0;
} }
cde_command_byte_ptr = 0; state->cde_command_byte_ptr = 0;
} }
else if (cde_command_byte_ptr == 0) else if (state->cde_command_byte_ptr == 0)
{ {
cde_num_status_bytes = 1; state->cde_num_status_bytes = 1;
cde_status_bytes[0] = d & 0xff; state->cde_status_bytes[0] = d & 0xff;
cde_status_byte_ptr = 0; state->cde_status_byte_ptr = 0;
cde_response = 1; state->cde_response = 1;
} }
if (d != 0x180) if (d != 0x180)
{ {
cde_command_bytes[cde_command_byte_ptr++] = d; state->cde_command_bytes[state->cde_command_byte_ptr++] = d;
} }
break; break;
@ -941,13 +965,13 @@ static WRITE64_HANDLER(cde_w)
if (d & 0x20) if (d & 0x20)
{ {
cde_dma[0].dma_done = 1; state->cde_dma[0].dma_done = 1;
cde_dma_transfer(space, 0, 0); cde_dma_transfer(space, 0, 0);
} }
if (d & 0x40) if (d & 0x40)
{ {
cde_dma[0].dma_done = 1; state->cde_dma[0].dma_done = 1;
cde_dma_transfer(space, 0, 1); cde_dma_transfer(space, 0, 1);
} }
@ -957,28 +981,28 @@ static WRITE64_HANDLER(cde_w)
{ {
mame_printf_debug("CDE: DMA0 dst addr %08X\n", d); mame_printf_debug("CDE: DMA0 dst addr %08X\n", d);
cde_dma[0].dst_addr = d; state->cde_dma[0].dst_addr = d;
break; break;
} }
case 0x30c/4: // DMA Channel 0 length? case 0x30c/4: // DMA Channel 0 length?
{ {
mame_printf_debug("CDE: DMA0 length %08X\n", d); mame_printf_debug("CDE: DMA0 length %08X\n", d);
cde_dma[0].length = d; state->cde_dma[0].length = d;
break; break;
} }
case 0x318/4: // DMA Channel 0 next destination address case 0x318/4: // DMA Channel 0 next destination address
{ {
mame_printf_debug("CDE: DMA0 next dst addr %08X\n", d); mame_printf_debug("CDE: DMA0 next dst addr %08X\n", d);
cde_dma[0].next_dst_addr = d; state->cde_dma[0].next_dst_addr = d;
break; break;
} }
case 0x31c/4: // DMA Channel 0 next length? case 0x31c/4: // DMA Channel 0 next length?
{ {
mame_printf_debug("CDE: DMA0 next length %08X\n", d); mame_printf_debug("CDE: DMA0 next length %08X\n", d);
cde_dma[0].next_length = d; state->cde_dma[0].next_length = d;
break; break;
} }
@ -991,28 +1015,28 @@ static WRITE64_HANDLER(cde_w)
{ {
mame_printf_debug("CDE: DMA1 dst addr %08X\n", d); mame_printf_debug("CDE: DMA1 dst addr %08X\n", d);
cde_dma[1].dst_addr = d; state->cde_dma[1].dst_addr = d;
break; break;
} }
case 0x32c/4: // DMA Channel 1 length? case 0x32c/4: // DMA Channel 1 length?
{ {
mame_printf_debug("CDE: DMA1 length %08X\n", d); mame_printf_debug("CDE: DMA1 length %08X\n", d);
cde_dma[1].length = d; state->cde_dma[1].length = d;
break; break;
} }
case 0x338/4: // DMA Channel 1 next destination address case 0x338/4: // DMA Channel 1 next destination address
{ {
mame_printf_debug("CDE: DMA1 next dst addr %08X\n", d); mame_printf_debug("CDE: DMA1 next dst addr %08X\n", d);
cde_dma[1].next_dst_addr = d; state->cde_dma[1].next_dst_addr = d;
break; break;
} }
case 0x33c/4: // DMA Channel 1 next length? case 0x33c/4: // DMA Channel 1 next length?
{ {
mame_printf_debug("CDE: DMA1 next length %08X\n", d); mame_printf_debug("CDE: DMA1 next length %08X\n", d);
cde_dma[1].next_length = d; state->cde_dma[1].next_length = d;
break; break;
} }
@ -1020,12 +1044,12 @@ static WRITE64_HANDLER(cde_w)
{ {
if (d & 0x80000000) if (d & 0x80000000)
{ {
irq_active &= ~0x8; state->irq_active &= ~0x8;
} }
if (d & 0x60000000) if (d & 0x60000000)
{ {
cde_dma[0].dma_done = 0; state->cde_dma[0].dma_done = 0;
cde_dma[1].dma_done = 0; state->cde_dma[1].dma_done = 0;
} }
break; break;
} }
@ -1102,7 +1126,7 @@ static ADDRESS_MAP_START( m2_main, ADDRESS_SPACE_PROGRAM, 64 )
AM_RANGE(0x10000000, 0x10000007) AM_READ(cpu_r) AM_RANGE(0x10000000, 0x10000007) AM_READ(cpu_r)
AM_RANGE(0x10000008, 0x10001007) AM_NOP // ??? AM_RANGE(0x10000008, 0x10001007) AM_NOP // ???
AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share2") AM_RANGE(0x20000000, 0x201fffff) AM_ROM AM_SHARE("share2")
AM_RANGE(0x40000000, 0x407fffff) AM_RAM AM_SHARE("share3") AM_BASE(&main_ram) AM_RANGE(0x40000000, 0x407fffff) AM_RAM AM_SHARE("share3") AM_BASE_MEMBER(konamim2_state, main_ram)
AM_RANGE(0xfff00000, 0xffffffff) AM_ROM AM_REGION("boot", 0) AM_SHARE("share2") AM_RANGE(0xfff00000, 0xffffffff) AM_ROM AM_REGION("boot", 0) AM_SHARE("share2")
ADDRESS_MAP_END ADDRESS_MAP_END
@ -1117,20 +1141,21 @@ static const powerpc_config ppc602_config =
static INTERRUPT_GEN(m2) static INTERRUPT_GEN(m2)
{ {
if (irq_enable & 0x800000) konamim2_state *state = device->machine->driver_data<konamim2_state>();
if (state->irq_enable & 0x800000)
{ {
irq_active |= 0x800000; state->irq_active |= 0x800000;
} }
/*if (irq_enable & 0x8) /*if (state->irq_enable & 0x8)
{ {
irq_active |= 0x8; state->irq_active |= 0x8;
}*/ }*/
cpu_set_input_line(device, INPUT_LINE_IRQ0, ASSERT_LINE); cpu_set_input_line(device, INPUT_LINE_IRQ0, ASSERT_LINE);
} }
static MACHINE_CONFIG_START( m2, driver_device ) static MACHINE_CONFIG_START( m2, konamim2_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", PPC602, 33000000) /* actually PPC602, 66MHz */ MCFG_CPU_ADD("maincpu", PPC602, 33000000) /* actually PPC602, 66MHz */
@ -1257,8 +1282,9 @@ ROM_END
static DRIVER_INIT( m2 ) static DRIVER_INIT( m2 )
{ {
unk3 = U64(0xffffffffffffffff); konamim2_state *state = machine->driver_data<konamim2_state>();
unk20004 = 0; state->unk3 = U64(0xffffffffffffffff);
state->unk20004 = 0;
cde_init(machine); cde_init(machine);
} }

View File

@ -627,7 +627,6 @@ Notes:
#include "emu.h" #include "emu.h"
#include "cpu/v60/v60.h" #include "cpu/v60/v60.h"
#include "deprecat.h" #include "deprecat.h"
#include "includes/system16.h"
#include "video/segaic24.h" #include "video/segaic24.h"
#include "cpu/m68000/m68000.h" #include "cpu/m68000/m68000.h"
#include "cpu/mb86233/mb86233.h" #include "cpu/mb86233/mb86233.h"
@ -636,10 +635,7 @@ Notes:
#include "machine/nvram.h" #include "machine/nvram.h"
#include "includes/model1.h" #include "includes/model1.h"
static int model1_sound_irq;
#define FIFO_SIZE (8)
static int to_68k[FIFO_SIZE], fifo_wptr, fifo_rptr;
static READ16_HANDLER( io_r ) static READ16_HANDLER( io_r )
{ {
@ -683,19 +679,20 @@ static WRITE16_HANDLER( bank_w )
} }
static int last_irq;
static void irq_raise(running_machine *machine, int level) static void irq_raise(running_machine *machine, int level)
{ {
model1_state *state = machine->driver_data<model1_state>();
// logerror("irq: raising %d\n", level); // logerror("irq: raising %d\n", level);
// irq_status |= (1 << level); // irq_status |= (1 << level);
last_irq = level; state->last_irq = level;
cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE); cputag_set_input_line(machine, "maincpu", 0, HOLD_LINE);
} }
static IRQ_CALLBACK(irq_callback) static IRQ_CALLBACK(irq_callback)
{ {
return last_irq; model1_state *state = device->machine->driver_data<model1_state>();
return state->last_irq;
} }
// vf // vf
// 1 = fe3ed4 // 1 = fe3ed4
@ -719,16 +716,17 @@ static void irq_init(running_machine *machine)
static INTERRUPT_GEN(model1_interrupt) static INTERRUPT_GEN(model1_interrupt)
{ {
model1_state *state = device->machine->driver_data<model1_state>();
if (cpu_getiloops(device)) if (cpu_getiloops(device))
{ {
irq_raise(device->machine, 1); irq_raise(device->machine, 1);
} }
else else
{ {
irq_raise(device->machine, model1_sound_irq); irq_raise(device->machine, state->sound_irq);
// if the FIFO has something in it, signal the 68k too // if the FIFO has something in it, signal the 68k too
if (fifo_rptr != fifo_wptr) if (state->fifo_rptr != state->fifo_wptr)
{ {
cputag_set_input_line(device->machine, "audiocpu", 2, HOLD_LINE); cputag_set_input_line(device->machine, "audiocpu", 2, HOLD_LINE);
} }
@ -737,33 +735,35 @@ static INTERRUPT_GEN(model1_interrupt)
static MACHINE_RESET(model1) static MACHINE_RESET(model1)
{ {
model1_state *state = machine->driver_data<model1_state>();
memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x1000000); memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x1000000);
irq_init(machine); irq_init(machine);
model1_tgp_reset(machine, !strcmp(machine->gamedrv->name, "swa") || !strcmp(machine->gamedrv->name, "wingwar") || !strcmp(machine->gamedrv->name, "wingwaru") || !strcmp(machine->gamedrv->name, "wingwarj")); model1_tgp_reset(machine, !strcmp(machine->gamedrv->name, "swa") || !strcmp(machine->gamedrv->name, "wingwar") || !strcmp(machine->gamedrv->name, "wingwaru") || !strcmp(machine->gamedrv->name, "wingwarj"));
if (!strcmp(machine->gamedrv->name, "swa")) if (!strcmp(machine->gamedrv->name, "swa"))
{ {
model1_sound_irq = 0; state->sound_irq = 0;
} }
else else
{ {
model1_sound_irq = 3; state->sound_irq = 3;
} }
// init the sound FIFO // init the sound FIFO
fifo_rptr = fifo_wptr = 0; state->fifo_rptr = state->fifo_wptr = 0;
memset(to_68k, 0, sizeof(to_68k)); memset(state->to_68k, 0, sizeof(state->to_68k));
} }
static MACHINE_RESET(model1_vr) static MACHINE_RESET(model1_vr)
{ {
model1_state *state = machine->driver_data<model1_state>();
memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x1000000); memory_set_bankptr(machine, "bank1", machine->region("maincpu")->base() + 0x1000000);
irq_init(machine); irq_init(machine);
model1_vr_tgp_reset(machine); model1_vr_tgp_reset(machine);
model1_sound_irq = 3; state->sound_irq = 3;
// init the sound FIFO // init the sound FIFO
fifo_rptr = fifo_wptr = 0; state->fifo_rptr = state->fifo_wptr = 0;
memset(to_68k, 0, sizeof(to_68k)); memset(state->to_68k, 0, sizeof(state->to_68k));
} }
static READ16_HANDLER( network_ctl_r ) static READ16_HANDLER( network_ctl_r )
@ -780,19 +780,21 @@ static WRITE16_HANDLER( network_ctl_w )
static WRITE16_HANDLER(md1_w) static WRITE16_HANDLER(md1_w)
{ {
COMBINE_DATA(model1_display_list1+offset); model1_state *state = space->machine->driver_data<model1_state>();
COMBINE_DATA(state->display_list1+offset);
if(0 && offset) if(0 && offset)
return; return;
if(1 && model1_dump) if(1 && state->dump)
logerror("TGP: md1_w %x, %04x @ %04x (%x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu)); logerror("TGP: md1_w %x, %04x @ %04x (%x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu));
} }
static WRITE16_HANDLER(md0_w) static WRITE16_HANDLER(md0_w)
{ {
COMBINE_DATA(model1_display_list0+offset); model1_state *state = space->machine->driver_data<model1_state>();
COMBINE_DATA(state->display_list0+offset);
if(0 && offset) if(0 && offset)
return; return;
if(1 && model1_dump) if(1 && state->dump)
logerror("TGP: md0_w %x, %04x @ %04x (%x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu)); logerror("TGP: md0_w %x, %04x @ %04x (%x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu));
} }
@ -804,37 +806,37 @@ static WRITE16_HANDLER(p_w)
logerror("XVIDEO: p_w %x, %04x @ %04x (%x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu)); logerror("XVIDEO: p_w %x, %04x @ %04x (%x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu));
} }
static UINT16 *mr;
static WRITE16_HANDLER(mr_w) static WRITE16_HANDLER(mr_w)
{ {
COMBINE_DATA(mr+offset); model1_state *state = space->machine->driver_data<model1_state>();
COMBINE_DATA(state->mr+offset);
if(0 && offset == 0x1138/2) if(0 && offset == 0x1138/2)
logerror("MR.w %x, %04x @ %04x (%x)\n", offset*2+0x500000, data, mem_mask, cpu_get_pc(space->cpu)); logerror("MR.w %x, %04x @ %04x (%x)\n", offset*2+0x500000, data, mem_mask, cpu_get_pc(space->cpu));
} }
static UINT16 *mr2;
static WRITE16_HANDLER(mr2_w) static WRITE16_HANDLER(mr2_w)
{ {
COMBINE_DATA(mr2+offset); model1_state *state = space->machine->driver_data<model1_state>();
COMBINE_DATA(state->mr2+offset);
#if 0 #if 0
if(0 && offset == 0x6e8/2) { if(0 && offset == 0x6e8/2) {
logerror("MR.w %x, %04x @ %04x (%x)\n", offset*2+0x400000, data, mem_mask, cpu_get_pc(space->cpu)); logerror("MR.w %x, %04x @ %04x (%x)\n", offset*2+0x400000, data, mem_mask, cpu_get_pc(space->cpu));
} }
if(offset/2 == 0x3680/4) if(offset/2 == 0x3680/4)
logerror("MW f80[r25], %04x%04x (%x)\n", mr2[0x3680/2+1], mr2[0x3680/2], cpu_get_pc(space->cpu)); logerror("MW f80[r25], %04x%04x (%x)\n", state->mr2[0x3680/2+1], state->mr2[0x3680/2], cpu_get_pc(space->cpu));
if(offset/2 == 0x06ca/4) if(offset/2 == 0x06ca/4)
logerror("MW fca[r19], %04x%04x (%x)\n", mr2[0x06ca/2+1], mr2[0x06ca/2], cpu_get_pc(space->cpu)); logerror("MW fca[r19], %04x%04x (%x)\n", state->mr2[0x06ca/2+1], state->mr2[0x06ca/2], cpu_get_pc(space->cpu));
if(offset/2 == 0x1eca/4) if(offset/2 == 0x1eca/4)
logerror("MW fca[r22], %04x%04x (%x)\n", mr2[0x1eca/2+1], mr2[0x1eca/2], cpu_get_pc(space->cpu)); logerror("MW fca[r22], %04x%04x (%x)\n", state->mr2[0x1eca/2+1], state->mr2[0x1eca/2], cpu_get_pc(space->cpu));
#endif #endif
// wingwar scene position, pc=e1ce -> d735 // wingwar scene position, pc=e1ce -> d735
if(offset/2 == 0x1f08/4) if(offset/2 == 0x1f08/4)
logerror("MW 8[r10], %f (%x)\n", *(float *)(mr2+0x1f08/2), cpu_get_pc(space->cpu)); logerror("MW 8[r10], %f (%x)\n", *(float *)(state->mr2+0x1f08/2), cpu_get_pc(space->cpu));
if(offset/2 == 0x1f0c/4) if(offset/2 == 0x1f0c/4)
logerror("MW c[r10], %f (%x)\n", *(float *)(mr2+0x1f0c/2), cpu_get_pc(space->cpu)); logerror("MW c[r10], %f (%x)\n", *(float *)(state->mr2+0x1f0c/2), cpu_get_pc(space->cpu));
if(offset/2 == 0x1f10/4) if(offset/2 == 0x1f10/4)
logerror("MW 10[r10], %f (%x)\n", *(float *)(mr2+0x1f10/2), cpu_get_pc(space->cpu)); logerror("MW 10[r10], %f (%x)\n", *(float *)(state->mr2+0x1f10/2), cpu_get_pc(space->cpu));
} }
static READ16_HANDLER( snd_68k_ready_r ) static READ16_HANDLER( snd_68k_ready_r )
@ -852,9 +854,10 @@ static READ16_HANDLER( snd_68k_ready_r )
static WRITE16_HANDLER( snd_latch_to_68k_w ) static WRITE16_HANDLER( snd_latch_to_68k_w )
{ {
to_68k[fifo_wptr] = data; model1_state *state = space->machine->driver_data<model1_state>();
fifo_wptr++; state->to_68k[state->fifo_wptr] = data;
if (fifo_wptr >= FIFO_SIZE) fifo_wptr = 0; state->fifo_wptr++;
if (state->fifo_wptr >= ARRAY_LENGTH(state->to_68k)) state->fifo_wptr = 0;
// signal the 68000 that there's data waiting // signal the 68000 that there's data waiting
cputag_set_input_line(space->machine, "audiocpu", 2, HOLD_LINE); cputag_set_input_line(space->machine, "audiocpu", 2, HOLD_LINE);
@ -867,11 +870,11 @@ static ADDRESS_MAP_START( model1_mem, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x100000, 0x1fffff) AM_ROMBANK("bank1") AM_RANGE(0x100000, 0x1fffff) AM_ROMBANK("bank1")
AM_RANGE(0x200000, 0x2fffff) AM_ROM AM_RANGE(0x200000, 0x2fffff) AM_ROM
AM_RANGE(0x400000, 0x40ffff) AM_RAM_WRITE(mr2_w) AM_BASE(&mr2) AM_RANGE(0x400000, 0x40ffff) AM_RAM_WRITE(mr2_w) AM_BASE_MEMBER(model1_state, mr2)
AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(mr_w) AM_BASE(&mr) AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(mr_w) AM_BASE_MEMBER(model1_state, mr)
AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(md0_w) AM_BASE(&model1_display_list0) AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(md0_w) AM_BASE_MEMBER(model1_state, display_list0)
AM_RANGE(0x610000, 0x61ffff) AM_RAM_WRITE(md1_w) AM_BASE(&model1_display_list1) AM_RANGE(0x610000, 0x61ffff) AM_RAM_WRITE(md1_w) AM_BASE_MEMBER(model1_state, display_list1)
AM_RANGE(0x680000, 0x680003) AM_READWRITE(model1_listctl_r, model1_listctl_w) AM_RANGE(0x680000, 0x680003) AM_READWRITE(model1_listctl_r, model1_listctl_w)
AM_RANGE(0x700000, 0x70ffff) AM_READWRITE(sys24_tile_r, sys24_tile_w) AM_RANGE(0x700000, 0x70ffff) AM_READWRITE(sys24_tile_r, sys24_tile_w)
@ -882,7 +885,7 @@ static ADDRESS_MAP_START( model1_mem, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x780000, 0x7fffff) AM_READWRITE(sys24_char_r, sys24_char_w) AM_RANGE(0x780000, 0x7fffff) AM_READWRITE(sys24_char_r, sys24_char_w)
AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(p_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(p_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x910000, 0x91bfff) AM_RAM AM_BASE(&model1_color_xlat) AM_RANGE(0x910000, 0x91bfff) AM_RAM AM_BASE_MEMBER(model1_state, color_xlat)
AM_RANGE(0xc00000, 0xc0003f) AM_READ(io_r) AM_WRITENOP AM_RANGE(0xc00000, 0xc0003f) AM_READ(io_r) AM_WRITENOP
@ -915,11 +918,11 @@ static ADDRESS_MAP_START( model1_vr_mem, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x100000, 0x1fffff) AM_ROMBANK("bank1") AM_RANGE(0x100000, 0x1fffff) AM_ROMBANK("bank1")
AM_RANGE(0x200000, 0x2fffff) AM_ROM AM_RANGE(0x200000, 0x2fffff) AM_ROM
AM_RANGE(0x400000, 0x40ffff) AM_RAM_WRITE(mr2_w) AM_BASE(&mr2) AM_RANGE(0x400000, 0x40ffff) AM_RAM_WRITE(mr2_w) AM_BASE_MEMBER(model1_state, mr2)
AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(mr_w) AM_BASE(&mr) AM_RANGE(0x500000, 0x53ffff) AM_RAM_WRITE(mr_w) AM_BASE_MEMBER(model1_state, mr)
AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(md0_w) AM_BASE(&model1_display_list0) AM_RANGE(0x600000, 0x60ffff) AM_RAM_WRITE(md0_w) AM_BASE_MEMBER(model1_state, display_list0)
AM_RANGE(0x610000, 0x61ffff) AM_RAM_WRITE(md1_w) AM_BASE(&model1_display_list1) AM_RANGE(0x610000, 0x61ffff) AM_RAM_WRITE(md1_w) AM_BASE_MEMBER(model1_state, display_list1)
AM_RANGE(0x680000, 0x680003) AM_READWRITE(model1_listctl_r, model1_listctl_w) AM_RANGE(0x680000, 0x680003) AM_READWRITE(model1_listctl_r, model1_listctl_w)
AM_RANGE(0x700000, 0x70ffff) AM_READWRITE(sys24_tile_r, sys24_tile_w) AM_RANGE(0x700000, 0x70ffff) AM_READWRITE(sys24_tile_r, sys24_tile_w)
@ -930,7 +933,7 @@ static ADDRESS_MAP_START( model1_vr_mem, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x780000, 0x7fffff) AM_READWRITE(sys24_char_r, sys24_char_w) AM_RANGE(0x780000, 0x7fffff) AM_READWRITE(sys24_char_r, sys24_char_w)
AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(p_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(p_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x910000, 0x91bfff) AM_RAM AM_BASE(&model1_color_xlat) AM_RANGE(0x910000, 0x91bfff) AM_RAM AM_BASE_MEMBER(model1_state, color_xlat)
AM_RANGE(0xc00000, 0xc0003f) AM_READ(io_r) AM_WRITENOP AM_RANGE(0xc00000, 0xc0003f) AM_READ(io_r) AM_WRITENOP
@ -960,12 +963,13 @@ ADDRESS_MAP_END
static READ16_HANDLER( m1_snd_68k_latch_r ) static READ16_HANDLER( m1_snd_68k_latch_r )
{ {
model1_state *state = space->machine->driver_data<model1_state>();
UINT16 retval; UINT16 retval;
retval = to_68k[fifo_rptr]; retval = state->to_68k[state->fifo_rptr];
fifo_rptr++; state->fifo_rptr++;
if (fifo_rptr >= FIFO_SIZE) fifo_rptr = 0; if (state->fifo_rptr >= ARRAY_LENGTH(state->to_68k)) state->fifo_rptr = 0;
return retval; return retval;
} }
@ -1497,7 +1501,7 @@ ROM_START( wingwarj )
ROM_END ROM_END
static MACHINE_CONFIG_START( model1, driver_device ) static MACHINE_CONFIG_START( model1, model1_state )
MCFG_CPU_ADD("maincpu", V60, 16000000) MCFG_CPU_ADD("maincpu", V60, 16000000)
MCFG_CPU_PROGRAM_MAP(model1_mem) MCFG_CPU_PROGRAM_MAP(model1_mem)
MCFG_CPU_IO_MAP(model1_io) MCFG_CPU_IO_MAP(model1_io)
@ -1537,7 +1541,7 @@ static MACHINE_CONFIG_START( model1, driver_device )
MCFG_SOUND_ROUTE(1, "rspeaker", 1.0) MCFG_SOUND_ROUTE(1, "rspeaker", 1.0)
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_START( model1_vr, driver_device ) static MACHINE_CONFIG_START( model1_vr, model1_state )
MCFG_CPU_ADD("maincpu", V60, 16000000) MCFG_CPU_ADD("maincpu", V60, 16000000)
MCFG_CPU_PROGRAM_MAP(model1_vr_mem) MCFG_CPU_PROGRAM_MAP(model1_vr_mem)
MCFG_CPU_IO_MAP(model1_vr_io) MCFG_CPU_IO_MAP(model1_vr_io)

File diff suppressed because it is too large Load Diff

View File

@ -607,50 +607,47 @@ ALL VROM ROMs are 16M MASK
#include "sound/scsp.h" #include "sound/scsp.h"
#include "includes/model3.h" #include "includes/model3.h"
static UINT8 irq_enable;
static UINT8 irq_state;
static UINT8 scsi_irq_state;
int model3_step;
UINT32 *model3_vrom;
static UINT64 *work_ram;
static int model3_crom_bank = 0;
static int model3_controls_bank;
static UINT32 real3d_device_id;
static void real3d_dma_callback(running_machine *machine, UINT32 src, UINT32 dst, int length, int byteswap); static void real3d_dma_callback(running_machine *machine, UINT32 src, UINT32 dst, int length, int byteswap);
static UINT16 *model3_soundram;
static void update_irq_state(running_machine *machine) static void update_irq_state(running_machine *machine)
{ {
if ((irq_enable & irq_state) || scsi_irq_state) model3_state *state = machine->driver_data<model3_state>();
if ((state->irq_enable & state->irq_state) || state->scsi_irq_state)
{ {
// printf("IRQ set: state %x enable %x scsi %x\n", irq_state, irq_enable, scsi_irq_state); // printf("IRQ set: state %x enable %x scsi %x\n", state->irq_state, state->irq_enable, state->scsi_irq_state);
cputag_set_input_line(machine, "maincpu", PPC_IRQ, ASSERT_LINE); cputag_set_input_line(machine, "maincpu", PPC_IRQ, ASSERT_LINE);
scsi_irq_state = 0; state->scsi_irq_state = 0;
} }
else else
{ {
// printf("IRQ clear: state %x enable %x scsi %x\n", irq_state, irq_enable, scsi_irq_state); // printf("IRQ clear: state %x enable %x scsi %x\n", state->irq_state, state->irq_enable, state->scsi_irq_state);
cputag_set_input_line(machine, "maincpu", PPC_IRQ, CLEAR_LINE); cputag_set_input_line(machine, "maincpu", PPC_IRQ, CLEAR_LINE);
} }
} }
void model3_set_irq_line(running_machine *machine, UINT8 bit, int state) void model3_set_irq_line(running_machine *machine, UINT8 bit, int line)
{ {
if (state != CLEAR_LINE) model3_state *state = machine->driver_data<model3_state>();
irq_state |= bit; if (line != CLEAR_LINE)
state->irq_state |= bit;
else else
irq_state &= ~bit; state->irq_state &= ~bit;
update_irq_state(machine); update_irq_state(machine);
} }
static UINT32 pci_device_get_reg(int device, int reg) /*****************************************************************************/
/* Motorola MPC105 PCI Bridge/Memory Controller */
static UINT32 pci_device_get_reg(model3_state *state)
{ {
int device = state->pci_device;
int reg = state->pci_reg;
switch(device) switch(device)
{ {
case 11: /* ??? */ case 11: /* ??? */
@ -665,7 +662,7 @@ static UINT32 pci_device_get_reg(int device, int reg)
case 13: /* Real3D Controller chip */ case 13: /* Real3D Controller chip */
switch(reg) switch(reg)
{ {
case 0: return real3d_device_id; /* PCI Vendor ID & Device ID */ case 0: return state->real3d_device_id; /* PCI Vendor ID & Device ID */
default: default:
logerror("pci_device_get_reg: Real3D controller, unknown reg %02X", reg); logerror("pci_device_get_reg: Real3D controller, unknown reg %02X", reg);
break; break;
@ -699,8 +696,11 @@ static UINT32 pci_device_get_reg(int device, int reg)
return 0; return 0;
} }
static void pci_device_set_reg(int device, int reg, UINT32 value) static void pci_device_set_reg(model3_state *state, UINT32 value)
{ {
int device = state->pci_device;
int reg = state->pci_reg;
switch(device) switch(device)
{ {
case 11: /* Unknown device for now !!! */ case 11: /* Unknown device for now !!! */
@ -769,184 +769,186 @@ static void pci_device_set_reg(int device, int reg, UINT32 value)
} }
} }
/*****************************************************************************/
/* Motorola MPC105 PCI Bridge/Memory Controller */
static UINT32 mpc105_regs[0x40];
static UINT32 mpc105_addr;
static int pci_bus;
static int pci_device;
static int pci_function;
static int pci_reg;
static READ64_HANDLER( mpc105_addr_r ) static READ64_HANDLER( mpc105_addr_r )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
return (UINT64)mpc105_addr << 32; return (UINT64)state->mpc105_addr << 32;
} }
return 0; return 0;
} }
static WRITE64_HANDLER( mpc105_addr_w ) static WRITE64_HANDLER( mpc105_addr_w )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
UINT32 d = FLIPENDIAN_INT32((UINT32)(data >> 32)); UINT32 d = FLIPENDIAN_INT32((UINT32)(data >> 32));
mpc105_addr = data >> 32; state->mpc105_addr = data >> 32;
pci_bus = (d >> 16) & 0xff; state->pci_bus = (d >> 16) & 0xff;
pci_device = (d >> 11) & 0x1f; state->pci_device = (d >> 11) & 0x1f;
pci_function = (d >> 8) & 0x7; state->pci_function = (d >> 8) & 0x7;
pci_reg = (d >> 2) & 0x3f; state->pci_reg = (d >> 2) & 0x3f;
} }
} }
static READ64_HANDLER( mpc105_data_r ) static READ64_HANDLER( mpc105_data_r )
{ {
if(pci_device == 0) { model3_state *state = space->machine->driver_data<model3_state>();
return ((UINT64)(FLIPENDIAN_INT32(mpc105_regs[(pci_reg/2)+1])) << 32) | if(state->pci_device == 0) {
((UINT64)(FLIPENDIAN_INT32(mpc105_regs[(pci_reg/2)+0]))); return ((UINT64)(FLIPENDIAN_INT32(state->mpc105_regs[(state->pci_reg/2)+1])) << 32) |
((UINT64)(FLIPENDIAN_INT32(state->mpc105_regs[(state->pci_reg/2)+0])));
} }
return FLIPENDIAN_INT32(pci_device_get_reg(pci_device, pci_reg)); return FLIPENDIAN_INT32(pci_device_get_reg(state));
} }
static WRITE64_HANDLER( mpc105_data_w ) static WRITE64_HANDLER( mpc105_data_w )
{ {
if(pci_device == 0) { model3_state *state = space->machine->driver_data<model3_state>();
mpc105_regs[(pci_reg/2)+1] = FLIPENDIAN_INT32((UINT32)(data >> 32)); if(state->pci_device == 0) {
mpc105_regs[(pci_reg/2)+0] = FLIPENDIAN_INT32((UINT32)(data)); state->mpc105_regs[(state->pci_reg/2)+1] = FLIPENDIAN_INT32((UINT32)(data >> 32));
state->mpc105_regs[(state->pci_reg/2)+0] = FLIPENDIAN_INT32((UINT32)(data));
return; return;
} }
if (ACCESSING_BITS_0_31) if (ACCESSING_BITS_0_31)
{ {
pci_device_set_reg(pci_device, pci_reg, FLIPENDIAN_INT32((UINT32)data)); pci_device_set_reg(state, FLIPENDIAN_INT32((UINT32)data));
} }
} }
static READ64_HANDLER( mpc105_reg_r ) static READ64_HANDLER( mpc105_reg_r )
{ {
return ((UINT64)(mpc105_regs[(offset*2)+0]) << 32) | model3_state *state = space->machine->driver_data<model3_state>();
(UINT64)(mpc105_regs[(offset*2)+1]); return ((UINT64)(state->mpc105_regs[(offset*2)+0]) << 32) |
(UINT64)(state->mpc105_regs[(offset*2)+1]);
} }
static WRITE64_HANDLER( mpc105_reg_w ) static WRITE64_HANDLER( mpc105_reg_w )
{ {
mpc105_regs[(offset*2)+0] = (UINT32)(data >> 32); model3_state *state = space->machine->driver_data<model3_state>();
mpc105_regs[(offset*2)+1] = (UINT32)data; state->mpc105_regs[(offset*2)+0] = (UINT32)(data >> 32);
state->mpc105_regs[(offset*2)+1] = (UINT32)data;
} }
static void mpc105_init(void) static void mpc105_init(running_machine *machine)
{ {
model3_state *state = machine->driver_data<model3_state>();
/* set reset values */ /* set reset values */
memset(mpc105_regs, 0, sizeof(mpc105_regs)); memset(state->mpc105_regs, 0, sizeof(state->mpc105_regs));
mpc105_regs[0x00/4] = 0x00011057; /* Vendor ID & Device ID */ state->mpc105_regs[0x00/4] = 0x00011057; /* Vendor ID & Device ID */
mpc105_regs[0x04/4] = 0x00800006; /* PCI Command & PCI Status */ state->mpc105_regs[0x04/4] = 0x00800006; /* PCI Command & PCI Status */
mpc105_regs[0x08/4] = 0x00060000; /* Class code */ state->mpc105_regs[0x08/4] = 0x00060000; /* Class code */
mpc105_regs[0xa8/4] = 0x0010ff00; /* Processor interface configuration 1 */ state->mpc105_regs[0xa8/4] = 0x0010ff00; /* Processor interface configuration 1 */
mpc105_regs[0xac/4] = 0x060c000c; /* Processor interface configuration 2 */ state->mpc105_regs[0xac/4] = 0x060c000c; /* Processor interface configuration 2 */
mpc105_regs[0xb8/4] = 0x04000000; state->mpc105_regs[0xb8/4] = 0x04000000;
mpc105_regs[0xf0/4] = 0x0000ff02; /* Memory control configuration 1 */ state->mpc105_regs[0xf0/4] = 0x0000ff02; /* Memory control configuration 1 */
mpc105_regs[0xf4/4] = 0x00030000; /* Memory control configuration 2 */ state->mpc105_regs[0xf4/4] = 0x00030000; /* Memory control configuration 2 */
mpc105_regs[0xfc/4] = 0x00000010; /* Memory control configuration 4 */ state->mpc105_regs[0xfc/4] = 0x00000010; /* Memory control configuration 4 */
} }
/*****************************************************************************/ /*****************************************************************************/
/* Motorola MPC106 PCI Bridge/Memory Controller */ /* Motorola MPC106 PCI Bridge/Memory Controller */
static UINT32 mpc106_regs[0x40];
static UINT32 mpc106_addr;
static READ64_HANDLER( mpc106_addr_r ) static READ64_HANDLER( mpc106_addr_r )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
return (UINT64)mpc106_addr << 32; return (UINT64)state->mpc106_addr << 32;
} }
return 0; return 0;
} }
static WRITE64_HANDLER( mpc106_addr_w ) static WRITE64_HANDLER( mpc106_addr_w )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
UINT32 d = FLIPENDIAN_INT32((UINT32)(data >> 32)); UINT32 d = FLIPENDIAN_INT32((UINT32)(data >> 32));
if (((d >> 8) & 0xffffff) == 0x800000) if (((d >> 8) & 0xffffff) == 0x800000)
{ {
mpc106_addr = d & 0xff; state->mpc106_addr = d & 0xff;
} }
else else
{ {
mpc106_addr = data >> 32; state->mpc106_addr = data >> 32;
pci_bus = (d >> 16) & 0xff; state->pci_bus = (d >> 16) & 0xff;
pci_device = (d >> 11) & 0x1f; state->pci_device = (d >> 11) & 0x1f;
pci_function = (d >> 8) & 0x7; state->pci_function = (d >> 8) & 0x7;
pci_reg = (d >> 2) & 0x3f; state->pci_reg = (d >> 2) & 0x3f;
} }
} }
} }
static READ64_HANDLER( mpc106_data_r ) static READ64_HANDLER( mpc106_data_r )
{ {
if(pci_device == 0) { model3_state *state = space->machine->driver_data<model3_state>();
return ((UINT64)(FLIPENDIAN_INT32(mpc106_regs[(pci_reg/2)+1])) << 32) | if(state->pci_device == 0) {
((UINT64)(FLIPENDIAN_INT32(mpc106_regs[(pci_reg/2)+0]))); return ((UINT64)(FLIPENDIAN_INT32(state->mpc106_regs[(state->pci_reg/2)+1])) << 32) |
((UINT64)(FLIPENDIAN_INT32(state->mpc106_regs[(state->pci_reg/2)+0])));
} }
if (ACCESSING_BITS_32_63) if (ACCESSING_BITS_32_63)
{ {
return (UINT64)(FLIPENDIAN_INT32(pci_device_get_reg(pci_device, pci_reg))) << 32; return (UINT64)(FLIPENDIAN_INT32(pci_device_get_reg(state))) << 32;
} }
else else
{ {
return (UINT64)(FLIPENDIAN_INT32(pci_device_get_reg(pci_device, pci_reg))); return (UINT64)(FLIPENDIAN_INT32(pci_device_get_reg(state)));
} }
} }
static WRITE64_HANDLER( mpc106_data_w ) static WRITE64_HANDLER( mpc106_data_w )
{ {
if(pci_device == 0) { model3_state *state = space->machine->driver_data<model3_state>();
mpc106_regs[(pci_reg/2)+1] = FLIPENDIAN_INT32((UINT32)(data >> 32)); if(state->pci_device == 0) {
mpc106_regs[(pci_reg/2)+0] = FLIPENDIAN_INT32((UINT32)(data)); state->mpc106_regs[(state->pci_reg/2)+1] = FLIPENDIAN_INT32((UINT32)(data >> 32));
state->mpc106_regs[(state->pci_reg/2)+0] = FLIPENDIAN_INT32((UINT32)(data));
return; return;
} }
if (ACCESSING_BITS_0_31) if (ACCESSING_BITS_0_31)
{ {
pci_device_set_reg(pci_device, pci_reg, FLIPENDIAN_INT32((UINT32)data)); pci_device_set_reg(state, FLIPENDIAN_INT32((UINT32)data));
} }
} }
static READ64_HANDLER( mpc106_reg_r ) static READ64_HANDLER( mpc106_reg_r )
{ {
return ((UINT64)(mpc106_regs[(offset*2)+0]) << 32) | model3_state *state = space->machine->driver_data<model3_state>();
(UINT64)(mpc106_regs[(offset*2)+1]); return ((UINT64)(state->mpc106_regs[(offset*2)+0]) << 32) |
(UINT64)(state->mpc106_regs[(offset*2)+1]);
} }
static WRITE64_HANDLER( mpc106_reg_w ) static WRITE64_HANDLER( mpc106_reg_w )
{ {
mpc106_regs[(offset*2)+0] = (UINT32)(data >> 32); model3_state *state = space->machine->driver_data<model3_state>();
mpc106_regs[(offset*2)+1] = (UINT32)data; state->mpc106_regs[(offset*2)+0] = (UINT32)(data >> 32);
state->mpc106_regs[(offset*2)+1] = (UINT32)data;
} }
static void mpc106_init(void) static void mpc106_init(running_machine *machine)
{ {
model3_state *state = machine->driver_data<model3_state>();
/* set reset values */ /* set reset values */
memset(mpc106_regs, 0, sizeof(mpc106_regs)); memset(state->mpc106_regs, 0, sizeof(state->mpc106_regs));
mpc106_regs[0x00/4] = 0x00021057; /* Vendor ID & Device ID */ state->mpc106_regs[0x00/4] = 0x00021057; /* Vendor ID & Device ID */
mpc106_regs[0x04/4] = 0x00800006; /* PCI Command & PCI Status */ state->mpc106_regs[0x04/4] = 0x00800006; /* PCI Command & PCI Status */
mpc106_regs[0x08/4] = 0x00060000; /* Class code */ state->mpc106_regs[0x08/4] = 0x00060000; /* Class code */
mpc106_regs[0x0c/4] = 0x00000800; /* Cache line size */ state->mpc106_regs[0x0c/4] = 0x00000800; /* Cache line size */
mpc106_regs[0x70/4] = 0x00cd0000; /* Output driver control */ state->mpc106_regs[0x70/4] = 0x00cd0000; /* Output driver control */
mpc106_regs[0xa8/4] = 0x0010ff00; /* Processor interface configuration 1 */ state->mpc106_regs[0xa8/4] = 0x0010ff00; /* Processor interface configuration 1 */
mpc106_regs[0xac/4] = 0x060c000c; /* Processor interface configuration 2 */ state->mpc106_regs[0xac/4] = 0x060c000c; /* Processor interface configuration 2 */
mpc106_regs[0xb8/4] = 0x04000000; state->mpc106_regs[0xb8/4] = 0x04000000;
mpc106_regs[0xc0/4] = 0x00000100; /* Error enabling 1 */ state->mpc106_regs[0xc0/4] = 0x00000100; /* Error enabling 1 */
mpc106_regs[0xe0/4] = 0x00420fff; /* Emulation support configuration 1 */ state->mpc106_regs[0xe0/4] = 0x00420fff; /* Emulation support configuration 1 */
mpc106_regs[0xe8/4] = 0x00200000; /* Emulation support configuration 2 */ state->mpc106_regs[0xe8/4] = 0x00200000; /* Emulation support configuration 2 */
mpc106_regs[0xf0/4] = 0x0000ff02; /* Memory control configuration 1 */ state->mpc106_regs[0xf0/4] = 0x0000ff02; /* Memory control configuration 1 */
mpc106_regs[0xf4/4] = 0x00030000; /* Memory control configuration 2 */ state->mpc106_regs[0xf4/4] = 0x00030000; /* Memory control configuration 2 */
mpc106_regs[0xfc/4] = 0x00000010; /* Memory control configuration 4 */ state->mpc106_regs[0xfc/4] = 0x00000010; /* Memory control configuration 4 */
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1022,29 +1024,25 @@ static UINT32 scsi_fetch(running_machine *machine, UINT32 dsp)
static void scsi_irq_callback(running_machine *machine, int state) static void scsi_irq_callback(running_machine *machine, int state)
{ {
scsi_irq_state = state; model3_state *drvstate = machine->driver_data<model3_state>();
drvstate->scsi_irq_state = state;
update_irq_state(machine); update_irq_state(machine);
} }
/*****************************************************************************/ /*****************************************************************************/
/* Real3D DMA */ /* Real3D DMA */
static UINT32 dma_data;
static UINT32 dma_status;
static UINT32 dma_source;
static UINT32 dma_dest;
static UINT32 dma_endian;
static UINT32 dma_irq;
static READ64_HANDLER( real3d_dma_r ) static READ64_HANDLER( real3d_dma_r )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
switch(offset) switch(offset)
{ {
case 1: case 1:
return (dma_irq << 24) | (dma_endian << 8); return (state->dma_irq << 24) | (state->dma_endian << 8);
case 2: case 2:
if(ACCESSING_BITS_0_31) { if(ACCESSING_BITS_0_31) {
return dma_data; return state->dma_data;
} }
break; break;
} }
@ -1054,15 +1052,16 @@ static READ64_HANDLER( real3d_dma_r )
static WRITE64_HANDLER( real3d_dma_w ) static WRITE64_HANDLER( real3d_dma_w )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
switch(offset) switch(offset)
{ {
case 0: case 0:
if(ACCESSING_BITS_32_63) { /* DMA source address */ if(ACCESSING_BITS_32_63) { /* DMA source address */
dma_source = FLIPENDIAN_INT32((UINT32)(data >> 32)); state->dma_source = FLIPENDIAN_INT32((UINT32)(data >> 32));
return; return;
} }
if(ACCESSING_BITS_0_31) { /* DMA destination address */ if(ACCESSING_BITS_0_31) { /* DMA destination address */
dma_dest = FLIPENDIAN_INT32((UINT32)(data)); state->dma_dest = FLIPENDIAN_INT32((UINT32)(data));
return; return;
} }
break; break;
@ -1070,29 +1069,29 @@ static WRITE64_HANDLER( real3d_dma_w )
if(ACCESSING_BITS_32_63) /* DMA length */ if(ACCESSING_BITS_32_63) /* DMA length */
{ {
int length = FLIPENDIAN_INT32((UINT32)(data >> 32)) * 4; int length = FLIPENDIAN_INT32((UINT32)(data >> 32)) * 4;
if (dma_endian & 0x80) if (state->dma_endian & 0x80)
{ {
real3d_dma_callback(space->machine, dma_source, dma_dest, length, 0); real3d_dma_callback(space->machine, state->dma_source, state->dma_dest, length, 0);
} }
else else
{ {
real3d_dma_callback(space->machine, dma_source, dma_dest, length, 1); real3d_dma_callback(space->machine, state->dma_source, state->dma_dest, length, 1);
} }
dma_irq |= 0x01; state->dma_irq |= 0x01;
scsi_irq_callback(space->machine, 1); scsi_irq_callback(space->machine, 1);
return; return;
} }
else if(ACCESSING_BITS_16_23) else if(ACCESSING_BITS_16_23)
{ {
if(data & 0x10000) { if(data & 0x10000) {
dma_irq &= ~0x1; state->dma_irq &= ~0x1;
scsi_irq_callback(space->machine, 0); scsi_irq_callback(space->machine, 0);
} }
return; return;
} }
else if(ACCESSING_BITS_8_15) else if(ACCESSING_BITS_8_15)
{ {
dma_endian = (data >> 8) & 0xff; state->dma_endian = (data >> 8) & 0xff;
return; return;
} }
break; break;
@ -1100,16 +1099,16 @@ static WRITE64_HANDLER( real3d_dma_w )
if(ACCESSING_BITS_32_63) { /* DMA command */ if(ACCESSING_BITS_32_63) { /* DMA command */
UINT32 cmd = FLIPENDIAN_INT32((UINT32)(data >> 32)); UINT32 cmd = FLIPENDIAN_INT32((UINT32)(data >> 32));
if(cmd & 0x20000000) { if(cmd & 0x20000000) {
dma_data = FLIPENDIAN_INT32(real3d_device_id); /* (PCI Vendor & Device ID) */ state->dma_data = FLIPENDIAN_INT32(state->real3d_device_id); /* (PCI Vendor & Device ID) */
} }
else if(cmd & 0x80000000) { else if(cmd & 0x80000000) {
dma_status ^= 0xffffffff; state->dma_status ^= 0xffffffff;
dma_data = dma_status; state->dma_data = state->dma_status;
} }
return; return;
} }
if(ACCESSING_BITS_0_31) { /* ??? */ if(ACCESSING_BITS_0_31) { /* ??? */
dma_data = 0xffffffff; state->dma_data = 0xffffffff;
return; return;
} }
return; return;
@ -1187,11 +1186,12 @@ static void model3_exit(running_machine &machine)
static void configure_fast_ram(running_machine *machine) static void configure_fast_ram(running_machine *machine)
{ {
model3_state *state = machine->driver_data<model3_state>();
/* set conservative DRC options */ /* set conservative DRC options */
ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS - PPCDRC_ACCURATE_SINGLES); ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS - PPCDRC_ACCURATE_SINGLES);
/* configure fast RAM regions for DRC */ /* configure fast RAM regions for DRC */
ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x007fffff, FALSE, work_ram); ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x007fffff, FALSE, state->work_ram);
} }
static MACHINE_START(model3_10) static MACHINE_START(model3_10)
@ -1217,44 +1217,45 @@ static MACHINE_START(model3_21)
static void model3_init(running_machine *machine, int step) static void model3_init(running_machine *machine, int step)
{ {
model3_step = step; model3_state *state = machine->driver_data<model3_state>();
state->step = step;
memory_set_bankptr(machine, "bank1", machine->region( "user1" )->base() + 0x800000 ); /* banked CROM */ memory_set_bankptr(machine, "bank1", machine->region( "user1" )->base() + 0x800000 ); /* banked CROM */
memory_set_bankptr(machine, "bank4", machine->region("samples")->base() + 0x200000); memory_set_bankptr(machine, "bank4", machine->region("samples")->base() + 0x200000);
memory_set_bankptr(machine, "bank5", machine->region("samples")->base() + 0x600000); memory_set_bankptr(machine, "bank5", machine->region("samples")->base() + 0x600000);
// copy the 68k vector table into RAM // copy the 68k vector table into RAM
memcpy(model3_soundram, machine->region("audiocpu")->base()+0x80000, 16); memcpy(state->soundram, machine->region("audiocpu")->base()+0x80000, 16);
machine->device("audiocpu")->reset(); machine->device("audiocpu")->reset();
model3_machine_init(step); // step 1.5 model3_machine_init(machine, step); // step 1.5
model3_tap_reset(); model3_tap_reset(machine);
if(step < 0x20) { if(step < 0x20) {
if( mame_stricmp(machine->gamedrv->name, "vs215") == 0 || if( mame_stricmp(machine->gamedrv->name, "vs215") == 0 ||
mame_stricmp(machine->gamedrv->name, "vs29815") == 0 || mame_stricmp(machine->gamedrv->name, "vs29815") == 0 ||
mame_stricmp(machine->gamedrv->name, "bass") == 0 ) mame_stricmp(machine->gamedrv->name, "bass") == 0 )
{ {
mpc106_init(); mpc106_init(machine);
} }
else else
{ {
mpc105_init(); mpc105_init(machine);
} }
real3d_device_id = 0x16c311db; /* PCI Vendor ID (11db = SEGA), Device ID (16c3 = 315-5827) */ state->real3d_device_id = 0x16c311db; /* PCI Vendor ID (11db = SEGA), Device ID (16c3 = 315-5827) */
} }
else { else {
mpc106_init(); mpc106_init(machine);
// some step 2+ games need the older PCI ID (obvious symptom: // some step 2+ games need the older PCI ID (obvious symptom:
// vbl is enabled briefly then disabled so the game hangs) // vbl is enabled briefly then disabled so the game hangs)
if (mame_stricmp(machine->gamedrv->name, "magtruck") == 0 || if (mame_stricmp(machine->gamedrv->name, "magtruck") == 0 ||
mame_stricmp(machine->gamedrv->name, "von254g") == 0) mame_stricmp(machine->gamedrv->name, "von254g") == 0)
{ {
real3d_device_id = 0x16c311db; /* PCI Vendor ID (11db = SEGA), Device ID (16c3 = 315-5827) */ state->real3d_device_id = 0x16c311db; /* PCI Vendor ID (11db = SEGA), Device ID (16c3 = 315-5827) */
} }
else else
{ {
real3d_device_id = 0x178611db; /* PCI Vendor ID (11db = SEGA), Device ID (1786 = 315-6022) */ state->real3d_device_id = 0x178611db; /* PCI Vendor ID (11db = SEGA), Device ID (1786 = 315-6022) */
} }
} }
} }
@ -1264,25 +1265,20 @@ static MACHINE_RESET(model3_15) { model3_init(machine, 0x15); }
static MACHINE_RESET(model3_20) { model3_init(machine, 0x20); } static MACHINE_RESET(model3_20) { model3_init(machine, 0x20); }
static MACHINE_RESET(model3_21) { model3_init(machine, 0x21); } static MACHINE_RESET(model3_21) { model3_init(machine, 0x21); }
static UINT64 controls_2;
static UINT64 controls_3;
static UINT8 model3_serial_fifo1;
static UINT8 model3_serial_fifo2;
static int lightgun_reg_sel;
static int adc_channel;
static READ64_HANDLER( model3_ctrl_r ) static READ64_HANDLER( model3_ctrl_r )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
switch( offset ) switch( offset )
{ {
case 0: case 0:
if (ACCESSING_BITS_56_63) if (ACCESSING_BITS_56_63)
{ {
return (UINT64)model3_controls_bank << 56; return (UINT64)state->controls_bank << 56;
} }
else if (ACCESSING_BITS_24_31) else if (ACCESSING_BITS_24_31)
{ {
if(model3_controls_bank & 0x1) if(state->controls_bank & 0x1)
{ {
return (input_port_read(space->machine, "IN1")) << 24; return (input_port_read(space->machine, "IN1")) << 24;
} }
@ -1316,14 +1312,14 @@ static READ64_HANDLER( model3_ctrl_r )
case 5: case 5:
if (ACCESSING_BITS_24_31) /* Serial comm RX FIFO 1 */ if (ACCESSING_BITS_24_31) /* Serial comm RX FIFO 1 */
{ {
return (UINT64)model3_serial_fifo1 << 24; return (UINT64)state->serial_fifo1 << 24;
} }
break; break;
case 6: case 6:
if (ACCESSING_BITS_56_63) /* Serial comm RX FIFO 2 */ if (ACCESSING_BITS_56_63) /* Serial comm RX FIFO 2 */
{ {
return (UINT64)model3_serial_fifo2 << 56; return (UINT64)state->serial_fifo2 << 56;
} }
else if (ACCESSING_BITS_24_31) /* Serial comm full/empty flags */ else if (ACCESSING_BITS_24_31) /* Serial comm full/empty flags */
{ {
@ -1335,9 +1331,9 @@ static READ64_HANDLER( model3_ctrl_r )
if (ACCESSING_BITS_24_31) /* ADC Data read */ if (ACCESSING_BITS_24_31) /* ADC Data read */
{ {
static const char *const adcnames[] = { "AN0", "AN1", "AN2", "AN3", "AN4", "AN5", "AN6", "AN7" }; static const char *const adcnames[] = { "AN0", "AN1", "AN2", "AN3", "AN4", "AN5", "AN6", "AN7" };
UINT8 adc_data = input_port_read_safe(space->machine, adcnames[adc_channel], 0); UINT8 adc_data = input_port_read_safe(space->machine, adcnames[state->adc_channel], 0);
adc_channel++; state->adc_channel++;
adc_channel &= 0x7; state->adc_channel &= 0x7;
return (UINT64)adc_data << 24; return (UINT64)adc_data << 24;
} }
break; break;
@ -1349,6 +1345,7 @@ static READ64_HANDLER( model3_ctrl_r )
static WRITE64_HANDLER( model3_ctrl_w ) static WRITE64_HANDLER( model3_ctrl_w )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
switch(offset) switch(offset)
{ {
case 0: case 0:
@ -1359,16 +1356,16 @@ static WRITE64_HANDLER( model3_ctrl_w )
eeprom_write_bit(device, (reg & 0x20) ? 1 : 0); eeprom_write_bit(device, (reg & 0x20) ? 1 : 0);
eeprom_set_clock_line(device, (reg & 0x80) ? ASSERT_LINE : CLEAR_LINE); eeprom_set_clock_line(device, (reg & 0x80) ? ASSERT_LINE : CLEAR_LINE);
eeprom_set_cs_line(device, (reg & 0x40) ? CLEAR_LINE : ASSERT_LINE); eeprom_set_cs_line(device, (reg & 0x40) ? CLEAR_LINE : ASSERT_LINE);
model3_controls_bank = reg & 0xff; state->controls_bank = reg & 0xff;
} }
return; return;
case 2: case 2:
COMBINE_DATA(&controls_2); COMBINE_DATA(&state->controls_2);
return; return;
case 3: case 3:
COMBINE_DATA(&controls_3); COMBINE_DATA(&state->controls_3);
return; return;
case 4: case 4:
@ -1381,40 +1378,40 @@ static WRITE64_HANDLER( model3_ctrl_w )
switch(data >> 24) switch(data >> 24)
{ {
case 0x00: case 0x00:
lightgun_reg_sel = model3_serial_fifo2; state->lightgun_reg_sel = state->serial_fifo2;
break; break;
case 0x87: case 0x87:
model3_serial_fifo1 = 0; state->serial_fifo1 = 0;
switch(lightgun_reg_sel) /* read lightrun register */ switch(state->lightgun_reg_sel) /* read lightrun register */
{ {
case 0: /* player 1 gun X-position, lower 8-bits */ case 0: /* player 1 gun X-position, lower 8-bits */
model3_serial_fifo2 = input_port_read(space->machine, "LIGHT0_Y") & 0xff; state->serial_fifo2 = input_port_read(space->machine, "LIGHT0_Y") & 0xff;
break; break;
case 1: /* player 1 gun X-position, upper 2-bits */ case 1: /* player 1 gun X-position, upper 2-bits */
model3_serial_fifo2 = (input_port_read(space->machine, "LIGHT0_Y") >> 8) & 0x3; state->serial_fifo2 = (input_port_read(space->machine, "LIGHT0_Y") >> 8) & 0x3;
break; break;
case 2: /* player 1 gun Y-position, lower 8-bits */ case 2: /* player 1 gun Y-position, lower 8-bits */
model3_serial_fifo2 = input_port_read(space->machine, "LIGHT0_X") & 0xff; state->serial_fifo2 = input_port_read(space->machine, "LIGHT0_X") & 0xff;
break; break;
case 3: /* player 1 gun Y-position, upper 2-bits */ case 3: /* player 1 gun Y-position, upper 2-bits */
model3_serial_fifo2 = (input_port_read(space->machine, "LIGHT0_X") >> 8) & 0x3; state->serial_fifo2 = (input_port_read(space->machine, "LIGHT0_X") >> 8) & 0x3;
break; break;
case 4: /* player 2 gun X-position, lower 8-bits */ case 4: /* player 2 gun X-position, lower 8-bits */
model3_serial_fifo2 = input_port_read(space->machine, "LIGHT1_Y") & 0xff; state->serial_fifo2 = input_port_read(space->machine, "LIGHT1_Y") & 0xff;
break; break;
case 5: /* player 2 gun X-position, upper 2-bits */ case 5: /* player 2 gun X-position, upper 2-bits */
model3_serial_fifo2 = (input_port_read(space->machine, "LIGHT1_Y") >> 8) & 0x3; state->serial_fifo2 = (input_port_read(space->machine, "LIGHT1_Y") >> 8) & 0x3;
break; break;
case 6: /* player 2 gun Y-position, lower 8-bits */ case 6: /* player 2 gun Y-position, lower 8-bits */
model3_serial_fifo2 = input_port_read(space->machine, "LIGHT1_X") & 0xff; state->serial_fifo2 = input_port_read(space->machine, "LIGHT1_X") & 0xff;
break; break;
case 7: /* player 2 gun Y-position, upper 2-bits */ case 7: /* player 2 gun Y-position, upper 2-bits */
model3_serial_fifo2 = (input_port_read(space->machine, "LIGHT1_X") >> 8) & 0x3; state->serial_fifo2 = (input_port_read(space->machine, "LIGHT1_X") >> 8) & 0x3;
break; break;
case 8: /* gun offscreen (bit set = gun offscreen, bit clear = gun on screen) */ case 8: /* gun offscreen (bit set = gun offscreen, bit clear = gun on screen) */
model3_serial_fifo2 = 0; /* bit 0 = player 1, bit 1 = player 2 */ state->serial_fifo2 = 0; /* bit 0 = player 1, bit 1 = player 2 */
if(input_port_read(space->machine, "OFFSCREEN") & 0x1) { if(input_port_read(space->machine, "OFFSCREEN") & 0x1) {
model3_serial_fifo2 |= 0x01; state->serial_fifo2 |= 0x01;
} }
break; break;
} }
@ -1429,7 +1426,7 @@ static WRITE64_HANDLER( model3_ctrl_w )
case 5: case 5:
if (ACCESSING_BITS_56_63) /* Serial comm TX FIFO 2 */ if (ACCESSING_BITS_56_63) /* Serial comm TX FIFO 2 */
{ {
model3_serial_fifo2 = data >> 56; state->serial_fifo2 = data >> 56;
return; return;
} }
break; break;
@ -1437,7 +1434,7 @@ static WRITE64_HANDLER( model3_ctrl_w )
case 7: case 7:
if (ACCESSING_BITS_24_31) /* ADC Channel selection */ if (ACCESSING_BITS_24_31) /* ADC Channel selection */
{ {
adc_channel = (data >> 24) & 0xf; state->adc_channel = (data >> 24) & 0xf;
} }
return; return;
} }
@ -1447,6 +1444,7 @@ static WRITE64_HANDLER( model3_ctrl_w )
static READ64_HANDLER( model3_sys_r ) static READ64_HANDLER( model3_sys_r )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
// printf("model3_sys_r: mask %llx @ %x (PC %x)\n", mem_mask, offset, cpu_get_pc(space->cpu)); // printf("model3_sys_r: mask %llx @ %x (PC %x)\n", mem_mask, offset, cpu_get_pc(space->cpu));
switch (offset) switch (offset)
@ -1454,26 +1452,26 @@ static READ64_HANDLER( model3_sys_r )
case 0x08/8: case 0x08/8:
if (ACCESSING_BITS_56_63) if (ACCESSING_BITS_56_63)
{ {
return ((UINT64)model3_crom_bank << 56); return ((UINT64)state->crom_bank << 56);
} }
break; break;
case 0x10/8: case 0x10/8:
if (ACCESSING_BITS_56_63) if (ACCESSING_BITS_56_63)
{ {
UINT64 res = model3_tap_read(); UINT64 res = model3_tap_read(space->machine);
return res<<61; return res<<61;
} }
else if (ACCESSING_BITS_24_31) else if (ACCESSING_BITS_24_31)
{ {
return (irq_enable<<24); return (state->irq_enable<<24);
} }
else logerror("m3_sys: Unk sys_r @ 0x10: mask = %x\n", (UINT32)mem_mask); else logerror("m3_sys: Unk sys_r @ 0x10: mask = %x\n", (UINT32)mem_mask);
break; break;
case 0x18/8: case 0x18/8:
// printf("read irq_state %x (PC %x)\n", irq_state, cpu_get_pc(space->cpu)); // printf("read state->irq_state %x (PC %x)\n", state->irq_state, cpu_get_pc(space->cpu));
return (UINT64)irq_state<<56 | 0xff000000; return (UINT64)state->irq_state<<56 | 0xff000000;
break; break;
} }
@ -1483,6 +1481,7 @@ static READ64_HANDLER( model3_sys_r )
static WRITE64_HANDLER( model3_sys_w ) static WRITE64_HANDLER( model3_sys_w )
{ {
model3_state *state = space->machine->driver_data<model3_state>();
// printf("model3_sys_w: %llx to %x mask %llx\n", data, offset, mem_mask); // printf("model3_sys_w: %llx to %x mask %llx\n", data, offset, mem_mask);
switch (offset) switch (offset)
@ -1490,14 +1489,14 @@ static WRITE64_HANDLER( model3_sys_w )
case 0x10/8: case 0x10/8:
if (ACCESSING_BITS_24_31) if (ACCESSING_BITS_24_31)
{ {
irq_enable = (data>>24)&0xff; state->irq_enable = (data>>24)&0xff;
} }
else logerror("m3_sys: unknown mask on IRQen write\n"); else logerror("m3_sys: unknown mask on IRQen write\n");
break; break;
case 0x18/8: case 0x18/8:
if ((mem_mask & 0xff000000) == 0xff000000) // int ACK with bits in REVERSE ORDER from the other registers (Seeeee-gaaaa!) if ((mem_mask & 0xff000000) == 0xff000000) // int ACK with bits in REVERSE ORDER from the other registers (Seeeee-gaaaa!)
{ // may also be a secondary enable based on behavior of e.g. magtruck VBL handler { // may also be a secondary enable based on behavior of e.g. magtruck VBL handler
// UINT32 old_irq = irq_state; // UINT32 old_irq = state->irq_state;
UINT8 ack = (data>>24)&0xff, realack; UINT8 ack = (data>>24)&0xff, realack;
int i; int i;
@ -1519,7 +1518,7 @@ static WRITE64_HANDLER( model3_sys_w )
// printf("%x to ack (realack %x)\n", ack, realack); // printf("%x to ack (realack %x)\n", ack, realack);
irq_state &= realack; state->irq_state &= realack;
break; break;
} }
} }
@ -1531,7 +1530,7 @@ static WRITE64_HANDLER( model3_sys_w )
case 0x08/8: case 0x08/8:
if (ACCESSING_BITS_56_63) if (ACCESSING_BITS_56_63)
{ {
model3_crom_bank = data >> 56; state->crom_bank = data >> 56;
data >>= 56; data >>= 56;
data = (~data) & 0x7; data = (~data) & 0x7;
@ -1541,7 +1540,7 @@ static WRITE64_HANDLER( model3_sys_w )
if (ACCESSING_BITS_24_31) if (ACCESSING_BITS_24_31)
{ {
data >>= 24; data >>= 24;
model3_tap_write( model3_tap_write(space->machine,
(data >> 6) & 1,// TCK (data >> 6) & 1,// TCK
(data >> 2) & 1,// TMS (data >> 2) & 1,// TMS
(data >> 5) & 1,// TDI (data >> 5) & 1,// TDI
@ -1574,19 +1573,19 @@ static WRITE64_HANDLER( model3_rtc_w )
} }
} }
static UINT64 real3d_status = 0;
static READ64_HANDLER(real3d_status_r) static READ64_HANDLER(real3d_status_r)
{ {
real3d_status ^= U64(0xffffffffffffffff); model3_state *state = space->machine->driver_data<model3_state>();
state->real3d_status ^= U64(0xffffffffffffffff);
if (offset == 0) if (offset == 0)
{ {
/* pretty sure this is VBLANK */ /* pretty sure this is VBLANK */
real3d_status &= ~U64(0x0000000200000000); state->real3d_status &= ~U64(0x0000000200000000);
if (space->machine->primary_screen->vblank()) if (space->machine->primary_screen->vblank())
real3d_status |= U64(0x0000000200000000); state->real3d_status |= U64(0x0000000200000000);
return real3d_status; return state->real3d_status;
} }
return real3d_status; return state->real3d_status;
} }
/* SCSP interface */ /* SCSP interface */
@ -1614,20 +1613,20 @@ static WRITE64_HANDLER(model3_sound_w)
static UINT64 network_ram[0x10000];
static READ64_HANDLER(network_r) static READ64_HANDLER(network_r)
{ {
model3_state *state = space->machine->driver_data<model3_state>();
mame_printf_debug("network_r: %02X at %08X\n", offset, cpu_get_pc(space->cpu)); mame_printf_debug("network_r: %02X at %08X\n", offset, cpu_get_pc(space->cpu));
return network_ram[offset]; return state->network_ram[offset];
} }
static WRITE64_HANDLER(network_w) static WRITE64_HANDLER(network_w)
{ {
COMBINE_DATA(network_ram + offset); model3_state *state = space->machine->driver_data<model3_state>();
COMBINE_DATA(state->network_ram + offset);
mame_printf_debug("network_w: %02X, %08X%08X at %08X\n", offset, (UINT32)(data >> 32), (UINT32)(data), cpu_get_pc(space->cpu)); mame_printf_debug("network_w: %02X, %08X%08X at %08X\n", offset, (UINT32)(data >> 32), (UINT32)(data), cpu_get_pc(space->cpu));
} }
static int prot_data_ptr = 0;
static const UINT16 vs299_prot_data[] = static const UINT16 vs299_prot_data[] =
{ {
@ -1701,6 +1700,7 @@ static const UINT16 eca_prot_data[] =
static READ64_HANDLER(model3_security_r) static READ64_HANDLER(model3_security_r)
{ {
model3_state *state = space->machine->driver_data<model3_state>();
switch(offset) switch(offset)
{ {
case 0x00/8: return 0; /* status */ case 0x00/8: return 0; /* status */
@ -1709,44 +1709,44 @@ static READ64_HANDLER(model3_security_r)
if (mame_stricmp(space->machine->gamedrv->name, "vs299") == 0 || if (mame_stricmp(space->machine->gamedrv->name, "vs299") == 0 ||
mame_stricmp(space->machine->gamedrv->name, "vs2v991") == 0) mame_stricmp(space->machine->gamedrv->name, "vs2v991") == 0)
{ {
return (UINT64)vs299_prot_data[prot_data_ptr++] << 48; return (UINT64)vs299_prot_data[state->prot_data_ptr++] << 48;
} }
else if (mame_stricmp(space->machine->gamedrv->name, "swtrilgy") == 0 || else if (mame_stricmp(space->machine->gamedrv->name, "swtrilgy") == 0 ||
mame_stricmp(space->machine->gamedrv->name, "swtrilgya") == 0) mame_stricmp(space->machine->gamedrv->name, "swtrilgya") == 0)
{ {
UINT64 data = (UINT64)swt_prot_data[prot_data_ptr++] << 16; UINT64 data = (UINT64)swt_prot_data[state->prot_data_ptr++] << 16;
if (prot_data_ptr > 0x38) if (state->prot_data_ptr > 0x38)
{ {
prot_data_ptr = 0; state->prot_data_ptr = 0;
} }
return data; return data;
} }
else if (mame_stricmp(space->machine->gamedrv->name, "fvipers2") == 0) else if (mame_stricmp(space->machine->gamedrv->name, "fvipers2") == 0)
{ {
UINT64 data = (UINT64)fvipers2_prot_data[prot_data_ptr++] << 16; UINT64 data = (UINT64)fvipers2_prot_data[state->prot_data_ptr++] << 16;
if (prot_data_ptr >= 0x41) if (state->prot_data_ptr >= 0x41)
{ {
prot_data_ptr = 0; state->prot_data_ptr = 0;
} }
return data; return data;
} }
else if (mame_stricmp(space->machine->gamedrv->name, "spikeout") == 0 || else if (mame_stricmp(space->machine->gamedrv->name, "spikeout") == 0 ||
mame_stricmp(space->machine->gamedrv->name, "spikeofe") == 0) mame_stricmp(space->machine->gamedrv->name, "spikeofe") == 0)
{ {
UINT64 data = (UINT64)spikeout_prot_data[prot_data_ptr++] << 16; UINT64 data = (UINT64)spikeout_prot_data[state->prot_data_ptr++] << 16;
if (prot_data_ptr >= 0x55) if (state->prot_data_ptr >= 0x55)
{ {
prot_data_ptr = 0; state->prot_data_ptr = 0;
} }
return data; return data;
} }
else if (mame_stricmp(space->machine->gamedrv->name, "eca") == 0 || else if (mame_stricmp(space->machine->gamedrv->name, "eca") == 0 ||
mame_stricmp(space->machine->gamedrv->name, "ecax") == 0) mame_stricmp(space->machine->gamedrv->name, "ecax") == 0)
{ {
UINT64 data = (UINT64)eca_prot_data[prot_data_ptr++] << 16; UINT64 data = (UINT64)eca_prot_data[state->prot_data_ptr++] << 16;
if (prot_data_ptr >= 0x31) if (state->prot_data_ptr >= 0x31)
{ {
prot_data_ptr = 0; state->prot_data_ptr = 0;
} }
return data; return data;
} }
@ -1771,7 +1771,7 @@ static WRITE64_HANDLER(daytona2_rombank_w)
} }
static ADDRESS_MAP_START( model3_mem, ADDRESS_SPACE_PROGRAM, 64) static ADDRESS_MAP_START( model3_mem, ADDRESS_SPACE_PROGRAM, 64)
AM_RANGE(0x00000000, 0x007fffff) AM_RAM AM_BASE(&work_ram) /* work RAM */ AM_RANGE(0x00000000, 0x007fffff) AM_RAM AM_BASE_MEMBER(model3_state, work_ram) /* work RAM */
AM_RANGE(0x84000000, 0x8400003f) AM_READ( real3d_status_r ) AM_RANGE(0x84000000, 0x8400003f) AM_READ( real3d_status_r )
AM_RANGE(0x88000000, 0x88000007) AM_WRITE( real3d_cmd_w ) AM_RANGE(0x88000000, 0x88000007) AM_WRITE( real3d_cmd_w )
@ -1788,7 +1788,7 @@ static ADDRESS_MAP_START( model3_mem, ADDRESS_SPACE_PROGRAM, 64)
AM_RANGE(0xf1000000, 0xf10f7fff) AM_READWRITE( model3_char_r, model3_char_w ) /* character RAM */ AM_RANGE(0xf1000000, 0xf10f7fff) AM_READWRITE( model3_char_r, model3_char_w ) /* character RAM */
AM_RANGE(0xf10f8000, 0xf10fffff) AM_READWRITE( model3_tile_r, model3_tile_w ) /* tilemaps */ AM_RANGE(0xf10f8000, 0xf10fffff) AM_READWRITE( model3_tile_r, model3_tile_w ) /* tilemaps */
AM_RANGE(0xf1100000, 0xf111ffff) AM_READWRITE( model3_palette_r, model3_palette_w ) AM_BASE(&paletteram64) /* palette */ AM_RANGE(0xf1100000, 0xf111ffff) AM_READWRITE( model3_palette_r, model3_palette_w ) AM_BASE_MEMBER(model3_state, paletteram64) /* palette */
AM_RANGE(0xf1180000, 0xf11800ff) AM_READWRITE( model3_vid_reg_r, model3_vid_reg_w ) AM_RANGE(0xf1180000, 0xf11800ff) AM_READWRITE( model3_vid_reg_r, model3_vid_reg_w )
AM_RANGE(0xff800000, 0xffffffff) AM_ROM AM_REGION("user1", 0) AM_RANGE(0xff800000, 0xffffffff) AM_ROM AM_REGION("user1", 0)
@ -4891,7 +4891,7 @@ static WRITE16_HANDLER( model3snd_ctrl )
} }
static ADDRESS_MAP_START( model3_snd, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( model3_snd, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_REGION("scsp1", 0) AM_BASE(&model3_soundram) AM_RANGE(0x000000, 0x07ffff) AM_RAM AM_REGION("scsp1", 0) AM_BASE_MEMBER(model3_state, soundram)
AM_RANGE(0x100000, 0x100fff) AM_DEVREADWRITE("scsp1", scsp_r, scsp_w) AM_RANGE(0x100000, 0x100fff) AM_DEVREADWRITE("scsp1", scsp_r, scsp_w)
AM_RANGE(0x200000, 0x27ffff) AM_RAM AM_REGION("scsp2", 0) AM_RANGE(0x200000, 0x27ffff) AM_RAM AM_REGION("scsp2", 0)
AM_RANGE(0x300000, 0x300fff) AM_DEVREADWRITE("scsp2", scsp_r, scsp_w) AM_RANGE(0x300000, 0x300fff) AM_DEVREADWRITE("scsp2", scsp_r, scsp_w)
@ -4902,13 +4902,13 @@ static ADDRESS_MAP_START( model3_snd, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0xe00000, 0xffffff) AM_ROMBANK("bank5") AM_RANGE(0xe00000, 0xffffff) AM_ROMBANK("bank5")
ADDRESS_MAP_END ADDRESS_MAP_END
static int scsp_last_line = 0;
static void scsp_irq(device_t *device, int irq) static void scsp_irq(device_t *device, int irq)
{ {
model3_state *state = device->machine->driver_data<model3_state>();
if (irq > 0) if (irq > 0)
{ {
scsp_last_line = irq; state->scsp_last_line = irq;
cputag_set_input_line(device->machine, "audiocpu", irq, ASSERT_LINE); cputag_set_input_line(device->machine, "audiocpu", irq, ASSERT_LINE);
} }
else else
@ -4938,17 +4938,17 @@ static const scsp_interface scsp2_interface =
0x02: Video (VBLANK start?) 0x02: Video (VBLANK start?)
0x01: Video (unused?) 0x01: Video (unused?)
*/ */
static int model3_vblank = 0;
static INTERRUPT_GEN(model3_interrupt) static INTERRUPT_GEN(model3_interrupt)
{ {
if (model3_vblank == 0) { model3_state *state = device->machine->driver_data<model3_state>();
if (state->vblank == 0) {
model3_set_irq_line(device->machine, 0x02, ASSERT_LINE); model3_set_irq_line(device->machine, 0x02, ASSERT_LINE);
} else { } else {
model3_set_irq_line(device->machine, 0x0d, ASSERT_LINE); model3_set_irq_line(device->machine, 0x0d, ASSERT_LINE);
} }
model3_vblank++; state->vblank++;
model3_vblank &= 1; state->vblank &= 1;
} }
static const powerpc_config model3_10 = static const powerpc_config model3_10 =
@ -4969,7 +4969,7 @@ static const powerpc_config model3_2x =
66000000 /* Multiplier 2.5, Bus = 66MHz, Core = 166MHz */ 66000000 /* Multiplier 2.5, Bus = 66MHz, Core = 166MHz */
}; };
static MACHINE_CONFIG_START( model3_10, driver_device ) static MACHINE_CONFIG_START( model3_10, model3_state )
MCFG_CPU_ADD("maincpu", PPC603E, 66000000) MCFG_CPU_ADD("maincpu", PPC603E, 66000000)
MCFG_CPU_CONFIG(model3_10) MCFG_CPU_CONFIG(model3_10)
MCFG_CPU_PROGRAM_MAP(model3_mem) MCFG_CPU_PROGRAM_MAP(model3_mem)
@ -5011,7 +5011,7 @@ static MACHINE_CONFIG_START( model3_10, driver_device )
MCFG_SOUND_ROUTE(0, "rspeaker", 2.0) MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_START( model3_15, driver_device ) static MACHINE_CONFIG_START( model3_15, model3_state )
MCFG_CPU_ADD("maincpu", PPC603E, 100000000) MCFG_CPU_ADD("maincpu", PPC603E, 100000000)
MCFG_CPU_CONFIG(model3_15) MCFG_CPU_CONFIG(model3_15)
MCFG_CPU_PROGRAM_MAP(model3_mem) MCFG_CPU_PROGRAM_MAP(model3_mem)
@ -5051,7 +5051,7 @@ static MACHINE_CONFIG_START( model3_15, driver_device )
MCFG_SOUND_ROUTE(0, "rspeaker", 2.0) MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_START( model3_20, driver_device ) static MACHINE_CONFIG_START( model3_20, model3_state )
MCFG_CPU_ADD("maincpu", PPC603R, 166000000) MCFG_CPU_ADD("maincpu", PPC603R, 166000000)
MCFG_CPU_CONFIG(model3_2x) MCFG_CPU_CONFIG(model3_2x)
MCFG_CPU_PROGRAM_MAP(model3_mem) MCFG_CPU_PROGRAM_MAP(model3_mem)
@ -5091,7 +5091,7 @@ static MACHINE_CONFIG_START( model3_20, driver_device )
MCFG_SOUND_ROUTE(0, "rspeaker", 2.0) MCFG_SOUND_ROUTE(0, "rspeaker", 2.0)
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_START( model3_21, driver_device ) static MACHINE_CONFIG_START( model3_21, model3_state )
MCFG_CPU_ADD("maincpu", PPC603R, 166000000) MCFG_CPU_ADD("maincpu", PPC603R, 166000000)
MCFG_CPU_CONFIG(model3_2x) MCFG_CPU_CONFIG(model3_2x)
MCFG_CPU_PROGRAM_MAP(model3_mem) MCFG_CPU_PROGRAM_MAP(model3_mem)
@ -5134,6 +5134,7 @@ MACHINE_CONFIG_END
static void interleave_vroms(running_machine *machine) static void interleave_vroms(running_machine *machine)
{ {
model3_state *state = machine->driver_data<model3_state>();
int start; int start;
int i,j,x; int i,j,x;
UINT16 *vrom1 = (UINT16*)machine->region("user3")->base(); UINT16 *vrom1 = (UINT16*)machine->region("user3")->base();
@ -5141,8 +5142,8 @@ static void interleave_vroms(running_machine *machine)
int vrom_length = machine->region("user3")->bytes(); int vrom_length = machine->region("user3")->bytes();
UINT16 *vrom; UINT16 *vrom;
model3_vrom = auto_alloc_array(machine, UINT32, 0x4000000/4); state->vrom = auto_alloc_array(machine, UINT32, 0x4000000/4);
vrom = (UINT16 *)model3_vrom; vrom = (UINT16 *)state->vrom;
if( vrom_length <= 0x1000000 ) { if( vrom_length <= 0x1000000 ) {
start = 0x1000000; start = 0x1000000;
@ -5397,9 +5398,11 @@ static DRIVER_INIT( vs299 )
static DRIVER_INIT( harley ) static DRIVER_INIT( harley )
{ {
model3_state *state = machine->driver_data<model3_state>();
UINT32 *rom = (UINT32*)machine->region("user1")->base(); UINT32 *rom = (UINT32*)machine->region("user1")->base();
DRIVER_INIT_CALL(model3_20); DRIVER_INIT_CALL(model3_20);
state->network_ram = auto_alloc_array_clear(machine, UINT64, 0x10000);
memory_install_readwrite64_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc0000000, 0xc00fffff, 0, 0, network_r, network_w ); memory_install_readwrite64_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc0000000, 0xc00fffff, 0, 0, network_r, network_w );
rom[(0x50e8d4^4)/4] = 0x60000000; rom[(0x50e8d4^4)/4] = 0x60000000;

View File

@ -33,9 +33,7 @@
#include "includes/konamipt.h" #include "includes/konamipt.h"
#include "includes/mystwarr.h" #include "includes/mystwarr.h"
static UINT16 *gx_workram;
static UINT8 mw_irq_control;
static const eeprom_interface eeprom_intf = static const eeprom_interface eeprom_intf =
{ {
@ -108,7 +106,8 @@ static WRITE16_HANDLER( mmeeprom_w )
static INTERRUPT_GEN(mystwarr_interrupt) static INTERRUPT_GEN(mystwarr_interrupt)
{ {
if (!(mw_irq_control & 0x01)) return; mystwarr_state *state = device->machine->driver_data<mystwarr_state>();
if (!(state->mw_irq_control & 0x01)) return;
switch (cpu_getiloops(device)) switch (cpu_getiloops(device))
{ {
@ -146,7 +145,8 @@ static INTERRUPT_GEN(metamrph_interrupt)
static INTERRUPT_GEN(mchamp_interrupt) static INTERRUPT_GEN(mchamp_interrupt)
{ {
if (!(mw_irq_control & 0x02)) return; mystwarr_state *state = device->machine->driver_data<mystwarr_state>();
if (!(state->mw_irq_control & 0x02)) return;
switch (cpu_getiloops(device)) switch (cpu_getiloops(device))
{ {
@ -215,11 +215,12 @@ static READ16_HANDLER( sound_status_msb_r )
static WRITE16_HANDLER( irq_ack_w ) static WRITE16_HANDLER( irq_ack_w )
{ {
mystwarr_state *state = space->machine->driver_data<mystwarr_state>();
K056832_b_word_w(space, offset, data, mem_mask); K056832_b_word_w(space, offset, data, mem_mask);
if (offset == 3 && ACCESSING_BITS_0_7) if (offset == 3 && ACCESSING_BITS_0_7)
{ {
mw_irq_control = data&0xff; state->mw_irq_control = data&0xff;
// if ((data &0xf0) != 0xd0) logerror("Unknown write to IRQ reg: %x\n", data); // if ((data &0xf0) != 0xd0) logerror("Unknown write to IRQ reg: %x\n", data);
@ -258,7 +259,7 @@ static WRITE16_HANDLER( K053247_scattered_word_w )
/* Mystic Warriors */ /* Mystic Warriors */
static ADDRESS_MAP_START( mystwarr_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( mystwarr_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x1fffff) AM_ROM // main program AM_RANGE(0x000000, 0x1fffff) AM_ROM // main program
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&gx_workram) AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(mystwarr_state, gx_workram)
AM_RANGE(0x400000, 0x40ffff) AM_READWRITE(K053247_scattered_word_r,K053247_scattered_word_w) AM_BASE_GENERIC(spriteram) AM_RANGE(0x400000, 0x40ffff) AM_READWRITE(K053247_scattered_word_r,K053247_scattered_word_w) AM_BASE_GENERIC(spriteram)
AM_RANGE(0x480000, 0x4800ff) AM_WRITE(K055555_word_w) AM_RANGE(0x480000, 0x4800ff) AM_WRITE(K055555_word_w)
AM_RANGE(0x482000, 0x48200f) AM_READ(K055673_rom_word_r) AM_RANGE(0x482000, 0x48200f) AM_READ(K055673_rom_word_r)
@ -296,7 +297,7 @@ ADDRESS_MAP_END
/* Metamorphic Force */ /* Metamorphic Force */
static ADDRESS_MAP_START( metamrph_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( metamrph_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x1fffff) AM_ROM // main program AM_RANGE(0x000000, 0x1fffff) AM_ROM // main program
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&gx_workram) AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(mystwarr_state, gx_workram)
AM_RANGE(0x210000, 0x210fff) AM_READWRITE(K053247_word_r,K053247_word_w) AM_RANGE(0x210000, 0x210fff) AM_READWRITE(K053247_word_r,K053247_word_w)
AM_RANGE(0x211000, 0x21ffff) AM_RAM AM_RANGE(0x211000, 0x21ffff) AM_RAM
AM_RANGE(0x240000, 0x240007) AM_WRITE(K053246_word_w) AM_RANGE(0x240000, 0x240007) AM_WRITE(K053246_word_w)
@ -339,7 +340,7 @@ ADDRESS_MAP_END
/* Violent Storm */ /* Violent Storm */
static ADDRESS_MAP_START( viostorm_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( viostorm_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x1fffff) AM_ROM // main program AM_RANGE(0x000000, 0x1fffff) AM_ROM // main program
AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE(&gx_workram) AM_RANGE(0x200000, 0x20ffff) AM_RAM AM_BASE_MEMBER(mystwarr_state, gx_workram)
AM_RANGE(0x210000, 0x210fff) AM_READWRITE(K053247_word_r,K053247_word_w) AM_RANGE(0x210000, 0x210fff) AM_READWRITE(K053247_word_r,K053247_word_w)
AM_RANGE(0x211000, 0x21ffff) AM_RAM AM_RANGE(0x211000, 0x21ffff) AM_RAM
AM_RANGE(0x240000, 0x240007) AM_WRITE(K053246_word_w) AM_RANGE(0x240000, 0x240007) AM_WRITE(K053246_word_w)
@ -408,14 +409,16 @@ static WRITE16_HANDLER( K053247_martchmp_word_w )
static READ16_HANDLER( mccontrol_r ) static READ16_HANDLER( mccontrol_r )
{ {
return mw_irq_control<<8; mystwarr_state *state = space->machine->driver_data<mystwarr_state>();
return state->mw_irq_control<<8;
} }
static WRITE16_HANDLER( mccontrol_w ) static WRITE16_HANDLER( mccontrol_w )
{ {
mystwarr_state *state = space->machine->driver_data<mystwarr_state>();
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
{ {
mw_irq_control = data>>8; state->mw_irq_control = data>>8;
// bit 0 = watchdog // bit 0 = watchdog
// bit 1 = IRQ enable // bit 1 = IRQ enable
// bit 2 = OBJCHA // bit 2 = OBJCHA
@ -433,7 +436,7 @@ static WRITE16_HANDLER( mccontrol_w )
/* Martial Champion */ /* Martial Champion */
static ADDRESS_MAP_START( martchmp_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( martchmp_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM // main program AM_RANGE(0x000000, 0x0fffff) AM_ROM // main program
AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&gx_workram) // work RAM AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE_MEMBER(mystwarr_state, gx_workram) // work RAM
AM_RANGE(0x300000, 0x3fffff) AM_ROM // data ROM AM_RANGE(0x300000, 0x3fffff) AM_ROM // data ROM
AM_RANGE(0x400000, 0x4000ff) AM_WRITE(K055555_word_w) // PCU2 AM_RANGE(0x400000, 0x4000ff) AM_WRITE(K055555_word_w) // PCU2
AM_RANGE(0x402000, 0x40200f) AM_READ(K055673_rom_word_r) // sprite ROM readback AM_RANGE(0x402000, 0x40200f) AM_READ(K055673_rom_word_r) // sprite ROM readback
@ -496,7 +499,7 @@ static ADDRESS_MAP_START( dadandrn_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x48c000, 0x48c01f) AM_WRITE(K054338_word_w) AM_RANGE(0x48c000, 0x48c01f) AM_WRITE(K054338_word_w)
AM_RANGE(0x48e000, 0x48e001) AM_READ_PORT("IN0_P1") // bit 3 (0x8) is test switch AM_RANGE(0x48e000, 0x48e001) AM_READ_PORT("IN0_P1") // bit 3 (0x8) is test switch
AM_RANGE(0x48e020, 0x48e021) AM_READ(dddeeprom_r) AM_RANGE(0x48e020, 0x48e021) AM_READ(dddeeprom_r)
AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE(&gx_workram) AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_MEMBER(mystwarr_state, gx_workram)
AM_RANGE(0x680000, 0x68003f) AM_READWRITE(K055550_word_r,K055550_word_w) AM_RANGE(0x680000, 0x68003f) AM_READWRITE(K055550_word_r,K055550_word_w)
AM_RANGE(0x6a0000, 0x6a0001) AM_WRITE(mmeeprom_w) AM_RANGE(0x6a0000, 0x6a0001) AM_WRITE(mmeeprom_w)
AM_RANGE(0x6c0000, 0x6c0001) AM_WRITE(ddd_053936_enable_w) AM_RANGE(0x6c0000, 0x6c0001) AM_WRITE(ddd_053936_enable_w)
@ -544,7 +547,7 @@ static ADDRESS_MAP_START( gaiapols_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x48c000, 0x48c01f) AM_WRITE(K054338_word_w) AM_RANGE(0x48c000, 0x48c01f) AM_WRITE(K054338_word_w)
AM_RANGE(0x48e000, 0x48e001) AM_READ_PORT("IN0_P1") // bit 3 (0x8) is test switch AM_RANGE(0x48e000, 0x48e001) AM_READ_PORT("IN0_P1") // bit 3 (0x8) is test switch
AM_RANGE(0x48e020, 0x48e021) AM_READ(dddeeprom_r) AM_RANGE(0x48e020, 0x48e021) AM_READ(dddeeprom_r)
AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE(&gx_workram) AM_RANGE(0x600000, 0x60ffff) AM_RAM AM_BASE_MEMBER(mystwarr_state, gx_workram)
AM_RANGE(0x660000, 0x6600ff) AM_READWRITE(K054000_lsb_r,K054000_lsb_w) AM_RANGE(0x660000, 0x6600ff) AM_READWRITE(K054000_lsb_r,K054000_lsb_w)
AM_RANGE(0x6a0000, 0x6a0001) AM_WRITE(mmeeprom_w) AM_RANGE(0x6a0000, 0x6a0001) AM_WRITE(mmeeprom_w)
AM_RANGE(0x6c0000, 0x6c0001) AM_WRITE(ddd_053936_enable_w) AM_RANGE(0x6c0000, 0x6c0001) AM_WRITE(ddd_053936_enable_w)
@ -566,16 +569,17 @@ ADDRESS_MAP_END
/**********************************************************************************/ /**********************************************************************************/
static int cur_sound_region;
static void reset_sound_region(running_machine *machine) static void reset_sound_region(running_machine *machine)
{ {
memory_set_bankptr(machine, "bank2", machine->region("soundcpu")->base() + 0x10000 + cur_sound_region*0x4000); mystwarr_state *state = machine->driver_data<mystwarr_state>();
memory_set_bankptr(machine, "bank2", machine->region("soundcpu")->base() + 0x10000 + state->cur_sound_region*0x4000);
} }
static WRITE8_HANDLER( sound_bankswitch_w ) static WRITE8_HANDLER( sound_bankswitch_w )
{ {
cur_sound_region = (data & 0xf); mystwarr_state *state = space->machine->driver_data<mystwarr_state>();
state->cur_sound_region = (data & 0xf);
reset_sound_region(space->machine); reset_sound_region(space->machine);
} }
@ -857,14 +861,15 @@ static STATE_POSTLOAD( mystwarr_postload )
static MACHINE_START( mystwarr ) static MACHINE_START( mystwarr )
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
/* set default bankswitch */ /* set default bankswitch */
cur_sound_region = 2; state->cur_sound_region = 2;
reset_sound_region(machine); reset_sound_region(machine);
mw_irq_control = 0; state->mw_irq_control = 0;
state_save_register_global(machine, mw_irq_control); state_save_register_global(machine, state->mw_irq_control);
state_save_register_global(machine, cur_sound_region); state_save_register_global(machine, state->cur_sound_region);
machine->state().register_postload(mystwarr_postload, NULL); machine->state().register_postload(mystwarr_postload, NULL);
} }
@ -939,7 +944,7 @@ static MACHINE_RESET(gaiapols)
for (i=5; i<=7; i++) k054539_set_gain(k054539_1, i, 2.0); for (i=5; i<=7; i++) k054539_set_gain(k054539_1, i, 2.0);
} }
static MACHINE_CONFIG_START( mystwarr, driver_device ) static MACHINE_CONFIG_START( mystwarr, mystwarr_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 16000000) /* 16 MHz (confirmed) */ MCFG_CPU_ADD("maincpu", M68000, 16000000) /* 16 MHz (confirmed) */

View File

@ -225,9 +225,25 @@ Thrill Drive 713A13 - 713A14 -
#include "video/voodoo.h" #include "video/voodoo.h"
#include "video/konicdev.h" #include "video/konicdev.h"
static UINT8 led_reg0, led_reg1;
static UINT32 *work_ram; class nwktr_state : public driver_device
{
public:
nwktr_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 led_reg0;
UINT8 led_reg1;
UINT32 *work_ram;
int fpga_uploaded;
int lanc2_ram_r;
int lanc2_ram_w;
UINT8 *lanc2_ram;
UINT32 *sharc_dataram;
};
static WRITE32_HANDLER( paletteram32_w ) static WRITE32_HANDLER( paletteram32_w )
@ -245,6 +261,7 @@ static void voodoo_vblank_0(device_t *device, int param)
static VIDEO_UPDATE( nwktr ) static VIDEO_UPDATE( nwktr )
{ {
nwktr_state *state = screen->machine->driver_data<nwktr_state>();
device_t *voodoo = screen->machine->device("voodoo"); device_t *voodoo = screen->machine->device("voodoo");
device_t *k001604 = screen->machine->device("k001604"); device_t *k001604 = screen->machine->device("k001604");
@ -254,8 +271,8 @@ static VIDEO_UPDATE( nwktr )
k001604_draw_front_layer(k001604, bitmap, cliprect); k001604_draw_front_layer(k001604, bitmap, cliprect);
draw_7segment_led(bitmap, 3, 3, led_reg0); draw_7segment_led(bitmap, 3, 3, state->led_reg0);
draw_7segment_led(bitmap, 9, 3, led_reg1); draw_7segment_led(bitmap, 9, 3, state->led_reg1);
return 0; return 0;
} }
@ -296,16 +313,17 @@ static READ32_HANDLER( sysreg_r )
static WRITE32_HANDLER( sysreg_w ) static WRITE32_HANDLER( sysreg_w )
{ {
nwktr_state *state = space->machine->driver_data<nwktr_state>();
device_t *adc12138 = space->machine->device("adc12138"); device_t *adc12138 = space->machine->device("adc12138");
if( offset == 0 ) if( offset == 0 )
{ {
if (ACCESSING_BITS_24_31) if (ACCESSING_BITS_24_31)
{ {
led_reg0 = (data >> 24) & 0xff; state->led_reg0 = (data >> 24) & 0xff;
} }
if (ACCESSING_BITS_16_23) if (ACCESSING_BITS_16_23)
{ {
led_reg1 = (data >> 16) & 0xff; state->led_reg1 = (data >> 16) & 0xff;
} }
return; return;
} }
@ -338,28 +356,26 @@ static WRITE32_HANDLER( sysreg_w )
} }
} }
static int fpga_uploaded = 0;
static int lanc2_ram_r = 0;
static int lanc2_ram_w = 0;
static UINT8 *lanc2_ram;
static void lanc2_init(running_machine *machine) static void lanc2_init(running_machine *machine)
{ {
fpga_uploaded = 0; nwktr_state *state = machine->driver_data<nwktr_state>();
lanc2_ram_r = 0; state->fpga_uploaded = 0;
lanc2_ram_w = 0; state->lanc2_ram_r = 0;
lanc2_ram = auto_alloc_array(machine, UINT8, 0x8000); state->lanc2_ram_w = 0;
state->lanc2_ram = auto_alloc_array(machine, UINT8, 0x8000);
} }
static READ32_HANDLER( lanc1_r ) static READ32_HANDLER( lanc1_r )
{ {
nwktr_state *state = space->machine->driver_data<nwktr_state>();
switch (offset) switch (offset)
{ {
case 0x40/4: case 0x40/4:
{ {
UINT32 r = 0; UINT32 r = 0;
r |= (fpga_uploaded) ? (1 << 6) : 0; r |= (state->fpga_uploaded) ? (1 << 6) : 0;
r |= 1 << 5; r |= 1 << 5;
return (r) << 24; return (r) << 24;
@ -380,14 +396,15 @@ static WRITE32_HANDLER( lanc1_w )
static READ32_HANDLER( lanc2_r ) static READ32_HANDLER( lanc2_r )
{ {
nwktr_state *state = space->machine->driver_data<nwktr_state>();
UINT32 r = 0; UINT32 r = 0;
if (offset == 0) if (offset == 0)
{ {
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
{ {
r |= lanc2_ram[lanc2_ram_r & 0x7fff]; r |= state->lanc2_ram[state->lanc2_ram_r & 0x7fff];
lanc2_ram_r++; state->lanc2_ram_r++;
} }
else else
{ {
@ -410,6 +427,7 @@ static READ32_HANDLER( lanc2_r )
static WRITE32_HANDLER( lanc2_w ) static WRITE32_HANDLER( lanc2_w )
{ {
nwktr_state *state = space->machine->driver_data<nwktr_state>();
if (offset == 0) if (offset == 0)
{ {
if (ACCESSING_BITS_24_31) if (ACCESSING_BITS_24_31)
@ -425,14 +443,14 @@ static WRITE32_HANDLER( lanc2_w )
((value << 5) & 0x40) | ((value << 5) & 0x40) |
((value << 7) & 0x80); ((value << 7) & 0x80);
fpga_uploaded = 1; state->fpga_uploaded = 1;
//printf("lanc2_fpga_w: %02X at %08X\n", value, cpu_get_pc(space->cpu)); //printf("lanc2_fpga_w: %02X at %08X\n", value, cpu_get_pc(space->cpu));
} }
else if (ACCESSING_BITS_0_7) else if (ACCESSING_BITS_0_7)
{ {
lanc2_ram[lanc2_ram_w & 0x7fff] = data & 0xff; state->lanc2_ram[state->lanc2_ram_w & 0x7fff] = data & 0xff;
lanc2_ram_w++; state->lanc2_ram_w++;
} }
else else
{ {
@ -443,15 +461,15 @@ static WRITE32_HANDLER( lanc2_w )
{ {
if (mame_stricmp(space->machine->gamedrv->name, "thrilld") == 0) if (mame_stricmp(space->machine->gamedrv->name, "thrilld") == 0)
{ {
work_ram[(0x3ffed0/4) + 0] = 0x472a3731; state->work_ram[(0x3ffed0/4) + 0] = 0x472a3731;
work_ram[(0x3ffed0/4) + 1] = 0x33202020; state->work_ram[(0x3ffed0/4) + 1] = 0x33202020;
work_ram[(0x3ffed0/4) + 2] = 0x2d2d2a2a; state->work_ram[(0x3ffed0/4) + 2] = 0x2d2d2a2a;
work_ram[(0x3ffed0/4) + 3] = 0x2a207878; state->work_ram[(0x3ffed0/4) + 3] = 0x2a207878;
work_ram[(0x3fff40/4) + 0] = 0x47433731; state->work_ram[(0x3fff40/4) + 0] = 0x47433731;
work_ram[(0x3fff40/4) + 1] = 0x33000000; state->work_ram[(0x3fff40/4) + 1] = 0x33000000;
work_ram[(0x3fff40/4) + 2] = 0x19994a41; state->work_ram[(0x3fff40/4) + 2] = 0x19994a41;
work_ram[(0x3fff40/4) + 3] = 0x4100a9b1; state->work_ram[(0x3fff40/4) + 3] = 0x4100a9b1;
} }
} }
@ -462,15 +480,16 @@ static WRITE32_HANDLER( lanc2_w )
static MACHINE_START( nwktr ) static MACHINE_START( nwktr )
{ {
nwktr_state *state = machine->driver_data<nwktr_state>();
/* set conservative DRC options */ /* set conservative DRC options */
ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS); ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS);
/* configure fast RAM regions for DRC */ /* configure fast RAM regions for DRC */
ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x003fffff, FALSE, work_ram); ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x003fffff, FALSE, state->work_ram);
} }
static ADDRESS_MAP_START( nwktr_map, ADDRESS_SPACE_PROGRAM, 32 ) static ADDRESS_MAP_START( nwktr_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE(&work_ram) /* Work RAM */ AM_RANGE(0x00000000, 0x003fffff) AM_RAM AM_BASE_MEMBER(nwktr_state, work_ram) /* Work RAM */
AM_RANGE(0x74000000, 0x740000ff) AM_DEVREADWRITE("k001604", k001604_reg_r, k001604_reg_w) AM_RANGE(0x74000000, 0x740000ff) AM_DEVREADWRITE("k001604", k001604_reg_r, k001604_reg_w)
AM_RANGE(0x74010000, 0x74017fff) AM_RAM_WRITE(paletteram32_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x74010000, 0x74017fff) AM_RAM_WRITE(paletteram32_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x74020000, 0x7403ffff) AM_DEVREADWRITE("k001604", k001604_tile_r, k001604_tile_w) AM_RANGE(0x74020000, 0x7403ffff) AM_DEVREADWRITE("k001604", k001604_tile_r, k001604_tile_w)
@ -502,16 +521,17 @@ ADDRESS_MAP_END
/*****************************************************************************/ /*****************************************************************************/
static UINT32 *sharc_dataram;
static READ32_HANDLER( dsp_dataram_r ) static READ32_HANDLER( dsp_dataram_r )
{ {
return sharc_dataram[offset] & 0xffff; nwktr_state *state = space->machine->driver_data<nwktr_state>();
return state->sharc_dataram[offset] & 0xffff;
} }
static WRITE32_HANDLER( dsp_dataram_w ) static WRITE32_HANDLER( dsp_dataram_w )
{ {
sharc_dataram[offset] = data; nwktr_state *state = space->machine->driver_data<nwktr_state>();
state->sharc_dataram[offset] = data;
} }
static ADDRESS_MAP_START( sharc_map, ADDRESS_SPACE_DATA, 32 ) static ADDRESS_MAP_START( sharc_map, ADDRESS_SPACE_DATA, 32 )
@ -652,7 +672,7 @@ static MACHINE_RESET( nwktr )
cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE); cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
} }
static MACHINE_CONFIG_START( nwktr, driver_device ) static MACHINE_CONFIG_START( nwktr, nwktr_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */ MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */
@ -715,11 +735,12 @@ MACHINE_CONFIG_END
static DRIVER_INIT(nwktr) static DRIVER_INIT(nwktr)
{ {
nwktr_state *state = machine->driver_data<nwktr_state>();
init_konami_cgboard(machine, 1, CGBOARD_TYPE_NWKTR); init_konami_cgboard(machine, 1, CGBOARD_TYPE_NWKTR);
set_cgboard_texture_bank(machine, 0, "bank5", machine->region("user5")->base()); set_cgboard_texture_bank(machine, 0, "bank5", machine->region("user5")->base());
sharc_dataram = auto_alloc_array(machine, UINT32, 0x100000/4); state->sharc_dataram = auto_alloc_array(machine, UINT32, 0x100000/4);
led_reg0 = led_reg1 = 0x7f; state->led_reg0 = state->led_reg1 = 0x7f;
lanc2_init(machine); lanc2_init(machine);
} }

View File

@ -28,11 +28,6 @@ GP1 HDD data contents:
#include "machine/nvram.h" #include "machine/nvram.h"
#include "includes/qdrmfgp.h" #include "includes/qdrmfgp.h"
static UINT8 *sndram;
static UINT16 *workram;
static UINT16 control;
static INT32 qdrmfgp_pal;
static INT32 gp2_irq_control;
/************************************* /*************************************
* *
@ -42,9 +37,10 @@ static INT32 gp2_irq_control;
static CUSTOM_INPUT( inputs_r ) static CUSTOM_INPUT( inputs_r )
{ {
qdrmfgp_state *state = field->port->machine->driver_data<qdrmfgp_state>();
const char *tag1 = (const char *)param; const char *tag1 = (const char *)param;
const char *tag2 = tag1 + strlen(tag1) + 1; const char *tag2 = tag1 + strlen(tag1) + 1;
return input_port_read(field->port->machine, (control & 0x0080) ? tag1 : tag2); return input_port_read(field->port->machine, (state->control & 0x0080) ? tag1 : tag2);
} }
static CUSTOM_INPUT( battery_sensor_r ) static CUSTOM_INPUT( battery_sensor_r )
@ -54,13 +50,10 @@ static CUSTOM_INPUT( battery_sensor_r )
} }
int qdrmfgp_get_palette(void)
{
return qdrmfgp_pal;
}
static WRITE16_HANDLER( gp_control_w ) static WRITE16_HANDLER( gp_control_w )
{ {
qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>();
/* bit 0 enable irq 1 (sound) */ /* bit 0 enable irq 1 (sound) */
/* bit 1 enable irq 2 (not used) */ /* bit 1 enable irq 2 (not used) */
/* bit 2 enable irq 3 (vblank) */ /* bit 2 enable irq 3 (vblank) */
@ -73,10 +66,10 @@ static WRITE16_HANDLER( gp_control_w )
/* bit 11 headphone volume: 1=up, 0=down */ /* bit 11 headphone volume: 1=up, 0=down */
/* bit 15 gfxrom bankswitch */ /* bit 15 gfxrom bankswitch */
COMBINE_DATA(&control); COMBINE_DATA(&state->control);
qdrmfgp_pal = control & 0x70; state->pal = state->control & 0x70;
if (control & 0x0100) if (state->control & 0x0100)
{ {
qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>(); qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>();
int vol = state->m_nvram[0x10] & 0xff; int vol = state->m_nvram[0x10] & 0xff;
@ -94,6 +87,8 @@ static WRITE16_HANDLER( gp_control_w )
static WRITE16_HANDLER( gp2_control_w ) static WRITE16_HANDLER( gp2_control_w )
{ {
qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>();
/* bit 2 enable irq 3 (sound) */ /* bit 2 enable irq 3 (sound) */
/* bit 3 enable irq 4 (vblank) */ /* bit 3 enable irq 4 (vblank) */
/* bit 4 enable irq 5 (hdd) */ /* bit 4 enable irq 5 (hdd) */
@ -104,10 +99,10 @@ static WRITE16_HANDLER( gp2_control_w )
/* bit 11 headphone volume: 1=up, 0=down */ /* bit 11 headphone volume: 1=up, 0=down */
/* bit 15 gfxrom bankswitch */ /* bit 15 gfxrom bankswitch */
COMBINE_DATA(&control); COMBINE_DATA(&state->control);
qdrmfgp_pal = 0; state->pal = 0;
if (control & 0x0100) if (state->control & 0x0100)
{ {
qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>(); qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>();
int vol = state->m_nvram[0x8] & 0xff; int vol = state->m_nvram[0x8] & 0xff;
@ -126,13 +121,14 @@ static WRITE16_HANDLER( gp2_control_w )
static READ16_HANDLER( v_rom_r ) static READ16_HANDLER( v_rom_r )
{ {
qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>();
device_t *k056832 = space->machine->device("k056832"); device_t *k056832 = space->machine->device("k056832");
UINT8 *mem8 = space->machine->region("gfx1")->base(); UINT8 *mem8 = space->machine->region("gfx1")->base();
int bank = k056832_word_r(k056832, 0x34/2, 0xffff); int bank = k056832_word_r(k056832, 0x34/2, 0xffff);
offset += bank * 0x800 * 4; offset += bank * 0x800 * 4;
if (control & 0x8000) if (state->control & 0x8000)
offset += 0x800 * 2; offset += 0x800 * 2;
return (mem8[offset + 1] << 8) + mem8[offset]; return (mem8[offset + 1] << 8) + mem8[offset];
@ -184,19 +180,21 @@ static WRITE16_HANDLER( gp2_vram_mirror_w )
static READ16_HANDLER( sndram_r ) static READ16_HANDLER( sndram_r )
{ {
qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>();
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
return sndram[offset]; return state->sndram[offset];
return 0; return 0;
} }
static WRITE16_HANDLER( sndram_w ) static WRITE16_HANDLER( sndram_w )
{ {
qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>();
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
{ {
sndram[offset] = data & 0xff; state->sndram[offset] = data & 0xff;
if (offset >= 0x40000) if (offset >= 0x40000)
sndram[offset+0xc00000-0x900000] = data & 0xff; state->sndram[offset+0xc00000-0x900000] = data & 0xff;
} }
} }
@ -238,6 +236,7 @@ static WRITE16_DEVICE_HANDLER( ide_alt_w )
static READ16_HANDLER( gp2_ide_std_r ) static READ16_HANDLER( gp2_ide_std_r )
{ {
qdrmfgp_state *state = space->machine->driver_data<qdrmfgp_state>();
device_t *device = space->machine->device("ide"); device_t *device = space->machine->device("ide");
if (offset & 0x01) if (offset & 0x01)
{ {
@ -246,11 +245,11 @@ static READ16_HANDLER( gp2_ide_std_r )
switch (cpu_get_previouspc(space->cpu)) switch (cpu_get_previouspc(space->cpu))
{ {
case 0xdb4c: case 0xdb4c:
if ((workram[0x5fa4/2] - cpu_get_reg(space->cpu, M68K_D0)) <= 0x10) if ((state->workram[0x5fa4/2] - cpu_get_reg(space->cpu, M68K_D0)) <= 0x10)
gp2_irq_control = 1; state->gp2_irq_control = 1;
break; break;
case 0xdec2: case 0xdec2:
gp2_irq_control = 1; state->gp2_irq_control = 1;
default: default:
break; break;
} }
@ -270,16 +269,17 @@ static READ16_HANDLER( gp2_ide_std_r )
static INTERRUPT_GEN(qdrmfgp_interrupt) static INTERRUPT_GEN(qdrmfgp_interrupt)
{ {
qdrmfgp_state *state = device->machine->driver_data<qdrmfgp_state>();
switch (cpu_getiloops(device)) switch (cpu_getiloops(device))
{ {
case 0: case 0:
if (control & 0x0001) if (state->control & 0x0001)
cpu_set_input_line(device, 1, HOLD_LINE); cpu_set_input_line(device, 1, HOLD_LINE);
break; break;
case 1: case 1:
/* trigger V-blank interrupt */ /* trigger V-blank interrupt */
if (control & 0x0004) if (state->control & 0x0004)
cpu_set_input_line(device, 3, HOLD_LINE); cpu_set_input_line(device, 3, HOLD_LINE);
break; break;
} }
@ -287,7 +287,8 @@ static INTERRUPT_GEN(qdrmfgp_interrupt)
static void ide_interrupt(device_t *device, int state) static void ide_interrupt(device_t *device, int state)
{ {
if (control & 0x0008) qdrmfgp_state *drvstate = device->machine->driver_data<qdrmfgp_state>();
if (drvstate->control & 0x0008)
{ {
if (state != CLEAR_LINE) if (state != CLEAR_LINE)
cputag_set_input_line(device->machine, "maincpu", 4, HOLD_LINE); cputag_set_input_line(device->machine, "maincpu", 4, HOLD_LINE);
@ -300,25 +301,28 @@ static void ide_interrupt(device_t *device, int state)
static TIMER_CALLBACK( gp2_timer_callback ) static TIMER_CALLBACK( gp2_timer_callback )
{ {
if (control & 0x0004) qdrmfgp_state *state = machine->driver_data<qdrmfgp_state>();
if (state->control & 0x0004)
cputag_set_input_line(machine, "maincpu", 3, HOLD_LINE); cputag_set_input_line(machine, "maincpu", 3, HOLD_LINE);
} }
static INTERRUPT_GEN(qdrmfgp2_interrupt) static INTERRUPT_GEN(qdrmfgp2_interrupt)
{ {
qdrmfgp_state *state = device->machine->driver_data<qdrmfgp_state>();
/* trigger V-blank interrupt */ /* trigger V-blank interrupt */
if (control & 0x0008) if (state->control & 0x0008)
cpu_set_input_line(device, 4, HOLD_LINE); cpu_set_input_line(device, 4, HOLD_LINE);
} }
static void gp2_ide_interrupt(device_t *device, int state) static void gp2_ide_interrupt(device_t *device, int state)
{ {
if (control & 0x0010) qdrmfgp_state *drvstate = device->machine->driver_data<qdrmfgp_state>();
if (drvstate->control & 0x0010)
{ {
if (state != CLEAR_LINE) if (state != CLEAR_LINE)
{ {
if (gp2_irq_control) if (drvstate->gp2_irq_control)
gp2_irq_control = 0; drvstate->gp2_irq_control = 0;
else else
cputag_set_input_line(device->machine, "maincpu", 5, HOLD_LINE); cputag_set_input_line(device->machine, "maincpu", 5, HOLD_LINE);
} }
@ -338,7 +342,7 @@ static void gp2_ide_interrupt(device_t *device, int state)
static ADDRESS_MAP_START( qdrmfgp_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( qdrmfgp_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE(&workram) /* work ram */ AM_RANGE(0x100000, 0x10ffff) AM_RAM AM_BASE_MEMBER(qdrmfgp_state, workram) /* work ram */
AM_RANGE(0x180000, 0x183fff) AM_RAM AM_SHARE("nvram") /* backup ram */ AM_RANGE(0x180000, 0x183fff) AM_RAM AM_SHARE("nvram") /* backup ram */
AM_RANGE(0x280000, 0x280fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x280000, 0x280fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x300000, 0x30003f) AM_DEVWRITE("k056832", k056832_word_w) /* video reg */ AM_RANGE(0x300000, 0x30003f) AM_DEVWRITE("k056832", k056832_word_w) /* video reg */
@ -361,7 +365,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( qdrmfgp2_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( qdrmfgp2_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x0fffff) AM_ROM AM_RANGE(0x000000, 0x0fffff) AM_ROM
AM_RANGE(0x100000, 0x110fff) AM_RAM AM_BASE(&workram) /* work ram */ AM_RANGE(0x100000, 0x110fff) AM_RAM AM_BASE_MEMBER(qdrmfgp_state, workram) /* work ram */
AM_RANGE(0x180000, 0x183fff) AM_RAM AM_SHARE("nvram") /* backup ram */ AM_RANGE(0x180000, 0x183fff) AM_RAM AM_SHARE("nvram") /* backup ram */
AM_RANGE(0x280000, 0x280fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x280000, 0x280fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x300000, 0x30003f) AM_DEVWRITE("k056832", k056832_word_w) /* video reg */ AM_RANGE(0x300000, 0x30003f) AM_DEVWRITE("k056832", k056832_word_w) /* video reg */
@ -570,7 +574,8 @@ INPUT_PORTS_END
static void sound_irq(device_t *device) static void sound_irq(device_t *device)
{ {
if (control & 0x0001) qdrmfgp_state *state = device->machine->driver_data<qdrmfgp_state>();
if (state->control & 0x0001)
cputag_set_input_line(device->machine, "maincpu", 1, HOLD_LINE); cputag_set_input_line(device->machine, "maincpu", 1, HOLD_LINE);
} }
@ -608,9 +613,10 @@ static const k056832_interface qdrmfgp2_k056832_intf =
static MACHINE_START( qdrmfgp ) static MACHINE_START( qdrmfgp )
{ {
state_save_register_global(machine, control); qdrmfgp_state *state = machine->driver_data<qdrmfgp_state>();
state_save_register_global(machine, qdrmfgp_pal); state_save_register_global(machine, state->control);
state_save_register_global(machine, gp2_irq_control); state_save_register_global(machine, state->pal);
state_save_register_global(machine, state->gp2_irq_control);
} }
static MACHINE_START( qdrmfgp2 ) static MACHINE_START( qdrmfgp2 )
@ -623,10 +629,11 @@ static MACHINE_START( qdrmfgp2 )
static MACHINE_RESET( qdrmfgp ) static MACHINE_RESET( qdrmfgp )
{ {
sndram = machine->region("konami")->base() + 0x100000; qdrmfgp_state *state = machine->driver_data<qdrmfgp_state>();
state->sndram = machine->region("konami")->base() + 0x100000;
/* reset the IDE controller */ /* reset the IDE controller */
gp2_irq_control = 0; state->gp2_irq_control = 0;
devtag_reset(machine, "ide"); devtag_reset(machine, "ide");
} }

View File

@ -39,6 +39,17 @@ Notes/Tidbits:
#include "includes/galaxold.h" #include "includes/galaxold.h"
#include "sound/ay8910.h" #include "sound/ay8910.h"
class scobra_state : public driver_device
{
public:
scobra_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *soundram;
};
static const gfx_layout scobra_charlayout = static const gfx_layout scobra_charlayout =
{ {
8,8, 8,8,
@ -302,22 +313,23 @@ static ADDRESS_MAP_START( anteatgb_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xfe00, 0xfe03) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w) AM_RANGE(0xfe00, 0xfe03) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)
ADDRESS_MAP_END ADDRESS_MAP_END
static UINT8 *scobra_soundram;
static READ8_HANDLER(scobra_soundram_r) static READ8_HANDLER(scobra_soundram_r)
{ {
return scobra_soundram[offset & 0x03ff]; scobra_state *state = space->machine->driver_data<scobra_state>();
return state->soundram[offset & 0x03ff];
} }
static WRITE8_HANDLER(scobra_soundram_w) static WRITE8_HANDLER(scobra_soundram_w)
{ {
scobra_soundram[offset & 0x03ff] = data; scobra_state *state = space->machine->driver_data<scobra_state>();
state->soundram[offset & 0x03ff] = data;
} }
static ADDRESS_MAP_START( scobra_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( scobra_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x2fff) AM_ROM AM_RANGE(0x0000, 0x2fff) AM_ROM
AM_RANGE(0x8000, 0x8fff) AM_READWRITE(scobra_soundram_r, scobra_soundram_w) AM_RANGE(0x8000, 0x8fff) AM_READWRITE(scobra_soundram_r, scobra_soundram_w)
AM_RANGE(0x8000, 0x83ff) AM_WRITENOP AM_BASE(&scobra_soundram) /* only here to initialize pointer */ AM_RANGE(0x8000, 0x83ff) AM_WRITENOP AM_BASE_MEMBER(scobra_state, soundram) /* only here to initialize pointer */
AM_RANGE(0x9000, 0x9fff) AM_WRITE(scramble_filter_w) AM_RANGE(0x9000, 0x9fff) AM_WRITE(scramble_filter_w)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -325,7 +337,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( hustlerb_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( hustlerb_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x2fff) AM_ROM AM_RANGE(0x0000, 0x2fff) AM_ROM
AM_RANGE(0x6000, 0x6fff) AM_WRITE(frogger_filter_w) AM_RANGE(0x6000, 0x6fff) AM_WRITE(frogger_filter_w)
AM_RANGE(0x8000, 0x8fff) AM_RAM_READ(scobra_soundram_r) AM_BASE(&scobra_soundram) /* only here to initialize pointer */ AM_RANGE(0x8000, 0x8fff) AM_RAM_READ(scobra_soundram_r) AM_BASE_MEMBER(scobra_state, soundram) /* only here to initialize pointer */
ADDRESS_MAP_END ADDRESS_MAP_END
@ -850,7 +862,7 @@ static const ay8910_interface scobra_ay8910_interface_2 =
}; };
static MACHINE_CONFIG_START( type1, driver_device ) static MACHINE_CONFIG_START( type1, scobra_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 18432000/6) /* 3.072 MHz */ MCFG_CPU_ADD("maincpu", Z80, 18432000/6) /* 3.072 MHz */
@ -975,7 +987,7 @@ static MACHINE_CONFIG_DERIVED( darkplnt, type2 )
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_START( hustler, driver_device ) static MACHINE_CONFIG_START( hustler, scobra_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 18432000/6) /* 3.072 MHz */ MCFG_CPU_ADD("maincpu", Z80, 18432000/6) /* 3.072 MHz */

View File

@ -152,24 +152,6 @@
/*************************************
*
* Global variables
*
*************************************/
static UINT8 *mainram;
static UINT8 has_usb;
static UINT8 mult_data[2];
static UINT16 mult_result;
static UINT8 spinner_select;
static UINT8 spinner_sign;
static UINT8 spinner_count;
/************************************* /*************************************
* *
* Machine setup and config * Machine setup and config
@ -186,19 +168,21 @@ static INPUT_CHANGED( service_switch )
static MACHINE_START( g80v ) static MACHINE_START( g80v )
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
/* register for save states */ /* register for save states */
state_save_register_global_array(machine, mult_data); state_save_register_global_array(machine, state->mult_data);
state_save_register_global(machine, mult_result); state_save_register_global(machine, state->mult_result);
state_save_register_global(machine, spinner_select); state_save_register_global(machine, state->spinner_select);
state_save_register_global(machine, spinner_sign); state_save_register_global(machine, state->spinner_sign);
state_save_register_global(machine, spinner_count); state_save_register_global(machine, state->spinner_count);
} }
static MACHINE_RESET( g80v ) static MACHINE_RESET( g80v )
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
/* if we have a Universal Sound Board, reset it here */ /* if we have a Universal Sound Board, reset it here */
if (has_usb) if (state->has_usb)
sega_usb_reset(machine, 0x10); sega_usb_reset(machine, 0x10);
} }
@ -221,9 +205,11 @@ static offs_t decrypt_offset(address_space *space, offs_t offset)
return (offset & 0xff00) | (*sega_decrypt)(pc, space->read_byte(pc + 1)); return (offset & 0xff00) | (*sega_decrypt)(pc, space->read_byte(pc + 1));
} }
static WRITE8_HANDLER( mainram_w ) { mainram[decrypt_offset(space, offset)] = data; } static WRITE8_HANDLER( mainram_w ) {
segag80v_state *state = space->machine->driver_data<segag80v_state>(); state->mainram[decrypt_offset(space, offset)] = data; }
static WRITE8_HANDLER( usb_ram_w ) { sega_usb_ram_w(space, decrypt_offset(space, offset), data); } static WRITE8_HANDLER( usb_ram_w ) { sega_usb_ram_w(space, decrypt_offset(space, offset), data); }
static WRITE8_HANDLER( vectorram_w ) { segag80v_vectorram[decrypt_offset(space, offset)] = data; } static WRITE8_HANDLER( vectorram_w ) {
segag80v_state *state = space->machine->driver_data<segag80v_state>(); state->vectorram[decrypt_offset(space, offset)] = data; }
@ -267,15 +253,17 @@ static READ8_HANDLER( mangled_ports_r )
static WRITE8_HANDLER( spinner_select_w ) static WRITE8_HANDLER( spinner_select_w )
{ {
spinner_select = data; segag80v_state *state = space->machine->driver_data<segag80v_state>();
state->spinner_select = data;
} }
static READ8_HANDLER( spinner_input_r ) static READ8_HANDLER( spinner_input_r )
{ {
segag80v_state *state = space->machine->driver_data<segag80v_state>();
INT8 delta; INT8 delta;
if (spinner_select & 1) if (state->spinner_select & 1)
return input_port_read(space->machine, "FC"); return input_port_read(space->machine, "FC");
/* /*
@ -289,10 +277,10 @@ static READ8_HANDLER( spinner_input_r )
delta = input_port_read(space->machine, "SPINNER"); delta = input_port_read(space->machine, "SPINNER");
if (delta != 0) if (delta != 0)
{ {
spinner_sign = (delta >> 7) & 1; state->spinner_sign = (delta >> 7) & 1;
spinner_count += abs(delta); state->spinner_count += abs(delta);
} }
return ~((spinner_count << 1) | spinner_sign); return ~((state->spinner_count << 1) | state->spinner_sign);
} }
@ -311,13 +299,14 @@ static CUSTOM_INPUT( elim4_joint_coin_r )
static READ8_HANDLER( elim4_input_r ) static READ8_HANDLER( elim4_input_r )
{ {
segag80v_state *state = space->machine->driver_data<segag80v_state>();
UINT8 result = 0; UINT8 result = 0;
/* bit 3 enables demux */ /* bit 3 enables demux */
if (spinner_select & 8) if (state->spinner_select & 8)
{ {
/* Demux bit 0-2. Only 6 and 7 are connected */ /* Demux bit 0-2. Only 6 and 7 are connected */
switch (spinner_select & 7) switch (state->spinner_select & 7)
{ {
case 6: case 6:
/* player 3 & 4 controls */ /* player 3 & 4 controls */
@ -344,16 +333,18 @@ static READ8_HANDLER( elim4_input_r )
static WRITE8_HANDLER( multiply_w ) static WRITE8_HANDLER( multiply_w )
{ {
mult_data[offset] = data; segag80v_state *state = space->machine->driver_data<segag80v_state>();
state->mult_data[offset] = data;
if (offset == 1) if (offset == 1)
mult_result = mult_data[0] * mult_data[1]; state->mult_result = state->mult_data[0] * state->mult_data[1];
} }
static READ8_HANDLER( multiply_r ) static READ8_HANDLER( multiply_r )
{ {
UINT8 result = mult_result; segag80v_state *state = space->machine->driver_data<segag80v_state>();
mult_result >>= 8; UINT8 result = state->mult_result;
state->mult_result >>= 8;
return result; return result;
} }
@ -392,8 +383,8 @@ static WRITE8_HANDLER( unknown_w )
static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x07ff) AM_ROM /* CPU board ROM */ AM_RANGE(0x0000, 0x07ff) AM_ROM /* CPU board ROM */
AM_RANGE(0x0800, 0xbfff) AM_ROM /* PROM board ROM area */ AM_RANGE(0x0800, 0xbfff) AM_ROM /* PROM board ROM area */
AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(mainram_w) AM_BASE(&mainram) AM_RANGE(0xc800, 0xcfff) AM_RAM_WRITE(mainram_w) AM_BASE_MEMBER(segag80v_state, mainram)
AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(vectorram_w) AM_BASE(&segag80v_vectorram) AM_SIZE(&segag80v_vectorram_size) AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(vectorram_w) AM_BASE_MEMBER(segag80v_state, vectorram) AM_SIZE_MEMBER(segag80v_state, vectorram_size)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -909,7 +900,7 @@ static const samples_interface zektor_samples_interface =
* *
*************************************/ *************************************/
static MACHINE_CONFIG_START( g80v_base, driver_device ) static MACHINE_CONFIG_START( g80v_base, segag80v_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, CPU_CLOCK/2) MCFG_CPU_ADD("maincpu", Z80, CPU_CLOCK/2)
@ -1310,13 +1301,14 @@ ROM_END
static DRIVER_INIT( elim2 ) static DRIVER_INIT( elim2 )
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO); address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
/* configure security */ /* configure security */
sega_security(70); sega_security(70);
/* configure sound */ /* configure sound */
has_usb = FALSE; state->has_usb = FALSE;
memory_install_write8_handler(iospace, 0x3e, 0x3e, 0, 0, elim1_sh_w); memory_install_write8_handler(iospace, 0x3e, 0x3e, 0, 0, elim1_sh_w);
memory_install_write8_handler(iospace, 0x3f, 0x3f, 0, 0, elim2_sh_w); memory_install_write8_handler(iospace, 0x3f, 0x3f, 0, 0, elim2_sh_w);
} }
@ -1324,13 +1316,14 @@ static DRIVER_INIT( elim2 )
static DRIVER_INIT( elim4 ) static DRIVER_INIT( elim4 )
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO); address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
/* configure security */ /* configure security */
sega_security(76); sega_security(76);
/* configure sound */ /* configure sound */
has_usb = FALSE; state->has_usb = FALSE;
memory_install_write8_handler(iospace, 0x3e, 0x3e, 0, 0, elim1_sh_w); memory_install_write8_handler(iospace, 0x3e, 0x3e, 0, 0, elim1_sh_w);
memory_install_write8_handler(iospace, 0x3f, 0x3f, 0, 0, elim2_sh_w); memory_install_write8_handler(iospace, 0x3f, 0x3f, 0, 0, elim2_sh_w);
@ -1342,13 +1335,14 @@ static DRIVER_INIT( elim4 )
static DRIVER_INIT( spacfury ) static DRIVER_INIT( spacfury )
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO); address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
/* configure security */ /* configure security */
sega_security(64); sega_security(64);
/* configure sound */ /* configure sound */
has_usb = FALSE; state->has_usb = FALSE;
memory_install_write8_handler(iospace, 0x38, 0x38, 0, 0, sega_speech_data_w); memory_install_write8_handler(iospace, 0x38, 0x38, 0, 0, sega_speech_data_w);
memory_install_write8_handler(iospace, 0x3b, 0x3b, 0, 0, sega_speech_control_w); memory_install_write8_handler(iospace, 0x3b, 0x3b, 0, 0, sega_speech_control_w);
memory_install_write8_handler(iospace, 0x3e, 0x3e, 0, 0, spacfury1_sh_w); memory_install_write8_handler(iospace, 0x3e, 0x3e, 0, 0, spacfury1_sh_w);
@ -1358,6 +1352,7 @@ static DRIVER_INIT( spacfury )
static DRIVER_INIT( zektor ) static DRIVER_INIT( zektor )
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO); address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
device_t *ay = machine->device("aysnd"); device_t *ay = machine->device("aysnd");
@ -1365,7 +1360,7 @@ static DRIVER_INIT( zektor )
sega_security(82); sega_security(82);
/* configure sound */ /* configure sound */
has_usb = FALSE; state->has_usb = FALSE;
memory_install_write8_handler(iospace, 0x38, 0x38, 0, 0, sega_speech_data_w); memory_install_write8_handler(iospace, 0x38, 0x38, 0, 0, sega_speech_data_w);
memory_install_write8_handler(iospace, 0x3b, 0x3b, 0, 0, sega_speech_control_w); memory_install_write8_handler(iospace, 0x3b, 0x3b, 0, 0, sega_speech_control_w);
memory_install_write8_device_handler(iospace, ay, 0x3c, 0x3d, 0, 0, ay8910_address_data_w); memory_install_write8_device_handler(iospace, ay, 0x3c, 0x3d, 0, 0, ay8910_address_data_w);
@ -1380,6 +1375,7 @@ static DRIVER_INIT( zektor )
static DRIVER_INIT( tacscan ) static DRIVER_INIT( tacscan )
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
address_space *pgmspace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); address_space *pgmspace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO); address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
@ -1387,7 +1383,7 @@ static DRIVER_INIT( tacscan )
sega_security(76); sega_security(76);
/* configure sound */ /* configure sound */
has_usb = TRUE; state->has_usb = TRUE;
memory_install_readwrite8_handler(iospace, 0x3f, 0x3f, 0, 0, sega_usb_status_r, sega_usb_data_w); memory_install_readwrite8_handler(iospace, 0x3f, 0x3f, 0, 0, sega_usb_status_r, sega_usb_data_w);
memory_install_readwrite8_handler(pgmspace, 0xd000, 0xdfff, 0, 0, sega_usb_ram_r, usb_ram_w); memory_install_readwrite8_handler(pgmspace, 0xd000, 0xdfff, 0, 0, sega_usb_ram_r, usb_ram_w);
@ -1399,6 +1395,7 @@ static DRIVER_INIT( tacscan )
static DRIVER_INIT( startrek ) static DRIVER_INIT( startrek )
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
address_space *pgmspace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); address_space *pgmspace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO); address_space *iospace = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_IO);
@ -1406,7 +1403,7 @@ static DRIVER_INIT( startrek )
sega_security(64); sega_security(64);
/* configure sound */ /* configure sound */
has_usb = TRUE; state->has_usb = TRUE;
memory_install_write8_handler(iospace, 0x38, 0x38, 0, 0, sega_speech_data_w); memory_install_write8_handler(iospace, 0x38, 0x38, 0, 0, sega_speech_data_w);
memory_install_write8_handler(iospace, 0x3b, 0x3b, 0, 0, sega_speech_control_w); memory_install_write8_handler(iospace, 0x3b, 0x3b, 0, 0, sega_speech_control_w);

View File

@ -373,9 +373,6 @@ orunners: Interleaved with the dj and << >> buttons is the data the drives the
* *
*************************************/ *************************************/
UINT8 *ga2_dpram;
UINT16 *system32_workram;
UINT16 *system32_protram;
@ -385,31 +382,15 @@ UINT16 *system32_protram;
* *
*************************************/ *************************************/
static UINT8 *z80_shared_ram;
/* V60 interrupt controller */ /* V60 interrupt controller */
static UINT8 v60_irq_control[0x10];
static timer_device *v60_irq_timer[2];
/* sound interrupt controller */ /* sound interrupt controller */
static UINT8 sound_irq_control[4];
static UINT8 sound_irq_input;
static UINT8 sound_dummy_value;
static UINT16 sound_bank;
/* I/O chips and custom I/O */ /* I/O chips and custom I/O */
static UINT8 misc_io_data[2][0x10];
static read16_space_func custom_io_r[2];
static write16_space_func custom_io_w[2];
static UINT8 analog_bank;
static UINT8 analog_value[4];
static UINT8 sonic_last[6];
/* callbacks to handle output */ /* callbacks to handle output */
typedef void (*sys32_output_callback)(int which, UINT16 data);
static sys32_output_callback segas32_sw1_output, segas32_sw2_output, segas32_sw3_output;
static void (*system32_prot_vblank)(device_t *device); static void (*system32_prot_vblank)(device_t *device);
@ -432,12 +413,13 @@ static void signal_sound_irq(running_machine *machine, int which);
static MACHINE_RESET( system32 ) static MACHINE_RESET( system32 )
{ {
segas32_state *state = machine->driver_data<segas32_state>();
/* initialize the interrupt controller */ /* initialize the interrupt controller */
memset(v60_irq_control, 0xff, sizeof(v60_irq_control)); memset(state->v60_irq_control, 0xff, sizeof(state->v60_irq_control));
/* allocate timers */ /* allocate timers */
v60_irq_timer[0] = machine->device<timer_device>("v60_irq0"); state->v60_irq_timer[0] = machine->device<timer_device>("v60_irq0");
v60_irq_timer[1] = machine->device<timer_device>("v60_irq1"); state->v60_irq_timer[1] = machine->device<timer_device>("v60_irq1");
/* clear IRQ lines */ /* clear IRQ lines */
cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE); cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
@ -453,7 +435,8 @@ static MACHINE_RESET( system32 )
static void update_irq_state(running_machine *machine) static void update_irq_state(running_machine *machine)
{ {
UINT8 effirq = v60_irq_control[7] & ~v60_irq_control[6] & 0x1f; segas32_state *state = machine->driver_data<segas32_state>();
UINT8 effirq = state->v60_irq_control[7] & ~state->v60_irq_control[6] & 0x1f;
int vector; int vector;
/* loop over interrupt vectors, finding the highest priority one with */ /* loop over interrupt vectors, finding the highest priority one with */
@ -473,12 +456,13 @@ static void update_irq_state(running_machine *machine)
static void signal_v60_irq(running_machine *machine, int which) static void signal_v60_irq(running_machine *machine, int which)
{ {
segas32_state *state = machine->driver_data<segas32_state>();
int i; int i;
/* see if this interrupt input is mapped to any vectors; if so, mark them */ /* see if this interrupt input is mapped to any vectors; if so, mark them */
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
if (v60_irq_control[i] == which) if (state->v60_irq_control[i] == which)
v60_irq_control[7] |= 1 << i; state->v60_irq_control[7] |= 1 << i;
update_irq_state(machine); update_irq_state(machine);
} }
@ -491,6 +475,7 @@ static TIMER_DEVICE_CALLBACK( signal_v60_irq_callback )
static void int_control_w(address_space *space, int offset, UINT8 data) static void int_control_w(address_space *space, int offset, UINT8 data)
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
int duration; int duration;
// logerror("%06X:int_control_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data); // logerror("%06X:int_control_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data);
@ -501,42 +486,42 @@ static void int_control_w(address_space *space, int offset, UINT8 data)
case 2: case 2:
case 3: case 3:
case 4: /* vectors */ case 4: /* vectors */
v60_irq_control[offset] = data; state->v60_irq_control[offset] = data;
break; break;
case 5: /* unknown */ case 5: /* unknown */
v60_irq_control[offset] = data; state->v60_irq_control[offset] = data;
break; break;
case 6: /* mask */ case 6: /* mask */
v60_irq_control[offset] = data; state->v60_irq_control[offset] = data;
update_irq_state(space->machine); update_irq_state(space->machine);
break; break;
case 7: /* acknowledge */ case 7: /* acknowledge */
v60_irq_control[offset] &= data; state->v60_irq_control[offset] &= data;
update_irq_state(space->machine); update_irq_state(space->machine);
break; break;
case 8: case 8:
case 9: /* timer 0 count */ case 9: /* timer 0 count */
v60_irq_control[offset] = data; state->v60_irq_control[offset] = data;
duration = v60_irq_control[8] + ((v60_irq_control[9] << 8) & 0xf00); duration = state->v60_irq_control[8] + ((state->v60_irq_control[9] << 8) & 0xf00);
if (duration) if (duration)
{ {
attotime period = attotime::from_hz(TIMER_0_CLOCK) * duration; attotime period = attotime::from_hz(TIMER_0_CLOCK) * duration;
v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0); state->v60_irq_timer[0]->adjust(period, MAIN_IRQ_TIMER0);
} }
break; break;
case 10: case 10:
case 11: /* timer 1 count */ case 11: /* timer 1 count */
v60_irq_control[offset] = data; state->v60_irq_control[offset] = data;
duration = v60_irq_control[10] + ((v60_irq_control[11] << 8) & 0xf00); duration = state->v60_irq_control[10] + ((state->v60_irq_control[11] << 8) & 0xf00);
if (duration) if (duration)
{ {
attotime period = attotime::from_hz(TIMER_1_CLOCK) * duration; attotime period = attotime::from_hz(TIMER_1_CLOCK) * duration;
v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1); state->v60_irq_timer[1]->adjust(period, MAIN_IRQ_TIMER1);
} }
break; break;
@ -630,6 +615,7 @@ static INTERRUPT_GEN( start_of_vblank_int )
static UINT16 common_io_chip_r(address_space *space, int which, offs_t offset, UINT16 mem_mask) static UINT16 common_io_chip_r(address_space *space, int which, offs_t offset, UINT16 mem_mask)
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
static const char *const portnames[2][8] = static const char *const portnames[2][8] =
{ {
{ "P1_A", "P2_A", "PORTC_A", "PORTD_A", "SERVICE12_A", "SERVICE34_A", "PORTG_A", "PORTH_A" }, { "P1_A", "P2_A", "PORTC_A", "PORTD_A", "SERVICE12_A", "SERVICE34_A", "PORTG_A", "PORTH_A" },
@ -649,8 +635,8 @@ static UINT16 common_io_chip_r(address_space *space, int which, offs_t offset, U
case 0x0c/2: case 0x0c/2:
case 0x0e/2: case 0x0e/2:
/* if the port is configured as an output, return the last thing written */ /* if the port is configured as an output, return the last thing written */
if (misc_io_data[which][0x1e/2] & (1 << offset)) if (state->misc_io_data[which][0x1e/2] & (1 << offset))
return misc_io_data[which][offset]; return state->misc_io_data[which][offset];
/* otherwise, return an input port */ /* otherwise, return an input port */
return input_port_read_safe(space->machine, portnames[which][offset], 0xffff); return input_port_read_safe(space->machine, portnames[which][offset], 0xffff);
@ -668,12 +654,12 @@ static UINT16 common_io_chip_r(address_space *space, int which, offs_t offset, U
/* CNT register & mirror */ /* CNT register & mirror */
case 0x18/2: case 0x18/2:
case 0x1c/2: case 0x1c/2:
return misc_io_data[which][0x1c/2]; return state->misc_io_data[which][0x1c/2];
/* port direction register & mirror */ /* port direction register & mirror */
case 0x1a/2: case 0x1a/2:
case 0x1e/2: case 0x1e/2:
return misc_io_data[which][0x1e/2]; return state->misc_io_data[which][0x1e/2];
} }
return 0xffff; return 0xffff;
} }
@ -681,6 +667,7 @@ static UINT16 common_io_chip_r(address_space *space, int which, offs_t offset, U
static void common_io_chip_w(address_space *space, int which, offs_t offset, UINT16 data, UINT16 mem_mask) static void common_io_chip_w(address_space *space, int which, offs_t offset, UINT16 data, UINT16 mem_mask)
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
UINT8 old; UINT8 old;
/* only LSB matters */ /* only LSB matters */
@ -689,8 +676,8 @@ static void common_io_chip_w(address_space *space, int which, offs_t offset, UIN
/* generic implementation */ /* generic implementation */
offset &= 0x1f/2; offset &= 0x1f/2;
old = misc_io_data[which][offset]; old = state->misc_io_data[which][offset];
misc_io_data[which][offset] = data; state->misc_io_data[which][offset] = data;
switch (offset) switch (offset)
{ {
@ -701,14 +688,14 @@ static void common_io_chip_w(address_space *space, int which, offs_t offset, UIN
case 0x08/2: case 0x08/2:
case 0x0a/2: case 0x0a/2:
case 0x0c/2: case 0x0c/2:
if (segas32_sw2_output) if (state->sw2_output)
segas32_sw2_output(which, data); state->sw2_output(which, data);
break; break;
/* miscellaneous output */ /* miscellaneous output */
case 0x06/2: case 0x06/2:
if (segas32_sw1_output) if (state->sw1_output)
segas32_sw1_output(which, data); state->sw1_output(which, data);
if (which == 0) if (which == 0)
{ {
@ -726,7 +713,7 @@ static void common_io_chip_w(address_space *space, int which, offs_t offset, UIN
/* tile banking */ /* tile banking */
case 0x0e/2: case 0x0e/2:
if (which == 0) if (which == 0)
system32_tilebank_external = data; state->system32_tilebank_external = data;
else else
{ {
/* multi-32 EEPROM access */ /* multi-32 EEPROM access */
@ -739,7 +726,7 @@ static void common_io_chip_w(address_space *space, int which, offs_t offset, UIN
/* CNT register */ /* CNT register */
case 0x1c/2: case 0x1c/2:
system32_displayenable[which] = (data & 0x02); state->system32_displayenable[which] = (data & 0x02);
if (which == 0) if (which == 0)
cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE); cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_RESET, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE);
break; break;
@ -800,8 +787,9 @@ static WRITE32_HANDLER( io_chip_1_w )
static READ16_HANDLER( io_expansion_r ) static READ16_HANDLER( io_expansion_r )
{ {
if (custom_io_r[0]) segas32_state *state = space->machine->driver_data<segas32_state>();
return (*custom_io_r[0])(space, offset, mem_mask); if (state->custom_io_r[0])
return (*state->custom_io_r[0])(space, offset, mem_mask);
else else
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset); logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
return 0xffff; return 0xffff;
@ -810,12 +798,13 @@ static READ16_HANDLER( io_expansion_r )
static WRITE16_HANDLER( io_expansion_w ) static WRITE16_HANDLER( io_expansion_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
/* only LSB matters */ /* only LSB matters */
if (!ACCESSING_BITS_0_7) if (!ACCESSING_BITS_0_7)
return; return;
if (custom_io_w[0]) if (state->custom_io_w[0])
(*custom_io_w[0])(space, offset, data, mem_mask); (*state->custom_io_w[0])(space, offset, data, mem_mask);
else else
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff); logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
} }
@ -823,9 +812,10 @@ static WRITE16_HANDLER( io_expansion_w )
static READ32_HANDLER( io_expansion_0_r ) static READ32_HANDLER( io_expansion_0_r )
{ {
if (custom_io_r[0]) segas32_state *state = space->machine->driver_data<segas32_state>();
return (*custom_io_r[0])(space, offset*2+0, mem_mask) | if (state->custom_io_r[0])
((*custom_io_r[0])(space, offset*2+1, mem_mask >> 16) << 16); return (*state->custom_io_r[0])(space, offset*2+0, mem_mask) |
((*state->custom_io_r[0])(space, offset*2+1, mem_mask >> 16) << 16);
else else
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset); logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
return 0xffffffff; return 0xffffffff;
@ -834,25 +824,26 @@ static READ32_HANDLER( io_expansion_0_r )
static WRITE32_HANDLER( io_expansion_0_w ) static WRITE32_HANDLER( io_expansion_0_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
/* only LSB matters */ /* only LSB matters */
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
{ {
/* harddunk uses bits 4,5 for output lamps */ /* harddunk uses bits 4,5 for output lamps */
if (segas32_sw3_output) if (state->sw3_output)
segas32_sw3_output(0, data & 0xff); state->sw3_output(0, data & 0xff);
if (custom_io_w[0]) if (state->custom_io_w[0])
(*custom_io_w[0])(space, offset*2+0, data, mem_mask); (*state->custom_io_w[0])(space, offset*2+0, data, mem_mask);
else else
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff); logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
} }
if (ACCESSING_BITS_16_23) if (ACCESSING_BITS_16_23)
{ {
if (custom_io_w[0]) if (state->custom_io_w[0])
(*custom_io_w[0])(space, offset*2+1, data >> 16, mem_mask >> 16); (*state->custom_io_w[0])(space, offset*2+1, data >> 16, mem_mask >> 16);
else else
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff); logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
} }
@ -861,9 +852,10 @@ static WRITE32_HANDLER( io_expansion_0_w )
static READ32_HANDLER( io_expansion_1_r ) static READ32_HANDLER( io_expansion_1_r )
{ {
if (custom_io_r[1]) segas32_state *state = space->machine->driver_data<segas32_state>();
return (*custom_io_r[1])(space, offset*2+0, mem_mask) | if (state->custom_io_r[1])
((*custom_io_r[1])(space, offset*2+1, mem_mask >> 16) << 16); return (*state->custom_io_r[1])(space, offset*2+0, mem_mask) |
((*state->custom_io_r[1])(space, offset*2+1, mem_mask >> 16) << 16);
else else
logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset); logerror("%06X:io_expansion_r(%X)\n", cpu_get_pc(space->cpu), offset);
return 0xffffffff; return 0xffffffff;
@ -872,18 +864,19 @@ static READ32_HANDLER( io_expansion_1_r )
static WRITE32_HANDLER( io_expansion_1_w ) static WRITE32_HANDLER( io_expansion_1_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
/* only LSB matters */ /* only LSB matters */
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
{ {
if (custom_io_w[1]) if (state->custom_io_w[1])
(*custom_io_w[1])(space, offset*2+0, data, mem_mask); (*state->custom_io_w[1])(space, offset*2+0, data, mem_mask);
else else
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff); logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
} }
if (ACCESSING_BITS_16_23) if (ACCESSING_BITS_16_23)
{ {
if (custom_io_w[1]) if (state->custom_io_w[1])
(*custom_io_w[1])(space, offset*2+1, data >> 16, mem_mask >> 16); (*state->custom_io_w[1])(space, offset*2+1, data >> 16, mem_mask >> 16);
else else
logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff); logerror("%06X:io_expansion_w(%X) = %02X\n", cpu_get_pc(space->cpu), offset, data & 0xff);
} }
@ -899,6 +892,7 @@ static WRITE32_HANDLER( io_expansion_1_w )
static READ16_HANDLER( analog_custom_io_r ) static READ16_HANDLER( analog_custom_io_r )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
UINT16 result; UINT16 result;
switch (offset) switch (offset)
{ {
@ -906,8 +900,8 @@ static READ16_HANDLER( analog_custom_io_r )
case 0x12/2: case 0x12/2:
case 0x14/2: case 0x14/2:
case 0x16/2: case 0x16/2:
result = analog_value[offset & 3] | 0x7f; result = state->analog_value[offset & 3] | 0x7f;
analog_value[offset & 3] <<= 1; state->analog_value[offset & 3] <<= 1;
return result; return result;
} }
logerror("%06X:unknown analog_custom_io_r(%X) & %04X\n", cpu_get_pc(space->cpu), offset*2, mem_mask); logerror("%06X:unknown analog_custom_io_r(%X) & %04X\n", cpu_get_pc(space->cpu), offset*2, mem_mask);
@ -917,6 +911,7 @@ static READ16_HANDLER( analog_custom_io_r )
static WRITE16_HANDLER( analog_custom_io_w ) static WRITE16_HANDLER( analog_custom_io_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
static const char *const names[] = { "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4" }; static const char *const names[] = { "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4" };
switch (offset) switch (offset)
{ {
@ -924,7 +919,7 @@ static WRITE16_HANDLER( analog_custom_io_w )
case 0x12/2: case 0x12/2:
case 0x14/2: case 0x14/2:
case 0x16/2: case 0x16/2:
analog_value[offset & 3] = input_port_read_safe(space->machine, names[offset & 3], 0); state->analog_value[offset & 3] = input_port_read_safe(space->machine, names[offset & 3], 0);
return; return;
} }
logerror("%06X:unknown analog_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask); logerror("%06X:unknown analog_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask);
@ -950,6 +945,7 @@ static READ16_HANDLER( extra_custom_io_r )
static WRITE16_HANDLER( orunners_custom_io_w ) static WRITE16_HANDLER( orunners_custom_io_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
static const char *const names[] = { "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4", "ANALOG5", "ANALOG6", "ANALOG7", "ANALOG8" }; static const char *const names[] = { "ANALOG1", "ANALOG2", "ANALOG3", "ANALOG4", "ANALOG5", "ANALOG6", "ANALOG7", "ANALOG8" };
switch (offset) switch (offset)
{ {
@ -957,11 +953,11 @@ static WRITE16_HANDLER( orunners_custom_io_w )
case 0x12/2: case 0x12/2:
case 0x14/2: case 0x14/2:
case 0x16/2: case 0x16/2:
analog_value[offset & 3] = input_port_read_safe(space->machine, names[analog_bank * 4 + (offset & 3)], 0); state->analog_value[offset & 3] = input_port_read_safe(space->machine, names[state->analog_bank * 4 + (offset & 3)], 0);
return; return;
case 0x20/2: case 0x20/2:
analog_bank = data & 1; state->analog_bank = data & 1;
return; return;
} }
logerror("%06X:unknown orunners_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask); logerror("%06X:unknown orunners_custom_io_w(%X) = %04X & %04X\n", cpu_get_pc(space->cpu), offset*2, data, mem_mask);
@ -970,6 +966,7 @@ static WRITE16_HANDLER( orunners_custom_io_w )
static READ16_HANDLER( sonic_custom_io_r ) static READ16_HANDLER( sonic_custom_io_r )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
static const char *const names[] = { "TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3" }; static const char *const names[] = { "TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3" };
switch (offset) switch (offset)
@ -980,7 +977,7 @@ static READ16_HANDLER( sonic_custom_io_r )
case 0x0c/2: case 0x0c/2:
case 0x10/2: case 0x10/2:
case 0x14/2: case 0x14/2:
return (UINT8)(input_port_read(space->machine, names[offset/2]) - sonic_last[offset/2]); return (UINT8)(input_port_read(space->machine, names[offset/2]) - state->sonic_last[offset/2]);
} }
logerror("%06X:unknown sonic_custom_io_r(%X) & %04X\n", cpu_get_pc(space->cpu), offset*2, mem_mask); logerror("%06X:unknown sonic_custom_io_r(%X) & %04X\n", cpu_get_pc(space->cpu), offset*2, mem_mask);
@ -990,6 +987,7 @@ static READ16_HANDLER( sonic_custom_io_r )
static WRITE16_HANDLER( sonic_custom_io_w ) static WRITE16_HANDLER( sonic_custom_io_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
static const char *const names[] = { "TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3" }; static const char *const names[] = { "TRACKX1", "TRACKY1", "TRACKX2", "TRACKY2", "TRACKX3", "TRACKY3" };
switch (offset) switch (offset)
@ -997,8 +995,8 @@ static WRITE16_HANDLER( sonic_custom_io_w )
case 0x00/2: case 0x00/2:
case 0x08/2: case 0x08/2:
case 0x10/2: case 0x10/2:
sonic_last[offset/2 + 0] = input_port_read(space->machine, names[offset/2 + 0]); state->sonic_last[offset/2 + 0] = input_port_read(space->machine, names[offset/2 + 0]);
sonic_last[offset/2 + 1] = input_port_read(space->machine, names[offset/2 + 1]); state->sonic_last[offset/2 + 1] = input_port_read(space->machine, names[offset/2 + 1]);
return; return;
} }
@ -1043,36 +1041,40 @@ static READ32_HANDLER( random_number_32_r )
static READ16_HANDLER( shared_ram_16_r ) static READ16_HANDLER( shared_ram_16_r )
{ {
return z80_shared_ram[offset*2+0] | (z80_shared_ram[offset*2+1] << 8); segas32_state *state = space->machine->driver_data<segas32_state>();
return state->z80_shared_ram[offset*2+0] | (state->z80_shared_ram[offset*2+1] << 8);
} }
static WRITE16_HANDLER( shared_ram_16_w ) static WRITE16_HANDLER( shared_ram_16_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
z80_shared_ram[offset*2+0] = data; state->z80_shared_ram[offset*2+0] = data;
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
z80_shared_ram[offset*2+1] = data >> 8; state->z80_shared_ram[offset*2+1] = data >> 8;
} }
static READ32_HANDLER( shared_ram_32_r ) static READ32_HANDLER( shared_ram_32_r )
{ {
return z80_shared_ram[offset*4+0] | (z80_shared_ram[offset*4+1] << 8) | segas32_state *state = space->machine->driver_data<segas32_state>();
(z80_shared_ram[offset*4+2] << 16) | (z80_shared_ram[offset*4+3] << 24); return state->z80_shared_ram[offset*4+0] | (state->z80_shared_ram[offset*4+1] << 8) |
(state->z80_shared_ram[offset*4+2] << 16) | (state->z80_shared_ram[offset*4+3] << 24);
} }
static WRITE32_HANDLER( shared_ram_32_w ) static WRITE32_HANDLER( shared_ram_32_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
z80_shared_ram[offset*4+0] = data; state->z80_shared_ram[offset*4+0] = data;
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
z80_shared_ram[offset*4+1] = data >> 8; state->z80_shared_ram[offset*4+1] = data >> 8;
if (ACCESSING_BITS_16_23) if (ACCESSING_BITS_16_23)
z80_shared_ram[offset*4+2] = data >> 16; state->z80_shared_ram[offset*4+2] = data >> 16;
if (ACCESSING_BITS_24_31) if (ACCESSING_BITS_24_31)
z80_shared_ram[offset*4+3] = data >> 24; state->z80_shared_ram[offset*4+3] = data >> 24;
} }
@ -1085,7 +1087,8 @@ static WRITE32_HANDLER( shared_ram_32_w )
static void update_sound_irq_state(running_machine *machine) static void update_sound_irq_state(running_machine *machine)
{ {
UINT8 effirq = sound_irq_input & ~sound_irq_control[3] & 0x07; segas32_state *state = machine->driver_data<segas32_state>();
UINT8 effirq = state->sound_irq_input & ~state->sound_irq_control[3] & 0x07;
int vector; int vector;
/* loop over interrupt vectors, finding the highest priority one with */ /* loop over interrupt vectors, finding the highest priority one with */
@ -1105,32 +1108,35 @@ static void update_sound_irq_state(running_machine *machine)
static void signal_sound_irq(running_machine *machine, int which) static void signal_sound_irq(running_machine *machine, int which)
{ {
segas32_state *state = machine->driver_data<segas32_state>();
int i; int i;
/* see if this interrupt input is mapped to any vectors; if so, mark them */ /* see if this interrupt input is mapped to any vectors; if so, mark them */
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (sound_irq_control[i] == which) if (state->sound_irq_control[i] == which)
sound_irq_input |= 1 << i; state->sound_irq_input |= 1 << i;
update_sound_irq_state(machine); update_sound_irq_state(machine);
} }
static void clear_sound_irq(running_machine *machine, int which) static void clear_sound_irq(running_machine *machine, int which)
{ {
segas32_state *state = machine->driver_data<segas32_state>();
int i; int i;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
if (sound_irq_control[i] == which) if (state->sound_irq_control[i] == which)
sound_irq_input &= ~(1 << i); state->sound_irq_input &= ~(1 << i);
update_sound_irq_state(machine); update_sound_irq_state(machine);
} }
static WRITE8_HANDLER( sound_int_control_lo_w ) static WRITE8_HANDLER( sound_int_control_lo_w )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
/* odd offsets are interrupt acks */ /* odd offsets are interrupt acks */
if (offset & 1) if (offset & 1)
{ {
sound_irq_input &= data; state->sound_irq_input &= data;
update_sound_irq_state(space->machine); update_sound_irq_state(space->machine);
} }
@ -1142,7 +1148,8 @@ static WRITE8_HANDLER( sound_int_control_lo_w )
static WRITE8_HANDLER( sound_int_control_hi_w ) static WRITE8_HANDLER( sound_int_control_hi_w )
{ {
sound_irq_control[offset] = data; segas32_state *state = space->machine->driver_data<segas32_state>();
state->sound_irq_control[offset] = data;
update_sound_irq_state(space->machine); update_sound_irq_state(space->machine);
} }
@ -1165,15 +1172,17 @@ static void ym3438_irq_handler(device_t *device, int state)
static WRITE8_HANDLER( sound_bank_lo_w ) static WRITE8_HANDLER( sound_bank_lo_w )
{ {
sound_bank = (sound_bank & ~0x3f) | (data & 0x3f); segas32_state *state = space->machine->driver_data<segas32_state>();
memory_set_bankptr(space->machine, "bank1", space->machine->region("soundcpu")->base() + 0x100000 + 0x2000 * sound_bank); state->sound_bank = (state->sound_bank & ~0x3f) | (data & 0x3f);
memory_set_bankptr(space->machine, "bank1", space->machine->region("soundcpu")->base() + 0x100000 + 0x2000 * state->sound_bank);
} }
static WRITE8_HANDLER( sound_bank_hi_w ) static WRITE8_HANDLER( sound_bank_hi_w )
{ {
sound_bank = (sound_bank & 0x3f) | ((data & 0x04) << 4) | ((data & 0x03) << 7); segas32_state *state = space->machine->driver_data<segas32_state>();
memory_set_bankptr(space->machine, "bank1", space->machine->region("soundcpu")->base() + 0x100000 + 0x2000 * sound_bank); state->sound_bank = (state->sound_bank & 0x3f) | ((data & 0x04) << 4) | ((data & 0x03) << 7);
memory_set_bankptr(space->machine, "bank1", space->machine->region("soundcpu")->base() + 0x100000 + 0x2000 * state->sound_bank);
} }
@ -1198,13 +1207,15 @@ static WRITE8_DEVICE_HANDLER( scross_bank_w )
static READ8_HANDLER( sound_dummy_r ) static READ8_HANDLER( sound_dummy_r )
{ {
return sound_dummy_value; segas32_state *state = space->machine->driver_data<segas32_state>();
return state->sound_dummy_value;
} }
static WRITE8_HANDLER( sound_dummy_w ) static WRITE8_HANDLER( sound_dummy_w )
{ {
sound_dummy_value = data; segas32_state *state = space->machine->driver_data<segas32_state>();
state->sound_dummy_value = data;
} }
@ -1218,11 +1229,11 @@ static WRITE8_HANDLER( sound_dummy_w )
static ADDRESS_MAP_START( system32_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( system32_map, ADDRESS_SPACE_PROGRAM, 16 )
ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(0x000000, 0x1fffff) AM_ROM AM_RANGE(0x000000, 0x1fffff) AM_ROM
AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x0f0000) AM_RAM AM_BASE(&system32_workram) AM_RANGE(0x200000, 0x20ffff) AM_MIRROR(0x0f0000) AM_RAM AM_BASE_MEMBER(segas32_state, system32_workram)
AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_videoram_r, system32_videoram_w) AM_BASE(&system32_videoram) AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_videoram_r, system32_videoram_w) AM_BASE_MEMBER(segas32_state, system32_videoram)
AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_spriteram_r, system32_spriteram_w) AM_BASE(&system32_spriteram) AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_spriteram_r, system32_spriteram_w) AM_BASE_MEMBER(segas32_state, system32_spriteram)
AM_RANGE(0x500000, 0x50000f) AM_MIRROR(0x0ffff0) AM_READWRITE(system32_sprite_control_r, system32_sprite_control_w) AM_RANGE(0x500000, 0x50000f) AM_MIRROR(0x0ffff0) AM_READWRITE(system32_sprite_control_r, system32_sprite_control_w)
AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_paletteram_r, system32_paletteram_w) AM_BASE(&system32_paletteram[0]) AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x0e0000) AM_READWRITE(system32_paletteram_r, system32_paletteram_w) AM_BASE_MEMBER(segas32_state, system32_paletteram[0])
AM_RANGE(0x610000, 0x61007f) AM_MIRROR(0x0eff80) AM_READWRITE(system32_mixer_r, system32_mixer_w) AM_RANGE(0x610000, 0x61007f) AM_MIRROR(0x0eff80) AM_READWRITE(system32_mixer_r, system32_mixer_w)
AM_RANGE(0x700000, 0x701fff) AM_MIRROR(0x0fe000) AM_READWRITE(shared_ram_16_r, shared_ram_16_w) AM_RANGE(0x700000, 0x701fff) AM_MIRROR(0x0fe000) AM_READWRITE(shared_ram_16_r, shared_ram_16_w)
AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x0fff80) AM_READWRITE(io_chip_r, io_chip_w) AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x0fff80) AM_READWRITE(io_chip_r, io_chip_w)
@ -1238,12 +1249,12 @@ static ADDRESS_MAP_START( multi32_map, ADDRESS_SPACE_PROGRAM, 32 )
ADDRESS_MAP_GLOBAL_MASK(0xffffff) ADDRESS_MAP_GLOBAL_MASK(0xffffff)
AM_RANGE(0x000000, 0x1fffff) AM_ROM AM_RANGE(0x000000, 0x1fffff) AM_ROM
AM_RANGE(0x200000, 0x21ffff) AM_MIRROR(0x0e0000) AM_RAM AM_RANGE(0x200000, 0x21ffff) AM_MIRROR(0x0e0000) AM_RAM
AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_videoram_r, multi32_videoram_w) AM_BASE((UINT32 **)&system32_videoram) AM_RANGE(0x300000, 0x31ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_videoram_r, multi32_videoram_w) AM_BASE_MEMBER(segas32_state, system32_videoram)
AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_spriteram_r, multi32_spriteram_w) AM_BASE((UINT32 **)&system32_spriteram) AM_RANGE(0x400000, 0x41ffff) AM_MIRROR(0x0e0000) AM_READWRITE(multi32_spriteram_r, multi32_spriteram_w) AM_BASE_MEMBER(segas32_state, system32_spriteram)
AM_RANGE(0x500000, 0x50000f) AM_MIRROR(0x0ffff0) AM_READWRITE(multi32_sprite_control_r, multi32_sprite_control_w) AM_RANGE(0x500000, 0x50000f) AM_MIRROR(0x0ffff0) AM_READWRITE(multi32_sprite_control_r, multi32_sprite_control_w)
AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_0_r, multi32_paletteram_0_w) AM_BASE((UINT32 **)&system32_paletteram[0]) AM_RANGE(0x600000, 0x60ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_0_r, multi32_paletteram_0_w) AM_BASE_MEMBER(segas32_state, system32_paletteram[0])
AM_RANGE(0x610000, 0x61007f) AM_MIRROR(0x06ff80) AM_WRITE(multi32_mixer_0_w) AM_RANGE(0x610000, 0x61007f) AM_MIRROR(0x06ff80) AM_WRITE(multi32_mixer_0_w)
AM_RANGE(0x680000, 0x68ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_1_r, multi32_paletteram_1_w) AM_BASE((UINT32 **)&system32_paletteram[1]) AM_RANGE(0x680000, 0x68ffff) AM_MIRROR(0x060000) AM_READWRITE(multi32_paletteram_1_r, multi32_paletteram_1_w) AM_BASE_MEMBER(segas32_state, system32_paletteram[1])
AM_RANGE(0x690000, 0x69007f) AM_MIRROR(0x06ff80) AM_WRITE(multi32_mixer_1_w) AM_RANGE(0x690000, 0x69007f) AM_MIRROR(0x06ff80) AM_WRITE(multi32_mixer_1_w)
AM_RANGE(0x700000, 0x701fff) AM_MIRROR(0x0fe000) AM_READWRITE(shared_ram_32_r, shared_ram_32_w) AM_RANGE(0x700000, 0x701fff) AM_MIRROR(0x0fe000) AM_READWRITE(shared_ram_32_r, shared_ram_32_w)
AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x07ff80) AM_READWRITE(io_chip_0_r, io_chip_0_w) AM_RANGE(0xc00000, 0xc0001f) AM_MIRROR(0x07ff80) AM_READWRITE(io_chip_0_r, io_chip_0_w)
@ -1268,7 +1279,7 @@ static ADDRESS_MAP_START( system32_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank1") AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x0ff0) AM_DEVWRITE("rfsnd", rf5c68_w) AM_RANGE(0xc000, 0xc00f) AM_MIRROR(0x0ff0) AM_DEVWRITE("rfsnd", rf5c68_w)
AM_RANGE(0xd000, 0xdfff) AM_DEVREADWRITE("rfsnd", rf5c68_mem_r, rf5c68_mem_w) AM_RANGE(0xd000, 0xdfff) AM_DEVREADWRITE("rfsnd", rf5c68_mem_r, rf5c68_mem_w)
AM_RANGE(0xe000, 0xffff) AM_RAM AM_BASE(&z80_shared_ram) AM_RANGE(0xe000, 0xffff) AM_RAM AM_BASE_MEMBER(segas32_state, z80_shared_ram)
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( system32_sound_portmap, ADDRESS_SPACE_IO, 8 ) static ADDRESS_MAP_START( system32_sound_portmap, ADDRESS_SPACE_IO, 8 )
@ -1288,7 +1299,7 @@ static ADDRESS_MAP_START( multi32_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x9fff) AM_ROM AM_REGION("soundcpu", 0x100000) AM_RANGE(0x0000, 0x9fff) AM_ROM AM_REGION("soundcpu", 0x100000)
AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank1") AM_RANGE(0xa000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xdfff) AM_DEVREADWRITE("sega", multipcm_r, multipcm_w) AM_RANGE(0xc000, 0xdfff) AM_DEVREADWRITE("sega", multipcm_r, multipcm_w)
AM_RANGE(0xe000, 0xffff) AM_RAM AM_BASE(&z80_shared_ram) AM_RANGE(0xe000, 0xffff) AM_RAM AM_BASE_MEMBER(segas32_state, z80_shared_ram)
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( multi32_sound_portmap, ADDRESS_SPACE_IO, 8 ) static ADDRESS_MAP_START( multi32_sound_portmap, ADDRESS_SPACE_IO, 8 )
@ -1312,7 +1323,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( ga2_v25_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( ga2_v25_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x00000, 0x0ffff) AM_ROM AM_REGION("mcu", 0) AM_RANGE(0x00000, 0x0ffff) AM_ROM AM_REGION("mcu", 0)
AM_RANGE(0x10000, 0x1ffff) AM_RAM AM_BASE(&ga2_dpram) AM_RANGE(0x10000, 0x1ffff) AM_RAM AM_BASE_MEMBER(segas32_state, ga2_dpram)
AM_RANGE(0xf0000, 0xfffff) AM_ROM AM_REGION("mcu", 0) AM_RANGE(0xf0000, 0xfffff) AM_ROM AM_REGION("mcu", 0)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -2153,16 +2164,17 @@ static const ym3438_interface ym3438_config =
// Both arescue and f1en appear to use an identical shared RAM system. // Both arescue and f1en appear to use an identical shared RAM system.
static UINT16* dual_pcb_comms;
static WRITE16_HANDLER( dual_pcb_comms_w ) static WRITE16_HANDLER( dual_pcb_comms_w )
{ {
COMBINE_DATA(&dual_pcb_comms[offset]); segas32_state *state = space->machine->driver_data<segas32_state>();
COMBINE_DATA(&state->dual_pcb_comms[offset]);
} }
static READ16_HANDLER( dual_pcb_comms_r ) static READ16_HANDLER( dual_pcb_comms_r )
{ {
return dual_pcb_comms[offset]; segas32_state *state = space->machine->driver_data<segas32_state>();
return state->dual_pcb_comms[offset];
} }
@ -2183,7 +2195,7 @@ static READ16_HANDLER( dual_pcb_masterslave )
* *
*************************************/ *************************************/
static MACHINE_CONFIG_START( system32, driver_device ) static MACHINE_CONFIG_START( system32, segas32_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", V60, MASTER_CLOCK/2) MCFG_CPU_ADD("maincpu", V60, MASTER_CLOCK/2)
@ -2243,7 +2255,7 @@ static MACHINE_CONFIG_DERIVED( system32_v25, system32 )
MACHINE_CONFIG_END MACHINE_CONFIG_END
static MACHINE_CONFIG_START( multi32, driver_device ) static MACHINE_CONFIG_START( multi32, segas32_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", V70, MULTI32_CLOCK/2) MCFG_CPU_ADD("maincpu", V70, MULTI32_CLOCK/2)
@ -3807,15 +3819,16 @@ ROM_END
* *
*************************************/ *************************************/
static void segas32_common_init(read16_space_func custom_r, write16_space_func custom_w) static void segas32_common_init(running_machine *machine, read16_space_func custom_r, write16_space_func custom_w)
{ {
segas32_state *state = machine->driver_data<segas32_state>();
/* reset the custom handlers and other pointers */ /* reset the custom handlers and other pointers */
custom_io_r[0] = custom_r; state->custom_io_r[0] = custom_r;
custom_io_w[0] = custom_w; state->custom_io_w[0] = custom_w;
system32_prot_vblank = NULL; system32_prot_vblank = NULL;
segas32_sw1_output = NULL; state->sw1_output = NULL;
segas32_sw2_output = NULL; state->sw2_output = NULL;
segas32_sw3_output = NULL; state->sw3_output = NULL;
} }
@ -4003,8 +4016,9 @@ static void scross_sw2_output( int which, UINT16 data )
static DRIVER_INIT( alien3 ) static DRIVER_INIT( alien3 )
{ {
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_state *state = machine->driver_data<segas32_state>();
segas32_sw1_output = alien3_sw1_output; segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
state->sw1_output = alien3_sw1_output;
} }
static READ16_HANDLER( arescue_handshake_r ) static READ16_HANDLER( arescue_handshake_r )
@ -4019,23 +4033,24 @@ static READ16_HANDLER( arescue_slavebusy_r )
static DRIVER_INIT( arescue ) static DRIVER_INIT( arescue )
{ {
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_state *state = machine->driver_data<segas32_state>();
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00007, 0, 0, arescue_dsp_r, arescue_dsp_w); memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00007, 0, 0, arescue_dsp_r, arescue_dsp_w);
dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2); state->dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810fff, 0, 0, dual_pcb_comms_r, dual_pcb_comms_w); memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810fff, 0, 0, dual_pcb_comms_r, dual_pcb_comms_w);
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x818000, 0x818003, 0, 0, dual_pcb_masterslave); memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x818000, 0x818003, 0, 0, dual_pcb_masterslave);
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810001, 0, 0, arescue_handshake_r); memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810001, 0, 0, arescue_handshake_r);
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x81000e, 0x81000f, 0, 0, arescue_slavebusy_r); memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x81000e, 0x81000f, 0, 0, arescue_slavebusy_r);
segas32_sw1_output = arescue_sw1_output; state->sw1_output = arescue_sw1_output;
} }
static DRIVER_INIT( arabfgt ) static DRIVER_INIT( arabfgt )
{ {
segas32_common_init(extra_custom_io_r, NULL); segas32_common_init(machine, extra_custom_io_r, NULL);
/* install protection handlers */ /* install protection handlers */
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00100, 0xa0011f, 0, 0, arf_wakeup_protection_r); memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00100, 0xa0011f, 0, 0, arf_wakeup_protection_r);
@ -4045,10 +4060,11 @@ static DRIVER_INIT( arabfgt )
static DRIVER_INIT( brival ) static DRIVER_INIT( brival )
{ {
segas32_common_init(extra_custom_io_r, NULL); segas32_state *state = machine->driver_data<segas32_state>();
segas32_common_init(machine, extra_custom_io_r, NULL);
/* install protection handlers */ /* install protection handlers */
system32_protram = auto_alloc_array(machine, UINT16, 0x1000/2); state->system32_protram = auto_alloc_array(machine, UINT16, 0x1000/2);
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20ba00, 0x20ba07, 0, 0, brival_protection_r); memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20ba00, 0x20ba07, 0, 0, brival_protection_r);
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, brival_protection_w); memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, brival_protection_w);
} }
@ -4056,7 +4072,7 @@ static DRIVER_INIT( brival )
static DRIVER_INIT( darkedge ) static DRIVER_INIT( darkedge )
{ {
segas32_common_init(extra_custom_io_r, NULL); segas32_common_init(machine, extra_custom_io_r, NULL);
/* install protection handlers */ /* install protection handlers */
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa7ffff, 0, 0, darkedge_protection_r, darkedge_protection_w); memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa7ffff, 0, 0, darkedge_protection_r, darkedge_protection_w);
@ -4065,7 +4081,7 @@ static DRIVER_INIT( darkedge )
static DRIVER_INIT( dbzvrvs ) static DRIVER_INIT( dbzvrvs )
{ {
segas32_common_init(NULL, NULL); segas32_common_init(machine, NULL, NULL);
/* install protection handlers */ /* install protection handlers */
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa7ffff, 0, 0, dbzvrvs_protection_r, dbzvrvs_protection_w); memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa7ffff, 0, 0, dbzvrvs_protection_r, dbzvrvs_protection_w);
@ -4080,28 +4096,30 @@ static WRITE16_HANDLER( f1en_comms_echo_w )
static DRIVER_INIT( f1en ) static DRIVER_INIT( f1en )
{ {
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_state *state = machine->driver_data<segas32_state>();
segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2); state->dual_pcb_comms = auto_alloc_array(machine, UINT16, 0x1000/2);
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810fff, 0, 0, dual_pcb_comms_r, dual_pcb_comms_w); memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810000, 0x810fff, 0, 0, dual_pcb_comms_r, dual_pcb_comms_w);
memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x818000, 0x818003, 0, 0, dual_pcb_masterslave); memory_install_read16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x818000, 0x818003, 0, 0, dual_pcb_masterslave);
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810048, 0x810049, 0, 0, f1en_comms_echo_w); memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x810048, 0x810049, 0, 0, f1en_comms_echo_w);
segas32_sw1_output = radm_sw1_output; state->sw1_output = radm_sw1_output;
} }
static DRIVER_INIT( f1lap ) static DRIVER_INIT( f1lap )
{ {
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_state *state = machine->driver_data<segas32_state>();
segas32_sw1_output = f1lap_sw1_output; segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
state->sw1_output = f1lap_sw1_output;
} }
static DRIVER_INIT( ga2 ) static DRIVER_INIT( ga2 )
{ {
segas32_common_init(extra_custom_io_r, NULL); segas32_common_init(machine, extra_custom_io_r, NULL);
decrypt_ga2_protrom(machine); decrypt_ga2_protrom(machine);
memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, ga2_dpram_r, ga2_dpram_w); memory_install_readwrite16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa00000, 0xa00fff, 0, 0, ga2_dpram_r, ga2_dpram_w);
@ -4110,77 +4128,83 @@ static DRIVER_INIT( ga2 )
static DRIVER_INIT( harddunk ) static DRIVER_INIT( harddunk )
{ {
segas32_common_init(extra_custom_io_r, NULL); segas32_state *state = machine->driver_data<segas32_state>();
segas32_sw1_output = harddunk_sw1_output; segas32_common_init(machine, extra_custom_io_r, NULL);
segas32_sw2_output = harddunk_sw2_output; state->sw1_output = harddunk_sw1_output;
segas32_sw3_output = harddunk_sw3_output; state->sw2_output = harddunk_sw2_output;
state->sw3_output = harddunk_sw3_output;
} }
static DRIVER_INIT( holo ) static DRIVER_INIT( holo )
{ {
segas32_common_init(NULL, NULL); segas32_common_init(machine, NULL, NULL);
} }
static DRIVER_INIT( jpark ) static DRIVER_INIT( jpark )
{ {
segas32_state *state = machine->driver_data<segas32_state>();
/* Temp. Patch until we emulate the 'Drive Board', thanks to Malice */ /* Temp. Patch until we emulate the 'Drive Board', thanks to Malice */
UINT16 *pROM = (UINT16 *)machine->region("maincpu")->base(); UINT16 *pROM = (UINT16 *)machine->region("maincpu")->base();
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
pROM[0xC15A8/2] = 0xCD70; pROM[0xC15A8/2] = 0xCD70;
pROM[0xC15AA/2] = 0xD8CD; pROM[0xC15AA/2] = 0xD8CD;
segas32_sw1_output = jpark_sw1_output; state->sw1_output = jpark_sw1_output;
} }
static DRIVER_INIT( orunners ) static DRIVER_INIT( orunners )
{ {
segas32_common_init(analog_custom_io_r, orunners_custom_io_w); segas32_state *state = machine->driver_data<segas32_state>();
segas32_sw1_output = orunners_sw1_output; segas32_common_init(machine, analog_custom_io_r, orunners_custom_io_w);
segas32_sw2_output = orunners_sw2_output; state->sw1_output = orunners_sw1_output;
state->sw2_output = orunners_sw2_output;
} }
static DRIVER_INIT( radm ) static DRIVER_INIT( radm )
{ {
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_state *state = machine->driver_data<segas32_state>();
segas32_sw1_output = radm_sw1_output; segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
segas32_sw2_output = radm_sw2_output; state->sw1_output = radm_sw1_output;
state->sw2_output = radm_sw2_output;
} }
static DRIVER_INIT( radr ) static DRIVER_INIT( radr )
{ {
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_state *state = machine->driver_data<segas32_state>();
segas32_sw1_output = radm_sw1_output; segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
segas32_sw2_output = radr_sw2_output; state->sw1_output = radm_sw1_output;
state->sw2_output = radr_sw2_output;
} }
static DRIVER_INIT( scross ) static DRIVER_INIT( scross )
{ {
segas32_state *state = machine->driver_data<segas32_state>();
multipcm_device *multipcm = machine->device<multipcm_device>("sega"); multipcm_device *multipcm = machine->device<multipcm_device>("sega");
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
memory_install_write8_device_handler(cputag_get_address_space(machine, "soundcpu", ADDRESS_SPACE_PROGRAM), multipcm, 0xb0, 0xbf, 0, 0, scross_bank_w); memory_install_write8_device_handler(cputag_get_address_space(machine, "soundcpu", ADDRESS_SPACE_PROGRAM), multipcm, 0xb0, 0xbf, 0, 0, scross_bank_w);
segas32_sw1_output = scross_sw1_output; state->sw1_output = scross_sw1_output;
segas32_sw2_output = scross_sw2_output; state->sw2_output = scross_sw2_output;
} }
static DRIVER_INIT( slipstrm ) static DRIVER_INIT( slipstrm )
{ {
segas32_common_init(analog_custom_io_r, analog_custom_io_w); segas32_common_init(machine, analog_custom_io_r, analog_custom_io_w);
} }
static DRIVER_INIT( sonic ) static DRIVER_INIT( sonic )
{ {
segas32_common_init(sonic_custom_io_r, sonic_custom_io_w); segas32_common_init(machine, sonic_custom_io_r, sonic_custom_io_w);
/* install protection handlers */ /* install protection handlers */
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20E5C4, 0x20E5C5, 0, 0, sonic_level_load_protection); memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20E5C4, 0x20E5C5, 0, 0, sonic_level_load_protection);
@ -4189,34 +4213,35 @@ static DRIVER_INIT( sonic )
static DRIVER_INIT( sonicp ) static DRIVER_INIT( sonicp )
{ {
segas32_common_init(sonic_custom_io_r, sonic_custom_io_w); segas32_common_init(machine, sonic_custom_io_r, sonic_custom_io_w);
} }
static DRIVER_INIT( spidman ) static DRIVER_INIT( spidman )
{ {
segas32_common_init(extra_custom_io_r, NULL); segas32_common_init(machine, extra_custom_io_r, NULL);
} }
static DRIVER_INIT( svf ) static DRIVER_INIT( svf )
{ {
segas32_common_init(NULL, NULL); segas32_common_init(machine, NULL, NULL);
} }
static DRIVER_INIT( jleague ) static DRIVER_INIT( jleague )
{ {
segas32_common_init(NULL, NULL); segas32_common_init(machine, NULL, NULL);
memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20F700, 0x20F705, 0, 0, jleague_protection_w); memory_install_write16_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x20F700, 0x20F705, 0, 0, jleague_protection_w);
} }
static DRIVER_INIT( titlef ) static DRIVER_INIT( titlef )
{ {
segas32_common_init(NULL, NULL); segas32_state *state = machine->driver_data<segas32_state>();
segas32_sw1_output = titlef_sw1_output; segas32_common_init(machine, NULL, NULL);
segas32_sw2_output = titlef_sw2_output; state->sw1_output = titlef_sw1_output;
state->sw2_output = titlef_sw2_output;
} }

View File

@ -37,9 +37,9 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xe001, 0xe001) AM_READ_PORT("DSW2") AM_RANGE(0xe001, 0xe001) AM_READ_PORT("DSW2")
AM_RANGE(0xe800, 0xe800) AM_WRITE(suprloco_soundport_w) AM_RANGE(0xe800, 0xe800) AM_WRITE(suprloco_soundport_w)
AM_RANGE(0xe801, 0xe801) AM_READWRITE(suprloco_control_r, suprloco_control_w) AM_RANGE(0xe801, 0xe801) AM_READWRITE(suprloco_control_r, suprloco_control_w)
AM_RANGE(0xf000, 0xf6ff) AM_RAM_WRITE(suprloco_videoram_w) AM_BASE(&suprloco_videoram) AM_RANGE(0xf000, 0xf6ff) AM_RAM_WRITE(suprloco_videoram_w) AM_BASE_MEMBER(suprloco_state, videoram)
AM_RANGE(0xf700, 0xf7df) AM_RAM /* unused */ AM_RANGE(0xf700, 0xf7df) AM_RAM /* unused */
AM_RANGE(0xf7e0, 0xf7ff) AM_RAM_WRITE(suprloco_scrollram_w) AM_BASE(&suprloco_scrollram) AM_RANGE(0xf7e0, 0xf7ff) AM_RAM_WRITE(suprloco_scrollram_w) AM_BASE_MEMBER(suprloco_state, scrollram)
AM_RANGE(0xf800, 0xffff) AM_RAM AM_RANGE(0xf800, 0xffff) AM_RAM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -152,7 +152,7 @@ GFXDECODE_END
static MACHINE_CONFIG_START( suprloco, driver_device ) static MACHINE_CONFIG_START( suprloco, suprloco_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz (?) */ MCFG_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz (?) */

View File

@ -203,20 +203,6 @@ Notes:
#define SOUND_CLOCK XTAL_8MHz #define SOUND_CLOCK XTAL_8MHz
/* driver config */
static void (*videomode_custom)(running_machine *machine, UINT8 data, UINT8 prevdata);
static UINT8 mute_xor;
static UINT8 *system1_ram;
static UINT8 dakkochn_mux_data;
static UINT8 videomode_prev;
static UINT8 mcu_control;
static UINT8 *nob_mcu_status;
static UINT8 *nob_mcu_latch;
static UINT8 nob_maincpu_latch;
/************************************* /*************************************
* *
* Machine initialization * Machine initialization
@ -355,6 +341,7 @@ static const UINT8 cc_ex[0x100] = {
static MACHINE_START( system1 ) static MACHINE_START( system1 )
{ {
system1_state *state = machine->driver_data<system1_state>();
UINT32 numbanks = (machine->region("maincpu")->bytes() - 0x10000) / 0x4000; UINT32 numbanks = (machine->region("maincpu")->bytes() - 0x10000) / 0x4000;
if (numbanks > 0) if (numbanks > 0)
@ -365,25 +352,27 @@ static MACHINE_START( system1 )
z80_set_cycle_tables(machine->device("maincpu"), cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex); z80_set_cycle_tables(machine->device("maincpu"), cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex);
mute_xor = 0x00; state->mute_xor = 0x00;
state_save_register_global(machine, dakkochn_mux_data); state_save_register_global(machine, state->dakkochn_mux_data);
state_save_register_global(machine, videomode_prev); state_save_register_global(machine, state->videomode_prev);
state_save_register_global(machine, mcu_control); state_save_register_global(machine, state->mcu_control);
state_save_register_global(machine, nob_maincpu_latch); state_save_register_global(machine, state->nob_maincpu_latch);
} }
static MACHINE_START( system2 ) static MACHINE_START( system2 )
{ {
system1_state *state = machine->driver_data<system1_state>();
MACHINE_START_CALL(system1); MACHINE_START_CALL(system1);
mute_xor = 0x01; state->mute_xor = 0x01;
} }
static MACHINE_RESET( system1 ) static MACHINE_RESET( system1 )
{ {
dakkochn_mux_data = 0; system1_state *state = machine->driver_data<system1_state>();
state->dakkochn_mux_data = 0;
} }
@ -410,6 +399,7 @@ static void bank0c_custom_w(running_machine *machine, UINT8 data, UINT8 prevdata
static WRITE8_HANDLER( videomode_w ) static WRITE8_HANDLER( videomode_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
device_t *i8751 = space->machine->device("mcu"); device_t *i8751 = space->machine->device("mcu");
/* bit 6 is connected to the 8751 IRQ */ /* bit 6 is connected to the 8751 IRQ */
@ -417,9 +407,9 @@ static WRITE8_HANDLER( videomode_w )
cpu_set_input_line(i8751, MCS51_INT1_LINE, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE); cpu_set_input_line(i8751, MCS51_INT1_LINE, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE);
/* handle any custom banking or other stuff */ /* handle any custom banking or other stuff */
if (videomode_custom != NULL) if (state->videomode_custom != NULL)
(*videomode_custom)(space->machine, data, videomode_prev); (*state->videomode_custom)(space->machine, data, state->videomode_prev);
videomode_prev = data; state->videomode_prev = data;
/* bit 0 is for the coin counters */ /* bit 0 is for the coin counters */
coin_counter_w(space->machine, 0, data & 1); coin_counter_w(space->machine, 0, data & 1);
@ -438,23 +428,26 @@ static WRITE8_HANDLER( videomode_w )
static CUSTOM_INPUT( dakkochn_mux_data_r ) static CUSTOM_INPUT( dakkochn_mux_data_r )
{ {
system1_state *state = field->port->machine->driver_data<system1_state>();
static const char *const ports[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6" }; static const char *const ports[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6" };
return input_port_read(field->port->machine, ports[dakkochn_mux_data]); return input_port_read(field->port->machine, ports[state->dakkochn_mux_data]);
} }
static CUSTOM_INPUT( dakkochn_mux_status_r ) static CUSTOM_INPUT( dakkochn_mux_status_r )
{ {
system1_state *state = field->port->machine->driver_data<system1_state>();
/* reads from here indicate which mux port is selected */ /* reads from here indicate which mux port is selected */
return 1 << (dakkochn_mux_data); return 1 << (state->dakkochn_mux_data);
} }
static void dakkochn_custom_w(running_machine *machine, UINT8 data, UINT8 prevdata) static void dakkochn_custom_w(running_machine *machine, UINT8 data, UINT8 prevdata)
{ {
system1_state *state = machine->driver_data<system1_state>();
/* bit 1 toggling on clocks the mux; we store the previous state in the high bit of dakkochn_mux_data */ /* bit 1 toggling on clocks the mux; we store the previous state in the high bit of dakkochn_mux_data */
if ((data & 0x02) && !(prevdata & 0x02)) if ((data & 0x02) && !(prevdata & 0x02))
dakkochn_mux_data = (dakkochn_mux_data + 1) % 7; state->dakkochn_mux_data = (state->dakkochn_mux_data + 1) % 7;
/* remaining stuff acts like bank0c */ /* remaining stuff acts like bank0c */
bank0c_custom_w(machine, data, prevdata); bank0c_custom_w(machine, data, prevdata);
@ -470,8 +463,9 @@ static void dakkochn_custom_w(running_machine *machine, UINT8 data, UINT8 prevda
static WRITE8_DEVICE_HANDLER( sound_control_w ) static WRITE8_DEVICE_HANDLER( sound_control_w )
{ {
system1_state *state = device->machine->driver_data<system1_state>();
/* bit 0 = MUTE (inverted sense on System 2) */ /* bit 0 = MUTE (inverted sense on System 2) */
device->machine->sound().system_mute((data ^ mute_xor) & 1); device->machine->sound().system_mute((data ^ state->mute_xor) & 1);
/* bit 6 = feedback from sound board that read occurrred */ /* bit 6 = feedback from sound board that read occurrred */
@ -534,6 +528,7 @@ static TIMER_DEVICE_CALLBACK( soundirq_gen )
static WRITE8_HANDLER( mcu_control_w ) static WRITE8_HANDLER( mcu_control_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
/* /*
Bit 7 -> connects to TD62003 pins 5 & 6 @ IC151 Bit 7 -> connects to TD62003 pins 5 & 6 @ IC151
Bit 6 -> via PLS153, when high, asserts the BUSREQ signal, halting the Z80 Bit 6 -> via PLS153, when high, asserts the BUSREQ signal, halting the Z80
@ -544,7 +539,7 @@ static WRITE8_HANDLER( mcu_control_w )
Bit 1 -> n/c Bit 1 -> n/c
Bit 0 -> Directly connected to Z80 /INT line Bit 0 -> Directly connected to Z80 /INT line
*/ */
mcu_control = data; state->mcu_control = data;
cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_HALT, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE); cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_HALT, (data & 0x40) ? ASSERT_LINE : CLEAR_LINE);
cputag_set_input_line(space->machine, "maincpu", 0, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE); cputag_set_input_line(space->machine, "maincpu", 0, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE);
} }
@ -552,7 +547,8 @@ static WRITE8_HANDLER( mcu_control_w )
static WRITE8_HANDLER( mcu_io_w ) static WRITE8_HANDLER( mcu_io_w )
{ {
switch ((mcu_control >> 3) & 3) system1_state *state = space->machine->driver_data<system1_state>();
switch ((state->mcu_control >> 3) & 3)
{ {
case 0: case 0:
space->machine->device<z80_device>("maincpu")->space(AS_PROGRAM)->write_byte(offset, data); space->machine->device<z80_device>("maincpu")->space(AS_PROGRAM)->write_byte(offset, data);
@ -564,7 +560,7 @@ static WRITE8_HANDLER( mcu_io_w )
default: default:
logerror("%03X: MCU movx write mode %02X offset %04X = %02X\n", logerror("%03X: MCU movx write mode %02X offset %04X = %02X\n",
cpu_get_pc(space->cpu), mcu_control, offset, data); cpu_get_pc(space->cpu), state->mcu_control, offset, data);
break; break;
} }
} }
@ -572,7 +568,8 @@ static WRITE8_HANDLER( mcu_io_w )
static READ8_HANDLER( mcu_io_r ) static READ8_HANDLER( mcu_io_r )
{ {
switch ((mcu_control >> 3) & 3) system1_state *state = space->machine->driver_data<system1_state>();
switch ((state->mcu_control >> 3) & 3)
{ {
case 0: case 0:
return space->machine->device<z80_device>("maincpu")->space(AS_PROGRAM)->read_byte(offset); return space->machine->device<z80_device>("maincpu")->space(AS_PROGRAM)->read_byte(offset);
@ -585,7 +582,7 @@ static READ8_HANDLER( mcu_io_r )
default: default:
logerror("%03X: MCU movx read mode %02X offset %04X\n", logerror("%03X: MCU movx read mode %02X offset %04X\n",
cpu_get_pc(space->cpu), mcu_control, offset); cpu_get_pc(space->cpu), state->mcu_control, offset);
return 0xff; return 0xff;
} }
} }
@ -623,37 +620,40 @@ static TIMER_DEVICE_CALLBACK( mcu_t0_callback )
static WRITE8_HANDLER( nob_mcu_control_p2_w ) static WRITE8_HANDLER( nob_mcu_control_p2_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
/* bit 0 triggers a read from MCU port 0 */ /* bit 0 triggers a read from MCU port 0 */
if (((mcu_control ^ data) & 0x01) && !(data & 0x01)) if (((state->mcu_control ^ data) & 0x01) && !(data & 0x01))
*nob_mcu_latch = nob_maincpu_latch; *state->nob_mcu_latch = state->nob_maincpu_latch;
/* bit 1 triggers a write from MCU port 0 */ /* bit 1 triggers a write from MCU port 0 */
if (((mcu_control ^ data) & 0x02) && !(data & 0x02)) if (((state->mcu_control ^ data) & 0x02) && !(data & 0x02))
nob_maincpu_latch = *nob_mcu_latch; state->nob_maincpu_latch = *state->nob_mcu_latch;
/* bit 2 is toggled once near the end of an IRQ */ /* bit 2 is toggled once near the end of an IRQ */
if (((mcu_control ^ data) & 0x04) && !(data & 0x04)) if (((state->mcu_control ^ data) & 0x04) && !(data & 0x04))
cpu_set_input_line(space->cpu, MCS51_INT0_LINE, CLEAR_LINE); cpu_set_input_line(space->cpu, MCS51_INT0_LINE, CLEAR_LINE);
/* bit 3 is toggled once at the start of an IRQ, and again at the end */ /* bit 3 is toggled once at the start of an IRQ, and again at the end */
if (((mcu_control ^ data) & 0x08) && !(data & 0x08)) if (((state->mcu_control ^ data) & 0x08) && !(data & 0x08))
{ {
//logerror("MCU IRQ(8) toggle\n"); //logerror("MCU IRQ(8) toggle\n");
} }
mcu_control = data; state->mcu_control = data;
} }
static READ8_HANDLER( nob_maincpu_latch_r ) static READ8_HANDLER( nob_maincpu_latch_r )
{ {
return nob_maincpu_latch; system1_state *state = space->machine->driver_data<system1_state>();
return state->nob_maincpu_latch;
} }
static WRITE8_HANDLER( nob_maincpu_latch_w ) static WRITE8_HANDLER( nob_maincpu_latch_w )
{ {
nob_maincpu_latch = data; system1_state *state = space->machine->driver_data<system1_state>();
state->nob_maincpu_latch = data;
cputag_set_input_line(space->machine, "mcu", MCS51_INT0_LINE, ASSERT_LINE); cputag_set_input_line(space->machine, "mcu", MCS51_INT0_LINE, ASSERT_LINE);
space->machine->scheduler().boost_interleave(attotime::zero, attotime::from_usec(100)); space->machine->scheduler().boost_interleave(attotime::zero, attotime::from_usec(100));
} }
@ -661,7 +661,8 @@ static WRITE8_HANDLER( nob_maincpu_latch_w )
static READ8_HANDLER( nob_mcu_status_r ) static READ8_HANDLER( nob_mcu_status_r )
{ {
return *nob_mcu_status; system1_state *state = space->machine->driver_data<system1_state>();
return *state->nob_mcu_status;
} }
@ -673,7 +674,6 @@ static READ8_HANDLER( nob_mcu_status_r )
*************************************/ *************************************/
// nobb - these ports are used for some kind of replacement protection system used by the bootleg // nobb - these ports are used for some kind of replacement protection system used by the bootleg
static int nobb_inport23_step;
static READ8_HANDLER( nobb_inport1c_r ) static READ8_HANDLER( nobb_inport1c_r )
{ {
@ -689,14 +689,16 @@ static READ8_HANDLER( nobb_inport22_r )
static READ8_HANDLER( nobb_inport23_r ) static READ8_HANDLER( nobb_inport23_r )
{ {
// logerror("IN $23 : pc = %04x - step = %02x\n",cpu_get_pc(space->cpu),nobb_inport23_step); system1_state *state = space->machine->driver_data<system1_state>();
return(nobb_inport23_step); // logerror("IN $23 : pc = %04x - step = %02x\n",cpu_get_pc(space->cpu),state->nobb_inport23_step);
return(state->nobb_inport23_step);
} }
static WRITE8_HANDLER( nobb_outport24_w ) static WRITE8_HANDLER( nobb_outport24_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
// logerror("OUT $24 : pc = %04x - data = %02x\n",cpu_get_pc(space->cpu),data); // logerror("OUT $24 : pc = %04x - data = %02x\n",cpu_get_pc(space->cpu),data);
nobb_inport23_step = data; state->nobb_inport23_step = data;
} }
@ -711,7 +713,7 @@ static WRITE8_HANDLER( nobb_outport24_w )
static ADDRESS_MAP_START( system1_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( system1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1") AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
AM_RANGE(0xc000, 0xcfff) AM_RAM AM_BASE(&system1_ram) AM_RANGE(0xc000, 0xcfff) AM_RAM AM_BASE_MEMBER(system1_state, ram)
AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE_GENERIC(spriteram) AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(system1_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(system1_paletteram_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xe000, 0xefff) AM_READWRITE(system1_videoram_r, system1_videoram_w) AM_RANGE(0xe000, 0xefff) AM_READWRITE(system1_videoram_r, system1_videoram_w)
@ -732,7 +734,7 @@ static ADDRESS_MAP_START( nobo_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE_GENERIC(spriteram) AM_RANGE(0xd000, 0xd7ff) AM_RAM AM_BASE_GENERIC(spriteram)
AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(system1_paletteram_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(system1_paletteram_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xe000, 0xefff) AM_READWRITE(system1_videoram_r, system1_videoram_w) AM_RANGE(0xe000, 0xefff) AM_READWRITE(system1_videoram_r, system1_videoram_w)
AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE(&system1_ram) AM_RANGE(0xf000, 0xffff) AM_RAM AM_BASE_MEMBER(system1_state, ram)
ADDRESS_MAP_END ADDRESS_MAP_END
/* I/O map for systems with an 8255 PPI */ /* I/O map for systems with an 8255 PPI */
@ -792,8 +794,8 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( nob_mcu_io_map, ADDRESS_SPACE_IO, 8 ) static ADDRESS_MAP_START( nob_mcu_io_map, ADDRESS_SPACE_IO, 8 )
ADDRESS_MAP_UNMAP_HIGH ADDRESS_MAP_UNMAP_HIGH
AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P0) AM_RAM AM_BASE(&nob_mcu_latch) AM_RANGE(MCS51_PORT_P0, MCS51_PORT_P0) AM_RAM AM_BASE_MEMBER(system1_state, nob_mcu_latch)
AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_WRITEONLY AM_BASE(&nob_mcu_status) AM_RANGE(MCS51_PORT_P1, MCS51_PORT_P1) AM_WRITEONLY AM_BASE_MEMBER(system1_state, nob_mcu_status)
AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_WRITE(nob_mcu_control_p2_w) AM_RANGE(MCS51_PORT_P2, MCS51_PORT_P2) AM_WRITE(nob_mcu_control_p2_w)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -4490,9 +4492,22 @@ ROM_END
* *
*************************************/ *************************************/
static DRIVER_INIT( bank00 ) { videomode_custom = NULL; } static DRIVER_INIT( bank00 )
static DRIVER_INIT( bank44 ) { videomode_custom = bank44_custom_w; } {
static DRIVER_INIT( bank0c ) { videomode_custom = bank0c_custom_w; } system1_state *state = machine->driver_data<system1_state>();
state->videomode_custom = NULL;
}
static DRIVER_INIT( bank44 )
{
system1_state *state = machine->driver_data<system1_state>();
state->videomode_custom = bank44_custom_w;
}
static DRIVER_INIT( bank0c )
{
system1_state *state = machine->driver_data<system1_state>();
state->videomode_custom = bank0c_custom_w;
}
static DRIVER_INIT( regulus ) { DRIVER_INIT_CALL(bank00); regulus_decode(machine, "maincpu"); } static DRIVER_INIT( regulus ) { DRIVER_INIT_CALL(bank00); regulus_decode(machine, "maincpu"); }
static DRIVER_INIT( mrviking ) { DRIVER_INIT_CALL(bank00); mrviking_decode(machine, "maincpu"); } static DRIVER_INIT( mrviking ) { DRIVER_INIT_CALL(bank00); mrviking_decode(machine, "maincpu"); }
@ -4524,8 +4539,8 @@ static DRIVER_INIT( wboysys2 ) { DRIVER_INIT_CALL(bank0c); sega_315_5177_decode(
static DRIVER_INIT( dakkochn ) static DRIVER_INIT( dakkochn )
{ {
DRIVER_INIT_CALL(bank0c); system1_state *state = machine->driver_data<system1_state>();
videomode_custom = dakkochn_custom_w; state->videomode_custom = dakkochn_custom_w;
mc8123_decrypt_rom(machine, "maincpu", "key", "bank1", 4); mc8123_decrypt_rom(machine, "maincpu", "key", "bank1", 4);

View File

@ -26,7 +26,18 @@ CPU is an Intel 80188
#include "emu.h" #include "emu.h"
#include "cpu/i86/i86.h" #include "cpu/i86/i86.h"
static UINT8 *led_vram_lo,*led_vram_hi;
class timetrv_state : public driver_device
{
public:
timetrv_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *led_vram_lo;
UINT8 *led_vram_hi;
};
static VIDEO_START( timetrv ) static VIDEO_START( timetrv )
{ {
@ -35,7 +46,8 @@ static VIDEO_START( timetrv )
static VIDEO_UPDATE( timetrv ) static VIDEO_UPDATE( timetrv )
{ {
popmessage("%s%s",led_vram_lo,led_vram_hi); timetrv_state *state = screen->machine->driver_data<timetrv_state>();
popmessage("%s%s",state->led_vram_lo,state->led_vram_hi);
return 0; return 0;
} }
@ -75,8 +87,8 @@ static ADDRESS_MAP_START( timetrv_io, ADDRESS_SPACE_IO, 8 )
AM_RANGE(0x1080, 0x1082) AM_READ(in_r) //dsw AM_RANGE(0x1080, 0x1082) AM_READ(in_r) //dsw
AM_RANGE(0x1100, 0x1105) AM_WRITENOP //laserdisc write area AM_RANGE(0x1100, 0x1105) AM_WRITENOP //laserdisc write area
AM_RANGE(0x1100, 0x1105) AM_READ(ld_r) //5 -> laserdisc read status AM_RANGE(0x1100, 0x1105) AM_READ(ld_r) //5 -> laserdisc read status
AM_RANGE(0x1180, 0x1187) AM_RAM AM_BASE(&led_vram_lo)//led string,part 1 AM_RANGE(0x1180, 0x1187) AM_RAM AM_BASE_MEMBER(timetrv_state, led_vram_lo)//led string,part 1
AM_RANGE(0x1200, 0x1207) AM_RAM AM_BASE(&led_vram_hi)//led string,part 2 AM_RANGE(0x1200, 0x1207) AM_RAM AM_BASE_MEMBER(timetrv_state, led_vram_hi)//led string,part 2
AM_RANGE(0xff80, 0xffff) AM_RAM //am80188-em-like cpu internal regs? AM_RANGE(0xff80, 0xffff) AM_RAM //am80188-em-like cpu internal regs?
ADDRESS_MAP_END ADDRESS_MAP_END
@ -125,7 +137,7 @@ static INTERRUPT_GEN( ld_irq )
cpu_set_input_line_and_vector(device,0,HOLD_LINE,0x48/4); //ld irq cpu_set_input_line_and_vector(device,0,HOLD_LINE,0x48/4); //ld irq
} }
static MACHINE_CONFIG_START( timetrv, driver_device ) static MACHINE_CONFIG_START( timetrv, timetrv_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu",I80188,20000000) //??? MCFG_CPU_ADD("maincpu",I80188,20000000) //???

View File

@ -72,22 +72,23 @@ C004 76489 #4 trigger
#include "includes/konamipt.h" #include "includes/konamipt.h"
#include "includes/tp84.h" #include "includes/tp84.h"
static cpu_device *audiocpu;
static MACHINE_START( tp84 ) static MACHINE_START( tp84 )
{ {
audiocpu = machine->device<cpu_device>("audiocpu"); tp84_state *state = machine->driver_data<tp84_state>();
state->audiocpu = machine->device<cpu_device>("audiocpu");
} }
static READ8_HANDLER( tp84_sh_timer_r ) static READ8_HANDLER( tp84_sh_timer_r )
{ {
tp84_state *state = space->machine->driver_data<tp84_state>();
/* main xtal 14.318MHz, divided by 4 to get the CPU clock, further */ /* main xtal 14.318MHz, divided by 4 to get the CPU clock, further */
/* divided by 2048 to get this timer */ /* divided by 2048 to get this timer */
/* (divide by (2048/2), and not 1024, because the CPU cycle counter is */ /* (divide by (2048/2), and not 1024, because the CPU cycle counter is */
/* incremented every other state change of the clock) */ /* incremented every other state change of the clock) */
return (audiocpu->total_cycles() / (2048/2)) & 0x0f; return (state->audiocpu->total_cycles() / (2048/2)) & 0x0f;
} }
@ -127,43 +128,43 @@ static WRITE8_HANDLER( tp84_sh_irqtrigger_w )
static ADDRESS_MAP_START( tp84_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( tp84_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x2000, 0x2000) AM_WRITE(watchdog_reset_w) AM_RANGE(0x2000, 0x2000) AM_WRITE(watchdog_reset_w)
AM_RANGE(0x2800, 0x2800) AM_READ_PORT("SYSTEM") AM_WRITEONLY AM_BASE(&tp84_palette_bank) AM_RANGE(0x2800, 0x2800) AM_READ_PORT("SYSTEM") AM_WRITEONLY AM_BASE_MEMBER(tp84_state, palette_bank)
AM_RANGE(0x2820, 0x2820) AM_READ_PORT("P1") AM_RANGE(0x2820, 0x2820) AM_READ_PORT("P1")
AM_RANGE(0x2840, 0x2840) AM_READ_PORT("P2") AM_RANGE(0x2840, 0x2840) AM_READ_PORT("P2")
AM_RANGE(0x2860, 0x2860) AM_READ_PORT("DSW1") AM_RANGE(0x2860, 0x2860) AM_READ_PORT("DSW1")
AM_RANGE(0x3000, 0x3000) AM_READ_PORT("DSW2") AM_WRITEONLY AM_RANGE(0x3000, 0x3000) AM_READ_PORT("DSW2") AM_WRITEONLY
AM_RANGE(0x3004, 0x3004) AM_WRITEONLY AM_BASE(&tp84_flipscreen_x) AM_RANGE(0x3004, 0x3004) AM_WRITEONLY AM_BASE_MEMBER(tp84_state, flipscreen_x)
AM_RANGE(0x3005, 0x3005) AM_WRITEONLY AM_BASE(&tp84_flipscreen_y) AM_RANGE(0x3005, 0x3005) AM_WRITEONLY AM_BASE_MEMBER(tp84_state, flipscreen_y)
AM_RANGE(0x3800, 0x3800) AM_WRITE(tp84_sh_irqtrigger_w) AM_RANGE(0x3800, 0x3800) AM_WRITE(tp84_sh_irqtrigger_w)
AM_RANGE(0x3a00, 0x3a00) AM_WRITE(soundlatch_w) AM_RANGE(0x3a00, 0x3a00) AM_WRITE(soundlatch_w)
AM_RANGE(0x3c00, 0x3c00) AM_WRITEONLY AM_BASE(&tp84_scroll_x) AM_RANGE(0x3c00, 0x3c00) AM_WRITEONLY AM_BASE_MEMBER(tp84_state, scroll_x)
AM_RANGE(0x3e00, 0x3e00) AM_WRITEONLY AM_BASE(&tp84_scroll_y) AM_RANGE(0x3e00, 0x3e00) AM_WRITEONLY AM_BASE_MEMBER(tp84_state, scroll_y)
AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE(&tp84_bg_videoram) AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE_MEMBER(tp84_state, bg_videoram)
AM_RANGE(0x4400, 0x47ff) AM_RAM AM_BASE(&tp84_fg_videoram) AM_RANGE(0x4400, 0x47ff) AM_RAM AM_BASE_MEMBER(tp84_state, fg_videoram)
AM_RANGE(0x4800, 0x4bff) AM_RAM AM_BASE(&tp84_bg_colorram) AM_RANGE(0x4800, 0x4bff) AM_RAM AM_BASE_MEMBER(tp84_state, bg_colorram)
AM_RANGE(0x4c00, 0x4fff) AM_RAM AM_BASE(&tp84_fg_colorram) AM_RANGE(0x4c00, 0x4fff) AM_RAM AM_BASE_MEMBER(tp84_state, fg_colorram)
AM_RANGE(0x5000, 0x57ff) AM_RAM AM_SHARE("share1") AM_RANGE(0x5000, 0x57ff) AM_RAM AM_SHARE("share1")
AM_RANGE(0x8000, 0xffff) AM_ROM AM_RANGE(0x8000, 0xffff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( tp84b_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( tp84b_cpu1_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE(&tp84_bg_videoram) AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE_MEMBER(tp84_state, bg_videoram)
AM_RANGE(0x0400, 0x07ff) AM_RAM AM_BASE(&tp84_fg_videoram) AM_RANGE(0x0400, 0x07ff) AM_RAM AM_BASE_MEMBER(tp84_state, fg_videoram)
AM_RANGE(0x0800, 0x0bff) AM_RAM AM_BASE(&tp84_bg_colorram) AM_RANGE(0x0800, 0x0bff) AM_RAM AM_BASE_MEMBER(tp84_state, bg_colorram)
AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_BASE(&tp84_fg_colorram) AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_BASE_MEMBER(tp84_state, fg_colorram)
AM_RANGE(0x1000, 0x17ff) AM_RAM AM_SHARE("share1") AM_RANGE(0x1000, 0x17ff) AM_RAM AM_SHARE("share1")
AM_RANGE(0x1800, 0x1800) AM_WRITE(watchdog_reset_w) AM_RANGE(0x1800, 0x1800) AM_WRITE(watchdog_reset_w)
AM_RANGE(0x1a00, 0x1a00) AM_READ_PORT("SYSTEM") AM_WRITEONLY AM_BASE(&tp84_palette_bank) AM_RANGE(0x1a00, 0x1a00) AM_READ_PORT("SYSTEM") AM_WRITEONLY AM_BASE_MEMBER(tp84_state, palette_bank)
AM_RANGE(0x1a20, 0x1a20) AM_READ_PORT("P1") AM_RANGE(0x1a20, 0x1a20) AM_READ_PORT("P1")
AM_RANGE(0x1a40, 0x1a40) AM_READ_PORT("P2") AM_RANGE(0x1a40, 0x1a40) AM_READ_PORT("P2")
AM_RANGE(0x1a60, 0x1a60) AM_READ_PORT("DSW1") AM_RANGE(0x1a60, 0x1a60) AM_READ_PORT("DSW1")
AM_RANGE(0x1c00, 0x1c00) AM_READ_PORT("DSW2") AM_WRITENOP AM_RANGE(0x1c00, 0x1c00) AM_READ_PORT("DSW2") AM_WRITENOP
AM_RANGE(0x1c04, 0x1c04) AM_WRITEONLY AM_BASE(&tp84_flipscreen_x) AM_RANGE(0x1c04, 0x1c04) AM_WRITEONLY AM_BASE_MEMBER(tp84_state, flipscreen_x)
AM_RANGE(0x1c05, 0x1c05) AM_WRITEONLY AM_BASE(&tp84_flipscreen_y) AM_RANGE(0x1c05, 0x1c05) AM_WRITEONLY AM_BASE_MEMBER(tp84_state, flipscreen_y)
AM_RANGE(0x1e00, 0x1e00) AM_WRITE(tp84_sh_irqtrigger_w) AM_RANGE(0x1e00, 0x1e00) AM_WRITE(tp84_sh_irqtrigger_w)
AM_RANGE(0x1e80, 0x1e80) AM_WRITE(soundlatch_w) AM_RANGE(0x1e80, 0x1e80) AM_WRITE(soundlatch_w)
AM_RANGE(0x1f00, 0x1f00) AM_WRITEONLY AM_BASE(&tp84_scroll_x) AM_RANGE(0x1f00, 0x1f00) AM_WRITEONLY AM_BASE_MEMBER(tp84_state, scroll_x)
AM_RANGE(0x1f80, 0x1f80) AM_WRITEONLY AM_BASE(&tp84_scroll_y) AM_RANGE(0x1f80, 0x1f80) AM_WRITEONLY AM_BASE_MEMBER(tp84_state, scroll_y)
AM_RANGE(0x8000, 0xffff) AM_ROM AM_RANGE(0x8000, 0xffff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -173,7 +174,7 @@ static ADDRESS_MAP_START( cpu2_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x2000, 0x2000) AM_READ(tp84_scanline_r) /* beam position */ AM_RANGE(0x2000, 0x2000) AM_READ(tp84_scanline_r) /* beam position */
AM_RANGE(0x4000, 0x4000) AM_WRITE(interrupt_enable_w) AM_RANGE(0x4000, 0x4000) AM_WRITE(interrupt_enable_w)
AM_RANGE(0x6000, 0x679f) AM_RAM AM_RANGE(0x6000, 0x679f) AM_RAM
AM_RANGE(0x67a0, 0x67ff) AM_RAM_WRITE(tp84_spriteram_w) AM_BASE(&tp84_spriteram) AM_RANGE(0x67a0, 0x67ff) AM_RAM_WRITE(tp84_spriteram_w) AM_BASE_MEMBER(tp84_state, spriteram)
AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("share1") AM_RANGE(0x8000, 0x87ff) AM_RAM AM_SHARE("share1")
AM_RANGE(0xe000, 0xffff) AM_ROM AM_RANGE(0xe000, 0xffff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -274,7 +275,7 @@ GFXDECODE_END
static MACHINE_CONFIG_START( tp84, driver_device ) static MACHINE_CONFIG_START( tp84, tp84_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("cpu1",M6809, XTAL_18_432MHz/12) /* verified on pcb */ MCFG_CPU_ADD("cpu1",M6809, XTAL_18_432MHz/12) /* verified on pcb */

View File

@ -53,26 +53,18 @@ Known Issues:
#include "includes/twin16.h" #include "includes/twin16.h"
#include "includes/konamipt.h" #include "includes/konamipt.h"
UINT16 twin16_custom_video;
UINT16 *twin16_gfx_rom;
UINT16 *twin16_sprite_gfx_ram;
UINT16 *twin16_tile_gfx_ram;
UINT16 *twin16_text_ram;
static UINT16 twin16_CPUA_register, twin16_CPUB_register;
#define CPUA_IRQ_ENABLE (twin16_CPUA_register & 0x20)
#define CPUB_IRQ_ENABLE (twin16_CPUB_register & 0x02)
static UINT16 twin16_sound_command;
static int cuebrickj_nvram_bank;
static UINT16 cuebrickj_nvram[0x400*0x20]; // 32k paged in a 1k window
int twin16_spriteram_process_enable( void ) #define CPUA_IRQ_ENABLE (state->CPUA_register & 0x20)
#define CPUB_IRQ_ENABLE (state->CPUB_register & 0x02)
int twin16_spriteram_process_enable( running_machine *machine )
{ {
return (twin16_CPUA_register & 0x40) == 0; twin16_state *state = machine->driver_data<twin16_state>();
return (state->CPUA_register & 0x40) == 0;
} }
/******************************************************************************************/ /******************************************************************************************/
@ -103,22 +95,26 @@ static READ16_HANDLER( extra_rom_r )
static READ16_HANDLER( twin16_gfx_rom1_r ) static READ16_HANDLER( twin16_gfx_rom1_r )
{ {
return twin16_gfx_rom[offset + ((twin16_CPUB_register&0x04)?0x40000:0)]; twin16_state *state = space->machine->driver_data<twin16_state>();
return state->gfx_rom[offset + ((state->CPUB_register&0x04)?0x40000:0)];
} }
static READ16_HANDLER( twin16_gfx_rom2_r ) static READ16_HANDLER( twin16_gfx_rom2_r )
{ {
return twin16_gfx_rom[offset + 0x80000 + ((twin16_CPUB_register&0x04)?0x40000:0)]; twin16_state *state = space->machine->driver_data<twin16_state>();
return state->gfx_rom[offset + 0x80000 + ((state->CPUB_register&0x04)?0x40000:0)];
} }
static WRITE16_HANDLER( sound_command_w ) static WRITE16_HANDLER( sound_command_w )
{ {
COMBINE_DATA(&twin16_sound_command); twin16_state *state = space->machine->driver_data<twin16_state>();
soundlatch_w( space, 0, twin16_sound_command&0xff ); COMBINE_DATA(&state->sound_command);
soundlatch_w( space, 0, state->sound_command&0xff );
} }
static WRITE16_HANDLER( twin16_CPUA_register_w ) static WRITE16_HANDLER( twin16_CPUA_register_w )
{ {
twin16_state *state = space->machine->driver_data<twin16_state>();
/* /*
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
X sprite processing disable X sprite processing disable
@ -127,58 +123,60 @@ static WRITE16_HANDLER( twin16_CPUA_register_w )
X 0->1 trigger IRQ on sound CPU X 0->1 trigger IRQ on sound CPU
x x x coin counters x x x coin counters
*/ */
UINT16 old = twin16_CPUA_register; UINT16 old = state->CPUA_register;
COMBINE_DATA(&twin16_CPUA_register); COMBINE_DATA(&state->CPUA_register);
if (twin16_CPUA_register != old) if (state->CPUA_register != old)
{ {
if ((old & 0x08) == 0 && (twin16_CPUA_register & 0x08)) if ((old & 0x08) == 0 && (state->CPUA_register & 0x08))
cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff); cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
if ((old & 0x40) && (twin16_CPUA_register & 0x40) == 0) if ((old & 0x40) && (state->CPUA_register & 0x40) == 0)
twin16_spriteram_process(space->machine); twin16_spriteram_process(space->machine);
if ((old & 0x10) == 0 && (twin16_CPUA_register & 0x10)) if ((old & 0x10) == 0 && (state->CPUA_register & 0x10))
cputag_set_input_line(space->machine, "sub", M68K_IRQ_6, HOLD_LINE); cputag_set_input_line(space->machine, "sub", M68K_IRQ_6, HOLD_LINE);
coin_counter_w(space->machine, 0, twin16_CPUA_register & 0x01); coin_counter_w(space->machine, 0, state->CPUA_register & 0x01);
coin_counter_w(space->machine, 1, twin16_CPUA_register & 0x02); coin_counter_w(space->machine, 1, state->CPUA_register & 0x02);
coin_counter_w(space->machine, 2, twin16_CPUA_register & 0x04); coin_counter_w(space->machine, 2, state->CPUA_register & 0x04);
} }
} }
static WRITE16_HANDLER( twin16_CPUB_register_w ) static WRITE16_HANDLER( twin16_CPUB_register_w )
{ {
twin16_state *state = space->machine->driver_data<twin16_state>();
/* /*
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
X gfx bank select X gfx bank select
X IRQ5 enable X IRQ5 enable
X 0->1 trigger IRQ6 on CPUA X 0->1 trigger IRQ6 on CPUA
*/ */
UINT16 old = twin16_CPUB_register; UINT16 old = state->CPUB_register;
COMBINE_DATA(&twin16_CPUB_register); COMBINE_DATA(&state->CPUB_register);
if( twin16_CPUB_register!=old ) if( state->CPUB_register!=old )
{ {
if ((old & 0x01) == 0 && (twin16_CPUB_register & 0x01)) if ((old & 0x01) == 0 && (state->CPUB_register & 0x01))
cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_6, HOLD_LINE); cputag_set_input_line(space->machine, "maincpu", M68K_IRQ_6, HOLD_LINE);
} }
} }
static WRITE16_HANDLER( fround_CPU_register_w ) static WRITE16_HANDLER( fround_CPU_register_w )
{ {
twin16_state *state = space->machine->driver_data<twin16_state>();
/* /*
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
X 0->1 trigger IRQ on sound CPU X 0->1 trigger IRQ on sound CPU
x x coin counters x x coin counters
*/ */
UINT16 old = twin16_CPUA_register; UINT16 old = state->CPUA_register;
COMBINE_DATA(&twin16_CPUA_register); COMBINE_DATA(&state->CPUA_register);
if (twin16_CPUA_register != old) if (state->CPUA_register != old)
{ {
if ((old & 0x08) == 0 && (twin16_CPUA_register & 0x08)) if ((old & 0x08) == 0 && (state->CPUA_register & 0x08))
cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff); cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
coin_counter_w(space->machine, 0, twin16_CPUA_register & 0x01); coin_counter_w(space->machine, 0, state->CPUA_register & 0x01);
coin_counter_w(space->machine, 1, twin16_CPUA_register & 0x02); coin_counter_w(space->machine, 1, state->CPUA_register & 0x02);
} }
} }
@ -215,17 +213,20 @@ static WRITE8_DEVICE_HANDLER( twin16_upd_start_w )
static READ16_HANDLER( cuebrickj_nvram_r ) static READ16_HANDLER( cuebrickj_nvram_r )
{ {
return cuebrickj_nvram[offset + (cuebrickj_nvram_bank * 0x400 / 2)]; twin16_state *state = space->machine->driver_data<twin16_state>();
return state->cuebrickj_nvram[offset + (state->cuebrickj_nvram_bank * 0x400 / 2)];
} }
static WRITE16_HANDLER( cuebrickj_nvram_w ) static WRITE16_HANDLER( cuebrickj_nvram_w )
{ {
COMBINE_DATA(&cuebrickj_nvram[offset + (cuebrickj_nvram_bank * 0x400 / 2)]); twin16_state *state = space->machine->driver_data<twin16_state>();
COMBINE_DATA(&state->cuebrickj_nvram[offset + (state->cuebrickj_nvram_bank * 0x400 / 2)]);
} }
static WRITE16_HANDLER( cuebrickj_nvram_bank_w ) static WRITE16_HANDLER( cuebrickj_nvram_bank_w )
{ {
cuebrickj_nvram_bank = (data >> 8); twin16_state *state = space->machine->driver_data<twin16_state>();
state->cuebrickj_nvram_bank = (data >> 8);
} }
/* Memory Maps */ /* Memory Maps */
@ -257,7 +258,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x0b0400, 0x0b0401) AM_WRITE(cuebrickj_nvram_bank_w) AM_RANGE(0x0b0400, 0x0b0401) AM_WRITE(cuebrickj_nvram_bank_w)
AM_RANGE(0x0c0000, 0x0c000f) AM_WRITE(twin16_video_register_w) AM_RANGE(0x0c0000, 0x0c000f) AM_WRITE(twin16_video_register_w)
AM_RANGE(0x0c000e, 0x0c000f) AM_READ(twin16_sprite_status_r) AM_RANGE(0x0c000e, 0x0c000f) AM_READ(twin16_sprite_status_r)
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(twin16_text_ram_w) AM_BASE(&twin16_text_ram) AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(twin16_text_ram_w) AM_BASE_MEMBER(twin16_state, text_ram)
// AM_RANGE(0x104000, 0x105fff) AM_NOP // miaj // AM_RANGE(0x104000, 0x105fff) AM_NOP // miaj
AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(twin16_state, videoram) AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(twin16_state, videoram)
AM_RANGE(0x140000, 0x143fff) AM_RAM AM_SHARE("share1") AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x140000, 0x143fff) AM_RAM AM_SHARE("share1") AM_BASE_SIZE_GENERIC(spriteram)
@ -272,10 +273,10 @@ static ADDRESS_MAP_START( sub_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x0a0000, 0x0a0001) AM_WRITE(twin16_CPUB_register_w) AM_RANGE(0x0a0000, 0x0a0001) AM_WRITE(twin16_CPUB_register_w)
AM_RANGE(0x400000, 0x403fff) AM_RAM AM_SHARE("share1") AM_RANGE(0x400000, 0x403fff) AM_RAM AM_SHARE("share1")
AM_RANGE(0x480000, 0x483fff) AM_READWRITE(videoram16_r, videoram16_w) AM_RANGE(0x480000, 0x483fff) AM_READWRITE(videoram16_r, videoram16_w)
AM_RANGE(0x500000, 0x53ffff) AM_RAM AM_BASE(&twin16_tile_gfx_ram) AM_RANGE(0x500000, 0x53ffff) AM_RAM AM_BASE_MEMBER(twin16_state, tile_gfx_ram)
AM_RANGE(0x600000, 0x6fffff) AM_READ(twin16_gfx_rom1_r) AM_RANGE(0x600000, 0x6fffff) AM_READ(twin16_gfx_rom1_r)
AM_RANGE(0x700000, 0x77ffff) AM_READ(twin16_gfx_rom2_r) AM_RANGE(0x700000, 0x77ffff) AM_READ(twin16_gfx_rom2_r)
AM_RANGE(0x780000, 0x79ffff) AM_RAM AM_BASE(&twin16_sprite_gfx_ram) AM_RANGE(0x780000, 0x79ffff) AM_RAM AM_BASE_MEMBER(twin16_state, sprite_gfx_ram)
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( fround_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( fround_map, ADDRESS_SPACE_PROGRAM, 16 )
@ -290,7 +291,7 @@ static ADDRESS_MAP_START( fround_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x0c0000, 0x0c000f) AM_WRITE(twin16_video_register_w) AM_RANGE(0x0c0000, 0x0c000f) AM_WRITE(twin16_video_register_w)
AM_RANGE(0x0c000e, 0x0c000f) AM_READ(twin16_sprite_status_r) AM_RANGE(0x0c000e, 0x0c000f) AM_READ(twin16_sprite_status_r)
AM_RANGE(0x0e0000, 0x0e0001) AM_WRITE(fround_gfx_bank_w) AM_RANGE(0x0e0000, 0x0e0001) AM_WRITE(fround_gfx_bank_w)
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(twin16_text_ram_w) AM_BASE(&twin16_text_ram) AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(twin16_text_ram_w) AM_BASE_MEMBER(twin16_state, text_ram)
AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(twin16_state, videoram) AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(twin16_state, videoram)
AM_RANGE(0x140000, 0x143fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0x140000, 0x143fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
AM_RANGE(0x500000, 0x6fffff) AM_READ(twin16_gfx_rom1_r) AM_RANGE(0x500000, 0x6fffff) AM_READ(twin16_gfx_rom1_r)
@ -690,11 +691,13 @@ static const k007232_interface k007232_config =
static INTERRUPT_GEN( CPUA_interrupt ) static INTERRUPT_GEN( CPUA_interrupt )
{ {
twin16_state *state = device->machine->driver_data<twin16_state>();
if (CPUA_IRQ_ENABLE) cpu_set_input_line(device, 5, HOLD_LINE); if (CPUA_IRQ_ENABLE) cpu_set_input_line(device, 5, HOLD_LINE);
} }
static INTERRUPT_GEN( CPUB_interrupt ) static INTERRUPT_GEN( CPUB_interrupt )
{ {
twin16_state *state = device->machine->driver_data<twin16_state>();
if (CPUB_IRQ_ENABLE) cpu_set_input_line(device, 5, HOLD_LINE); if (CPUB_IRQ_ENABLE) cpu_set_input_line(device, 5, HOLD_LINE);
} }
@ -707,16 +710,17 @@ static MACHINE_RESET( twin16 )
static MACHINE_START( twin16 ) static MACHINE_START( twin16 )
{ {
twin16_CPUA_register=0; twin16_state *state = machine->driver_data<twin16_state>();
twin16_CPUB_register=0; state->CPUA_register=0;
state->CPUB_register=0;
/* register for savestates */ /* register for savestates */
state_save_register_global(machine, twin16_CPUA_register); state_save_register_global(machine, state->CPUA_register);
state_save_register_global(machine, twin16_CPUB_register); state_save_register_global(machine, state->CPUB_register);
state_save_register_global(machine, twin16_sound_command); state_save_register_global(machine, state->sound_command);
state_save_register_global(machine, cuebrickj_nvram_bank); state_save_register_global(machine, state->cuebrickj_nvram_bank);
state_save_register_global_array(machine, cuebrickj_nvram); state_save_register_global_array(machine, state->cuebrickj_nvram);
} }
static MACHINE_CONFIG_START( twin16, twin16_state ) static MACHINE_CONFIG_START( twin16, twin16_state )
@ -1303,38 +1307,42 @@ ROM_END
static void gfx_untangle( running_machine *machine ) static void gfx_untangle( running_machine *machine )
{ {
twin16_state *state = machine->driver_data<twin16_state>();
// sprite, tile data // sprite, tile data
int i; int i;
UINT16 *temp = auto_alloc_array(machine, UINT16, 0x200000/2); UINT16 *temp = auto_alloc_array(machine, UINT16, 0x200000/2);
twin16_gfx_rom = (UINT16 *)machine->region("gfx2")->base(); state->gfx_rom = (UINT16 *)machine->region("gfx2")->base();
memcpy( temp, twin16_gfx_rom, 0x200000 ); memcpy( temp, state->gfx_rom, 0x200000 );
for( i=0; i<0x080000; i++ ) for( i=0; i<0x080000; i++ )
{ {
twin16_gfx_rom[i*2+0] = temp[i+0x080000]; state->gfx_rom[i*2+0] = temp[i+0x080000];
twin16_gfx_rom[i*2+1] = temp[i]; state->gfx_rom[i*2+1] = temp[i];
} }
auto_free( machine, temp ); auto_free( machine, temp );
} }
static DRIVER_INIT( twin16 ) static DRIVER_INIT( twin16 )
{ {
twin16_state *state = machine->driver_data<twin16_state>();
gfx_untangle(machine); gfx_untangle(machine);
twin16_custom_video = 0; state->custom_video = 0;
} }
static DRIVER_INIT( fround ) static DRIVER_INIT( fround )
{ {
twin16_state *state = machine->driver_data<twin16_state>();
gfx_untangle(machine); gfx_untangle(machine);
twin16_custom_video = 1; state->custom_video = 1;
} }
static DRIVER_INIT( cuebrickj ) static DRIVER_INIT( cuebrickj )
{ {
twin16_state *state = machine->driver_data<twin16_state>();
gfx_untangle(machine); gfx_untangle(machine);
machine->device<nvram_device>("nvram")->set_base(cuebrickj_nvram, 0x400*0x20); machine->device<nvram_device>("nvram")->set_base(state->cuebrickj_nvram, 0x400*0x20);
} }
/* Game Drivers */ /* Game Drivers */

View File

@ -17,14 +17,25 @@ TODO:
#include "sound/k056800.h" #include "sound/k056800.h"
static UINT32 *vram; class ultrsprt_state : public driver_device
static UINT32 *workram; {
public:
ultrsprt_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT32 *vram;
UINT32 *workram;
};
static VIDEO_UPDATE( ultrsprt ) static VIDEO_UPDATE( ultrsprt )
{ {
ultrsprt_state *state = screen->machine->driver_data<ultrsprt_state>();
int i, j; int i, j;
UINT8 *ram = (UINT8 *)vram; UINT8 *ram = (UINT8 *)state->vram;
for (j=0; j < 400; j++) for (j=0; j < 400; j++)
{ {
@ -82,25 +93,26 @@ static WRITE32_HANDLER( int_ack_w )
static MACHINE_START( ultrsprt ) static MACHINE_START( ultrsprt )
{ {
ultrsprt_state *state = machine->driver_data<ultrsprt_state>();
/* set conservative DRC options */ /* set conservative DRC options */
ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS); ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS);
/* configure fast RAM regions for DRC */ /* configure fast RAM regions for DRC */
ppcdrc_add_fastram(machine->device("maincpu"), 0x80000000, 0x8007ffff, FALSE, vram); ppcdrc_add_fastram(machine->device("maincpu"), 0x80000000, 0x8007ffff, FALSE, state->vram);
ppcdrc_add_fastram(machine->device("maincpu"), 0xff000000, 0xff01ffff, FALSE, workram); ppcdrc_add_fastram(machine->device("maincpu"), 0xff000000, 0xff01ffff, FALSE, state->workram);
} }
static ADDRESS_MAP_START( ultrsprt_map, ADDRESS_SPACE_PROGRAM, 32 ) static ADDRESS_MAP_START( ultrsprt_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x00000000, 0x0007ffff) AM_RAM AM_BASE(&vram) AM_RANGE(0x00000000, 0x0007ffff) AM_RAM AM_BASE_MEMBER(ultrsprt_state, vram)
AM_RANGE(0x70000000, 0x70000003) AM_READWRITE(eeprom_r, eeprom_w) AM_RANGE(0x70000000, 0x70000003) AM_READWRITE(eeprom_r, eeprom_w)
AM_RANGE(0x70000020, 0x70000023) AM_READ_PORT("P1") AM_RANGE(0x70000020, 0x70000023) AM_READ_PORT("P1")
AM_RANGE(0x70000040, 0x70000043) AM_READ_PORT("P2") AM_RANGE(0x70000040, 0x70000043) AM_READ_PORT("P2")
AM_RANGE(0x70000080, 0x70000087) AM_DEVWRITE("k056800", k056800_host_w) AM_RANGE(0x70000080, 0x70000087) AM_DEVWRITE("k056800", k056800_host_w)
AM_RANGE(0x70000088, 0x7000008f) AM_DEVREAD("k056800", k056800_host_r) AM_RANGE(0x70000088, 0x7000008f) AM_DEVREAD("k056800", k056800_host_r)
AM_RANGE(0x700000e0, 0x700000e3) AM_WRITE(int_ack_w) AM_RANGE(0x700000e0, 0x700000e3) AM_WRITE(int_ack_w)
AM_RANGE(0x7f000000, 0x7f01ffff) AM_RAM AM_BASE(&workram) AM_RANGE(0x7f000000, 0x7f01ffff) AM_RAM AM_BASE_MEMBER(ultrsprt_state, workram)
AM_RANGE(0x7f700000, 0x7f703fff) AM_RAM_WRITE(palette_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x7f700000, 0x7f703fff) AM_RAM_WRITE(palette_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x7f800000, 0x7f9fffff) AM_MIRROR(0x00600000) AM_ROM AM_REGION("user1", 0) AM_RANGE(0x7f800000, 0x7f9fffff) AM_MIRROR(0x00600000) AM_ROM AM_REGION("user1", 0)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -201,7 +213,7 @@ static const k056800_interface ultrsprt_k056800_interface =
}; };
static MACHINE_CONFIG_START( ultrsprt, driver_device ) static MACHINE_CONFIG_START( ultrsprt, ultrsprt_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", PPC403GA, 25000000) /* PowerPC 403GA 25MHz */ MCFG_CPU_ADD("maincpu", PPC403GA, 25000000) /* PowerPC 403GA 25MHz */
MCFG_CPU_PROGRAM_MAP(ultrsprt_map) MCFG_CPU_PROGRAM_MAP(ultrsprt_map)

View File

@ -45,6 +45,21 @@ DASM code snippets:
#include "machine/timekpr.h" #include "machine/timekpr.h"
#include "video/voodoo.h" #include "video/voodoo.h"
class viper_state : public driver_device
{
public:
viper_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT32 mpc8240_regs[256/4];
UINT32 epic_iack;
int cf_card_ide;
int unk1_bit;
UINT32 voodoo3_pci_reg[0x100];
};
//#define VIPER_DEBUG_LOG //#define VIPER_DEBUG_LOG
static VIDEO_UPDATE(viper) static VIDEO_UPDATE(viper)
@ -56,9 +71,9 @@ static VIDEO_UPDATE(viper)
/*****************************************************************************/ /*****************************************************************************/
static UINT32 mpc8240_regs[256/4];
static UINT32 mpc8240_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask) static UINT32 mpc8240_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
{ {
viper_state *state = device->machine->driver_data<viper_state>();
#ifdef VIPER_DEBUG_LOG #ifdef VIPER_DEBUG_LOG
printf("MPC8240: PCI read %d, %02X, %08X\n", function, reg, mem_mask); printf("MPC8240: PCI read %d, %02X, %08X\n", function, reg, mem_mask);
#endif #endif
@ -67,16 +82,17 @@ static UINT32 mpc8240_pci_r(device_t *busdevice, device_t *device, int function,
{ {
} }
return mpc8240_regs[reg/4]; return state->mpc8240_regs[reg/4];
} }
static void mpc8240_pci_w(device_t *busdevice, device_t *device, int function, int reg, UINT32 data, UINT32 mem_mask) static void mpc8240_pci_w(device_t *busdevice, device_t *device, int function, int reg, UINT32 data, UINT32 mem_mask)
{ {
viper_state *state = device->machine->driver_data<viper_state>();
#ifdef VIPER_DEBUG_LOG #ifdef VIPER_DEBUG_LOG
printf("MPC8240: PCI write %d, %02X, %08X, %08X\n", function, reg, data, mem_mask); printf("MPC8240: PCI write %d, %02X, %08X, %08X\n", function, reg, data, mem_mask);
#endif #endif
COMBINE_DATA(mpc8240_regs + (reg/4)); COMBINE_DATA(state->mpc8240_regs + (reg/4));
} }
@ -102,10 +118,10 @@ static WRITE64_DEVICE_HANDLER( pci_config_data_w )
static UINT32 epic_iack;
static READ32_HANDLER( epic_r ) static READ32_HANDLER( epic_r )
{ {
viper_state *state = space->machine->driver_data<viper_state>();
int reg; int reg;
reg = offset * 4; reg = offset * 4;
@ -121,7 +137,7 @@ static READ32_HANDLER( epic_r )
switch (reg & 0xffff) switch (reg & 0xffff)
{ {
case 0x00a0: // IACK case 0x00a0: // IACK
return epic_iack; return state->epic_iack;
} }
break; break;
@ -133,6 +149,7 @@ static READ32_HANDLER( epic_r )
static WRITE32_HANDLER( epic_w ) static WRITE32_HANDLER( epic_w )
{ {
viper_state *state = space->machine->driver_data<viper_state>();
int reg; int reg;
reg = offset * 4; reg = offset * 4;
@ -148,7 +165,7 @@ static WRITE32_HANDLER( epic_w )
switch (reg & 0xffff) switch (reg & 0xffff)
{ {
case 0x00b0: // EOI case 0x00b0: // EOI
epic_iack = 0xff; state->epic_iack = 0xff;
break; break;
} }
break; break;
@ -166,7 +183,6 @@ static WRITE64_HANDLER(epic_64be_w)
} }
static int cf_card_ide = 0;
static const UINT8 cf_card_tuples[] = static const UINT8 cf_card_tuples[] =
{ {
@ -226,11 +242,12 @@ static WRITE64_DEVICE_HANDLER(cf_card_data_w)
static READ64_DEVICE_HANDLER(cf_card_r) static READ64_DEVICE_HANDLER(cf_card_r)
{ {
viper_state *state = device->machine->driver_data<viper_state>();
UINT64 r = 0; UINT64 r = 0;
if (ACCESSING_BITS_16_31) if (ACCESSING_BITS_16_31)
{ {
if (cf_card_ide) if (state->cf_card_ide)
{ {
switch (offset & 0xf) switch (offset & 0xf)
{ {
@ -289,6 +306,7 @@ static READ64_DEVICE_HANDLER(cf_card_r)
static WRITE64_DEVICE_HANDLER(cf_card_w) static WRITE64_DEVICE_HANDLER(cf_card_w)
{ {
viper_state *state = device->machine->driver_data<viper_state>();
#ifdef VIPER_DEBUG_LOG #ifdef VIPER_DEBUG_LOG
printf("%s:compact_flash_w: %08X%08X, %08X, %08X%08X\n", device->machine->describe_context(), (UINT32)(data>>32), (UINT32)(data), offset, (UINT32)(mem_mask >> 32), (UINT32)(mem_mask)); printf("%s:compact_flash_w: %08X%08X, %08X, %08X%08X\n", device->machine->describe_context(), (UINT32)(data>>32), (UINT32)(data), offset, (UINT32)(mem_mask >> 32), (UINT32)(mem_mask));
#endif #endif
@ -341,7 +359,7 @@ static WRITE64_DEVICE_HANDLER(cf_card_w)
{ {
if ((data >> 16) & 0x80) if ((data >> 16) & 0x80)
{ {
cf_card_ide = 1; state->cf_card_ide = 1;
// soft reset // soft reset
// sector count register is set to 0x01 // sector count register is set to 0x01
@ -364,9 +382,10 @@ static WRITE64_DEVICE_HANDLER(cf_card_w)
static WRITE64_HANDLER(unk2_w) static WRITE64_HANDLER(unk2_w)
{ {
viper_state *state = space->machine->driver_data<viper_state>();
if (ACCESSING_BITS_56_63) if (ACCESSING_BITS_56_63)
{ {
cf_card_ide = 0; state->cf_card_ide = 0;
} }
} }
@ -397,15 +416,15 @@ static WRITE64_DEVICE_HANDLER(ata_w)
} }
} }
static int unk1_bit = 0;
static READ64_HANDLER(unk1_r) static READ64_HANDLER(unk1_r)
{ {
viper_state *state = space->machine->driver_data<viper_state>();
UINT64 r = 0; UINT64 r = 0;
//return 0;//U64(0x0000400000000000); //return 0;//U64(0x0000400000000000);
if (ACCESSING_BITS_40_47) if (ACCESSING_BITS_40_47)
{ {
r |= (UINT64)(unk1_bit << 5) << 40; r |= (UINT64)(state->unk1_bit << 5) << 40;
} }
return r; return r;
@ -413,23 +432,25 @@ static READ64_HANDLER(unk1_r)
static WRITE64_HANDLER(unk1a_w) static WRITE64_HANDLER(unk1a_w)
{ {
viper_state *state = space->machine->driver_data<viper_state>();
if (ACCESSING_BITS_56_63) if (ACCESSING_BITS_56_63)
{ {
unk1_bit = 1; state->unk1_bit = 1;
} }
} }
static WRITE64_HANDLER(unk1b_w) static WRITE64_HANDLER(unk1b_w)
{ {
viper_state *state = space->machine->driver_data<viper_state>();
if (ACCESSING_BITS_56_63) if (ACCESSING_BITS_56_63)
{ {
unk1_bit = 0; state->unk1_bit = 0;
} }
} }
static UINT32 voodoo3_pci_reg[0x100];
static UINT32 voodoo3_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask) static UINT32 voodoo3_pci_r(device_t *busdevice, device_t *device, int function, int reg, UINT32 mem_mask)
{ {
viper_state *state = device->machine->driver_data<viper_state>();
switch (reg) switch (reg)
{ {
case 0x00: // PCI Vendor ID (0x121a = 3dfx), Device ID (0x0005 = Voodoo 3) case 0x00: // PCI Vendor ID (0x121a = 3dfx), Device ID (0x0005 = Voodoo 3)
@ -442,23 +463,23 @@ static UINT32 voodoo3_pci_r(device_t *busdevice, device_t *device, int function,
} }
case 0x10: // memBaseAddr0 case 0x10: // memBaseAddr0
{ {
return voodoo3_pci_reg[0x10/4]; return state->voodoo3_pci_reg[0x10/4];
} }
case 0x14: // memBaseAddr1 case 0x14: // memBaseAddr1
{ {
return voodoo3_pci_reg[0x14/4]; return state->voodoo3_pci_reg[0x14/4];
} }
case 0x18: // memBaseAddr1 case 0x18: // memBaseAddr1
{ {
return voodoo3_pci_reg[0x18/4]; return state->voodoo3_pci_reg[0x18/4];
} }
case 0x40: // fabId case 0x40: // fabId
{ {
return voodoo3_pci_reg[0x40/4]; return state->voodoo3_pci_reg[0x40/4];
} }
case 0x50: // cfgScratch case 0x50: // cfgScratch
{ {
return voodoo3_pci_reg[0x50/4]; return state->voodoo3_pci_reg[0x50/4];
} }
default: default:
@ -469,24 +490,25 @@ static UINT32 voodoo3_pci_r(device_t *busdevice, device_t *device, int function,
static void voodoo3_pci_w(device_t *busdevice, device_t *device, int function, int reg, UINT32 data, UINT32 mem_mask) static void voodoo3_pci_w(device_t *busdevice, device_t *device, int function, int reg, UINT32 data, UINT32 mem_mask)
{ {
viper_state *state = device->machine->driver_data<viper_state>();
// printf("voodoo3_pci_w: %08X, %08X\n", reg, data); // printf("voodoo3_pci_w: %08X, %08X\n", reg, data);
switch (reg) switch (reg)
{ {
case 0x04: // Command register case 0x04: // Command register
{ {
voodoo3_pci_reg[0x04/4] = data; state->voodoo3_pci_reg[0x04/4] = data;
break; break;
} }
case 0x10: // memBaseAddr0 case 0x10: // memBaseAddr0
{ {
if (data == 0xffffffff) if (data == 0xffffffff)
{ {
voodoo3_pci_reg[0x10/4] = 0xfe000000; state->voodoo3_pci_reg[0x10/4] = 0xfe000000;
} }
else else
{ {
voodoo3_pci_reg[0x10/4] = data; state->voodoo3_pci_reg[0x10/4] = data;
} }
break; break;
} }
@ -494,11 +516,11 @@ static void voodoo3_pci_w(device_t *busdevice, device_t *device, int function, i
{ {
if (data == 0xffffffff) if (data == 0xffffffff)
{ {
voodoo3_pci_reg[0x14/4] = 0xfe000008; state->voodoo3_pci_reg[0x14/4] = 0xfe000008;
} }
else else
{ {
voodoo3_pci_reg[0x14/4] = data; state->voodoo3_pci_reg[0x14/4] = data;
} }
break; break;
} }
@ -506,11 +528,11 @@ static void voodoo3_pci_w(device_t *busdevice, device_t *device, int function, i
{ {
if (data == 0xffffffff) if (data == 0xffffffff)
{ {
voodoo3_pci_reg[0x18/4] = 0xffffff01; state->voodoo3_pci_reg[0x18/4] = 0xffffff01;
} }
else else
{ {
voodoo3_pci_reg[0x18/4] = data; state->voodoo3_pci_reg[0x18/4] = data;
} }
break; break;
} }
@ -520,12 +542,12 @@ static void voodoo3_pci_w(device_t *busdevice, device_t *device, int function, i
} }
case 0x40: // fabId case 0x40: // fabId
{ {
voodoo3_pci_reg[0x40/4] = data; state->voodoo3_pci_reg[0x40/4] = data;
break; break;
} }
case 0x50: // cfgScratch case 0x50: // cfgScratch
{ {
voodoo3_pci_reg[0x50/4] = data; state->voodoo3_pci_reg[0x50/4] = data;
break; break;
} }
@ -614,7 +636,7 @@ static MACHINE_RESET(viper)
devtag_reset(machine, "ide"); devtag_reset(machine, "ide");
} }
static MACHINE_CONFIG_START( viper, driver_device ) static MACHINE_CONFIG_START( viper, viper_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", MPC8240, 200000000) MCFG_CPU_ADD("maincpu", MPC8240, 200000000)

View File

@ -280,14 +280,6 @@ TODO:
#include "wecleman.lh" #include "wecleman.lh"
#include "includes/wecleman.h" #include "includes/wecleman.h"
/* Variables only used here: */
static UINT16 *blitter_regs;
static int multiply_reg[2];
static UINT16 *wecleman_protection_ram;
static int spr_color_offs;
/* Variables that video has acces to: */
int wecleman_selected_ip, wecleman_irqctrl;
/*************************************************************************** /***************************************************************************
Common Routines Common Routines
@ -295,11 +287,12 @@ int wecleman_selected_ip, wecleman_irqctrl;
static READ16_HANDLER( wecleman_protection_r ) static READ16_HANDLER( wecleman_protection_r )
{ {
wecleman_state *state = space->machine->driver_data<wecleman_state>();
int blend, data0, data1, r0, g0, b0, r1, g1, b1; int blend, data0, data1, r0, g0, b0, r1, g1, b1;
data0 = wecleman_protection_ram[0]; data0 = state->protection_ram[0];
blend = wecleman_protection_ram[2]; blend = state->protection_ram[2];
data1 = wecleman_protection_ram[1]; data1 = state->protection_ram[1];
blend &= 0x3ff; blend &= 0x3ff;
// a precalculated table will take an astronomical 4096^2(colors) x 1024(steps) x 2(word) bytes // a precalculated table will take an astronomical 4096^2(colors) x 1024(steps) x 2(word) bytes
@ -321,10 +314,9 @@ static READ16_HANDLER( wecleman_protection_r )
static WRITE16_HANDLER( wecleman_protection_w ) static WRITE16_HANDLER( wecleman_protection_w )
{ {
static int state = 0; wecleman_state *state = space->machine->driver_data<wecleman_state>();
if (offset == 2) state->prot_state = data & 0x2000;
if (offset == 2) state = data & 0x2000; if (!state->prot_state) COMBINE_DATA(state->protection_ram + offset);
if (!state) COMBINE_DATA(wecleman_protection_ram + offset);
} }
@ -350,12 +342,13 @@ static WRITE16_HANDLER( wecleman_protection_w )
*/ */
static WRITE16_HANDLER( irqctrl_w ) static WRITE16_HANDLER( irqctrl_w )
{ {
wecleman_state *state = space->machine->driver_data<wecleman_state>();
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
{ {
// logerror("CPU #0 - PC = %06X - $140005 <- %02X (old value: %02X)\n",cpu_get_pc(space->cpu), data&0xFF, old_data&0xFF); // logerror("CPU #0 - PC = %06X - $140005 <- %02X (old value: %02X)\n",cpu_get_pc(space->cpu), data&0xFF, old_data&0xFF);
// Bit 0 : SUBINT // Bit 0 : SUBINT
if ( (wecleman_irqctrl & 1) && (!(data & 1)) ) // 1->0 transition if ( (state->irqctrl & 1) && (!(data & 1)) ) // 1->0 transition
cputag_set_input_line(space->machine, "sub", 4, HOLD_LINE); cputag_set_input_line(space->machine, "sub", 4, HOLD_LINE);
// Bit 1 : NSUBRST // Bit 1 : NSUBRST
@ -369,7 +362,7 @@ static WRITE16_HANDLER( irqctrl_w )
// Bit 4 : SCR-HCNT // Bit 4 : SCR-HCNT
// Bit 5 : SCR-VCNT // Bit 5 : SCR-VCNT
// Bit 6 : TV-KILL // Bit 6 : TV-KILL
wecleman_irqctrl = data; // latch the value state->irqctrl = data; // latch the value
} }
} }
@ -386,13 +379,15 @@ static WRITE16_HANDLER( irqctrl_w )
*/ */
static WRITE16_HANDLER( selected_ip_w ) static WRITE16_HANDLER( selected_ip_w )
{ {
if (ACCESSING_BITS_0_7) wecleman_selected_ip = data & 0xff; // latch the value wecleman_state *state = space->machine->driver_data<wecleman_state>();
if (ACCESSING_BITS_0_7) state->selected_ip = data & 0xff; // latch the value
} }
/* $140021.b - Return the previously selected input port's value */ /* $140021.b - Return the previously selected input port's value */
static READ16_HANDLER( selected_ip_r ) static READ16_HANDLER( selected_ip_r )
{ {
switch ( (wecleman_selected_ip >> 5) & 3 ) wecleman_state *state = space->machine->driver_data<wecleman_state>();
switch ( (state->selected_ip >> 5) & 3 )
{ // From WEC Le Mans Schems: { // From WEC Le Mans Schems:
case 0: return input_port_read(space->machine, "ACCEL"); // Accel - Schems: Accelevr case 0: return input_port_read(space->machine, "ACCEL"); // Accel - Schems: Accelevr
case 1: return ~0; // ????? - Schems: Not Used case 1: return ~0; // ????? - Schems: Not Used
@ -439,32 +434,33 @@ static READ16_HANDLER( selected_ip_r )
*/ */
static WRITE16_HANDLER( blitter_w ) static WRITE16_HANDLER( blitter_w )
{ {
COMBINE_DATA(&blitter_regs[offset]); wecleman_state *state = space->machine->driver_data<wecleman_state>();
COMBINE_DATA(&state->blitter_regs[offset]);
/* do a blit if $80010.b has been written */ /* do a blit if $80010.b has been written */
if ( (offset == 0x10/2) && (ACCESSING_BITS_8_15) ) if ( (offset == 0x10/2) && (ACCESSING_BITS_8_15) )
{ {
/* 80000.b = ?? usually 0 - other values: 02 ; 00 - ? logic function ? */ /* 80000.b = ?? usually 0 - other values: 02 ; 00 - ? logic function ? */
/* 80001.b = ?? usually 0 - other values: 3f ; 01 - ? height ? */ /* 80001.b = ?? usually 0 - other values: 3f ; 01 - ? height ? */
int minterm = ( blitter_regs[0x0/2] & 0xFF00 ) >> 8; int minterm = ( state->blitter_regs[0x0/2] & 0xFF00 ) >> 8;
int list_len = ( blitter_regs[0x0/2] & 0x00FF ) >> 0; int list_len = ( state->blitter_regs[0x0/2] & 0x00FF ) >> 0;
/* 80002.w = ?? always 0 - ? increment per horizontal line ? */ /* 80002.w = ?? always 0 - ? increment per horizontal line ? */
/* no proof at all, it's always 0 */ /* no proof at all, it's always 0 */
//int srcdisp = blitter_regs[0x2/2] & 0xFF00; //int srcdisp = state->blitter_regs[0x2/2] & 0xFF00;
//int destdisp = blitter_regs[0x2/2] & 0x00FF; //int destdisp = state->blitter_regs[0x2/2] & 0x00FF;
/* 80004.l = source data address */ /* 80004.l = source data address */
int src = ( blitter_regs[0x4/2] << 16 ) + blitter_regs[0x6/2]; int src = ( state->blitter_regs[0x4/2] << 16 ) + state->blitter_regs[0x6/2];
/* 80008.l = list of blits address */ /* 80008.l = list of blits address */
int list = ( blitter_regs[0x8/2] << 16 ) + blitter_regs[0xA/2]; int list = ( state->blitter_regs[0x8/2] << 16 ) + state->blitter_regs[0xA/2];
/* 8000C.l = destination address */ /* 8000C.l = destination address */
int dest = ( blitter_regs[0xC/2] << 16 ) + blitter_regs[0xE/2]; int dest = ( state->blitter_regs[0xC/2] << 16 ) + state->blitter_regs[0xE/2];
/* 80010.b = number of words to move */ /* 80010.b = number of words to move */
int size = ( blitter_regs[0x10/2] ) & 0x00FF; int size = ( state->blitter_regs[0x10/2] ) & 0x00FF;
/* Word aligned transfers only ?? */ /* Word aligned transfers only ?? */
src &= (~1); list &= (~1); dest &= (~1); src &= (~1); list &= (~1); dest &= (~1);
@ -497,7 +493,7 @@ static WRITE16_HANDLER( blitter_w )
space->write_word(destptr, space->read_word(i)); space->write_word(destptr, space->read_word(i));
destptr = dest + 14; destptr = dest + 14;
i = space->read_word(list) + spr_color_offs; i = space->read_word(list) + state->spr_color_offs;
space->write_word(destptr, i); space->write_word(destptr, i);
dest += 16; dest += 16;
@ -519,13 +515,13 @@ static WRITE16_HANDLER( wecleman_soundlatch_w );
static ADDRESS_MAP_START( wecleman_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( wecleman_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x03ffff) AM_ROM // ROM (03c000-03ffff used as RAM sometimes!) AM_RANGE(0x000000, 0x03ffff) AM_ROM // ROM (03c000-03ffff used as RAM sometimes!)
AM_RANGE(0x040494, 0x040495) AM_WRITE(wecleman_videostatus_w) AM_BASE(&wecleman_videostatus) // cloud blending control (HACK) AM_RANGE(0x040494, 0x040495) AM_WRITE(wecleman_videostatus_w) AM_BASE_MEMBER(wecleman_state, videostatus) // cloud blending control (HACK)
AM_RANGE(0x040000, 0x043fff) AM_RAM // RAM AM_RANGE(0x040000, 0x043fff) AM_RAM // RAM
AM_RANGE(0x060000, 0x060005) AM_WRITE(wecleman_protection_w) AM_BASE(&wecleman_protection_ram) AM_RANGE(0x060000, 0x060005) AM_WRITE(wecleman_protection_w) AM_BASE_MEMBER(wecleman_state, protection_ram)
AM_RANGE(0x060006, 0x060007) AM_READ(wecleman_protection_r) // MCU read AM_RANGE(0x060006, 0x060007) AM_READ(wecleman_protection_r) // MCU read
AM_RANGE(0x080000, 0x080011) AM_RAM_WRITE(blitter_w) AM_BASE(&blitter_regs) // Blitter AM_RANGE(0x080000, 0x080011) AM_RAM_WRITE(blitter_w) AM_BASE_MEMBER(wecleman_state, blitter_regs) // Blitter
AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(wecleman_pageram_w) AM_BASE(&wecleman_pageram) // Background Layers AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(wecleman_pageram_w) AM_BASE_MEMBER(wecleman_state, pageram) // Background Layers
AM_RANGE(0x108000, 0x108fff) AM_RAM_WRITE(wecleman_txtram_w) AM_BASE(&wecleman_txtram) // Text Layer AM_RANGE(0x108000, 0x108fff) AM_RAM_WRITE(wecleman_txtram_w) AM_BASE_MEMBER(wecleman_state, txtram) // Text Layer
AM_RANGE(0x110000, 0x110fff) AM_RAM_WRITE(wecleman_paletteram16_SSSSBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x110000, 0x110fff) AM_RAM_WRITE(wecleman_paletteram16_SSSSBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0x124000, 0x127fff) AM_RAM AM_SHARE("share1") // Shared with main CPU AM_RANGE(0x124000, 0x127fff) AM_RAM AM_SHARE("share1") // Shared with main CPU
AM_RANGE(0x130000, 0x130fff) AM_RAM AM_BASE_GENERIC(spriteram) // Sprites AM_RANGE(0x130000, 0x130fff) AM_RAM AM_BASE_GENERIC(spriteram) // Sprites
@ -552,7 +548,7 @@ static WRITE16_HANDLER( hotchase_soundlatch_w );
static ADDRESS_MAP_START( hotchase_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( hotchase_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x03ffff) AM_ROM AM_RANGE(0x000000, 0x03ffff) AM_ROM
AM_RANGE(0x040000, 0x063fff) AM_RAM // RAM (weird size!?) AM_RANGE(0x040000, 0x063fff) AM_RAM // RAM (weird size!?)
AM_RANGE(0x080000, 0x080011) AM_RAM_WRITE(blitter_w) AM_BASE(&blitter_regs) // Blitter AM_RANGE(0x080000, 0x080011) AM_RAM_WRITE(blitter_w) AM_BASE_MEMBER(wecleman_state, blitter_regs) // Blitter
AM_RANGE(0x100000, 0x100fff) AM_DEVREADWRITE8("k051316_1", k051316_r, k051316_w, 0x00ff) // Background AM_RANGE(0x100000, 0x100fff) AM_DEVREADWRITE8("k051316_1", k051316_r, k051316_w, 0x00ff) // Background
AM_RANGE(0x101000, 0x10101f) AM_DEVWRITE8("k051316_1", k051316_ctrl_w, 0x00ff) // Background Ctrl AM_RANGE(0x101000, 0x10101f) AM_DEVWRITE8("k051316_1", k051316_ctrl_w, 0x00ff) // Background Ctrl
AM_RANGE(0x102000, 0x102fff) AM_DEVREADWRITE8("k051316_2", k051316_r, k051316_w, 0x00ff) // Foreground AM_RANGE(0x102000, 0x102fff) AM_DEVREADWRITE8("k051316_2", k051316_r, k051316_w, 0x00ff) // Foreground
@ -581,7 +577,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( wecleman_sub_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( wecleman_sub_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x00ffff) AM_ROM // ROM AM_RANGE(0x000000, 0x00ffff) AM_ROM // ROM
AM_RANGE(0x060000, 0x060fff) AM_RAM AM_BASE(&wecleman_roadram) AM_SIZE(&wecleman_roadram_size) // Road AM_RANGE(0x060000, 0x060fff) AM_RAM AM_BASE_MEMBER(wecleman_state, roadram) AM_SIZE_MEMBER(wecleman_state, roadram_size) // Road
AM_RANGE(0x070000, 0x073fff) AM_RAM AM_SHARE("share1") // RAM (Shared with main CPU) AM_RANGE(0x070000, 0x073fff) AM_RAM AM_SHARE("share1") // RAM (Shared with main CPU)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -592,7 +588,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( hotchase_sub_map, ADDRESS_SPACE_PROGRAM, 16 ) static ADDRESS_MAP_START( hotchase_sub_map, ADDRESS_SPACE_PROGRAM, 16 )
AM_RANGE(0x000000, 0x01ffff) AM_ROM // ROM AM_RANGE(0x000000, 0x01ffff) AM_ROM // ROM
AM_RANGE(0x020000, 0x020fff) AM_RAM AM_BASE(&wecleman_roadram) AM_SIZE(&wecleman_roadram_size) // Road AM_RANGE(0x020000, 0x020fff) AM_RAM AM_BASE_MEMBER(wecleman_state, roadram) AM_SIZE_MEMBER(wecleman_state, roadram_size) // Road
AM_RANGE(0x040000, 0x043fff) AM_RAM AM_SHARE("share1") // Shared with main CPU AM_RANGE(0x040000, 0x043fff) AM_RAM AM_SHARE("share1") // Shared with main CPU
AM_RANGE(0x060000, 0x060fff) AM_RAM // RAM AM_RANGE(0x060000, 0x060fff) AM_RAM // RAM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -615,12 +611,14 @@ WRITE16_HANDLER( wecleman_soundlatch_w )
/* Protection - an external multiplyer connected to the sound CPU */ /* Protection - an external multiplyer connected to the sound CPU */
static READ8_HANDLER( multiply_r ) static READ8_HANDLER( multiply_r )
{ {
return (multiply_reg[0] * multiply_reg[1]) & 0xFF; wecleman_state *state = space->machine->driver_data<wecleman_state>();
return (state->multiply_reg[0] * state->multiply_reg[1]) & 0xFF;
} }
static WRITE8_HANDLER( multiply_w ) static WRITE8_HANDLER( multiply_w )
{ {
multiply_reg[offset] = data; wecleman_state *state = space->machine->driver_data<wecleman_state>();
state->multiply_reg[offset] = data;
} }
/* K007232 registers reminder: /* K007232 registers reminder:
@ -1033,7 +1031,7 @@ static MACHINE_RESET( wecleman )
k007232_set_bank( machine->device("konami"), 0, 1 ); k007232_set_bank( machine->device("konami"), 0, 1 );
} }
static MACHINE_CONFIG_START( wecleman, driver_device ) static MACHINE_CONFIG_START( wecleman, wecleman_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 10000000) /* Schems show 10MHz */ MCFG_CPU_ADD("maincpu", M68000, 10000000) /* Schems show 10MHz */
@ -1104,7 +1102,7 @@ static const k051316_interface hotchase_k051316_intf_1 =
hotchase_zoom_callback_1 hotchase_zoom_callback_1
}; };
static MACHINE_CONFIG_START( hotchase, driver_device ) static MACHINE_CONFIG_START( hotchase, wecleman_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", M68000, 10000000) /* 10 MHz - PCB is drawn in one set's readme */ MCFG_CPU_ADD("maincpu", M68000, 10000000) /* 10 MHz - PCB is drawn in one set's readme */
@ -1245,6 +1243,7 @@ static void bitswap(running_machine *machine,UINT8 *src,size_t len,int _14,int _
/* Unpack sprites data and do some patching */ /* Unpack sprites data and do some patching */
static DRIVER_INIT( wecleman ) static DRIVER_INIT( wecleman )
{ {
wecleman_state *state = machine->driver_data<wecleman_state>();
int i, len; int i, len;
UINT8 *RAM; UINT8 *RAM;
// UINT16 *RAM1 = (UINT16 *) machine->region("maincpu")->base(); /* Main CPU patches */ // UINT16 *RAM1 = (UINT16 *) machine->region("maincpu")->base(); /* Main CPU patches */
@ -1281,7 +1280,7 @@ static DRIVER_INIT( wecleman )
bitswap(machine, machine->region("gfx3")->base(), machine->region("gfx3")->bytes(), bitswap(machine, machine->region("gfx3")->base(), machine->region("gfx3")->bytes(),
20,19,18,17,16,15,14,7,12,4,2,5,6,13,8,9,11,3,10,1,0); 20,19,18,17,16,15,14,7,12,4,2,5,6,13,8,9,11,3,10,1,0);
spr_color_offs = 0x40; state->spr_color_offs = 0x40;
} }
@ -1388,6 +1387,7 @@ static void hotchase_sprite_decode( running_machine *machine, int num16_banks, i
/* Unpack sprites data and do some patching */ /* Unpack sprites data and do some patching */
static DRIVER_INIT( hotchase ) static DRIVER_INIT( hotchase )
{ {
wecleman_state *state = machine->driver_data<wecleman_state>();
// UINT16 *RAM1 = (UINT16) machine->region("maincpu")->base(); /* Main CPU patches */ // UINT16 *RAM1 = (UINT16) machine->region("maincpu")->base(); /* Main CPU patches */
// RAM[0x1140/2] = 0x0015; RAM[0x195c/2] = 0x601A; // faster self test // RAM[0x1140/2] = 0x0015; RAM[0x195c/2] = 0x601A; // faster self test
@ -1405,7 +1405,7 @@ static DRIVER_INIT( hotchase )
RAM = machine->region("gfx3")->base(); RAM = machine->region("gfx3")->base();
memcpy(&RAM[0], &RAM[0x10000/2], 0x10000/2); memcpy(&RAM[0], &RAM[0x10000/2], 0x10000/2);
spr_color_offs = 0; state->spr_color_offs = 0;
} }

View File

@ -176,7 +176,22 @@ Check gticlub.c for details on the bottom board.
#include "video/konicdev.h" #include "video/konicdev.h"
#include "video/gticlub.h" #include "video/gticlub.h"
static UINT8 led_reg0, led_reg1;
class zr107_state : public driver_device
{
public:
zr107_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 led_reg0;
UINT8 led_reg1;
int ccu_vcth;
int ccu_vctl;
UINT32 *workram;
UINT32 *sharc_dataram;
};
@ -189,6 +204,7 @@ static VIDEO_START( jetwave )
static VIDEO_UPDATE( jetwave ) static VIDEO_UPDATE( jetwave )
{ {
zr107_state *state = screen->machine->driver_data<zr107_state>();
device_t *k001604 = screen->machine->device("k001604"); device_t *k001604 = screen->machine->device("k001604");
bitmap_fill(bitmap, cliprect, screen->machine->pens[0]); bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
@ -197,8 +213,8 @@ static VIDEO_UPDATE( jetwave )
k001604_draw_front_layer(k001604, bitmap, cliprect); k001604_draw_front_layer(k001604, bitmap, cliprect);
draw_7segment_led(bitmap, 3, 3, led_reg0); draw_7segment_led(bitmap, 3, 3, state->led_reg0);
draw_7segment_led(bitmap, 9, 3, led_reg1); draw_7segment_led(bitmap, 9, 3, state->led_reg1);
sharc_set_flag_input(screen->machine->device("dsp"), 1, ASSERT_LINE); sharc_set_flag_input(screen->machine->device("dsp"), 1, ASSERT_LINE);
return 0; return 0;
@ -241,6 +257,7 @@ static VIDEO_START( zr107 )
static VIDEO_UPDATE( zr107 ) static VIDEO_UPDATE( zr107 )
{ {
zr107_state *state = screen->machine->driver_data<zr107_state>();
device_t *k056832 = screen->machine->device("k056832"); device_t *k056832 = screen->machine->device("k056832");
bitmap_fill(bitmap, cliprect, screen->machine->pens[0]); bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
@ -248,8 +265,8 @@ static VIDEO_UPDATE( zr107 )
K001005_draw(bitmap, cliprect); K001005_draw(bitmap, cliprect);
k056832_tilemap_draw(k056832, bitmap, cliprect, 0, 0, 0); k056832_tilemap_draw(k056832, bitmap, cliprect, 0, 0, 0);
draw_7segment_led(bitmap, 3, 3, led_reg0); draw_7segment_led(bitmap, 3, 3, state->led_reg0);
draw_7segment_led(bitmap, 9, 3, led_reg1); draw_7segment_led(bitmap, 9, 3, state->led_reg1);
sharc_set_flag_input(screen->machine->device("dsp"), 1, ASSERT_LINE); sharc_set_flag_input(screen->machine->device("dsp"), 1, ASSERT_LINE);
return 0; return 0;
@ -280,14 +297,15 @@ static READ8_HANDLER( sysreg_r )
static WRITE8_HANDLER( sysreg_w ) static WRITE8_HANDLER( sysreg_w )
{ {
zr107_state *state = space->machine->driver_data<zr107_state>();
switch (offset) switch (offset)
{ {
case 0: /* LED Register 0 */ case 0: /* LED Register 0 */
led_reg0 = data; state->led_reg0 = data;
break; break;
case 1: /* LED Register 1 */ case 1: /* LED Register 1 */
led_reg1 = data; state->led_reg1 = data;
break; break;
case 2: /* Parallel data register */ case 2: /* Parallel data register */
@ -341,10 +359,9 @@ static WRITE8_HANDLER( sysreg_w )
} }
} }
static int ccu_vcth = 0;
static int ccu_vctl = 0;
static READ32_HANDLER( ccu_r ) static READ32_HANDLER( ccu_r )
{ {
zr107_state *state = space->machine->driver_data<zr107_state>();
UINT32 r = 0; UINT32 r = 0;
switch (offset) switch (offset)
{ {
@ -353,14 +370,14 @@ static READ32_HANDLER( ccu_r )
// Midnight Run polls the vertical counter in vblank // Midnight Run polls the vertical counter in vblank
if (ACCESSING_BITS_24_31) if (ACCESSING_BITS_24_31)
{ {
ccu_vcth ^= 0xff; state->ccu_vcth ^= 0xff;
r |= ccu_vcth << 24; r |= state->ccu_vcth << 24;
} }
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
{ {
ccu_vctl++; state->ccu_vctl++;
ccu_vctl &= 0x1ff; state->ccu_vctl &= 0x1ff;
r |= (ccu_vctl >> 2) << 8; r |= (state->ccu_vctl >> 2) << 8;
} }
} }
} }
@ -375,18 +392,18 @@ static WRITE32_HANDLER( ccu_w )
/******************************************************************/ /******************************************************************/
static UINT32 *workram;
static MACHINE_START( zr107 ) static MACHINE_START( zr107 )
{ {
zr107_state *state = machine->driver_data<zr107_state>();
/* set conservative DRC options */ /* set conservative DRC options */
ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS); ppcdrc_set_options(machine->device("maincpu"), PPCDRC_COMPATIBLE_OPTIONS);
/* configure fast RAM regions for DRC */ /* configure fast RAM regions for DRC */
ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x000fffff, FALSE, workram); ppcdrc_add_fastram(machine->device("maincpu"), 0x00000000, 0x000fffff, FALSE, state->workram);
} }
static ADDRESS_MAP_START( zr107_map, ADDRESS_SPACE_PROGRAM, 32 ) static ADDRESS_MAP_START( zr107_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x00000000, 0x000fffff) AM_RAM AM_BASE(&workram) /* Work RAM */ AM_RANGE(0x00000000, 0x000fffff) AM_RAM AM_BASE_MEMBER(zr107_state, workram) /* Work RAM */
AM_RANGE(0x74000000, 0x74003fff) AM_DEVREADWRITE("k056832", k056832_ram_long_r, k056832_ram_long_w) AM_RANGE(0x74000000, 0x74003fff) AM_DEVREADWRITE("k056832", k056832_ram_long_r, k056832_ram_long_w)
AM_RANGE(0x74020000, 0x7402003f) AM_DEVREADWRITE("k056832", k056832_long_r, k056832_long_w) AM_RANGE(0x74020000, 0x7402003f) AM_DEVREADWRITE("k056832", k056832_long_r, k056832_long_w)
AM_RANGE(0x74060000, 0x7406003f) AM_READWRITE(ccu_r, ccu_w) AM_RANGE(0x74060000, 0x7406003f) AM_READWRITE(ccu_r, ccu_w)
@ -474,16 +491,17 @@ static const k054539_interface k054539_config =
/*****************************************************************************/ /*****************************************************************************/
static UINT32 *sharc_dataram;
static READ32_HANDLER( dsp_dataram_r ) static READ32_HANDLER( dsp_dataram_r )
{ {
return sharc_dataram[offset] & 0xffff; zr107_state *state = space->machine->driver_data<zr107_state>();
return state->sharc_dataram[offset] & 0xffff;
} }
static WRITE32_HANDLER( dsp_dataram_w ) static WRITE32_HANDLER( dsp_dataram_w )
{ {
sharc_dataram[offset] = data; zr107_state *state = space->machine->driver_data<zr107_state>();
state->sharc_dataram[offset] = data;
} }
static ADDRESS_MAP_START( sharc_map, ADDRESS_SPACE_DATA, 32 ) static ADDRESS_MAP_START( sharc_map, ADDRESS_SPACE_DATA, 32 )
@ -717,7 +735,7 @@ static MACHINE_RESET( zr107 )
cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE); cputag_set_input_line(machine, "dsp", INPUT_LINE_RESET, ASSERT_LINE);
} }
static MACHINE_CONFIG_START( zr107, driver_device ) static MACHINE_CONFIG_START( zr107, zr107_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */ MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */
@ -778,7 +796,7 @@ static const k001604_interface jetwave_k001604_intf =
0 /* slrasslt hack */ 0 /* slrasslt hack */
}; };
static MACHINE_CONFIG_START( jetwave, driver_device ) static MACHINE_CONFIG_START( jetwave, zr107_state )
/* basic machine hardware */ /* basic machine hardware */
MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */ MCFG_CPU_ADD("maincpu", PPC403GA, 64000000/2) /* PowerPC 403GA 32MHz */
@ -835,9 +853,10 @@ MACHINE_CONFIG_END
static void init_zr107(running_machine *machine) static void init_zr107(running_machine *machine)
{ {
sharc_dataram = auto_alloc_array(machine, UINT32, 0x100000/4); zr107_state *state = machine->driver_data<zr107_state>();
led_reg0 = led_reg1 = 0x7f; state->sharc_dataram = auto_alloc_array(machine, UINT32, 0x100000/4);
ccu_vcth = ccu_vctl = 0; state->led_reg0 = state->led_reg1 = 0x7f;
state->ccu_vcth = state->ccu_vctl = 0;
K001005_preprocess_texture_data(machine->region("gfx1")->base(), machine->region("gfx1")->bytes(), 0); K001005_preprocess_texture_data(machine->region("gfx1")->base(), machine->region("gfx1")->bytes(), 0);
} }

View File

@ -15,6 +15,7 @@ public:
UINT8 * banked_rom; UINT8 * banked_rom;
// UINT8 * paletteram_1000; // this currently uses generic palette handling // UINT8 * paletteram_1000; // this currently uses generic palette handling
// UINT8 * nvram; // this currently uses generic nvram handling // UINT8 * nvram; // this currently uses generic nvram handling
UINT8 *paletteram_1000;
/* video-related */ /* video-related */
int k88games_priority; int k88games_priority;

View File

@ -1,3 +1,5 @@
#include "machine/6522via.h"
class beezer_state : public driver_device class beezer_state : public driver_device
{ {
public: public:
@ -5,13 +7,16 @@ public:
: driver_device(machine, config) { } : driver_device(machine, config) { }
UINT8 *videoram; UINT8 *videoram;
int pbus;
int banklatch;
int scanline;
}; };
/*----------- defined in machine/beezer.c -----------*/ /*----------- defined in machine/beezer.c -----------*/
//extern const via6522_interface b_via_0_interface; extern const via6522_interface b_via_0_interface;
//extern const via6522_interface b_via_1_interface; extern const via6522_interface b_via_1_interface;
DRIVER_INIT( beezer ); DRIVER_INIT( beezer );
WRITE8_HANDLER( beezer_bankswitch_w ); WRITE8_HANDLER( beezer_bankswitch_w );

View File

@ -1,6 +1,24 @@
/*----------- defined in video/djmain.c -----------*/ class djmain_state : public driver_device
{
public:
djmain_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT32 *djmain_obj_ram; int sndram_bank;
UINT8 *sndram;
int turntable_select;
UINT8 turntable_last_pos[2];
UINT16 turntable_pos[2];
UINT8 pending_vb_int;
UINT16 v_ctrl;
UINT32 obj_regs[0xa0/4];
const UINT8 *ide_user_password;
const UINT8 *ide_master_password;
UINT32 *obj_ram;
};
/*----------- defined in video/djmain.c -----------*/
VIDEO_UPDATE( djmain ); VIDEO_UPDATE( djmain );
VIDEO_START( djmain ); VIDEO_START( djmain );

View File

@ -5,16 +5,32 @@
***************************************************************************/ ***************************************************************************/
class fastfred_state : public driver_device
{
public:
fastfred_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 imago_sprites[0x800*3];
UINT16 imago_sprites_address;
UINT8 imago_sprites_bank;
int hardware_type;
UINT8 *videoram;
UINT8 *spriteram;
size_t spriteram_size;
UINT8 *attributesram;
UINT8 *background_color;
UINT8 *imago_fg_videoram;
UINT16 charbank;
UINT8 colorbank;
tilemap_t *bg_tilemap;
tilemap_t *fg_tilemap;
tilemap_t *web_tilemap;
};
/*----------- defined in video/fastfred.c -----------*/ /*----------- defined in video/fastfred.c -----------*/
extern int fastfred_hardware_type;
extern UINT8 *fastfred_videoram;
extern UINT8 *fastfred_spriteram;
extern size_t fastfred_spriteram_size;
extern UINT8 *fastfred_attributesram;
extern UINT8 *fastfred_background_color;
PALETTE_INIT( fastfred ); PALETTE_INIT( fastfred );
VIDEO_START( fastfred ); VIDEO_START( fastfred );
WRITE8_HANDLER( fastfred_videoram_w ); WRITE8_HANDLER( fastfred_videoram_w );
@ -27,7 +43,6 @@ WRITE8_HANDLER( fastfred_flip_screen_x_w );
WRITE8_HANDLER( fastfred_flip_screen_y_w ); WRITE8_HANDLER( fastfred_flip_screen_y_w );
VIDEO_UPDATE( fastfred ); VIDEO_UPDATE( fastfred );
extern UINT8 *imago_fg_videoram;
VIDEO_START( imago ); VIDEO_START( imago );
VIDEO_UPDATE( imago ); VIDEO_UPDATE( imago );
WRITE8_HANDLER( imago_fg_videoram_w ); WRITE8_HANDLER( imago_fg_videoram_w );

View File

@ -1,3 +1,19 @@
class hexion_state : public driver_device
{
public:
hexion_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *vram[2];
UINT8 *unkram;
int bankctrl;
int rambank;
int pmcbank;
int gfxrom_select;
tilemap_t *bg_tilemap[2];
};
/*----------- defined in video/hexion.c -----------*/ /*----------- defined in video/hexion.c -----------*/
VIDEO_START( hexion ); VIDEO_START( hexion );

View File

@ -1,7 +1,89 @@
typedef void (*tgp_func)(running_machine *machine);
enum {FIFO_SIZE = 256};
enum {MAT_STACK_SIZE = 32};
class model1_state : public driver_device
{
public:
model1_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
struct view *view;
struct point *pointdb, *pointpt;
struct quad_m1 *quaddb, *quadpt;
struct quad_m1 **quadind;
int sound_irq;
int to_68k[8];
int fifo_wptr;
int fifo_rptr;
int last_irq;
UINT16 *mr;
UINT16 *mr2;
int dump;
UINT16 *display_list0;
UINT16 *display_list1;
UINT16 *color_xlat;
offs_t pushpc;
int fifoin_rpos;
int fifoin_wpos;
UINT32 fifoin_data[FIFO_SIZE];
int swa;
int fifoin_cbcount;
tgp_func fifoin_cb;
INT32 fifoout_rpos;
INT32 fifoout_wpos;
UINT32 fifoout_data[FIFO_SIZE];
UINT32 list_length;
float cmat[12];
float mat_stack[MAT_STACK_SIZE][12];
float mat_vector[21][12];
INT32 mat_stack_pos;
float acc;
float tgp_vf_xmin;
float tgp_vf_xmax;
float tgp_vf_zmin;
float tgp_vf_zmax;
float tgp_vf_ygnd;
float tgp_vf_yflr;
float tgp_vf_yjmp;
float tgp_vr_circx;
float tgp_vr_circy;
float tgp_vr_circrad;
float tgp_vr_cbox[12];
int tgp_vr_select;
UINT16 ram_adr;
UINT16 ram_latch[2];
UINT16 ram_scanadr;
UINT32 *ram_data;
float tgp_vr_base[4];
int puuu;
int ccount;
UINT32 copro_r;
UINT32 copro_w;
int copro_fifoout_rpos;
int copro_fifoout_wpos;
UINT32 copro_fifoout_data[FIFO_SIZE];
int copro_fifoout_num;
int copro_fifoin_rpos;
int copro_fifoin_wpos;
UINT32 copro_fifoin_data[FIFO_SIZE];
int copro_fifoin_num;
UINT32 vr_r;
UINT32 vr_w;
UINT16 listctl[2];
UINT16 *glist;
int render_done;
UINT16 *tgp_ram;
UINT16 *paletteram16;
UINT32 *poly_rom;
UINT32 *poly_ram;
};
/*----------- defined in machine/model1.c -----------*/ /*----------- defined in machine/model1.c -----------*/
extern const mb86233_cpu_core model1_vr_tgp_config; extern const mb86233_cpu_core model1_vr_tgp_config;
extern int model1_dump;
READ16_HANDLER( model1_tgp_copro_r ); READ16_HANDLER( model1_tgp_copro_r );
WRITE16_HANDLER( model1_tgp_copro_w ); WRITE16_HANDLER( model1_tgp_copro_w );
@ -27,9 +109,6 @@ void model1_tgp_reset(running_machine *machine, int swa);
/*----------- defined in video/model1.c -----------*/ /*----------- defined in video/model1.c -----------*/
extern UINT16 *model1_display_list0, *model1_display_list1;
extern UINT16 *model1_color_xlat;
VIDEO_START(model1); VIDEO_START(model1);
VIDEO_UPDATE(model1); VIDEO_UPDATE(model1);
VIDEO_EOF(model1); VIDEO_EOF(model1);

View File

@ -1,13 +1,71 @@
/*----------- defined in drivers/model2.c -----------*/ #include "video/poly.h"
extern UINT32 geo_read_start_address;
extern UINT32 geo_write_start_address; typedef struct _raster_state raster_state;
extern UINT32 *model2_bufferram; typedef struct _geo_state geo_state;
extern UINT32 *model2_colorxlat;
extern UINT32 *model2_textureram0;
extern UINT32 *model2_textureram1; class model2_state : public driver_device
extern UINT32 *model2_lumaram; {
extern UINT32 *model2_paletteram32; public:
model2_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT32 *workram;
UINT32 intreq;
UINT32 intena;
UINT32 coproctl;
UINT32 coprocnt;
UINT32 geoctl;
UINT32 geocnt;
UINT16 *soundram;
UINT32 timervals[4];
UINT32 timerorig[4];
int timerrun[4];
timer_device *timers[4];
int ctrlmode;
int analog_channel;
UINT32 *tgp_program;
int dsp_type;
int copro_fifoin_rpos;
int copro_fifoin_wpos;
UINT32 *copro_fifoin_data;
int copro_fifoin_num;
int copro_fifoout_rpos;
int copro_fifoout_wpos;
UINT32 *copro_fifoout_data;
int copro_fifoout_num;
UINT16 cmd_data;
UINT8 driveio_comm_data;
int iop_write_num;
UINT32 iop_data;
int geo_iop_write_num;
UINT32 geo_iop_data;
int to_68k;
int protstate;
int protpos;
UINT8 protram[256];
int prot_a;
int maxxstate;
UINT32 netram[0x8000/4];
int zflagi;
int zflag;
int sysres;
int scsp_last_line;
int jnet_time_out;
UINT32 geo_read_start_address;
UINT32 geo_write_start_address;
UINT32 *bufferram;
UINT32 *colorxlat;
UINT32 *textureram0;
UINT32 *textureram1;
UINT32 *lumaram;
UINT32 *paletteram32;
poly_manager *poly;
raster_state *raster;
geo_state *geo;
bitmap_t *sys24_bitmap;
};
/*----------- defined in video/model2.c -----------*/ /*----------- defined in video/model2.c -----------*/
@ -15,4 +73,4 @@ extern UINT32 *model2_paletteram32;
VIDEO_START(model2); VIDEO_START(model2);
VIDEO_UPDATE(model2); VIDEO_UPDATE(model2);
void model2_3d_set_zclip( UINT8 clip ); void model2_3d_set_zclip( running_machine *machine, UINT8 clip );

View File

@ -1,25 +1,123 @@
/*----------- defined in drivers/model3.c -----------*/ #include "video/poly.h"
extern UINT32 *model3_vrom; typedef float MATRIX[4][4];
extern int model3_step; typedef float VECTOR[4];
typedef float VECTOR3[3];
typedef struct {
float x,y,z,d;
} PLANE;
typedef struct _cached_texture cached_texture;
class model3_state : public driver_device
{
public:
model3_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 irq_enable;
UINT8 irq_state;
UINT8 scsi_irq_state;
UINT64 *work_ram;
int crom_bank;
int controls_bank;
UINT32 real3d_device_id;
UINT16 *soundram;
UINT32 mpc105_regs[0x40];
UINT32 mpc105_addr;
int pci_bus;
int pci_device;
int pci_function;
int pci_reg;
UINT32 mpc106_regs[0x40];
UINT32 mpc106_addr;
UINT32 dma_data;
UINT32 dma_status;
UINT32 dma_source;
UINT32 dma_dest;
UINT32 dma_endian;
UINT32 dma_irq;
UINT64 controls_2;
UINT64 controls_3;
UINT8 serial_fifo1;
UINT8 serial_fifo2;
int lightgun_reg_sel;
int adc_channel;
UINT64 real3d_status;
UINT64 *network_ram;
int prot_data_ptr;
int scsp_last_line;
int vblank;
UINT32 *vrom;
int step;
UINT64 *paletteram64;
int m3_step;
INT32 tap_state;
UINT64 ir;
UINT8 id_data[32];
INT32 id_size;
int tdo;
UINT8 layer_enable;
UINT32 layer_modulate_r;
UINT32 layer_modulate_g;
UINT32 layer_modulate_b;
UINT32 layer_modulate1;
UINT32 layer_modulate2;
UINT64 layer_scroll[2];
UINT64 *m3_char_ram;
UINT64 *m3_tile_ram;
UINT32 *texture_fifo;
int texture_fifo_pos;
UINT16 *texture_ram[2];
UINT32 *display_list_ram;
UINT32 *culling_ram;
UINT32 *polygon_ram;
UINT16 *pal_lookup;
int real3d_display_list;
bitmap_t *bitmap3d;
bitmap_t *zbuffer;
rectangle clip3d;
rectangle *screen_clip;
VECTOR3 parallel_light;
float parallel_light_intensity;
float ambient_light_intensity;
poly_manager *poly;
int list_depth;
int tick;
int debug_layer_disable;
UINT64 vid_reg0;
int matrix_stack_ptr;
MATRIX *matrix_stack;
MATRIX coordinate_system;
float viewport_focal_length;
int viewport_region_x;
int viewport_region_y;
int viewport_region_width;
int viewport_region_height;
PLANE clip_plane[5];
UINT32 matrix_base_address;
cached_texture *texcache[2][1024/32][2048/32];
};
/*----------- defined in drivers/model3.c -----------*/
void model3_set_irq_line(running_machine *machine, UINT8 bit, int state); void model3_set_irq_line(running_machine *machine, UINT8 bit, int state);
/*----------- defined in machine/model3.c -----------*/ /*----------- defined in machine/model3.c -----------*/
extern void model3_machine_init(int step); extern void model3_machine_init(running_machine *machine, int step);
extern int model3_tap_read(void); extern int model3_tap_read(running_machine *machine);
extern void model3_tap_write(int tck, int tms, int tdi, int trst); extern void model3_tap_write(running_machine *machine, int tck, int tms, int tdi, int trst);
extern void model3_tap_reset(void); extern void model3_tap_reset(running_machine *machine);
extern READ32_HANDLER(rtc72421_r); extern READ32_HANDLER(rtc72421_r);
extern WRITE32_HANDLER(rtc72421_w); extern WRITE32_HANDLER(rtc72421_w);
/*----------- defined in video/model3.c -----------*/ /*----------- defined in video/model3.c -----------*/
extern UINT64 *paletteram64;
READ64_HANDLER(model3_char_r); READ64_HANDLER(model3_char_r);
WRITE64_HANDLER(model3_char_w); WRITE64_HANDLER(model3_char_w);
READ64_HANDLER(model3_tile_r); READ64_HANDLER(model3_tile_r);

View File

@ -1,3 +1,26 @@
class mystwarr_state : public driver_device
{
public:
mystwarr_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT16 *gx_workram;
UINT8 mw_irq_control;
int cur_sound_region;
int layer_colorbase[6];
int oinprion;
int cbparam;
int sprite_colorbase;
int sub1_colorbase;
int last_psac_colorbase;
int gametype;
int roz_enable;
int roz_rombank;
tilemap_t *ult_936_tilemap;
UINT16 clip;
};
/*----------- defined in video/mystwarr.c -----------*/ /*----------- defined in video/mystwarr.c -----------*/
VIDEO_START( gaiapols ); VIDEO_START( gaiapols );

View File

@ -6,13 +6,13 @@ public:
m_nvram(*this, "nvram") { } m_nvram(*this, "nvram") { }
required_shared_ptr<UINT8> m_nvram; required_shared_ptr<UINT8> m_nvram;
UINT8 *sndram;
UINT16 *workram;
UINT16 control;
INT32 gp2_irq_control;
INT32 pal;
}; };
/*----------- defined in drivers/qdrmfgp.c -----------*/
int qdrmfgp_get_palette(void);
/*----------- defined in video/qdrmfgp.c -----------*/ /*----------- defined in video/qdrmfgp.c -----------*/
VIDEO_START( qdrmfgp ); VIDEO_START( qdrmfgp );

View File

@ -5,6 +5,26 @@
*************************************************************************/ *************************************************************************/
class segag80v_state : public driver_device
{
public:
segag80v_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *mainram;
UINT8 has_usb;
UINT8 mult_data[2];
UINT16 mult_result;
UINT8 spinner_select;
UINT8 spinner_sign;
UINT8 spinner_count;
UINT8 *vectorram;
size_t vectorram_size;
int min_x;
int min_y;
};
/*----------- defined in audio/segag80v.c -----------*/ /*----------- defined in audio/segag80v.c -----------*/
WRITE8_HANDLER( elim1_sh_w ); WRITE8_HANDLER( elim1_sh_w );
@ -17,8 +37,5 @@ WRITE8_HANDLER( zektor2_sh_w );
/*----------- defined in video/segag80v.c -----------*/ /*----------- defined in video/segag80v.c -----------*/
extern UINT8 *segag80v_vectorram;
extern size_t segag80v_vectorram_size;
VIDEO_START( segag80v ); VIDEO_START( segag80v );
VIDEO_UPDATE( segag80v ); VIDEO_UPDATE( segag80v );

View File

@ -5,11 +5,57 @@
***************************************************************************/ ***************************************************************************/
/*----------- defined in drivers/segas32.c -----------*/ typedef void (*sys32_output_callback)(int which, UINT16 data);
struct layer_info
{
bitmap_t * bitmap;
UINT8 * transparent;
};
extern UINT8 *ga2_dpram;
extern UINT16 *system32_workram; class segas32_state : public driver_device
extern UINT16 *system32_protram; {
public:
segas32_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
UINT8 *z80_shared_ram;
UINT8 v60_irq_control[0x10];
timer_device *v60_irq_timer[2];
UINT8 sound_irq_control[4];
UINT8 sound_irq_input;
UINT8 sound_dummy_value;
UINT16 sound_bank;
UINT8 misc_io_data[2][0x10];
read16_space_func custom_io_r[2];
write16_space_func custom_io_w[2];
UINT8 analog_bank;
UINT8 analog_value[4];
UINT8 sonic_last[6];
sys32_output_callback sw1_output;
sys32_output_callback sw2_output;
sys32_output_callback sw3_output;
UINT16* dual_pcb_comms;
UINT8 *ga2_dpram;
UINT16 *system32_workram;
UINT16 *system32_protram;
UINT16 *system32_videoram;
UINT16 *system32_spriteram;
UINT16 *system32_paletteram[2];
UINT16 system32_displayenable[2];
UINT16 system32_tilebank_external;
UINT16 arescue_dsp_io[6];
UINT8 is_multi32;
struct cache_entry *cache_head;
struct layer_info layer_data[11];
UINT16 mixer_control[2][0x40];
UINT16 *solid_0000;
UINT16 *solid_ffff;
UINT8 sprite_render_count;
UINT8 sprite_control_latched[8];
UINT8 sprite_control[8];
UINT32 *spriteram_32bit;
};
/*----------- defined in machine/segas32.c -----------*/ /*----------- defined in machine/segas32.c -----------*/
@ -42,12 +88,6 @@ WRITE16_HANDLER( arescue_dsp_w );
/*----------- defined in video/segas32.c -----------*/ /*----------- defined in video/segas32.c -----------*/
extern UINT16 *system32_videoram;
extern UINT16 *system32_spriteram;
extern UINT16 *system32_paletteram[2];
extern UINT16 system32_displayenable[2];
extern UINT16 system32_tilebank_external;
VIDEO_START(system32); VIDEO_START(system32);
VIDEO_START(multi32); VIDEO_START(multi32);
VIDEO_UPDATE(system32); VIDEO_UPDATE(system32);

View File

@ -1,7 +1,17 @@
/*----------- defined in video/suprloco.c -----------*/ class suprloco_state : public driver_device
{
public:
suprloco_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *suprloco_videoram; UINT8 *videoram;
extern UINT8 *suprloco_scrollram; UINT8 *scrollram;
tilemap_t *bg_tilemap;
int control;
};
/*----------- defined in video/suprloco.c -----------*/
PALETTE_INIT( suprloco ); PALETTE_INIT( suprloco );
VIDEO_START( suprloco ); VIDEO_START( suprloco );

View File

@ -5,6 +5,25 @@ public:
: driver_device(machine, config) { } : driver_device(machine, config) { }
UINT8 *videoram; UINT8 *videoram;
void (*videomode_custom)(running_machine *machine, UINT8 data, UINT8 prevdata);
UINT8 mute_xor;
UINT8 *ram;
UINT8 dakkochn_mux_data;
UINT8 videomode_prev;
UINT8 mcu_control;
UINT8 *nob_mcu_status;
UINT8 *nob_mcu_latch;
UINT8 nob_maincpu_latch;
int nobb_inport23_step;
UINT8 *mix_collide;
UINT8 mix_collide_summary;
UINT8 *sprite_collide;
UINT8 sprite_collide_summary;
bitmap_t *sprite_bitmap;
UINT8 video_mode;
UINT8 videoram_bank;
tilemap_t *tilemap_page[8];
UINT8 tilemap_pages;
}; };

View File

@ -1,15 +1,26 @@
/*----------- defined in video/tp84.c -----------*/ class tp84_state : public driver_device
{
public:
tp84_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern UINT8 *tp84_bg_videoram; cpu_device *audiocpu;
extern UINT8 *tp84_bg_colorram; UINT8 *bg_videoram;
extern UINT8 *tp84_fg_videoram; UINT8 *bg_colorram;
extern UINT8 *tp84_fg_colorram; UINT8 *fg_videoram;
extern UINT8 *tp84_spriteram; UINT8 *fg_colorram;
extern UINT8 *tp84_scroll_x; UINT8 *spriteram;
extern UINT8 *tp84_scroll_y; UINT8 *scroll_x;
extern UINT8 *tp84_palette_bank; UINT8 *scroll_y;
extern UINT8 *tp84_flipscreen_x; UINT8 *palette_bank;
extern UINT8 *tp84_flipscreen_y; UINT8 *flipscreen_x;
UINT8 *flipscreen_y;
tilemap_t *bg_tilemap;
tilemap_t *fg_tilemap;
};
/*----------- defined in video/tp84.c -----------*/
WRITE8_HANDLER( tp84_spriteram_w ); WRITE8_HANDLER( tp84_spriteram_w );
READ8_HANDLER( tp84_scanline_r ); READ8_HANDLER( tp84_scanline_r );

View File

@ -5,17 +5,31 @@ public:
: driver_device(machine, config) { } : driver_device(machine, config) { }
UINT16 *videoram; UINT16 *videoram;
UINT16 CPUA_register;
UINT16 CPUB_register;
UINT16 sound_command;
int cuebrickj_nvram_bank;
UINT16 cuebrickj_nvram[0x400*0x20];
UINT16 custom_video;
UINT16 *gfx_rom;
UINT16 *text_ram;
UINT16 *sprite_gfx_ram;
UINT16 *tile_gfx_ram;
UINT16 sprite_buffer[0x800];
emu_timer *sprite_timer;
int sprite_busy;
int need_process_spriteram;
UINT16 gfx_bank;
UINT16 scrollx[3];
UINT16 scrolly[3];
UINT16 video_register;
tilemap_t *text_tilemap;
}; };
/*----------- defined in drivers/twin16.c -----------*/ /*----------- defined in drivers/twin16.c -----------*/
extern UINT16 twin16_custom_video; int twin16_spriteram_process_enable( running_machine *machine );
extern UINT16 *twin16_gfx_rom;
extern UINT16 *twin16_text_ram;
extern UINT16 *twin16_sprite_gfx_ram;
extern UINT16 *twin16_tile_gfx_ram;
int twin16_spriteram_process_enable( void );
/*----------- defined in video/twin16.c -----------*/ /*----------- defined in video/twin16.c -----------*/
@ -30,4 +44,4 @@ VIDEO_START( twin16 );
VIDEO_UPDATE( twin16 ); VIDEO_UPDATE( twin16 );
VIDEO_EOF( twin16 ); VIDEO_EOF( twin16 );
void twin16_spriteram_process( running_machine* ); void twin16_spriteram_process( running_machine *machine );

View File

@ -1,14 +1,46 @@
/*----------- defined in drivers/wecleman.c -----------*/ class wecleman_state : public driver_device
{
public:
wecleman_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
extern int wecleman_selected_ip, wecleman_irqctrl; UINT16 *blitter_regs;
int multiply_reg[2];
UINT16 *protection_ram;
int spr_color_offs;
int prot_state;
int selected_ip;
int irqctrl;
UINT16 *videostatus;
UINT16 *pageram;
UINT16 *txtram;
UINT16 *roadram;
size_t roadram_size;
int bgpage[4];
int fgpage[4];
const int *gfx_bank;
tilemap_t *bg_tilemap;
tilemap_t *fg_tilemap;
tilemap_t *txt_tilemap;
int *spr_idx_list;
int *spr_pri_list;
int *t32x32pm;
int gameid;
int spr_offsx;
int spr_offsy;
int spr_count;
UINT16 *rgb_half;
int cloud_blend;
int cloud_ds;
int cloud_visible;
pen_t black_pen;
struct sprite *sprite_list;
struct sprite **spr_ptr_list;
};
/*----------- defined in video/wecleman.c -----------*/ /*----------- defined in video/wecleman.c -----------*/
extern UINT16 *wecleman_videostatus;
extern UINT16 *wecleman_pageram, *wecleman_txtram, *wecleman_roadram;
extern size_t wecleman_roadram_size;
WRITE16_HANDLER( hotchase_paletteram16_SBGRBBBBGGGGRRRR_word_w ); WRITE16_HANDLER( hotchase_paletteram16_SBGRBBBBGGGGRRRR_word_w );
WRITE16_HANDLER( wecleman_paletteram16_SSSSBBBBGGGGRRRR_word_w ); WRITE16_HANDLER( wecleman_paletteram16_SSSSBBBBGGGGRRRR_word_w );
WRITE16_HANDLER( wecleman_videostatus_w ); WRITE16_HANDLER( wecleman_videostatus_w );

View File

@ -3,11 +3,6 @@
#include "machine/6522via.h" #include "machine/6522via.h"
#include "includes/beezer.h" #include "includes/beezer.h"
extern const via6522_interface b_via_0_interface;
extern const via6522_interface b_via_1_interface;
static int pbus;
static int banklatch;
static READ8_DEVICE_HANDLER( b_via_0_pa_r ); static READ8_DEVICE_HANDLER( b_via_0_pa_r );
static READ8_DEVICE_HANDLER( b_via_0_pb_r ); static READ8_DEVICE_HANDLER( b_via_0_pb_r );
@ -93,16 +88,19 @@ static READ_LINE_DEVICE_HANDLER( b_via_0_ca2_r )
static READ8_DEVICE_HANDLER( b_via_0_pa_r ) static READ8_DEVICE_HANDLER( b_via_0_pa_r )
{ {
return (banklatch&0x38)<<2; // return X,Y,Z bits TODO: the Z bit connects somewhere else... where? beezer_state *state = device->machine->driver_data<beezer_state>();
return (state->banklatch&0x38)<<2; // return X,Y,Z bits TODO: the Z bit connects somewhere else... where?
} }
static READ8_DEVICE_HANDLER( b_via_0_pb_r ) static READ8_DEVICE_HANDLER( b_via_0_pb_r )
{ {
return pbus; beezer_state *state = device->machine->driver_data<beezer_state>();
return state->pbus;
} }
static WRITE8_DEVICE_HANDLER( b_via_0_pa_w ) static WRITE8_DEVICE_HANDLER( b_via_0_pa_w )
{ {
beezer_state *state = device->machine->driver_data<beezer_state>();
if ((data & 0x08) == 0) if ((data & 0x08) == 0)
cputag_set_input_line(device->machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE); cputag_set_input_line(device->machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
else else
@ -113,16 +111,16 @@ static WRITE8_DEVICE_HANDLER( b_via_0_pa_w )
switch (data & 0x03) switch (data & 0x03)
{ {
case 0: case 0:
pbus = input_port_read(device->machine, "IN0"); state->pbus = input_port_read(device->machine, "IN0");
break; break;
case 1: case 1:
pbus = input_port_read(device->machine, "IN1") | (input_port_read(device->machine, "IN2") << 4); state->pbus = input_port_read(device->machine, "IN1") | (input_port_read(device->machine, "IN2") << 4);
break; break;
case 2: case 2:
pbus = input_port_read(device->machine, "DSWB"); state->pbus = input_port_read(device->machine, "DSWB");
break; break;
case 3: case 3:
pbus = input_port_read(device->machine, "DSWA"); // Technically DSWA isn't populated on the board and is pulled to 0xFF with resistor pack, but there IS a DSWA port in the driver so we may as well use it. state->pbus = input_port_read(device->machine, "DSWA"); // Technically DSWA isn't populated on the board and is pulled to 0xFF with resistor pack, but there IS a DSWA port in the driver so we may as well use it.
break; break;
} }
} }
@ -130,12 +128,14 @@ static WRITE8_DEVICE_HANDLER( b_via_0_pa_w )
static WRITE8_DEVICE_HANDLER( b_via_0_pb_w ) static WRITE8_DEVICE_HANDLER( b_via_0_pb_w )
{ {
pbus = data; beezer_state *state = device->machine->driver_data<beezer_state>();
state->pbus = data;
} }
static READ8_DEVICE_HANDLER( b_via_1_pa_r ) static READ8_DEVICE_HANDLER( b_via_1_pa_r )
{ {
return pbus; beezer_state *state = device->machine->driver_data<beezer_state>();
return state->pbus;
} }
static READ8_DEVICE_HANDLER( b_via_1_pb_r ) static READ8_DEVICE_HANDLER( b_via_1_pb_r )
@ -145,7 +145,8 @@ static READ8_DEVICE_HANDLER( b_via_1_pb_r )
static WRITE8_DEVICE_HANDLER( b_via_1_pa_w ) static WRITE8_DEVICE_HANDLER( b_via_1_pa_w )
{ {
pbus = data; beezer_state *state = device->machine->driver_data<beezer_state>();
state->pbus = data;
} }
static WRITE8_DEVICE_HANDLER( b_via_1_pb_w ) static WRITE8_DEVICE_HANDLER( b_via_1_pb_w )
@ -157,13 +158,15 @@ static WRITE8_DEVICE_HANDLER( b_via_1_pb_w )
DRIVER_INIT( beezer ) DRIVER_INIT( beezer )
{ {
pbus = 0; beezer_state *state = machine->driver_data<beezer_state>();
banklatch = 0; state->pbus = 0;
state->banklatch = 0;
} }
WRITE8_HANDLER( beezer_bankswitch_w ) WRITE8_HANDLER( beezer_bankswitch_w )
{ {
banklatch = data&0x3f; // latched 'x,y,z' plus bank bits in ls174 @ 4H beezer_state *state = space->machine->driver_data<beezer_state>();
state->banklatch = data&0x3f; // latched 'x,y,z' plus bank bits in ls174 @ 4H
if ((data & 0x07) == 0) if ((data & 0x07) == 0)
{ {
via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0"); via6522_device *via_0 = space->machine->device<via6522_device>("via6522_0");

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,6 @@
#include "emu.h" #include "emu.h"
#include "includes/model3.h" #include "includes/model3.h"
static int m3_step;
/******************************************************************/ /******************************************************************/
/* Real3D TAP Port */ /* Real3D TAP Port */
@ -20,9 +19,8 @@ static int m3_step;
* 167 of the 3D-RAM manual. * 167 of the 3D-RAM manual.
*/ */
#define NEXT(new_state) fsm[state][new_state] #define NEXT(new_state) fsm[state->tap_state][new_state]
static INT32 state; // current state
static const INT32 fsm[][2] = { static const INT32 fsm[][2] = {
{ 1, 0 }, // 0 Test-Logic/Reset { 1, 0 }, // 0 Test-Logic/Reset
{ 1, 2 }, // 1 Run-Test/Idle { 1, 2 }, // 1 Run-Test/Idle
@ -42,18 +40,6 @@ static const INT32 fsm[][2] = {
{ 1, 2 } // 15 Update-IR { 1, 2 } // 15 Update-IR
}; };
/*
* TAP Registers
*/
static UINT64 current_instruction; // latched IR (not always equal to IR)
static UINT64 ir; // instruction register (46 bits)
static UINT8 id_data[32]; // ASIC ID code data buffer
static INT32 id_size; // size of ID data in bits
//static INT32 ptr; // current bit ptr for data
static int tdo; // bit shifted out to TDO
/* /*
* insert_bit(): * insert_bit():
@ -78,12 +64,12 @@ static void insert_bit(UINT8 *buf, INT32 bit_num, INT32 bit)
* Inserts a 32-bit ID code into the ID bit field. * Inserts a 32-bit ID code into the ID bit field.
*/ */
static void insert_id(UINT32 id, INT32 start_bit) static void insert_id(model3_state *state, UINT32 id, INT32 start_bit)
{ {
INT32 i; INT32 i;
for (i = 31; i >= 0; i--) for (i = 31; i >= 0; i--)
insert_bit(id_data, start_bit++, (id >> i) & 1); insert_bit(state->id_data, start_bit++, (id >> i) & 1);
} }
/* /*
@ -136,9 +122,10 @@ static int shift(UINT8 *data, INT32 num_bits)
* TDO. * TDO.
*/ */
int model3_tap_read(void) int model3_tap_read(running_machine *machine)
{ {
return tdo; model3_state *state = machine->driver_data<model3_state>();
return state->tdo;
} }
/* /*
@ -154,14 +141,15 @@ int model3_tap_read(void)
* trst = Reset. * trst = Reset.
*/ */
void model3_tap_write(int tck, int tms, int tdi, int trst) void model3_tap_write(running_machine *machine, int tck, int tms, int tdi, int trst)
{ {
model3_state *state = machine->driver_data<model3_state>();
if (!tck) if (!tck)
return; return;
state = NEXT(tms); state->tap_state = NEXT(tms);
switch (state) switch (state->tap_state)
{ {
case 3: // Capture-DR case 3: // Capture-DR
@ -187,39 +175,39 @@ void model3_tap_write(int tck, int tms, int tdi, int trst)
* data on TAP reset and when the instruction is issued. * data on TAP reset and when the instruction is issued.
*/ */
if (m3_step == 0x10) if (state->m3_step == 0x10)
{ {
insert_id(0x116C7057, 1 + 0 * 32); insert_id(state, 0x116C7057, 1 + 0 * 32);
insert_id(0x216C3057, 1 + 1 * 32); insert_id(state, 0x216C3057, 1 + 1 * 32);
insert_id(0x116C4057, 1 + 2 * 32); insert_id(state, 0x116C4057, 1 + 2 * 32);
insert_id(0x216C5057, 1 + 3 * 32); insert_id(state, 0x216C5057, 1 + 3 * 32);
insert_id(0x116C6057, 1 + 4 * 32 + 1); insert_id(state, 0x116C6057, 1 + 4 * 32 + 1);
insert_id(0x116C6057, 1 + 5 * 32 + 1); insert_id(state, 0x116C6057, 1 + 5 * 32 + 1);
} }
else if (m3_step == 0x15) else if (state->m3_step == 0x15)
{ {
insert_id(0x316C7057, 1 + 0 * 32); insert_id(state, 0x316C7057, 1 + 0 * 32);
insert_id(0x316C3057, 1 + 1 * 32); insert_id(state, 0x316C3057, 1 + 1 * 32);
insert_id(0x216C4057, 1 + 2 * 32); // Lost World may to use 0x016C4057 insert_id(state, 0x216C4057, 1 + 2 * 32); // Lost World may to use 0x016C4057
insert_id(0x316C5057, 1 + 3 * 32); insert_id(state, 0x316C5057, 1 + 3 * 32);
insert_id(0x216C6057, 1 + 4 * 32 + 1); insert_id(state, 0x216C6057, 1 + 4 * 32 + 1);
insert_id(0x216C6057, 1 + 5 * 32 + 1); insert_id(state, 0x216C6057, 1 + 5 * 32 + 1);
} }
else if (m3_step >= 0x20) else if (state->m3_step >= 0x20)
{ {
insert_id(0x416C7057, 1 + 0 * 32); insert_id(state, 0x416C7057, 1 + 0 * 32);
insert_id(0x416C3057, 1 + 1 * 32); insert_id(state, 0x416C3057, 1 + 1 * 32);
insert_id(0x316C4057, 1 + 2 * 32); insert_id(state, 0x316C4057, 1 + 2 * 32);
insert_id(0x416C5057, 1 + 3 * 32); insert_id(state, 0x416C5057, 1 + 3 * 32);
insert_id(0x316C6057, 1 + 4 * 32 + 1); insert_id(state, 0x316C6057, 1 + 4 * 32 + 1);
insert_id(0x316C6057, 1 + 5 * 32 + 1); insert_id(state, 0x316C6057, 1 + 5 * 32 + 1);
} }
break; break;
case 4: // Shift-DR case 4: // Shift-DR
tdo = shift(id_data, id_size); state->tdo = shift(state->id_data, state->id_size);
break; break;
case 10: // Capture-IR case 10: // Capture-IR
@ -228,7 +216,7 @@ void model3_tap_write(int tck, int tms, int tdi, int trst)
* Load lower 2 bits with 01 as per IEEE 1149.1-1990 * Load lower 2 bits with 01 as per IEEE 1149.1-1990
*/ */
ir = 1; state->ir = 1;
break; break;
case 11: // Shift-IR case 11: // Shift-IR
@ -237,9 +225,9 @@ void model3_tap_write(int tck, int tms, int tdi, int trst)
* Shift IR towards output and load in new data from TDI * Shift IR towards output and load in new data from TDI
*/ */
tdo = ir & 1; // shift LSB to output state->tdo = state->ir & 1; // shift LSB to output
ir >>= 1; state->ir >>= 1;
ir |= ((UINT64) tdi << 45); state->ir |= ((UINT64) tdi << 45);
break; break;
case 15: // Update-IR case 15: // Update-IR
@ -249,8 +237,7 @@ void model3_tap_write(int tck, int tms, int tdi, int trst)
* TCK) * TCK)
*/ */
ir &= U64(0x3fffffffffff); state->ir &= U64(0x3fffffffffff);
current_instruction = ir;
break; break;
default: default:
@ -265,11 +252,12 @@ void model3_tap_write(int tck, int tms, int tdi, int trst)
* Resets the TAP (simulating a power up or SCAN_RST signal.) * Resets the TAP (simulating a power up or SCAN_RST signal.)
*/ */
void model3_tap_reset(void) void model3_tap_reset(running_machine *machine)
{ {
id_size = 197; // 197 bits model3_state *state = machine->driver_data<model3_state>();
state->id_size = 197; // 197 bits
state = 0; // test-logic/reset state->tap_state = 0; // test-logic/reset
} }
/* /*
@ -279,9 +267,10 @@ void model3_tap_reset(void)
* *
*/ */
void model3_machine_init(int step) void model3_machine_init(running_machine *machine, int step)
{ {
m3_step = step; model3_state *state = machine->driver_data<model3_state>();
state->m3_step = step;
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -56,7 +56,8 @@ WRITE16_HANDLER( ga2_dpram_w )
READ16_HANDLER( ga2_dpram_r ) READ16_HANDLER( ga2_dpram_r )
{ {
return (ga2_dpram[offset])|(ga2_dpram[offset+1]<<8); segas32_state *state = space->machine->driver_data<segas32_state>();
return (state->ga2_dpram[offset])|(state->ga2_dpram[offset+1]<<8);
} }
@ -102,26 +103,27 @@ READ16_HANDLER(ga2_wakeup_protection_r)
WRITE16_HANDLER(sonic_level_load_protection) WRITE16_HANDLER(sonic_level_load_protection)
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
UINT16 level; UINT16 level;
//Perform write //Perform write
system32_workram[CLEARED_LEVELS / 2] = (data & mem_mask) | (system32_workram[CLEARED_LEVELS / 2] & ~mem_mask); state->system32_workram[CLEARED_LEVELS / 2] = (data & mem_mask) | (state->system32_workram[CLEARED_LEVELS / 2] & ~mem_mask);
//Refresh current level //Refresh current level
if (system32_workram[CLEARED_LEVELS / 2] == 0) if (state->system32_workram[CLEARED_LEVELS / 2] == 0)
{ {
level = 0x0007; level = 0x0007;
} }
else else
{ {
const UINT8 *ROM = space->machine->region("maincpu")->base(); const UINT8 *ROM = space->machine->region("maincpu")->base();
level = *((ROM + LEVEL_ORDER_ARRAY) + (system32_workram[CLEARED_LEVELS / 2] * 2) - 1); level = *((ROM + LEVEL_ORDER_ARRAY) + (state->system32_workram[CLEARED_LEVELS / 2] * 2) - 1);
level |= *((ROM + LEVEL_ORDER_ARRAY) + (system32_workram[CLEARED_LEVELS / 2] * 2) - 2) << 8; level |= *((ROM + LEVEL_ORDER_ARRAY) + (state->system32_workram[CLEARED_LEVELS / 2] * 2) - 2) << 8;
} }
system32_workram[CURRENT_LEVEL / 2] = level; state->system32_workram[CURRENT_LEVEL / 2] = level;
//Reset level status //Reset level status
system32_workram[CURRENT_LEVEL_STATUS / 2] = 0x0000; state->system32_workram[CURRENT_LEVEL_STATUS / 2] = 0x0000;
system32_workram[(CURRENT_LEVEL_STATUS + 2) / 2] = 0x0000; state->system32_workram[(CURRENT_LEVEL_STATUS + 2) / 2] = 0x0000;
} }
@ -136,6 +138,7 @@ WRITE16_HANDLER(sonic_level_load_protection)
// and can write things into work RAM. we simulate that here for burning rival. // and can write things into work RAM. we simulate that here for burning rival.
READ16_HANDLER(brival_protection_r) READ16_HANDLER(brival_protection_r)
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
if (mem_mask == 0xffff) // only trap on word-wide reads if (mem_mask == 0xffff) // only trap on word-wide reads
{ {
switch (offset) switch (offset)
@ -147,11 +150,12 @@ READ16_HANDLER(brival_protection_r)
} }
} }
return system32_workram[0xba00/2 + offset]; return state->system32_workram[0xba00/2 + offset];
} }
WRITE16_HANDLER(brival_protection_w) WRITE16_HANDLER(brival_protection_w)
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
static const int protAddress[6][2] = static const int protAddress[6][2] =
{ {
{ 0x109517, 0x00/2 }, { 0x109517, 0x00/2 },
@ -195,7 +199,7 @@ WRITE16_HANDLER(brival_protection_w)
memcpy(ret, &ROM[protAddress[curProtType][0]], 16); memcpy(ret, &ROM[protAddress[curProtType][0]], 16);
ret[16] = '\0'; ret[16] = '\0';
memcpy(&system32_protram[protAddress[curProtType][1]], ret, 16); memcpy(&state->system32_protram[protAddress[curProtType][1]], ret, 16);
} }
@ -303,7 +307,8 @@ READ16_HANDLER(arf_wakeup_protection_r)
******************************************************************************/ ******************************************************************************/
WRITE16_HANDLER( jleague_protection_w ) WRITE16_HANDLER( jleague_protection_w )
{ {
COMBINE_DATA( &system32_workram[0xf700/2 + offset ] ); segas32_state *state = space->machine->driver_data<segas32_state>();
COMBINE_DATA( &state->system32_workram[0xf700/2 + offset ] );
switch( offset ) switch( offset )
{ {
@ -343,13 +348,13 @@ WRITE16_HANDLER( jleague_protection_w )
99.99% of the dsp code is unused because the V60 ROM is hardcoded as part of a twin set, 99.99% of the dsp code is unused because the V60 ROM is hardcoded as part of a twin set,
maybe the standalone board was for dev only? nop the 3 bytes at 0x06023A for standalone. (centred intro text) maybe the standalone board was for dev only? nop the 3 bytes at 0x06023A for standalone. (centred intro text)
*/ */
static UINT16 arescue_dsp_io[6] = {0,0,0,0,0,0};
READ16_HANDLER( arescue_dsp_r ) READ16_HANDLER( arescue_dsp_r )
{ {
segas32_state *state = space->machine->driver_data<segas32_state>();
if( offset == 4/2 ) if( offset == 4/2 )
{ {
switch( arescue_dsp_io[0] ) switch( state->arescue_dsp_io[0] )
{ {
case 0: case 0:
case 1: case 1:
@ -357,25 +362,26 @@ READ16_HANDLER( arescue_dsp_r )
break; break;
case 3: case 3:
arescue_dsp_io[0] = 0x8000; state->arescue_dsp_io[0] = 0x8000;
arescue_dsp_io[2/2] = 0x0001; state->arescue_dsp_io[2/2] = 0x0001;
break; break;
case 6: case 6:
arescue_dsp_io[0] = 4 * arescue_dsp_io[2/2]; state->arescue_dsp_io[0] = 4 * state->arescue_dsp_io[2/2];
break; break;
default: default:
logerror("Unhandled DSP cmd %04x (%04x).\n", arescue_dsp_io[0], arescue_dsp_io[1] ); logerror("Unhandled DSP cmd %04x (%04x).\n", state->arescue_dsp_io[0], state->arescue_dsp_io[1] );
break; break;
} }
} }
return arescue_dsp_io[offset]; return state->arescue_dsp_io[offset];
} }
WRITE16_HANDLER( arescue_dsp_w ) WRITE16_HANDLER( arescue_dsp_w )
{ {
COMBINE_DATA(&arescue_dsp_io[offset]); segas32_state *state = space->machine->driver_data<segas32_state>();
COMBINE_DATA(&state->arescue_dsp_io[offset]);
} }

View File

@ -3,15 +3,15 @@
#include "machine/6522via.h" #include "machine/6522via.h"
#include "includes/beezer.h" #include "includes/beezer.h"
static int scanline=0;
INTERRUPT_GEN( beezer_interrupt ) INTERRUPT_GEN( beezer_interrupt )
{ {
beezer_state *state = device->machine->driver_data<beezer_state>();
via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0"); via6522_device *via_0 = device->machine->device<via6522_device>("via6522_0");
scanline = (scanline + 1) % 0x80; state->scanline = (state->scanline + 1) % 0x80;
via_0->write_ca2((scanline & 0x10) ? 1 : 0); via_0->write_ca2((state->scanline & 0x10) ? 1 : 0);
if ((scanline & 0x78) == 0x78) if ((state->scanline & 0x78) == 0x78)
cpu_set_input_line(device, M6809_FIRQ_LINE, ASSERT_LINE); cpu_set_input_line(device, M6809_FIRQ_LINE, ASSERT_LINE);
else else
cpu_set_input_line(device, M6809_FIRQ_LINE, CLEAR_LINE); cpu_set_input_line(device, M6809_FIRQ_LINE, CLEAR_LINE);
@ -68,6 +68,7 @@ WRITE8_HANDLER( beezer_map_w )
READ8_HANDLER( beezer_line_r ) READ8_HANDLER( beezer_line_r )
{ {
return (scanline & 0xfe) << 1; beezer_state *state = space->machine->driver_data<beezer_state>();
return (state->scanline & 0xfe) << 1;
} }

View File

@ -10,11 +10,11 @@
#define NUM_SPRITES (0x800 / 16) #define NUM_SPRITES (0x800 / 16)
#define NUM_LAYERS 2 #define NUM_LAYERS 2
UINT32 *djmain_obj_ram;
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)
{ {
djmain_state *state = machine->driver_data<djmain_state>();
device_t *k055555 = machine->device("k055555"); device_t *k055555 = machine->device("k055555");
int offs, pri_code; int offs, pri_code;
int sortedlist[NUM_SPRITES]; int sortedlist[NUM_SPRITES];
@ -27,12 +27,12 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta
/* prebuild a sorted table */ /* prebuild a sorted table */
for (offs = 0; offs < NUM_SPRITES * 4; offs += 4) for (offs = 0; offs < NUM_SPRITES * 4; offs += 4)
{ {
if (djmain_obj_ram[offs] & 0x00008000) if (state->obj_ram[offs] & 0x00008000)
{ {
if (djmain_obj_ram[offs] & 0x80000000) if (state->obj_ram[offs] & 0x80000000)
continue; continue;
pri_code = djmain_obj_ram[offs] & (NUM_SPRITES - 1); pri_code = state->obj_ram[offs] & (NUM_SPRITES - 1);
sortedlist[pri_code] = offs; sortedlist[pri_code] = offs;
} }
} }
@ -53,16 +53,16 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta
offs = sortedlist[pri_code]; offs = sortedlist[pri_code];
if (offs == -1) continue; if (offs == -1) continue;
code = djmain_obj_ram[offs] >> 16; code = state->obj_ram[offs] >> 16;
flipx = (djmain_obj_ram[offs] >> 10) & 1; flipx = (state->obj_ram[offs] >> 10) & 1;
flipy = (djmain_obj_ram[offs] >> 11) & 1; flipy = (state->obj_ram[offs] >> 11) & 1;
size = sizetab[(djmain_obj_ram[offs] >> 8) & 3]; size = sizetab[(state->obj_ram[offs] >> 8) & 3];
ox = (INT16)(djmain_obj_ram[offs + 1] & 0xffff); ox = (INT16)(state->obj_ram[offs + 1] & 0xffff);
oy = (INT16)(djmain_obj_ram[offs + 1] >> 16); oy = (INT16)(state->obj_ram[offs + 1] >> 16);
xscale = djmain_obj_ram[offs + 2] >> 16; xscale = state->obj_ram[offs + 2] >> 16;
yscale = djmain_obj_ram[offs + 2] & 0xffff; yscale = state->obj_ram[offs + 2] & 0xffff;
if (!xscale || !yscale) if (!xscale || !yscale)
continue; continue;
@ -72,7 +72,7 @@ static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const recta
ox -= (size * xscale) >> 13; ox -= (size * xscale) >> 13;
oy -= (size * yscale) >> 13; oy -= (size * yscale) >> 13;
color = (djmain_obj_ram[offs + 3] >> 16) & 15; color = (state->obj_ram[offs + 3] >> 16) & 15;
for (x = 0; x < size; x++) for (x = 0; x < size; x++)
for (y = 0; y < size; y++) for (y = 0; y < size; y++)

View File

@ -11,12 +11,6 @@
#include "includes/fastfred.h" #include "includes/fastfred.h"
#include "includes/galaxold.h" #include "includes/galaxold.h"
UINT8 *fastfred_videoram;
UINT8 *fastfred_spriteram;
size_t fastfred_spriteram_size;
UINT8 *fastfred_attributesram;
UINT8 *fastfred_background_color;
UINT8 *imago_fg_videoram;
static const rectangle spritevisiblearea = static const rectangle spritevisiblearea =
@ -31,10 +25,6 @@ static const rectangle spritevisibleareaflipx =
2*8, 30*8-1 2*8, 30*8-1
}; };
static UINT16 charbank;
static UINT8 colorbank;
int fastfred_hardware_type;
static tilemap_t *bg_tilemap, *fg_tilemap, *web_tilemap;
/*************************************************************************** /***************************************************************************
@ -105,10 +95,11 @@ PALETTE_INIT( fastfred )
static TILE_GET_INFO( get_tile_info ) static TILE_GET_INFO( get_tile_info )
{ {
fastfred_state *state = machine->driver_data<fastfred_state>();
UINT8 x = tile_index & 0x1f; UINT8 x = tile_index & 0x1f;
UINT16 code = charbank | fastfred_videoram[tile_index]; UINT16 code = state->charbank | state->videoram[tile_index];
UINT8 color = colorbank | (fastfred_attributesram[2 * x + 1] & 0x07); UINT8 color = state->colorbank | (state->attributesram[2 * x + 1] & 0x07);
SET_TILE_INFO(0, code, color, 0); SET_TILE_INFO(0, code, color, 0);
} }
@ -123,10 +114,11 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( fastfred ) VIDEO_START( fastfred )
{ {
bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32); fastfred_state *state = machine->driver_data<fastfred_state>();
state->bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_transparent_pen(bg_tilemap, 0); tilemap_set_transparent_pen(state->bg_tilemap, 0);
tilemap_set_scroll_cols(bg_tilemap, 32); tilemap_set_scroll_cols(state->bg_tilemap, 32);
} }
@ -138,14 +130,16 @@ VIDEO_START( fastfred )
WRITE8_HANDLER( fastfred_videoram_w ) WRITE8_HANDLER( fastfred_videoram_w )
{ {
fastfred_videoram[offset] = data; fastfred_state *state = space->machine->driver_data<fastfred_state>();
tilemap_mark_tile_dirty(bg_tilemap, offset); state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
WRITE8_HANDLER( fastfred_attributes_w ) WRITE8_HANDLER( fastfred_attributes_w )
{ {
if (fastfred_attributesram[offset] != data) fastfred_state *state = space->machine->driver_data<fastfred_state>();
if (state->attributesram[offset] != data)
{ {
if (offset & 0x01) if (offset & 0x01)
{ {
@ -153,65 +147,69 @@ WRITE8_HANDLER( fastfred_attributes_w )
int i; int i;
for (i = offset / 2; i < 0x0400; i += 32) for (i = offset / 2; i < 0x0400; i += 32)
tilemap_mark_tile_dirty(bg_tilemap, i); tilemap_mark_tile_dirty(state->bg_tilemap, i);
} }
else else
{ {
/* coloumn scroll */ /* coloumn scroll */
tilemap_set_scrolly(bg_tilemap, offset / 2, data); tilemap_set_scrolly(state->bg_tilemap, offset / 2, data);
} }
fastfred_attributesram[offset] = data; state->attributesram[offset] = data;
} }
} }
WRITE8_HANDLER( fastfred_charbank1_w ) WRITE8_HANDLER( fastfred_charbank1_w )
{ {
UINT16 new_data = (charbank & 0x0200) | ((data & 0x01) << 8); fastfred_state *state = space->machine->driver_data<fastfred_state>();
UINT16 new_data = (state->charbank & 0x0200) | ((data & 0x01) << 8);
if (new_data != charbank) if (new_data != state->charbank)
{ {
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
charbank = new_data; state->charbank = new_data;
} }
} }
WRITE8_HANDLER( fastfred_charbank2_w ) WRITE8_HANDLER( fastfred_charbank2_w )
{ {
UINT16 new_data = (charbank & 0x0100) | ((data & 0x01) << 9); fastfred_state *state = space->machine->driver_data<fastfred_state>();
UINT16 new_data = (state->charbank & 0x0100) | ((data & 0x01) << 9);
if (new_data != charbank) if (new_data != state->charbank)
{ {
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
charbank = new_data; state->charbank = new_data;
} }
} }
WRITE8_HANDLER( fastfred_colorbank1_w ) WRITE8_HANDLER( fastfred_colorbank1_w )
{ {
UINT8 new_data = (colorbank & 0x10) | ((data & 0x01) << 3); fastfred_state *state = space->machine->driver_data<fastfred_state>();
UINT8 new_data = (state->colorbank & 0x10) | ((data & 0x01) << 3);
if (new_data != colorbank) if (new_data != state->colorbank)
{ {
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
colorbank = new_data; state->colorbank = new_data;
} }
} }
WRITE8_HANDLER( fastfred_colorbank2_w ) WRITE8_HANDLER( fastfred_colorbank2_w )
{ {
UINT8 new_data = (colorbank & 0x08) | ((data & 0x01) << 4); fastfred_state *state = space->machine->driver_data<fastfred_state>();
UINT8 new_data = (state->colorbank & 0x08) | ((data & 0x01) << 4);
if (new_data != colorbank) if (new_data != state->colorbank)
{ {
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
colorbank = new_data; state->colorbank = new_data;
} }
} }
@ -219,21 +217,23 @@ WRITE8_HANDLER( fastfred_colorbank2_w )
WRITE8_HANDLER( fastfred_flip_screen_x_w ) WRITE8_HANDLER( fastfred_flip_screen_x_w )
{ {
fastfred_state *state = space->machine->driver_data<fastfred_state>();
if (flip_screen_x_get(space->machine) != (data & 0x01)) if (flip_screen_x_get(space->machine) != (data & 0x01))
{ {
flip_screen_x_set(space->machine, data & 0x01); flip_screen_x_set(space->machine, data & 0x01);
tilemap_set_flip(bg_tilemap, (flip_screen_x_get(space->machine) ? TILEMAP_FLIPX : 0) | (flip_screen_y_get(space->machine) ? TILEMAP_FLIPY : 0)); tilemap_set_flip(state->bg_tilemap, (flip_screen_x_get(space->machine) ? TILEMAP_FLIPX : 0) | (flip_screen_y_get(space->machine) ? TILEMAP_FLIPY : 0));
} }
} }
WRITE8_HANDLER( fastfred_flip_screen_y_w ) WRITE8_HANDLER( fastfred_flip_screen_y_w )
{ {
fastfred_state *state = space->machine->driver_data<fastfred_state>();
if (flip_screen_y_get(space->machine) != (data & 0x01)) if (flip_screen_y_get(space->machine) != (data & 0x01))
{ {
flip_screen_y_set(space->machine, data & 0x01); flip_screen_y_set(space->machine, data & 0x01);
tilemap_set_flip(bg_tilemap, (flip_screen_x_get(space->machine) ? TILEMAP_FLIPX : 0) | (flip_screen_y_get(space->machine) ? TILEMAP_FLIPY : 0)); tilemap_set_flip(state->bg_tilemap, (flip_screen_x_get(space->machine) ? TILEMAP_FLIPX : 0) | (flip_screen_y_get(space->machine) ? TILEMAP_FLIPY : 0));
} }
} }
@ -247,43 +247,44 @@ WRITE8_HANDLER( fastfred_flip_screen_y_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)
{ {
fastfred_state *state = machine->driver_data<fastfred_state>();
int offs; int offs;
for (offs = fastfred_spriteram_size - 4; offs >= 0; offs -= 4) for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
{ {
UINT8 code,sx,sy; UINT8 code,sx,sy;
int flipx,flipy; int flipx,flipy;
sx = fastfred_spriteram[offs + 3]; sx = state->spriteram[offs + 3];
sy = 240 - fastfred_spriteram[offs]; sy = 240 - state->spriteram[offs];
if (fastfred_hardware_type == 3) if (state->hardware_type == 3)
{ {
// Imago // Imago
code = (fastfred_spriteram[offs + 1]) & 0x3f; code = (state->spriteram[offs + 1]) & 0x3f;
flipx = 0; flipx = 0;
flipy = 0; flipy = 0;
} }
else if (fastfred_hardware_type == 2) else if (state->hardware_type == 2)
{ {
// Boggy 84 // Boggy 84
code = fastfred_spriteram[offs + 1] & 0x7f; code = state->spriteram[offs + 1] & 0x7f;
flipx = 0; flipx = 0;
flipy = fastfred_spriteram[offs + 1] & 0x80; flipy = state->spriteram[offs + 1] & 0x80;
} }
else if (fastfred_hardware_type == 1) else if (state->hardware_type == 1)
{ {
// Fly-Boy/Fast Freddie/Red Robin // Fly-Boy/Fast Freddie/Red Robin
code = fastfred_spriteram[offs + 1] & 0x7f; code = state->spriteram[offs + 1] & 0x7f;
flipx = 0; flipx = 0;
flipy = ~fastfred_spriteram[offs + 1] & 0x80; flipy = ~state->spriteram[offs + 1] & 0x80;
} }
else else
{ {
// Jump Coaster // Jump Coaster
code = (fastfred_spriteram[offs + 1] & 0x3f) | 0x40; code = (state->spriteram[offs + 1] & 0x3f) | 0x40;
flipx = ~fastfred_spriteram[offs + 1] & 0x40; flipx = ~state->spriteram[offs + 1] & 0x40;
flipy = fastfred_spriteram[offs + 1] & 0x80; flipy = state->spriteram[offs + 1] & 0x80;
} }
@ -300,7 +301,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
drawgfx_transpen(bitmap,flip_screen_x_get(machine) ? &spritevisibleareaflipx : &spritevisiblearea,machine->gfx[1], drawgfx_transpen(bitmap,flip_screen_x_get(machine) ? &spritevisibleareaflipx : &spritevisiblearea,machine->gfx[1],
code, code,
colorbank | (fastfred_spriteram[offs + 2] & 0x07), state->colorbank | (state->spriteram[offs + 2] & 0x07),
flipx,flipy, flipx,flipy,
sx,sy,0); sx,sy,0);
} }
@ -309,8 +310,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( fastfred ) VIDEO_UPDATE( fastfred )
{ {
bitmap_fill(bitmap, cliprect, *fastfred_background_color); fastfred_state *state = screen->machine->driver_data<fastfred_state>();
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); bitmap_fill(bitmap, cliprect, *state->background_color);
tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
draw_sprites(screen->machine, bitmap, cliprect); draw_sprites(screen->machine, bitmap, cliprect);
return 0; return 0;
@ -319,17 +321,19 @@ VIDEO_UPDATE( fastfred )
static TILE_GET_INFO( imago_get_tile_info_bg ) static TILE_GET_INFO( imago_get_tile_info_bg )
{ {
fastfred_state *state = machine->driver_data<fastfred_state>();
UINT8 x = tile_index & 0x1f; UINT8 x = tile_index & 0x1f;
UINT16 code = charbank * 0x100 + fastfred_videoram[tile_index]; UINT16 code = state->charbank * 0x100 + state->videoram[tile_index];
UINT8 color = colorbank | (fastfred_attributesram[2 * x + 1] & 0x07); UINT8 color = state->colorbank | (state->attributesram[2 * x + 1] & 0x07);
SET_TILE_INFO(0, code, color, 0); SET_TILE_INFO(0, code, color, 0);
} }
static TILE_GET_INFO( imago_get_tile_info_fg ) static TILE_GET_INFO( imago_get_tile_info_fg )
{ {
int code = imago_fg_videoram[tile_index]; fastfred_state *state = machine->driver_data<fastfred_state>();
int code = state->imago_fg_videoram[tile_index];
SET_TILE_INFO(2, code, 2, 0); SET_TILE_INFO(2, code, 2, 0);
} }
@ -340,27 +344,30 @@ static TILE_GET_INFO( imago_get_tile_info_web )
WRITE8_HANDLER( imago_fg_videoram_w ) WRITE8_HANDLER( imago_fg_videoram_w )
{ {
imago_fg_videoram[offset] = data; fastfred_state *state = space->machine->driver_data<fastfred_state>();
tilemap_mark_tile_dirty(fg_tilemap, offset); state->imago_fg_videoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset);
} }
WRITE8_HANDLER( imago_charbank_w ) WRITE8_HANDLER( imago_charbank_w )
{ {
if( charbank != data ) fastfred_state *state = space->machine->driver_data<fastfred_state>();
if( state->charbank != data )
{ {
charbank = data; state->charbank = data;
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
} }
} }
VIDEO_START( imago ) VIDEO_START( imago )
{ {
web_tilemap = tilemap_create(machine, imago_get_tile_info_web,tilemap_scan_rows, 8,8,32,32); fastfred_state *state = machine->driver_data<fastfred_state>();
bg_tilemap = tilemap_create(machine, imago_get_tile_info_bg, tilemap_scan_rows,8,8,32,32); state->web_tilemap = tilemap_create(machine, imago_get_tile_info_web,tilemap_scan_rows, 8,8,32,32);
fg_tilemap = tilemap_create(machine, imago_get_tile_info_fg, tilemap_scan_rows,8,8,32,32); state->bg_tilemap = tilemap_create(machine, imago_get_tile_info_bg, tilemap_scan_rows,8,8,32,32);
state->fg_tilemap = tilemap_create(machine, imago_get_tile_info_fg, tilemap_scan_rows,8,8,32,32);
tilemap_set_transparent_pen(bg_tilemap, 0); tilemap_set_transparent_pen(state->bg_tilemap, 0);
tilemap_set_transparent_pen(fg_tilemap, 0); tilemap_set_transparent_pen(state->fg_tilemap, 0);
/* the game has a galaxian starfield */ /* the game has a galaxian starfield */
galaxold_init_stars(machine, 256); galaxold_init_stars(machine, 256);
@ -373,11 +380,12 @@ VIDEO_START( imago )
VIDEO_UPDATE( imago ) VIDEO_UPDATE( imago )
{ {
tilemap_draw(bitmap,cliprect,web_tilemap,0,0); fastfred_state *state = screen->machine->driver_data<fastfred_state>();
tilemap_draw(bitmap,cliprect,state->web_tilemap,0,0);
galaxold_draw_stars(screen->machine, bitmap, cliprect); galaxold_draw_stars(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
draw_sprites(screen->machine, bitmap, cliprect); draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap,cliprect,fg_tilemap,0,0); tilemap_draw(bitmap,cliprect,state->fg_tilemap,0,0);
return 0; return 0;
} }

View File

@ -1,6 +1,7 @@
#include "emu.h" #include "emu.h"
#include "cpu/sharc/sharc.h" #include "cpu/sharc/sharc.h"
#include "machine/konppc.h" #include "machine/konppc.h"
#include "video/voodoo.h"
#include "video/poly.h" #include "video/poly.h"
#include "video/konicdev.h" #include "video/konicdev.h"
#include "video/gticlub.h" #include "video/gticlub.h"
@ -17,8 +18,12 @@ struct _poly_extra_data
int texture_mirror_y; int texture_mirror_y;
}; };
extern UINT8 gticlub_led_reg0; static UINT8 gticlub_led_reg[2];
extern UINT8 gticlub_led_reg1;
void gticlub_led_setreg(int offset, UINT8 data)
{
gticlub_led_reg[offset] = data;
}
/*****************************************************************************/ /*****************************************************************************/
@ -967,6 +972,7 @@ static int debug_tex_palette = 0;
VIDEO_START( gticlub ) VIDEO_START( gticlub )
{ {
gticlub_led_reg[0] = gticlub_led_reg[1] = 0x7f;
tick = 0; tick = 0;
debug_tex_page = 0; debug_tex_page = 0;
debug_tex_palette = 0; debug_tex_palette = 0;
@ -1035,11 +1041,44 @@ VIDEO_UPDATE( gticlub )
} }
#endif #endif
draw_7segment_led(bitmap, 3, 3, gticlub_led_reg0); draw_7segment_led(bitmap, 3, 3, gticlub_led_reg[0]);
draw_7segment_led(bitmap, 9, 3, gticlub_led_reg1); draw_7segment_led(bitmap, 9, 3, gticlub_led_reg[1]);
//cputag_set_input_line(screen->machine, "dsp", SHARC_INPUT_FLAG1, ASSERT_LINE); //cputag_set_input_line(screen->machine, "dsp", SHARC_INPUT_FLAG1, ASSERT_LINE);
sharc_set_flag_input(screen->machine->device("dsp"), 1, ASSERT_LINE); sharc_set_flag_input(screen->machine->device("dsp"), 1, ASSERT_LINE);
return 0; return 0;
} }
VIDEO_UPDATE( hangplt )
{
bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
if (strcmp(screen->tag(), "lscreen") == 0)
{
device_t *k001604 = screen->machine->device("k001604_1");
device_t *voodoo = screen->machine->device("voodoo0");
// k001604_draw_back_layer(k001604, bitmap, cliprect);
voodoo_update(voodoo, bitmap, cliprect);
k001604_draw_front_layer(k001604, bitmap, cliprect);
}
else if (strcmp(screen->tag(), "rscreen") == 0)
{
device_t *k001604 = screen->machine->device("k001604_2");
device_t *voodoo = screen->machine->device("voodoo1");
// k001604_draw_back_layer(k001604, bitmap, cliprect);
voodoo_update(voodoo, bitmap, cliprect);
k001604_draw_front_layer(k001604, bitmap, cliprect);
}
draw_7segment_led(bitmap, 3, 3, gticlub_led_reg[0]);
draw_7segment_led(bitmap, 9, 3, gticlub_led_reg[1]);
return 0;
}

View File

@ -1,3 +1,5 @@
void gticlub_led_setreg(int offset, UINT8 data);
void K001005_draw(bitmap_t *bitmap, const rectangle *cliprect); void K001005_draw(bitmap_t *bitmap, const rectangle *cliprect);
void K001005_swap_buffers(running_machine *machine); void K001005_swap_buffers(running_machine *machine);
void K001005_init(running_machine *machine); void K001005_init(running_machine *machine);
@ -14,3 +16,4 @@ WRITE32_HANDLER(K001006_1_w);
VIDEO_START( gticlub ); VIDEO_START( gticlub );
VIDEO_UPDATE( gticlub ); VIDEO_UPDATE( gticlub );
VIDEO_UPDATE( hangplt );

View File

@ -1,9 +1,6 @@
#include "emu.h" #include "emu.h"
#include "includes/hexion.h" #include "includes/hexion.h"
static UINT8 *vram[2],*unkram;
static int bankctrl,rambank,pmcbank,gfxrom_select;
static tilemap_t *bg_tilemap[2];
@ -25,12 +22,14 @@ INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_
static TILE_GET_INFO( get_tile_info0 ) static TILE_GET_INFO( get_tile_info0 )
{ {
get_tile_info(machine,tileinfo,tile_index,vram[0]); hexion_state *state = machine->driver_data<hexion_state>();
get_tile_info(machine,tileinfo,tile_index,state->vram[0]);
} }
static TILE_GET_INFO( get_tile_info1 ) static TILE_GET_INFO( get_tile_info1 )
{ {
get_tile_info(machine,tileinfo,tile_index,vram[1]); hexion_state *state = machine->driver_data<hexion_state>();
get_tile_info(machine,tileinfo,tile_index,state->vram[1]);
} }
@ -43,16 +42,17 @@ static TILE_GET_INFO( get_tile_info1 )
VIDEO_START( hexion ) VIDEO_START( hexion )
{ {
bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,64,32); hexion_state *state = machine->driver_data<hexion_state>();
bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows, 8,8,64,32); state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,64,32);
state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows, 8,8,64,32);
tilemap_set_transparent_pen(bg_tilemap[0],0); tilemap_set_transparent_pen(state->bg_tilemap[0],0);
tilemap_set_scrollx(bg_tilemap[1],0,-4); tilemap_set_scrollx(state->bg_tilemap[1],0,-4);
tilemap_set_scrolly(bg_tilemap[1],0,4); tilemap_set_scrolly(state->bg_tilemap[1],0,4);
vram[0] = machine->region("maincpu")->base() + 0x30000; state->vram[0] = machine->region("maincpu")->base() + 0x30000;
vram[1] = vram[0] + 0x2000; state->vram[1] = state->vram[0] + 0x2000;
unkram = vram[1] + 0x2000; state->unkram = state->vram[1] + 0x2000;
} }
@ -65,6 +65,7 @@ VIDEO_START( hexion )
WRITE8_HANDLER( hexion_bankswitch_w ) WRITE8_HANDLER( hexion_bankswitch_w )
{ {
hexion_state *state = space->machine->driver_data<hexion_state>();
UINT8 *rom = space->machine->region("maincpu")->base() + 0x10000; UINT8 *rom = space->machine->region("maincpu")->base() + 0x10000;
/* bits 0-3 select ROM bank */ /* bits 0-3 select ROM bank */
@ -73,12 +74,12 @@ WRITE8_HANDLER( hexion_bankswitch_w )
/* does bit 6 trigger the 052591? */ /* does bit 6 trigger the 052591? */
if (data & 0x40) if (data & 0x40)
{ {
int bank = unkram[0]&1; int bank = state->unkram[0]&1;
memset(vram[bank],unkram[1],0x2000); memset(state->vram[bank],state->unkram[1],0x2000);
tilemap_mark_all_tiles_dirty(bg_tilemap[bank]); tilemap_mark_all_tiles_dirty(state->bg_tilemap[bank]);
} }
/* bit 7 = PMC-BK */ /* bit 7 = PMC-BK */
pmcbank = (data & 0x80) >> 7; state->pmcbank = (data & 0x80) >> 7;
/* other bits unknown */ /* other bits unknown */
if (data & 0x30) if (data & 0x30)
@ -89,67 +90,71 @@ if (data & 0x30)
READ8_HANDLER( hexion_bankedram_r ) READ8_HANDLER( hexion_bankedram_r )
{ {
if (gfxrom_select && offset < 0x1000) hexion_state *state = space->machine->driver_data<hexion_state>();
if (state->gfxrom_select && offset < 0x1000)
{ {
return space->machine->region("gfx1")->base()[((gfxrom_select & 0x7f) << 12) + offset]; return space->machine->region("gfx1")->base()[((state->gfxrom_select & 0x7f) << 12) + offset];
} }
else if (bankctrl == 0) else if (state->bankctrl == 0)
{ {
return vram[rambank][offset]; return state->vram[state->rambank][offset];
} }
else if (bankctrl == 2 && offset < 0x800) else if (state->bankctrl == 2 && offset < 0x800)
{ {
return unkram[offset]; return state->unkram[offset];
} }
else else
{ {
//logerror("%04x: bankedram_r offset %04x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,bankctrl); //logerror("%04x: bankedram_r offset %04x, state->bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,state->bankctrl);
return 0; return 0;
} }
} }
WRITE8_HANDLER( hexion_bankedram_w ) WRITE8_HANDLER( hexion_bankedram_w )
{ {
if (bankctrl == 3 && offset == 0 && (data & 0xfe) == 0) hexion_state *state = space->machine->driver_data<hexion_state>();
if (state->bankctrl == 3 && offset == 0 && (data & 0xfe) == 0)
{ {
//logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,bankctrl); //logerror("%04x: bankedram_w offset %04x, data %02x, state->bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,state->bankctrl);
rambank = data & 1; state->rambank = data & 1;
} }
else if (bankctrl == 0) else if (state->bankctrl == 0)
{ {
if (pmcbank) if (state->pmcbank)
{ {
//logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,bankctrl); //logerror("%04x: bankedram_w offset %04x, data %02x, state->bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,state->bankctrl);
vram[rambank][offset] = data; state->vram[state->rambank][offset] = data;
tilemap_mark_tile_dirty(bg_tilemap[rambank],offset/4); tilemap_mark_tile_dirty(state->bg_tilemap[state->rambank],offset/4);
} }
else else
logerror("%04x pmc internal ram %04x = %02x\n",cpu_get_pc(space->cpu),offset,data); logerror("%04x pmc internal ram %04x = %02x\n",cpu_get_pc(space->cpu),offset,data);
} }
else if (bankctrl == 2 && offset < 0x800) else if (state->bankctrl == 2 && offset < 0x800)
{ {
if (pmcbank) if (state->pmcbank)
{ {
//logerror("%04x: unkram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,bankctrl); //logerror("%04x: unkram_w offset %04x, data %02x, state->bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,state->bankctrl);
unkram[offset] = data; state->unkram[offset] = data;
} }
else else
logerror("%04x pmc internal ram %04x = %02x\n",cpu_get_pc(space->cpu),offset,data); logerror("%04x pmc internal ram %04x = %02x\n",cpu_get_pc(space->cpu),offset,data);
} }
else else
logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,bankctrl); logerror("%04x: bankedram_w offset %04x, data %02x, state->bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,state->bankctrl);
} }
WRITE8_HANDLER( hexion_bankctrl_w ) WRITE8_HANDLER( hexion_bankctrl_w )
{ {
hexion_state *state = space->machine->driver_data<hexion_state>();
//logerror("%04x: bankctrl_w %02x\n",cpu_get_pc(space->cpu),data); //logerror("%04x: bankctrl_w %02x\n",cpu_get_pc(space->cpu),data);
bankctrl = data; state->bankctrl = data;
} }
WRITE8_HANDLER( hexion_gfxrom_select_w ) WRITE8_HANDLER( hexion_gfxrom_select_w )
{ {
hexion_state *state = space->machine->driver_data<hexion_state>();
//logerror("%04x: gfxrom_select_w %02x\n",cpu_get_pc(space->cpu),data); //logerror("%04x: gfxrom_select_w %02x\n",cpu_get_pc(space->cpu),data);
gfxrom_select = data; state->gfxrom_select = data;
} }
@ -162,7 +167,8 @@ WRITE8_HANDLER( hexion_gfxrom_select_w )
VIDEO_UPDATE( hexion ) VIDEO_UPDATE( hexion )
{ {
tilemap_draw(bitmap,cliprect,bg_tilemap[1],0,0); hexion_state *state = screen->machine->driver_data<hexion_state>();
tilemap_draw(bitmap,cliprect,bg_tilemap[0],0,0); tilemap_draw(bitmap,cliprect,state->bg_tilemap[1],0,0);
tilemap_draw(bitmap,cliprect,state->bg_tilemap[0],0,0);
return 0; return 0;
} }

View File

@ -72,7 +72,7 @@ static bitmap_t *gxtype1_roz_dstbitmap;
static bitmap_t *gxtype1_roz_dstbitmap2; static bitmap_t *gxtype1_roz_dstbitmap2;
static rectangle gxtype1_roz_dstbitmapclip; static rectangle gxtype1_roz_dstbitmapclip;
static void (*game_tile_callback)(int layer, int *code, int *color, int *flags); static void (*game_tile_callback)(running_machine *machine, int layer, int *code, int *color, int *flags);
// Localized K053936/ROZ+ // Localized K053936/ROZ+
#define K053936_MAX_CHIPS 2 #define K053936_MAX_CHIPS 2
@ -923,7 +923,7 @@ INLINE int K055555GX_decode_inpri(int c18) // (see p.59 7.2.2)
return(c18 | op); return(c18 | op);
} }
static void konamigx_type2_sprite_callback(int *code, int *color, int *priority) static void konamigx_type2_sprite_callback(running_machine *machine, int *code, int *color, int *priority)
{ {
int num = *code; int num = *code;
int c18 = *color; int c18 = *color;
@ -934,7 +934,7 @@ static void konamigx_type2_sprite_callback(int *code, int *color, int *priority)
*priority = K055555GX_decode_inpri(c18); *priority = K055555GX_decode_inpri(c18);
} }
static void konamigx_dragoonj_sprite_callback(int *code, int *color, int *priority) static void konamigx_dragoonj_sprite_callback(running_machine *machine, int *code, int *color, int *priority)
{ {
int num, op, pri, c18; int num, op, pri, c18;
@ -952,7 +952,7 @@ static void konamigx_dragoonj_sprite_callback(int *code, int *color, int *priori
*color = K055555GX_decode_objcolor(c18); *color = K055555GX_decode_objcolor(c18);
} }
static void konamigx_salmndr2_sprite_callback(int *code, int *color, int *priority) static void konamigx_salmndr2_sprite_callback(running_machine *machine, int *code, int *color, int *priority)
{ {
int num, op, pri, c18; int num, op, pri, c18;
@ -970,7 +970,7 @@ static void konamigx_salmndr2_sprite_callback(int *code, int *color, int *priori
*color = K055555GX_decode_objcolor(c18); *color = K055555GX_decode_objcolor(c18);
} }
static void konamigx_le2_sprite_callback(int *code, int *color, int *priority) static void konamigx_le2_sprite_callback(running_machine *machine, int *code, int *color, int *priority)
{ {
int num, op, pri; int num, op, pri;
@ -1116,7 +1116,7 @@ static int gx_objdma, gx_primode;
// mirrored K053247 and K054338 settings // mirrored K053247 and K054338 settings
UINT16 *K053247_ram; UINT16 *K053247_ram;
static gfx_element *K053247_gfx; static gfx_element *K053247_gfx;
static void (*K053247_callback)(int *code,int *color,int *priority); static void (*K053247_callback)(running_machine *machine, int *code,int *color,int *priority);
static int K053247_dx, K053247_dy; static int K053247_dx, K053247_dy;
static int *K054338_shdRGB; static int *K054338_shdRGB;
@ -1362,7 +1362,7 @@ void konamigx_mixer(running_machine *machine, bitmap_t *bitmap, const rectangle
color = k = gx_spriteram[offs+6]; color = k = gx_spriteram[offs+6];
l = gx_spriteram[offs+7]; l = gx_spriteram[offs+7];
(*K053247_callback)(&code, &color, &pri); (*K053247_callback)(machine, &code, &color, &pri);
/* /*
shadow = shadow code shadow = shadow code
@ -1955,7 +1955,7 @@ static TILE_GET_INFO( get_gx_psac1b_tile_info )
SET_TILE_INFO(0, tileno, colour, flip); SET_TILE_INFO(0, tileno, colour, flip);
} }
static void konamigx_type2_tile_callback(int layer, int *code, int *color, int *flags) static void konamigx_type2_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
{ {
int d = *code; int d = *code;
@ -1963,7 +1963,7 @@ static void konamigx_type2_tile_callback(int layer, int *code, int *color, int *
K055555GX_decode_vmixcolor(layer, color); K055555GX_decode_vmixcolor(layer, color);
} }
static void konamigx_alpha_tile_callback(int layer, int *code, int *color, int *flags) static void konamigx_alpha_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
{ {
int mixcode; int mixcode;
int d = *code; int d = *code;

View File

@ -3721,10 +3721,10 @@ static UINT8 K053246_regs[8];
static UINT16 K053247_regs[16]; static UINT16 K053247_regs[16];
static UINT16 *K053247_ram=0; static UINT16 *K053247_ram=0;
static gfx_element *K053247_gfx; static gfx_element *K053247_gfx;
static void (*K053247_callback)(int *code,int *color,int *priority); static void (*K053247_callback)(running_machine *machine, int *code,int *color,int *priority);
static UINT8 K053246_OBJCHA_line; static UINT8 K053246_OBJCHA_line;
void K053247_export_config(UINT16 **ram, gfx_element **gfx, void (**callback)(int *, int *, int *), int *dx, int *dy) void K053247_export_config(UINT16 **ram, gfx_element **gfx, void (**callback)(running_machine *, int *, int *, int *), int *dx, int *dy)
{ {
if(ram) if(ram)
*ram = K053247_ram; *ram = K053247_ram;
@ -3841,7 +3841,7 @@ void K053247_vh_start(running_machine *machine, const char *gfx_memory_region, i
#endif #endif
/* K055673 used with the 54246 in PreGX/Run and Gun/System GX games */ /* K055673 used with the 54246 in PreGX/Run and Gun/System GX games */
void K055673_vh_start(running_machine *machine, const char *gfx_memory_region, int layout, int dx, int dy, void (*callback)(int *code,int *color,int *priority)) void K055673_vh_start(running_machine *machine, const char *gfx_memory_region, int layout, int dx, int dy, void (*callback)(running_machine *machine, int *code,int *color,int *priority))
{ {
int gfx_index; int gfx_index;
UINT32 total; UINT32 total;
@ -5542,7 +5542,7 @@ int K056832_get_lookup(int bits)
} }
#endif #endif
static void (*K056832_callback)(int layer, int *code, int *color, int *flags); static void (*K056832_callback)(running_machine *machine, int layer, int *code, int *color, int *flags);
INLINE void K056832_get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int pageIndex ) INLINE void K056832_get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int pageIndex )
{ {
@ -5579,7 +5579,7 @@ INLINE void K056832_get_tile_info( running_machine *machine, tile_data *tileinfo
color = (attr & smptr->palm1) | (attr>>smptr->pals2 & smptr->palm2); color = (attr & smptr->palm1) | (attr>>smptr->pals2 & smptr->palm2);
flags = TILE_FLIPYX(flip); flags = TILE_FLIPYX(flip);
(*K056832_callback)(layer, &code, &color, &flags); (*K056832_callback)(machine, layer, &code, &color, &flags);
SET_TILE_INFO(K056832_gfxnum, SET_TILE_INFO(K056832_gfxnum,
code, code,
@ -5678,7 +5678,7 @@ static STATE_POSTLOAD( K056832_postload )
void K056832_vh_start(running_machine *machine, const char *gfx_memory_region, int bpp, int big, void K056832_vh_start(running_machine *machine, const char *gfx_memory_region, int bpp, int big,
int (*scrolld)[4][2], int (*scrolld)[4][2],
void (*callback)(int layer, int *code, int *color, int *flags), void (*callback)(running_machine *machine, int layer, int *code, int *color, int *flags),
int djmain_hack) int djmain_hack)
{ {
tilemap_t *tmap; tilemap_t *tmap;

View File

@ -144,7 +144,7 @@ void K053245_set_SpriteOffset(int chip,int offsx, int offsy);
#define K055673_LAYOUT_GX6 3 #define K055673_LAYOUT_GX6 3
void K055673_vh_start(running_machine *machine, const char *gfx_memory_region, int alt_layout, int dx, int dy, void K055673_vh_start(running_machine *machine, const char *gfx_memory_region, int alt_layout, int dx, int dy,
void (*callback)(int *code,int *color,int *priority)); void (*callback)(running_machine *machine, int *code,int *color,int *priority));
READ16_HANDLER( K055673_rom_word_r ); READ16_HANDLER( K055673_rom_word_r );
READ16_HANDLER( K055673_GX6bpp_rom_word_r ); READ16_HANDLER( K055673_GX6bpp_rom_word_r );
@ -179,7 +179,7 @@ void K053247_set_SpriteOffset(int offsx, int offsy);
void K053247_wraparound_enable(int status); void K053247_wraparound_enable(int status);
void K05324x_set_z_rejection(int zcode); // common to K053245/6/7 void K05324x_set_z_rejection(int zcode); // common to K053245/6/7
#endif #endif
void K053247_export_config(UINT16 **ram, gfx_element **gfx, void (**callback)(int *, int *, int *), int *dx, int *dy); void K053247_export_config(UINT16 **ram, gfx_element **gfx, void (**callback)(running_machine *, int *, int *, int *), int *dx, int *dy);
#ifdef UNUSED_FUNCTION #ifdef UNUSED_FUNCTION
READ8_HANDLER( K053246_r ); READ8_HANDLER( K053246_r );
@ -280,7 +280,7 @@ void K056832_SetExtLinescroll(void); /* Lethal Enforcers */
void K056832_vh_start(running_machine *machine, const char *gfx_memory_region, int bpp, int big, void K056832_vh_start(running_machine *machine, const char *gfx_memory_region, int bpp, int big,
int (*scrolld)[4][2], int (*scrolld)[4][2],
void (*callback)(int layer, int *code, int *color, int *flags), void (*callback)(running_machine *machine, int layer, int *code, int *color, int *flags),
int djmain_hack); int djmain_hack);
READ16_HANDLER( K056832_ram_word_r ); READ16_HANDLER( K056832_ram_word_r );
WRITE16_HANDLER( K056832_ram_word_w ); WRITE16_HANDLER( K056832_ram_word_w );

View File

@ -4,7 +4,7 @@ static void draw_scanline_normal(void *dest, INT32 scanline, const poly_extent *
const cached_texture *texture = extra->texture; const cached_texture *texture = extra->texture;
bitmap_t *destmap = (bitmap_t *)dest; bitmap_t *destmap = (bitmap_t *)dest;
UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0); UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0);
UINT32 *d = BITMAP_ADDR32(zbuffer, scanline, 0); UINT32 *d = BITMAP_ADDR32(extra->zbuffer, scanline, 0);
float ooz = extent->param[0].start; float ooz = extent->param[0].start;
float uoz = extent->param[1].start; float uoz = extent->param[1].start;
float voz = extent->param[2].start; float voz = extent->param[2].start;
@ -53,7 +53,7 @@ static void draw_scanline_trans(void *dest, INT32 scanline, const poly_extent *e
const cached_texture *texture = extra->texture; const cached_texture *texture = extra->texture;
bitmap_t *destmap = (bitmap_t *)dest; bitmap_t *destmap = (bitmap_t *)dest;
UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0); UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0);
UINT32 *d = BITMAP_ADDR32(zbuffer, scanline, 0); UINT32 *d = BITMAP_ADDR32(extra->zbuffer, scanline, 0);
float ooz = extent->param[0].start; float ooz = extent->param[0].start;
float uoz = extent->param[1].start; float uoz = extent->param[1].start;
float voz = extent->param[2].start; float voz = extent->param[2].start;
@ -108,7 +108,7 @@ static void draw_scanline_alpha(void *dest, INT32 scanline, const poly_extent *e
const cached_texture *texture = extra->texture; const cached_texture *texture = extra->texture;
bitmap_t *destmap = (bitmap_t *)dest; bitmap_t *destmap = (bitmap_t *)dest;
UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0); UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0);
UINT32 *d = BITMAP_ADDR32(zbuffer, scanline, 0); UINT32 *d = BITMAP_ADDR32(extra->zbuffer, scanline, 0);
float ooz = extent->param[0].start; float ooz = extent->param[0].start;
float uoz = extent->param[1].start; float uoz = extent->param[1].start;
float voz = extent->param[2].start; float voz = extent->param[2].start;
@ -166,7 +166,7 @@ static void draw_scanline_alpha_test(void *dest, INT32 scanline, const poly_exte
const cached_texture *texture = extra->texture; const cached_texture *texture = extra->texture;
bitmap_t *destmap = (bitmap_t *)dest; bitmap_t *destmap = (bitmap_t *)dest;
UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0); UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0);
UINT32 *d = BITMAP_ADDR32(zbuffer, scanline, 0); UINT32 *d = BITMAP_ADDR32(extra->zbuffer, scanline, 0);
float ooz = extent->param[0].start; float ooz = extent->param[0].start;
float uoz = extent->param[1].start; float uoz = extent->param[1].start;
float voz = extent->param[2].start; float voz = extent->param[2].start;
@ -225,7 +225,7 @@ static void draw_scanline_color(void *dest, INT32 scanline, const poly_extent *e
const poly_extra_data *extra = (const poly_extra_data *)extradata; const poly_extra_data *extra = (const poly_extra_data *)extradata;
bitmap_t *destmap = (bitmap_t *)dest; bitmap_t *destmap = (bitmap_t *)dest;
UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0); UINT16 *p = BITMAP_ADDR16(destmap, scanline, 0);
UINT32 *d = BITMAP_ADDR32(zbuffer, scanline, 0); UINT32 *d = BITMAP_ADDR32(extra->zbuffer, scanline, 0);
float ooz = extent->param[0].start; float ooz = extent->param[0].start;
float doozdx = extent->param[0].dpdx; float doozdx = extent->param[0].dpdx;
int fr = extra->color & 0x7c00; int fr = extra->color & 0x7c00;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -58,15 +58,16 @@ static void MODEL2_FUNC_NAME(void *dest, INT32 scanline, const poly_extent *exte
{ {
#if !defined( MODEL2_TRANSLUCENT) #if !defined( MODEL2_TRANSLUCENT)
const poly_extra_data *extra = (const poly_extra_data *)extradata; const poly_extra_data *extra = (const poly_extra_data *)extradata;
model2_state *state = extra->state;
bitmap_t *destmap = (bitmap_t *)dest; bitmap_t *destmap = (bitmap_t *)dest;
UINT32 *p = BITMAP_ADDR32(destmap, scanline, 0); UINT32 *p = BITMAP_ADDR32(destmap, scanline, 0);
/* extract color information */ /* extract color information */
const UINT16 *colortable_r = (const UINT16 *)&model2_colorxlat[0x0000/4]; const UINT16 *colortable_r = (const UINT16 *)&state->colorxlat[0x0000/4];
const UINT16 *colortable_g = (const UINT16 *)&model2_colorxlat[0x4000/4]; const UINT16 *colortable_g = (const UINT16 *)&state->colorxlat[0x4000/4];
const UINT16 *colortable_b = (const UINT16 *)&model2_colorxlat[0x8000/4]; const UINT16 *colortable_b = (const UINT16 *)&state->colorxlat[0x8000/4];
const UINT16 *lumaram = (const UINT16 *)model2_lumaram; const UINT16 *lumaram = (const UINT16 *)state->lumaram;
const UINT16 *palram = (const UINT16 *)model2_paletteram32; const UINT16 *palram = (const UINT16 *)state->paletteram32;
UINT32 lumabase = extra->lumabase; UINT32 lumabase = extra->lumabase;
UINT32 color = extra->colorbase; UINT32 color = extra->colorbase;
UINT8 luma; UINT8 luma;
@ -110,6 +111,7 @@ static void MODEL2_FUNC_NAME(void *dest, INT32 scanline, const poly_extent *exte
static void MODEL2_FUNC_NAME(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid) static void MODEL2_FUNC_NAME(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid)
{ {
const poly_extra_data *extra = (const poly_extra_data *)extradata; const poly_extra_data *extra = (const poly_extra_data *)extradata;
model2_state *state = extra->state;
bitmap_t *destmap = (bitmap_t *)dest; bitmap_t *destmap = (bitmap_t *)dest;
UINT32 *p = BITMAP_ADDR32(destmap, scanline, 0); UINT32 *p = BITMAP_ADDR32(destmap, scanline, 0);
@ -117,11 +119,11 @@ static void MODEL2_FUNC_NAME(void *dest, INT32 scanline, const poly_extent *exte
UINT32 tex_height = extra->texheight; UINT32 tex_height = extra->texheight;
/* extract color information */ /* extract color information */
const UINT16 *colortable_r = (const UINT16 *)&model2_colorxlat[0x0000/4]; const UINT16 *colortable_r = (const UINT16 *)&state->colorxlat[0x0000/4];
const UINT16 *colortable_g = (const UINT16 *)&model2_colorxlat[0x4000/4]; const UINT16 *colortable_g = (const UINT16 *)&state->colorxlat[0x4000/4];
const UINT16 *colortable_b = (const UINT16 *)&model2_colorxlat[0x8000/4]; const UINT16 *colortable_b = (const UINT16 *)&state->colorxlat[0x8000/4];
const UINT16 *lumaram = (const UINT16 *)model2_lumaram; const UINT16 *lumaram = (const UINT16 *)state->lumaram;
const UINT16 *palram = (const UINT16 *)model2_paletteram32; const UINT16 *palram = (const UINT16 *)state->paletteram32;
UINT32 colorbase = extra->colorbase; UINT32 colorbase = extra->colorbase;
UINT32 lumabase = extra->lumabase; UINT32 lumabase = extra->lumabase;
UINT32 tex_x = extra->texx; UINT32 tex_x = extra->texx;

File diff suppressed because it is too large Load Diff

View File

@ -10,11 +10,6 @@
#include "includes/konamigx.h" #include "includes/konamigx.h"
#include "includes/mystwarr.h" #include "includes/mystwarr.h"
static int layer_colorbase[6];
static int oinprion, cbparam;
static int sprite_colorbase, sub1_colorbase, last_psac_colorbase, gametype;
static int roz_enable, roz_rombank;
static tilemap_t *ult_936_tilemap;
// create a decoding buffer to hold decodable tiles so that the ROM test will pass by // create a decoding buffer to hold decodable tiles so that the ROM test will pass by
// reading the original raw data // reading the original raw data
@ -65,39 +60,44 @@ static void mystwarr_decode_tiles(running_machine *machine)
// Mystic Warriors requires tile based blending. // Mystic Warriors requires tile based blending.
static void mystwarr_tile_callback(int layer, int *code, int *color, int *flags) static void mystwarr_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
{ {
if (layer==1) {if ((*code&0xff00)+(*color)==0x4101) cbparam++; else cbparam--;} //* water hack (TEMPORARY) mystwarr_state *state = machine->driver_data<mystwarr_state>();
if (layer==1) {if ((*code&0xff00)+(*color)==0x4101) state->cbparam++; else state->cbparam--;} //* water hack (TEMPORARY)
*color = layer_colorbase[layer] | (*color>>1 & 0x1f); *color = state->layer_colorbase[layer] | (*color>>1 & 0x1f);
} }
// for games with 5bpp tile data // for games with 5bpp tile data
static void game5bpp_tile_callback(int layer, int *code, int *color, int *flags) static void game5bpp_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
{ {
*color = layer_colorbase[layer] | (*color>>1 & 0x1f); mystwarr_state *state = machine->driver_data<mystwarr_state>();
*color = state->layer_colorbase[layer] | (*color>>1 & 0x1f);
} }
// for games with 4bpp tile data // for games with 4bpp tile data
static void game4bpp_tile_callback(int layer, int *code, int *color, int *flags) static void game4bpp_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
{ {
*color = layer_colorbase[layer] | (*color>>2 & 0x0f); mystwarr_state *state = machine->driver_data<mystwarr_state>();
*color = state->layer_colorbase[layer] | (*color>>2 & 0x0f);
} }
static void mystwarr_sprite_callback(int *code, int *color, int *priority) static void mystwarr_sprite_callback(running_machine *machine, int *code, int *color, int *priority)
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
int c = *color; int c = *color;
*color = sprite_colorbase | (c & 0x001f); *color = state->sprite_colorbase | (c & 0x001f);
*priority = c & 0x00f0; *priority = c & 0x00f0;
} }
static void metamrph_sprite_callback(int *code, int *color, int *priority) static void metamrph_sprite_callback(running_machine *machine, int *code, int *color, int *priority)
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
int c = *color; int c = *color;
int attr = c; int attr = c;
c = (c & 0x1f) | sprite_colorbase; c = (c & 0x1f) | state->sprite_colorbase;
// Bit8 & 9 are effect attributes. It is not known whether the effects are generated by external logic. // Bit8 & 9 are effect attributes. It is not known whether the effects are generated by external logic.
if ((attr & 0x300) != 0x300) if ((attr & 0x300) != 0x300)
@ -112,26 +112,28 @@ static void metamrph_sprite_callback(int *code, int *color, int *priority)
} }
} }
static void gaiapols_sprite_callback(int *code, int *color, int *priority) static void gaiapols_sprite_callback(running_machine *machine, int *code, int *color, int *priority)
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
int c = *color; int c = *color;
*color = sprite_colorbase | (c>>4 & 0x20) | (c & 0x001f); *color = state->sprite_colorbase | (c>>4 & 0x20) | (c & 0x001f);
*priority = c & 0x00e0; *priority = c & 0x00e0;
} }
static void martchmp_sprite_callback(int *code, int *color, int *priority) static void martchmp_sprite_callback(running_machine *machine, int *code, int *color, int *priority)
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
int c = *color; int c = *color;
// Bit8 & 9 are effect attributes. It is not known whether the effects are generated by external logic. // Bit8 & 9 are effect attributes. It is not known whether the effects are generated by external logic.
if ((c & 0x3ff) == 0x11f) if ((c & 0x3ff) == 0x11f)
*color = K055555_FULLSHADOW; *color = K055555_FULLSHADOW;
else else
*color = sprite_colorbase | (c & 0x1f); *color = state->sprite_colorbase | (c & 0x1f);
if (oinprion & 0xf0) if (state->oinprion & 0xf0)
*priority = cbparam; // use PCU2 internal priority *priority = state->cbparam; // use PCU2 internal priority
else else
*priority = c & 0xf0; // use color implied priority *priority = c & 0xf0; // use color implied priority
} }
@ -140,6 +142,7 @@ static void martchmp_sprite_callback(int *code, int *color, int *priority)
static TILE_GET_INFO( get_gai_936_tile_info ) static TILE_GET_INFO( get_gai_936_tile_info )
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
int tileno, colour; int tileno, colour;
UINT8 *ROM = machine->region("gfx4")->base(); UINT8 *ROM = machine->region("gfx4")->base();
UINT8 *dat1 = ROM, *dat2 = ROM + 0x20000, *dat3 = ROM + 0x60000; UINT8 *dat1 = ROM, *dat2 = ROM + 0x20000, *dat3 = ROM + 0x60000;
@ -153,17 +156,18 @@ static TILE_GET_INFO( get_gai_936_tile_info )
if (dat2[tile_index] & 0x80) colour |= 0x10; if (dat2[tile_index] & 0x80) colour |= 0x10;
colour |= sub1_colorbase << 4; colour |= state->sub1_colorbase << 4;
SET_TILE_INFO(0, tileno, colour, 0); SET_TILE_INFO(0, tileno, colour, 0);
} }
VIDEO_START(gaiapols) VIDEO_START(gaiapols)
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
K055555_vh_start(machine); K055555_vh_start(machine);
K054338_vh_start(machine); K054338_vh_start(machine);
gametype = 0; state->gametype = 0;
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game4bpp_tile_callback, 0); K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game4bpp_tile_callback, 0);
@ -181,29 +185,31 @@ VIDEO_START(gaiapols)
K053936_wraparound_enable(0, 1); K053936_wraparound_enable(0, 1);
K053936GP_set_offset(0, -10, 0); // floor tiles in demo loop2 (Elaine vs. boss) K053936GP_set_offset(0, -10, 0); // floor tiles in demo loop2 (Elaine vs. boss)
ult_936_tilemap = tilemap_create(machine, get_gai_936_tile_info, tilemap_scan_rows, 16, 16, 512, 512); state->ult_936_tilemap = tilemap_create(machine, get_gai_936_tile_info, tilemap_scan_rows, 16, 16, 512, 512);
tilemap_set_transparent_pen(ult_936_tilemap, 0); tilemap_set_transparent_pen(state->ult_936_tilemap, 0);
} }
static TILE_GET_INFO( get_ult_936_tile_info ) static TILE_GET_INFO( get_ult_936_tile_info )
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
int tileno, colour; int tileno, colour;
UINT8 *ROM = machine->region("gfx4")->base(); UINT8 *ROM = machine->region("gfx4")->base();
UINT8 *dat1 = ROM, *dat2 = ROM + 0x40000; UINT8 *dat1 = ROM, *dat2 = ROM + 0x40000;
tileno = dat2[tile_index] | ((dat1[tile_index]&0x1f)<<8); tileno = dat2[tile_index] | ((dat1[tile_index]&0x1f)<<8);
colour = sub1_colorbase; colour = state->sub1_colorbase;
SET_TILE_INFO(0, tileno, colour, (dat1[tile_index]&0x40) ? TILE_FLIPX : 0); SET_TILE_INFO(0, tileno, colour, (dat1[tile_index]&0x40) ? TILE_FLIPX : 0);
} }
VIDEO_START(dadandrn) VIDEO_START(dadandrn)
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
K055555_vh_start(machine); K055555_vh_start(machine);
K054338_vh_start(machine); K054338_vh_start(machine);
gametype = 1; state->gametype = 1;
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game5bpp_tile_callback, 0); K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, game5bpp_tile_callback, 0);
@ -223,16 +229,17 @@ VIDEO_START(dadandrn)
K053936_wraparound_enable(0, 1); K053936_wraparound_enable(0, 1);
K053936GP_set_offset(0, -8, 0); // Brainy's laser K053936GP_set_offset(0, -8, 0); // Brainy's laser
ult_936_tilemap = tilemap_create(machine, get_ult_936_tile_info, tilemap_scan_rows, 16, 16, 512, 512); state->ult_936_tilemap = tilemap_create(machine, get_ult_936_tile_info, tilemap_scan_rows, 16, 16, 512, 512);
tilemap_set_transparent_pen(ult_936_tilemap, 0); tilemap_set_transparent_pen(state->ult_936_tilemap, 0);
} }
VIDEO_START(mystwarr) VIDEO_START(mystwarr)
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
K055555_vh_start(machine); K055555_vh_start(machine);
K054338_vh_start(machine); K054338_vh_start(machine);
gametype = 0; state->gametype = 0;
K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, mystwarr_tile_callback, 0); K056832_vh_start(machine, "gfx1", K056832_BPP_5, 0, NULL, mystwarr_tile_callback, 0);
@ -247,14 +254,15 @@ VIDEO_START(mystwarr)
K056832_set_LayerOffset(2, 2-3, 0); K056832_set_LayerOffset(2, 2-3, 0);
K056832_set_LayerOffset(3, 3-3, 0); K056832_set_LayerOffset(3, 3-3, 0);
cbparam = 0; state->cbparam = 0;
} }
VIDEO_START(metamrph) VIDEO_START(metamrph)
{ {
mystwarr_state *state = machine->driver_data<mystwarr_state>();
const char * rgn_250 = "gfx3"; const char * rgn_250 = "gfx3";
gametype = 0; state->gametype = 0;
K055555_vh_start(machine); K055555_vh_start(machine);
K054338_vh_start(machine); K054338_vh_start(machine);
@ -279,7 +287,8 @@ VIDEO_START(metamrph)
VIDEO_START(viostorm) VIDEO_START(viostorm)
{ {
gametype = 0; mystwarr_state *state = machine->driver_data<mystwarr_state>();
state->gametype = 0;
K055555_vh_start(machine); K055555_vh_start(machine);
K054338_vh_start(machine); K054338_vh_start(machine);
@ -300,7 +309,8 @@ VIDEO_START(viostorm)
VIDEO_START(martchmp) VIDEO_START(martchmp)
{ {
gametype = 0; mystwarr_state *state = machine->driver_data<mystwarr_state>();
state->gametype = 0;
K055555_vh_start(machine); K055555_vh_start(machine);
K054338_vh_start(machine); K054338_vh_start(machine);
@ -325,18 +335,19 @@ VIDEO_START(martchmp)
VIDEO_UPDATE(mystwarr) VIDEO_UPDATE(mystwarr)
{ {
mystwarr_state *state = screen->machine->driver_data<mystwarr_state>();
int i, old, blendmode=0; int i, old, blendmode=0;
if (cbparam<0) cbparam=0; else if (cbparam>=32) blendmode=(1<<16|GXMIX_BLEND_FORCE)<<2; //* water hack (TEMPORARY) if (state->cbparam<0) state->cbparam=0; else if (state->cbparam>=32) blendmode=(1<<16|GXMIX_BLEND_FORCE)<<2; //* water hack (TEMPORARY)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
old = layer_colorbase[i]; old = state->layer_colorbase[i];
layer_colorbase[i] = K055555_get_palette_index(i)<<4; state->layer_colorbase[i] = K055555_get_palette_index(i)<<4;
if( old != layer_colorbase[i] ) K056832_mark_plane_dirty(i); if( old != state->layer_colorbase[i] ) K056832_mark_plane_dirty(i);
} }
sprite_colorbase = K055555_get_palette_index(4)<<5; state->sprite_colorbase = K055555_get_palette_index(4)<<5;
konamigx_mixer(screen->machine, bitmap, cliprect, 0, 0, 0, 0, blendmode, 0, 0); konamigx_mixer(screen->machine, bitmap, cliprect, 0, 0, 0, 0, blendmode, 0, 0);
return 0; return 0;
@ -344,16 +355,17 @@ VIDEO_UPDATE(mystwarr)
VIDEO_UPDATE(metamrph) VIDEO_UPDATE(metamrph)
{ {
mystwarr_state *state = screen->machine->driver_data<mystwarr_state>();
int i, old; int i, old;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
old = layer_colorbase[i]; old = state->layer_colorbase[i];
layer_colorbase[i] = K055555_get_palette_index(i)<<4; state->layer_colorbase[i] = K055555_get_palette_index(i)<<4;
if (old != layer_colorbase[i]) K056832_mark_plane_dirty(i); if (old != state->layer_colorbase[i]) K056832_mark_plane_dirty(i);
} }
sprite_colorbase = K055555_get_palette_index(4)<<4; state->sprite_colorbase = K055555_get_palette_index(4)<<4;
konamigx_mixer(screen->machine, bitmap, cliprect, 0, GXSUB_K053250 | GXSUB_4BPP, 0, 0, 0, 0, 0); konamigx_mixer(screen->machine, bitmap, cliprect, 0, GXSUB_K053250 | GXSUB_4BPP, 0, 0, 0, 0, 0);
return 0; return 0;
@ -361,22 +373,23 @@ VIDEO_UPDATE(metamrph)
VIDEO_UPDATE(martchmp) VIDEO_UPDATE(martchmp)
{ {
mystwarr_state *state = screen->machine->driver_data<mystwarr_state>();
int i, old, blendmode; int i, old, blendmode;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
old = layer_colorbase[i]; old = state->layer_colorbase[i];
layer_colorbase[i] = K055555_get_palette_index(i)<<4; state->layer_colorbase[i] = K055555_get_palette_index(i)<<4;
if (old != layer_colorbase[i]) K056832_mark_plane_dirty(i); if (old != state->layer_colorbase[i]) K056832_mark_plane_dirty(i);
} }
sprite_colorbase = K055555_get_palette_index(4)<<5; state->sprite_colorbase = K055555_get_palette_index(4)<<5;
cbparam = K055555_read_register(K55_PRIINP_8); state->cbparam = K055555_read_register(K55_PRIINP_8);
oinprion = K055555_read_register(K55_OINPRI_ON); state->oinprion = K055555_read_register(K55_OINPRI_ON);
// not quite right // not quite right
blendmode = (oinprion==0xef && K054338_read_register(K338_REG_PBLEND)) ? ((1<<16|GXMIX_BLEND_FORCE)<<2) : 0; blendmode = (state->oinprion==0xef && K054338_read_register(K338_REG_PBLEND)) ? ((1<<16|GXMIX_BLEND_FORCE)<<2) : 0;
konamigx_mixer(screen->machine, bitmap, cliprect, 0, 0, 0, 0, blendmode, 0, 0); konamigx_mixer(screen->machine, bitmap, cliprect, 0, 0, 0, 0, blendmode, 0, 0);
return 0; return 0;
@ -386,16 +399,17 @@ VIDEO_UPDATE(martchmp)
WRITE16_HANDLER(ddd_053936_enable_w) WRITE16_HANDLER(ddd_053936_enable_w)
{ {
mystwarr_state *state = space->machine->driver_data<mystwarr_state>();
if (ACCESSING_BITS_8_15) if (ACCESSING_BITS_8_15)
{ {
roz_enable = data & 0x0100; state->roz_enable = data & 0x0100;
roz_rombank = (data & 0xc000)>>14; state->roz_rombank = (data & 0xc000)>>14;
} }
} }
WRITE16_HANDLER(ddd_053936_clip_w) WRITE16_HANDLER(ddd_053936_clip_w)
{ {
static UINT16 clip; mystwarr_state *state = space->machine->driver_data<mystwarr_state>();
int old, clip_x, clip_y, size_x, size_y; int old, clip_x, clip_y, size_x, size_y;
int minx, maxx, miny, maxy; int minx, maxx, miny, maxy;
@ -405,14 +419,14 @@ WRITE16_HANDLER(ddd_053936_clip_w)
} }
else else
{ {
old = clip; old = state->clip;
COMBINE_DATA(&clip); COMBINE_DATA(&state->clip);
if (clip != old) if (state->clip != old)
{ {
clip_x = (clip & 0x003f) >> 0; clip_x = (state->clip & 0x003f) >> 0;
clip_y = (clip & 0x0fc0) >> 6; clip_y = (state->clip & 0x0fc0) >> 6;
size_x = (clip & 0x3000) >> 12; size_x = (state->clip & 0x3000) >> 12;
size_y = (clip & 0xc000) >> 14; size_y = (state->clip & 0xc000) >> 14;
switch (size_x) switch (size_x)
{ {
@ -471,34 +485,37 @@ READ16_HANDLER(ddd_053936_tilerom_1_r)
// reference: 223db0 in gaiapolis (ROMs 32n, 29n, 26n) // reference: 223db0 in gaiapolis (ROMs 32n, 29n, 26n)
READ16_HANDLER(gai_053936_tilerom_2_r) READ16_HANDLER(gai_053936_tilerom_2_r)
{ {
mystwarr_state *state = space->machine->driver_data<mystwarr_state>();
UINT8 *ROM = (UINT8 *)space->machine->region("gfx3")->base(); UINT8 *ROM = (UINT8 *)space->machine->region("gfx3")->base();
offset += (roz_rombank * 0x100000); offset += (state->roz_rombank * 0x100000);
return ROM[offset/2]<<8; return ROM[offset/2]<<8;
} }
READ16_HANDLER(ddd_053936_tilerom_2_r) READ16_HANDLER(ddd_053936_tilerom_2_r)
{ {
mystwarr_state *state = space->machine->driver_data<mystwarr_state>();
UINT8 *ROM = (UINT8 *)space->machine->region("gfx3")->base(); UINT8 *ROM = (UINT8 *)space->machine->region("gfx3")->base();
offset += (roz_rombank * 0x100000); offset += (state->roz_rombank * 0x100000);
return ROM[offset]<<8; return ROM[offset]<<8;
} }
VIDEO_UPDATE(dadandrn) /* and gaiapols */ VIDEO_UPDATE(dadandrn) /* and gaiapols */
{ {
mystwarr_state *state = screen->machine->driver_data<mystwarr_state>();
int i, newbase, dirty, rozmode; int i, newbase, dirty, rozmode;
if (gametype == 0) if (state->gametype == 0)
{ {
sprite_colorbase = (K055555_get_palette_index(4)<<4)&0x7f; state->sprite_colorbase = (K055555_get_palette_index(4)<<4)&0x7f;
rozmode = GXSUB_4BPP; rozmode = GXSUB_4BPP;
} }
else else
{ {
sprite_colorbase = (K055555_get_palette_index(4)<<3)&0x7f; state->sprite_colorbase = (K055555_get_palette_index(4)<<3)&0x7f;
rozmode = GXSUB_8BPP; rozmode = GXSUB_8BPP;
} }
@ -507,9 +524,9 @@ VIDEO_UPDATE(dadandrn) /* and gaiapols */
for (i=0; i<4; i++) for (i=0; i<4; i++)
{ {
newbase = K055555_get_palette_index(i)<<4; newbase = K055555_get_palette_index(i)<<4;
if (layer_colorbase[i] != newbase) if (state->layer_colorbase[i] != newbase)
{ {
layer_colorbase[i] = newbase; state->layer_colorbase[i] = newbase;
K056832_mark_plane_dirty(i); K056832_mark_plane_dirty(i);
} }
} }
@ -519,9 +536,9 @@ VIDEO_UPDATE(dadandrn) /* and gaiapols */
for (dirty=0, i=0; i<4; i++) for (dirty=0, i=0; i<4; i++)
{ {
newbase = K055555_get_palette_index(i)<<4; newbase = K055555_get_palette_index(i)<<4;
if (layer_colorbase[i] != newbase) if (state->layer_colorbase[i] != newbase)
{ {
layer_colorbase[i] = newbase; state->layer_colorbase[i] = newbase;
dirty = 1; dirty = 1;
} }
} }
@ -529,17 +546,17 @@ VIDEO_UPDATE(dadandrn) /* and gaiapols */
} }
last_psac_colorbase = sub1_colorbase; state->last_psac_colorbase = state->sub1_colorbase;
sub1_colorbase = K055555_get_palette_index(5); state->sub1_colorbase = K055555_get_palette_index(5);
if (last_psac_colorbase != sub1_colorbase) if (state->last_psac_colorbase != state->sub1_colorbase)
{ {
tilemap_mark_all_tiles_dirty(ult_936_tilemap); tilemap_mark_all_tiles_dirty(state->ult_936_tilemap);
if (MW_VERBOSE) if (MW_VERBOSE)
popmessage("K053936: PSAC colorbase changed"); popmessage("K053936: PSAC colorbase changed");
} }
konamigx_mixer(screen->machine, bitmap, cliprect, (roz_enable) ? ult_936_tilemap : 0, rozmode, 0, 0, 0, 0, 0); konamigx_mixer(screen->machine, bitmap, cliprect, (state->roz_enable) ? state->ult_936_tilemap : 0, rozmode, 0, 0, 0, 0, 0);
return 0; return 0;
} }

View File

@ -12,7 +12,8 @@
void qdrmfgp_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags) void qdrmfgp_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)
{ {
*color = ((*color>>2) & 0x0f) | qdrmfgp_get_palette(); qdrmfgp_state *state = machine->driver_data<qdrmfgp_state>();
*color = ((*color>>2) & 0x0f) | state->pal;
} }
void qdrmfgp2_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags) void qdrmfgp2_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags)

View File

@ -15,9 +15,6 @@
#define IRQ_CLOCK (U34_CLOCK/0x1f788) /* 40Hz interrupt */ #define IRQ_CLOCK (U34_CLOCK/0x1f788) /* 40Hz interrupt */
UINT8 *segag80v_vectorram;
size_t segag80v_vectorram_size;
static int min_x, min_y;
/* /*
@ -79,7 +76,7 @@ static int min_x, min_y;
*/ */
INLINE int adjust_xy(int rawx, int rawy, int *outx, int *outy) INLINE int adjust_xy(segag80v_state *state, int rawx, int rawy, int *outx, int *outy)
{ {
int clipped = FALSE; int clipped = FALSE;
@ -104,18 +101,19 @@ INLINE int adjust_xy(int rawx, int rawy, int *outx, int *outy)
*outy &= 0x3ff; *outy &= 0x3ff;
/* convert into .16 values */ /* convert into .16 values */
*outx = (*outx - (min_x - 512)) << 16; *outx = (*outx - (state->min_x - 512)) << 16;
*outy = (*outy - (min_y - 512)) << 16; *outy = (*outy - (state->min_y - 512)) << 16;
return clipped; return clipped;
} }
static void sega_generate_vector_list(running_machine *machine) static void sega_generate_vector_list(running_machine *machine)
{ {
segag80v_state *state = machine->driver_data<segag80v_state>();
UINT8 *sintable = machine->region("proms")->base(); UINT8 *sintable = machine->region("proms")->base();
double total_time = 1.0 / (double)IRQ_CLOCK; double total_time = 1.0 / (double)IRQ_CLOCK;
UINT16 symaddr = 0; UINT16 symaddr = 0;
UINT8 *vectorram = segag80v_vectorram; UINT8 *vectorram = state->vectorram;
vector_clear_list(); vector_clear_list();
@ -178,7 +176,7 @@ static void sega_generate_vector_list(running_machine *machine)
int adjx, adjy, clipped; int adjx, adjy, clipped;
/* Add a starting point to the vector list. */ /* Add a starting point to the vector list. */
clipped = adjust_xy(curx, cury, &adjx, &adjy); clipped = adjust_xy(state, curx, cury, &adjx, &adjy);
if (!clipped) if (!clipped)
vector_add_point(machine, adjx, adjy, 0, 0); vector_add_point(machine, adjx, adjy, 0, 0);
@ -244,7 +242,7 @@ static void sega_generate_vector_list(running_machine *machine)
intensity = 0; intensity = 0;
/* Loop over the length of the vector. */ /* Loop over the length of the vector. */
clipped = adjust_xy(curx, cury, &adjx, &adjy); clipped = adjust_xy(state, curx, cury, &adjx, &adjy);
xaccum = yaccum = 0; xaccum = yaccum = 0;
while (length-- != 0 && total_time > 0) while (length-- != 0 && total_time > 0)
{ {
@ -283,7 +281,7 @@ static void sega_generate_vector_list(running_machine *machine)
/* Apply the clipping from the DAC circuit. If the values clip */ /* Apply the clipping from the DAC circuit. If the values clip */
/* the beam is turned off, but the computations continue right */ /* the beam is turned off, but the computations continue right */
/* on going. */ /* on going. */
newclip = adjust_xy(curx, cury, &adjx, &adjy); newclip = adjust_xy(state, curx, cury, &adjx, &adjy);
if (newclip != clipped) if (newclip != clipped)
{ {
/* if we're just becoming unclipped, add an empty point */ /* if we're just becoming unclipped, add an empty point */
@ -327,10 +325,11 @@ static void sega_generate_vector_list(running_machine *machine)
VIDEO_START( segag80v ) VIDEO_START( segag80v )
{ {
assert_always(segag80v_vectorram_size != 0, "segag80v_vectorram==0"); segag80v_state *state = machine->driver_data<segag80v_state>();
assert_always(state->vectorram_size != 0, "vectorram==0");
min_x =machine->primary_screen->visible_area().min_x; state->min_x =machine->primary_screen->visible_area().min_x;
min_y =machine->primary_screen->visible_area().min_y; state->min_y =machine->primary_screen->visible_area().min_y;
VIDEO_START_CALL(vector); VIDEO_START_CALL(vector);
} }

File diff suppressed because it is too large Load Diff

View File

@ -9,11 +9,7 @@
#include "emu.h" #include "emu.h"
#include "includes/suprloco.h" #include "includes/suprloco.h"
UINT8 *suprloco_videoram;
UINT8 *suprloco_scrollram;
static tilemap_t *bg_tilemap;
static int control;
#define SPR_Y_TOP 0 #define SPR_Y_TOP 0
#define SPR_Y_BOTTOM 1 #define SPR_Y_BOTTOM 1
@ -80,10 +76,11 @@ PALETTE_INIT( suprloco )
static TILE_GET_INFO( get_tile_info ) static TILE_GET_INFO( get_tile_info )
{ {
UINT8 attr = suprloco_videoram[2*tile_index+1]; suprloco_state *state = machine->driver_data<suprloco_state>();
UINT8 attr = state->videoram[2*tile_index+1];
SET_TILE_INFO( SET_TILE_INFO(
0, 0,
suprloco_videoram[2*tile_index] | ((attr & 0x03) << 8), state->videoram[2*tile_index] | ((attr & 0x03) << 8),
(attr & 0x1c) >> 2, (attr & 0x1c) >> 2,
0); 0);
tileinfo->category = (attr & 0x20) >> 5; tileinfo->category = (attr & 0x20) >> 5;
@ -99,9 +96,10 @@ static TILE_GET_INFO( get_tile_info )
VIDEO_START( suprloco ) VIDEO_START( suprloco )
{ {
bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32); suprloco_state *state = machine->driver_data<suprloco_state>();
state->bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,32,32);
tilemap_set_scroll_rows(bg_tilemap,32); tilemap_set_scroll_rows(state->bg_tilemap,32);
} }
@ -114,20 +112,23 @@ VIDEO_START( suprloco )
WRITE8_HANDLER( suprloco_videoram_w ) WRITE8_HANDLER( suprloco_videoram_w )
{ {
suprloco_videoram[offset] = data; suprloco_state *state = space->machine->driver_data<suprloco_state>();
tilemap_mark_tile_dirty(bg_tilemap,offset/2); state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap,offset/2);
} }
WRITE8_HANDLER( suprloco_scrollram_w ) WRITE8_HANDLER( suprloco_scrollram_w )
{ {
suprloco_state *state = space->machine->driver_data<suprloco_state>();
int adj = flip_screen_get(space->machine) ? -8 : 8; int adj = flip_screen_get(space->machine) ? -8 : 8;
suprloco_scrollram[offset] = data; state->scrollram[offset] = data;
tilemap_set_scrollx(bg_tilemap,offset, data - adj); tilemap_set_scrollx(state->bg_tilemap,offset, data - adj);
} }
WRITE8_HANDLER( suprloco_control_w ) WRITE8_HANDLER( suprloco_control_w )
{ {
suprloco_state *state = space->machine->driver_data<suprloco_state>();
/* There is probably a palette select in here */ /* There is probably a palette select in here */
/* Bit 0 - coin counter A */ /* Bit 0 - coin counter A */
@ -138,7 +139,7 @@ WRITE8_HANDLER( suprloco_control_w )
/* Bit 6 - probably unused */ /* Bit 6 - probably unused */
/* Bit 7 - flip screen */ /* Bit 7 - flip screen */
if ((control & 0x10) != (data & 0x10)) if ((state->control & 0x10) != (data & 0x10))
{ {
/*logerror("Bit 4 = %d\n", (data >> 4) & 1); */ /*logerror("Bit 4 = %d\n", (data >> 4) & 1); */
} }
@ -148,13 +149,14 @@ WRITE8_HANDLER( suprloco_control_w )
flip_screen_set(space->machine, data & 0x80); flip_screen_set(space->machine, data & 0x80);
control = data; state->control = data;
} }
READ8_HANDLER( suprloco_control_r ) READ8_HANDLER( suprloco_control_r )
{ {
return control; suprloco_state *state = space->machine->driver_data<suprloco_state>();
return state->control;
} }
@ -179,6 +181,7 @@ INLINE void draw_pixel(bitmap_t *bitmap,const rectangle *cliprect,int x,int y,in
static void draw_sprite(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int spr_number) static void draw_sprite(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int spr_number)
{ {
suprloco_state *state = machine->driver_data<suprloco_state>();
int flip = flip_screen_get(machine); int flip = flip_screen_get(machine);
int sx,sy,col,row,height,src,adjy,dy; int sx,sy,col,row,height,src,adjy,dy;
UINT8 *spr_reg; UINT8 *spr_reg;
@ -193,7 +196,7 @@ static void draw_sprite(running_machine *machine, bitmap_t *bitmap,const rectang
skip = spr_reg[SPR_SKIP_LO] + (spr_reg[SPR_SKIP_HI] << 8); skip = spr_reg[SPR_SKIP_LO] + (spr_reg[SPR_SKIP_HI] << 8);
height = spr_reg[SPR_Y_BOTTOM] - spr_reg[SPR_Y_TOP]; height = spr_reg[SPR_Y_BOTTOM] - spr_reg[SPR_Y_TOP];
pen_base = 0x100 + 0x10 * (spr_reg[SPR_COL]&0x03) + ((control & 0x20)?0x100:0); pen_base = 0x100 + 0x10 * (spr_reg[SPR_COL]&0x03) + ((state->control & 0x20)?0x100:0);
sx = spr_reg[SPR_X]; sx = spr_reg[SPR_X];
sy = spr_reg[SPR_Y_TOP] + 1; sy = spr_reg[SPR_Y_TOP] + 1;
@ -267,8 +270,9 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( suprloco ) VIDEO_UPDATE( suprloco )
{ {
tilemap_draw(bitmap,cliprect,bg_tilemap,0,0); suprloco_state *state = screen->machine->driver_data<suprloco_state>();
tilemap_draw(bitmap,cliprect,state->bg_tilemap,0,0);
draw_sprites(screen->machine,bitmap,cliprect); draw_sprites(screen->machine,bitmap,cliprect);
tilemap_draw(bitmap,cliprect,bg_tilemap,1,0); tilemap_draw(bitmap,cliprect,state->bg_tilemap,1,0);
return 0; return 0;
} }

View File

@ -81,21 +81,6 @@
#include "emu.h" #include "emu.h"
#include "includes/system1.h" #include "includes/system1.h"
static UINT8 *mix_collide;
static UINT8 mix_collide_summary;
static UINT8 *sprite_collide;
static UINT8 sprite_collide_summary;
static bitmap_t *sprite_bitmap;
static UINT8 system1_video_mode;
static UINT8 videoram_bank;
static tilemap_t *tilemap_page[8];
static UINT8 tilemap_pages;
/************************************* /*************************************
* *
@ -127,31 +112,31 @@ static void video_start_common(running_machine *machine, int pagecount)
int pagenum; int pagenum;
/* allocate memory for the collision arrays */ /* allocate memory for the collision arrays */
mix_collide = auto_alloc_array_clear(machine, UINT8, 64); state->mix_collide = auto_alloc_array_clear(machine, UINT8, 64);
sprite_collide = auto_alloc_array_clear(machine, UINT8, 1024); state->sprite_collide = auto_alloc_array_clear(machine, UINT8, 1024);
/* allocate memory for videoram */ /* allocate memory for videoram */
tilemap_pages = pagecount; state->tilemap_pages = pagecount;
state->videoram = auto_alloc_array_clear(machine, UINT8, 0x800 * pagecount); state->videoram = auto_alloc_array_clear(machine, UINT8, 0x800 * pagecount);
/* create the tilemap pages */ /* create the tilemap pages */
for (pagenum = 0; pagenum < pagecount; pagenum++) for (pagenum = 0; pagenum < pagecount; pagenum++)
{ {
tilemap_page[pagenum] = tilemap_create(machine, tile_get_info, tilemap_scan_rows, 8,8, 32,32); state->tilemap_page[pagenum] = tilemap_create(machine, tile_get_info, tilemap_scan_rows, 8,8, 32,32);
tilemap_set_transparent_pen(tilemap_page[pagenum], 0); tilemap_set_transparent_pen(state->tilemap_page[pagenum], 0);
tilemap_set_user_data(tilemap_page[pagenum], state->videoram + 0x800 * pagenum); tilemap_set_user_data(state->tilemap_page[pagenum], state->videoram + 0x800 * pagenum);
} }
/* allocate a temporary bitmap for sprite rendering */ /* allocate a temporary bitmap for sprite rendering */
sprite_bitmap = auto_bitmap_alloc(machine, 256, 256, BITMAP_FORMAT_INDEXED16); state->sprite_bitmap = auto_bitmap_alloc(machine, 256, 256, BITMAP_FORMAT_INDEXED16);
/* register for save stats */ /* register for save stats */
state_save_register_global(machine, system1_video_mode); state_save_register_global(machine, state->video_mode);
state_save_register_global(machine, mix_collide_summary); state_save_register_global(machine, state->mix_collide_summary);
state_save_register_global(machine, sprite_collide_summary); state_save_register_global(machine, state->sprite_collide_summary);
state->save_pointer(NAME(state->videoram), 0x800 * pagecount); state->save_pointer(NAME(state->videoram), 0x800 * pagecount);
state_save_register_global_pointer(machine, mix_collide, 64); state_save_register_global_pointer(machine, state->mix_collide, 64);
state_save_register_global_pointer(machine, sprite_collide, 1024); state_save_register_global_pointer(machine, state->sprite_collide, 1024);
} }
@ -176,10 +161,11 @@ VIDEO_START( system2 )
WRITE8_HANDLER( system1_videomode_w ) WRITE8_HANDLER( system1_videomode_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
if (data & 0x6e) logerror("videomode = %02x\n",data); if (data & 0x6e) logerror("videomode = %02x\n",data);
/* bit 4 is screen blank */ /* bit 4 is screen blank */
system1_video_mode = data; state->video_mode = data;
/* bit 7 is flip screen */ /* bit 7 is flip screen */
flip_screen_set(space->machine, data & 0x80); flip_screen_set(space->machine, data & 0x80);
@ -195,20 +181,23 @@ if (data & 0x6e) logerror("videomode = %02x\n",data);
READ8_HANDLER( system1_mixer_collision_r ) READ8_HANDLER( system1_mixer_collision_r )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
space->machine->primary_screen->update_now(); space->machine->primary_screen->update_now();
return mix_collide[offset & 0x3f] | 0x7e | (mix_collide_summary << 7); return state->mix_collide[offset & 0x3f] | 0x7e | (state->mix_collide_summary << 7);
} }
WRITE8_HANDLER( system1_mixer_collision_w ) WRITE8_HANDLER( system1_mixer_collision_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
space->machine->primary_screen->update_now(); space->machine->primary_screen->update_now();
mix_collide[offset & 0x3f] = 0; state->mix_collide[offset & 0x3f] = 0;
} }
WRITE8_HANDLER( system1_mixer_collision_reset_w ) WRITE8_HANDLER( system1_mixer_collision_reset_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
space->machine->primary_screen->update_now(); space->machine->primary_screen->update_now();
mix_collide_summary = 0; state->mix_collide_summary = 0;
} }
@ -221,20 +210,23 @@ WRITE8_HANDLER( system1_mixer_collision_reset_w )
READ8_HANDLER( system1_sprite_collision_r ) READ8_HANDLER( system1_sprite_collision_r )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
space->machine->primary_screen->update_now(); space->machine->primary_screen->update_now();
return sprite_collide[offset & 0x3ff] | 0x7e | (sprite_collide_summary << 7); return state->sprite_collide[offset & 0x3ff] | 0x7e | (state->sprite_collide_summary << 7);
} }
WRITE8_HANDLER( system1_sprite_collision_w ) WRITE8_HANDLER( system1_sprite_collision_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
space->machine->primary_screen->update_now(); space->machine->primary_screen->update_now();
sprite_collide[offset & 0x3ff] = 0; state->sprite_collide[offset & 0x3ff] = 0;
} }
WRITE8_HANDLER( system1_sprite_collision_reset_w ) WRITE8_HANDLER( system1_sprite_collision_reset_w )
{ {
system1_state *state = space->machine->driver_data<system1_state>();
space->machine->primary_screen->update_now(); space->machine->primary_screen->update_now();
sprite_collide_summary = 0; state->sprite_collide_summary = 0;
} }
@ -265,7 +257,7 @@ READ8_HANDLER( system1_videoram_r )
system1_state *state = space->machine->driver_data<system1_state>(); system1_state *state = space->machine->driver_data<system1_state>();
UINT8 *videoram = state->videoram; UINT8 *videoram = state->videoram;
videoram_wait_states(space->machine->firstcpu); videoram_wait_states(space->machine->firstcpu);
offset |= 0x1000 * ((videoram_bank >> 1) % (tilemap_pages / 2)); offset |= 0x1000 * ((state->videoram_bank >> 1) % (state->tilemap_pages / 2));
return videoram[offset]; return videoram[offset];
} }
@ -274,19 +266,20 @@ WRITE8_HANDLER( system1_videoram_w )
system1_state *state = space->machine->driver_data<system1_state>(); system1_state *state = space->machine->driver_data<system1_state>();
UINT8 *videoram = state->videoram; UINT8 *videoram = state->videoram;
videoram_wait_states(space->machine->firstcpu); videoram_wait_states(space->machine->firstcpu);
offset |= 0x1000 * ((videoram_bank >> 1) % (tilemap_pages / 2)); offset |= 0x1000 * ((state->videoram_bank >> 1) % (state->tilemap_pages / 2));
videoram[offset] = data; videoram[offset] = data;
tilemap_mark_tile_dirty(tilemap_page[offset / 0x800], (offset % 0x800) / 2); tilemap_mark_tile_dirty(state->tilemap_page[offset / 0x800], (offset % 0x800) / 2);
/* force a partial update if the page is changing */ /* force a partial update if the page is changing */
if (tilemap_pages > 2 && offset >= 0x740 && offset < 0x748 && offset % 2 == 0) if (state->tilemap_pages > 2 && offset >= 0x740 && offset < 0x748 && offset % 2 == 0)
space->machine->primary_screen->update_now(); space->machine->primary_screen->update_now();
} }
WRITE8_DEVICE_HANDLER( system1_videoram_bank_w ) WRITE8_DEVICE_HANDLER( system1_videoram_bank_w )
{ {
videoram_bank = data; system1_state *state = device->machine->driver_data<system1_state>();
state->videoram_bank = data;
} }
@ -370,6 +363,7 @@ WRITE8_HANDLER( system1_paletteram_w )
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int xoffset) static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int xoffset)
{ {
system1_state *state = machine->driver_data<system1_state>();
UINT32 gfxbanks = machine->region("sprites")->bytes() / 0x8000; UINT32 gfxbanks = machine->region("sprites")->bytes() / 0x8000;
const UINT8 *gfxbase = machine->region("sprites")->base(); const UINT8 *gfxbase = machine->region("sprites")->base();
UINT8 *spriteram = machine->generic.spriteram.u8; UINT8 *spriteram = machine->generic.spriteram.u8;
@ -456,7 +450,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int prevpix = destbase[effx]; int prevpix = destbase[effx];
if ((prevpix & 0x0f) != 0) if ((prevpix & 0x0f) != 0)
sprite_collide[((prevpix >> 4) & 0x1f) + 32 * spritenum] = sprite_collide_summary = 1; state->sprite_collide[((prevpix >> 4) & 0x1f) + 32 * spritenum] = state->sprite_collide_summary = 1;
destbase[effx] = color1 | palettebase; destbase[effx] = color1 | palettebase;
} }
} }
@ -474,7 +468,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
int prevpix = destbase[effx]; int prevpix = destbase[effx];
if ((prevpix & 0x0f) != 0) if ((prevpix & 0x0f) != 0)
sprite_collide[((prevpix >> 4) & 0x1f) + 32 * spritenum] = sprite_collide_summary = 1; state->sprite_collide[((prevpix >> 4) & 0x1f) + 32 * spritenum] = state->sprite_collide_summary = 1;
destbase[effx] = color2 | palettebase; destbase[effx] = color2 | palettebase;
} }
} }
@ -493,18 +487,19 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static void video_update_common(device_t *screen, bitmap_t *bitmap, const rectangle *cliprect, bitmap_t *fgpixmap, bitmap_t **bgpixmaps, const int *bgrowscroll, int bgyscroll, int spritexoffs) static void video_update_common(device_t *screen, bitmap_t *bitmap, const rectangle *cliprect, bitmap_t *fgpixmap, bitmap_t **bgpixmaps, const int *bgrowscroll, int bgyscroll, int spritexoffs)
{ {
system1_state *state = screen->machine->driver_data<system1_state>();
const UINT8 *lookup = screen->machine->region("proms")->base(); const UINT8 *lookup = screen->machine->region("proms")->base();
int x, y; int x, y;
/* first clear the sprite bitmap and draw sprites within this area */ /* first clear the sprite bitmap and draw sprites within this area */
bitmap_fill(sprite_bitmap, cliprect, 0); bitmap_fill(state->sprite_bitmap, cliprect, 0);
draw_sprites(screen->machine, sprite_bitmap, cliprect, spritexoffs); draw_sprites(screen->machine, state->sprite_bitmap, cliprect, spritexoffs);
/* iterate over rows */ /* iterate over rows */
for (y = cliprect->min_y; y <= cliprect->max_y; y++) for (y = cliprect->min_y; y <= cliprect->max_y; y++)
{ {
UINT16 *fgbase = BITMAP_ADDR16(fgpixmap, y & 0xff, 0); UINT16 *fgbase = BITMAP_ADDR16(fgpixmap, y & 0xff, 0);
UINT16 *sprbase = BITMAP_ADDR16(sprite_bitmap, y & 0xff, 0); UINT16 *sprbase = BITMAP_ADDR16(state->sprite_bitmap, y & 0xff, 0);
UINT16 *dstbase = BITMAP_ADDR16(bitmap, y, 0); UINT16 *dstbase = BITMAP_ADDR16(bitmap, y, 0);
int bgy = (y + bgyscroll) & 0x1ff; int bgy = (y + bgyscroll) & 0x1ff;
int bgxscroll = bgrowscroll[y / 8]; int bgxscroll = bgrowscroll[y / 8];
@ -534,11 +529,11 @@ static void video_update_common(device_t *screen, bitmap_t *bitmap, const rectan
/* compute collisions based on two of the PROM bits */ /* compute collisions based on two of the PROM bits */
if (!(lookup_value & 4)) if (!(lookup_value & 4))
mix_collide[((lookup_value & 8) << 2) | ((sprpix >> 4) & 0x1f)] = mix_collide_summary = 1; state->mix_collide[((lookup_value & 8) << 2) | ((sprpix >> 4) & 0x1f)] = state->mix_collide_summary = 1;
/* the lower 2 PROM bits select the palette and which pixels */ /* the lower 2 PROM bits select the palette and which pixels */
lookup_value &= 3; lookup_value &= 3;
if (system1_video_mode & 0x10) if (state->video_mode & 0x10)
dstbase[x] = 0; dstbase[x] = 0;
else if (lookup_value == 0) else if (lookup_value == 0)
dstbase[x] = 0x000 | (sprpix & 0x1ff); dstbase[x] = 0x000 | (sprpix & 0x1ff);
@ -568,10 +563,10 @@ VIDEO_UPDATE( system1 )
int y; int y;
/* all 4 background pages are the same, fixed to page 0 */ /* all 4 background pages are the same, fixed to page 0 */
bgpixmaps[0] = bgpixmaps[1] = bgpixmaps[2] = bgpixmaps[3] = tilemap_get_pixmap(tilemap_page[0]); bgpixmaps[0] = bgpixmaps[1] = bgpixmaps[2] = bgpixmaps[3] = tilemap_get_pixmap(state->tilemap_page[0]);
/* foreground is fixed to page 1 */ /* foreground is fixed to page 1 */
fgpixmap = tilemap_get_pixmap(tilemap_page[1]); fgpixmap = tilemap_get_pixmap(state->tilemap_page[1]);
/* get fixed scroll offsets */ /* get fixed scroll offsets */
xscroll = (videoram[0xffc] | (videoram[0xffd] << 8)) / 2 + 14; xscroll = (videoram[0xffc] | (videoram[0xffd] << 8)) / 2 + 14;
@ -605,13 +600,13 @@ VIDEO_UPDATE( system2 )
int y; int y;
/* 4 independent background pages */ /* 4 independent background pages */
bgpixmaps[0] = tilemap_get_pixmap(tilemap_page[videoram[0x740] & 7]); bgpixmaps[0] = tilemap_get_pixmap(state->tilemap_page[videoram[0x740] & 7]);
bgpixmaps[1] = tilemap_get_pixmap(tilemap_page[videoram[0x742] & 7]); bgpixmaps[1] = tilemap_get_pixmap(state->tilemap_page[videoram[0x742] & 7]);
bgpixmaps[2] = tilemap_get_pixmap(tilemap_page[videoram[0x744] & 7]); bgpixmaps[2] = tilemap_get_pixmap(state->tilemap_page[videoram[0x744] & 7]);
bgpixmaps[3] = tilemap_get_pixmap(tilemap_page[videoram[0x746] & 7]); bgpixmaps[3] = tilemap_get_pixmap(state->tilemap_page[videoram[0x746] & 7]);
/* foreground is fixed to page 0 */ /* foreground is fixed to page 0 */
fgpixmap = tilemap_get_pixmap(tilemap_page[0]); fgpixmap = tilemap_get_pixmap(state->tilemap_page[0]);
/* get scroll offsets */ /* get scroll offsets */
if (!flip_screen_get(screen->machine)) if (!flip_screen_get(screen->machine))
@ -647,13 +642,13 @@ VIDEO_UPDATE( system2_rowscroll )
int y; int y;
/* 4 independent background pages */ /* 4 independent background pages */
bgpixmaps[0] = tilemap_get_pixmap(tilemap_page[videoram[0x740] & 7]); bgpixmaps[0] = tilemap_get_pixmap(state->tilemap_page[videoram[0x740] & 7]);
bgpixmaps[1] = tilemap_get_pixmap(tilemap_page[videoram[0x742] & 7]); bgpixmaps[1] = tilemap_get_pixmap(state->tilemap_page[videoram[0x742] & 7]);
bgpixmaps[2] = tilemap_get_pixmap(tilemap_page[videoram[0x744] & 7]); bgpixmaps[2] = tilemap_get_pixmap(state->tilemap_page[videoram[0x744] & 7]);
bgpixmaps[3] = tilemap_get_pixmap(tilemap_page[videoram[0x746] & 7]); bgpixmaps[3] = tilemap_get_pixmap(state->tilemap_page[videoram[0x746] & 7]);
/* foreground is fixed to page 0 */ /* foreground is fixed to page 0 */
fgpixmap = tilemap_get_pixmap(tilemap_page[0]); fgpixmap = tilemap_get_pixmap(state->tilemap_page[0]);
/* get scroll offsets */ /* get scroll offsets */
if (!flip_screen_get(screen->machine)) if (!flip_screen_get(screen->machine))

View File

@ -11,18 +11,7 @@
#include "includes/tp84.h" #include "includes/tp84.h"
UINT8 *tp84_bg_videoram;
UINT8 *tp84_bg_colorram;
UINT8 *tp84_fg_videoram;
UINT8 *tp84_fg_colorram;
UINT8 *tp84_spriteram;
UINT8 *tp84_scroll_x;
UINT8 *tp84_scroll_y;
UINT8 *tp84_palette_bank;
UINT8 *tp84_flipscreen_x;
UINT8 *tp84_flipscreen_y;
static tilemap_t *bg_tilemap, *fg_tilemap;
/* /*
@ -116,9 +105,10 @@ PALETTE_INIT( tp84 )
WRITE8_HANDLER( tp84_spriteram_w ) WRITE8_HANDLER( tp84_spriteram_w )
{ {
tp84_state *state = space->machine->driver_data<tp84_state>();
/* the game multiplexes the sprites, so update now */ /* the game multiplexes the sprites, so update now */
space->machine->primary_screen->update_now(); space->machine->primary_screen->update_now();
tp84_spriteram[offset] = data; state->spriteram[offset] = data;
} }
@ -131,22 +121,24 @@ READ8_HANDLER( tp84_scanline_r )
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
int code = ((tp84_bg_colorram[tile_index] & 0x30) << 4) | tp84_bg_videoram[tile_index]; tp84_state *state = machine->driver_data<tp84_state>();
int color = ((*tp84_palette_bank & 0x07) << 6) | int code = ((state->bg_colorram[tile_index] & 0x30) << 4) | state->bg_videoram[tile_index];
((*tp84_palette_bank & 0x18) << 1) | int color = ((*state->palette_bank & 0x07) << 6) |
(tp84_bg_colorram[tile_index] & 0x0f); ((*state->palette_bank & 0x18) << 1) |
int flags = TILE_FLIPYX(tp84_bg_colorram[tile_index] >> 6); (state->bg_colorram[tile_index] & 0x0f);
int flags = TILE_FLIPYX(state->bg_colorram[tile_index] >> 6);
SET_TILE_INFO(0, code, color, flags); SET_TILE_INFO(0, code, color, flags);
} }
static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_fg_tile_info )
{ {
int code = ((tp84_fg_colorram[tile_index] & 0x30) << 4) | tp84_fg_videoram[tile_index]; tp84_state *state = machine->driver_data<tp84_state>();
int color = ((*tp84_palette_bank & 0x07) << 6) | int code = ((state->fg_colorram[tile_index] & 0x30) << 4) | state->fg_videoram[tile_index];
((*tp84_palette_bank & 0x18) << 1) | int color = ((*state->palette_bank & 0x07) << 6) |
(tp84_fg_colorram[tile_index] & 0x0f); ((*state->palette_bank & 0x18) << 1) |
int flags = TILE_FLIPYX(tp84_fg_colorram[tile_index] >> 6); (state->fg_colorram[tile_index] & 0x0f);
int flags = TILE_FLIPYX(state->fg_colorram[tile_index] >> 6);
SET_TILE_INFO(0, code, color, flags); SET_TILE_INFO(0, code, color, flags);
} }
@ -154,25 +146,27 @@ static TILE_GET_INFO( get_fg_tile_info )
VIDEO_START( tp84 ) VIDEO_START( tp84 )
{ {
bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); tp84_state *state = machine->driver_data<tp84_state>();
fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
} }
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)
{ {
tp84_state *state = machine->driver_data<tp84_state>();
int offs; int offs;
int palette_base = ((*tp84_palette_bank & 0x07) << 4); int palette_base = ((*state->palette_bank & 0x07) << 4);
for (offs = 0x5c; offs >= 0; offs -= 4) for (offs = 0x5c; offs >= 0; offs -= 4)
{ {
int x = tp84_spriteram[offs]; int x = state->spriteram[offs];
int y = 240 - tp84_spriteram[offs + 3]; int y = 240 - state->spriteram[offs + 3];
int code = tp84_spriteram[offs + 1]; int code = state->spriteram[offs + 1];
int color = palette_base | (tp84_spriteram[offs + 2] & 0x0f); int color = palette_base | (state->spriteram[offs + 2] & 0x0f);
int flip_x = ~tp84_spriteram[offs + 2] & 0x40; int flip_x = ~state->spriteram[offs + 2] & 0x40;
int flip_y = tp84_spriteram[offs + 2] & 0x80; int flip_y = state->spriteram[offs + 2] & 0x80;
drawgfx_transmask(bitmap, cliprect, machine->gfx[1], code, color, flip_x, flip_y, x, y, drawgfx_transmask(bitmap, cliprect, machine->gfx[1], code, color, flip_x, flip_y, x, y,
colortable_get_transpen_mask(machine->colortable, machine->gfx[1], color, palette_base)); colortable_get_transpen_mask(machine->colortable, machine->gfx[1], color, palette_base));
@ -183,6 +177,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( tp84 ) VIDEO_UPDATE( tp84 )
{ {
tp84_state *state = screen->machine->driver_data<tp84_state>();
rectangle clip = *cliprect; rectangle clip = *cliprect;
const rectangle &visarea = screen->visible_area(); const rectangle &visarea = screen->visible_area();
@ -190,25 +185,25 @@ VIDEO_UPDATE( tp84 )
{ {
tilemap_mark_all_tiles_dirty_all(screen->machine); tilemap_mark_all_tiles_dirty_all(screen->machine);
tilemap_set_scrollx(bg_tilemap, 0, *tp84_scroll_x); tilemap_set_scrollx(state->bg_tilemap, 0, *state->scroll_x);
tilemap_set_scrolly(bg_tilemap, 0, *tp84_scroll_y); tilemap_set_scrolly(state->bg_tilemap, 0, *state->scroll_y);
tilemap_set_flip_all(screen->machine, ((*tp84_flipscreen_x & 0x01) ? TILEMAP_FLIPX : 0) | tilemap_set_flip_all(screen->machine, ((*state->flipscreen_x & 0x01) ? TILEMAP_FLIPX : 0) |
((*tp84_flipscreen_y & 0x01) ? TILEMAP_FLIPY : 0)); ((*state->flipscreen_y & 0x01) ? TILEMAP_FLIPY : 0));
} }
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine, bitmap, cliprect); draw_sprites(screen->machine, bitmap, cliprect);
/* draw top status region */ /* draw top status region */
clip.min_x = visarea.min_x; clip.min_x = visarea.min_x;
clip.max_x = visarea.min_x + 15; clip.max_x = visarea.min_x + 15;
tilemap_draw(bitmap, &clip, fg_tilemap, 0, 0); tilemap_draw(bitmap, &clip, state->fg_tilemap, 0, 0);
/* draw bottom status region */ /* draw bottom status region */
clip.min_x = visarea.max_x - 15; clip.min_x = visarea.max_x - 15;
clip.max_x = visarea.max_x; clip.max_x = visarea.max_x;
tilemap_draw(bitmap, &clip, fg_tilemap, 0, 0); tilemap_draw(bitmap, &clip, state->fg_tilemap, 0, 0);
return 0; return 0;
} }

View File

@ -15,15 +15,8 @@
#include "emu.h" #include "emu.h"
#include "includes/twin16.h" #include "includes/twin16.h"
static UINT16 twin16_sprite_buffer[0x800];
static TIMER_CALLBACK( twin16_sprite_tick ); static TIMER_CALLBACK( twin16_sprite_tick );
static emu_timer *twin16_sprite_timer;
static int twin16_sprite_busy;
static int need_process_spriteram;
static UINT16 gfx_bank;
static UINT16 scrollx[3], scrolly[3];
static UINT16 video_register;
enum enum
{ {
@ -46,12 +39,12 @@ enum
TWIN16_SPRITE_CAST_SHADOW = 0x20 TWIN16_SPRITE_CAST_SHADOW = 0x20
}; };
static tilemap_t *text_tilemap;
WRITE16_HANDLER( twin16_text_ram_w ) WRITE16_HANDLER( twin16_text_ram_w )
{ {
COMBINE_DATA(&twin16_text_ram[offset]); twin16_state *state = space->machine->driver_data<twin16_state>();
tilemap_mark_tile_dirty(text_tilemap, offset); COMBINE_DATA(&state->text_ram[offset]);
tilemap_mark_tile_dirty(state->text_tilemap, offset);
} }
WRITE16_HANDLER( twin16_paletteram_word_w ) WRITE16_HANDLER( twin16_paletteram_word_w )
@ -65,30 +58,32 @@ WRITE16_HANDLER( twin16_paletteram_word_w )
WRITE16_HANDLER( fround_gfx_bank_w ) WRITE16_HANDLER( fround_gfx_bank_w )
{ {
COMBINE_DATA(&gfx_bank); twin16_state *state = space->machine->driver_data<twin16_state>();
COMBINE_DATA(&state->gfx_bank);
} }
WRITE16_HANDLER( twin16_video_register_w ) WRITE16_HANDLER( twin16_video_register_w )
{ {
twin16_state *state = space->machine->driver_data<twin16_state>();
switch (offset) switch (offset)
{ {
case 0: case 0:
COMBINE_DATA( &video_register ); COMBINE_DATA( &state->video_register );
flip_screen_x_set(space->machine, video_register & TWIN16_SCREEN_FLIPX); flip_screen_x_set(space->machine, state->video_register & TWIN16_SCREEN_FLIPX);
flip_screen_y_set(space->machine, video_register & TWIN16_SCREEN_FLIPY); flip_screen_y_set(space->machine, state->video_register & TWIN16_SCREEN_FLIPY);
break; break;
case 1: COMBINE_DATA( &scrollx[0] ); break; case 1: COMBINE_DATA( &state->scrollx[0] ); break;
case 2: COMBINE_DATA( &scrolly[0] ); break; case 2: COMBINE_DATA( &state->scrolly[0] ); break;
case 3: COMBINE_DATA( &scrollx[1] ); break; case 3: COMBINE_DATA( &state->scrollx[1] ); break;
case 4: COMBINE_DATA( &scrolly[1] ); break; case 4: COMBINE_DATA( &state->scrolly[1] ); break;
case 5: COMBINE_DATA( &scrollx[2] ); break; case 5: COMBINE_DATA( &state->scrollx[2] ); break;
case 6: COMBINE_DATA( &scrolly[2] ); break; case 6: COMBINE_DATA( &state->scrolly[2] ); break;
default: default:
logerror("unknown video_register write:%d", data ); logerror("unknown state->video_register write:%d", data );
break; break;
} }
} }
@ -141,31 +136,35 @@ WRITE16_HANDLER( twin16_video_register_w )
READ16_HANDLER( twin16_sprite_status_r ) READ16_HANDLER( twin16_sprite_status_r )
{ {
twin16_state *state = space->machine->driver_data<twin16_state>();
// bit 0: busy, other bits: dunno // bit 0: busy, other bits: dunno
return twin16_sprite_busy; return state->sprite_busy;
} }
static TIMER_CALLBACK( twin16_sprite_tick ) static TIMER_CALLBACK( twin16_sprite_tick )
{ {
twin16_sprite_busy = 0; twin16_state *state = machine->driver_data<twin16_state>();
state->sprite_busy = 0;
} }
static int twin16_set_sprite_timer( running_machine *machine ) static int twin16_set_sprite_timer( running_machine *machine )
{ {
if (twin16_sprite_busy) return 1; twin16_state *state = machine->driver_data<twin16_state>();
if (state->sprite_busy) return 1;
// sprite system busy, maybe a dma? time is guessed, assume 4 scanlines // sprite system busy, maybe a dma? time is guessed, assume 4 scanlines
twin16_sprite_busy = 1; state->sprite_busy = 1;
twin16_sprite_timer->adjust(machine->primary_screen->frame_period() / machine->primary_screen->height() * 4); state->sprite_timer->adjust(machine->primary_screen->frame_period() / machine->primary_screen->height() * 4);
return 0; return 0;
} }
void twin16_spriteram_process( running_machine *machine ) void twin16_spriteram_process( running_machine *machine )
{ {
twin16_state *state = machine->driver_data<twin16_state>();
UINT16 *spriteram16 = machine->generic.spriteram.u16; UINT16 *spriteram16 = machine->generic.spriteram.u16;
UINT16 dx = scrollx[0]; UINT16 dx = state->scrollx[0];
UINT16 dy = scrolly[0]; UINT16 dy = state->scrolly[0];
const UINT16 *source = &spriteram16[0x0000]; const UINT16 *source = &spriteram16[0x0000];
const UINT16 *finish = &spriteram16[0x1800]; const UINT16 *finish = &spriteram16[0x1800];
@ -219,11 +218,12 @@ void twin16_spriteram_process( running_machine *machine )
} }
source += 0x50/2; source += 0x50/2;
} }
need_process_spriteram = 0; state->need_process_spriteram = 0;
} }
static void draw_sprites( running_machine *machine, bitmap_t *bitmap ) static void draw_sprites( running_machine *machine, bitmap_t *bitmap )
{ {
twin16_state *state = machine->driver_data<twin16_state>();
const UINT16 *source = 0x1800+machine->generic.buffered_spriteram.u16 + 0x800 - 4; const UINT16 *source = 0x1800+machine->generic.buffered_spriteram.u16 + 0x800 - 4;
const UINT16 *finish = 0x1800+machine->generic.buffered_spriteram.u16; const UINT16 *finish = 0x1800+machine->generic.buffered_spriteram.u16;
@ -246,9 +246,9 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap )
int flipx = attributes&0x0100; int flipx = attributes&0x0100;
int priority = (attributes&0x4000)?TWIN16_SPRITE_PRI_L1:TWIN16_SPRITE_PRI_L2; int priority = (attributes&0x4000)?TWIN16_SPRITE_PRI_L1:TWIN16_SPRITE_PRI_L2;
if( twin16_custom_video ) { if( state->custom_video ) {
/* fround board */ /* fround board */
pen_data = twin16_gfx_rom + 0x80000; pen_data = state->gfx_rom + 0x80000;
} }
else else
{ {
@ -256,20 +256,20 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap )
{ {
/* bank select */ /* bank select */
case 0: case 0:
pen_data = twin16_gfx_rom; pen_data = state->gfx_rom;
break; break;
case 1: case 1:
pen_data = twin16_gfx_rom + 0x40000; pen_data = state->gfx_rom + 0x40000;
break; break;
case 2: case 2:
pen_data = twin16_gfx_rom + 0x80000; pen_data = state->gfx_rom + 0x80000;
if( code&0x4000 ) pen_data += 0x40000; if( code&0x4000 ) pen_data += 0x40000;
break; break;
case 3: case 3:
pen_data = twin16_sprite_gfx_ram; pen_data = state->sprite_gfx_ram;
break; break;
} }
code &= 0xfff; code &= 0xfff;
@ -282,13 +282,13 @@ static void draw_sprites( running_machine *machine, bitmap_t *bitmap )
pen_data += code*0x40; pen_data += code*0x40;
if( video_register&TWIN16_SCREEN_FLIPY ) if( state->video_register&TWIN16_SCREEN_FLIPY )
{ {
if (ypos>65000) ypos=ypos-65536; /* Bit hacky */ if (ypos>65000) ypos=ypos-65536; /* Bit hacky */
ypos = 256-ypos-height; ypos = 256-ypos-height;
flipy = !flipy; flipy = !flipy;
} }
if( video_register&TWIN16_SCREEN_FLIPX ) if( state->video_register&TWIN16_SCREEN_FLIPX )
{ {
if (xpos>65000) xpos=xpos-65536; /* Bit hacky */ if (xpos>65000) xpos=xpos-65536; /* Bit hacky */
xpos = 320-xpos-width; xpos = 320-xpos-width;
@ -353,45 +353,45 @@ static void draw_layer( running_machine *machine, bitmap_t *bitmap, int opaque )
int i, xxor, yxor; int i, xxor, yxor;
int bank_table[4]; int bank_table[4];
int dx, dy, palette; int dx, dy, palette;
int tile_flipx = video_register&TWIN16_TILE_FLIPX; int tile_flipx = state->video_register&TWIN16_TILE_FLIPX;
int tile_flipy = video_register&TWIN16_TILE_FLIPY; int tile_flipy = state->video_register&TWIN16_TILE_FLIPY;
if( ((video_register&TWIN16_PLANE_ORDER)?1:0) != opaque ) { if( ((state->video_register&TWIN16_PLANE_ORDER)?1:0) != opaque ) {
source += 0x1000; source += 0x1000;
dx = scrollx[2]; dx = state->scrollx[2];
dy = scrolly[2]; dy = state->scrolly[2];
palette = 1; palette = 1;
} }
else { else {
source += 0x0000; source += 0x0000;
dx = scrollx[1]; dx = state->scrollx[1];
dy = scrolly[1]; dy = state->scrolly[1];
palette = 0; palette = 0;
} }
if( twin16_custom_video ) { if( state->custom_video ) {
/* fround board */ /* fround board */
gfx_base = twin16_gfx_rom; gfx_base = state->gfx_rom;
bank_table[3] = (gfx_bank>>(4*3))&0xf; bank_table[3] = (state->gfx_bank>>(4*3))&0xf;
bank_table[2] = (gfx_bank>>(4*2))&0xf; bank_table[2] = (state->gfx_bank>>(4*2))&0xf;
bank_table[1] = (gfx_bank>>(4*1))&0xf; bank_table[1] = (state->gfx_bank>>(4*1))&0xf;
bank_table[0] = (gfx_bank>>(4*0))&0xf; bank_table[0] = (state->gfx_bank>>(4*0))&0xf;
} }
else { else {
gfx_base = twin16_tile_gfx_ram; gfx_base = state->tile_gfx_ram;
bank_table[0] = 0; bank_table[0] = 0;
bank_table[1] = 1; bank_table[1] = 1;
bank_table[2] = 2; bank_table[2] = 2;
bank_table[3] = 3; bank_table[3] = 3;
} }
if( video_register&TWIN16_SCREEN_FLIPX ) if( state->video_register&TWIN16_SCREEN_FLIPX )
{ {
dx = 256-dx-64; dx = 256-dx-64;
tile_flipx = !tile_flipx; tile_flipx = !tile_flipx;
} }
if( video_register&TWIN16_SCREEN_FLIPY ) if( state->video_register&TWIN16_SCREEN_FLIPY )
{ {
dy = 256-dy; dy = 256-dy;
tile_flipy = !tile_flipy; tile_flipy = !tile_flipy;
@ -407,8 +407,8 @@ static void draw_layer( running_machine *machine, bitmap_t *bitmap, int opaque )
int sy = (i/64)*8; int sy = (i/64)*8;
int xpos,ypos; int xpos,ypos;
if( video_register&TWIN16_SCREEN_FLIPX ) sx = 63*8 - sx; if( state->video_register&TWIN16_SCREEN_FLIPX ) sx = 63*8 - sx;
if( video_register&TWIN16_SCREEN_FLIPY ) sy = 63*8 - sy; if( state->video_register&TWIN16_SCREEN_FLIPY ) sy = 63*8 - sy;
xpos = (sx-dx)&0x1ff; xpos = (sx-dx)&0x1ff;
ypos = (sy-dy)&0x1ff; ypos = (sy-dy)&0x1ff;
@ -477,7 +477,8 @@ static void draw_layer( running_machine *machine, bitmap_t *bitmap, int opaque )
static TILE_GET_INFO( get_text_tile_info ) static TILE_GET_INFO( get_text_tile_info )
{ {
const UINT16 *source = twin16_text_ram; twin16_state *state = machine->driver_data<twin16_state>();
const UINT16 *source = state->text_ram;
int attr = source[tile_index]; int attr = source[tile_index];
/* fedcba9876543210 /* fedcba9876543210
-x-------------- yflip -x-------------- yflip
@ -497,56 +498,59 @@ static TILE_GET_INFO( get_text_tile_info )
VIDEO_START( twin16 ) VIDEO_START( twin16 )
{ {
text_tilemap = tilemap_create(machine, get_text_tile_info, tilemap_scan_rows, 8, 8, 64, 32); twin16_state *state = machine->driver_data<twin16_state>();
tilemap_set_transparent_pen(text_tilemap, 0); state->text_tilemap = tilemap_create(machine, get_text_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
tilemap_set_transparent_pen(state->text_tilemap, 0);
palette_set_shadow_factor(machine,0.4); // screenshots estimate palette_set_shadow_factor(machine,0.4); // screenshots estimate
memset(twin16_sprite_buffer,0xff,0x800*sizeof(UINT16)); memset(state->sprite_buffer,0xff,0x800*sizeof(UINT16));
twin16_sprite_busy = 0; state->sprite_busy = 0;
twin16_sprite_timer = machine->scheduler().timer_alloc(FUNC(twin16_sprite_tick)); state->sprite_timer = machine->scheduler().timer_alloc(FUNC(twin16_sprite_tick));
twin16_sprite_timer->adjust(attotime::never); state->sprite_timer->adjust(attotime::never);
/* register for savestates */ /* register for savestates */
state_save_register_global_array(machine, twin16_sprite_buffer); state_save_register_global_array(machine, state->sprite_buffer);
state_save_register_global_array(machine, scrollx); state_save_register_global_array(machine, state->scrollx);
state_save_register_global_array(machine, scrolly); state_save_register_global_array(machine, state->scrolly);
state_save_register_global(machine, need_process_spriteram); state_save_register_global(machine, state->need_process_spriteram);
state_save_register_global(machine, gfx_bank); state_save_register_global(machine, state->gfx_bank);
state_save_register_global(machine, video_register); state_save_register_global(machine, state->video_register);
state_save_register_global(machine, twin16_sprite_busy); state_save_register_global(machine, state->sprite_busy);
} }
VIDEO_UPDATE( twin16 ) VIDEO_UPDATE( twin16 )
{ {
twin16_state *state = screen->machine->driver_data<twin16_state>();
int text_flip=0; int text_flip=0;
if (video_register&TWIN16_SCREEN_FLIPX) text_flip|=TILEMAP_FLIPX; if (state->video_register&TWIN16_SCREEN_FLIPX) text_flip|=TILEMAP_FLIPX;
if (video_register&TWIN16_SCREEN_FLIPY) text_flip|=TILEMAP_FLIPY; if (state->video_register&TWIN16_SCREEN_FLIPY) text_flip|=TILEMAP_FLIPY;
bitmap_fill(screen->machine->priority_bitmap,cliprect,0); bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
draw_layer( screen->machine, bitmap, 1 ); draw_layer( screen->machine, bitmap, 1 );
draw_layer( screen->machine, bitmap, 0 ); draw_layer( screen->machine, bitmap, 0 );
draw_sprites( screen->machine, bitmap ); draw_sprites( screen->machine, bitmap );
if (text_flip) tilemap_set_flip(text_tilemap, text_flip); if (text_flip) tilemap_set_flip(state->text_tilemap, text_flip);
tilemap_draw(bitmap, cliprect, text_tilemap, 0, 0); tilemap_draw(bitmap, cliprect, state->text_tilemap, 0, 0);
return 0; return 0;
} }
VIDEO_EOF( twin16 ) VIDEO_EOF( twin16 )
{ {
twin16_state *state = machine->driver_data<twin16_state>();
twin16_set_sprite_timer(machine); twin16_set_sprite_timer(machine);
if (twin16_spriteram_process_enable()) { if (twin16_spriteram_process_enable(machine)) {
if (need_process_spriteram) twin16_spriteram_process(machine); if (state->need_process_spriteram) twin16_spriteram_process(machine);
need_process_spriteram = 1; state->need_process_spriteram = 1;
/* if the sprite preprocessor is used, sprite ram is copied to an external buffer first, /* if the sprite preprocessor is used, sprite ram is copied to an external buffer first,
as evidenced by 1-frame sprite lag in gradius2 and devilw otherwise, though there's probably as evidenced by 1-frame sprite lag in gradius2 and devilw otherwise, though there's probably
more to it than that */ more to it than that */
memcpy(&machine->generic.buffered_spriteram.u16[0x1800],twin16_sprite_buffer,0x800*sizeof(UINT16)); memcpy(&machine->generic.buffered_spriteram.u16[0x1800],state->sprite_buffer,0x800*sizeof(UINT16));
memcpy(twin16_sprite_buffer,&machine->generic.spriteram.u16[0x1800],0x800*sizeof(UINT16)); memcpy(state->sprite_buffer,&machine->generic.spriteram.u16[0x1800],0x800*sizeof(UINT16));
} }
else { else {
address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);

View File

@ -37,25 +37,6 @@ struct sprite
int shadow_mode, flags; int shadow_mode, flags;
}; };
/* Variables that driver has acces to: */
UINT16 *wecleman_videostatus;
UINT16 *wecleman_pageram, *wecleman_txtram, *wecleman_roadram;
size_t wecleman_roadram_size;
static int wecleman_bgpage[4], wecleman_fgpage[4];
static const int *wecleman_gfx_bank;
/* Variables only used here: */
static tilemap_t *bg_tilemap, *fg_tilemap, *txt_tilemap;
static struct sprite *sprite_list;
static struct sprite **spr_ptr_list;
static int *spr_idx_list, *spr_pri_list, *t32x32pm;
static int gameid, spr_offsx, spr_offsy, spr_count;
static UINT16 *rgb_half;
static int cloud_blend, cloud_ds, cloud_visible;
static pen_t black_pen;
/*************************************************************************** /***************************************************************************
@ -94,18 +75,19 @@ static pen_t black_pen;
static void get_sprite_info(running_machine *machine) static void get_sprite_info(running_machine *machine)
{ {
wecleman_state *state = machine->driver_data<wecleman_state>();
const pen_t *base_pal = machine->pens; const pen_t *base_pal = machine->pens;
UINT8 *base_gfx = machine->region("gfx1")->base(); UINT8 *base_gfx = machine->region("gfx1")->base();
int gfx_max = machine->region("gfx1")->bytes(); int gfx_max = machine->region("gfx1")->bytes();
UINT16 *source = machine->generic.spriteram.u16; UINT16 *source = machine->generic.spriteram.u16;
struct sprite *sprite = sprite_list; struct sprite *sprite = state->sprite_list;
struct sprite *finish = sprite_list + NUM_SPRITES; struct sprite *finish = state->sprite_list + NUM_SPRITES;
int bank, code, gfx, zoom; int bank, code, gfx, zoom;
for (spr_count=0; sprite<finish; source+=0x10/2, sprite++) for (state->spr_count=0; sprite<finish; source+=0x10/2, sprite++)
{ {
if (source[0x00/2] == 0xffff) break; if (source[0x00/2] == 0xffff) break;
@ -128,7 +110,7 @@ static void get_sprite_info(running_machine *machine)
sprite->pal_base = (source[0x0e/2] & 0xff) << 4; sprite->pal_base = (source[0x0e/2] & 0xff) << 4;
sprite->pal_data = base_pal + sprite->pal_base; sprite->pal_data = base_pal + sprite->pal_base;
gfx = (wecleman_gfx_bank[bank] << 15) + (code & 0x7fff); gfx = (state->gfx_bank[bank] << 15) + (code & 0x7fff);
sprite->flags = 0; sprite->flags = 0;
if (code & 0x8000) { sprite->flags |= SPRITE_FLIPX; gfx += 1-sprite->tile_width; } if (code & 0x8000) { sprite->flags |= SPRITE_FLIPX; gfx += 1-sprite->tile_width; }
@ -144,17 +126,17 @@ static void get_sprite_info(running_machine *machine)
sprite->line_offset = sprite->tile_width; sprite->line_offset = sprite->tile_width;
sprite->total_width = sprite->tile_width - (sprite->tile_width * (zoom & 0xff)) / 0x80; sprite->total_width = sprite->tile_width - (sprite->tile_width * (zoom & 0xff)) / 0x80;
sprite->total_height += 1; sprite->total_height += 1;
sprite->x += spr_offsx; sprite->x += state->spr_offsx;
sprite->y += spr_offsy; sprite->y += state->spr_offsy;
if (gameid == 0) if (state->gameid == 0)
{ {
spr_idx_list[spr_count] = spr_count; state->spr_idx_list[state->spr_count] = state->spr_count;
spr_pri_list[spr_count] = source[0x0e/2] >> 8; state->spr_pri_list[state->spr_count] = source[0x0e/2] >> 8;
} }
spr_ptr_list[spr_count] = sprite; state->spr_ptr_list[state->spr_count] = sprite;
spr_count++; state->spr_count++;
} }
} }
@ -187,7 +169,7 @@ static void sortsprite(int *idx_array, int *key_array, int size)
} }
// draws a 8bpp palette sprites on a 16bpp direct RGB target (sub-par implementation) // draws a 8bpp palette sprites on a 16bpp direct RGB target (sub-par implementation)
static void do_blit_zoom32(bitmap_t *bitmap, const rectangle *cliprect, struct sprite *sprite) static void do_blit_zoom32(wecleman_state *state, bitmap_t *bitmap, const rectangle *cliprect, struct sprite *sprite)
{ {
#define PRECISION_X 20 #define PRECISION_X 20
#define PRECISION_Y 20 #define PRECISION_Y 20
@ -335,7 +317,7 @@ static void do_blit_zoom32(bitmap_t *bitmap, const rectangle *cliprect, struct s
dst_ptr[sx] = base + pix; dst_ptr[sx] = base + pix;
else else
{ {
if (dst_ptr[sx] != black_pen) if (dst_ptr[sx] != state->black_pen)
dst_ptr[sx] |= 0x800; dst_ptr[sx] |= 0x800;
} }
} }
@ -348,19 +330,20 @@ static void do_blit_zoom32(bitmap_t *bitmap, const rectangle *cliprect, struct s
} }
} }
static void sprite_draw(bitmap_t *bitmap, const rectangle *cliprect) static void sprite_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{ {
wecleman_state *state = machine->driver_data<wecleman_state>();
int i; int i;
if (gameid == 0) // Wec Le Mans if (state->gameid == 0) // Wec Le Mans
{ {
sortsprite(spr_idx_list, spr_pri_list, spr_count); sortsprite(state->spr_idx_list, state->spr_pri_list, state->spr_count);
for (i=0; i<spr_count; i++) do_blit_zoom32(bitmap, cliprect, spr_ptr_list[spr_idx_list[i]]); for (i=0; i<state->spr_count; i++) do_blit_zoom32(state, bitmap, cliprect, state->spr_ptr_list[state->spr_idx_list[i]]);
} }
else // Hot Chase else // Hot Chase
{ {
for (i=0; i<spr_count; i++) do_blit_zoom32(bitmap, cliprect, spr_ptr_list[i]); for (i=0; i<state->spr_count; i++) do_blit_zoom32(state, bitmap, cliprect, state->spr_ptr_list[i]);
} }
} }
@ -436,14 +419,16 @@ static void sprite_draw(bitmap_t *bitmap, const rectangle *cliprect)
static TILE_GET_INFO( wecleman_get_txt_tile_info ) static TILE_GET_INFO( wecleman_get_txt_tile_info )
{ {
int code = wecleman_txtram[tile_index]; wecleman_state *state = machine->driver_data<wecleman_state>();
int code = state->txtram[tile_index];
SET_TILE_INFO(PAGE_GFX, code&0xfff, (code>>5&0x78)+(code>>12), 0); SET_TILE_INFO(PAGE_GFX, code&0xfff, (code>>5&0x78)+(code>>12), 0);
} }
WRITE16_HANDLER( wecleman_txtram_w ) WRITE16_HANDLER( wecleman_txtram_w )
{ {
UINT16 old_data = wecleman_txtram[offset]; wecleman_state *state = space->machine->driver_data<wecleman_state>();
UINT16 new_data = COMBINE_DATA(&wecleman_txtram[offset]); UINT16 old_data = state->txtram[offset];
UINT16 new_data = COMBINE_DATA(&state->txtram[offset]);
if ( old_data != new_data ) if ( old_data != new_data )
{ {
@ -452,27 +437,27 @@ WRITE16_HANDLER( wecleman_txtram_w )
/* pages selector for the background */ /* pages selector for the background */
if (offset == 0xEFE/2) if (offset == 0xEFE/2)
{ {
wecleman_bgpage[0] = (new_data >> 0x4) & 3; state->bgpage[0] = (new_data >> 0x4) & 3;
wecleman_bgpage[1] = (new_data >> 0x0) & 3; state->bgpage[1] = (new_data >> 0x0) & 3;
wecleman_bgpage[2] = (new_data >> 0xc) & 3; state->bgpage[2] = (new_data >> 0xc) & 3;
wecleman_bgpage[3] = (new_data >> 0x8) & 3; state->bgpage[3] = (new_data >> 0x8) & 3;
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
} }
/* pages selector for the foreground */ /* pages selector for the foreground */
if (offset == 0xEFC/2) if (offset == 0xEFC/2)
{ {
wecleman_fgpage[0] = (new_data >> 0x4) & 3; state->fgpage[0] = (new_data >> 0x4) & 3;
wecleman_fgpage[1] = (new_data >> 0x0) & 3; state->fgpage[1] = (new_data >> 0x0) & 3;
wecleman_fgpage[2] = (new_data >> 0xc) & 3; state->fgpage[2] = (new_data >> 0xc) & 3;
wecleman_fgpage[3] = (new_data >> 0x8) & 3; state->fgpage[3] = (new_data >> 0x8) & 3;
tilemap_mark_all_tiles_dirty(fg_tilemap); tilemap_mark_all_tiles_dirty(state->fg_tilemap);
} }
/* Parallactic horizontal scroll registers follow */ /* Parallactic horizontal scroll registers follow */
} }
else else
tilemap_mark_tile_dirty(txt_tilemap, offset); tilemap_mark_tile_dirty(state->txt_tilemap, offset);
} }
} }
@ -482,8 +467,9 @@ WRITE16_HANDLER( wecleman_txtram_w )
static TILE_GET_INFO( wecleman_get_bg_tile_info ) static TILE_GET_INFO( wecleman_get_bg_tile_info )
{ {
int page = wecleman_bgpage[((tile_index&0x7f)>>6) + ((tile_index>>12)<<1)]; wecleman_state *state = machine->driver_data<wecleman_state>();
int code = wecleman_pageram[(tile_index&0x3f) + ((tile_index>>7&0x1f)<<6) + (page<<11)]; int page = state->bgpage[((tile_index&0x7f)>>6) + ((tile_index>>12)<<1)];
int code = state->pageram[(tile_index&0x3f) + ((tile_index>>7&0x1f)<<6) + (page<<11)];
SET_TILE_INFO(PAGE_GFX, code&0xfff, (code>>5&0x78)+(code>>12), 0); SET_TILE_INFO(PAGE_GFX, code&0xfff, (code>>5&0x78)+(code>>12), 0);
} }
@ -494,8 +480,9 @@ static TILE_GET_INFO( wecleman_get_bg_tile_info )
static TILE_GET_INFO( wecleman_get_fg_tile_info ) static TILE_GET_INFO( wecleman_get_fg_tile_info )
{ {
int page = wecleman_fgpage[((tile_index&0x7f)>>6) + ((tile_index>>12)<<1)]; wecleman_state *state = machine->driver_data<wecleman_state>();
int code = wecleman_pageram[(tile_index&0x3f) + ((tile_index>>7&0x1f)<<6) + (page<<11)]; int page = state->fgpage[((tile_index&0x7f)>>6) + ((tile_index>>12)<<1)];
int code = state->pageram[(tile_index&0x3f) + ((tile_index>>7&0x1f)<<6) + (page<<11)];
if (!code || code==0xffff) code = 0x20; if (!code || code==0xffff) code = 0x20;
SET_TILE_INFO(PAGE_GFX, code&0xfff, (code>>5&0x78)+(code>>12), 0); SET_TILE_INFO(PAGE_GFX, code&0xfff, (code>>5&0x78)+(code>>12), 0);
@ -508,7 +495,8 @@ static TILE_GET_INFO( wecleman_get_fg_tile_info )
/* Pages that compose both the background and the foreground */ /* Pages that compose both the background and the foreground */
WRITE16_HANDLER( wecleman_pageram_w ) WRITE16_HANDLER( wecleman_pageram_w )
{ {
COMBINE_DATA(&wecleman_pageram[offset]); wecleman_state *state = space->machine->driver_data<wecleman_state>();
COMBINE_DATA(&state->pageram[offset]);
{ {
int page,col,row; int page,col,row;
@ -518,16 +506,16 @@ WRITE16_HANDLER( wecleman_pageram_w )
row = ( offset / PAGE_NX ) % PAGE_NY; row = ( offset / PAGE_NX ) % PAGE_NY;
/* background */ /* background */
if (wecleman_bgpage[0] == page) tilemap_mark_tile_dirty(bg_tilemap, (col+PAGE_NX*0) + (row+PAGE_NY*0)*PAGE_NX*2 ); if (state->bgpage[0] == page) tilemap_mark_tile_dirty(state->bg_tilemap, (col+PAGE_NX*0) + (row+PAGE_NY*0)*PAGE_NX*2 );
if (wecleman_bgpage[1] == page) tilemap_mark_tile_dirty(bg_tilemap, (col+PAGE_NX*1) + (row+PAGE_NY*0)*PAGE_NX*2 ); if (state->bgpage[1] == page) tilemap_mark_tile_dirty(state->bg_tilemap, (col+PAGE_NX*1) + (row+PAGE_NY*0)*PAGE_NX*2 );
if (wecleman_bgpage[2] == page) tilemap_mark_tile_dirty(bg_tilemap, (col+PAGE_NX*0) + (row+PAGE_NY*1)*PAGE_NX*2 ); if (state->bgpage[2] == page) tilemap_mark_tile_dirty(state->bg_tilemap, (col+PAGE_NX*0) + (row+PAGE_NY*1)*PAGE_NX*2 );
if (wecleman_bgpage[3] == page) tilemap_mark_tile_dirty(bg_tilemap, (col+PAGE_NX*1) + (row+PAGE_NY*1)*PAGE_NX*2 ); if (state->bgpage[3] == page) tilemap_mark_tile_dirty(state->bg_tilemap, (col+PAGE_NX*1) + (row+PAGE_NY*1)*PAGE_NX*2 );
/* foreground */ /* foreground */
if (wecleman_fgpage[0] == page) tilemap_mark_tile_dirty(fg_tilemap, (col+PAGE_NX*0) + (row+PAGE_NY*0)*PAGE_NX*2 ); if (state->fgpage[0] == page) tilemap_mark_tile_dirty(state->fg_tilemap, (col+PAGE_NX*0) + (row+PAGE_NY*0)*PAGE_NX*2 );
if (wecleman_fgpage[1] == page) tilemap_mark_tile_dirty(fg_tilemap, (col+PAGE_NX*1) + (row+PAGE_NY*0)*PAGE_NX*2 ); if (state->fgpage[1] == page) tilemap_mark_tile_dirty(state->fg_tilemap, (col+PAGE_NX*1) + (row+PAGE_NY*0)*PAGE_NX*2 );
if (wecleman_fgpage[2] == page) tilemap_mark_tile_dirty(fg_tilemap, (col+PAGE_NX*0) + (row+PAGE_NY*1)*PAGE_NX*2 ); if (state->fgpage[2] == page) tilemap_mark_tile_dirty(state->fg_tilemap, (col+PAGE_NX*0) + (row+PAGE_NY*1)*PAGE_NX*2 );
if (wecleman_fgpage[3] == page) tilemap_mark_tile_dirty(fg_tilemap, (col+PAGE_NX*1) + (row+PAGE_NY*1)*PAGE_NX*2 ); if (state->fgpage[3] == page) tilemap_mark_tile_dirty(state->fg_tilemap, (col+PAGE_NX*1) + (row+PAGE_NY*1)*PAGE_NX*2 );
} }
} }
@ -553,6 +541,7 @@ WRITE16_HANDLER( wecleman_pageram_w )
static void wecleman_draw_road(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority) static void wecleman_draw_road(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority)
{ {
wecleman_state *state = machine->driver_data<wecleman_state>();
// must be powers of 2 // must be powers of 2
#define XSIZE 512 #define XSIZE 512
#define YSIZE 256 #define YSIZE 256
@ -593,10 +582,10 @@ static void wecleman_draw_road(running_machine *machine, bitmap_t *bitmap, const
UINT32 pix; UINT32 pix;
UINT16 road; UINT16 road;
road = wecleman_roadram[sy]; road = state->roadram[sy];
if ((road>>8) != 0x02) continue; if ((road>>8) != 0x02) continue;
pix = rgb_ptr[(wecleman_roadram[sy+(YSIZE*2)] & 0xf) + 0x7f0]; pix = rgb_ptr[(state->roadram[sy+(YSIZE*2)] & 0xf) + 0x7f0];
for (sx = 0; sx < DST_WIDTH; sx++) for (sx = 0; sx < DST_WIDTH; sx++)
dst[sx] = pix; dst[sx] = pix;
@ -619,7 +608,7 @@ static void wecleman_draw_road(running_machine *machine, bitmap_t *bitmap, const
UINT32 pix; UINT32 pix;
UINT16 road; UINT16 road;
road = wecleman_roadram[sy]; road = state->roadram[sy];
if ((road>>8) != 0x04) continue; if ((road>>8) != 0x04) continue;
road &= YMASK; road &= YMASK;
@ -634,9 +623,9 @@ static void wecleman_draw_road(running_machine *machine, bitmap_t *bitmap, const
mdy = ((road * MIDCURB_DY) >> 8) * bitmap->rowpixels; mdy = ((road * MIDCURB_DY) >> 8) * bitmap->rowpixels;
tdy = ((road * TOPCURB_DY) >> 8) * bitmap->rowpixels; tdy = ((road * TOPCURB_DY) >> 8) * bitmap->rowpixels;
scrollx = wecleman_roadram[sy+YSIZE] + (0x18 - 0xe00); scrollx = state->roadram[sy+YSIZE] + (0x18 - 0xe00);
pal_ptr = road_rgb + ((wecleman_roadram[sy+(YSIZE*2)]<<3) & 8); pal_ptr = road_rgb + ((state->roadram[sy+(YSIZE*2)]<<3) & 8);
for (sx = 0; sx < DST_WIDTH; sx++, scrollx++) for (sx = 0; sx < DST_WIDTH; sx++, scrollx++)
{ {
@ -677,6 +666,7 @@ static void draw_cloud(bitmap_t *bitmap,
int tmw_l2, int tmh_l2, // tilemap width and height in log(2) int tmw_l2, int tmh_l2, // tilemap width and height in log(2)
int alpha, int pal_offset ) // alpha(0-3f), # of color codes to shift int alpha, int pal_offset ) // alpha(0-3f), # of color codes to shift
{ {
wecleman_state *state = gfx->machine->driver_data<wecleman_state>();
const UINT8 *src_ptr; const UINT8 *src_ptr;
UINT16 *tmap_ptr; UINT16 *tmap_ptr;
UINT32 *dst_base, *dst_ptr; UINT32 *dst_base, *dst_ptr;
@ -749,9 +739,9 @@ static void draw_cloud(bitmap_t *bitmap,
dg = (dstrgb >> 11) & 0x1f; dg = (dstrgb >> 11) & 0x1f;
db = (dstrgb >> 19) & 0x1f; db = (dstrgb >> 19) & 0x1f;
dr = (t32x32pm[dr - sr + alpha] >> 5) + dr; dr = (state->t32x32pm[dr - sr + alpha] >> 5) + dr;
dg = (t32x32pm[dg - sg + alpha] >> 5) + dg; dg = (state->t32x32pm[dg - sg + alpha] >> 5) + dg;
db = (t32x32pm[db - sb + alpha] >> 5) + db; db = (state->t32x32pm[db - sb + alpha] >> 5) + db;
dst_ptr[tx] = MAKE_RGB(pal5bit(db), pal5bit(dg), pal5bit(dr)); dst_ptr[tx] = MAKE_RGB(pal5bit(db), pal5bit(dg), pal5bit(dr));
} }
@ -804,6 +794,7 @@ static void draw_cloud(bitmap_t *bitmap,
static void hotchase_draw_road(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void hotchase_draw_road(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
{ {
wecleman_state *state = machine->driver_data<wecleman_state>();
/* Referred to what's in the ROMs */ /* Referred to what's in the ROMs */
#define XSIZE 512 #define XSIZE 512
#define YSIZE 512 #define YSIZE 512
@ -814,7 +805,7 @@ static void hotchase_draw_road(running_machine *machine, bitmap_t *bitmap, const
/* Let's draw from the top to the bottom of the visible screen */ /* Let's draw from the top to the bottom of the visible screen */
for (sy = visarea.min_y;sy <= visarea.max_y;sy++) for (sy = visarea.min_y;sy <= visarea.max_y;sy++)
{ {
int code = wecleman_roadram[sy*4/2+2/2] + (wecleman_roadram[sy*4/2+0/2] << 16); int code = state->roadram[sy*4/2+2/2] + (state->roadram[sy*4/2+0/2] << 16);
int color = ((code & 0x00f00000) >> 20) + 0x70; int color = ((code & 0x00f00000) >> 20) + 0x70;
int scrollx = ((code & 0x0007fc00) >> 10) * 2; int scrollx = ((code & 0x0007fc00) >> 10) * 2;
@ -845,20 +836,21 @@ static void hotchase_draw_road(running_machine *machine, bitmap_t *bitmap, const
// new video and palette code // new video and palette code
WRITE16_HANDLER( wecleman_videostatus_w ) WRITE16_HANDLER( wecleman_videostatus_w )
{ {
COMBINE_DATA(wecleman_videostatus); wecleman_state *state = space->machine->driver_data<wecleman_state>();
COMBINE_DATA(state->videostatus);
// bit0-6: background transition, 0=off, 1=on // bit0-6: background transition, 0=off, 1=on
// bit7: palette being changed, 0=no, 1=yes // bit7: palette being changed, 0=no, 1=yes
if (ACCESSING_BITS_0_7) if (ACCESSING_BITS_0_7)
{ {
if ((data & 0x7f) == 0 && !cloud_ds) if ((data & 0x7f) == 0 && !state->cloud_ds)
cloud_ds = BLEND_INC; state->cloud_ds = BLEND_INC;
else else
if ((data & 0x7f) == 1 && !cloud_visible) if ((data & 0x7f) == 1 && !state->cloud_visible)
{ {
data ^= 1; data ^= 1;
cloud_ds = BLEND_DEC; state->cloud_ds = BLEND_DEC;
cloud_visible = 1; state->cloud_visible = 1;
} }
} }
} }
@ -894,6 +886,7 @@ WRITE16_HANDLER( wecleman_paletteram16_SSSSBBBBGGGGRRRR_word_w )
VIDEO_START( wecleman ) VIDEO_START( wecleman )
{ {
wecleman_state *state = machine->driver_data<wecleman_state>();
/* /*
Sprite banking - each bank is 0x20000 bytes (we support 0x40 bank codes) Sprite banking - each bank is 0x20000 bytes (we support 0x40 bank codes)
This game has ROMs for 16 banks This game has ROMs for 16 banks
@ -912,69 +905,69 @@ VIDEO_START( wecleman )
assert(machine->primary_screen->format() == BITMAP_FORMAT_RGB32); assert(machine->primary_screen->format() == BITMAP_FORMAT_RGB32);
buffer = auto_alloc_array(machine, UINT8, 0x12c00); // working buffer for sprite operations buffer = auto_alloc_array(machine, UINT8, 0x12c00); // working buffer for sprite operations
gameid = 0; state->gameid = 0;
wecleman_gfx_bank = bank; state->gfx_bank = bank;
spr_offsx = -0xbc + BMP_PAD; state->spr_offsx = -0xbc + BMP_PAD;
spr_offsy = 1 + BMP_PAD; state->spr_offsy = 1 + BMP_PAD;
cloud_blend = BLEND_MAX; state->cloud_blend = BLEND_MAX;
cloud_ds = 0; state->cloud_ds = 0;
cloud_visible = 0; state->cloud_visible = 0;
black_pen = get_black_pen(machine); state->black_pen = get_black_pen(machine);
rgb_half = (UINT16*)(buffer + 0x00000); state->rgb_half = (UINT16*)(buffer + 0x00000);
t32x32pm = (int*)(buffer + 0x10020); state->t32x32pm = (int*)(buffer + 0x10020);
spr_ptr_list = (struct sprite **)(buffer + 0x12000); state->spr_ptr_list = (struct sprite **)(buffer + 0x12000);
spr_idx_list = (int *)(buffer + 0x12400); state->spr_idx_list = (int *)(buffer + 0x12400);
spr_pri_list = (int *)(buffer + 0x12800); state->spr_pri_list = (int *)(buffer + 0x12800);
for (i=0; i<0x8000; i++) for (i=0; i<0x8000; i++)
{ {
j = i>>1; j = i>>1;
rgb_half[i] = (j&0xf) | (j&0x1e0) | (j&0x3c00); state->rgb_half[i] = (j&0xf) | (j&0x1e0) | (j&0x3c00);
} }
for (j=0; j<0x20; j++) for (j=0; j<0x20; j++)
{ {
for (i=-0x1f; i<0x20; i++) for (i=-0x1f; i<0x20; i++)
{ {
*(t32x32pm + (j<<6) + i) = i * j; *(state->t32x32pm + (j<<6) + i) = i * j;
} }
} }
sprite_list = auto_alloc_array_clear(machine, struct sprite, NUM_SPRITES); state->sprite_list = auto_alloc_array_clear(machine, struct sprite, NUM_SPRITES);
bg_tilemap = tilemap_create(machine, wecleman_get_bg_tile_info, state->bg_tilemap = tilemap_create(machine, wecleman_get_bg_tile_info,
tilemap_scan_rows, tilemap_scan_rows,
/* We draw part of the road below */ /* We draw part of the road below */
8,8, 8,8,
PAGE_NX * 2, PAGE_NY * 2 ); PAGE_NX * 2, PAGE_NY * 2 );
fg_tilemap = tilemap_create(machine, wecleman_get_fg_tile_info, state->fg_tilemap = tilemap_create(machine, wecleman_get_fg_tile_info,
tilemap_scan_rows, tilemap_scan_rows,
8,8, 8,8,
PAGE_NX * 2, PAGE_NY * 2); PAGE_NX * 2, PAGE_NY * 2);
txt_tilemap = tilemap_create(machine, wecleman_get_txt_tile_info, state->txt_tilemap = tilemap_create(machine, wecleman_get_txt_tile_info,
tilemap_scan_rows, tilemap_scan_rows,
8,8, 8,8,
PAGE_NX * 1, PAGE_NY * 1); PAGE_NX * 1, PAGE_NY * 1);
tilemap_set_scroll_rows(bg_tilemap, TILEMAP_DIMY); /* Screen-wise scrolling */ tilemap_set_scroll_rows(state->bg_tilemap, TILEMAP_DIMY); /* Screen-wise scrolling */
tilemap_set_scroll_cols(bg_tilemap, 1); tilemap_set_scroll_cols(state->bg_tilemap, 1);
tilemap_set_transparent_pen(bg_tilemap,0); tilemap_set_transparent_pen(state->bg_tilemap,0);
tilemap_set_scroll_rows(fg_tilemap, TILEMAP_DIMY); /* Screen-wise scrolling */ tilemap_set_scroll_rows(state->fg_tilemap, TILEMAP_DIMY); /* Screen-wise scrolling */
tilemap_set_scroll_cols(fg_tilemap, 1); tilemap_set_scroll_cols(state->fg_tilemap, 1);
tilemap_set_transparent_pen(fg_tilemap,0); tilemap_set_transparent_pen(state->fg_tilemap,0);
tilemap_set_scroll_rows(txt_tilemap, 1); tilemap_set_scroll_rows(state->txt_tilemap, 1);
tilemap_set_scroll_cols(txt_tilemap, 1); tilemap_set_scroll_cols(state->txt_tilemap, 1);
tilemap_set_transparent_pen(txt_tilemap,0); tilemap_set_transparent_pen(state->txt_tilemap,0);
tilemap_set_scrollx(txt_tilemap, 0, 512-320-16 -BMP_PAD); tilemap_set_scrollx(state->txt_tilemap, 0, 512-320-16 -BMP_PAD);
tilemap_set_scrolly(txt_tilemap, 0, -BMP_PAD ); tilemap_set_scrolly(state->txt_tilemap, 0, -BMP_PAD );
// patches out a mysterious pixel floating in the sky (tile decoding bug?) // patches out a mysterious pixel floating in the sky (tile decoding bug?)
*(machine->gfx[0]->gfxdata + (machine->gfx[0]->char_modulo*0xaca+7)) = 0; *(machine->gfx[0]->gfxdata + (machine->gfx[0]->char_modulo*0xaca+7)) = 0;
@ -996,6 +989,7 @@ void hotchase_zoom_callback_1(running_machine *machine, int *code,int *color,int
VIDEO_START( hotchase ) VIDEO_START( hotchase )
{ {
wecleman_state *state = machine->driver_data<wecleman_state>();
/* /*
Sprite banking - each bank is 0x20000 bytes (we support 0x40 bank codes) Sprite banking - each bank is 0x20000 bytes (we support 0x40 bank codes)
This game has ROMs for 0x30 banks This game has ROMs for 0x30 banks
@ -1012,15 +1006,15 @@ VIDEO_START( hotchase )
buffer = auto_alloc_array(machine, UINT8, 0x400); // reserve 1k for sprite list buffer = auto_alloc_array(machine, UINT8, 0x400); // reserve 1k for sprite list
gameid = 1; state->gameid = 1;
wecleman_gfx_bank = bank; state->gfx_bank = bank;
spr_offsx = -0xc0; state->spr_offsx = -0xc0;
spr_offsy = 0; state->spr_offsy = 0;
black_pen = get_black_pen(machine); state->black_pen = get_black_pen(machine);
spr_ptr_list = (struct sprite **)buffer; state->spr_ptr_list = (struct sprite **)buffer;
sprite_list = auto_alloc_array_clear(machine, struct sprite, NUM_SPRITES); state->sprite_list = auto_alloc_array_clear(machine, struct sprite, NUM_SPRITES);
} }
@ -1030,6 +1024,7 @@ VIDEO_START( hotchase )
VIDEO_UPDATE ( wecleman ) VIDEO_UPDATE ( wecleman )
{ {
wecleman_state *state = screen->machine->driver_data<wecleman_state>();
const pen_t *mrct; const pen_t *mrct;
int video_on; int video_on;
int fg_x, bg_x, fg_y, bg_y; int fg_x, bg_x, fg_y, bg_y;
@ -1038,29 +1033,29 @@ VIDEO_UPDATE ( wecleman )
mrct = screen->machine->pens; mrct = screen->machine->pens;
video_on = wecleman_irqctrl & 0x40; video_on = state->irqctrl & 0x40;
set_led_status(screen->machine, 0, wecleman_selected_ip & 0x04); // Start lamp set_led_status(screen->machine, 0, state->selected_ip & 0x04); // Start lamp
fg_y = (wecleman_txtram[0x0f24>>1] & (TILEMAP_DIMY - 1)); fg_y = (state->txtram[0x0f24>>1] & (TILEMAP_DIMY - 1));
bg_y = (wecleman_txtram[0x0f26>>1] & (TILEMAP_DIMY - 1)); bg_y = (state->txtram[0x0f26>>1] & (TILEMAP_DIMY - 1));
cloud_sx = wecleman_txtram[0xfee>>1] + 0xb0; cloud_sx = state->txtram[0xfee>>1] + 0xb0;
cloud_sy = bg_y; cloud_sy = bg_y;
tilemap_set_scrolly(bg_tilemap, 0, bg_y -BMP_PAD); tilemap_set_scrolly(state->bg_tilemap, 0, bg_y -BMP_PAD);
tilemap_set_scrolly(fg_tilemap, 0, fg_y -BMP_PAD); tilemap_set_scrolly(state->fg_tilemap, 0, fg_y -BMP_PAD);
for (i=0; i<(28<<2); i+=4) for (i=0; i<(28<<2); i+=4)
{ {
fg_x = wecleman_txtram[(i+0xf80)>>1] + (0xb0 -BMP_PAD); fg_x = state->txtram[(i+0xf80)>>1] + (0xb0 -BMP_PAD);
bg_x = wecleman_txtram[(i+0xf82)>>1] + (0xb0 -BMP_PAD); bg_x = state->txtram[(i+0xf82)>>1] + (0xb0 -BMP_PAD);
k = i<<1; k = i<<1;
for (j=0; j<8; j++) for (j=0; j<8; j++)
{ {
tilemap_set_scrollx(fg_tilemap, (fg_y + k + j) & (TILEMAP_DIMY - 1), fg_x); tilemap_set_scrollx(state->fg_tilemap, (fg_y + k + j) & (TILEMAP_DIMY - 1), fg_x);
tilemap_set_scrollx(bg_tilemap, (bg_y + k + j) & (TILEMAP_DIMY - 1), bg_x); tilemap_set_scrollx(state->bg_tilemap, (bg_y + k + j) & (TILEMAP_DIMY - 1), bg_x);
} }
} }
@ -1070,16 +1065,16 @@ VIDEO_UPDATE ( wecleman )
get_sprite_info(screen->machine); get_sprite_info(screen->machine);
bitmap_fill(bitmap, cliprect, black_pen); bitmap_fill(bitmap, cliprect, state->black_pen);
/* Draw the road (lines which have priority 0x02) */ /* Draw the road (lines which have priority 0x02) */
if (video_on) wecleman_draw_road(screen->machine, bitmap, cliprect, 0x02); if (video_on) wecleman_draw_road(screen->machine, bitmap, cliprect, 0x02);
/* Draw the background */ /* Draw the background */
if (video_on) tilemap_draw(bitmap,cliprect, bg_tilemap, 0, 0); if (video_on) tilemap_draw(bitmap,cliprect, state->bg_tilemap, 0, 0);
// draws the cloud layer; needs work // draws the cloud layer; needs work
if (cloud_visible) if (state->cloud_visible)
{ {
/* palette hacks! */ /* palette hacks! */
((pen_t *)mrct)[0] = ((pen_t *)mrct)[0x40] = ((pen_t *)mrct)[0x200] = ((pen_t *)mrct)[0x205]; ((pen_t *)mrct)[0] = ((pen_t *)mrct)[0x40] = ((pen_t *)mrct)[0x200] = ((pen_t *)mrct)[0x205];
@ -1088,32 +1083,32 @@ VIDEO_UPDATE ( wecleman )
draw_cloud( draw_cloud(
bitmap, bitmap,
screen->machine->gfx[0], screen->machine->gfx[0],
wecleman_pageram+0x1800, state->pageram+0x1800,
BMP_PAD, BMP_PAD, BMP_PAD, BMP_PAD,
41, 20, 41, 20,
cloud_sx, cloud_sy, cloud_sx, cloud_sy,
6, 5, 6, 5,
cloud_blend/BLEND_STEPS, 0); state->cloud_blend/BLEND_STEPS, 0);
cloud_blend += cloud_ds; state->cloud_blend += state->cloud_ds;
if (cloud_blend < BLEND_MIN) if (state->cloud_blend < BLEND_MIN)
{ cloud_blend = BLEND_MIN; cloud_ds = 0; *wecleman_videostatus |= 1; } { state->cloud_blend = BLEND_MIN; state->cloud_ds = 0; *state->videostatus |= 1; }
else if (cloud_blend > BLEND_MAX) else if (state->cloud_blend > BLEND_MAX)
{ cloud_blend = BLEND_MAX; cloud_ds = 0; cloud_visible = 0; } { state->cloud_blend = BLEND_MAX; state->cloud_ds = 0; state->cloud_visible = 0; }
} }
/* Draw the foreground */ /* Draw the foreground */
if (video_on) tilemap_draw(bitmap,cliprect, fg_tilemap, 0, 0); if (video_on) tilemap_draw(bitmap,cliprect, state->fg_tilemap, 0, 0);
/* Draw the road (lines which have priority 0x04) */ /* Draw the road (lines which have priority 0x04) */
if (video_on) wecleman_draw_road(screen->machine, bitmap,cliprect, 0x04); if (video_on) wecleman_draw_road(screen->machine, bitmap,cliprect, 0x04);
/* Draw the sprites */ /* Draw the sprites */
if (video_on) sprite_draw(bitmap,cliprect); if (video_on) sprite_draw(screen->machine, bitmap,cliprect);
/* Draw the text layer */ /* Draw the text layer */
if (video_on) tilemap_draw(bitmap,cliprect, txt_tilemap, 0, 0); if (video_on) tilemap_draw(bitmap,cliprect, state->txt_tilemap, 0, 0);
return 0; return 0;
} }
@ -1123,17 +1118,18 @@ VIDEO_UPDATE ( wecleman )
VIDEO_UPDATE( hotchase ) VIDEO_UPDATE( hotchase )
{ {
wecleman_state *state = screen->machine->driver_data<wecleman_state>();
device_t *k051316_1 = screen->machine->device("k051316_1"); device_t *k051316_1 = screen->machine->device("k051316_1");
device_t *k051316_2 = screen->machine->device("k051316_2"); device_t *k051316_2 = screen->machine->device("k051316_2");
int video_on; int video_on;
video_on = wecleman_irqctrl & 0x40; video_on = state->irqctrl & 0x40;
set_led_status(screen->machine, 0, wecleman_selected_ip & 0x04); // Start lamp set_led_status(screen->machine, 0, state->selected_ip & 0x04); // Start lamp
get_sprite_info(screen->machine); get_sprite_info(screen->machine);
bitmap_fill(bitmap, cliprect, black_pen); bitmap_fill(bitmap, cliprect, state->black_pen);
/* Draw the background */ /* Draw the background */
if (video_on) if (video_on)
@ -1145,7 +1141,7 @@ VIDEO_UPDATE( hotchase )
/* Draw the sprites */ /* Draw the sprites */
if (video_on) if (video_on)
sprite_draw(bitmap,cliprect); sprite_draw(screen->machine, bitmap,cliprect);
/* Draw the foreground (text) */ /* Draw the foreground (text) */
if (video_on) if (video_on)