Added driver data struct and save states to btime.c and scregg.c

This commit is contained in:
Fabio Priuli 2009-11-27 10:09:27 +00:00
parent 5ea417d583
commit 832b946cc5
5 changed files with 671 additions and 510 deletions

View File

@ -157,59 +157,49 @@ enum
AUDIO_ENABLE_AY8910 /* via ay-8910 port A */ AUDIO_ENABLE_AY8910 /* via ay-8910 port A */
}; };
static WRITE8_HANDLER( audio_command_w ); static WRITE8_HANDLER( audio_command_w );
static READ8_HANDLER( audio_command_r ); static READ8_HANDLER( audio_command_r );
static READ8_HANDLER( zoar_dsw1_read ); static READ8_HANDLER( zoar_dsw1_read );
static UINT8 *decrypted; static UINT8 *decrypted;
static UINT8 *rambase;
static UINT8 *audio_rambase;
static UINT8 audio_nmi_enable_type;
static UINT8 audio_nmi_enabled;
static UINT8 audio_nmi_state;
static MACHINE_START( btime )
{
/* by default, the audio NMI is disabled, except for bootlegs which don't use the enable */
audio_nmi_enabled = (audio_nmi_enable_type == AUDIO_ENABLE_NONE);
}
static WRITE8_HANDLER( audio_nmi_enable_w ) static WRITE8_HANDLER( audio_nmi_enable_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
/* for most games, this serves as the NMI enable for the audio CPU; however, /* for most games, this serves as the NMI enable for the audio CPU; however,
lnc and disco use bit 0 of the first AY-8910's port A instead; many other lnc and disco use bit 0 of the first AY-8910's port A instead; many other
games also write there in addition to this address */ games also write there in addition to this address */
if (audio_nmi_enable_type == AUDIO_ENABLE_DIRECT) if (state->audio_nmi_enable_type == AUDIO_ENABLE_DIRECT)
{ {
audio_nmi_enabled = data & 1; state->audio_nmi_enabled = data & 1;
cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, (audio_nmi_enabled && audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, (state->audio_nmi_enabled && state->audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE);
} }
} }
static WRITE8_DEVICE_HANDLER( ay_audio_nmi_enable_w ) static WRITE8_DEVICE_HANDLER( ay_audio_nmi_enable_w )
{ {
btime_state *state = (btime_state *)device->machine->driver_data;
/* port A bit 0, when 1, inhibits the NMI */ /* port A bit 0, when 1, inhibits the NMI */
if (audio_nmi_enable_type == AUDIO_ENABLE_AY8910) if (state->audio_nmi_enable_type == AUDIO_ENABLE_AY8910)
{ {
audio_nmi_enabled = ~data & 1; state->audio_nmi_enabled = ~data & 1;
cputag_set_input_line(device->machine, "audiocpu", INPUT_LINE_NMI, (audio_nmi_enabled && audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, (state->audio_nmi_enabled && state->audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE);
} }
} }
static TIMER_DEVICE_CALLBACK( audio_nmi_gen ) static TIMER_DEVICE_CALLBACK( audio_nmi_gen )
{ {
btime_state *state = (btime_state *)timer->machine->driver_data;
int scanline = param; int scanline = param;
audio_nmi_state = scanline & 8; state->audio_nmi_state = scanline & 8;
cputag_set_input_line(timer->machine, "audiocpu", INPUT_LINE_NMI, (audio_nmi_enabled && audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, (state->audio_nmi_enabled && state->audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE);
} }
INLINE UINT8 swap_bits_5_6(UINT8 data) INLINE UINT8 swap_bits_5_6(UINT8 data)
{ {
return BITSWAP8(data,7,5,6,4,3,2,1,0); return BITSWAP8(data,7,5,6,4,3,2,1,0);
@ -218,6 +208,7 @@ INLINE UINT8 swap_bits_5_6(UINT8 data)
static void btime_decrypt( const address_space *space ) static void btime_decrypt( const address_space *space )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
UINT8 *src, *src1; UINT8 *src, *src1;
int addr, addr1; int addr, addr1;
@ -233,12 +224,12 @@ static void btime_decrypt(const address_space *space)
/* however if the previous instruction was JSR (which caused a write to */ /* however if the previous instruction was JSR (which caused a write to */
/* the stack), fetch the address of the next instruction. */ /* the stack), fetch the address of the next instruction. */
addr1 = cpu_get_previouspc(space->cpu); addr1 = cpu_get_previouspc(space->cpu);
src1 = (addr1 < 0x9000) ? rambase : memory_region(space->machine, "maincpu"); src1 = (addr1 < 0x9000) ? state->rambase : memory_region(space->machine, "maincpu");
if (decrypted[addr1] == 0x20) /* JSR $xxxx */ if (decrypted[addr1] == 0x20) /* JSR $xxxx */
addr = src1[addr1 + 1] + 256 * src1[addr1 + 2]; addr = src1[addr1 + 1] + 256 * src1[addr1 + 2];
/* If the address of the next instruction is xxxx xxx1 xxxx x1xx, decode it. */ /* If the address of the next instruction is xxxx xxx1 xxxx x1xx, decode it. */
src = (addr < 0x9000) ? rambase : memory_region(space->machine, "maincpu"); src = (addr < 0x9000) ? state->rambase : memory_region(space->machine, "maincpu");
if ((addr & 0x0104) == 0x0104) if ((addr & 0x0104) == 0x0104)
{ {
/* 76543210 -> 65342710 bit rotation */ /* 76543210 -> 65342710 bit rotation */
@ -248,6 +239,8 @@ static void btime_decrypt(const address_space *space)
static WRITE8_HANDLER( lnc_w ) static WRITE8_HANDLER( lnc_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
if (offset <= 0x3bff) ; if (offset <= 0x3bff) ;
else if (offset >= 0x3c00 && offset <= 0x3fff) { lnc_videoram_w(space, offset - 0x3c00, data); return; } else if (offset >= 0x3c00 && offset <= 0x3fff) { lnc_videoram_w(space, offset - 0x3c00, data); return; }
else if (offset >= 0x7c00 && offset <= 0x7fff) { lnc_mirrorvideoram_w(space, offset - 0x7c00, data); return; } else if (offset >= 0x7c00 && offset <= 0x7fff) { lnc_mirrorvideoram_w(space, offset - 0x7c00, data); return; }
@ -259,7 +252,7 @@ static WRITE8_HANDLER( lnc_w )
else if (offset >= 0xb000 && offset <= 0xb1ff) ; else if (offset >= 0xb000 && offset <= 0xb1ff) ;
else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset); else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset);
rambase[offset] = data; state->rambase[offset] = data;
/* Swap bits 5 & 6 for opcodes */ /* Swap bits 5 & 6 for opcodes */
decrypted[offset] = swap_bits_5_6(data); decrypted[offset] = swap_bits_5_6(data);
@ -267,6 +260,8 @@ static WRITE8_HANDLER( lnc_w )
static WRITE8_HANDLER( mmonkey_w ) static WRITE8_HANDLER( mmonkey_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
if (offset <= 0x3bff) ; if (offset <= 0x3bff) ;
else if (offset >= 0x3c00 && offset <= 0x3fff) { lnc_videoram_w(space, offset - 0x3c00, data); return; } else if (offset >= 0x3c00 && offset <= 0x3fff) { lnc_videoram_w(space, offset - 0x3c00, data); return; }
else if (offset >= 0x7c00 && offset <= 0x7fff) { lnc_mirrorvideoram_w(space, offset - 0x7c00, data); return; } else if (offset >= 0x7c00 && offset <= 0x7fff) { lnc_mirrorvideoram_w(space, offset - 0x7c00, data); return; }
@ -277,7 +272,7 @@ static WRITE8_HANDLER( mmonkey_w )
else if (offset >= 0xb000 && offset <= 0xbfff) { mmonkey_protection_w(space, offset - 0xb000, data); return; } else if (offset >= 0xb000 && offset <= 0xbfff) { mmonkey_protection_w(space, offset - 0xb000, data); return; }
else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset); else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset);
rambase[offset] = data; state->rambase[offset] = data;
/* Swap bits 5 & 6 for opcodes */ /* Swap bits 5 & 6 for opcodes */
decrypted[offset] = swap_bits_5_6(data); decrypted[offset] = swap_bits_5_6(data);
@ -285,6 +280,8 @@ static WRITE8_HANDLER( mmonkey_w )
static WRITE8_HANDLER( btime_w ) static WRITE8_HANDLER( btime_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
if (offset <= 0x07ff) ; if (offset <= 0x07ff) ;
else if (offset >= 0x0c00 && offset <= 0x0c0f) btime_paletteram_w(space, offset - 0x0c00, data); else if (offset >= 0x0c00 && offset <= 0x0c0f) btime_paletteram_w(space, offset - 0x0c00, data);
else if (offset >= 0x1000 && offset <= 0x17ff) ; else if (offset >= 0x1000 && offset <= 0x17ff) ;
@ -295,13 +292,15 @@ static WRITE8_HANDLER( btime_w )
else if (offset == 0x4004) bnj_scroll1_w(space, 0, data); else if (offset == 0x4004) bnj_scroll1_w(space, 0, data);
else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset); else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset);
rambase[offset] = data; state->rambase[offset] = data;
btime_decrypt(space); btime_decrypt(space);
} }
static WRITE8_HANDLER( tisland_w ) static WRITE8_HANDLER( tisland_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
if (offset <= 0x07ff) ; if (offset <= 0x07ff) ;
else if (offset >= 0x0c00 && offset <= 0x0c0f) btime_paletteram_w(space, offset - 0x0c00, data); else if (offset >= 0x0c00 && offset <= 0x0c0f) btime_paletteram_w(space, offset - 0x0c00, data);
else if (offset >= 0x1000 && offset <= 0x17ff) ; else if (offset >= 0x1000 && offset <= 0x17ff) ;
@ -314,14 +313,15 @@ static WRITE8_HANDLER( tisland_w )
// else if (offset == 0x8000) btime_video_control_w(space,0,data); // else if (offset == 0x8000) btime_video_control_w(space,0,data);
else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset); else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset);
state->rambase[offset] = data;
rambase[offset] = data;
btime_decrypt(space); btime_decrypt(space);
} }
static WRITE8_HANDLER( zoar_w ) static WRITE8_HANDLER( zoar_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
if (offset <= 0x07ff) ; if (offset <= 0x07ff) ;
else if (offset >= 0x8000 && offset <= 0x87ff) ; else if (offset >= 0x8000 && offset <= 0x87ff) ;
else if (offset >= 0x8800 && offset <= 0x8bff) btime_mirrorvideoram_w(space, offset - 0x8800, data); else if (offset >= 0x8800 && offset <= 0x8bff) btime_mirrorvideoram_w(space, offset - 0x8800, data);
@ -333,13 +333,15 @@ static WRITE8_HANDLER( zoar_w )
else if (offset == 0x9806) audio_command_w(space, 0, data); else if (offset == 0x9806) audio_command_w(space, 0, data);
else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset); else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset);
rambase[offset] = data; state->rambase[offset] = data;
btime_decrypt(space); btime_decrypt(space);
} }
static WRITE8_HANDLER( disco_w ) static WRITE8_HANDLER( disco_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
if (offset <= 0x04ff) ; if (offset <= 0x04ff) ;
else if (offset >= 0x2000 && offset <= 0x7fff) deco_charram_w(space, offset - 0x2000, data); else if (offset >= 0x2000 && offset <= 0x7fff) deco_charram_w(space, offset - 0x2000, data);
else if (offset >= 0x8000 && offset <= 0x881f) ; else if (offset >= 0x8000 && offset <= 0x881f) ;
@ -347,7 +349,7 @@ static WRITE8_HANDLER( disco_w )
else if (offset == 0x9c00) disco_video_control_w(space, 0, data); else if (offset == 0x9c00) disco_video_control_w(space, 0, data);
else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset); else logerror("CPU '%s' PC %04x: warning - write %02x to unmapped memory address %04x\n", space->cpu->tag, cpu_get_pc(space->cpu), data, offset);
rambase[offset] = data; state->rambase[offset] = data;
btime_decrypt(space); btime_decrypt(space);
} }
@ -356,10 +358,10 @@ static WRITE8_HANDLER( disco_w )
static ADDRESS_MAP_START( btime_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( btime_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xffff) AM_WRITE(btime_w) /* override the following entries to */ AM_RANGE(0x0000, 0xffff) AM_WRITE(btime_w) /* override the following entries to */
/* support ROM decryption */ /* support ROM decryption */
AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&rambase) AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(btime_state, rambase)
AM_RANGE(0x0c00, 0x0c0f) AM_WRITE(btime_paletteram_w) AM_BASE(&paletteram) AM_RANGE(0x0c00, 0x0c0f) AM_WRITE(btime_paletteram_w) AM_BASE(&paletteram)
AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&btime_colorram) AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE_MEMBER(btime_state, colorram)
AM_RANGE(0x1800, 0x1bff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w) AM_RANGE(0x1800, 0x1bff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w)
AM_RANGE(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w) AM_RANGE(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w)
AM_RANGE(0x4000, 0x4000) AM_READ_PORT("P1") AM_WRITENOP AM_RANGE(0x4000, 0x4000) AM_READ_PORT("P1") AM_WRITENOP
@ -371,15 +373,15 @@ static ADDRESS_MAP_START( btime_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( cookrace_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( cookrace_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE(&rambase) AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE_MEMBER(btime_state, rambase)
AM_RANGE(0x0500, 0x3fff) AM_ROM AM_RANGE(0x0500, 0x3fff) AM_ROM
AM_RANGE(0xc000, 0xc3ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0xc000, 0xc3ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE(&btime_colorram) AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE_MEMBER(btime_state, colorram)
AM_RANGE(0xc800, 0xcbff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w) AM_RANGE(0xc800, 0xcbff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w)
AM_RANGE(0xcc00, 0xcfff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w) AM_RANGE(0xcc00, 0xcfff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w)
AM_RANGE(0xd000, 0xd0ff) AM_RAM /* background? */ AM_RANGE(0xd000, 0xd0ff) AM_RAM /* background? */
AM_RANGE(0xd100, 0xd3ff) AM_RAM /* ? */ AM_RANGE(0xd100, 0xd3ff) AM_RAM /* ? */
AM_RANGE(0xd400, 0xd7ff) AM_RAM AM_BASE(&bnj_backgroundram) AM_SIZE(&bnj_backgroundram_size) AM_RANGE(0xd400, 0xd7ff) AM_RAM AM_BASE_MEMBER(btime_state, bnj_backgroundram) AM_SIZE_MEMBER(btime_state, bnj_backgroundram_size)
AM_RANGE(0xe000, 0xe000) AM_READ_PORT("DSW1") AM_WRITE(bnj_video_control_w) AM_RANGE(0xe000, 0xe000) AM_READ_PORT("DSW1") AM_WRITE(bnj_video_control_w)
AM_RANGE(0xe300, 0xe300) AM_READ_PORT("DSW1") /* mirror address used on high score name entry */ AM_RANGE(0xe300, 0xe300) AM_READ_PORT("DSW1") /* mirror address used on high score name entry */
/* screen */ /* screen */
@ -393,10 +395,10 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( tisland_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( tisland_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xffff) AM_WRITE(tisland_w) /* override the following entries to */ AM_RANGE(0x0000, 0xffff) AM_WRITE(tisland_w) /* override the following entries to */
/* support ROM decryption */ /* support ROM decryption */
AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&rambase) AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(btime_state, rambase)
AM_RANGE(0x0c00, 0x0c0f) AM_WRITE(btime_paletteram_w) AM_BASE(&paletteram) AM_RANGE(0x0c00, 0x0c0f) AM_WRITE(btime_paletteram_w) AM_BASE(&paletteram)
AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&btime_colorram) AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE_MEMBER(btime_state, colorram)
AM_RANGE(0x1800, 0x1bff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w) AM_RANGE(0x1800, 0x1bff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w)
AM_RANGE(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w) AM_RANGE(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w)
AM_RANGE(0x4000, 0x4000) AM_READ_PORT("P1") AM_WRITENOP AM_RANGE(0x4000, 0x4000) AM_READ_PORT("P1") AM_WRITENOP
@ -411,9 +413,9 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( zoar_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( zoar_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xffff) AM_WRITE(zoar_w) /* override the following entries to */ AM_RANGE(0x0000, 0xffff) AM_WRITE(zoar_w) /* override the following entries to */
/* support ROM decryption */ /* support ROM decryption */
AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&rambase) AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(btime_state, rambase)
AM_RANGE(0x8000, 0x83ff) AM_WRITEONLY AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x8000, 0x83ff) AM_WRITEONLY AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x8400, 0x87ff) AM_WRITEONLY AM_BASE(&btime_colorram) AM_RANGE(0x8400, 0x87ff) AM_WRITEONLY AM_BASE_MEMBER(btime_state, colorram)
AM_RANGE(0x8800, 0x8bff) AM_WRITE(btime_mirrorvideoram_w) AM_RANGE(0x8800, 0x8bff) AM_WRITE(btime_mirrorvideoram_w)
AM_RANGE(0x8c00, 0x8fff) AM_WRITE(btime_mirrorcolorram_w) AM_RANGE(0x8c00, 0x8fff) AM_WRITE(btime_mirrorcolorram_w)
AM_RANGE(0x9000, 0x9000) AM_WRITE(zoar_video_control_w) AM_RANGE(0x9000, 0x9000) AM_WRITE(zoar_video_control_w)
@ -421,7 +423,7 @@ static ADDRESS_MAP_START( zoar_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x9801, 0x9801) AM_READ_PORT("DSW2") AM_RANGE(0x9801, 0x9801) AM_READ_PORT("DSW2")
AM_RANGE(0x9802, 0x9802) AM_READ_PORT("P1") AM_RANGE(0x9802, 0x9802) AM_READ_PORT("P1")
AM_RANGE(0x9803, 0x9803) AM_READ_PORT("P2") AM_RANGE(0x9803, 0x9803) AM_READ_PORT("P2")
AM_RANGE(0x9800, 0x9803) AM_WRITEONLY AM_BASE(&zoar_scrollram) AM_RANGE(0x9800, 0x9803) AM_WRITEONLY AM_BASE_MEMBER(btime_state, zoar_scrollram)
AM_RANGE(0x9804, 0x9804) AM_READ_PORT("SYSTEM") AM_WRITE(bnj_scroll2_w) AM_RANGE(0x9804, 0x9804) AM_READ_PORT("SYSTEM") AM_WRITE(bnj_scroll2_w)
AM_RANGE(0x9805, 0x9805) AM_WRITE(bnj_scroll1_w) AM_RANGE(0x9805, 0x9805) AM_WRITE(bnj_scroll1_w)
AM_RANGE(0x9806, 0x9806) AM_WRITE(audio_command_w) AM_RANGE(0x9806, 0x9806) AM_WRITE(audio_command_w)
@ -431,13 +433,13 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( lnc_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( lnc_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xffff) AM_WRITE(lnc_w) /* override the following entries to */ AM_RANGE(0x0000, 0xffff) AM_WRITE(lnc_w) /* override the following entries to */
/* support ROM decryption */ /* support ROM decryption */
AM_RANGE(0x0000, 0x3bff) AM_RAM AM_BASE(&rambase) AM_RANGE(0x0000, 0x3bff) AM_RAM AM_BASE_MEMBER(btime_state, rambase)
AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(lnc_videoram_w) AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(lnc_videoram_w) AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x7800, 0x7bff) AM_WRITEONLY AM_BASE(&btime_colorram) /* this is just here to initialize the pointer */ AM_RANGE(0x7800, 0x7bff) AM_WRITEONLY AM_BASE_MEMBER(btime_state, colorram) /* this is just here to initialize the pointer */
AM_RANGE(0x7c00, 0x7fff) AM_READWRITE(btime_mirrorvideoram_r, lnc_mirrorvideoram_w) AM_RANGE(0x7c00, 0x7fff) AM_READWRITE(btime_mirrorvideoram_r, lnc_mirrorvideoram_w)
AM_RANGE(0x8000, 0x8000) AM_READ_PORT("DSW1") AM_WRITENOP /* ??? */ AM_RANGE(0x8000, 0x8000) AM_READ_PORT("DSW1") AM_WRITENOP /* ??? */
AM_RANGE(0x8001, 0x8001) AM_READ_PORT("DSW2") AM_WRITE(bnj_video_control_w) AM_RANGE(0x8001, 0x8001) AM_READ_PORT("DSW2") AM_WRITE(bnj_video_control_w)
AM_RANGE(0x8003, 0x8003) AM_WRITEONLY AM_BASE(&lnc_charbank) AM_RANGE(0x8003, 0x8003) AM_WRITEONLY AM_BASE_MEMBER(btime_state, lnc_charbank)
AM_RANGE(0x9000, 0x9000) AM_READ_PORT("P1") AM_WRITENOP /* IRQ ack??? */ AM_RANGE(0x9000, 0x9000) AM_READ_PORT("P1") AM_WRITENOP /* IRQ ack??? */
AM_RANGE(0x9001, 0x9001) AM_READ_PORT("P2") AM_RANGE(0x9001, 0x9001) AM_READ_PORT("P2")
AM_RANGE(0x9002, 0x9002) AM_READ_PORT("SYSTEM") AM_WRITE(audio_command_w) AM_RANGE(0x9002, 0x9002) AM_READ_PORT("SYSTEM") AM_WRITE(audio_command_w)
@ -448,13 +450,13 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( mmonkey_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( mmonkey_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xffff) AM_WRITE(mmonkey_w) /* override the following entries to */ AM_RANGE(0x0000, 0xffff) AM_WRITE(mmonkey_w) /* override the following entries to */
/* support ROM decryption */ /* support ROM decryption */
AM_RANGE(0x0000, 0x3bff) AM_RAM AM_BASE(&rambase) AM_RANGE(0x0000, 0x3bff) AM_RAM AM_BASE_MEMBER(btime_state, rambase)
AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(lnc_videoram_w) AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(lnc_videoram_w) AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x7800, 0x7bff) AM_WRITEONLY AM_BASE(&btime_colorram) /* this is just here to initialize the pointer */ AM_RANGE(0x7800, 0x7bff) AM_WRITEONLY AM_BASE_MEMBER(btime_state, colorram) /* this is just here to initialize the pointer */
AM_RANGE(0x7c00, 0x7fff) AM_READWRITE(btime_mirrorvideoram_r, lnc_mirrorvideoram_w) AM_RANGE(0x7c00, 0x7fff) AM_READWRITE(btime_mirrorvideoram_r, lnc_mirrorvideoram_w)
AM_RANGE(0x8000, 0x8000) AM_READ_PORT("DSW1") AM_RANGE(0x8000, 0x8000) AM_READ_PORT("DSW1")
AM_RANGE(0x8001, 0x8001) AM_READ_PORT("DSW2") AM_WRITE(bnj_video_control_w) AM_RANGE(0x8001, 0x8001) AM_READ_PORT("DSW2") AM_WRITE(bnj_video_control_w)
AM_RANGE(0x8003, 0x8003) AM_WRITEONLY AM_BASE(&lnc_charbank) AM_RANGE(0x8003, 0x8003) AM_WRITEONLY AM_BASE_MEMBER(btime_state, lnc_charbank)
AM_RANGE(0x9000, 0x9000) AM_READ_PORT("P1") AM_WRITENOP /* IRQ ack??? */ AM_RANGE(0x9000, 0x9000) AM_READ_PORT("P1") AM_WRITENOP /* IRQ ack??? */
AM_RANGE(0x9001, 0x9001) AM_READ_PORT("P2") AM_RANGE(0x9001, 0x9001) AM_READ_PORT("P2")
AM_RANGE(0x9002, 0x9002) AM_READ_PORT("SYSTEM") AM_WRITE(audio_command_w) AM_RANGE(0x9002, 0x9002) AM_READ_PORT("SYSTEM") AM_WRITE(audio_command_w)
@ -463,17 +465,17 @@ static ADDRESS_MAP_START( mmonkey_map, ADDRESS_SPACE_PROGRAM, 8 )
ADDRESS_MAP_END ADDRESS_MAP_END
static ADDRESS_MAP_START( bnj_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( bnj_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&rambase) AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(btime_state, rambase)
AM_RANGE(0x1000, 0x1000) AM_READ_PORT("DSW1") AM_RANGE(0x1000, 0x1000) AM_READ_PORT("DSW1")
AM_RANGE(0x1001, 0x1001) AM_READ_PORT("DSW2") AM_WRITE(bnj_video_control_w) AM_RANGE(0x1001, 0x1001) AM_READ_PORT("DSW2") AM_WRITE(bnj_video_control_w)
AM_RANGE(0x1002, 0x1002) AM_READ_PORT("P1") AM_WRITE(audio_command_w) AM_RANGE(0x1002, 0x1002) AM_READ_PORT("P1") AM_WRITE(audio_command_w)
AM_RANGE(0x1003, 0x1003) AM_READ_PORT("P2") AM_RANGE(0x1003, 0x1003) AM_READ_PORT("P2")
AM_RANGE(0x1004, 0x1004) AM_READ_PORT("SYSTEM") AM_RANGE(0x1004, 0x1004) AM_READ_PORT("SYSTEM")
AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x4400, 0x47ff) AM_RAM AM_BASE(&btime_colorram) AM_RANGE(0x4400, 0x47ff) AM_RAM AM_BASE_MEMBER(btime_state, colorram)
AM_RANGE(0x4800, 0x4bff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w) AM_RANGE(0x4800, 0x4bff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w)
AM_RANGE(0x4c00, 0x4fff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w) AM_RANGE(0x4c00, 0x4fff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w)
AM_RANGE(0x5000, 0x51ff) AM_WRITE(bnj_background_w) AM_BASE(&bnj_backgroundram) AM_SIZE(&bnj_backgroundram_size) AM_RANGE(0x5000, 0x51ff) AM_WRITE(bnj_background_w) AM_BASE_MEMBER(btime_state, bnj_backgroundram) AM_SIZE_MEMBER(btime_state, bnj_backgroundram_size)
AM_RANGE(0x5400, 0x5400) AM_WRITE(bnj_scroll1_w) AM_RANGE(0x5400, 0x5400) AM_WRITE(bnj_scroll1_w)
AM_RANGE(0x5800, 0x5800) AM_WRITE(bnj_scroll2_w) AM_RANGE(0x5800, 0x5800) AM_WRITE(bnj_scroll2_w)
AM_RANGE(0x5c00, 0x5c0f) AM_WRITE(btime_paletteram_w) AM_BASE(&paletteram) AM_RANGE(0x5c00, 0x5c0f) AM_WRITE(btime_paletteram_w) AM_BASE(&paletteram)
@ -483,11 +485,11 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( disco_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( disco_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0xffff) AM_WRITE(disco_w) /* override the following entries to */ AM_RANGE(0x0000, 0xffff) AM_WRITE(disco_w) /* override the following entries to */
/* support ROM decryption */ /* support ROM decryption */
AM_RANGE(0x0000, 0x04ff) AM_RAM AM_BASE(&rambase) AM_RANGE(0x0000, 0x04ff) AM_RAM AM_BASE_MEMBER(btime_state, rambase)
AM_RANGE(0x2000, 0x7fff) AM_RAM_WRITE(deco_charram_w) AM_BASE(&deco_charram) AM_RANGE(0x2000, 0x7fff) AM_RAM_WRITE(deco_charram_w) AM_BASE_MEMBER(btime_state, deco_charram)
AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x8400, 0x87ff) AM_RAM AM_BASE(&btime_colorram) AM_RANGE(0x8400, 0x87ff) AM_RAM AM_BASE_MEMBER(btime_state, colorram)
AM_RANGE(0x8800, 0x881f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) AM_RANGE(0x8800, 0x881f) AM_RAM AM_BASE_MEMBER(btime_state, spriteram) AM_SIZE(&spriteram_size)
AM_RANGE(0x9000, 0x9000) AM_READ_PORT("SYSTEM") AM_RANGE(0x9000, 0x9000) AM_READ_PORT("SYSTEM")
AM_RANGE(0x9200, 0x9200) AM_READ_PORT("P1") AM_RANGE(0x9200, 0x9200) AM_READ_PORT("P1")
AM_RANGE(0x9400, 0x9400) AM_READ_PORT("P2") AM_RANGE(0x9400, 0x9400) AM_READ_PORT("P2")
@ -500,7 +502,7 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( audio_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( audio_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM AM_BASE(&audio_rambase) AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x1c00) AM_RAM AM_BASE_MEMBER(btime_state, audio_rambase)
AM_RANGE(0x2000, 0x3fff) AM_DEVWRITE("ay1", ay8910_data_w) AM_RANGE(0x2000, 0x3fff) AM_DEVWRITE("ay1", ay8910_data_w)
AM_RANGE(0x4000, 0x5fff) AM_DEVWRITE("ay1", ay8910_address_w) AM_RANGE(0x4000, 0x5fff) AM_DEVWRITE("ay1", ay8910_address_w)
AM_RANGE(0x6000, 0x7fff) AM_DEVWRITE("ay2", ay8910_data_w) AM_RANGE(0x6000, 0x7fff) AM_DEVWRITE("ay2", ay8910_data_w)
@ -523,31 +525,38 @@ ADDRESS_MAP_END
static INPUT_CHANGED( coin_inserted_irq_hi ) static INPUT_CHANGED( coin_inserted_irq_hi )
{ {
btime_state *state = (btime_state *)field->port->machine->driver_data;
if (newval) if (newval)
cputag_set_input_line(field->port->machine, "maincpu", 0, HOLD_LINE); cpu_set_input_line(state->maincpu, 0, HOLD_LINE);
} }
static INPUT_CHANGED( coin_inserted_irq_lo ) static INPUT_CHANGED( coin_inserted_irq_lo )
{ {
btime_state *state = (btime_state *)field->port->machine->driver_data;
if (!newval) if (!newval)
cputag_set_input_line(field->port->machine, "maincpu", 0, HOLD_LINE); cpu_set_input_line(state->maincpu, 0, HOLD_LINE);
} }
static INPUT_CHANGED( coin_inserted_nmi_lo ) static INPUT_CHANGED( coin_inserted_nmi_lo )
{ {
cputag_set_input_line(field->port->machine, "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); btime_state *state = (btime_state *)field->port->machine->driver_data;
cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
} }
static WRITE8_HANDLER( audio_command_w ) static WRITE8_HANDLER( audio_command_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
soundlatch_w(space, offset, data); soundlatch_w(space, offset, data);
cputag_set_input_line(space->machine, "audiocpu", 0, ASSERT_LINE); cpu_set_input_line(state->audiocpu, 0, ASSERT_LINE);
} }
static READ8_HANDLER( audio_command_r ) static READ8_HANDLER( audio_command_r )
{ {
cputag_set_input_line(space->machine, "audiocpu", 0, CLEAR_LINE); btime_state *state = (btime_state *)space->machine->driver_data;
cpu_set_input_line(state->audiocpu, 0, CLEAR_LINE);
return soundlatch_r(space, offset); return soundlatch_r(space, offset);
} }
@ -1412,8 +1421,75 @@ static DISCRETE_SOUND_START( btime_sound )
DISCRETE_SOUND_END DISCRETE_SOUND_END
static MACHINE_START( btime )
{
btime_state *state = (btime_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = devtag_get_device(machine, "audiocpu");
state_save_register_global(machine, state->btime_palette);
state_save_register_global(machine, state->bnj_scroll1);
state_save_register_global(machine, state->bnj_scroll2);
state_save_register_global_array(machine, state->btime_tilemap);
state_save_register_global(machine, state->audio_nmi_enabled);
state_save_register_global(machine, state->audio_nmi_state);
}
static MACHINE_START( mmonkey )
{
btime_state *state = (btime_state *)machine->driver_data;
MACHINE_START_CALL(btime);
state_save_register_global(machine, state->protection_command);
state_save_register_global(machine, state->protection_status);
state_save_register_global(machine, state->protection_value);
state_save_register_global(machine, state->protection_ret);
}
MACHINE_RESET( btime )
{
btime_state *state = (btime_state *)machine->driver_data;
/* by default, the audio NMI is disabled, except for bootlegs which don't use the enable */
state->audio_nmi_enabled = (state->audio_nmi_enable_type == AUDIO_ENABLE_NONE);
state->btime_palette = 0;
state->bnj_scroll1 = 0;
state->bnj_scroll2 = 0;
state->btime_tilemap[0] = 0;
state->btime_tilemap[1] = 0;
state->btime_tilemap[2] = 0;
state->btime_tilemap[3] = 0;
state->audio_nmi_state = 0;
}
MACHINE_RESET( lnc )
{
btime_state *state = (btime_state *)machine->driver_data;
*state->lnc_charbank = 1;
MACHINE_RESET_CALL(btime);
}
MACHINE_RESET( mmonkey )
{
btime_state *state = (btime_state *)machine->driver_data;
MACHINE_RESET_CALL(lnc);
state->protection_command = 0;
state->protection_status = 0;
state->protection_value = 0;
state->protection_ret = 0;
}
static MACHINE_DRIVER_START( btime ) static MACHINE_DRIVER_START( btime )
/* driver data */
MDRV_DRIVER_DATA(btime_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, HCLK2) /* seletable between H2/H4 via jumper */ MDRV_CPU_ADD("maincpu", M6502, HCLK2) /* seletable between H2/H4 via jumper */
MDRV_CPU_PROGRAM_MAP(btime_map) MDRV_CPU_PROGRAM_MAP(btime_map)
@ -1428,6 +1504,7 @@ static MACHINE_DRIVER_START( btime )
MDRV_SCREEN_RAW_PARAMS(HCLK, 384, 8, 248, 272, 8, 248) MDRV_SCREEN_RAW_PARAMS(HCLK, 384, 8, 248, 272, 8, 248)
MDRV_MACHINE_START(btime) MDRV_MACHINE_START(btime)
MDRV_MACHINE_RESET(btime)
MDRV_GFXDECODE(btime) MDRV_GFXDECODE(btime)
MDRV_PALETTE_LENGTH(16) MDRV_PALETTE_LENGTH(16)
@ -1509,6 +1586,9 @@ static MACHINE_DRIVER_START( mmonkey )
MDRV_IMPORT_FROM(wtennis) MDRV_IMPORT_FROM(wtennis)
MDRV_CPU_MODIFY("maincpu") MDRV_CPU_MODIFY("maincpu")
MDRV_CPU_PROGRAM_MAP(mmonkey_map) MDRV_CPU_PROGRAM_MAP(mmonkey_map)
MDRV_MACHINE_START(mmonkey)
MDRV_MACHINE_RESET(mmonkey)
MACHINE_DRIVER_END MACHINE_DRIVER_END
@ -2024,12 +2104,14 @@ static void init_rom1(running_machine *machine)
static DRIVER_INIT( btime ) static DRIVER_INIT( btime )
{ {
btime_state *state = (btime_state *)machine->driver_data;
init_rom1(machine); init_rom1(machine);
audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; state->audio_nmi_enable_type = AUDIO_ENABLE_DIRECT;
} }
static DRIVER_INIT( zoar ) static DRIVER_INIT( zoar )
{ {
btime_state *state = (btime_state *)machine->driver_data;
UINT8 *rom = memory_region(machine, "maincpu"); UINT8 *rom = memory_region(machine, "maincpu");
/* At location 0xD50A is what looks like an undocumented opcode. I tried /* At location 0xD50A is what looks like an undocumented opcode. I tried
@ -2039,11 +2121,12 @@ static DRIVER_INIT( zoar )
memset(&rom[0xd50a],0xea,8); memset(&rom[0xd50a],0xea,8);
init_rom1(machine); init_rom1(machine);
audio_nmi_enable_type = AUDIO_ENABLE_AY8910; state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910;
} }
static DRIVER_INIT( tisland ) static DRIVER_INIT( tisland )
{ {
btime_state *state = (btime_state *)machine->driver_data;
UINT8 *rom = memory_region(machine, "maincpu"); UINT8 *rom = memory_region(machine, "maincpu");
/* At location 0xa2b6 there's a strange RLA followed by a BPL that reads from an /* At location 0xa2b6 there's a strange RLA followed by a BPL that reads from an
@ -2053,74 +2136,81 @@ static DRIVER_INIT( tisland )
memset(&rom[0xa2b6],0x24,1); memset(&rom[0xa2b6],0x24,1);
init_rom1(machine); init_rom1(machine);
audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; state->audio_nmi_enable_type = AUDIO_ENABLE_DIRECT;
} }
static DRIVER_INIT( lnc ) static DRIVER_INIT( lnc )
{ {
btime_state *state = (btime_state *)machine->driver_data;
decrypt_C10707_cpu(machine, "maincpu"); decrypt_C10707_cpu(machine, "maincpu");
audio_nmi_enable_type = AUDIO_ENABLE_AY8910; state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910;
} }
static DRIVER_INIT( bnj ) static DRIVER_INIT( bnj )
{ {
btime_state *state = (btime_state *)machine->driver_data;
decrypt_C10707_cpu(machine, "maincpu"); decrypt_C10707_cpu(machine, "maincpu");
audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; state->audio_nmi_enable_type = AUDIO_ENABLE_DIRECT;
} }
static DRIVER_INIT( disco ) static DRIVER_INIT( disco )
{ {
btime_state *state = (btime_state *)machine->driver_data;
DRIVER_INIT_CALL(btime); DRIVER_INIT_CALL(btime);
audio_nmi_enable_type = AUDIO_ENABLE_AY8910; state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910;
} }
static DRIVER_INIT( cookrace ) static DRIVER_INIT( cookrace )
{ {
btime_state *state = (btime_state *)machine->driver_data;
decrypt_C10707_cpu(machine, "maincpu"); decrypt_C10707_cpu(machine, "maincpu");
memory_install_read8_handler(cputag_get_address_space(machine, "audiocpu", ADDRESS_SPACE_PROGRAM), 0x0200, 0x0fff, 0, 0, (read8_space_func)SMH_BANK(10)); memory_install_read8_handler(cputag_get_address_space(machine, "audiocpu", ADDRESS_SPACE_PROGRAM), 0x0200, 0x0fff, 0, 0, (read8_space_func)SMH_BANK(10));
memory_set_bankptr(machine, 10, memory_region(machine, "audiocpu") + 0xe200); memory_set_bankptr(machine, 10, memory_region(machine, "audiocpu") + 0xe200);
audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; state->audio_nmi_enable_type = AUDIO_ENABLE_DIRECT;
} }
static DRIVER_INIT( protennb ) static DRIVER_INIT( protennb )
{ {
btime_state *state = (btime_state *)machine->driver_data;
DRIVER_INIT_CALL(btime); DRIVER_INIT_CALL(btime);
audio_nmi_enable_type = AUDIO_ENABLE_AY8910; state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910;
} }
static DRIVER_INIT( wtennis ) static DRIVER_INIT( wtennis )
{ {
btime_state *state = (btime_state *)machine->driver_data;
decrypt_C10707_cpu(machine, "maincpu"); decrypt_C10707_cpu(machine, "maincpu");
memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc15f, 0xc15f, 0, 0, wtennis_reset_hack_r); memory_install_read8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc15f, 0xc15f, 0, 0, wtennis_reset_hack_r);
memory_install_read8_handler(cputag_get_address_space(machine, "audiocpu", ADDRESS_SPACE_PROGRAM), 0x0200, 0x0fff, 0, 0, (read8_space_func)SMH_BANK(10)); memory_install_read8_handler(cputag_get_address_space(machine, "audiocpu", ADDRESS_SPACE_PROGRAM), 0x0200, 0x0fff, 0, 0, (read8_space_func)SMH_BANK(10));
memory_set_bankptr(machine, 10, memory_region(machine, "audiocpu") + 0xe200); memory_set_bankptr(machine, 10, memory_region(machine, "audiocpu") + 0xe200);
audio_nmi_enable_type = AUDIO_ENABLE_AY8910; state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910;
} }
static DRIVER_INIT( sdtennis ) static DRIVER_INIT( sdtennis )
{ {
btime_state *state = (btime_state *)machine->driver_data;
decrypt_C10707_cpu(machine, "maincpu"); decrypt_C10707_cpu(machine, "maincpu");
decrypt_C10707_cpu(machine, "audiocpu"); decrypt_C10707_cpu(machine, "audiocpu");
audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; state->audio_nmi_enable_type = AUDIO_ENABLE_DIRECT;
} }
GAME( 1982, btime, 0, btime, btime, btime, ROT270, "Data East Corporation", "Burger Time (Data East set 1)", 0 ) GAME( 1982, btime, 0, btime, btime, btime, ROT270, "Data East Corporation", "Burger Time (Data East set 1)", GAME_SUPPORTS_SAVE )
GAME( 1982, btime2, btime, btime, btime, btime, ROT270, "Data East Corporation", "Burger Time (Data East set 2)", 0 ) GAME( 1982, btime2, btime, btime, btime, btime, ROT270, "Data East Corporation", "Burger Time (Data East set 2)", GAME_SUPPORTS_SAVE )
GAME( 1982, btimem, btime, btime, btime, btime, ROT270, "Data East (Bally Midway license)", "Burger Time (Midway)", 0 ) GAME( 1982, btimem, btime, btime, btime, btime, ROT270, "Data East (Bally Midway license)", "Burger Time (Midway)", GAME_SUPPORTS_SAVE )
GAME( 1982, cookrace, btime, cookrace, cookrace, cookrace, ROT270, "bootleg", "Cook Race", 0 ) GAME( 1982, cookrace, btime, cookrace, cookrace, cookrace, ROT270, "bootleg", "Cook Race", GAME_SUPPORTS_SAVE )
GAME( 1981, tisland, 0, tisland, btime, tisland, ROT270, "Data East Corporation", "Treasure Island", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS ) GAME( 1981, tisland, 0, tisland, btime, tisland, ROT270, "Data East Corporation", "Treasure Island", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
GAME( 1981, lnc, 0, lnc, lnc, lnc, ROT270, "Data East Corporation", "Lock'n'Chase", 0 ) GAME( 1981, lnc, 0, lnc, lnc, lnc, ROT270, "Data East Corporation", "Lock'n'Chase", GAME_SUPPORTS_SAVE )
GAME( 1982, protennb, 0, disco, disco, protennb, ROT270, "bootleg", "Tennis (bootleg of Pro Tennis)", 0 ) GAME( 1982, protennb, 0, disco, disco, protennb, ROT270, "bootleg", "Tennis (bootleg of Pro Tennis)", GAME_SUPPORTS_SAVE )
GAME( 1982, wtennis, 0, wtennis, wtennis, wtennis, ROT270, "bootleg", "World Tennis", 0 ) GAME( 1982, wtennis, 0, wtennis, wtennis, wtennis, ROT270, "bootleg", "World Tennis", GAME_SUPPORTS_SAVE )
GAME( 1982, mmonkey, 0, mmonkey, mmonkey, lnc, ROT270, "Technos Japan + Roller Tron", "Minky Monkey", 0 ) GAME( 1982, mmonkey, 0, mmonkey, mmonkey, lnc, ROT270, "Technos Japan + Roller Tron", "Minky Monkey", GAME_SUPPORTS_SAVE )
GAME( 1982, brubber, 0, bnj, bnj, bnj, ROT270, "Data East", "Burnin' Rubber", 0 ) GAME( 1982, brubber, 0, bnj, bnj, bnj, ROT270, "Data East", "Burnin' Rubber", GAME_SUPPORTS_SAVE )
GAME( 1982, bnj, brubber, bnj, bnj, bnj, ROT270, "Data East USA (Bally Midway license)", "Bump 'n' Jump", 0 ) GAME( 1982, bnj, brubber, bnj, bnj, bnj, ROT270, "Data East USA (Bally Midway license)", "Bump 'n' Jump", GAME_SUPPORTS_SAVE )
GAME( 1982, caractn, brubber, bnj, bnj, bnj, ROT270, "bootleg", "Car Action", 0 ) GAME( 1982, caractn, brubber, bnj, bnj, bnj, ROT270, "bootleg", "Car Action", GAME_SUPPORTS_SAVE )
GAME( 1982, zoar, 0, zoar, zoar, zoar, ROT270, "Data East USA", "Zoar", 0 ) GAME( 1982, zoar, 0, zoar, zoar, zoar, ROT270, "Data East USA", "Zoar", GAME_SUPPORTS_SAVE )
GAME( 1982, disco, 0, disco, disco, disco, ROT270, "Data East", "Disco No.1", 0 ) GAME( 1982, disco, 0, disco, disco, disco, ROT270, "Data East", "Disco No.1", GAME_SUPPORTS_SAVE )
GAME( 1982, discof, disco, disco, disco, disco, ROT270, "Data East", "Disco No.1 (Rev.F)", 0 ) GAME( 1982, discof, disco, disco, disco, disco, ROT270, "Data East", "Disco No.1 (Rev.F)", GAME_SUPPORTS_SAVE )
GAME( 1983, sdtennis, 0, bnj, sdtennis, sdtennis, ROT270, "Data East Corporation", "Super Doubles Tennis", 0 ) GAME( 1983, sdtennis, 0, bnj, sdtennis, sdtennis, ROT270, "Data East Corporation", "Super Doubles Tennis", GAME_SUPPORTS_SAVE )

View File

@ -57,8 +57,8 @@ it as ASCII text.
static ADDRESS_MAP_START( dommy_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( dommy_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x07ff) AM_RAM AM_RANGE(0x0000, 0x07ff) AM_RAM
AM_RANGE(0x2000, 0x23ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x2000, 0x23ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x2400, 0x27ff) AM_RAM AM_BASE(&btime_colorram) AM_RANGE(0x2400, 0x27ff) AM_RAM AM_BASE_MEMBER(btime_state, colorram)
AM_RANGE(0x2800, 0x2bff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w) AM_RANGE(0x2800, 0x2bff) AM_READWRITE(btime_mirrorvideoram_r, btime_mirrorvideoram_w)
AM_RANGE(0x4000, 0x4000) AM_READ_PORT("DSW1") AM_WRITENOP AM_RANGE(0x4000, 0x4000) AM_READ_PORT("DSW1") AM_WRITENOP
AM_RANGE(0x4001, 0x4001) AM_READ_PORT("DSW2") AM_WRITE(btime_video_control_w) AM_RANGE(0x4001, 0x4001) AM_READ_PORT("DSW2") AM_WRITE(btime_video_control_w)
@ -73,8 +73,8 @@ ADDRESS_MAP_END
static ADDRESS_MAP_START( eggs_map, ADDRESS_SPACE_PROGRAM, 8 ) static ADDRESS_MAP_START( eggs_map, ADDRESS_SPACE_PROGRAM, 8 )
AM_RANGE(0x0000, 0x07ff) AM_RAM AM_RANGE(0x0000, 0x07ff) AM_RAM
AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size)
AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&btime_colorram) AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE_MEMBER(btime_state, colorram)
AM_RANGE(0x1800, 0x1bff) AM_READWRITE(btime_mirrorvideoram_r,btime_mirrorvideoram_w) AM_RANGE(0x1800, 0x1bff) AM_READWRITE(btime_mirrorvideoram_r,btime_mirrorvideoram_w)
AM_RANGE(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r,btime_mirrorcolorram_w) AM_RANGE(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r,btime_mirrorcolorram_w)
AM_RANGE(0x2000, 0x2000) AM_READ_PORT("DSW1") AM_WRITE(btime_video_control_w) AM_RANGE(0x2000, 0x2000) AM_READ_PORT("DSW1") AM_WRITE(btime_video_control_w)
@ -200,13 +200,45 @@ GFXDECODE_END
static MACHINE_START( scregg )
{
btime_state *state = (btime_state *)machine->driver_data;
state->maincpu = devtag_get_device(machine, "maincpu");
state->audiocpu = NULL;
state_save_register_global(machine, state->btime_palette);
state_save_register_global(machine, state->bnj_scroll1);
state_save_register_global(machine, state->bnj_scroll2);
state_save_register_global_array(machine, state->btime_tilemap);
}
MACHINE_RESET( scregg )
{
btime_state *state = (btime_state *)machine->driver_data;
state->btime_palette = 0;
state->bnj_scroll1 = 0;
state->bnj_scroll2 = 0;
state->btime_tilemap[0] = 0;
state->btime_tilemap[1] = 0;
state->btime_tilemap[2] = 0;
state->btime_tilemap[3] = 0;
}
static MACHINE_DRIVER_START( dommy ) static MACHINE_DRIVER_START( dommy )
/* driver data */
MDRV_DRIVER_DATA(btime_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, 1500000) MDRV_CPU_ADD("maincpu", M6502, 1500000)
MDRV_CPU_PROGRAM_MAP(dommy_map) MDRV_CPU_PROGRAM_MAP(dommy_map)
MDRV_CPU_PERIODIC_INT(irq0_line_hold,16*60) //??? MDRV_CPU_PERIODIC_INT(irq0_line_hold,16*60) //???
MDRV_MACHINE_START(scregg)
MDRV_MACHINE_RESET(scregg)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(57) MDRV_SCREEN_REFRESH_RATE(57)
@ -235,11 +267,17 @@ MACHINE_DRIVER_END
static MACHINE_DRIVER_START( scregg ) static MACHINE_DRIVER_START( scregg )
/* driver data */
MDRV_DRIVER_DATA(btime_state)
/* basic machine hardware */ /* basic machine hardware */
MDRV_CPU_ADD("maincpu", M6502, 1500000) MDRV_CPU_ADD("maincpu", M6502, 1500000)
MDRV_CPU_PROGRAM_MAP(eggs_map) MDRV_CPU_PROGRAM_MAP(eggs_map)
MDRV_CPU_PERIODIC_INT(irq0_line_hold,16*60) //??? MDRV_CPU_PERIODIC_INT(irq0_line_hold,16*60) //???
MDRV_MACHINE_START(scregg)
MDRV_MACHINE_RESET(scregg)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(57) MDRV_SCREEN_REFRESH_RATE(57)
@ -369,7 +407,7 @@ static DRIVER_INIT( rockduck )
} }
GAME( 1983, dommy, 0, dommy, scregg, 0, ROT270, "Technos Japan", "Dommy", 0 ) GAME( 1983, dommy, 0, dommy, scregg, 0, ROT270, "Technos Japan", "Dommy", GAME_SUPPORTS_SAVE )
GAME( 1983, scregg, 0, scregg, scregg, 0, ROT270, "Technos Japan", "Scrambled Egg", 0 ) GAME( 1983, scregg, 0, scregg, scregg, 0, ROT270, "Technos Japan", "Scrambled Egg", GAME_SUPPORTS_SAVE )
GAME( 1983, eggs, scregg, scregg, scregg, 0, ROT270, "[Technos Japan] Universal USA", "Eggs", 0 ) GAME( 1983, eggs, scregg, scregg, scregg, 0, ROT270, "[Technos Japan] Universal USA", "Eggs", GAME_SUPPORTS_SAVE )
GAME( 1983, rockduck, 0, scregg, rockduck, rockduck, ROT270, "Datel SAS", "Rock Duck (prototype?)", GAME_WRONG_COLORS ) GAME( 1983, rockduck, 0, scregg, rockduck, rockduck, ROT270, "Datel SAS", "Rock Duck (prototype?)", GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE )

View File

@ -1,3 +1,45 @@
typedef struct _btime_state btime_state;
struct _btime_state
{
/* memory pointers */
UINT8 * videoram;
UINT8 * colorram;
// UINT8 * paletteram; // currently this uses generic palette handling
UINT8 * lnc_charbank;
UINT8 * bnj_backgroundram;
UINT8 * zoar_scrollram;
UINT8 * deco_charram;
UINT8 * spriteram; // used by disco
size_t bnj_backgroundram_size;
// UINT8 * decrypted;
UINT8 * rambase;
UINT8 * audio_rambase;
/* video-related */
bitmap_t *background_bitmap;
UINT8 btime_palette;
UINT8 bnj_scroll1;
UINT8 bnj_scroll2;
UINT8 btime_tilemap[4];
/* audio-related */
UINT8 audio_nmi_enable_type;
UINT8 audio_nmi_enabled;
UINT8 audio_nmi_state;
/* protection-related (for mmonkey) */
int protection_command;
int protection_status;
int protection_value;
int protection_ret;
/* devices */
const device_config *maincpu;
const device_config *audiocpu;
};
/*----------- defined in machine/btime.c -----------*/ /*----------- defined in machine/btime.c -----------*/
READ8_HANDLER( mmonkey_protection_r ); READ8_HANDLER( mmonkey_protection_r );
@ -6,15 +48,6 @@ WRITE8_HANDLER( mmonkey_protection_w );
/*----------- defined in video/btime.c -----------*/ /*----------- defined in video/btime.c -----------*/
extern UINT8 *btime_videoram;
extern size_t btime_videoram_size;
extern UINT8 *btime_colorram;
extern UINT8 *lnc_charbank;
extern UINT8 *bnj_backgroundram;
extern size_t bnj_backgroundram_size;
extern UINT8 *zoar_scrollram;
extern UINT8 *deco_charram;
PALETTE_INIT( btime ); PALETTE_INIT( btime );
PALETTE_INIT( lnc ); PALETTE_INIT( lnc );

View File

@ -4,34 +4,29 @@
#define BASE 0xb000 #define BASE 0xb000
static int protection_command;
static int protection_status = 0;
static int protection_value;
static int protection_ret = 0;
READ8_HANDLER( mmonkey_protection_r ) READ8_HANDLER( mmonkey_protection_r )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
UINT8 *RAM = memory_region(space->machine, "maincpu"); UINT8 *RAM = memory_region(space->machine, "maincpu");
int ret = 0; int ret = 0;
if (offset == 0x0000) ret = protection_status; if (offset == 0x0000)
else if (offset == 0x0e00) ret = protection_ret; ret = state->protection_status;
else if (offset >= 0x0d00 && offset <= 0x0d02) ret = RAM[BASE+offset]; /* addition result */ else if (offset == 0x0e00)
else logerror("Unknown protection read. PC=%04X Offset=%04X\n", cpu_get_pc(space->cpu), offset); ret = state->protection_ret;
else if (offset >= 0x0d00 && offset <= 0x0d02)
ret = RAM[BASE + offset]; /* addition result */
else
logerror("Unknown protection read. PC=%04X Offset=%04X\n", cpu_get_pc(space->cpu), offset);
return ret; return ret;
} }
WRITE8_HANDLER( mmonkey_protection_w ) WRITE8_HANDLER( mmonkey_protection_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
UINT8 *RAM = memory_region(space->machine, "maincpu"); UINT8 *RAM = memory_region(space->machine, "maincpu");
if (offset == 0) if (offset == 0)
{ {
/* protection trigger */ /* protection trigger */
@ -39,7 +34,7 @@ WRITE8_HANDLER( mmonkey_protection_w )
{ {
int i, s1, s2, r; int i, s1, s2, r;
switch (protection_command) switch (state->protection_command)
{ {
case 0: /* score addition */ case 0: /* score addition */
@ -69,25 +64,31 @@ WRITE8_HANDLER( mmonkey_protection_w )
/* instanteniously in emulation time */ /* instanteniously in emulation time */
for (i = 0; i < 0x100; i++) for (i = 0; i < 0x100; i++)
{ {
if (RAM[BASE+0x0f00+i] == protection_value) if (RAM[BASE + 0x0f00 + i] == state->protection_value)
{ {
protection_ret = i; state->protection_ret = i;
break; break;
} }
} }
break; break;
default: default:
logerror("Unemulated protection command=%02X. PC=%04X\n", protection_command, cpu_get_pc(space->cpu)); logerror("Unemulated protection command=%02X. PC=%04X\n", state->protection_command, cpu_get_pc(space->cpu));
break; break;
} }
protection_status = 0; state->protection_status = 0;
} }
} }
else if (offset == 0x0c00) protection_command = data; else if (offset == 0x0c00)
else if (offset == 0x0e00) protection_value = data; state->protection_command = data;
else if (offset >= 0x0f00) RAM[BASE+offset] = data; /* decrypt table */ else if (offset == 0x0e00)
else if (offset >= 0x0d00 && offset <= 0x0d05) RAM[BASE+offset] = data; /* source table */ state->protection_value = data;
else logerror("Unknown protection write=%02X. PC=%04X Offset=%04X\n", data, cpu_get_pc(space->cpu), offset); else if (offset >= 0x0f00)
RAM[BASE + offset] = data; /* decrypt table */
else if (offset >= 0x0d00 && offset <= 0x0d05)
RAM[BASE + offset] = data; /* source table */
else
logerror("Unknown protection write=%02X. PC=%04X Offset=%04X\n", data, cpu_get_pc(space->cpu), offset);
} }

