Added shared driver data struct to 40love.c, bking.c, buggychl.c and msisaac.c (they use the same mcu emulation)

As a result, bking.c, buggychl.c and msisaac.c now support save states (40love.c already did, even if mcu values were not saved)
This commit is contained in:
Fabio Priuli 2009-12-02 22:39:48 +00:00
parent 71be191faf
commit 6ad7e040ec
10 changed files with 1309 additions and 862 deletions

View File

@ -225,49 +225,35 @@ Notes - Has jumper setting for 122HZ or 61HZ)
#include "sound/msm5232.h" #include "sound/msm5232.h"
#include "includes/buggychl.h" #include "includes/buggychl.h"
extern VIDEO_START( fortyl );
extern VIDEO_UPDATE( fortyl );
extern PALETTE_INIT( fortyl );
extern WRITE8_HANDLER( fortyl_bg_videoram_w );
extern WRITE8_HANDLER( fortyl_bg_colorram_w );
extern READ8_HANDLER ( fortyl_bg_videoram_r );
extern READ8_HANDLER ( fortyl_bg_colorram_r );
extern WRITE8_HANDLER( fortyl_pixram_sel_w );
extern READ8_HANDLER( fortyl_pixram_r );
extern WRITE8_HANDLER( fortyl_pixram_w );
extern UINT8 *fortyl_video_ctrl;
extern int fortyl_pix_color[4];
static UINT8 *undoukai_ram;
static int sound_nmi_enable,pending_nmi;
static TIMER_CALLBACK( nmi_callback ) static TIMER_CALLBACK( nmi_callback )
{ {
if (sound_nmi_enable) cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); buggychl_state *state = (buggychl_state *)machine->driver_data;
else pending_nmi = 1; if (state->sound_nmi_enable)
cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
else
state->pending_nmi = 1;
} }
static WRITE8_HANDLER( sound_command_w ) static WRITE8_HANDLER( sound_command_w )
{ {
soundlatch_w(space,0,data); soundlatch_w(space, 0, data);
timer_call_after_resynch(space->machine, NULL, data,nmi_callback); timer_call_after_resynch(space->machine, NULL, data, nmi_callback);
} }
static WRITE8_HANDLER( nmi_disable_w ) static WRITE8_HANDLER( nmi_disable_w )
{ {
sound_nmi_enable = 0; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->sound_nmi_enable = 0;
} }
static WRITE8_HANDLER( nmi_enable_w ) static WRITE8_HANDLER( nmi_enable_w )
{ {
sound_nmi_enable = 1; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
if (pending_nmi) state->sound_nmi_enable = 1;
if (state->pending_nmi)
{ {
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
pending_nmi = 0; state->pending_nmi = 0;
} }
} }
@ -283,64 +269,64 @@ static WRITE8_HANDLER( fortyl_coin_counter_w )
static READ8_HANDLER( fortyl_mcu_r ) static READ8_HANDLER( fortyl_mcu_r )
{ {
return buggychl_mcu_r(space,offset); return buggychl_mcu_r(space, offset);
} }
static READ8_HANDLER( fortyl_mcu_status_r ) static READ8_HANDLER( fortyl_mcu_status_r )
{ {
return buggychl_mcu_status_r(space,offset); return buggychl_mcu_status_r(space, offset);
} }
static WRITE8_HANDLER( fortyl_mcu_w ) static WRITE8_HANDLER( fortyl_mcu_w )
{ {
buggychl_mcu_w(space,offset,data); buggychl_mcu_w(space, offset, data);
} }
static WRITE8_HANDLER( bank_select_w ) static WRITE8_HANDLER( bank_select_w )
{ {
if ((data!=0x02) && (data!=0xfd)) if ((data != 0x02) && (data != 0xfd))
{ {
// logerror("WRONG BANK SELECT = %x !!!!\n",data); // logerror("WRONG BANK SELECT = %x !!!!\n",data);
// popmessage("WRONG BANK SELECT = %x !!!!\n",data); // popmessage("WRONG BANK SELECT = %x !!!!\n",data);
} }
memory_set_bank(space->machine, 1, data&1 ); memory_set_bank(space->machine, 1, data & 1);
} }
static UINT8 pix1;
static UINT8 pix2[2];
static WRITE8_HANDLER( pix1_w ) static WRITE8_HANDLER( pix1_w )
{ {
// if ( data > 7 ) buggychl_state *state = (buggychl_state *)space->machine->driver_data;
// logerror("pix1 = %2x\n",data); // if (data > 7)
// logerror("pix1 = %2x\n", data);
pix1 = data; state->pix1 = data;
} }
static WRITE8_HANDLER( pix2_w ) static WRITE8_HANDLER( pix2_w )
{ {
// if ( (data!=0x00) && (data!=0xff) ) buggychl_state *state = (buggychl_state *)space->machine->driver_data;
// logerror("pix2 = %2x\n",data); // if ((data!=0x00) && (data != 0xff))
// logerror("pix2 = %2x\n", data);
pix2[0] = pix2[1]; state->pix2[0] = state->pix2[1];
pix2[1] = data; state->pix2[1] = data;
} }
#if 0 #if 0
static READ8_HANDLER( pix1_r ) static READ8_HANDLER( pix1_r )
{ {
return pix1; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return state->pix1;
} }
#endif #endif
static READ8_HANDLER( pix2_r ) static READ8_HANDLER( pix2_r )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
int res; int res;
int d1 = pix1 & 7; int d1 = state->pix1 & 7;
res = (((pix2[1] << (d1+8)) | (pix2[0] << d1)) & 0xff00) >> 8; res = (((state->pix2[1] << (d1 + 8)) | (state->pix2[0] << d1)) & 0xff00) >> 8;
return res; return res;
} }
@ -350,11 +336,6 @@ static READ8_HANDLER( pix2_r )
fake MCU (undoukai and field day) fake MCU (undoukai and field day)
****************************************************************************/ ****************************************************************************/
static int from_mcu;
static int mcu_cmd;
static UINT8 mcu_in[2][16],mcu_out[2][16];
static const UINT8 mcu_data0[0x80] = static const UINT8 mcu_data0[0x80] =
{ {
0x0a,0x08,0x0f,0x07,0x06,0x05,0x04,0x00, 0x0a,0x08,0x0f,0x07,0x06,0x05,0x04,0x00,
@ -419,18 +400,18 @@ static const UINT8 mcu_data2[0x80] =
static WRITE8_HANDLER( undoukai_mcu_w ) static WRITE8_HANDLER( undoukai_mcu_w )
{ {
int ram_adr = undoukai_ram[0x1b5]*0x100 + undoukai_ram[0x1b4]; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
int ram_adr = state->mcu_ram[0x1b5] * 0x100 + state->mcu_ram[0x1b4];
int d; int d, i;
int i;
// logerror("mcu_w %02x\n",data); // logerror("mcu_w %02x\n", data);
if (mcu_cmd != -1) if (state->mcu_cmd != -1)
{ {
mcu_in[(mcu_cmd & 0x10)>>4][mcu_cmd & 0x0f] = data; state->mcu_in[(state->mcu_cmd & 0x10) >> 4][state->mcu_cmd & 0x0f] = data;
mcu_cmd = -1; state->mcu_cmd = -1;
} }
else else
{ {
@ -444,17 +425,16 @@ static WRITE8_HANDLER( undoukai_mcu_w )
case 0xc5: case 0xc5:
case 0xc6: case 0xc6:
case 0xc7: case 0xc7:
mcu_cmd = (data & 0x0f) | 0x10; state->mcu_cmd = (data & 0x0f) | 0x10;
break; break;
case 0xb0: case 0xb0:
case 0xb1: case 0xb1:
case 0xb2: case 0xb2:
case 0xb3: case 0xb3:
mcu_cmd = data & 0x0f; state->mcu_cmd = data & 0x0f;
break; break;
case 0x30: case 0x30:
case 0x31: case 0x31:
case 0x32: case 0x32:
@ -465,96 +445,96 @@ static WRITE8_HANDLER( undoukai_mcu_w )
case 0x37: case 0x37:
case 0x38: case 0x38:
case 0x39: case 0x39:
from_mcu = mcu_out[0][data & 0x0f]; state->from_mcu = state->mcu_out[0][data & 0x0f];
break; break;
case 0x40: case 0x40:
case 0x41: case 0x41:
case 0x42: case 0x42:
from_mcu = mcu_out[1][data & 0x0f]; state->from_mcu = state->mcu_out[1][data & 0x0f];
break; break;
case 0x01: case 0x01:
mcu_out[0][0] = (mcu_in[0][0] ^ (mcu_in[0][0] >> 4)) & 0x0f; state->mcu_out[0][0] = (state->mcu_in[0][0] ^ (state->mcu_in[0][0] >> 4)) & 0x0f;
break; break;
case 0x02: case 0x02:
if (mcu_in[0][3] != 0x00) if (state->mcu_in[0][3] != 0x00)
{ {
mcu_out[0][1] = 0x0c; state->mcu_out[0][1] = 0x0c;
mcu_out[0][2] = 0x00; state->mcu_out[0][2] = 0x00;
} }
else else
{ {
mcu_out[0][2] = 0xa2; state->mcu_out[0][2] = 0xa2;
switch (mcu_in[0][0] & 0x03) switch (state->mcu_in[0][0] & 0x03)
{ {
case 0: mcu_out[0][1] = 0x55; break; case 0: state->mcu_out[0][1] = 0x55; break;
case 1: mcu_out[0][1] = 0x3d; break; case 1: state->mcu_out[0][1] = 0x3d; break;
case 2: mcu_out[0][1] = 0x45; break; case 2: state->mcu_out[0][1] = 0x45; break;
case 3: mcu_out[0][1] = 0x4d; break; case 3: state->mcu_out[0][1] = 0x4d; break;
} }
} }
break; break;
case 0x03: case 0x03:
mcu_out[0][1] = (((mcu_in[0][0] * 8) & 0x38) -1) & 0xff ; state->mcu_out[0][1] = (((state->mcu_in[0][0] * 8) & 0x38) -1) & 0xff ;
if (mcu_in[0][1] | mcu_in[0][2]) if (state->mcu_in[0][1] | state->mcu_in[0][2])
d = 0x40; d = 0x40;
else else
d = 0x00; d = 0x00;
for (i=0;i<8;i++) for (i = 0; i < 8; i++)
mcu_out[0][i+2] = mcu_data0[((mcu_out[0][1] + i) & 0x3f) + d]; state->mcu_out[0][i + 2] = mcu_data0[((state->mcu_out[0][1] + i) & 0x3f) + d];
break; break;
case 0x04: case 0x04:
mcu_out[0][0] = ((mcu_in[0][0] & 0x0f) << 4) + (mcu_in[0][1] & 0x0f); state->mcu_out[0][0] = ((state->mcu_in[0][0] & 0x0f) << 4) + (state->mcu_in[0][1] & 0x0f);
mcu_out[0][1] = ((mcu_in[0][2] & 0x0f) << 4) + (mcu_in[0][3] & 0x0f); state->mcu_out[0][1] = ((state->mcu_in[0][2] & 0x0f) << 4) + (state->mcu_in[0][3] & 0x0f);
break; break;
case 0x05: case 0x05:
// mcu_out[0][0] = 255*cos(PI*mcu_in[0][0]/180); // state->mcu_out[0][0] = 255 * cos(PI * state->mcu_in[0][0] / 180);
// mcu_out[0][1] = 255*sin(PI*mcu_in[0][0]/180); // state->mcu_out[0][1] = 255 * sin(PI * state->mcu_in[0][0] / 180);
d = mcu_in[0][0] & 0x7f; d = state->mcu_in[0][0] & 0x7f;
mcu_out[0][0] = mcu_data1[d]; state->mcu_out[0][0] = mcu_data1[d];
mcu_out[0][1] = mcu_data2[d]; state->mcu_out[0][1] = mcu_data2[d];
break; break;
case 0x06: case 0x06:
if (mcu_in[0][0] != 0x00) if (state->mcu_in[0][0] != 0x00)
mcu_out[0][0] = 0xfa; state->mcu_out[0][0] = 0xfa;
else else
switch (mcu_in[0][1]) switch (state->mcu_in[0][1])
{ {
case 0x00: mcu_out[0][0] = 0x02; break; case 0x00: state->mcu_out[0][0] = 0x02; break;
case 0x01: mcu_out[0][0] = 0x01; break; case 0x01: state->mcu_out[0][0] = 0x01; break;
case 0x02: mcu_out[0][0] = 0x01; break; case 0x02: state->mcu_out[0][0] = 0x01; break;
case 0x03: mcu_out[0][0] = 0x04; break; case 0x03: state->mcu_out[0][0] = 0x04; break;
case 0x04: mcu_out[0][0] = 0x01; break; case 0x04: state->mcu_out[0][0] = 0x01; break;
case 0x05: mcu_out[0][0] = 0x14; break; case 0x05: state->mcu_out[0][0] = 0x14; break;
case 0x06: mcu_out[0][0] = 0x14; break; case 0x06: state->mcu_out[0][0] = 0x14; break;
case 0x07: mcu_out[0][0] = 0xb6; break; case 0x07: state->mcu_out[0][0] = 0xb6; break;
default: default:
// popmessage("cmd06: %02x %02x",mcu_in[0][0],mcu_in[0][1]); // popmessage("cmd06: %02x %02x", state->mcu_in[0][0], state->mcu_in[0][1]);
logerror("cmd06: %02x %02x\n",mcu_in[0][0],mcu_in[0][1]); logerror("cmd06: %02x %02x\n", state->mcu_in[0][0], state->mcu_in[0][1]);
} }
break; break;
case 0x07: case 0x07:
switch (mcu_in[0][0] & 7) switch (state->mcu_in[0][0] & 7)
{ {
case 0: mcu_out[0][0] = 0x1d; break; case 0: state->mcu_out[0][0] = 0x1d; break;
case 1: mcu_out[0][0] = 0x1b; break; case 1: state->mcu_out[0][0] = 0x1b; break;
case 2: mcu_out[0][0] = 0x15; break; case 2: state->mcu_out[0][0] = 0x15; break;
case 3: mcu_out[0][0] = 0x13; break; case 3: state->mcu_out[0][0] = 0x13; break;
case 4: mcu_out[0][0] = 0x25; break; case 4: state->mcu_out[0][0] = 0x25; break;
case 5: mcu_out[0][0] = 0x23; break; case 5: state->mcu_out[0][0] = 0x23; break;
case 6: mcu_out[0][0] = 0xff; break; case 6: state->mcu_out[0][0] = 0xff; break;
case 7: mcu_out[0][0] = 0xff; break; case 7: state->mcu_out[0][0] = 0xff; break;
} }
break; break;
@ -563,27 +543,28 @@ static WRITE8_HANDLER( undoukai_mcu_w )
if(ram_adr >= 0xa000 && ram_adr < 0xa800) if(ram_adr >= 0xa000 && ram_adr < 0xa800)
{ {
ram_adr = ram_adr - 0xa000; ram_adr = ram_adr - 0xa000;
mcu_out[1][0] = undoukai_ram[ram_adr]; state->mcu_out[1][0] = state->mcu_ram[ram_adr];
mcu_out[1][1] = undoukai_ram[ram_adr+1]; state->mcu_out[1][1] = state->mcu_ram[ram_adr + 1];
mcu_out[1][2] = undoukai_ram[ram_adr+2] & 0x0f; state->mcu_out[1][2] = state->mcu_ram[ram_adr + 2] & 0x0f;
} }
break; break;
default: default:
from_mcu = 0x5d; state->from_mcu = 0x5d;
// popmessage("unknown cmd%02x: %02x %02x %02x %02x",data,mcu_in[0][0],mcu_in[0][1],mcu_in[0][2],mcu_in[0][3]); // popmessage("unknown cmd%02x: %02x %02x %02x %02x", data, state->mcu_in[0][0], state->mcu_in[0][1], state->mcu_in[0][2], state->mcu_in[0][3]);
// logerror("unknown cmd%02x: %02x %02x %02x %02x\n",data,mcu_in[0][0],mcu_in[0][1],mcu_in[0][2],mcu_in[0][3]); // logerror("unknown cmd%02x: %02x %02x %02x %02x\n", data, state->mcu_in[0][0], state->mcu_in[0][1], state->mcu_in[0][2], state->mcu_in[0][3]);
} }
} }
} }
static READ8_HANDLER( undoukai_mcu_r ) static READ8_HANDLER( undoukai_mcu_r )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
// logerror("mcu_r %02x\n",from_mcu); // logerror("mcu_r %02x\n", state->from_mcu);
return from_mcu; return state->from_mcu;
} }
static READ8_HANDLER( undoukai_mcu_status_r ) static READ8_HANDLER( undoukai_mcu_status_r )
@ -597,20 +578,19 @@ static READ8_HANDLER( undoukai_mcu_status_r )
static DRIVER_INIT( undoukai ) static DRIVER_INIT( undoukai )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
UINT8 *ROM = memory_region(machine, "maincpu"); UINT8 *ROM = memory_region(machine, "maincpu");
memory_configure_bank(machine, 1, 0, 2, &ROM[0x10000], 0x2000); memory_configure_bank(machine, 1, 0, 2, &ROM[0x10000], 0x2000);
from_mcu = 0xff; state->pix_color[0] = 0x000;
mcu_cmd = -1; state->pix_color[1] = 0x1e3;
state->pix_color[2] = 0x16c;
fortyl_pix_color[0] = 0x000; state->pix_color[3] = 0x1ec;
fortyl_pix_color[1] = 0x1e3;
fortyl_pix_color[2] = 0x16c;
fortyl_pix_color[3] = 0x1ec;
} }
static DRIVER_INIT( 40love ) static DRIVER_INIT( 40love )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
UINT8 *ROM = memory_region(machine, "maincpu"); UINT8 *ROM = memory_region(machine, "maincpu");
memory_configure_bank(machine, 1, 0, 2, &ROM[0x10000], 0x2000); memory_configure_bank(machine, 1, 0, 2, &ROM[0x10000], 0x2000);
@ -620,38 +600,38 @@ static DRIVER_INIT( 40love )
UINT8 *ROM = memory_region(machine, "gfx2"); UINT8 *ROM = memory_region(machine, "gfx2");
int adr = 0x10 * 0x022b; int adr = 0x10 * 0x022b;
ROM[adr+0x000a] = 0x00; ROM[adr + 0x000a] = 0x00;
ROM[adr+0x000b] = 0x00; ROM[adr + 0x000b] = 0x00;
ROM[adr+0x400a] = 0x00; ROM[adr + 0x400a] = 0x00;
ROM[adr+0x400b] = 0x00; ROM[adr + 0x400b] = 0x00;
#endif #endif
fortyl_pix_color[0] = 0x000; state->pix_color[0] = 0x000;
fortyl_pix_color[1] = 0x1e3; state->pix_color[1] = 0x1e3;
fortyl_pix_color[2] = 0x16c; state->pix_color[2] = 0x16c;
fortyl_pix_color[3] = 0x1ec; state->pix_color[3] = 0x1ec;
} }
/***************************************************************************/ /***************************************************************************/
static UINT8 snd_data;
static UINT8 snd_flag;
static READ8_HANDLER( from_snd_r ) static READ8_HANDLER( from_snd_r )
{ {
snd_flag = 0; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return snd_data; state->snd_flag = 0;
return state->snd_data;
} }
static READ8_HANDLER( snd_flag_r ) static READ8_HANDLER( snd_flag_r )
{ {
return snd_flag | 0xfd; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return state->snd_flag | 0xfd;
} }
static WRITE8_HANDLER( to_main_w ) static WRITE8_HANDLER( to_main_w )
{ {
snd_data = data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
snd_flag = 2; state->snd_data = data;
state->snd_flag = 2;
} }
/***************************************************************************/ /***************************************************************************/
@ -672,11 +652,11 @@ static ADDRESS_MAP_START( 40love_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x880b, 0x880b) AM_READ_PORT("P2") AM_RANGE(0x880b, 0x880b) AM_READ_PORT("P2")
AM_RANGE(0x880c, 0x880c) AM_READ_PORT("DSW1") AM_WRITE(fortyl_pixram_sel_w) /* pixram bank select */ AM_RANGE(0x880c, 0x880c) AM_READ_PORT("DSW1") AM_WRITE(fortyl_pixram_sel_w) /* pixram bank select */
AM_RANGE(0x880d, 0x880d) AM_READ_PORT("DSW2") AM_WRITENOP /* unknown */ AM_RANGE(0x880d, 0x880d) AM_READ_PORT("DSW2") AM_WRITENOP /* unknown */
AM_RANGE(0x9000, 0x97ff) AM_READWRITE(fortyl_bg_videoram_r, fortyl_bg_videoram_w) AM_BASE_GENERIC(videoram) /* #1 M5517P on video board */ AM_RANGE(0x9000, 0x97ff) AM_READWRITE(fortyl_bg_videoram_r, fortyl_bg_videoram_w) AM_BASE_MEMBER(buggychl_state, videoram) /* #1 M5517P on video board */
AM_RANGE(0x9800, 0x983f) AM_RAM AM_BASE(&fortyl_video_ctrl) /* video control area */ AM_RANGE(0x9800, 0x983f) AM_RAM AM_BASE_MEMBER(buggychl_state, video_ctrl) /* video control area */
AM_RANGE(0x9840, 0x987f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprites part 1 */ AM_RANGE(0x9840, 0x987f) AM_RAM AM_BASE_SIZE_MEMBER(buggychl_state, spriteram, spriteram_size) /* sprites part 1 */
AM_RANGE(0x9880, 0x98bf) AM_READWRITE(fortyl_bg_colorram_r, fortyl_bg_colorram_w) AM_BASE_GENERIC(colorram) /* background attributes (2 bytes per line) */ AM_RANGE(0x9880, 0x98bf) AM_READWRITE(fortyl_bg_colorram_r, fortyl_bg_colorram_w) AM_BASE_MEMBER(buggychl_state, colorram) /* background attributes (2 bytes per line) */
AM_RANGE(0x98c0, 0x98ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2)/* sprites part 2 */ AM_RANGE(0x98c0, 0x98ff) AM_RAM AM_BASE_SIZE_MEMBER(buggychl_state, spriteram2, spriteram2_size)/* sprites part 2 */
AM_RANGE(0xa000, 0xbfff) AM_ROMBANK(1) AM_RANGE(0xa000, 0xbfff) AM_ROMBANK(1)
AM_RANGE(0xc000, 0xffff) AM_READWRITE(fortyl_pixram_r, fortyl_pixram_w) /* banked pixel layer */ AM_RANGE(0xc000, 0xffff) AM_READWRITE(fortyl_pixram_r, fortyl_pixram_w) /* banked pixel layer */
ADDRESS_MAP_END ADDRESS_MAP_END
@ -684,7 +664,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( undoukai_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( undoukai_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x9fff) AM_ROMBANK(1) AM_RANGE(0x8000, 0x9fff) AM_ROMBANK(1)
AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_BASE(&undoukai_ram) /* M5517P on main board */ AM_RANGE(0xa000, 0xa7ff) AM_RAM AM_BASE_MEMBER(buggychl_state, mcu_ram) /* M5517P on main board */
AM_RANGE(0xa800, 0xa800) AM_READWRITE(undoukai_mcu_r, undoukai_mcu_w) AM_RANGE(0xa800, 0xa800) AM_READWRITE(undoukai_mcu_r, undoukai_mcu_w)
AM_RANGE(0xa801, 0xa801) AM_READWRITE(undoukai_mcu_status_r, pix1_w) //pixel layer related AM_RANGE(0xa801, 0xa801) AM_READWRITE(undoukai_mcu_status_r, pix1_w) //pixel layer related
AM_RANGE(0xa802, 0xa802) AM_WRITE(bank_select_w) AM_RANGE(0xa802, 0xa802) AM_WRITE(bank_select_w)
@ -698,34 +678,32 @@ static ADDRESS_MAP_START( undoukai_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xa80b, 0xa80b) AM_READ_PORT("P2") AM_RANGE(0xa80b, 0xa80b) AM_READ_PORT("P2")
AM_RANGE(0xa80c, 0xa80c) AM_READ_PORT("DSW1") AM_WRITE(fortyl_pixram_sel_w) /* pixram bank select */ AM_RANGE(0xa80c, 0xa80c) AM_READ_PORT("DSW1") AM_WRITE(fortyl_pixram_sel_w) /* pixram bank select */
AM_RANGE(0xa80d, 0xa80d) AM_READ_PORT("DSW2") AM_WRITENOP /* unknown */ AM_RANGE(0xa80d, 0xa80d) AM_READ_PORT("DSW2") AM_WRITENOP /* unknown */
AM_RANGE(0xb000, 0xb7ff) AM_READWRITE(fortyl_bg_videoram_r, fortyl_bg_videoram_w) AM_BASE_GENERIC(videoram) /* #1 M5517P on video board */ AM_RANGE(0xb000, 0xb7ff) AM_READWRITE(fortyl_bg_videoram_r, fortyl_bg_videoram_w) AM_BASE_MEMBER(buggychl_state, videoram) /* #1 M5517P on video board */
AM_RANGE(0xb800, 0xb83f) AM_RAM AM_BASE(&fortyl_video_ctrl) /* video control area */ AM_RANGE(0xb800, 0xb83f) AM_RAM AM_BASE_MEMBER(buggychl_state, video_ctrl) /* video control area */
AM_RANGE(0xb840, 0xb87f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprites part 1 */ AM_RANGE(0xb840, 0xb87f) AM_RAM AM_BASE_SIZE_MEMBER(buggychl_state, spriteram, spriteram_size) /* sprites part 1 */
AM_RANGE(0xb880, 0xb8bf) AM_READWRITE(fortyl_bg_colorram_r, fortyl_bg_colorram_w) AM_BASE_GENERIC(colorram) /* background attributes (2 bytes per line) */ AM_RANGE(0xb880, 0xb8bf) AM_READWRITE(fortyl_bg_colorram_r, fortyl_bg_colorram_w) AM_BASE_MEMBER(buggychl_state, colorram) /* background attributes (2 bytes per line) */
AM_RANGE(0xb8e0, 0xb8ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2) /* sprites part 2 */ AM_RANGE(0xb8e0, 0xb8ff) AM_RAM AM_BASE_SIZE_MEMBER(buggychl_state, spriteram2, spriteram2_size) /* sprites part 2 */
AM_RANGE(0xc000, 0xffff) AM_READWRITE(fortyl_pixram_r, fortyl_pixram_w) AM_RANGE(0xc000, 0xffff) AM_READWRITE(fortyl_pixram_r, fortyl_pixram_w)
ADDRESS_MAP_END ADDRESS_MAP_END
static int vol_ctrl[16];
static MACHINE_RESET( ta7630 ) static MACHINE_RESET( ta7630 )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
int i; int i;
double db = 0.0; double db = 0.0;
double db_step = 1.50; /* 1.50 dB step (at least, maybe more) */ double db_step = 1.50; /* 1.50 dB step (at least, maybe more) */
double db_step_inc = 0.125; double db_step_inc = 0.125;
for (i=0; i<16; i++) for (i = 0; i < 16; i++)
{ {
double max = 100.0 / pow(10.0, db/20.0 ); double max = 100.0 / pow(10.0, db/20.0);
vol_ctrl[ 15-i ] = max; state->vol_ctrl[15 - i] = max;
/*logerror("vol_ctrl[%x] = %i (%f dB)\n",15-i,vol_ctrl[ 15-i ],db);*/ /*logerror("vol_ctrl[%x] = %i (%f dB)\n", 15 - i, state->vol_ctrl[15 - i], db);*/
db += db_step; db += db_step;
db_step += db_step_inc; db_step += db_step_inc;
} }
/* for (i=0; i<8; i++) /* for (i = 0; i < 8; i++)
logerror("SOUND Chan#%i name=%s\n", i, mixer_get_name(i) ); */ logerror("SOUND Chan#%i name=%s\n", i, mixer_get_name(i) ); */
/* /*
channels 0-2 AY#0 channels 0-2 AY#0
@ -733,48 +711,46 @@ static MACHINE_RESET( ta7630 )
*/ */
} }
static UINT8 snd_ctrl0=0;
static UINT8 snd_ctrl1=0;
static UINT8 snd_ctrl2=0;
static UINT8 snd_ctrl3=0;
static WRITE8_DEVICE_HANDLER( sound_control_0_w ) static WRITE8_DEVICE_HANDLER( sound_control_0_w )
{ {
snd_ctrl0 = data & 0xff; buggychl_state *state = (buggychl_state *)device->machine->driver_data;
// popmessage("SND0 0=%02x 1=%02x 2=%02x 3=%02x", snd_ctrl0, snd_ctrl1, snd_ctrl2, snd_ctrl3); state->snd_ctrl0 = data & 0xff;
// popmessage("SND0 0=%02x 1=%02x 2=%02x 3=%02x", state->snd_ctrl0, state->snd_ctrl1, state->snd_ctrl2, state->snd_ctrl3);
/* this definitely controls main melody voice on 2'-1 and 4'-1 outputs */ /* this definitely controls main melody voice on 2'-1 and 4'-1 outputs */
sound_set_output_gain(device, 0, vol_ctrl[ (snd_ctrl0>>4) & 15 ] / 100.0); /* group1 from msm5232 */ sound_set_output_gain(device, 0, state->vol_ctrl[(state->snd_ctrl0 >> 4) & 15] / 100.0); /* group1 from msm5232 */
sound_set_output_gain(device, 1, vol_ctrl[ (snd_ctrl0>>4) & 15 ] / 100.0); /* group1 from msm5232 */ sound_set_output_gain(device, 1, state->vol_ctrl[(state->snd_ctrl0 >> 4) & 15] / 100.0); /* group1 from msm5232 */
sound_set_output_gain(device, 2, vol_ctrl[ (snd_ctrl0>>4) & 15 ] / 100.0); /* group1 from msm5232 */ sound_set_output_gain(device, 2, state->vol_ctrl[(state->snd_ctrl0 >> 4) & 15] / 100.0); /* group1 from msm5232 */
sound_set_output_gain(device, 3, vol_ctrl[ (snd_ctrl0>>4) & 15 ] / 100.0); /* group1 from msm5232 */ sound_set_output_gain(device, 3, state->vol_ctrl[(state->snd_ctrl0 >> 4) & 15] / 100.0); /* group1 from msm5232 */
} }
static WRITE8_DEVICE_HANDLER( sound_control_1_w ) static WRITE8_DEVICE_HANDLER( sound_control_1_w )
{ {
snd_ctrl1 = data & 0xff; buggychl_state *state = (buggychl_state *)device->machine->driver_data;
// popmessage("SND1 0=%02x 1=%02x 2=%02x 3=%02x", snd_ctrl0, snd_ctrl1, snd_ctrl2, snd_ctrl3); state->snd_ctrl1 = data & 0xff;
sound_set_output_gain(device, 4, vol_ctrl[ (snd_ctrl1>>4) & 15 ] / 100.0); /* group2 from msm5232 */ // popmessage("SND1 0=%02x 1=%02x 2=%02x 3=%02x", state->snd_ctrl0, state->snd_ctrl1, state->snd_ctrl2, state->snd_ctrl3);
sound_set_output_gain(device, 5, vol_ctrl[ (snd_ctrl1>>4) & 15 ] / 100.0); /* group2 from msm5232 */ sound_set_output_gain(device, 4, state->vol_ctrl[(state->snd_ctrl1 >> 4) & 15] / 100.0); /* group2 from msm5232 */
sound_set_output_gain(device, 6, vol_ctrl[ (snd_ctrl1>>4) & 15 ] / 100.0); /* group2 from msm5232 */ sound_set_output_gain(device, 5, state->vol_ctrl[(state->snd_ctrl1 >> 4) & 15] / 100.0); /* group2 from msm5232 */
sound_set_output_gain(device, 7, vol_ctrl[ (snd_ctrl1>>4) & 15 ] / 100.0); /* group2 from msm5232 */ sound_set_output_gain(device, 6, state->vol_ctrl[(state->snd_ctrl1 >> 4) & 15] / 100.0); /* group2 from msm5232 */
sound_set_output_gain(device, 7, state->vol_ctrl[(state->snd_ctrl1 >> 4) & 15] / 100.0); /* group2 from msm5232 */
} }
static WRITE8_DEVICE_HANDLER( sound_control_2_w ) static WRITE8_DEVICE_HANDLER( sound_control_2_w )
{ {
buggychl_state *state = (buggychl_state *)device->machine->driver_data;
int i; int i;
state->snd_ctrl2 = data & 0xff;
// popmessage("SND2 0=%02x 1=%02x 2=%02x 3=%02x", state->snd_ctrl0, state->snd_ctrl1, state->snd_ctrl2, state->snd_ctrl3);
snd_ctrl2 = data & 0xff; for (i = 0; i < 3; i++)
// popmessage("SND2 0=%02x 1=%02x 2=%02x 3=%02x", snd_ctrl0, snd_ctrl1, snd_ctrl2, snd_ctrl3); sound_set_output_gain(device, i, state->vol_ctrl[(state->snd_ctrl2 >> 4) & 15] / 100.0); /* ym2149f all */
for (i=0; i<3; i++)
sound_set_output_gain(device, i, vol_ctrl[ (snd_ctrl2>>4) & 15 ] / 100.0); /* ym2149f all */
} }
static WRITE8_DEVICE_HANDLER( sound_control_3_w ) /* unknown */ static WRITE8_DEVICE_HANDLER( sound_control_3_w ) /* unknown */
{ {
snd_ctrl3 = data & 0xff; buggychl_state *state = (buggychl_state *)device->machine->driver_data;
// popmessage("SND3 0=%02x 1=%02x 2=%02x 3=%02x", snd_ctrl0, snd_ctrl1, snd_ctrl2, snd_ctrl3); state->snd_ctrl3 = data & 0xff;
// popmessage("SND3 0=%02x 1=%02x 2=%02x 3=%02x", state->snd_ctrl0, state->snd_ctrl1, state->snd_ctrl2, state->snd_ctrl3);
} }
static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -793,12 +769,12 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7ff) ADDRESS_MAP_GLOBAL_MASK(0x7ff)
AM_RANGE(0x0000, 0x0000) AM_READWRITE(buggychl_68705_portA_r, buggychl_68705_portA_w) AM_RANGE(0x0000, 0x0000) AM_READWRITE(buggychl_68705_port_a_r, buggychl_68705_port_a_w)
AM_RANGE(0x0001, 0x0001) AM_READWRITE(buggychl_68705_portB_r, buggychl_68705_portB_w) AM_RANGE(0x0001, 0x0001) AM_READWRITE(buggychl_68705_port_b_r, buggychl_68705_port_b_w)
AM_RANGE(0x0002, 0x0002) AM_READWRITE(buggychl_68705_portC_r, buggychl_68705_portC_w) AM_RANGE(0x0002, 0x0002) AM_READWRITE(buggychl_68705_port_c_r, buggychl_68705_port_c_w)
AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddrA_w) AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddr_a_w)
AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddrB_w) AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddr_b_w)
AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddrC_w) AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddr_c_w)
AM_RANGE(0x0010, 0x007f) AM_RAM AM_RANGE(0x0010, 0x007f) AM_RAM
AM_RANGE(0x0080, 0x07ff) AM_ROM AM_RANGE(0x0080, 0x07ff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -1019,27 +995,135 @@ static const msm5232_interface msm5232_config =
/*******************************************************************************/ /*******************************************************************************/
static MACHINE_START( common )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
state->audiocpu = devtag_get_device(machine, "audiocpu");
state->mcu = devtag_get_device(machine, "mcu");
/* video */
state_save_register_global(machine, state->pix1);
state_save_register_global_array(machine, state->pix2);
/* sound */
state_save_register_global(machine, state->sound_nmi_enable);
state_save_register_global(machine, state->pending_nmi);
state_save_register_global(machine, state->snd_data);
state_save_register_global(machine, state->snd_flag);
state_save_register_global_array(machine, state->vol_ctrl);
state_save_register_global(machine, state->snd_ctrl0);
state_save_register_global(machine, state->snd_ctrl1);
state_save_register_global(machine, state->snd_ctrl2);
state_save_register_global(machine, state->snd_ctrl3);
}
static MACHINE_START( 40love ) static MACHINE_START( 40love )
{ {
state_save_register_global(machine, pix1); buggychl_state *state = (buggychl_state *)machine->driver_data;
state_save_register_global_array(machine, pix2);
state_save_register_global(machine, from_mcu); MACHINE_START_CALL(common);
state_save_register_global(machine, mcu_cmd);
state_save_register_global_array(machine, mcu_in[0]); /* mcu */
state_save_register_global_array(machine, mcu_in[1]); state_save_register_global(machine, state->from_main);
state_save_register_global_array(machine, mcu_out[0]); state_save_register_global(machine, state->from_mcu);
state_save_register_global_array(machine, mcu_out[1]); state_save_register_global(machine, state->mcu_sent);
state_save_register_global(machine, snd_data); state_save_register_global(machine, state->main_sent);
state_save_register_global(machine, snd_flag); state_save_register_global(machine, state->port_a_in);
state_save_register_global_array(machine, vol_ctrl); state_save_register_global(machine, state->port_a_out);
state_save_register_global(machine, snd_ctrl0); state_save_register_global(machine, state->ddr_a);
state_save_register_global(machine, snd_ctrl1); state_save_register_global(machine, state->port_b_in);
state_save_register_global(machine, snd_ctrl2); state_save_register_global(machine, state->port_b_out);
state_save_register_global(machine, snd_ctrl3); state_save_register_global(machine, state->ddr_b);
state_save_register_global(machine, state->port_c_in);
state_save_register_global(machine, state->port_c_out);
state_save_register_global(machine, state->ddr_c);
}
static MACHINE_START( undoukai )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
MACHINE_START_CALL(common);
/* fake mcu */
state_save_register_global(machine, state->from_mcu);
state_save_register_global(machine, state->mcu_cmd);
state_save_register_global_array(machine, state->mcu_in[0]);
state_save_register_global_array(machine, state->mcu_in[1]);
state_save_register_global_array(machine, state->mcu_out[0]);
state_save_register_global_array(machine, state->mcu_out[1]);
}
static MACHINE_RESET( common )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
MACHINE_RESET_CALL(ta7630);
/* video */
state->pix1 = 0;
state->pix2[0] = 0;
state->pix2[1] = 0;
/* sound */
state->sound_nmi_enable = 0;
state->pending_nmi = 0;
state->snd_data = 0;
state->snd_flag = 0;
state->snd_ctrl0 = 0;
state->snd_ctrl1 = 0;
state->snd_ctrl2 = 0;
state->snd_ctrl3 = 0;
}
static MACHINE_RESET( 40love )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
MACHINE_RESET_CALL(common);
/* mcu */
state->mcu_sent = 0;
state->main_sent = 0;
state->from_main = 0;
state->from_mcu = 0;
state->port_a_in = 0;
state->port_a_out = 0;
state->ddr_a = 0;
state->port_b_in = 0;
state->port_b_out = 0;
state->ddr_b = 0;
state->port_c_in = 0;
state->port_c_out = 0;
state->ddr_c = 0;
}
static MACHINE_RESET( undoukai )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
int i;
MACHINE_RESET_CALL(common);
/* fake mcu */
state->from_mcu = 0xff;
state->mcu_cmd = -1;
for (i = 0; i < 16; i++)
{
state->mcu_in[0][i] = 0;
state->mcu_in[1][i] = 0;
state->mcu_out[0][i] = 0;
state->mcu_out[1][i] = 0;
}
} }
static MACHINE_DRIVER_START( 40love ) static MACHINE_DRIVER_START( 40love )
/* driver data */
MDRV_DRIVER_DATA(buggychl_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu",Z80,8000000/2) /* OK */ MDRV_CPU_ADD("maincpu",Z80,8000000/2) /* OK */
MDRV_CPU_PROGRAM_MAP(40love_map) MDRV_CPU_PROGRAM_MAP(40love_map)
@ -1053,7 +1137,8 @@ static MACHINE_DRIVER_START( 40love )
MDRV_CPU_PROGRAM_MAP(mcu_map) MDRV_CPU_PROGRAM_MAP(mcu_map)
MDRV_QUANTUM_TIME(HZ(6000)) /* high interleave to ensure proper synchronization of CPUs */ MDRV_QUANTUM_TIME(HZ(6000)) /* high interleave to ensure proper synchronization of CPUs */
MDRV_MACHINE_RESET(ta7630) /* init machine */ MDRV_MACHINE_START(40love)
MDRV_MACHINE_RESET(40love)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
@ -1069,8 +1154,6 @@ static MACHINE_DRIVER_START( 40love )
MDRV_VIDEO_START(fortyl) MDRV_VIDEO_START(fortyl)
MDRV_VIDEO_UPDATE(fortyl) MDRV_VIDEO_UPDATE(fortyl)
MDRV_MACHINE_START(40love)
/* sound hardware */ /* sound hardware */
MDRV_SPEAKER_STANDARD_MONO("mono") MDRV_SPEAKER_STANDARD_MONO("mono")
@ -1098,6 +1181,9 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( undoukai ) static MACHINE_DRIVER_START( undoukai )
/* driver data */
MDRV_DRIVER_DATA(buggychl_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu",Z80,8000000/2) MDRV_CPU_ADD("maincpu",Z80,8000000/2)
MDRV_CPU_PROGRAM_MAP(undoukai_map) MDRV_CPU_PROGRAM_MAP(undoukai_map)
@ -1110,7 +1196,8 @@ static MACHINE_DRIVER_START( undoukai )
// MDRV_CPU_ADD("mcu",M68705,18432000/6) // MDRV_CPU_ADD("mcu",M68705,18432000/6)
// MDRV_CPU_PROGRAM_MAP(mcu_map) // MDRV_CPU_PROGRAM_MAP(mcu_map)
MDRV_MACHINE_RESET(ta7630) /* init machine */ MDRV_MACHINE_START(undoukai)
MDRV_MACHINE_RESET(undoukai) /* init machine */
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
@ -1126,8 +1213,6 @@ static MACHINE_DRIVER_START( undoukai )
MDRV_VIDEO_START(fortyl) MDRV_VIDEO_START(fortyl)
MDRV_VIDEO_UPDATE(fortyl) MDRV_VIDEO_UPDATE(fortyl)
MDRV_MACHINE_START(40love)
/* sound hardware */ /* sound hardware */
MDRV_SPEAKER_STANDARD_MONO("mono") MDRV_SPEAKER_STANDARD_MONO("mono")

View File

@ -22,71 +22,50 @@ DIP Locations verified for:
#include "sound/dac.h" #include "sound/dac.h"
#include "includes/buggychl.h" #include "includes/buggychl.h"
extern PALETTE_INIT( bking );
extern VIDEO_START( bking );
extern VIDEO_UPDATE( bking );
extern VIDEO_EOF( bking );
extern WRITE8_HANDLER( bking_xld1_w );
extern WRITE8_HANDLER( bking_yld1_w );
extern WRITE8_HANDLER( bking_xld2_w );
extern WRITE8_HANDLER( bking_yld2_w );
extern WRITE8_HANDLER( bking_xld3_w );
extern WRITE8_HANDLER( bking_yld3_w );
extern WRITE8_HANDLER( bking_msk_w );
extern WRITE8_HANDLER( bking_cont1_w );
extern WRITE8_HANDLER( bking_cont2_w );
extern WRITE8_HANDLER( bking_cont3_w );
extern WRITE8_HANDLER( bking_hitclr_w );
extern WRITE8_HANDLER( bking_playfield_w );
extern READ8_HANDLER( bking_input_port_5_r );
extern READ8_HANDLER( bking_input_port_6_r );
extern READ8_HANDLER( bking_pos_r );
UINT8 *bking_playfield_ram;
static int bking3_addr_h, bking3_addr_l;
static int sndnmi_enable;
static READ8_HANDLER( bking_sndnmi_disable_r ) static READ8_HANDLER( bking_sndnmi_disable_r )
{ {
sndnmi_enable = 0; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->sound_nmi_enable = 0;
return 0; return 0;
} }
static WRITE8_HANDLER( bking_sndnmi_enable_w ) static WRITE8_HANDLER( bking_sndnmi_enable_w )
{ {
sndnmi_enable = 1; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->sound_nmi_enable = 1;
} }
static WRITE8_HANDLER( bking_soundlatch_w ) static WRITE8_HANDLER( bking_soundlatch_w )
{ {
int i,code; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
int i, code = 0;
code = 0;
for (i = 0;i < 8;i++) for (i = 0;i < 8;i++)
if (data & (1 << i)) code |= 0x80 >> i; if (data & (1 << i))
code |= 0x80 >> i;
soundlatch_w(space,offset,code); soundlatch_w(space, offset, code);
if (sndnmi_enable) cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); if (state->sound_nmi_enable)
cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
} }
static WRITE8_HANDLER( bking3_addr_l_w ) static WRITE8_HANDLER( bking3_addr_l_w )
{ {
bking3_addr_l = data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->addr_l = data;
} }
static WRITE8_HANDLER( bking3_addr_h_w ) static WRITE8_HANDLER( bking3_addr_h_w )
{ {
bking3_addr_h = data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->addr_h = data;
} }
static READ8_HANDLER( bking3_extrarom_r ) static READ8_HANDLER( bking3_extrarom_r )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
UINT8 *rom = memory_region(space->machine, "user2"); UINT8 *rom = memory_region(space->machine, "user2");
return rom[bking3_addr_h * 256 + bking3_addr_l]; return rom[state->addr_h * 256 + state->addr_l];
} }
static WRITE8_HANDLER( unk_w ) static WRITE8_HANDLER( unk_w )
@ -105,7 +84,7 @@ static READ8_HANDLER( bking3_ext_check_r )
static ADDRESS_MAP_START( bking_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( bking_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x7fff) AM_ROM AM_RANGE(0x0000, 0x7fff) AM_ROM
AM_RANGE(0x8000, 0x83ff) AM_RAM AM_RANGE(0x8000, 0x83ff) AM_RAM
AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(bking_playfield_w) AM_BASE(&bking_playfield_ram) AM_RANGE(0x9000, 0x97ff) AM_RAM_WRITE(bking_playfield_w) AM_BASE_MEMBER(buggychl_state, playfield_ram)
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( bking_io_map, ADDRESS_SPACE_IO, 8 ) static ADDRESS_MAP_START( bking_io_map, ADDRESS_SPACE_IO, 8 )
@ -165,40 +144,40 @@ static ADDRESS_MAP_START( bking_audio_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END ADDRESS_MAP_END
#if 0 #if 0
static UINT8 portA_in,portA_out,ddrA; static UINT8 port_a_in,port_a_out,ddr_a;
static READ8_HANDLER( bking3_68705_portA_r ) static READ8_HANDLER( bking3_68705_port_a_r )
{ {
//printf("portA_r = %02X\n",(portA_out & ddrA) | (portA_in & ~ddrA)); //printf("port_a_r = %02X\n",(port_a_out & ddr_a) | (port_a_in & ~ddr_a));
return (portA_out & ddrA) | (portA_in & ~ddrA); return (port_a_out & ddr_a) | (port_a_in & ~ddr_a);
} }
static WRITE8_HANDLER( bking3_68705_portA_w ) static WRITE8_HANDLER( bking3_68705_port_a_w )
{ {
portA_out = data; port_a_out = data;
// printf("portA_out = %02X\n",data); // printf("port_a_out = %02X\n",data);
} }
static WRITE8_HANDLER( bking3_68705_ddrA_w ) static WRITE8_HANDLER( bking3_68705_ddr_a_w )
{ {
ddrA = data; ddr_a = data;
} }
static UINT8 portB_in,portB_out,ddrB; static UINT8 port_b_in,port_b_out,ddr_b;
static READ8_HANDLER( bking3_68705_portB_r ) static READ8_HANDLER( bking3_68705_port_b_r )
{ {
return (portB_out & ddrB) | (portB_in & ~ddrB); return (port_b_out & ddr_b) | (port_b_in & ~ddr_b);
} }
static WRITE8_HANDLER( bking3_68705_portB_w ) static WRITE8_HANDLER( bking3_68705_port_b_w )
{ {
// if(data != 0xff) // if(data != 0xff)
// printf("portB_out = %02X\n",data); // printf("port_b_out = %02X\n",data);
if (~data & 0x02) if (~data & 0x02)
{ {
portA_in = from_main; port_a_in = from_main;
if (main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE); if (main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
main_sent = 0; main_sent = 0;
} }
@ -206,44 +185,45 @@ static WRITE8_HANDLER( bking3_68705_portB_w )
if (~data & 0x04) if (~data & 0x04)
{ {
/* 68705 is writing data for the Z80 */ /* 68705 is writing data for the Z80 */
from_mcu = portA_out; from_mcu = port_a_out;
mcu_sent = 1; mcu_sent = 1;
} }
if(data != 0xff && data != 0xfb && data != 0xfd) if(data != 0xff && data != 0xfb && data != 0xfd)
printf("portB_w = %X\n",data); printf("port_b_w = %X\n",data);
portB_out = data; port_b_out = data;
} }
static WRITE8_HANDLER( bking3_68705_ddrB_w ) static WRITE8_HANDLER( bking3_68705_ddr_b_w )
{ {
ddrB = data; ddr_b = data;
} }
static READ8_HANDLER( bking3_68705_portC_r ) static READ8_HANDLER( bking3_68705_port_c_r )
{ {
int portC_in = 0; int port_c_in = 0;
if (main_sent) portC_in |= 0x01; if (main_sent) port_c_in |= 0x01;
if (!mcu_sent) portC_in |= 0x02; if (!mcu_sent) port_c_in |= 0x02;
//logerror("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),portC_in); //logerror("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),port_c_in);
return portC_in; return port_c_in;
} }
#endif #endif
static ADDRESS_MAP_START( m68705_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( m68705_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7ff) ADDRESS_MAP_GLOBAL_MASK(0x7ff)
AM_RANGE(0x0000, 0x0000) AM_READWRITE(buggychl_68705_portA_r, buggychl_68705_portA_w) AM_RANGE(0x0000, 0x0000) AM_READWRITE(buggychl_68705_port_a_r, buggychl_68705_port_a_w)
AM_RANGE(0x0001, 0x0001) AM_READWRITE(buggychl_68705_portB_r, buggychl_68705_portB_w) AM_RANGE(0x0001, 0x0001) AM_READWRITE(buggychl_68705_port_b_r, buggychl_68705_port_b_w)
AM_RANGE(0x0002, 0x0002) AM_READWRITE(buggychl_68705_portC_r, buggychl_68705_portC_w) AM_RANGE(0x0002, 0x0002) AM_READWRITE(buggychl_68705_port_c_r, buggychl_68705_port_c_w)
AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddrA_w) AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddr_a_w)
AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddrB_w) AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddr_b_w)
AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddrC_w) AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddr_c_w)
AM_RANGE(0x0010, 0x007f) AM_RAM AM_RANGE(0x0010, 0x007f) AM_RAM
AM_RANGE(0x0080, 0x07ff) AM_ROM AM_RANGE(0x0080, 0x07ff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
static INPUT_PORTS_START( bking ) static INPUT_PORTS_START( bking )
PORT_START("IN0") /* IN0 */ PORT_START("IN0")
PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_BIT( 0xfc, IP_ACTIVE_HIGH, IPT_UNUSED )
@ -251,7 +231,7 @@ static INPUT_PORTS_START( bking )
/* continue inputs are labelled in schematics. */ /* continue inputs are labelled in schematics. */
/* They are not connected though to any button */ /* They are not connected though to any button */
PORT_START("IN1") /* IN1 */ PORT_START("IN1")
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 ) PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Continue 1 */ PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED ) /* Continue 1 */
@ -260,7 +240,7 @@ static INPUT_PORTS_START( bking )
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT ) PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT )
PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) /* Not Connected */ PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED ) /* Not Connected */
PORT_START("DSWA") /* IN2 - DIP Switch A */ PORT_START("DSWA")
PORT_DIPNAME( 0x01, 0x00, "Holes Awarded" ) PORT_DIPLOCATION("SWA:1") PORT_DIPNAME( 0x01, 0x00, "Holes Awarded" ) PORT_DIPLOCATION("SWA:1")
PORT_DIPSETTING( 0x00, "Par Play: 0 Holes/Birdie: 1 Hole/Eagle: 2 Holes/Double Eagle: 4 Holes" ) PORT_DIPSETTING( 0x00, "Par Play: 0 Holes/Birdie: 1 Hole/Eagle: 2 Holes/Double Eagle: 4 Holes" )
PORT_DIPSETTING( 0x01, "Par Play: 1 Hole/Birdie: 2 Holes/Eagle: 3 Holes/Double Eagle: 4 Holes" ) PORT_DIPSETTING( 0x01, "Par Play: 1 Hole/Birdie: 2 Holes/Eagle: 3 Holes/Double Eagle: 4 Holes" )
@ -285,7 +265,7 @@ static INPUT_PORTS_START( bking )
PORT_DIPSETTING( 0x00, DEF_STR(Upright) ) PORT_DIPSETTING( 0x00, DEF_STR(Upright) )
PORT_DIPSETTING( 0x80, DEF_STR(Cocktail) ) PORT_DIPSETTING( 0x80, DEF_STR(Cocktail) )
PORT_START("DSWB") /* IN3 - DIP Switch B */ PORT_START("DSWB")
PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWB:1,2,3,4") PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWB:1,2,3,4")
PORT_DIPSETTING( 0x0f, DEF_STR( 9C_1C ) ) PORT_DIPSETTING( 0x0f, DEF_STR( 9C_1C ) )
PORT_DIPSETTING( 0x0e, DEF_STR( 8C_1C ) ) PORT_DIPSETTING( 0x0e, DEF_STR( 8C_1C ) )
@ -321,7 +301,7 @@ static INPUT_PORTS_START( bking )
PORT_DIPSETTING( 0x60, DEF_STR( 1C_7C ) ) PORT_DIPSETTING( 0x60, DEF_STR( 1C_7C ) )
PORT_DIPSETTING( 0x70, DEF_STR( 1C_8C ) ) PORT_DIPSETTING( 0x70, DEF_STR( 1C_8C ) )
PORT_START("DSWC") /* IN4 - DIP Switch C */ PORT_START("DSWC")
PORT_DIPNAME( 0x01, 0x01, "Appearance of Crow" ) PORT_DIPLOCATION("SWC:1") PORT_DIPNAME( 0x01, 0x01, "Appearance of Crow" ) PORT_DIPLOCATION("SWC:1")
PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x01, DEF_STR( On ) ) PORT_DIPSETTING( 0x01, DEF_STR( On ) )
@ -344,16 +324,16 @@ static INPUT_PORTS_START( bking )
PORT_DIPSETTING( 0x00, "1 Way" ) PORT_DIPSETTING( 0x00, "1 Way" )
PORT_DIPSETTING( 0x80, "2 Way" ) PORT_DIPSETTING( 0x80, "2 Way" )
PORT_START("TRACK0_X") /* IN5 */ PORT_START("TRACK0_X")
PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) /* Sensitivity, clip, min, max */ PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) /* Sensitivity, clip, min, max */
PORT_START("TRACK0_Y") /* IN6 */ PORT_START("TRACK0_Y")
PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_REVERSE /* Sensitivity, clip, min, max */ PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_REVERSE /* Sensitivity, clip, min, max */
PORT_START("TRACK1_X") /* IN7 */ PORT_START("TRACK1_X")
PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_COCKTAIL /* Sensitivity, clip, min, max */ PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_COCKTAIL /* Sensitivity, clip, min, max */
PORT_START("TRACK1_Y") /* IN8 */ PORT_START("TRACK1_Y")
PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_REVERSE PORT_COCKTAIL /* Sensitivity, clip, min, max */ PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_REVERSE PORT_COCKTAIL /* Sensitivity, clip, min, max */
INPUT_PORTS_END INPUT_PORTS_END
@ -412,10 +392,11 @@ static GFXDECODE_START( bking )
GFXDECODE_END GFXDECODE_END
static WRITE8_DEVICE_HANDLER( portb_w ) static WRITE8_DEVICE_HANDLER( port_b_w )
{ {
/* don't know what this is... could be a filter */ /* don't know what this is... could be a filter */
if (data != 0x00) logerror("portB = %02x\n",data); if (data != 0x00)
logerror("port_b = %02x\n", data);
} }
static const ay8910_interface ay8910_config = static const ay8910_interface ay8910_config =
@ -425,11 +406,123 @@ static const ay8910_interface ay8910_config =
DEVCB_NULL, DEVCB_NULL,
DEVCB_NULL, DEVCB_NULL,
DEVCB_DEVICE_HANDLER("dac", dac_signed_w), DEVCB_DEVICE_HANDLER("dac", dac_signed_w),
DEVCB_HANDLER(portb_w) DEVCB_HANDLER(port_b_w)
}; };
static MACHINE_START( bking )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
state->audiocpu = devtag_get_device(machine, "audiocpu");
/* video */
state_save_register_global_array(machine, state->pc3259_output);
state_save_register_global(machine, state->pc3259_mask);
state_save_register_global(machine, state->xld1);
state_save_register_global(machine, state->xld2);
state_save_register_global(machine, state->xld3);
state_save_register_global(machine, state->yld1);
state_save_register_global(machine, state->yld2);
state_save_register_global(machine, state->yld3);
state_save_register_global(machine, state->ball1_pic);
state_save_register_global(machine, state->ball2_pic);
state_save_register_global(machine, state->crow_pic);
state_save_register_global(machine, state->crow_flip);
state_save_register_global(machine, state->palette_bank);
state_save_register_global(machine, state->controller);
state_save_register_global(machine, state->hit);
/* sound */
state_save_register_global(machine, state->sound_nmi_enable);
}
static MACHINE_START( bking3 )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
state->mcu = devtag_get_device(machine, "mcu");
MACHINE_START_CALL(bking);
/* misc */
state_save_register_global(machine, state->addr_h);
state_save_register_global(machine, state->addr_l);
/* mcu */
state_save_register_global(machine, state->from_main);
state_save_register_global(machine, state->from_mcu);
state_save_register_global(machine, state->mcu_sent);
state_save_register_global(machine, state->main_sent);
state_save_register_global(machine, state->port_a_in);
state_save_register_global(machine, state->port_a_out);
state_save_register_global(machine, state->ddr_a);
state_save_register_global(machine, state->port_b_in);
state_save_register_global(machine, state->port_b_out);
state_save_register_global(machine, state->ddr_b);
state_save_register_global(machine, state->port_c_in);
state_save_register_global(machine, state->port_c_out);
state_save_register_global(machine, state->ddr_c);
}
static MACHINE_RESET( bking )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
/* video */
state->pc3259_output[0] = 0;
state->pc3259_output[1] = 0;
state->pc3259_output[2] = 0;
state->pc3259_output[3] = 0;
state->pc3259_mask = 0;
state->xld1 = 0;
state->xld2 = 0;
state->xld3 = 0;
state->yld1 = 0;
state->yld2 = 0;
state->yld3 = 0;
state->ball1_pic = 0;
state->ball2_pic = 0;
state->crow_pic = 0;
state->crow_flip = 0;
state->palette_bank = 0;
state->controller = 0;
state->hit = 0;
/* sound */
state->sound_nmi_enable = 1;
}
static MACHINE_RESET( bking3 )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
MACHINE_RESET_CALL(bking);
/* misc */
state->addr_h = 0;
state->addr_l = 0;
/* mcu */
state->mcu_sent = 0;
state->main_sent = 0;
state->from_main = 0;
state->from_mcu = 0;
state->port_a_in = 0;
state->port_a_out = 0;
state->ddr_a = 0;
state->port_b_in = 0;
state->port_b_out = 0;
state->ddr_b = 0;
state->port_c_in = 0;
state->port_c_out = 0;
state->ddr_c = 0;
}
static MACHINE_DRIVER_START( bking ) static MACHINE_DRIVER_START( bking )
/* driver data */
MDRV_DRIVER_DATA(buggychl_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("main_cpu", Z80, XTAL_12MHz/4) /* 3 MHz */ MDRV_CPU_ADD("main_cpu", Z80, XTAL_12MHz/4) /* 3 MHz */
MDRV_CPU_PROGRAM_MAP(bking_map) MDRV_CPU_PROGRAM_MAP(bking_map)
@ -444,6 +537,9 @@ static MACHINE_DRIVER_START( bking )
/* - periodic IRQ, with frequency 6000000/(4*16*16*10*16) = 36.621 Hz, */ /* - periodic IRQ, with frequency 6000000/(4*16*16*10*16) = 36.621 Hz, */
MDRV_CPU_PERIODIC_INT(irq0_line_hold, (double)6000000/(4*16*16*10*16)) MDRV_CPU_PERIODIC_INT(irq0_line_hold, (double)6000000/(4*16*16*10*16))
MDRV_MACHINE_START(bking)
MDRV_MACHINE_RESET(bking)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -482,7 +578,8 @@ static MACHINE_DRIVER_START( bking3 )
MDRV_CPU_ADD("mcu", M68705, XTAL_3MHz) /* xtal is 3MHz, divided by 4 internally */ MDRV_CPU_ADD("mcu", M68705, XTAL_3MHz) /* xtal is 3MHz, divided by 4 internally */
MDRV_CPU_PROGRAM_MAP(m68705_map) MDRV_CPU_PROGRAM_MAP(m68705_map)
MDRV_MACHINE_RESET(buggychl) MDRV_MACHINE_START(bking3)
MDRV_MACHINE_RESET(bking3)
MDRV_QUANTUM_TIME(HZ(6000)) MDRV_QUANTUM_TIME(HZ(6000))
MACHINE_DRIVER_END MACHINE_DRIVER_END
@ -775,11 +872,7 @@ ROM_START( bking3 )
ROM_LOAD( "a24-21.25", 0x0000, 0x1000, CRC(3106fcac) SHA1(08454adfb58e5df84140d86ed52fa4ef684df9f1) ) /* extra rom on the same SUB PCB where is the mcu */ ROM_LOAD( "a24-21.25", 0x0000, 0x1000, CRC(3106fcac) SHA1(08454adfb58e5df84140d86ed52fa4ef684df9f1) ) /* extra rom on the same SUB PCB where is the mcu */
ROM_END ROM_END
static DRIVER_INIT( bking )
{
sndnmi_enable = 1;
}
GAME( 1982, bking, 0, bking, bking, bking, ROT270, "Taito Corporation", "Birdie King", 0 ) GAME( 1982, bking, 0, bking, bking, 0, ROT270, "Taito Corporation", "Birdie King", GAME_SUPPORTS_SAVE )
GAME( 1983, bking2, 0, bking, bking2, bking, ROT90, "Taito Corporation", "Birdie King 2", 0 ) GAME( 1983, bking2, 0, bking, bking2, 0, ROT90, "Taito Corporation", "Birdie King 2", GAME_SUPPORTS_SAVE )
GAME( 1984, bking3, 0, bking3, bking2, bking, ROT90, "Taito Corporation", "Birdie King 3", 0 ) GAME( 1984, bking3, 0, bking3, bking2, 0, ROT90, "Taito Corporation", "Birdie King 3", GAME_SUPPORTS_SAVE )

View File

@ -95,13 +95,14 @@ static WRITE8_HANDLER( bankswitch_w )
memory_set_bankptr(space->machine, 1,&memory_region(space->machine, "maincpu")[0x10000 + (data & 7) * 0x2000]); memory_set_bankptr(space->machine, 1,&memory_region(space->machine, "maincpu")[0x10000 + (data & 7) * 0x2000]);
} }
static int sound_nmi_enable,pending_nmi;
static TIMER_CALLBACK( nmi_callback ) static TIMER_CALLBACK( nmi_callback )
{ {
if (sound_nmi_enable) cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); buggychl_state *state = (buggychl_state *)machine->driver_data;
else pending_nmi = 1;
if (state->sound_nmi_enable)
cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
else
state->pending_nmi = 1;
} }
static WRITE8_HANDLER( sound_command_w ) static WRITE8_HANDLER( sound_command_w )
@ -112,16 +113,18 @@ static WRITE8_HANDLER( sound_command_w )
static WRITE8_HANDLER( nmi_disable_w ) static WRITE8_HANDLER( nmi_disable_w )
{ {
sound_nmi_enable = 0; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->sound_nmi_enable = 0;
} }
static WRITE8_HANDLER( nmi_enable_w ) static WRITE8_HANDLER( nmi_enable_w )
{ {
sound_nmi_enable = 1; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
if (pending_nmi) state->sound_nmi_enable = 1;
if (state->pending_nmi)
{ {
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
pending_nmi = 0; state->pending_nmi = 0;
} }
} }
@ -138,15 +141,15 @@ static ADDRESS_MAP_START( buggychl_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x8000, 0x87ff) AM_RAM /* 6116 SRAM (36) */ AM_RANGE(0x8000, 0x87ff) AM_RAM /* 6116 SRAM (36) */
AM_RANGE(0x8800, 0x8fff) AM_RAM /* 6116 SRAM (35) */ AM_RANGE(0x8800, 0x8fff) AM_RAM /* 6116 SRAM (35) */
AM_RANGE(0x9000, 0x9fff) AM_WRITE(buggychl_sprite_lookup_w) AM_RANGE(0x9000, 0x9fff) AM_WRITE(buggychl_sprite_lookup_w)
AM_RANGE(0xa000, 0xbfff) AM_ROMBANK(1) AM_WRITE(buggychl_chargen_w) AM_BASE(&buggychl_character_ram) AM_RANGE(0xa000, 0xbfff) AM_ROMBANK(1) AM_WRITE(buggychl_chargen_w) AM_BASE_MEMBER(buggychl_state, charram)
AM_RANGE(0xc800, 0xcfff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram) AM_RANGE(0xc800, 0xcfff) AM_RAM AM_BASE_SIZE_MEMBER(buggychl_state, videoram, videoram_size)
AM_RANGE(0xd100, 0xd100) AM_WRITE(buggychl_ctrl_w) AM_RANGE(0xd100, 0xd100) AM_WRITE(buggychl_ctrl_w)
AM_RANGE(0xd200, 0xd200) AM_WRITE(bankswitch_w) AM_RANGE(0xd200, 0xd200) AM_WRITE(bankswitch_w)
AM_RANGE(0xd300, 0xd300) AM_WRITE(watchdog_reset_w) AM_RANGE(0xd300, 0xd300) AM_WRITE(watchdog_reset_w)
AM_RANGE(0xd303, 0xd303) AM_WRITE(buggychl_sprite_lookup_bank_w) AM_RANGE(0xd303, 0xd303) AM_WRITE(buggychl_sprite_lookup_bank_w)
AM_RANGE(0xd400, 0xd400) AM_READWRITE(buggychl_mcu_r, buggychl_mcu_w) AM_RANGE(0xd400, 0xd400) AM_READWRITE(buggychl_mcu_r, buggychl_mcu_w)
AM_RANGE(0xd401, 0xd401) AM_READ(buggychl_mcu_status_r) AM_RANGE(0xd401, 0xd401) AM_READ(buggychl_mcu_status_r)
AM_RANGE(0xd500, 0xd57f) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0xd500, 0xd57f) AM_WRITEONLY AM_BASE_SIZE_MEMBER(buggychl_state, spriteram, spriteram_size)
AM_RANGE(0xd600, 0xd600) AM_READ_PORT("DSW1") AM_RANGE(0xd600, 0xd600) AM_READ_PORT("DSW1")
AM_RANGE(0xd601, 0xd601) AM_READ_PORT("DSW2") AM_RANGE(0xd601, 0xd601) AM_READ_PORT("DSW2")
AM_RANGE(0xd602, 0xd602) AM_READ_PORT("DSW3") AM_RANGE(0xd602, 0xd602) AM_READ_PORT("DSW3")
@ -158,8 +161,8 @@ static ADDRESS_MAP_START( buggychl_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xd610, 0xd610) AM_WRITE(sound_command_w) AM_RANGE(0xd610, 0xd610) AM_WRITE(sound_command_w)
AM_RANGE(0xd618, 0xd618) AM_WRITENOP /* accelerator clear */ AM_RANGE(0xd618, 0xd618) AM_WRITENOP /* accelerator clear */
AM_RANGE(0xd700, 0xd7ff) AM_WRITE(paletteram_xxxxRRRRGGGGBBBB_be_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xd700, 0xd7ff) AM_WRITE(paletteram_xxxxRRRRGGGGBBBB_be_w) AM_BASE_GENERIC(paletteram)
AM_RANGE(0xd840, 0xd85f) AM_WRITEONLY AM_BASE(&buggychl_scrollv) AM_RANGE(0xd840, 0xd85f) AM_WRITEONLY AM_BASE_MEMBER(buggychl_state, scrollv)
AM_RANGE(0xdb00, 0xdbff) AM_WRITEONLY AM_BASE(&buggychl_scrollh) AM_RANGE(0xdb00, 0xdbff) AM_WRITEONLY AM_BASE_MEMBER(buggychl_state, scrollh)
AM_RANGE(0xdc04, 0xdc04) AM_WRITEONLY /* should be fg scroll */ AM_RANGE(0xdc04, 0xdc04) AM_WRITEONLY /* should be fg scroll */
AM_RANGE(0xdc06, 0xdc06) AM_WRITE(buggychl_bg_scrollx_w) AM_RANGE(0xdc06, 0xdc06) AM_WRITE(buggychl_bg_scrollx_w)
ADDRESS_MAP_END ADDRESS_MAP_END
@ -182,12 +185,12 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7ff) ADDRESS_MAP_GLOBAL_MASK(0x7ff)
AM_RANGE(0x0000, 0x0000) AM_READWRITE(buggychl_68705_portA_r, buggychl_68705_portA_w) AM_RANGE(0x0000, 0x0000) AM_READWRITE(buggychl_68705_port_a_r, buggychl_68705_port_a_w)
AM_RANGE(0x0001, 0x0001) AM_READWRITE(buggychl_68705_portB_r, buggychl_68705_portB_w) AM_RANGE(0x0001, 0x0001) AM_READWRITE(buggychl_68705_port_b_r, buggychl_68705_port_b_w)
AM_RANGE(0x0002, 0x0002) AM_READWRITE(buggychl_68705_portC_r, buggychl_68705_portC_w) AM_RANGE(0x0002, 0x0002) AM_READWRITE(buggychl_68705_port_c_r, buggychl_68705_port_c_w)
AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddrA_w) AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddr_a_w)
AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddrB_w) AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddr_b_w)
AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddrC_w) AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddr_c_w)
AM_RANGE(0x0010, 0x007f) AM_RAM AM_RANGE(0x0010, 0x007f) AM_RAM
AM_RANGE(0x0080, 0x07ff) AM_ROM AM_RANGE(0x0080, 0x07ff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -327,19 +330,19 @@ GFXDECODE_END
static WRITE8_DEVICE_HANDLER( portA_0_w ) static WRITE8_DEVICE_HANDLER( port_a_0_w )
{ {
/* VOL/BAL for the 7630 on this 8910 output */ /* VOL/BAL for the 7630 on this 8910 output */
} }
static WRITE8_DEVICE_HANDLER( portB_0_w ) static WRITE8_DEVICE_HANDLER( port_b_0_w )
{ {
/* TRBL/BASS for the 7630 on this 8910 output */ /* TRBL/BASS for the 7630 on this 8910 output */
} }
static WRITE8_DEVICE_HANDLER( portA_1_w ) static WRITE8_DEVICE_HANDLER( port_a_1_w )
{ {
/* VOL/BAL for the 7630 on this 8910 output */ /* VOL/BAL for the 7630 on this 8910 output */
} }
static WRITE8_DEVICE_HANDLER( portB_1_w ) static WRITE8_DEVICE_HANDLER( port_b_1_w )
{ {
/* TRBL/BASS for the 7630 on this 8910 output */ /* TRBL/BASS for the 7630 on this 8910 output */
} }
@ -351,8 +354,8 @@ static const ay8910_interface ay8910_interface_1 =
AY8910_DEFAULT_LOADS, AY8910_DEFAULT_LOADS,
DEVCB_NULL, DEVCB_NULL,
DEVCB_NULL, DEVCB_NULL,
DEVCB_HANDLER(portA_0_w), DEVCB_HANDLER(port_a_0_w),
DEVCB_HANDLER(portB_0_w) DEVCB_HANDLER(port_b_0_w)
}; };
static const ay8910_interface ay8910_interface_2 = static const ay8910_interface ay8910_interface_2 =
@ -361,8 +364,8 @@ static const ay8910_interface ay8910_interface_2 =
AY8910_DEFAULT_LOADS, AY8910_DEFAULT_LOADS,
DEVCB_NULL, DEVCB_NULL,
DEVCB_NULL, DEVCB_NULL,
DEVCB_HANDLER(portA_1_w), DEVCB_HANDLER(port_a_1_w),
DEVCB_HANDLER(portB_1_w) DEVCB_HANDLER(port_b_1_w)
}; };
static const msm5232_interface msm5232_config = static const msm5232_interface msm5232_config =
@ -371,8 +374,71 @@ static const msm5232_interface msm5232_config =
}; };
static MACHINE_START( buggychl )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
state->audiocpu = devtag_get_device(machine, "audiocpu");
state->mcu = devtag_get_device(machine, "mcu");
state_save_register_global(machine, state->sound_nmi_enable);
state_save_register_global(machine, state->pending_nmi);
state_save_register_global_array(machine, state->sprite_lookup);
state_save_register_global(machine, state->sl_bank);
state_save_register_global(machine, state->bg_on);
state_save_register_global(machine, state->sky_on);
state_save_register_global(machine, state->sprite_color_base);
state_save_register_global(machine, state->bg_scrollx);
/* mcu */
state_save_register_global(machine, state->from_main);
state_save_register_global(machine, state->from_mcu);
state_save_register_global(machine, state->mcu_sent);
state_save_register_global(machine, state->main_sent);
state_save_register_global(machine, state->port_a_in);
state_save_register_global(machine, state->port_a_out);
state_save_register_global(machine, state->ddr_a);
state_save_register_global(machine, state->port_b_in);
state_save_register_global(machine, state->port_b_out);
state_save_register_global(machine, state->ddr_b);
state_save_register_global(machine, state->port_c_in);
state_save_register_global(machine, state->port_c_out);
state_save_register_global(machine, state->ddr_c);
}
static MACHINE_RESET( buggychl )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
state->sound_nmi_enable = 0;
state->pending_nmi = 0;
state->sl_bank = 0;
state->bg_on = 0;
state->sky_on = 0;
state->sprite_color_base = 0;
state->bg_scrollx = 0;
/* mcu */
state->mcu_sent = 0;
state->main_sent = 0;
state->from_main = 0;
state->from_mcu = 0;
state->port_a_in = 0;
state->port_a_out = 0;
state->ddr_a = 0;
state->port_b_in = 0;
state->port_b_out = 0;
state->ddr_b = 0;
state->port_c_in = 0;
state->port_c_out = 0;
state->ddr_c = 0;
}
static MACHINE_DRIVER_START( buggychl ) static MACHINE_DRIVER_START( buggychl )
/* driver data */
MDRV_DRIVER_DATA(buggychl_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz??? */ MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz??? */
MDRV_CPU_PROGRAM_MAP(buggychl_map) MDRV_CPU_PROGRAM_MAP(buggychl_map)
@ -386,6 +452,9 @@ static MACHINE_DRIVER_START( buggychl )
MDRV_CPU_ADD("mcu", M68705,8000000/2) /* 4 MHz */ MDRV_CPU_ADD("mcu", M68705,8000000/2) /* 4 MHz */
MDRV_CPU_PROGRAM_MAP(mcu_map) MDRV_CPU_PROGRAM_MAP(mcu_map)
MDRV_MACHINE_START(buggychl)
MDRV_MACHINE_RESET(buggychl)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(60) MDRV_SCREEN_REFRESH_RATE(60)
@ -397,8 +466,6 @@ static MACHINE_DRIVER_START( buggychl )
MDRV_GFXDECODE(buggychl) MDRV_GFXDECODE(buggychl)
MDRV_PALETTE_LENGTH(128+128) MDRV_PALETTE_LENGTH(128+128)
MDRV_MACHINE_RESET(buggychl)
MDRV_PALETTE_INIT(buggychl) MDRV_PALETTE_INIT(buggychl)
MDRV_VIDEO_START(buggychl) MDRV_VIDEO_START(buggychl)
MDRV_VIDEO_UPDATE(buggychl) MDRV_VIDEO_UPDATE(buggychl)

View File

@ -20,56 +20,36 @@ TO DO:
- TA7630 volume table is hand tuned to match the sample, but still slighty off. - TA7630 volume table is hand tuned to match the sample, but still slighty off.
*/ */
//not used
//WRITE8_HANDLER( msisaac_textbank1_w );
//used
WRITE8_HANDLER( msisaac_fg_scrolly_w );
WRITE8_HANDLER( msisaac_fg_scrollx_w );
WRITE8_HANDLER( msisaac_bg_scrolly_w );
WRITE8_HANDLER( msisaac_bg_scrollx_w );
WRITE8_HANDLER( msisaac_bg2_scrolly_w );
WRITE8_HANDLER( msisaac_bg2_scrollx_w );
WRITE8_HANDLER( msisaac_bg2_textbank_w );
WRITE8_HANDLER( msisaac_bg_videoram_w );
WRITE8_HANDLER( msisaac_bg2_videoram_w );
WRITE8_HANDLER( msisaac_fg_videoram_w );
extern VIDEO_UPDATE( msisaac );
extern VIDEO_START( msisaac );
extern UINT8 *msisaac_videoram;
extern UINT8 *msisaac_videoram2;
static int sound_nmi_enable,pending_nmi;
static TIMER_CALLBACK( nmi_callback ) static TIMER_CALLBACK( nmi_callback )
{ {
if (sound_nmi_enable) cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); buggychl_state *state = (buggychl_state *)machine->driver_data;
else pending_nmi = 1; if (state->sound_nmi_enable)
cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
else
state->pending_nmi = 1;
} }
static WRITE8_HANDLER( sound_command_w ) static WRITE8_HANDLER( sound_command_w )
{ {
soundlatch_w(space,0,data); soundlatch_w(space, 0, data);
timer_call_after_resynch(space->machine, NULL, data,nmi_callback); timer_call_after_resynch(space->machine, NULL, data, nmi_callback);
} }
static WRITE8_HANDLER( nmi_disable_w ) static WRITE8_HANDLER( nmi_disable_w )
{ {
sound_nmi_enable = 0; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->sound_nmi_enable = 0;
} }
static WRITE8_HANDLER( nmi_enable_w ) static WRITE8_HANDLER( nmi_enable_w )
{ {
sound_nmi_enable = 1; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
if (pending_nmi) state->sound_nmi_enable = 1;
if (state->pending_nmi)
{ {
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
pending_nmi = 0; state->pending_nmi = 0;
} }
} }
@ -84,10 +64,11 @@ static WRITE8_HANDLER( msisaac_coin_counter_w )
coin_counter_w(space->machine, offset,data); coin_counter_w(space->machine, offset,data);
} }
#endif #endif
static WRITE8_HANDLER( ms_unknown_w ) static WRITE8_HANDLER( ms_unknown_w )
{ {
if (data!=0x08) if (data != 0x08)
popmessage("CPU #0 write to 0xf0a3 data=%2x",data); popmessage("CPU #0 write to 0xf0a3 data=%2x", data);
} }
@ -100,11 +81,6 @@ static WRITE8_HANDLER( ms_unknown_w )
/* Disabled because the mcu dump is currently unavailable. -AS */ /* Disabled because the mcu dump is currently unavailable. -AS */
//#define USE_MCU //#define USE_MCU
#ifndef USE_MCU
static UINT8 mcu_val = 0;
static UINT8 direction = 0;
#endif
static READ8_HANDLER( msisaac_mcu_r ) static READ8_HANDLER( msisaac_mcu_r )
{ {
@ -117,11 +93,12 @@ MCU simulation TODO:
\-Fix some graphics imperfections(*not* confirmed if they are caused by unhandled \-Fix some graphics imperfections(*not* confirmed if they are caused by unhandled
commands or imperfect video emulation). commands or imperfect video emulation).
*/ */
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
switch(mcu_val) switch (state->mcu_val)
{ {
/*Start-up check*/ /*Start-up check*/
case 0x5f: return (mcu_val+0x6b); case 0x5f: return (state->mcu_val + 0x6b);
/*These interferes with RAM operations(setting them to non-zero you * /*These interferes with RAM operations(setting them to non-zero you *
* will have unexpected results,such as infinite lives or score not * * will have unexpected results,such as infinite lives or score not *
* incremented properly).*/ * incremented properly).*/
@ -143,7 +120,7 @@ MCU simulation TODO:
//6-down //6-down
//7-leftdwn //7-leftdwn
UINT8 val= (input_port_read(space->machine, "IN1")>>2) & 0x0f; UINT8 val= (input_port_read(space->machine, "IN1") >> 2) & 0x0f;
/* bit0 = left /* bit0 = left
bit1 = right bit1 = right
bit2 = down bit2 = down
@ -161,10 +138,10 @@ MCU simulation TODO:
static const INT8 table[16] = { -1, 2, 6, -1, 0, 1, 7, 0, 4, 3, 5, 4, -1, 2, 6, -1 }; static const INT8 table[16] = { -1, 2, 6, -1, 0, 1, 7, 0, 4, 3, 5, 4, -1, 2, 6, -1 };
if (table[val] >= 0 ) if (table[val] >= 0)
direction = table[val]; state->direction = table[val];
return direction; return state->direction;
} }
/*This controls the arms when they return to the player. */ /*This controls the arms when they return to the player. */
@ -172,8 +149,8 @@ MCU simulation TODO:
return 0x45; return 0x45;
default: default:
logerror("CPU#0 read from MCU pc=%4x, mcu_val=%2x\n", cpu_get_pc(space->cpu), mcu_val ); logerror("CPU#0 read from MCU pc=%4x, mcu_val=%2x\n", cpu_get_pc(space->cpu), state->mcu_val);
return mcu_val; return state->mcu_val;
} }
#endif #endif
} }
@ -192,9 +169,10 @@ static WRITE8_HANDLER( msisaac_mcu_w )
#ifdef USE_MCU #ifdef USE_MCU
buggychl_mcu_w(offset,data); buggychl_mcu_w(offset,data);
#else #else
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
//if(data != 0x0a && data != 0x42 && data != 0x02) //if(data != 0x0a && data != 0x42 && data != 0x02)
// popmessage("PC = %04x %02x",cpu_get_pc(space->cpu),data); // popmessage("PC = %04x %02x", cpu_get_pc(space->cpu), data);
mcu_val = data; state->mcu_val = data;
#endif #endif
} }
@ -218,7 +196,7 @@ static ADDRESS_MAP_START( msisaac_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xf0c4, 0xf0c4) AM_WRITE(msisaac_bg_scrollx_w) AM_RANGE(0xf0c4, 0xf0c4) AM_WRITE(msisaac_bg_scrollx_w)
AM_RANGE(0xf0c5, 0xf0c5) AM_WRITE(msisaac_bg_scrolly_w) AM_RANGE(0xf0c5, 0xf0c5) AM_WRITE(msisaac_bg_scrolly_w)
AM_RANGE(0xf0e0, 0xf0e0) AM_READWRITE(msisaac_mcu_r,msisaac_mcu_w) AM_RANGE(0xf0e0, 0xf0e0) AM_READWRITE(msisaac_mcu_r, msisaac_mcu_w)
AM_RANGE(0xf0e1, 0xf0e1) AM_READ(msisaac_mcu_status_r) AM_RANGE(0xf0e1, 0xf0e1) AM_READ(msisaac_mcu_status_r)
AM_RANGE(0xf080, 0xf080) AM_READ_PORT("DSW1") AM_RANGE(0xf080, 0xf080) AM_READ_PORT("DSW1")
@ -228,19 +206,18 @@ static ADDRESS_MAP_START( msisaac_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0xf084, 0xf084) AM_READ_PORT("IN1") AM_RANGE(0xf084, 0xf084) AM_READ_PORT("IN1")
// AM_RANGE(0xf086, 0xf086) AM_READ_PORT("IN2") // AM_RANGE(0xf086, 0xf086) AM_READ_PORT("IN2")
AM_RANGE(0xf100, 0xf17f) AM_RAM AM_BASE_GENERIC(spriteram) //sprites AM_RANGE(0xf100, 0xf17f) AM_RAM AM_BASE_MEMBER(buggychl_state, spriteram) //sprites
AM_RANGE(0xf400, 0xf7ff) AM_RAM_WRITE(msisaac_fg_videoram_w) AM_BASE_GENERIC(videoram) AM_RANGE(0xf400, 0xf7ff) AM_RAM_WRITE(msisaac_fg_videoram_w) AM_BASE_MEMBER(buggychl_state, videoram)
AM_RANGE(0xf800, 0xfbff) AM_RAM_WRITE(msisaac_bg2_videoram_w) AM_BASE(&msisaac_videoram2) AM_RANGE(0xf800, 0xfbff) AM_RAM_WRITE(msisaac_bg2_videoram_w) AM_BASE_MEMBER(buggychl_state, videoram3)
AM_RANGE(0xfc00, 0xffff) AM_RAM_WRITE(msisaac_bg_videoram_w) AM_BASE(&msisaac_videoram) AM_RANGE(0xfc00, 0xffff) AM_RAM_WRITE(msisaac_bg_videoram_w) AM_BASE_MEMBER(buggychl_state, videoram2)
// AM_RANGE(0xf801, 0xf801) AM_WRITE(msisaac_bgcolor_w) // AM_RANGE(0xf801, 0xf801) AM_WRITE(msisaac_bgcolor_w)
// AM_RANGE(0xfc00, 0xfc00) AM_WRITE(flip_screen_w) // AM_RANGE(0xfc00, 0xfc00) AM_WRITE(flip_screen_w)
// AM_RANGE(0xfc03, 0xfc04) AM_WRITE(msisaac_coin_counter_w) // AM_RANGE(0xfc03, 0xfc04) AM_WRITE(msisaac_coin_counter_w)
ADDRESS_MAP_END ADDRESS_MAP_END
static int vol_ctrl[16];
static MACHINE_RESET( ta7630 ) static MACHINE_RESET( ta7630 )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
int i; int i;
double db = 0.0; double db = 0.0;
@ -249,8 +226,8 @@ static MACHINE_RESET( ta7630 )
for (i=0; i<16; i++) for (i=0; i<16; i++)
{ {
double max = 100.0 / pow(10.0, db/20.0 ); double max = 100.0 / pow(10.0, db/20.0 );
vol_ctrl[ 15-i ] = max; state->vol_ctrl[15 - i] = max;
/*logerror("vol_ctrl[%x] = %i (%f dB)\n",15-i,vol_ctrl[ 15-i ],db);*/ /*logerror("vol_ctrl[%x] = %i (%f dB)\n",15 - i, state->vol_ctrl[15 - i], db);*/
db += db_step; db += db_step;
db_step += db_step_inc; db_step += db_step_inc;
} }
@ -264,27 +241,26 @@ static MACHINE_RESET( ta7630 )
*/ */
} }
static UINT8 snd_ctrl0=0;
static UINT8 snd_ctrl1=0;
static WRITE8_DEVICE_HANDLER( sound_control_0_w ) static WRITE8_DEVICE_HANDLER( sound_control_0_w )
{ {
snd_ctrl0 = data & 0xff; buggychl_state *state = (buggychl_state *)device->machine->driver_data;
//popmessage("SND0 0=%2x 1=%2x", snd_ctrl0, snd_ctrl1); state->snd_ctrl0 = data & 0xff;
//popmessage("SND0 0=%2x 1=%2x", state->snd_ctrl0, state->snd_ctrl1);
sound_set_output_gain(device, 0, vol_ctrl[ snd_ctrl0 & 15 ] / 100.0); /* group1 from msm5232 */ sound_set_output_gain(device, 0, state->vol_ctrl[state->snd_ctrl0 & 15] / 100.0); /* group1 from msm5232 */
sound_set_output_gain(device, 1, vol_ctrl[ snd_ctrl0 & 15 ] / 100.0); /* group1 from msm5232 */ sound_set_output_gain(device, 1, state->vol_ctrl[state->snd_ctrl0 & 15] / 100.0); /* group1 from msm5232 */
sound_set_output_gain(device, 2, vol_ctrl[ snd_ctrl0 & 15 ] / 100.0); /* group1 from msm5232 */ sound_set_output_gain(device, 2, state->vol_ctrl[state->snd_ctrl0 & 15] / 100.0); /* group1 from msm5232 */
sound_set_output_gain(device, 3, vol_ctrl[ snd_ctrl0 & 15 ] / 100.0); /* group1 from msm5232 */ sound_set_output_gain(device, 3, state->vol_ctrl[state->snd_ctrl0 & 15] / 100.0); /* group1 from msm5232 */
sound_set_output_gain(device, 4, vol_ctrl[ (snd_ctrl0>>4) & 15 ] / 100.0); /* group2 from msm5232 */ sound_set_output_gain(device, 4, state->vol_ctrl[(state->snd_ctrl0 >> 4) & 15] / 100.0); /* group2 from msm5232 */
sound_set_output_gain(device, 5, vol_ctrl[ (snd_ctrl0>>4) & 15 ] / 100.0); /* group2 from msm5232 */ sound_set_output_gain(device, 5, state->vol_ctrl[(state->snd_ctrl0 >> 4) & 15] / 100.0); /* group2 from msm5232 */
sound_set_output_gain(device, 6, vol_ctrl[ (snd_ctrl0>>4) & 15 ] / 100.0); /* group2 from msm5232 */ sound_set_output_gain(device, 6, state->vol_ctrl[(state->snd_ctrl0 >> 4) & 15] / 100.0); /* group2 from msm5232 */
sound_set_output_gain(device, 7, vol_ctrl[ (snd_ctrl0>>4) & 15 ] / 100.0); /* group2 from msm5232 */ sound_set_output_gain(device, 7, state->vol_ctrl[(state->snd_ctrl0 >> 4) & 15] / 100.0); /* group2 from msm5232 */
} }
static WRITE8_HANDLER( sound_control_1_w ) static WRITE8_HANDLER( sound_control_1_w )
{ {
snd_ctrl1 = data & 0xff; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
//popmessage("SND1 0=%2x 1=%2x", snd_ctrl0, snd_ctrl1); state->snd_ctrl1 = data & 0xff;
//popmessage("SND1 0=%2x 1=%2x", state->snd_ctrl0, state->snd_ctrl1);
} }
static ADDRESS_MAP_START( msisaac_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( msisaac_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
@ -306,12 +282,12 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( msisaac_mcu_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( msisaac_mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_GLOBAL_MASK(0x7ff) ADDRESS_MAP_GLOBAL_MASK(0x7ff)
AM_RANGE(0x0000, 0x0000) AM_READ(buggychl_68705_portA_r,buggychl_68705_portA_w) AM_RANGE(0x0000, 0x0000) AM_READ(buggychl_68705_port_a_r,buggychl_68705_port_a_w)
AM_RANGE(0x0001, 0x0001) AM_READ(buggychl_68705_portB_r,buggychl_68705_portB_w) AM_RANGE(0x0001, 0x0001) AM_READ(buggychl_68705_port_b_r,buggychl_68705_port_b_w)
AM_RANGE(0x0002, 0x0002) AM_READ(buggychl_68705_portC_r,buggychl_68705_portC_w) AM_RANGE(0x0002, 0x0002) AM_READ(buggychl_68705_port_c_r,buggychl_68705_port_c_w)
AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddrA_w) AM_RANGE(0x0004, 0x0004) AM_WRITE(buggychl_68705_ddr_a_w)
AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddrB_w) AM_RANGE(0x0005, 0x0005) AM_WRITE(buggychl_68705_ddr_b_w)
AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddrC_w) AM_RANGE(0x0006, 0x0006) AM_WRITE(buggychl_68705_ddr_c_w)
AM_RANGE(0x0010, 0x007f) AM_RAM AM_RANGE(0x0010, 0x007f) AM_RAM
AM_RANGE(0x0080, 0x07ff) AM_ROM AM_RANGE(0x0080, 0x07ff) AM_ROM
ADDRESS_MAP_END ADDRESS_MAP_END
@ -475,8 +451,86 @@ static const msm5232_interface msm5232_config =
/*******************************************************************************/ /*******************************************************************************/
static MACHINE_START( msisaac )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
state->audiocpu = devtag_get_device(machine, "audiocpu");
/* video */
state_save_register_global(machine, state->bg2_textbank);
/* sound */
state_save_register_global(machine, state->sound_nmi_enable);
state_save_register_global(machine, state->pending_nmi);
state_save_register_global_array(machine, state->vol_ctrl);
state_save_register_global(machine, state->snd_ctrl0);
state_save_register_global(machine, state->snd_ctrl1);
#ifdef USE_MCU
state->mcu = devtag_get_device(machine, "mcu");
/* mcu */
state_save_register_global(machine, state->from_main);
state_save_register_global(machine, state->from_mcu);
state_save_register_global(machine, state->mcu_sent);
state_save_register_global(machine, state->main_sent);
state_save_register_global(machine, state->port_a_in);
state_save_register_global(machine, state->port_a_out);
state_save_register_global(machine, state->ddr_a);
state_save_register_global(machine, state->port_b_in);
state_save_register_global(machine, state->port_b_out);
state_save_register_global(machine, state->ddr_b);
state_save_register_global(machine, state->port_c_in);
state_save_register_global(machine, state->port_c_out);
state_save_register_global(machine, state->ddr_c);
#else
state_save_register_global(machine, state->mcu_val);
state_save_register_global(machine, state->direction);
#endif
}
static MACHINE_RESET( msisaac )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
MACHINE_RESET_CALL(ta7630);
/* video */
state->bg2_textbank = 0;
/* sound */
state->sound_nmi_enable = 0;
state->pending_nmi = 0;
state->snd_ctrl0 = 0;
state->snd_ctrl1 = 0;
#ifdef USE_MCU
cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
/* mcu */
state->mcu_sent = 0;
state->main_sent = 0;
state->from_main = 0;
state->from_mcu = 0;
state->port_a_in = 0;
state->port_a_out = 0;
state->ddr_a = 0;
state->port_b_in = 0;
state->port_b_out = 0;
state->ddr_b = 0;
state->port_c_in = 0;
state->port_c_out = 0;
state->ddr_c = 0;
#else
state->mcu_val = 0;
state->direction = 0;
#endif
}
static MACHINE_DRIVER_START( msisaac ) static MACHINE_DRIVER_START( msisaac )
/* driver data */
MDRV_DRIVER_DATA(buggychl_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", Z80, 4000000) MDRV_CPU_ADD("maincpu", Z80, 4000000)
MDRV_CPU_PROGRAM_MAP(msisaac_map) MDRV_CPU_PROGRAM_MAP(msisaac_map)
@ -491,7 +545,8 @@ static MACHINE_DRIVER_START( msisaac )
MDRV_CPU_PROGRAM_MAP(msisaac_mcu_map) MDRV_CPU_PROGRAM_MAP(msisaac_mcu_map)
#endif #endif
MDRV_MACHINE_RESET(ta7630) MDRV_MACHINE_START(msisaac)
MDRV_MACHINE_RESET(msisaac)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
@ -567,4 +622,5 @@ ROM_START( msisaac )
ROM_END ROM_END
GAME( 1985, msisaac, 0, msisaac, msisaac, 0, ROT270, "Taito Corporation", "Metal Soldier Isaac II", GAME_UNEMULATED_PROTECTION | GAME_NO_COCKTAIL)
GAME( 1985, msisaac, 0, msisaac, msisaac, 0, ROT270, "Taito Corporation", "Metal Soldier Isaac II", GAME_UNEMULATED_PROTECTION | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )

View File

@ -1,15 +1,105 @@
/*
buggychl mcu emulation is also used by
40love.c, bking.c and msisaac.c
*/
typedef struct _buggychl_state buggychl_state;
struct _buggychl_state
{
/* memory pointers */
UINT8 * videoram; // buggychl, 40love, msisaac
UINT8 * videoram2; // msisaac
UINT8 * videoram3; // msisaac
UINT8 * colorram; // 40love
UINT8 * spriteram; // buggychl, 40love, msisaac
UINT8 * spriteram2; // 40love
UINT8 * scrollv; // buggychl
UINT8 * scrollh; // buggychl
UINT8 * charram; // buggychl
UINT8 * video_ctrl; // 40love
// UINT8 * paletteram; // currently this uses generic palette handling (buggychl & msisaac)
UINT8 * mcu_ram; // 40love (undokai)
UINT8 * playfield_ram; // bking
size_t videoram_size;
size_t spriteram_size;
size_t spriteram2_size;
/* video-related */
bitmap_t *tmp_bitmap1, *tmp_bitmap2;
tilemap *bg_tilemap;
tilemap *fg_tilemap, *bg2_tilemap; // msisaac
// buggychl
int sl_bank, bg_on, sky_on, sprite_color_base, bg_scrollx;
UINT8 sprite_lookup[0x2000];
// 40love
UINT8 flipscreen, pix_redraw;
UINT8 xoffset;
UINT8 *pixram1;
UINT8 *pixram2;
bitmap_t *pixel_bitmap1;
bitmap_t *pixel_bitmap2;
tilemap *background;
int pixram_sel;
// bking
int pc3259_output[4];
int pc3259_mask;
UINT8 xld1, xld2, xld3;
UINT8 yld1, yld2, yld3;
int ball1_pic, ball2_pic;
int crow_pic, crow_flip;
int palette_bank, controller, hit;
// msisaac
int bg2_textbank;
/* sound-related */
int sound_nmi_enable, pending_nmi;
/* mcu */
UINT8 port_a_in, port_a_out, ddr_a;
UINT8 port_b_in, port_b_out, ddr_b;
UINT8 port_c_in, port_c_out, ddr_c;
UINT8 from_main, from_mcu;
int mcu_sent, main_sent;
/* fake mcu (in 40love.c) - it also uses from_mcu */
UINT8 mcu_in[2][16], mcu_out[2][16];
int mcu_cmd;
/* fake mcu (in msisaac.c) */
#ifndef USE_MCU
UINT8 mcu_val;
UINT8 direction;
#endif
/* misc */
// 40love
int pix_color[4];
UINT8 pix1, pix2[2];
UINT8 snd_data, snd_flag;
int vol_ctrl[16];
UINT8 snd_ctrl0, snd_ctrl1, snd_ctrl2, snd_ctrl3;
// bking
int addr_h, addr_l;
/* devices */
const device_config *audiocpu;
const device_config *mcu;
};
/*----------- defined in machine/buggychl.c -----------*/ /*----------- defined in machine/buggychl.c -----------*/
MACHINE_RESET( buggychl ); READ8_HANDLER( buggychl_68705_port_a_r );
READ8_HANDLER( buggychl_68705_portA_r ); WRITE8_HANDLER( buggychl_68705_port_a_w );
WRITE8_HANDLER( buggychl_68705_portA_w ); WRITE8_HANDLER( buggychl_68705_ddr_a_w );
WRITE8_HANDLER( buggychl_68705_ddrA_w ); READ8_HANDLER( buggychl_68705_port_b_r );
READ8_HANDLER( buggychl_68705_portB_r ); WRITE8_HANDLER( buggychl_68705_port_b_w );
WRITE8_HANDLER( buggychl_68705_portB_w ); WRITE8_HANDLER( buggychl_68705_ddr_b_w );
WRITE8_HANDLER( buggychl_68705_ddrB_w ); READ8_HANDLER( buggychl_68705_port_c_r );
READ8_HANDLER( buggychl_68705_portC_r ); WRITE8_HANDLER( buggychl_68705_port_c_w );
WRITE8_HANDLER( buggychl_68705_portC_w ); WRITE8_HANDLER( buggychl_68705_ddr_c_w );
WRITE8_HANDLER( buggychl_68705_ddrC_w );
WRITE8_HANDLER( buggychl_mcu_w ); WRITE8_HANDLER( buggychl_mcu_w );
READ8_HANDLER( buggychl_mcu_r ); READ8_HANDLER( buggychl_mcu_r );
READ8_HANDLER( buggychl_mcu_status_r ); READ8_HANDLER( buggychl_mcu_status_r );
@ -17,14 +107,67 @@ READ8_HANDLER( buggychl_mcu_status_r );
/*----------- defined in video/buggychl.c -----------*/ /*----------- defined in video/buggychl.c -----------*/
extern UINT8 *buggychl_scrollv,*buggychl_scrollh;
extern UINT8 *buggychl_character_ram;
PALETTE_INIT( buggychl );
VIDEO_START( buggychl );
WRITE8_HANDLER( buggychl_chargen_w ); WRITE8_HANDLER( buggychl_chargen_w );
WRITE8_HANDLER( buggychl_sprite_lookup_bank_w ); WRITE8_HANDLER( buggychl_sprite_lookup_bank_w );
WRITE8_HANDLER( buggychl_sprite_lookup_w ); WRITE8_HANDLER( buggychl_sprite_lookup_w );
WRITE8_HANDLER( buggychl_ctrl_w ); WRITE8_HANDLER( buggychl_ctrl_w );
WRITE8_HANDLER( buggychl_bg_scrollx_w ); WRITE8_HANDLER( buggychl_bg_scrollx_w );
PALETTE_INIT( buggychl );
VIDEO_START( buggychl );
VIDEO_UPDATE( buggychl ); VIDEO_UPDATE( buggychl );
/*----------- defined in video/40love.c -----------*/
WRITE8_HANDLER( fortyl_bg_videoram_w );
WRITE8_HANDLER( fortyl_bg_colorram_w );
READ8_HANDLER ( fortyl_bg_videoram_r );
READ8_HANDLER ( fortyl_bg_colorram_r );
WRITE8_HANDLER( fortyl_pixram_sel_w );
READ8_HANDLER( fortyl_pixram_r );
WRITE8_HANDLER( fortyl_pixram_w );
VIDEO_START( fortyl );
VIDEO_UPDATE( fortyl );
PALETTE_INIT( fortyl );
/*----------- defined in video/bking.c -----------*/
WRITE8_HANDLER( bking_xld1_w );
WRITE8_HANDLER( bking_yld1_w );
WRITE8_HANDLER( bking_xld2_w );
WRITE8_HANDLER( bking_yld2_w );
WRITE8_HANDLER( bking_xld3_w );
WRITE8_HANDLER( bking_yld3_w );
WRITE8_HANDLER( bking_msk_w );
WRITE8_HANDLER( bking_cont1_w );
WRITE8_HANDLER( bking_cont2_w );
WRITE8_HANDLER( bking_cont3_w );
WRITE8_HANDLER( bking_hitclr_w );
WRITE8_HANDLER( bking_playfield_w );
READ8_HANDLER( bking_input_port_5_r );
READ8_HANDLER( bking_input_port_6_r );
READ8_HANDLER( bking_pos_r );
PALETTE_INIT( bking );
VIDEO_START( bking );
VIDEO_UPDATE( bking );
VIDEO_EOF( bking );
/*----------- defined in video/msisaac.c -----------*/
WRITE8_HANDLER( msisaac_fg_scrolly_w );
WRITE8_HANDLER( msisaac_fg_scrollx_w );
WRITE8_HANDLER( msisaac_bg_scrolly_w );
WRITE8_HANDLER( msisaac_bg_scrollx_w );
WRITE8_HANDLER( msisaac_bg2_scrolly_w );
WRITE8_HANDLER( msisaac_bg2_scrollx_w );
WRITE8_HANDLER( msisaac_bg2_textbank_w );
WRITE8_HANDLER( msisaac_bg_videoram_w );
WRITE8_HANDLER( msisaac_bg2_videoram_w );
WRITE8_HANDLER( msisaac_fg_videoram_w );
VIDEO_UPDATE( msisaac );
VIDEO_START( msisaac );

View File

@ -3,17 +3,6 @@
#include "includes/buggychl.h" #include "includes/buggychl.h"
static UINT8 from_main,from_mcu;
static int mcu_sent,main_sent;
MACHINE_RESET( buggychl )
{
mcu_sent = 0;
main_sent = 0;
cputag_set_input_line(machine, "mcu", 0, CLEAR_LINE);
}
/*************************************************************************** /***************************************************************************
Buggy CHallenge 68705 protection interface Buggy CHallenge 68705 protection interface
@ -22,23 +11,24 @@ MACHINE_RESET( buggychl )
***************************************************************************/ ***************************************************************************/
static UINT8 portA_in,portA_out,ddrA; READ8_HANDLER( buggychl_68705_port_a_r )
READ8_HANDLER( buggychl_68705_portA_r )
{ {
//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return (portA_out & ddrA) | (portA_in & ~ddrA); //logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(space->cpu), state->port_a_in);
return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
} }
WRITE8_HANDLER( buggychl_68705_portA_w ) WRITE8_HANDLER( buggychl_68705_port_a_w )
{ {
//logerror("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
portA_out = data; //logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(space->cpu), data);
state->port_a_out = data;
} }
WRITE8_HANDLER( buggychl_68705_ddrA_w ) WRITE8_HANDLER( buggychl_68705_ddr_a_w )
{ {
ddrA = data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->ddr_a = data;
} }
@ -61,37 +51,40 @@ WRITE8_HANDLER( buggychl_68705_ddrA_w )
* the main Z80 memory location to access] * the main Z80 memory location to access]
*/ */
static UINT8 portB_in,portB_out,ddrB;
READ8_HANDLER( buggychl_68705_portB_r ) READ8_HANDLER( buggychl_68705_port_b_r )
{ {
return (portB_out & ddrB) | (portB_in & ~ddrB); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
} }
WRITE8_HANDLER( buggychl_68705_portB_w ) WRITE8_HANDLER( buggychl_68705_port_b_w )
{ {
logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data);
if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02)) if ((state->ddr_b & 0x02) && (~data & 0x02) && (state->port_b_out & 0x02))
{ {
portA_in = from_main; state->port_a_in = state->from_main;
if (main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE); if (state->main_sent)
main_sent = 0; cpu_set_input_line(state->mcu, 0, CLEAR_LINE);
logerror("read command %02x from main cpu\n", portA_in); state->main_sent = 0;
logerror("read command %02x from main cpu\n", state->port_a_in);
} }
if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04)) if ((state->ddr_b & 0x04) && (data & 0x04) && (~state->port_b_out & 0x04))
{ {
logerror("send command %02x to main cpu\n", portA_out); logerror("send command %02x to main cpu\n", state->port_a_out);
from_mcu = portA_out; state->from_mcu = state->port_a_out;
mcu_sent = 1; state->mcu_sent = 1;
} }
portB_out = data; state->port_b_out = data;
} }
WRITE8_HANDLER( buggychl_68705_ddrB_w ) WRITE8_HANDLER( buggychl_68705_ddr_b_w )
{ {
ddrB = data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->ddr_b = data;
} }
@ -104,53 +97,61 @@ WRITE8_HANDLER( buggychl_68705_ddrB_w )
* 1 R 0 when pending command 68705->Z80 * 1 R 0 when pending command 68705->Z80
*/ */
static UINT8 portC_in,portC_out,ddrC; READ8_HANDLER( buggychl_68705_port_c_r )
READ8_HANDLER( buggychl_68705_portC_r )
{ {
portC_in = 0; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
if (main_sent) portC_in |= 0x01; state->port_c_in = 0;
if (!mcu_sent) portC_in |= 0x02; if (state->main_sent)
logerror("%04x: 68705 port C read %02x\n", cpu_get_pc(space->cpu), portC_in); state->port_c_in |= 0x01;
return (portC_out & ddrC) | (portC_in & ~ddrC); if (!state->mcu_sent)
state->port_c_in |= 0x02;
logerror("%04x: 68705 port C read %02x\n", cpu_get_pc(space->cpu), state->port_c_in);
return (state->port_c_out & state->ddr_c) | (state->port_c_in & ~state->ddr_c);
} }
WRITE8_HANDLER( buggychl_68705_portC_w ) WRITE8_HANDLER( buggychl_68705_port_c_w )
{ {
logerror("%04x: 68705 port C write %02x\n", cpu_get_pc(space->cpu), data); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
portC_out = data; logerror("%04x: 68705 port C write %02x\n", cpu_get_pc(space->cpu), data);
state->port_c_out = data;
} }
WRITE8_HANDLER( buggychl_68705_ddrC_w ) WRITE8_HANDLER( buggychl_68705_ddr_c_w )
{ {
ddrC = data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->ddr_c = data;
} }
WRITE8_HANDLER( buggychl_mcu_w ) WRITE8_HANDLER( buggychl_mcu_w )
{ {
logerror("%04x: mcu_w %02x\n", cpu_get_pc(space->cpu), data); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
from_main = data; logerror("%04x: mcu_w %02x\n", cpu_get_pc(space->cpu), data);
main_sent = 1; state->from_main = data;
cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE); state->main_sent = 1;
cpu_set_input_line(state->mcu, 0, ASSERT_LINE);
} }
READ8_HANDLER( buggychl_mcu_r ) READ8_HANDLER( buggychl_mcu_r )
{ {
logerror("%04x: mcu_r %02x\n", cpu_get_pc(space->cpu), from_mcu); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
mcu_sent = 0; logerror("%04x: mcu_r %02x\n", cpu_get_pc(space->cpu), state->from_mcu);
return from_mcu; state->mcu_sent = 0;
return state->from_mcu;
} }
READ8_HANDLER( buggychl_mcu_status_r ) READ8_HANDLER( buggychl_mcu_status_r )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
int res = 0; int res = 0;
/* bit 0 = when 1, mcu is ready to receive data from main cpu */ /* bit 0 = when 1, mcu is ready to receive data from main cpu */
/* bit 1 = when 1, mcu has sent data to the main cpu */ /* bit 1 = when 1, mcu has sent data to the main cpu */
//logerror("%04x: mcu_status_r\n",cpu_get_pc(space->cpu)); //logerror("%04x: mcu_status_r\n",cpu_get_pc(space->cpu));
if (!main_sent) res |= 0x01; if (!state->main_sent)
if (mcu_sent) res |= 0x02; res |= 0x01;
if (state->mcu_sent)
res |= 0x02;
return res; return res;
} }