View File

@ -11,22 +11,6 @@ This file is also used by scregg.c
#include "driver.h" #include "driver.h"
#include "includes/btime.h" #include "includes/btime.h"
UINT8 *btime_videoram;
size_t btime_videoram_size;
UINT8 *btime_colorram;
UINT8 *lnc_charbank;
UINT8 *bnj_backgroundram;
UINT8 *zoar_scrollram;
UINT8 *deco_charram;
//UINT8 *progolf_fg_fb;
size_t bnj_backgroundram_size;
static UINT8 btime_palette = 0;
static UINT8 bnj_scroll1 = 0;
static UINT8 bnj_scroll2 = 0;
static bitmap_t *background_bitmap;
/*************************************************************************** /***************************************************************************
Burger Time doesn't have a color PROM. It uses RAM to dynamically Burger Time doesn't have a color PROM. It uses RAM to dynamically
@ -43,6 +27,7 @@ static bitmap_t *background_bitmap;
bit 0 -- 47 kohm resistor -- RED (inverted) bit 0 -- 47 kohm resistor -- RED (inverted)
***************************************************************************/ ***************************************************************************/
PALETTE_INIT( btime ) PALETTE_INIT( btime )
{ {
int i; int i;
@ -92,11 +77,11 @@ PALETTE_INIT( btime )
bit 0 -- 15 kohm resistor -- BLUE bit 0 -- 15 kohm resistor -- BLUE
***************************************************************************/ ***************************************************************************/
PALETTE_INIT( lnc ) PALETTE_INIT( lnc )
{ {
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, r, g, b; int bit0, bit1, bit2, r, g, b;
@ -121,13 +106,6 @@ PALETTE_INIT( lnc )
} }
} }
MACHINE_RESET( lnc )
{
*lnc_charbank = 1;
}
/*************************************************************************** /***************************************************************************
Start the video hardware emulation. Start the video hardware emulation.
@ -136,24 +114,25 @@ Start the video hardware emulation.
VIDEO_START( btime ) VIDEO_START( btime )
{ {
bnj_scroll1 = 0; btime_state *state = (btime_state *)machine->driver_data;
bnj_scroll2 = 0;
btime_palette = 0;
if (machine->gfx[0]->srcdata == NULL) if (machine->gfx[0]->srcdata == NULL)
gfx_element_set_source(machine->gfx[0], deco_charram); gfx_element_set_source(machine->gfx[0], state->deco_charram);
if (machine->gfx[1]->srcdata == NULL) if (machine->gfx[1]->srcdata == NULL)
gfx_element_set_source(machine->gfx[1], deco_charram); gfx_element_set_source(machine->gfx[1], state->deco_charram);
} }
VIDEO_START( bnj ) VIDEO_START( bnj )
{ {
btime_state *state = (btime_state *)machine->driver_data;
/* the background area is twice as wide as the screen */ /* the background area is twice as wide as the screen */
int width = 256; int width = 256;
int height = 256; int height = 256;
bitmap_format format = video_screen_get_format(machine->primary_screen); bitmap_format format = video_screen_get_format(machine->primary_screen);
background_bitmap = auto_bitmap_alloc(machine, 2*width, height, format); state->background_bitmap = auto_bitmap_alloc(machine, 2 * width, height, format);
state_save_register_global_bitmap(machine, state->background_bitmap);
VIDEO_START_CALL(btime); VIDEO_START_CALL(btime);
} }
@ -167,12 +146,14 @@ WRITE8_HANDLER( btime_paletteram_w )
WRITE8_HANDLER( lnc_videoram_w ) WRITE8_HANDLER( lnc_videoram_w )
{ {
btime_videoram[offset] = data; btime_state *state = (btime_state *)space->machine->driver_data;
btime_colorram[offset] = *lnc_charbank; state->videoram[offset] = data;
state->colorram[offset] = *state->lnc_charbank;
} }
READ8_HANDLER( btime_mirrorvideoram_r ) READ8_HANDLER( btime_mirrorvideoram_r )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
int x, y; int x, y;
/* swap x and y coordinates */ /* swap x and y coordinates */
@ -180,11 +161,12 @@ READ8_HANDLER( btime_mirrorvideoram_r )
y = offset % 32; y = offset % 32;
offset = 32 * y + x; offset = 32 * y + x;
return btime_videoram[offset]; return state->videoram[offset];
} }
READ8_HANDLER( btime_mirrorcolorram_r ) READ8_HANDLER( btime_mirrorcolorram_r )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
int x, y; int x, y;
/* swap x and y coordinates */ /* swap x and y coordinates */
@ -192,11 +174,12 @@ READ8_HANDLER( btime_mirrorcolorram_r )
y = offset % 32; y = offset % 32;
offset = 32 * y + x; offset = 32 * y + x;
return btime_colorram[offset]; return state->colorram[offset];
} }
WRITE8_HANDLER( btime_mirrorvideoram_w ) WRITE8_HANDLER( btime_mirrorvideoram_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
int x, y; int x, y;
/* swap x and y coordinates */ /* swap x and y coordinates */
@ -204,7 +187,7 @@ WRITE8_HANDLER( btime_mirrorvideoram_w )
y = offset % 32; y = offset % 32;
offset = 32 * y + x; offset = 32 * y + x;
btime_videoram[offset] = data; state->videoram[offset] = data;
} }
WRITE8_HANDLER( lnc_mirrorvideoram_w ) WRITE8_HANDLER( lnc_mirrorvideoram_w )
@ -221,6 +204,7 @@ WRITE8_HANDLER( lnc_mirrorvideoram_w )
WRITE8_HANDLER( btime_mirrorcolorram_w ) WRITE8_HANDLER( btime_mirrorcolorram_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
int x, y; int x, y;
/* swap x and y coordinates */ /* swap x and y coordinates */
@ -228,14 +212,16 @@ WRITE8_HANDLER( btime_mirrorcolorram_w )
y = offset % 32; y = offset % 32;
offset = 32 * y + x; offset = 32 * y + x;
btime_colorram[offset] = data; state->colorram[offset] = data;
} }
WRITE8_HANDLER( deco_charram_w ) WRITE8_HANDLER( deco_charram_w )
{ {
if (deco_charram[offset] == data) return; btime_state *state = (btime_state *)space->machine->driver_data;
if (state->deco_charram[offset] == data)
return;
deco_charram[offset] = data; state->deco_charram[offset] = data;
offset &= 0x1fff; offset &= 0x1fff;
@ -248,28 +234,32 @@ WRITE8_HANDLER( deco_charram_w )
WRITE8_HANDLER( bnj_background_w ) WRITE8_HANDLER( bnj_background_w )
{ {
bnj_backgroundram[offset] = data; btime_state *state = (btime_state *)space->machine->driver_data;
state->bnj_backgroundram[offset] = data;
} }
WRITE8_HANDLER( bnj_scroll1_w ) WRITE8_HANDLER( bnj_scroll1_w )
{ {
bnj_scroll1 = data; btime_state *state = (btime_state *)space->machine->driver_data;
state->bnj_scroll1 = data;
} }
WRITE8_HANDLER( bnj_scroll2_w ) WRITE8_HANDLER( bnj_scroll2_w )
{ {
bnj_scroll2 = data; btime_state *state = (btime_state *)space->machine->driver_data;
state->bnj_scroll2 = data;
} }
WRITE8_HANDLER( zoar_video_control_w ) WRITE8_HANDLER( zoar_video_control_w )
{ {
btime_state *state = (btime_state *)space->machine->driver_data;
// Zoar video control // Zoar video control
// //
// Bit 0-2 = Unknown (always 0). Marked as MCOL on schematics // Bit 0-2 = Unknown (always 0). Marked as MCOL on schematics
// Bit 3-4 = Palette // Bit 3-4 = Palette
// Bit 7 = Flip Screen // Bit 7 = Flip Screen
btime_palette = (data & 0x30) >> 3; state->btime_palette = (data & 0x30) >> 3;
flip_screen_set(space->machine, data & 0x80); flip_screen_set(space->machine, data & 0x80);
} }
@ -301,28 +291,29 @@ WRITE8_HANDLER( bnj_video_control_w )
WRITE8_HANDLER( disco_video_control_w ) WRITE8_HANDLER( disco_video_control_w )
{ {
btime_palette = (data >> 2) & 0x03; btime_state *state = (btime_state *)space->machine->driver_data;
state->btime_palette = (data >> 2) & 0x03;
if (!(input_port_read(space->machine, "DSW1") & 0x40)) /* cocktail mode */ if (!(input_port_read(space->machine, "DSW1") & 0x40)) /* cocktail mode */
{
flip_screen_set(space->machine, data & 0x01); flip_screen_set(space->machine, data & 0x01);
} }
}
static void draw_chars( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 transparency, UINT8 color, int priority ) static void draw_chars( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 transparency, UINT8 color, int priority )
{ {
btime_state *state = (btime_state *)machine->driver_data;
offs_t offs; offs_t offs;
for (offs = 0; offs < btime_videoram_size; offs++) for (offs = 0; offs < videoram_size; offs++)
{ {
UINT8 x = 31 - (offs / 32); UINT8 x = 31 - (offs / 32);
UINT8 y = offs % 32; UINT8 y = offs % 32;
UINT16 code = btime_videoram[offs] + 256 * (btime_colorram[offs] & 3); UINT16 code = state->videoram[offs] + 256 * (state->colorram[offs] & 3);
/* check priority */ /* check priority */
if ((priority != -1) && (priority != ((code >> 7) & 0x01))) continue; if ((priority != -1) && (priority != ((code >> 7) & 0x01)))
continue;
if (flip_screen_get(machine)) if (flip_screen_get(machine))
{ {
@ -391,9 +382,10 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta
static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8* tmap, UINT8 color ) static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8* tmap, UINT8 color )
{ {
btime_state *state = (btime_state *)machine->driver_data;
int i; int i;
const UINT8 *gfx = memory_region(machine, "bg_map"); const UINT8 *gfx = memory_region(machine, "bg_map");
int scroll = -(bnj_scroll2 | ((bnj_scroll1 & 0x03) << 8)); int scroll = -(state->bnj_scroll2 | ((state->bnj_scroll1 & 0x03) << 8));
// One extra iteration for wrap around // One extra iteration for wrap around
for (i = 0; i < 5; i++, scroll += 256) for (i = 0; i < 5; i++, scroll += 256)
@ -402,8 +394,10 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re
offs_t tileoffset = tmap[i & 3] * 0x100; offs_t tileoffset = tmap[i & 3] * 0x100;
// Skip if this tile is completely off the screen // Skip if this tile is completely off the screen
if (scroll > 256) break; if (scroll > 256)
if (scroll < -256) continue; break;
if (scroll < -256)
continue;
for (offs = 0; offs < 0x100; offs++) for (offs = 0; offs < 0x100; offs++)
{ {
@ -428,13 +422,12 @@ static void draw_background(running_machine *machine, bitmap_t *bitmap, const re
VIDEO_UPDATE( btime ) VIDEO_UPDATE( btime )
{ {
if (bnj_scroll1 & 0x10) btime_state *state = (btime_state *)screen->machine->driver_data;
if (state->bnj_scroll1 & 0x10)
{ {
int i, start; int i, start;
// Generate tile map // Generate tile map
static UINT8 btime_tilemap[4];
if (flip_screen_get(screen->machine)) if (flip_screen_get(screen->machine))
start = 0; start = 0;
else else
@ -442,17 +435,17 @@ VIDEO_UPDATE( btime )
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
btime_tilemap[i] = start | (bnj_scroll1 & 0x04); state->btime_tilemap[i] = start | (state->bnj_scroll1 & 0x04);
start = (start + 1) & 0x03; start = (start + 1) & 0x03;
} }
draw_background(screen->machine, bitmap, cliprect, btime_tilemap, 0); draw_background(screen->machine, bitmap, cliprect, state->btime_tilemap, 0);
draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, -1); draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, -1);
} }
else else
draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1);
draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 0, btime_videoram, 0x20); draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 0, state->videoram, 0x20);
return 0; return 0;
} }
@ -460,8 +453,9 @@ VIDEO_UPDATE( btime )
VIDEO_UPDATE( eggs ) VIDEO_UPDATE( eggs )
{ {
btime_state *state = (btime_state *)screen->machine->driver_data;
draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1);
draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, btime_videoram, 0x20); draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, state->videoram, 0x20);
return 0; return 0;
} }
@ -469,8 +463,9 @@ VIDEO_UPDATE( eggs )
VIDEO_UPDATE( lnc ) VIDEO_UPDATE( lnc )
{ {
btime_state *state = (btime_state *)screen->machine->driver_data;
draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1);
draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 2, btime_videoram, 0x20); draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 2, state->videoram, 0x20);
return 0; return 0;
} }
@ -478,17 +473,18 @@ VIDEO_UPDATE( lnc )
VIDEO_UPDATE( zoar ) VIDEO_UPDATE( zoar )
{ {
if (bnj_scroll1 & 0x04) btime_state *state = (btime_state *)screen->machine->driver_data;
if (state->bnj_scroll1 & 0x04)
{ {
draw_background(screen->machine, bitmap, cliprect, zoar_scrollram, btime_palette); draw_background(screen->machine, bitmap, cliprect, state->zoar_scrollram, state->btime_palette);
draw_chars(screen->machine, bitmap, cliprect, TRUE, btime_palette + 1, -1); draw_chars(screen->machine, bitmap, cliprect, TRUE, state->btime_palette + 1, -1);
} }
else else
draw_chars(screen->machine, bitmap, cliprect, FALSE, btime_palette + 1, -1); draw_chars(screen->machine, bitmap, cliprect, FALSE, state->btime_palette + 1, -1);
/* The order is important for correct priorities */ /* The order is important for correct priorities */
draw_sprites(screen->machine, bitmap, cliprect, btime_palette + 1, 1, 2, btime_videoram + 0x1f, 0x20); draw_sprites(screen->machine, bitmap, cliprect, state->btime_palette + 1, 1, 2, state->videoram + 0x1f, 0x20);
draw_sprites(screen->machine, bitmap, cliprect, btime_palette + 1, 1, 2, btime_videoram, 0x20); draw_sprites(screen->machine, bitmap, cliprect, state->btime_palette + 1, 1, 2, state->videoram, 0x20);
return 0; return 0;
} }
@ -496,11 +492,12 @@ VIDEO_UPDATE( zoar )
VIDEO_UPDATE( bnj ) VIDEO_UPDATE( bnj )
{ {
if (bnj_scroll1) btime_state *state = (btime_state *)screen->machine->driver_data;
if (state->bnj_scroll1)
{ {
int scroll, offs; int scroll, offs;
for (offs = bnj_backgroundram_size-1; offs >=0; offs--) for (offs = state->bnj_backgroundram_size - 1; offs >=0; offs--)
{ {
int sx, sy; int sx, sy;
@ -514,29 +511,29 @@ VIDEO_UPDATE( bnj )
sy = 256 - sy; sy = 256 - sy;
} }
drawgfx_opaque(background_bitmap, 0, screen->machine->gfx[2], drawgfx_opaque(state->background_bitmap, 0, screen->machine->gfx[2],
(bnj_backgroundram[offs] >> 4) + ((offs & 0x80) >> 3) + 32, (state->bnj_backgroundram[offs] >> 4) + ((offs & 0x80) >> 3) + 32,
0, 0,
flip_screen_get(screen->machine), flip_screen_get(screen->machine), flip_screen_get(screen->machine), flip_screen_get(screen->machine),
sx, sy); sx, sy);
} }
/* copy the background bitmap to the screen */ /* copy the background bitmap to the screen */
scroll = (bnj_scroll1 & 0x02) * 128 + 511 - bnj_scroll2; scroll = (state->bnj_scroll1 & 0x02) * 128 + 511 - state->bnj_scroll2;
if (!flip_screen_get(screen->machine)) if (!flip_screen_get(screen->machine))
scroll = 767 - scroll; scroll = 767 - scroll;
copyscrollbitmap(bitmap, background_bitmap, 1, &scroll, 0, 0, cliprect); copyscrollbitmap(bitmap, state->background_bitmap, 1, &scroll, 0, 0, cliprect);
/* copy the low priority characters followed by the sprites /* copy the low priority characters followed by the sprites
then the high priority characters */ then the high priority characters */
draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, 1); draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, 1);
draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, btime_videoram, 0x20); draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, state->videoram, 0x20);
draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, 0); draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, 0);
} }
else else
{ {
draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1);
draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, btime_videoram, 0x20); draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, state->videoram, 0x20);
} }
return 0; return 0;
@ -545,9 +542,10 @@ VIDEO_UPDATE( bnj )
VIDEO_UPDATE( cookrace ) VIDEO_UPDATE( cookrace )
{ {
btime_state *state = (btime_state *)screen->machine->driver_data;
int offs; int offs;
for (offs = bnj_backgroundram_size-1; offs >=0; offs--) for (offs = state->bnj_backgroundram_size - 1; offs >=0; offs--)
{ {
int sx, sy; int sx, sy;
@ -561,14 +559,14 @@ VIDEO_UPDATE( cookrace )
} }
drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[2], drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[2],
bnj_backgroundram[offs], state->bnj_backgroundram[offs],
0, 0,
flip_screen_get(screen->machine), flip_screen_get(screen->machine), flip_screen_get(screen->machine), flip_screen_get(screen->machine),
8*sx,8*sy); 8*sx,8*sy);
} }
draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, -1); draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, -1);
draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 0, btime_videoram, 0x20); draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 0, state->videoram, 0x20);
return 0; return 0;
} }
@ -576,8 +574,9 @@ VIDEO_UPDATE( cookrace )
VIDEO_UPDATE( disco ) VIDEO_UPDATE( disco )
{ {
draw_chars(screen->machine, bitmap, cliprect, FALSE, btime_palette, -1); btime_state *state = (btime_state *)screen->machine->driver_data;
draw_sprites(screen->machine, bitmap, cliprect, btime_palette, 0, 0, spriteram, 1); draw_chars(screen->machine, bitmap, cliprect, FALSE, state->btime_palette, -1);
draw_sprites(screen->machine, bitmap, cliprect, state->btime_palette, 0, 0, state->spriteram, 1);
return 0; return 0;
} }