View File

@ -3,27 +3,8 @@
*/ */
#include "driver.h" #include "driver.h"
#include "includes/buggychl.h"
/*
* variables
*/
UINT8 *fortyl_video_ctrl;
static UINT8 fortyl_flipscreen,fortyl_pix_redraw;
static const UINT8 fortyl_xoffset = 128;
static UINT8 *fortyl_pixram1;
static UINT8 *fortyl_pixram2;
static bitmap_t *pixel_bitmap1;
static bitmap_t *pixel_bitmap2;
static tilemap *background;
int fortyl_pix_color[4];
static int pixram_sel;
/* /*
* color prom decoding * color prom decoding
@ -33,9 +14,9 @@ PALETTE_INIT( fortyl )
{ {
int i; int i;
for (i = 0;i < machine->config->total_colors;i++) for (i = 0; i < machine->config->total_colors; i++)
{ {
int bit0,bit1,bit2,bit3,r,g,b; int bit0, bit1, bit2, bit3, r, g, b;
/* red component */ /* red component */
bit0 = (color_prom[0] >> 0) & 0x01; bit0 = (color_prom[0] >> 0) & 0x01;
@ -58,7 +39,7 @@ PALETTE_INIT( fortyl )
bit3 = (color_prom[2*machine->config->total_colors] >> 3) & 0x01; bit3 = (color_prom[2*machine->config->total_colors] >> 3) & 0x01;
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3; b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
palette_set_color(machine,i,MAKE_RGB(r,g,b)); palette_set_color(machine, i, MAKE_RGB(r,g,b));
color_prom++; color_prom++;
} }
@ -82,10 +63,11 @@ colorram format (2 bytes per one tilemap character line, 8 pixels height):
static TILE_GET_INFO( get_bg_tile_info ) static TILE_GET_INFO( get_bg_tile_info )
{ {
int tile_number = machine->generic.videoram.u8[tile_index]; buggychl_state *state = (buggychl_state *)machine->driver_data;
int tile_attrib = machine->generic.colorram.u8[(tile_index/64)*2]; int tile_number = state->videoram[tile_index];
int tile_h_bank = (tile_attrib&0x40)<<3; /* 0x40->0x200 */ int tile_attrib = state->colorram[(tile_index / 64) * 2];
int tile_l_bank = (tile_attrib&0x18)<<3; /* 0x10->0x80, 0x08->0x40 */ int tile_h_bank = (tile_attrib & 0x40) << 3; /* 0x40->0x200 */
int tile_l_bank = (tile_attrib & 0x18) << 3; /* 0x10->0x80, 0x08->0x40 */
int code = tile_number; int code = tile_number;
if ((tile_attrib & 0x20) && (code >= 0xc0)) if ((tile_attrib & 0x20) && (code >= 0xc0))
@ -106,8 +88,9 @@ static TILE_GET_INFO( get_bg_tile_info )
static STATE_POSTLOAD( redraw_pixels ) static STATE_POSTLOAD( redraw_pixels )
{ {
fortyl_pix_redraw = 1; buggychl_state *state = (buggychl_state *)machine->driver_data;
tilemap_mark_all_tiles_dirty(background); state->pix_redraw = 1;
tilemap_mark_all_tiles_dirty(state->bg_tilemap);
} }
@ -119,24 +102,27 @@ static STATE_POSTLOAD( redraw_pixels )
VIDEO_START( fortyl ) VIDEO_START( fortyl )
{ {
fortyl_pixram1 = auto_alloc_array_clear(machine, UINT8, 0x4000); buggychl_state *state = (buggychl_state *)machine->driver_data;
fortyl_pixram2 = auto_alloc_array_clear(machine, UINT8, 0x4000); state->pixram1 = auto_alloc_array_clear(machine, UINT8, 0x4000);
state->pixram2 = auto_alloc_array_clear(machine, UINT8, 0x4000);
pixel_bitmap1 = auto_bitmap_alloc(machine,256,256,video_screen_get_format(machine->primary_screen)); state->tmp_bitmap1 = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen));
pixel_bitmap2 = auto_bitmap_alloc(machine,256,256,video_screen_get_format(machine->primary_screen)); state->tmp_bitmap2 = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen));
background = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8,8,64,32); state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
tilemap_set_scroll_rows(background,32); state->xoffset = 128; // this never changes
tilemap_set_transparent_pen(background,0);
state_save_register_global(machine, fortyl_flipscreen); tilemap_set_scroll_rows(state->bg_tilemap, 32);
state_save_register_global_array(machine, fortyl_pix_color); tilemap_set_transparent_pen(state->bg_tilemap, 0);
state_save_register_global_pointer(machine, fortyl_pixram1, 0x4000);
state_save_register_global_pointer(machine, fortyl_pixram2, 0x4000); state_save_register_global(machine, state->flipscreen);
state_save_register_global_bitmap(machine, pixel_bitmap1); state_save_register_global_array(machine, state->pix_color);
state_save_register_global_bitmap(machine, pixel_bitmap2); state_save_register_global_pointer(machine, state->pixram1, 0x4000);
state_save_register_global(machine, pixram_sel); state_save_register_global_pointer(machine, state->pixram2, 0x4000);
state_save_register_global_bitmap(machine, state->tmp_bitmap1);
state_save_register_global_bitmap(machine, state->tmp_bitmap2);
state_save_register_global(machine, state->pixram_sel);
state_save_register_postload(machine, redraw_pixels, NULL); state_save_register_postload(machine, redraw_pixels, NULL);
} }
@ -147,114 +133,124 @@ VIDEO_START( fortyl )
***************************************************************************/ ***************************************************************************/
static void fortyl_set_scroll_x(running_machine *machine, int offset) static void fortyl_set_scroll_x( running_machine *machine, int offset )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
int i = offset & ~1; int i = offset & ~1;
int x = ((machine->generic.colorram.u8[i] & 0x80) << 1) | machine->generic.colorram.u8[i+1]; /* 9 bits signed */ int x = ((state->colorram[i] & 0x80) << 1) | state->colorram[i + 1]; /* 9 bits signed */
if (fortyl_flipscreen) if (state->flipscreen)
x += 0x51; x += 0x51;
else else
x -= 0x50; x -= 0x50;
x &= 0x1ff; x &= 0x1ff;
if (x&0x100) x -= 0x200; /* sign extend */ if (x & 0x100) x -= 0x200; /* sign extend */
tilemap_set_scrollx(background, offset/2, x); tilemap_set_scrollx(state->bg_tilemap, offset / 2, x);
} }
WRITE8_HANDLER( fortyl_pixram_sel_w ) WRITE8_HANDLER( fortyl_pixram_sel_w )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
int offs; int offs;
int f = data & 0x01; int f = data & 0x01;
pixram_sel = (data & 0x04) >> 2; state->pixram_sel = (data & 0x04) >> 2;
if (fortyl_flipscreen != f) if (state->flipscreen != f)
{ {
fortyl_flipscreen = f; state->flipscreen = f;
flip_screen_set(space->machine, fortyl_flipscreen); flip_screen_set(space->machine, state->flipscreen);
fortyl_pix_redraw = 1; state->pix_redraw = 1;
for (offs=0;offs<32;offs++) for (offs = 0; offs < 32; offs++)
fortyl_set_scroll_x(space->machine, offs*2); fortyl_set_scroll_x(space->machine, offs * 2);
} }
} }
READ8_HANDLER( fortyl_pixram_r ) READ8_HANDLER( fortyl_pixram_r )
{ {
if (pixram_sel) buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return fortyl_pixram2[offset]; if (state->pixram_sel)
return state->pixram2[offset];
else else
return fortyl_pixram1[offset]; return state->pixram1[offset];
} }
static void fortyl_plot_pix(int offset) static void fortyl_plot_pix( running_machine *machine, int offset )
{ {
int x,y,i,c,d1,d2; buggychl_state *state = (buggychl_state *)machine->driver_data;
int x, y, i, c, d1, d2;
x = (offset & 0x1f) * 8;
x = (offset & 0x1f)*8;
y = (offset >> 5) & 0xff; y = (offset >> 5) & 0xff;
if (pixram_sel) if (state->pixram_sel)
{ {
d1 = fortyl_pixram2[offset]; d1 = state->pixram2[offset];
d2 = fortyl_pixram2[offset + 0x2000]; d2 = state->pixram2[offset + 0x2000];
} }
else else
{ {
d1 = fortyl_pixram1[offset]; d1 = state->pixram1[offset];
d2 = fortyl_pixram1[offset + 0x2000]; d2 = state->pixram1[offset + 0x2000];
} }
for (i=0;i<8;i++) for (i = 0; i < 8; i++)
{ {
c = ((d2>>i)&1) + ((d1>>i)&1)*2; c = ((d2 >> i) & 1) + ((d1 >> i) & 1) * 2;
if (pixram_sel) if (state->pixram_sel)
*BITMAP_ADDR16(pixel_bitmap2, y, x+i) = fortyl_pix_color[c]; *BITMAP_ADDR16(state->tmp_bitmap2, y, x + i) = state->pix_color[c];
else else
*BITMAP_ADDR16(pixel_bitmap1, y, x+i) = fortyl_pix_color[c]; *BITMAP_ADDR16(state->tmp_bitmap1, y, x + i) = state->pix_color[c];
} }
} }
WRITE8_HANDLER( fortyl_pixram_w ) WRITE8_HANDLER( fortyl_pixram_w )
{ {
if (pixram_sel) buggychl_state *state = (buggychl_state *)space->machine->driver_data;
fortyl_pixram2[offset] = data; if (state->pixram_sel)
state->pixram2[offset] = data;
else else
fortyl_pixram1[offset] = data; state->pixram1[offset] = data;
fortyl_plot_pix(offset & 0x1fff); fortyl_plot_pix(space->machine, offset & 0x1fff);
} }
WRITE8_HANDLER( fortyl_bg_videoram_w ) WRITE8_HANDLER( fortyl_bg_videoram_w )
{ {
space->machine->generic.videoram.u8[offset]=data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(background,offset); state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
READ8_HANDLER( fortyl_bg_videoram_r ) READ8_HANDLER( fortyl_bg_videoram_r )
{ {
return space->machine->generic.videoram.u8[offset]; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return state->videoram[offset];
} }
WRITE8_HANDLER( fortyl_bg_colorram_w ) WRITE8_HANDLER( fortyl_bg_colorram_w )
{ {
if( space->machine->generic.colorram.u8[offset]!=data ) buggychl_state *state = (buggychl_state *)space->machine->driver_data;
if (state->colorram[offset] != data)
{ {
int i; int i;
space->machine->generic.colorram.u8[offset] = data; state->colorram[offset] = data;
for (i=(offset/2)*64; i<(offset/2)*64+64; i++) for (i = (offset / 2) * 64; i < (offset / 2) * 64 + 64; i++)
tilemap_mark_tile_dirty(background,i); tilemap_mark_tile_dirty(state->bg_tilemap, i);
fortyl_set_scroll_x(space->machine, offset); fortyl_set_scroll_x(space->machine, offset);
} }
} }
READ8_HANDLER( fortyl_bg_colorram_r ) READ8_HANDLER( fortyl_bg_colorram_r )
{ {
return space->machine->generic.colorram.u8[offset]; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return state->colorram[offset];
} }
/*************************************************************************** /***************************************************************************
@ -278,95 +274,98 @@ spriteram format (4 bytes per sprite):
offset 3 xxxxxxxx x position offset 3 xxxxxxxx x position
*/ */
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 )
{ {
UINT8 *spriteram = machine->generic.spriteram.u8; buggychl_state *state = (buggychl_state *)machine->driver_data;
UINT8 *spriteram_2 = machine->generic.spriteram2.u8; UINT8 *spriteram = state->spriteram;
UINT8 *spriteram_2 = state->spriteram2;
int offs; int offs;
/* spriteram #1 */ /* spriteram #1 */
for (offs = 0; offs < machine->generic.spriteram_size; offs += 4) for (offs = 0; offs < state->spriteram_size; offs += 4)
{ {
int code,color,sx,sy,flipx,flipy; int code, color, sx, sy, flipx, flipy;
sx = spriteram[offs+3]; sx = spriteram[offs + 3];
sy = spriteram[offs+0] +1; sy = spriteram[offs + 0] +1;
if (fortyl_flipscreen) if (state->flipscreen)
sx = 240 - sx; sx = 240 - sx;
else else
sy = 242 - sy; sy = 242 - sy;
code = (spriteram[offs+1] & 0x3f) + ((spriteram[offs+2] & 0x18) << 3); code = (spriteram[offs + 1] & 0x3f) + ((spriteram[offs + 2] & 0x18) << 3);
flipx = ((spriteram[offs+1] & 0x40) >> 6) ^ fortyl_flipscreen; flipx = ((spriteram[offs + 1] & 0x40) >> 6) ^ state->flipscreen;
flipy = ((spriteram[offs+1] & 0x80) >> 7) ^ fortyl_flipscreen; flipy = ((spriteram[offs + 1] & 0x80) >> 7) ^ state->flipscreen;
color = (spriteram[offs+2] & 0x07) + 0x08; color = (spriteram[offs + 2] & 0x07) + 0x08;
if (spriteram[offs+2] & 0xe0) if (spriteram[offs + 2] & 0xe0)
color = mame_rand(machine)&0xf; color = mame_rand(machine) & 0xf;
drawgfx_transpen(bitmap,cliprect,machine->gfx[1], drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
code, code,
color, color,
flipx,flipy, flipx,flipy,
sx+fortyl_xoffset,sy,0); sx+state->xoffset,sy,0);
} }
/* spriteram #2 */ /* spriteram #2 */
for (offs = 0; offs < machine->generic.spriteram2_size; offs += 4) for (offs = 0; offs < state->spriteram2_size; offs += 4)
{ {
int code,color,sx,sy,flipx,flipy; int code, color, sx, sy, flipx, flipy;
sx = spriteram_2[offs+3]; sx = spriteram_2[offs + 3];
sy = spriteram_2[offs+0] +1; sy = spriteram_2[offs + 0] +1;
if (fortyl_flipscreen) if (state->flipscreen)
sx = 240 - sx; sx = 240 - sx;
else else
sy = 242 - sy; sy = 242 - sy;
code = (spriteram_2[offs+1] & 0x3f) + ((spriteram_2[offs+2] & 0x18) << 3); code = (spriteram_2[offs + 1] & 0x3f) + ((spriteram_2[offs + 2] & 0x18) << 3);
flipx = ((spriteram_2[offs+1] & 0x40) >> 6) ^ fortyl_flipscreen; flipx = ((spriteram_2[offs + 1] & 0x40) >> 6) ^ state->flipscreen;
flipy = ((spriteram_2[offs+1] & 0x80) >> 7) ^ fortyl_flipscreen; flipy = ((spriteram_2[offs + 1] & 0x80) >> 7) ^ state->flipscreen;
color = (spriteram_2[offs+2] & 0x07) + 0x08; color = (spriteram_2[offs + 2] & 0x07) + 0x08;
if (spriteram_2[offs+2] & 0xe0) if (spriteram_2[offs + 2] & 0xe0)
color = mame_rand(machine)&0xf; color = mame_rand(machine) & 0xf;
drawgfx_transpen(bitmap,cliprect,machine->gfx[1], drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
code, code,
color, color,
flipx,flipy, flipx,flipy,
sx+fortyl_xoffset,sy,0); sx+state->xoffset,sy,0);
} }
} }
static void draw_pixram( bitmap_t *bitmap, const rectangle *cliprect ) static void draw_pixram( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
int offs; int offs;
int f = fortyl_flipscreen ^ 1; int f = state->flipscreen ^ 1;
if (fortyl_pix_redraw) if (state->pix_redraw)
{ {
fortyl_pix_redraw = 0; state->pix_redraw = 0;
for (offs=0; offs<0x2000; offs++) for (offs = 0; offs < 0x2000; offs++)
fortyl_plot_pix(offs); fortyl_plot_pix(machine, offs);
} }
if (pixram_sel) if (state->pixram_sel)
copybitmap(bitmap,pixel_bitmap1,f,f,fortyl_xoffset,0,cliprect); copybitmap(bitmap, state->tmp_bitmap1, f, f, state->xoffset, 0, cliprect);
else else
copybitmap(bitmap,pixel_bitmap2,f,f,fortyl_xoffset,0,cliprect); copybitmap(bitmap, state->tmp_bitmap2, f, f, state->xoffset, 0, cliprect);
} }
VIDEO_UPDATE( fortyl ) VIDEO_UPDATE( fortyl )
{ {
draw_pixram(bitmap,cliprect); buggychl_state *state = (buggychl_state *)screen->machine->driver_data;
draw_pixram(screen->machine, bitmap, cliprect);
tilemap_set_scrolldy(background,-fortyl_video_ctrl[1]+1,-fortyl_video_ctrl[1]-1 ); tilemap_set_scrolldy(state->bg_tilemap, - state->video_ctrl[1] + 1, - state->video_ctrl[1] - 1 );
tilemap_draw(bitmap,cliprect,background,0,0); 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;
} }

View File

@ -8,33 +8,7 @@
#include "driver.h" #include "driver.h"
#include "video/resnet.h" #include "video/resnet.h"
#include "includes/buggychl.h"
extern UINT8* bking_playfield_ram;
static int pc3259_output[4];
static int pc3259_mask;
static UINT8 xld1;
static UINT8 xld2;
static UINT8 xld3;
static UINT8 yld1;
static UINT8 yld2;
static UINT8 yld3;
static int ball1_pic;
static int ball2_pic;
static int crow_pic;
static int crow_flip;
static int palette_bank;
static int controller;
static int hit;
static bitmap_t *helper0;
static bitmap_t *helper1;
static tilemap *bg_tilemap;
/*************************************************************************** /***************************************************************************
@ -110,37 +84,45 @@ PALETTE_INIT( bking )
WRITE8_HANDLER( bking_xld1_w ) WRITE8_HANDLER( bking_xld1_w )
{ {
xld1 = -data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->xld1 = -data;
} }
WRITE8_HANDLER( bking_yld1_w ) WRITE8_HANDLER( bking_yld1_w )
{ {
yld1 = -data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->yld1 = -data;
} }
WRITE8_HANDLER( bking_xld2_w ) WRITE8_HANDLER( bking_xld2_w )
{ {
xld2 = -data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->xld2 = -data;
} }
WRITE8_HANDLER( bking_yld2_w ) WRITE8_HANDLER( bking_yld2_w )
{ {
yld2 = -data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->yld2 = -data;
} }
WRITE8_HANDLER( bking_xld3_w ) WRITE8_HANDLER( bking_xld3_w )
{ {
xld3 = -data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->xld3 = -data;
} }
WRITE8_HANDLER( bking_yld3_w ) WRITE8_HANDLER( bking_yld3_w )
{ {
yld3 = -data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->yld3 = -data;
} }
WRITE8_HANDLER( bking_cont1_w ) WRITE8_HANDLER( bking_cont1_w )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
/* D0 = COIN LOCK */ /* D0 = COIN LOCK */
/* D1 = BALL 5 (Controller selection) */ /* D1 = BALL 5 (Controller selection) */
/* D2 = VINV (flip screen) */ /* D2 = VINV (flip screen) */
@ -153,38 +135,42 @@ WRITE8_HANDLER( bking_cont1_w )
tilemap_set_flip_all(space->machine, flip_screen_get(space->machine) ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0); tilemap_set_flip_all(space->machine, flip_screen_get(space->machine) ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
controller = data & 0x02; state->controller = data & 0x02;
crow_pic = (data >> 4) & 0x0f; state->crow_pic = (data >> 4) & 0x0f;
} }
WRITE8_HANDLER( bking_cont2_w ) WRITE8_HANDLER( bking_cont2_w )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
/* D0-D2 = BALL10 - BALL12 (Selects player 1 ball picture) */ /* D0-D2 = BALL10 - BALL12 (Selects player 1 ball picture) */
/* D3-D5 = BALL20 - BALL22 (Selects player 2 ball picture) */ /* D3-D5 = BALL20 - BALL22 (Selects player 2 ball picture) */
/* D6 = HIT1 */ /* D6 = HIT1 */
/* D7 = HIT2 */ /* D7 = HIT2 */
ball1_pic = (data >> 0) & 0x07; state->ball1_pic = (data >> 0) & 0x07;
ball2_pic = (data >> 3) & 0x07; state->ball2_pic = (data >> 3) & 0x07;
hit = data >> 6; state->hit = data >> 6;
} }
WRITE8_HANDLER( bking_cont3_w ) WRITE8_HANDLER( bking_cont3_w )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
/* D0 = CROW INV (inverts Crow picture and coordinates) */ /* D0 = CROW INV (inverts Crow picture and coordinates) */
/* D1-D2 = COLOR 0 - COLOR 1 (switches 4 color palettes, global across all graphics) */ /* D1-D2 = COLOR 0 - COLOR 1 (switches 4 color palettes, global across all graphics) */
/* D3 = SOUND STOP */ /* D3 = SOUND STOP */
crow_flip = ~data & 0x01; state->crow_flip = ~data & 0x01;
if (palette_bank != ((data >> 1) & 0x03)) if (state->palette_bank != ((data >> 1) & 0x03))
{ {
tilemap_mark_all_tiles_dirty(bg_tilemap); tilemap_mark_all_tiles_dirty(state->bg_tilemap);
} }
palette_bank = (data >> 1) & 0x03; state->palette_bank = (data >> 1) & 0x03;
sound_global_enable(space->machine, ~data & 0x08); sound_global_enable(space->machine, ~data & 0x08);
} }
@ -192,97 +178,109 @@ WRITE8_HANDLER( bking_cont3_w )
WRITE8_HANDLER( bking_msk_w ) WRITE8_HANDLER( bking_msk_w )
{ {
pc3259_mask++; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->pc3259_mask++;
} }
WRITE8_HANDLER( bking_hitclr_w ) WRITE8_HANDLER( bking_hitclr_w )
{ {
pc3259_mask = 0; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->pc3259_mask = 0;
pc3259_output[0] = 0; state->pc3259_output[0] = 0;
pc3259_output[1] = 0; state->pc3259_output[1] = 0;
pc3259_output[2] = 0; state->pc3259_output[2] = 0;
pc3259_output[3] = 0; state->pc3259_output[3] = 0;
} }
WRITE8_HANDLER( bking_playfield_w ) WRITE8_HANDLER( bking_playfield_w )
{ {
bking_playfield_ram[offset] = data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(bg_tilemap, offset / 2); state->playfield_ram[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
} }
READ8_HANDLER( bking_input_port_5_r ) READ8_HANDLER( bking_input_port_5_r )
{ {
return input_port_read(space->machine, controller ? "TRACK1_X" : "TRACK0_X"); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return input_port_read(space->machine, state->controller ? "TRACK1_X" : "TRACK0_X");
} }
READ8_HANDLER( bking_input_port_6_r ) READ8_HANDLER( bking_input_port_6_r )
{ {
return input_port_read(space->machine, controller ? "TRACK1_Y" : "TRACK0_Y"); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return input_port_read(space->machine, state->controller ? "TRACK1_Y" : "TRACK0_Y");
} }
READ8_HANDLER( bking_pos_r ) READ8_HANDLER( bking_pos_r )
{ {
return pc3259_output[offset / 8] << 4; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
return state->pc3259_output[offset / 8] << 4;
} }
static TILE_GET_INFO( get_tile_info ) static TILE_GET_INFO( get_tile_info )
{ {
UINT8 code0 = bking_playfield_ram[2 * tile_index + 0]; buggychl_state *state = (buggychl_state *)machine->driver_data;
UINT8 code1 = bking_playfield_ram[2 * tile_index + 1]; UINT8 code0 = state->playfield_ram[2 * tile_index + 0];
UINT8 code1 = state->playfield_ram[2 * tile_index + 1];
int flags = 0; int flags = 0;
if (code1 & 4) flags |= TILE_FLIPX; if (code1 & 4) flags |= TILE_FLIPX;
if (code1 & 8) flags |= TILE_FLIPY; if (code1 & 8) flags |= TILE_FLIPY;
SET_TILE_INFO(0, code0 + 256 * code1, palette_bank, flags); SET_TILE_INFO(0, code0 + 256 * code1, state->palette_bank, flags);
} }
VIDEO_START( bking ) VIDEO_START( bking )
{ {
bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32); buggychl_state *state = (buggychl_state *)machine->driver_data;
helper0 = video_screen_auto_bitmap_alloc(machine->primary_screen); state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
helper1 = video_screen_auto_bitmap_alloc(machine->primary_screen); state->tmp_bitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen);
state->tmp_bitmap2 = video_screen_auto_bitmap_alloc(machine->primary_screen);
state_save_register_global_bitmap(machine, state->tmp_bitmap1);
state_save_register_global_bitmap(machine, state->tmp_bitmap2);
} }
VIDEO_UPDATE( bking ) VIDEO_UPDATE( bking )
{ {
tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0); buggychl_state *state = (buggychl_state *)screen->machine->driver_data;
tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
/* draw the balls */ /* draw the balls */
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[2], drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[2],
ball1_pic, state->ball1_pic,
palette_bank, state->palette_bank,
0, 0, 0, 0,
xld1, yld1, 0); state->xld1, state->yld1, 0);
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[3], drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[3],
ball2_pic, state->ball2_pic,
palette_bank, state->palette_bank,
0, 0, 0, 0,
xld2, yld2, 0); state->xld2, state->yld2, 0);
/* draw the crow */ /* draw the crow */
drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1], drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1],
crow_pic, state->crow_pic,
palette_bank, state->palette_bank,
crow_flip, crow_flip, state->crow_flip, state->crow_flip,
crow_flip ? xld3 - 16 : 256 - xld3, crow_flip ? yld3 - 16 : 256 - yld3, 0); state->crow_flip ? state->xld3 - 16 : 256 - state->xld3, state->crow_flip ? state->yld3 - 16 : 256 - state->yld3, 0);
return 0; return 0;
} }
VIDEO_EOF( bking ) VIDEO_EOF( bking )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
static const rectangle rect = { 0, 7, 0, 15 }; static const rectangle rect = { 0, 7, 0, 15 };
int xld = 0; int xld = 0;
@ -290,27 +288,27 @@ VIDEO_EOF( bking )
UINT32 latch = 0; UINT32 latch = 0;
if (pc3259_mask == 6) /* player 1 */ if (state->pc3259_mask == 6) /* player 1 */
{ {
xld = xld1; xld = state->xld1;
yld = yld1; yld = state->yld1;
drawgfx_opaque(helper1, &rect, machine->gfx[2], drawgfx_opaque(state->tmp_bitmap2, &rect, machine->gfx[2],
ball1_pic, state->ball1_pic,
0, 0,
0, 0, 0, 0,
0, 0); 0, 0);
latch = 0x0C00; latch = 0x0c00;
} }
if (pc3259_mask == 3) /* player 2 */ if (state->pc3259_mask == 3) /* player 2 */
{ {
xld = xld2; xld = state->xld2;
yld = yld2; yld = state->yld2;
drawgfx_opaque(helper1, &rect, machine->gfx[3], drawgfx_opaque(state->tmp_bitmap2, &rect, machine->gfx[3],
ball2_pic, state->ball2_pic,
0, 0,
0, 0, 0, 0,
0, 0); 0, 0);
@ -318,25 +316,25 @@ VIDEO_EOF( bking )
latch = 0x0400; latch = 0x0400;
} }
tilemap_set_scrollx(bg_tilemap, 0, flip_screen_get(machine) ? -xld : xld); tilemap_set_scrollx(state->bg_tilemap, 0, flip_screen_get(machine) ? -xld : xld);
tilemap_set_scrolly(bg_tilemap, 0, flip_screen_get(machine) ? -yld : yld); tilemap_set_scrolly(state->bg_tilemap, 0, flip_screen_get(machine) ? -yld : yld);
tilemap_draw(helper0, &rect, bg_tilemap, 0, 0); tilemap_draw(state->tmp_bitmap1, &rect, state->bg_tilemap, 0, 0);
tilemap_set_scrollx(bg_tilemap, 0, 0); tilemap_set_scrollx(state->bg_tilemap, 0, 0);
tilemap_set_scrolly(bg_tilemap, 0, 0); tilemap_set_scrolly(state->bg_tilemap, 0, 0);
if (latch != 0) if (latch != 0)
{ {
const UINT8* MASK = memory_region(machine, "user1") + 8 * hit; const UINT8* MASK = memory_region(machine, "user1") + 8 * state->hit;
int x; int x;
int y; int y;
for (y = rect.min_y; y <= rect.max_y; y++) for (y = rect.min_y; y <= rect.max_y; y++)
{ {
const UINT16* p0 = BITMAP_ADDR16(helper0, y, 0); const UINT16* p0 = BITMAP_ADDR16(state->tmp_bitmap1, y, 0);
const UINT16* p1 = BITMAP_ADDR16(helper1, y, 0); const UINT16* p1 = BITMAP_ADDR16(state->tmp_bitmap2, y, 0);
for (x = rect.min_x; x <= rect.max_x; x++) for (x = rect.min_x; x <= rect.max_x; x++)
{ {
@ -348,10 +346,10 @@ VIDEO_EOF( bking )
latch |= (flip_screen_get(machine) ? 31 - col : col) << 0; latch |= (flip_screen_get(machine) ? 31 - col : col) << 0;
latch |= (flip_screen_get(machine) ? 31 - row : row) << 5; latch |= (flip_screen_get(machine) ? 31 - row : row) << 5;
pc3259_output[0] = (latch >> 0x0) & 0xf; state->pc3259_output[0] = (latch >> 0x0) & 0xf;
pc3259_output[1] = (latch >> 0x4) & 0xf; state->pc3259_output[1] = (latch >> 0x4) & 0xf;
pc3259_output[2] = (latch >> 0x8) & 0xf; state->pc3259_output[2] = (latch >> 0x8) & 0xf;
pc3259_output[3] = (latch >> 0xc) & 0xf; state->pc3259_output[3] = (latch >> 0xc) & 0xf;
return; return;
} }

View File

@ -3,59 +3,54 @@
#include "includes/buggychl.h" #include "includes/buggychl.h"
UINT8 *buggychl_scrollv,*buggychl_scrollh;
static UINT8 buggychl_sprite_lookup[0x2000];
UINT8 *buggychl_character_ram;
static bitmap_t *tmpbitmap1,*tmpbitmap2;
static int sl_bank,bg_on,sky_on,sprite_color_base,bg_scrollx;
PALETTE_INIT( buggychl ) PALETTE_INIT( buggychl )
{ {
int i; int i;
/* arbitrary blue shading for the sky */ /* arbitrary blue shading for the sky */
for (i = 0;i < 128;i++) for (i = 0; i < 128; i++)
palette_set_color(machine,i+128,MAKE_RGB(0,i,2*i)); palette_set_color(machine, i + 128, MAKE_RGB(0, i, 2 * i));
} }
VIDEO_START( buggychl ) VIDEO_START( buggychl )
{ {
tmpbitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen); buggychl_state *state = (buggychl_state *)machine->driver_data;
tmpbitmap2 = video_screen_auto_bitmap_alloc(machine->primary_screen); state->tmp_bitmap1 = video_screen_auto_bitmap_alloc(machine->primary_screen);
state->tmp_bitmap2 = video_screen_auto_bitmap_alloc(machine->primary_screen);
gfx_element_set_source(machine->gfx[0], buggychl_character_ram); state_save_register_global_bitmap(machine, state->tmp_bitmap1);
state_save_register_global_bitmap(machine, state->tmp_bitmap2);
gfx_element_set_source(machine->gfx[0], state->charram);
} }
WRITE8_HANDLER( buggychl_chargen_w ) WRITE8_HANDLER( buggychl_chargen_w )
{ {
if (buggychl_character_ram[offset] != data) buggychl_state *state = (buggychl_state *)space->machine->driver_data;
if (state->charram[offset] != data)
{ {
buggychl_character_ram[offset] = data; state->charram[offset] = data;
gfx_element_mark_dirty(space->machine->gfx[0], (offset / 8) & 0xff); gfx_element_mark_dirty(space->machine->gfx[0], (offset / 8) & 0xff);
} }
} }
WRITE8_HANDLER( buggychl_sprite_lookup_bank_w ) WRITE8_HANDLER( buggychl_sprite_lookup_bank_w )
{ {
sl_bank = (data & 0x10) << 8; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->sl_bank = (data & 0x10) << 8;
} }
WRITE8_HANDLER( buggychl_sprite_lookup_w ) WRITE8_HANDLER( buggychl_sprite_lookup_w )
{ {
buggychl_sprite_lookup[offset + sl_bank] = data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->sprite_lookup[offset + state->sl_bank] = data;
} }
WRITE8_HANDLER( buggychl_ctrl_w ) WRITE8_HANDLER( buggychl_ctrl_w )
{ {
buggychl_state *state = (buggychl_state *)space->machine->driver_data;
/* /*
bit7 = lamp bit7 = lamp
bit6 = lockout bit6 = lockout
@ -69,49 +64,51 @@ WRITE8_HANDLER( buggychl_ctrl_w )
flip_screen_y_set(space->machine, data & 0x01); flip_screen_y_set(space->machine, data & 0x01);
flip_screen_x_set(space->machine, data & 0x02); flip_screen_x_set(space->machine, data & 0x02);
bg_on = data & 0x04; state->bg_on = data & 0x04;
sky_on = data & 0x08; state->sky_on = data & 0x08;
sprite_color_base = (data & 0x10) ? 1*16 : 3*16; state->sprite_color_base = (data & 0x10) ? 1 * 16 : 3 * 16;
coin_lockout_global_w(space->machine, (~data & 0x40) >> 6); coin_lockout_global_w(space->machine, (~data & 0x40) >> 6);
set_led_status(space->machine, 0,~data & 0x80); set_led_status(space->machine, 0, ~data & 0x80);
} }
WRITE8_HANDLER( buggychl_bg_scrollx_w ) WRITE8_HANDLER( buggychl_bg_scrollx_w )
{ {
bg_scrollx = -(data - 0x12); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
state->bg_scrollx = -(data - 0x12);
} }
static void draw_sky( bitmap_t *bitmap, const rectangle *cliprect )
static void draw_sky(bitmap_t *bitmap, const rectangle *cliprect)
{ {
int x,y; int x, y;
for (y = 0;y < 256;y++) for (y = 0; y < 256; y++)
for (x = 0;x < 256;x++) for (x = 0; x < 256; x++)
*BITMAP_ADDR16(bitmap, y, x) = 128 + x/2; *BITMAP_ADDR16(bitmap, y, x) = 128 + x / 2;
} }
static void draw_bg(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_bg( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
int offs; int offs;
int scroll[256]; int scroll[256];
for (offs = 0;offs < 0x400;offs++) for (offs = 0; offs < 0x400; offs++)
{ {
int code = machine->generic.videoram.u8[0x400+offs]; int code = state->videoram[0x400 + offs];
int sx = offs % 32; int sx = offs % 32;
int sy = offs / 32; int sy = offs / 32;
if (flip_screen_x_get(machine)) sx = 31 - sx; if (flip_screen_x_get(machine))
if (flip_screen_y_get(machine)) sy = 31 - sy; sx = 31 - sx;
if (flip_screen_y_get(machine))
sy = 31 - sy;
drawgfx_opaque(tmpbitmap1,NULL,machine->gfx[0], drawgfx_opaque(state->tmp_bitmap1, NULL, machine->gfx[0],
code, code,
2, 2,
flip_screen_x_get(machine),flip_screen_y_get(machine), flip_screen_x_get(machine),flip_screen_y_get(machine),
@ -119,37 +116,39 @@ static void draw_bg(running_machine *machine, bitmap_t *bitmap, const rectangle
} }
/* first copy to a temp bitmap doing column scroll */ /* first copy to a temp bitmap doing column scroll */
for (offs = 0;offs < 256;offs++) for (offs = 0; offs < 256; offs++)
scroll[offs] = -buggychl_scrollv[offs/8]; scroll[offs] = -state->scrollv[offs / 8];
copyscrollbitmap(tmpbitmap2,tmpbitmap1,1,&bg_scrollx,256,scroll,NULL); copyscrollbitmap(state->tmp_bitmap2, state->tmp_bitmap1, 1, &state->bg_scrollx, 256, scroll, NULL);
/* then copy to the screen doing row scroll */ /* then copy to the screen doing row scroll */
for (offs = 0;offs < 256;offs++) for (offs = 0; offs < 256; offs++)
scroll[offs] = -buggychl_scrollh[offs]; scroll[offs] = -state->scrollh[offs];
copyscrollbitmap_trans(bitmap,tmpbitmap2,256,scroll,0,0,cliprect,32); copyscrollbitmap_trans(bitmap, state->tmp_bitmap2, 256, scroll, 0, 0, cliprect, 32);
} }
static void draw_fg(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) static void draw_fg( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
buggychl_state *state = (buggychl_state *)machine->driver_data;
int offs; int offs;
for (offs = 0; offs < 0x400; offs++)
for (offs = 0;offs < 0x400;offs++)
{ {
int sx = offs % 32; int sx = offs % 32;
int sy = offs / 32; int sy = offs / 32;
int flipx = flip_screen_x_get(machine); int flipx = flip_screen_x_get(machine);
int flipy = flip_screen_y_get(machine); int flipy = flip_screen_y_get(machine);
/* the following line is most likely wrong */ /* the following line is most likely wrong */
int transpen = (bg_on && sx >= 22) ? -1 : 0; int transpen = (state->bg_on && sx >= 22) ? -1 : 0;
int code = machine->generic.videoram.u8[offs]; int code = state->videoram[offs];
if (flipx) sx = 31 - sx; if (flipx)
if (flipy) sy = 31 - sy; sx = 31 - sx;
if (flipy)
sy = 31 - sy;
drawgfx_transpen(bitmap,cliprect,machine->gfx[0], drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
code, code,
@ -161,69 +160,68 @@ static void draw_fg(running_machine *machine, bitmap_t *bitmap, const rectangle
} }
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 )
{ {
UINT8 *spriteram = machine->generic.spriteram.u8; buggychl_state *state = (buggychl_state *)machine->driver_data;
UINT8 *spriteram = state->spriteram;
int offs; int offs;
const UINT8 *gfx; const UINT8 *gfx;
profiler_mark_start(PROFILER_USER1); profiler_mark_start(PROFILER_USER1);
gfx = memory_region(machine, "gfx2"); gfx = memory_region(machine, "gfx2");
for (offs = 0;offs < machine->generic.spriteram_size;offs += 4) for (offs = 0; offs < state->spriteram_size; offs += 4)
{ {
int sx,sy,flipy,zoom,ch,x,px,y; int sx, sy, flipy, zoom, ch, x, px, y;
const UINT8 *lookup; const UINT8 *lookup;
const UINT8 *zoomx_rom,*zoomy_rom; const UINT8 *zoomx_rom, *zoomy_rom;
sx = spriteram[offs + 3] - ((spriteram[offs + 2] & 0x80) << 1);
sx = spriteram[offs+3] - ((spriteram[offs+2] & 0x80) << 1); sy = 256 - 64 - spriteram[offs] + ((spriteram[offs + 1] & 0x80) << 1);
sy = 256-64 - spriteram[offs] + ((spriteram[offs+1] & 0x80) << 1); flipy = spriteram[offs + 1] & 0x40;
flipy = spriteram[offs+1] & 0x40; zoom = spriteram[offs + 1] & 0x3f;
zoom = spriteram[offs+1] & 0x3f;
zoomy_rom = gfx + (zoom << 6); zoomy_rom = gfx + (zoom << 6);
zoomx_rom = gfx + 0x2000 + (zoom << 3); zoomx_rom = gfx + 0x2000 + (zoom << 3);
lookup = buggychl_sprite_lookup + ((spriteram[offs+2] & 0x7f) << 6); lookup = state->sprite_lookup + ((spriteram[offs + 2] & 0x7f) << 6);
for (y = 0;y < 64;y++) for (y = 0; y < 64; y++)
{ {
int dy = flip_screen_y_get(machine) ? (255 - sy - y) : (sy + y); int dy = flip_screen_y_get(machine) ? (255 - sy - y) : (sy + y);
if ((dy & ~0xff) == 0) if ((dy & ~0xff) == 0)
{ {
int charline,base_pos; int charline, base_pos;
charline = zoomy_rom[y] & 0x07; charline = zoomy_rom[y] & 0x07;
base_pos = zoomy_rom[y] & 0x38; base_pos = zoomy_rom[y] & 0x38;
if (flipy) base_pos ^= 0x38; if (flipy)
base_pos ^= 0x38;
px = 0; px = 0;
for (ch = 0;ch < 4;ch++) for (ch = 0; ch < 4; ch++)
{ {
int pos,code,realflipy; int pos, code, realflipy;
const UINT8 *pendata; const UINT8 *pendata;
pos = base_pos + 2*ch; pos = base_pos + 2 * ch;
code = 8 * (lookup[pos] | ((lookup[pos+1] & 0x07) << 8)); code = 8 * (lookup[pos] | ((lookup[pos + 1] & 0x07) << 8));
realflipy = (lookup[pos+1] & 0x80) ? !flipy : flipy; realflipy = (lookup[pos + 1] & 0x80) ? !flipy : flipy;
code += (realflipy ? (charline ^ 7) : charline); code += (realflipy ? (charline ^ 7) : charline);
pendata = gfx_element_get_data(machine->gfx[1], code); pendata = gfx_element_get_data(machine->gfx[1], code);
for (x = 0;x < 16;x++) for (x = 0; x < 16; x++)
{ {
int col; int col = pendata[x];
col = pendata[x];
if (col) if (col)
{ {
int dx = flip_screen_x_get(machine) ? (255 - sx - px) : (sx + px); int dx = flip_screen_x_get(machine) ? (255 - sx - px) : (sx + px);
if ((dx & ~0xff) == 0) if ((dx & ~0xff) == 0)
*BITMAP_ADDR16(bitmap, dy, dx) = sprite_color_base + col; *BITMAP_ADDR16(bitmap, dy, dx) = state->sprite_color_base + col;
} }
/* the following line is almost certainly wrong */ /* the following line is almost certainly wrong */
if (zoomx_rom[7-(2*ch+x/8)] & (1 << (x & 7))) if (zoomx_rom[7 - (2 * ch + x / 8)] & (1 << (x & 7)))
px++; px++;
} }
} }
@ -237,12 +235,14 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( buggychl ) VIDEO_UPDATE( buggychl )
{ {
if (sky_on) buggychl_state *state = (buggychl_state *)screen->machine->driver_data;
if (state->sky_on)
draw_sky(bitmap, cliprect); draw_sky(bitmap, cliprect);
else else
bitmap_fill(bitmap,cliprect,0); bitmap_fill(bitmap, cliprect, 0);
if (bg_on) if (state->bg_on)
draw_bg(screen->machine, bitmap, cliprect); draw_bg(screen->machine, bitmap, cliprect);
draw_sprites(screen->machine, bitmap, cliprect); draw_sprites(screen->machine, bitmap, cliprect);

View File

@ -3,17 +3,7 @@
*/ */
#include "driver.h" #include "driver.h"
#include "includes/buggychl.h"
/*
* variables
*/
UINT8 *msisaac_videoram;
UINT8 *msisaac_videoram2;
//static int textbank1;
static int bg2_textbank;
static tilemap *background, *background2, *foreground;
/*************************************************************************** /***************************************************************************
@ -24,19 +14,31 @@ static tilemap *background, *background2, *foreground;
static TILE_GET_INFO( get_fg_tile_info ) static TILE_GET_INFO( get_fg_tile_info )
{ {
int tile_number = machine->generic.videoram.u8[tile_index]; buggychl_state *state = (buggychl_state *)machine->driver_data;
int tile_number = state->videoram[tile_index];
SET_TILE_INFO( 0, SET_TILE_INFO( 0,
tile_number, tile_number,
0x10, 0x10,
0); 0);
} }
static TILE_GET_INFO( get_bg_tile_info )
{
buggychl_state *state = (buggychl_state *)machine->driver_data;
int tile_number = state->videoram2[tile_index];
SET_TILE_INFO( 1,
0x100 + tile_number,
0x30,
0);
}
static TILE_GET_INFO( get_bg2_tile_info ) static TILE_GET_INFO( get_bg2_tile_info )
{ {
int tile_number = msisaac_videoram2[tile_index]; buggychl_state *state = (buggychl_state *)machine->driver_data;
int tile_number = state->videoram3[tile_index];
/* graphics 0 or 1 */ /* graphics 0 or 1 */
int gfx_b = (bg2_textbank>>3) & 1; int gfx_b = (state->bg2_textbank >> 3) & 1;
SET_TILE_INFO( gfx_b, SET_TILE_INFO( gfx_b,
tile_number, tile_number,
@ -44,15 +46,6 @@ static TILE_GET_INFO( get_bg2_tile_info )
0); 0);
} }
static TILE_GET_INFO( get_bg_tile_info )
{
int tile_number = msisaac_videoram[tile_index];
SET_TILE_INFO( 1,
0x100+tile_number,
0x30,
0);
}
/*************************************************************************** /***************************************************************************
Start the video hardware emulation. Start the video hardware emulation.
@ -61,12 +54,13 @@ static TILE_GET_INFO( get_bg_tile_info )
VIDEO_START( msisaac ) VIDEO_START( msisaac )
{ {
background = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8,8,32,32); buggychl_state *state = (buggychl_state *)machine->driver_data;
background2 = tilemap_create(machine, get_bg2_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);
foreground = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows,8,8,32,32); state->bg2_tilemap = tilemap_create(machine, get_bg2_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);
tilemap_set_transparent_pen(background2,0); tilemap_set_transparent_pen(state->bg2_tilemap, 0);
tilemap_set_transparent_pen(foreground,0); tilemap_set_transparent_pen(state->fg_tilemap, 0);
} }
@ -78,77 +72,87 @@ VIDEO_START( msisaac )
WRITE8_HANDLER( msisaac_fg_scrolly_w ) WRITE8_HANDLER( msisaac_fg_scrolly_w )
{ {
tilemap_set_scrolly( foreground, 0, data ); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_set_scrolly(state->fg_tilemap, 0, data);
} }
WRITE8_HANDLER( msisaac_fg_scrollx_w ) WRITE8_HANDLER( msisaac_fg_scrollx_w )
{ {
tilemap_set_scrollx( foreground, 0, 9+data ); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_set_scrollx(state->fg_tilemap, 0, 9 + data);
} }
WRITE8_HANDLER( msisaac_bg2_scrolly_w ) WRITE8_HANDLER( msisaac_bg2_scrolly_w )
{ {
tilemap_set_scrolly( background2, 0, data ); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_set_scrolly(state->bg2_tilemap, 0, data);
} }
WRITE8_HANDLER( msisaac_bg2_scrollx_w ) WRITE8_HANDLER( msisaac_bg2_scrollx_w )
{ {
tilemap_set_scrollx( background2, 0, 9+2+data ); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_set_scrollx(state->bg2_tilemap, 0, 9 + 2 + data);
} }
WRITE8_HANDLER( msisaac_bg_scrolly_w ) WRITE8_HANDLER( msisaac_bg_scrolly_w )
{ {
tilemap_set_scrolly( background, 0, data ); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_set_scrolly(state->bg_tilemap, 0, data);
} }
WRITE8_HANDLER( msisaac_bg_scrollx_w ) WRITE8_HANDLER( msisaac_bg_scrollx_w )
{ {
tilemap_set_scrollx( background, 0, 9+4+data ); buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_set_scrollx(state->bg_tilemap, 0, 9 + 4 + data);
} }
#ifdef UNUSED_FUNCTION #ifdef UNUSED_FUNCTION
WRITE8_HANDLER( msisaac_textbank1_w ) WRITE8_HANDLER( msisaac_textbank1_w )
{ {
if( textbank1!=data ) if (textbank1!=data)
{ {
textbank1 = data; textbank1 = data;
tilemap_mark_all_tiles_dirty( foreground ); tilemap_mark_all_tiles_dirty(fg_tilemap);
} }
} }
#endif #endif
WRITE8_HANDLER( msisaac_bg2_textbank_w ) WRITE8_HANDLER( msisaac_bg2_textbank_w )
{ {
if( bg2_textbank != data ) buggychl_state *state = (buggychl_state *)space->machine->driver_data;
if (state->bg2_textbank != data )
{ {
bg2_textbank = data; state->bg2_textbank = data;
tilemap_mark_all_tiles_dirty( background2 ); tilemap_mark_all_tiles_dirty(state->bg2_tilemap);
//check if we are correct on this one //check if we are correct on this one
if ((data!=8) && (data!=0)) if ((data != 8) && (data != 0))
{ {
logerror("bg2 control=%2x\n",data); logerror("bg2 control=%2x\n", data);
} }
} }
} }
WRITE8_HANDLER( msisaac_bg_videoram_w ) WRITE8_HANDLER( msisaac_bg_videoram_w )
{ {
msisaac_videoram[offset]=data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(background,offset); state->videoram2[offset] = data;
tilemap_mark_tile_dirty(state->bg_tilemap, offset);
} }
WRITE8_HANDLER( msisaac_bg2_videoram_w ) WRITE8_HANDLER( msisaac_bg2_videoram_w )
{ {
msisaac_videoram2[offset]=data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(background2,offset); state->videoram3[offset] = data;
tilemap_mark_tile_dirty(state->bg2_tilemap, offset);
} }
WRITE8_HANDLER( msisaac_fg_videoram_w ) WRITE8_HANDLER( msisaac_fg_videoram_w )
{ {
space->machine->generic.videoram.u8[offset]=data; buggychl_state *state = (buggychl_state *)space->machine->driver_data;
tilemap_mark_tile_dirty(foreground,offset); state->videoram[offset] = data;
tilemap_mark_tile_dirty(state->fg_tilemap, offset);
} }
@ -157,33 +161,34 @@ WRITE8_HANDLER( msisaac_fg_videoram_w )
Display refresh Display refresh
***************************************************************************/ ***************************************************************************/
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
{ {
const UINT8 *source = machine->generic.spriteram.u8+32*4-4; buggychl_state *state = (buggychl_state *)machine->driver_data;
const UINT8 *finish = machine->generic.spriteram.u8; /* ? */ const UINT8 *source = state->spriteram + 32 * 4 - 4;
const UINT8 *finish = state->spriteram; /* ? */
while( source>=finish ) while (source >= finish)
{ {
int sx = source[0]; int sx = source[0];
int sy = 240-source[1]-1; int sy = 240 - source[1] - 1;
int attributes = source[2]; int attributes = source[2];
int sprite_number = source[3]; int sprite_number = source[3];
int color = (attributes>>4) & 0xf; int color = (attributes >> 4) & 0xf;
int flipx = (attributes&0x1); int flipx = (attributes & 0x1);
int flipy = (attributes&0x2); int flipy = (attributes & 0x2);
gfx_element *gfx = machine->gfx[2]; gfx_element *gfx = machine->gfx[2];
if (attributes&4) if (attributes & 4)
{ {
//color = rand()&15; //color = rand() & 15;
gfx = machine->gfx[3]; gfx = machine->gfx[3];
} }
if (attributes&8) /* double size sprite */ if (attributes & 8) /* double size sprite */
{ {
switch(attributes&3) switch (attributes & 3)
{ {
case 0: /* flipx==0 && flipy==0 */ case 0: /* flipx==0 && flipy==0 */
drawgfx_transpen(bitmap,cliprect,gfx, drawgfx_transpen(bitmap,cliprect,gfx,
@ -241,10 +246,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
VIDEO_UPDATE( msisaac ) VIDEO_UPDATE( msisaac )
{ {
tilemap_draw(bitmap,cliprect,background, 0,0); buggychl_state *state = (buggychl_state *)screen->machine->driver_data;
tilemap_draw(bitmap,cliprect,background2,0,0); tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
draw_sprites(screen->machine,bitmap,cliprect); tilemap_draw(bitmap, cliprect, state->bg2_tilemap, 0, 0);
tilemap_draw(bitmap,cliprect,foreground, 0,0); draw_sprites(screen->machine, bitmap, cliprect);
tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
return 0; return 0;
} }