From 832b946cc5d6acab9f1a6cd9cc00926942d95b3e Mon Sep 17 00:00:00 2001 From: Fabio Priuli Date: Fri, 27 Nov 2009 10:09:27 +0000 Subject: [PATCH] Added driver data struct and save states to btime.c and scregg.c --- src/mame/drivers/btime.c | 382 +++++++++++++++--------- src/mame/drivers/scregg.c | 58 +++- src/mame/includes/btime.h | 51 +++- src/mame/machine/btime.c | 77 ++--- src/mame/video/btime.c | 613 +++++++++++++++++++------------------- 5 files changed, 671 insertions(+), 510 deletions(-) diff --git a/src/mame/drivers/btime.c b/src/mame/drivers/btime.c index f04f959a407..c6897a63e93 100644 --- a/src/mame/drivers/btime.c +++ b/src/mame/drivers/btime.c @@ -143,11 +143,11 @@ A few notes: #include "sound/discrete.h" #include "includes/btime.h" -#define MASTER_CLOCK XTAL_12MHz -#define HCLK (MASTER_CLOCK/2) -#define HCLK1 (HCLK/2) -#define HCLK2 (HCLK1/2) -#define HCLK4 (HCLK2/2) +#define MASTER_CLOCK XTAL_12MHz +#define HCLK (MASTER_CLOCK/2) +#define HCLK1 (HCLK/2) +#define HCLK2 (HCLK1/2) +#define HCLK4 (HCLK2/2) enum @@ -157,67 +157,58 @@ enum AUDIO_ENABLE_AY8910 /* via ay-8910 port A */ }; + static WRITE8_HANDLER( audio_command_w ); static READ8_HANDLER( audio_command_r ); static READ8_HANDLER( zoar_dsw1_read ); 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 ) { + btime_state *state = (btime_state *)space->machine->driver_data; + /* 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 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; - cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, (audio_nmi_enabled && audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); + state->audio_nmi_enabled = data & 1; + 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 ) { + btime_state *state = (btime_state *)device->machine->driver_data; + /* 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; - cputag_set_input_line(device->machine, "audiocpu", INPUT_LINE_NMI, (audio_nmi_enabled && audio_nmi_state) ? ASSERT_LINE : CLEAR_LINE); + state->audio_nmi_enabled = ~data & 1; + 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 ) { + btime_state *state = (btime_state *)timer->machine->driver_data; int scanline = param; - 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); + state->audio_nmi_state = scanline & 8; + 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) { return BITSWAP8(data,7,5,6,4,3,2,1,0); } -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; 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 */ /* the stack), fetch the address of the next instruction. */ 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 */ - 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. */ - src = (addr < 0x9000) ? rambase : memory_region(space->machine, "maincpu"); + src = (addr < 0x9000) ? state->rambase : memory_region(space->machine, "maincpu"); if ((addr & 0x0104) == 0x0104) { /* 76543210 -> 65342710 bit rotation */ @@ -248,18 +239,20 @@ static void btime_decrypt(const address_space *space) static WRITE8_HANDLER( lnc_w ) { + btime_state *state = (btime_state *)space->machine->driver_data; + if (offset <= 0x3bff) ; - 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 >= 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 == 0x8000) { return; } /* AM_NOP */ - else if (offset == 0x8001) { bnj_video_control_w(space,0,data); return; } + else if (offset == 0x8001) { bnj_video_control_w(space, 0, data); return; } else if (offset == 0x8003) ; else if (offset == 0x9000) { return; } /* AM_NOP */ - else if (offset == 0x9002) { audio_command_w(space,0,data); return; } + else if (offset == 0x9002) { audio_command_w(space, 0, data); return; } 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 */ decrypted[offset] = swap_bits_5_6(data); @@ -267,17 +260,19 @@ static WRITE8_HANDLER( lnc_w ) static WRITE8_HANDLER( mmonkey_w ) { + btime_state *state = (btime_state *)space->machine->driver_data; + if (offset <= 0x3bff) ; - 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 == 0x8001) { bnj_video_control_w(space,0,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 == 0x8001) { bnj_video_control_w(space, 0, data); return; } else if (offset == 0x8003) ; else if (offset == 0x9000) { return; } /* AM_NOP */ - else if (offset == 0x9002) { audio_command_w(space,0,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 if (offset == 0x9002) { audio_command_w(space, 0, 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); - rambase[offset] = data; + state->rambase[offset] = data; /* Swap bits 5 & 6 for opcodes */ decrypted[offset] = swap_bits_5_6(data); @@ -285,69 +280,76 @@ static WRITE8_HANDLER( mmonkey_w ) static WRITE8_HANDLER( btime_w ) { - if (offset <= 0x07ff) ; - else if (offset >= 0x0c00 && offset <= 0x0c0f) btime_paletteram_w(space,offset - 0x0c00,data); - else if (offset >= 0x1000 && offset <= 0x17ff) ; - else if (offset >= 0x1800 && offset <= 0x1bff) btime_mirrorvideoram_w(space,offset - 0x1800,data); - else if (offset >= 0x1c00 && offset <= 0x1fff) btime_mirrorcolorram_w(space,offset - 0x1c00,data); - else if (offset == 0x4002) btime_video_control_w(space,0,data); - else if (offset == 0x4003) audio_command_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); + btime_state *state = (btime_state *)space->machine->driver_data; - rambase[offset] = data; + if (offset <= 0x07ff) ; + else if (offset >= 0x0c00 && offset <= 0x0c0f) btime_paletteram_w(space, offset - 0x0c00, data); + else if (offset >= 0x1000 && offset <= 0x17ff) ; + else if (offset >= 0x1800 && offset <= 0x1bff) btime_mirrorvideoram_w(space, offset - 0x1800, data); + else if (offset >= 0x1c00 && offset <= 0x1fff) btime_mirrorcolorram_w(space, offset - 0x1c00, data); + else if (offset == 0x4002) btime_video_control_w(space, 0, data); + else if (offset == 0x4003) audio_command_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); + + state->rambase[offset] = data; btime_decrypt(space); } static WRITE8_HANDLER( tisland_w ) { + btime_state *state = (btime_state *)space->machine->driver_data; + 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 >= 0x1800 && offset <= 0x1bff) btime_mirrorvideoram_w(space,offset - 0x1800,data); - else if (offset >= 0x1c00 && offset <= 0x1fff) btime_mirrorcolorram_w(space,offset - 0x1c00,data); - else if (offset == 0x4002) btime_video_control_w(space,0,data); - else if (offset == 0x4003) audio_command_w(space,0,data); - else if (offset == 0x4004) bnj_scroll1_w(space,0,data); - else if (offset == 0x4005) bnj_scroll2_w(space,0,data); + else if (offset >= 0x1800 && offset <= 0x1bff) btime_mirrorvideoram_w(space, offset - 0x1800, data); + else if (offset >= 0x1c00 && offset <= 0x1fff) btime_mirrorcolorram_w(space, offset - 0x1c00, data); + else if (offset == 0x4002) btime_video_control_w(space, 0, data); + else if (offset == 0x4003) audio_command_w(space, 0, data); + else if (offset == 0x4004) bnj_scroll1_w(space, 0, data); + else if (offset == 0x4005) bnj_scroll2_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); - - rambase[offset] = data; + state->rambase[offset] = data; btime_decrypt(space); } static WRITE8_HANDLER( zoar_w ) { + btime_state *state = (btime_state *)space->machine->driver_data; + if (offset <= 0x07ff) ; else if (offset >= 0x8000 && offset <= 0x87ff) ; - else if (offset >= 0x8800 && offset <= 0x8bff) btime_mirrorvideoram_w(space,offset - 0x8800,data); - else if (offset >= 0x8c00 && offset <= 0x8fff) btime_mirrorcolorram_w(space,offset - 0x8c00,data); - else if (offset == 0x9000) zoar_video_control_w(space,0, data); + else if (offset >= 0x8800 && offset <= 0x8bff) btime_mirrorvideoram_w(space, offset - 0x8800, data); + else if (offset >= 0x8c00 && offset <= 0x8fff) btime_mirrorcolorram_w(space, offset - 0x8c00, data); + else if (offset == 0x9000) zoar_video_control_w(space, 0, data); else if (offset >= 0x9800 && offset <= 0x9803) ; - else if (offset == 0x9804) bnj_scroll2_w(space,0,data); - else if (offset == 0x9805) bnj_scroll1_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 if (offset == 0x9804) bnj_scroll2_w(space, 0, data); + else if (offset == 0x9805) bnj_scroll1_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); - rambase[offset] = data; + state->rambase[offset] = data; btime_decrypt(space); } static WRITE8_HANDLER( disco_w ) { - if (offset <= 0x04ff) ; - else if (offset >= 0x2000 && offset <= 0x7fff) deco_charram_w(space,offset - 0x2000,data); - else if (offset >= 0x8000 && offset <= 0x881f) ; - else if (offset == 0x9a00) audio_command_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); + btime_state *state = (btime_state *)space->machine->driver_data; - rambase[offset] = data; + if (offset <= 0x04ff) ; + else if (offset >= 0x2000 && offset <= 0x7fff) deco_charram_w(space, offset - 0x2000, data); + else if (offset >= 0x8000 && offset <= 0x881f) ; + else if (offset == 0x9a00) audio_command_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); + + state->rambase[offset] = data; btime_decrypt(space); } @@ -356,10 +358,10 @@ static WRITE8_HANDLER( disco_w ) static ADDRESS_MAP_START( btime_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0xffff) AM_WRITE(btime_w) /* override the following entries to */ /* 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(0x1000, 0x13ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&btime_colorram) + AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size) + 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(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w) 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 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(0xc000, 0xc3ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0xc400, 0xc7ff) AM_RAM AM_BASE(&btime_colorram) + AM_RANGE(0xc000, 0xc3ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size) + 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(0xcc00, 0xcfff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w) AM_RANGE(0xd000, 0xd0ff) AM_RAM /* background? */ 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(0xe300, 0xe300) AM_READ_PORT("DSW1") /* mirror address used on high score name entry */ /* screen */ @@ -393,10 +395,10 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( tisland_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0xffff) AM_WRITE(tisland_w) /* override the following entries to */ /* 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(0x1000, 0x13ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&btime_colorram) + AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size) + 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(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r, btime_mirrorcolorram_w) 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 ) AM_RANGE(0x0000, 0xffff) AM_WRITE(zoar_w) /* override the following entries to */ /* support ROM decryption */ - AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE(&rambase) - AM_RANGE(0x8000, 0x83ff) AM_WRITEONLY AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0x8400, 0x87ff) AM_WRITEONLY AM_BASE(&btime_colorram) + AM_RANGE(0x0000, 0x07ff) AM_RAM AM_BASE_MEMBER(btime_state, rambase) + AM_RANGE(0x8000, 0x83ff) AM_WRITEONLY AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size) + AM_RANGE(0x8400, 0x87ff) AM_WRITEONLY AM_BASE_MEMBER(btime_state, colorram) AM_RANGE(0x8800, 0x8bff) AM_WRITE(btime_mirrorvideoram_w) AM_RANGE(0x8c00, 0x8fff) AM_WRITE(btime_mirrorcolorram_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(0x9802, 0x9802) AM_READ_PORT("P1") 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(0x9805, 0x9805) AM_WRITE(bnj_scroll1_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 ) AM_RANGE(0x0000, 0xffff) AM_WRITE(lnc_w) /* override the following entries to */ /* support ROM decryption */ - AM_RANGE(0x0000, 0x3bff) AM_RAM AM_BASE(&rambase) - AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(lnc_videoram_w) AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0x7800, 0x7bff) AM_WRITEONLY AM_BASE(&btime_colorram) /* this is just here to initialize the pointer */ + AM_RANGE(0x0000, 0x3bff) AM_RAM AM_BASE_MEMBER(btime_state, rambase) + 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_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(0x8000, 0x8000) AM_READ_PORT("DSW1") AM_WRITENOP /* ??? */ 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(0x9001, 0x9001) AM_READ_PORT("P2") 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 ) AM_RANGE(0x0000, 0xffff) AM_WRITE(mmonkey_w) /* override the following entries to */ /* support ROM decryption */ - AM_RANGE(0x0000, 0x3bff) AM_RAM AM_BASE(&rambase) - AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(lnc_videoram_w) AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0x7800, 0x7bff) AM_WRITEONLY AM_BASE(&btime_colorram) /* this is just here to initialize the pointer */ + AM_RANGE(0x0000, 0x3bff) AM_RAM AM_BASE_MEMBER(btime_state, rambase) + 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_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(0x8000, 0x8000) AM_READ_PORT("DSW1") 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(0x9001, 0x9001) AM_READ_PORT("P2") 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 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(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(0x1003, 0x1003) AM_READ_PORT("P2") 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(0x4400, 0x47ff) AM_RAM AM_BASE(&btime_colorram) + AM_RANGE(0x4000, 0x43ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size) + 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(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(0x5800, 0x5800) AM_WRITE(bnj_scroll2_w) 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 ) AM_RANGE(0x0000, 0xffff) AM_WRITE(disco_w) /* override the following entries to */ /* support ROM decryption */ - AM_RANGE(0x0000, 0x04ff) AM_RAM AM_BASE(&rambase) - AM_RANGE(0x2000, 0x7fff) AM_RAM_WRITE(deco_charram_w) AM_BASE(&deco_charram) - AM_RANGE(0x8000, 0x83ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0x8400, 0x87ff) AM_RAM AM_BASE(&btime_colorram) - AM_RANGE(0x8800, 0x881f) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) + AM_RANGE(0x0000, 0x04ff) AM_RAM AM_BASE_MEMBER(btime_state, rambase) + 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_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size) + AM_RANGE(0x8400, 0x87ff) AM_RAM AM_BASE_MEMBER(btime_state, colorram) + 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(0x9200, 0x9200) AM_READ_PORT("P1") 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 ) - 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(0x4000, 0x5fff) AM_DEVWRITE("ay1", ay8910_address_w) AM_RANGE(0x6000, 0x7fff) AM_DEVWRITE("ay2", ay8910_data_w) @@ -523,32 +525,39 @@ ADDRESS_MAP_END static INPUT_CHANGED( coin_inserted_irq_hi ) { + btime_state *state = (btime_state *)field->port->machine->driver_data; + 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 ) { + btime_state *state = (btime_state *)field->port->machine->driver_data; + 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 ) { - 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 ) { - soundlatch_w(space,offset,data); - cputag_set_input_line(space->machine, "audiocpu", 0, ASSERT_LINE); + btime_state *state = (btime_state *)space->machine->driver_data; + soundlatch_w(space, offset, data); + cpu_set_input_line(state->audiocpu, 0, ASSERT_LINE); } static READ8_HANDLER( audio_command_r ) { - cputag_set_input_line(space->machine, "audiocpu", 0, CLEAR_LINE); - return soundlatch_r(space,offset); + btime_state *state = (btime_state *)space->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, CLEAR_LINE); + return soundlatch_r(space, offset); } static READ8_HANDLER( zoar_dsw1_read ) @@ -1412,8 +1421,75 @@ static DISCRETE_SOUND_START( btime_sound ) 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 ) + /* driver data */ + MDRV_DRIVER_DATA(btime_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6502, HCLK2) /* seletable between H2/H4 via jumper */ 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_MACHINE_START(btime) + MDRV_MACHINE_RESET(btime) MDRV_GFXDECODE(btime) MDRV_PALETTE_LENGTH(16) @@ -1509,6 +1586,9 @@ static MACHINE_DRIVER_START( mmonkey ) MDRV_IMPORT_FROM(wtennis) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(mmonkey_map) + + MDRV_MACHINE_START(mmonkey) + MDRV_MACHINE_RESET(mmonkey) MACHINE_DRIVER_END @@ -2024,12 +2104,14 @@ static void init_rom1(running_machine *machine) static DRIVER_INIT( btime ) { + btime_state *state = (btime_state *)machine->driver_data; init_rom1(machine); - audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; + state->audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; } static DRIVER_INIT( zoar ) { + btime_state *state = (btime_state *)machine->driver_data; UINT8 *rom = memory_region(machine, "maincpu"); /* 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); init_rom1(machine); - audio_nmi_enable_type = AUDIO_ENABLE_AY8910; + state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910; } static DRIVER_INIT( tisland ) { + btime_state *state = (btime_state *)machine->driver_data; UINT8 *rom = memory_region(machine, "maincpu"); /* 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); init_rom1(machine); - audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; + state->audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; } static DRIVER_INIT( lnc ) { + btime_state *state = (btime_state *)machine->driver_data; decrypt_C10707_cpu(machine, "maincpu"); - audio_nmi_enable_type = AUDIO_ENABLE_AY8910; + state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910; } static DRIVER_INIT( bnj ) { + btime_state *state = (btime_state *)machine->driver_data; decrypt_C10707_cpu(machine, "maincpu"); - audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; + state->audio_nmi_enable_type = AUDIO_ENABLE_DIRECT; } static DRIVER_INIT( disco ) { + btime_state *state = (btime_state *)machine->driver_data; DRIVER_INIT_CALL(btime); - audio_nmi_enable_type = AUDIO_ENABLE_AY8910; + state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910; } static DRIVER_INIT( cookrace ) { + btime_state *state = (btime_state *)machine->driver_data; 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_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 ) { + btime_state *state = (btime_state *)machine->driver_data; DRIVER_INIT_CALL(btime); - audio_nmi_enable_type = AUDIO_ENABLE_AY8910; + state->audio_nmi_enable_type = AUDIO_ENABLE_AY8910; } static DRIVER_INIT( wtennis ) { + btime_state *state = (btime_state *)machine->driver_data; 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, "audiocpu", ADDRESS_SPACE_PROGRAM), 0x0200, 0x0fff, 0, 0, (read8_space_func)SMH_BANK(10)); 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 ) { + btime_state *state = (btime_state *)machine->driver_data; decrypt_C10707_cpu(machine, "maincpu"); 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, btime2, btime, btime, btime, btime, ROT270, "Data East Corporation", "Burger Time (Data East set 2)", 0 ) -GAME( 1982, btimem, btime, btime, btime, btime, ROT270, "Data East (Bally Midway license)", "Burger Time (Midway)", 0 ) -GAME( 1982, cookrace, btime, cookrace, cookrace, cookrace, ROT270, "bootleg", "Cook Race", 0 ) -GAME( 1981, tisland, 0, tisland, btime, tisland, ROT270, "Data East Corporation", "Treasure Island", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS ) -GAME( 1981, lnc, 0, lnc, lnc, lnc, ROT270, "Data East Corporation", "Lock'n'Chase", 0 ) -GAME( 1982, protennb, 0, disco, disco, protennb, ROT270, "bootleg", "Tennis (bootleg of Pro Tennis)", 0 ) -GAME( 1982, wtennis, 0, wtennis, wtennis, wtennis, ROT270, "bootleg", "World Tennis", 0 ) -GAME( 1982, mmonkey, 0, mmonkey, mmonkey, lnc, ROT270, "Technos Japan + Roller Tron", "Minky Monkey", 0 ) -GAME( 1982, brubber, 0, bnj, bnj, bnj, ROT270, "Data East", "Burnin' Rubber", 0 ) -GAME( 1982, bnj, brubber, bnj, bnj, bnj, ROT270, "Data East USA (Bally Midway license)", "Bump 'n' Jump", 0 ) -GAME( 1982, caractn, brubber, bnj, bnj, bnj, ROT270, "bootleg", "Car Action", 0 ) -GAME( 1982, zoar, 0, zoar, zoar, zoar, ROT270, "Data East USA", "Zoar", 0 ) -GAME( 1982, disco, 0, disco, disco, disco, ROT270, "Data East", "Disco No.1", 0 ) -GAME( 1982, discof, disco, disco, disco, disco, ROT270, "Data East", "Disco No.1 (Rev.F)", 0 ) -GAME( 1983, sdtennis, 0, bnj, sdtennis, sdtennis, ROT270, "Data East Corporation", "Super Doubles Tennis", 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)", GAME_SUPPORTS_SAVE ) +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", GAME_SUPPORTS_SAVE ) +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", GAME_SUPPORTS_SAVE ) +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", GAME_SUPPORTS_SAVE ) +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", GAME_SUPPORTS_SAVE ) +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", GAME_SUPPORTS_SAVE ) +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", GAME_SUPPORTS_SAVE ) +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", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/scregg.c b/src/mame/drivers/scregg.c index a0e5a545148..502ebfd1a3c 100644 --- a/src/mame/drivers/scregg.c +++ b/src/mame/drivers/scregg.c @@ -57,9 +57,9 @@ it as ASCII text. static ADDRESS_MAP_START( dommy_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x07ff) AM_RAM - AM_RANGE(0x2000, 0x23ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0x2400, 0x27ff) AM_RAM AM_BASE(&btime_colorram) - AM_RANGE(0x2800, 0x2bff) AM_READWRITE(btime_mirrorvideoram_r,btime_mirrorvideoram_w) + AM_RANGE(0x2000, 0x23ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size) + 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(0x4000, 0x4000) AM_READ_PORT("DSW1") AM_WRITENOP AM_RANGE(0x4001, 0x4001) AM_READ_PORT("DSW2") AM_WRITE(btime_video_control_w) /* AM_RANGE(0x4004, 0x4004) */ /* this is read */ @@ -73,8 +73,8 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( eggs_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x07ff) AM_RAM - AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&btime_videoram) AM_SIZE(&btime_videoram_size) - AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&btime_colorram) + AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_MEMBER(btime_state, videoram) AM_SIZE(&videoram_size) + 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(0x1c00, 0x1fff) AM_READWRITE(btime_mirrorcolorram_r,btime_mirrorcolorram_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 ) + /* driver data */ + MDRV_DRIVER_DATA(btime_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6502, 1500000) MDRV_CPU_PROGRAM_MAP(dommy_map) MDRV_CPU_PERIODIC_INT(irq0_line_hold,16*60) //??? + MDRV_MACHINE_START(scregg) + MDRV_MACHINE_RESET(scregg) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(57) @@ -235,11 +267,17 @@ MACHINE_DRIVER_END static MACHINE_DRIVER_START( scregg ) + /* driver data */ + MDRV_DRIVER_DATA(btime_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6502, 1500000) MDRV_CPU_PROGRAM_MAP(eggs_map) MDRV_CPU_PERIODIC_INT(irq0_line_hold,16*60) //??? + MDRV_MACHINE_START(scregg) + MDRV_MACHINE_RESET(scregg) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(57) @@ -361,7 +399,7 @@ static DRIVER_INIT( rockduck ) int x; UINT8 *src = memory_region( machine, "gfx1" ); - for (x=0x2000;x<0x6000;x++) + for (x = 0x2000; x < 0x6000; x++) { src[x] = BITSWAP8(src[x],2,0,3,6,1,4,7,5); @@ -369,7 +407,7 @@ static DRIVER_INIT( rockduck ) } -GAME( 1983, dommy, 0, dommy, scregg, 0, ROT270, "Technos Japan", "Dommy", 0 ) -GAME( 1983, scregg, 0, scregg, scregg, 0, ROT270, "Technos Japan", "Scrambled Egg", 0 ) -GAME( 1983, eggs, scregg, scregg, scregg, 0, ROT270, "[Technos Japan] Universal USA", "Eggs", 0 ) -GAME( 1983, rockduck, 0, scregg, rockduck, rockduck, ROT270, "Datel SAS", "Rock Duck (prototype?)", GAME_WRONG_COLORS ) +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", GAME_SUPPORTS_SAVE ) +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_SUPPORTS_SAVE ) diff --git a/src/mame/includes/btime.h b/src/mame/includes/btime.h index 2e2e9d0334d..ab6dbae8719 100644 --- a/src/mame/includes/btime.h +++ b/src/mame/includes/btime.h @@ -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 -----------*/ READ8_HANDLER( mmonkey_protection_r ); @@ -6,15 +48,6 @@ WRITE8_HANDLER( mmonkey_protection_w ); /*----------- 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( lnc ); diff --git a/src/mame/machine/btime.c b/src/mame/machine/btime.c index d2eb79a5a38..241679322a6 100644 --- a/src/mame/machine/btime.c +++ b/src/mame/machine/btime.c @@ -4,61 +4,56 @@ #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 ) { + btime_state *state = (btime_state *)space->machine->driver_data; UINT8 *RAM = memory_region(space->machine, "maincpu"); - int ret = 0; - if (offset == 0x0000) ret = protection_status; - else if (offset == 0x0e00) ret = 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); + if (offset == 0x0000) + ret = state->protection_status; + else if (offset == 0x0e00) + 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; } - - WRITE8_HANDLER( mmonkey_protection_w ) { + btime_state *state = (btime_state *)space->machine->driver_data; UINT8 *RAM = memory_region(space->machine, "maincpu"); - if (offset == 0) { /* protection trigger */ if (data == 0) { - int i,s1,s2,r; + int i, s1, s2, r; - switch (protection_command) + switch (state->protection_command) { case 0: /* score addition */ - s1 = ( 1 * (RAM[BASE+0x0d00] & 0x0f)) + ( 10 * (RAM[BASE+0x0d00] >> 4)) + - ( 100 * (RAM[BASE+0x0d01] & 0x0f)) + ( 1000 * (RAM[BASE+0x0d01] >> 4)) + - (10000 * (RAM[BASE+0x0d02] & 0x0f)) + (100000 * (RAM[BASE+0x0d02] >> 4)); + s1 = (1 * (RAM[BASE + 0x0d00] & 0x0f)) + (10 * (RAM[BASE + 0x0d00] >> 4)) + + (100 * (RAM[BASE + 0x0d01] & 0x0f)) + (1000 * (RAM[BASE + 0x0d01] >> 4)) + + (10000 * (RAM[BASE + 0x0d02] & 0x0f)) + (100000 * (RAM[BASE + 0x0d02] >> 4)); - s2 = ( 1 * (RAM[BASE+0x0d03] & 0x0f)) + ( 10 * (RAM[BASE+0x0d03] >> 4)) + - ( 100 * (RAM[BASE+0x0d04] & 0x0f)) + ( 1000 * (RAM[BASE+0x0d04] >> 4)) + - (10000 * (RAM[BASE+0x0d05] & 0x0f)) + (100000 * (RAM[BASE+0x0d05] >> 4)); + s2 = (1 * (RAM[BASE + 0x0d03] & 0x0f)) + (10 * (RAM[BASE + 0x0d03] >> 4)) + + (100 * (RAM[BASE + 0x0d04] & 0x0f)) + (1000 * (RAM[BASE + 0x0d04] >> 4)) + + (10000 * (RAM[BASE + 0x0d05] & 0x0f)) + (100000 * (RAM[BASE + 0x0d05] >> 4)); r = s1 + s2; - RAM[BASE+0x0d00] = (r % 10); r /= 10; - RAM[BASE+0x0d00] |= ((r % 10) << 4); r /= 10; - RAM[BASE+0x0d01] = (r % 10); r /= 10; - RAM[BASE+0x0d01] |= ((r % 10) << 4); r /= 10; - RAM[BASE+0x0d02] = (r % 10); r /= 10; - RAM[BASE+0x0d02] |= ((r % 10) << 4); + RAM[BASE + 0x0d00] = (r % 10); r /= 10; + RAM[BASE + 0x0d00] |= ((r % 10) << 4); r /= 10; + RAM[BASE + 0x0d01] = (r % 10); r /= 10; + RAM[BASE + 0x0d01] |= ((r % 10) << 4); r /= 10; + RAM[BASE + 0x0d02] = (r % 10); r /= 10; + RAM[BASE + 0x0d02] |= ((r % 10) << 4); break; @@ -69,25 +64,31 @@ WRITE8_HANDLER( mmonkey_protection_w ) /* instanteniously in emulation time */ 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; 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; } - protection_status = 0; + state->protection_status = 0; } } - else if (offset == 0x0c00) protection_command = data; - else if (offset == 0x0e00) protection_value = data; - 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); + else if (offset == 0x0c00) + state->protection_command = data; + else if (offset == 0x0e00) + state->protection_value = data; + 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); } + diff --git a/src/mame/video/btime.c b/src/mame/video/btime.c index 5696ec07639..ec4f3359e8b 100644 --- a/src/mame/video/btime.c +++ b/src/mame/video/btime.c @@ -4,29 +4,13 @@ Functions to emulate the video hardware of the machine. -This file is also used by scregg.c + This file is also used by scregg.c ***************************************************************************/ #include "driver.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 @@ -43,6 +27,7 @@ static bitmap_t *background_bitmap; bit 0 -- 47 kohm resistor -- RED (inverted) ***************************************************************************/ + PALETTE_INIT( btime ) { int i; @@ -52,9 +37,9 @@ PALETTE_INIT( btime ) /* This function is also used by Eggs. */ if (color_prom == 0) return; - 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; /* red component */ bit0 = (color_prom[i] >> 0) & 0x01; @@ -72,7 +57,7 @@ PALETTE_INIT( btime ) bit2 = (color_prom[i] >> 7) & 0x01; b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - palette_set_color(machine,i,MAKE_RGB(r,g,b)); + palette_set_color(machine, i, MAKE_RGB(r,g,b)); } } @@ -92,14 +77,14 @@ PALETTE_INIT( btime ) bit 0 -- 15 kohm resistor -- BLUE ***************************************************************************/ + PALETTE_INIT( lnc ) { 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; /* red component */ bit0 = (color_prom[i] >> 7) & 0x01; @@ -117,17 +102,10 @@ PALETTE_INIT( lnc ) bit2 = (color_prom[i] >> 0) & 0x01; b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2; - palette_set_color(machine,i,MAKE_RGB(r,g,b)); + palette_set_color(machine, i, MAKE_RGB(r,g,b)); } } - -MACHINE_RESET( lnc ) -{ - *lnc_charbank = 1; -} - - /*************************************************************************** Start the video hardware emulation. @@ -136,323 +114,338 @@ Start the video hardware emulation. VIDEO_START( btime ) { - bnj_scroll1 = 0; - bnj_scroll2 = 0; - btime_palette = 0; + btime_state *state = (btime_state *)machine->driver_data; 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) - gfx_element_set_source(machine->gfx[1], deco_charram); + gfx_element_set_source(machine->gfx[1], state->deco_charram); } VIDEO_START( bnj ) { - /* the background area is twice as wide as the screen */ - int width = 256; - int height = 256; - bitmap_format format = video_screen_get_format(machine->primary_screen); - background_bitmap = auto_bitmap_alloc(machine, 2*width, height, format); + btime_state *state = (btime_state *)machine->driver_data; + /* the background area is twice as wide as the screen */ + int width = 256; + int height = 256; + bitmap_format format = video_screen_get_format(machine->primary_screen); + state->background_bitmap = auto_bitmap_alloc(machine, 2 * width, height, format); - VIDEO_START_CALL(btime); + state_save_register_global_bitmap(machine, state->background_bitmap); + + VIDEO_START_CALL(btime); } WRITE8_HANDLER( btime_paletteram_w ) { - /* RGB output is inverted */ - paletteram_BBGGGRRR_w(space,offset,~data); + /* RGB output is inverted */ + paletteram_BBGGGRRR_w(space, offset, ~data); } WRITE8_HANDLER( lnc_videoram_w ) { - btime_videoram[offset] = data; - btime_colorram[offset] = *lnc_charbank; + btime_state *state = (btime_state *)space->machine->driver_data; + state->videoram[offset] = data; + state->colorram[offset] = *state->lnc_charbank; } READ8_HANDLER( btime_mirrorvideoram_r ) { - int x,y; + btime_state *state = (btime_state *)space->machine->driver_data; + int x, y; - /* swap x and y coordinates */ - x = offset / 32; - y = offset % 32; - offset = 32 * y + x; + /* swap x and y coordinates */ + x = offset / 32; + y = offset % 32; + offset = 32 * y + x; - return btime_videoram[offset]; + return state->videoram[offset]; } READ8_HANDLER( btime_mirrorcolorram_r ) { - int x,y; + btime_state *state = (btime_state *)space->machine->driver_data; + int x, y; - /* swap x and y coordinates */ - x = offset / 32; - y = offset % 32; - offset = 32 * y + x; + /* swap x and y coordinates */ + x = offset / 32; + y = offset % 32; + offset = 32 * y + x; - return btime_colorram[offset]; + return state->colorram[offset]; } WRITE8_HANDLER( btime_mirrorvideoram_w ) { - int x,y; + btime_state *state = (btime_state *)space->machine->driver_data; + int x, y; - /* swap x and y coordinates */ - x = offset / 32; - y = offset % 32; - offset = 32 * y + x; + /* swap x and y coordinates */ + x = offset / 32; + y = offset % 32; + offset = 32 * y + x; - btime_videoram[offset] = data; + state->videoram[offset] = data; } WRITE8_HANDLER( lnc_mirrorvideoram_w ) { - int x,y; + int x, y; - /* swap x and y coordinates */ - x = offset / 32; - y = offset % 32; - offset = 32 * y + x; + /* swap x and y coordinates */ + x = offset / 32; + y = offset % 32; + offset = 32 * y + x; - lnc_videoram_w(space,offset,data); + lnc_videoram_w(space, offset, data); } WRITE8_HANDLER( btime_mirrorcolorram_w ) { - int x,y; + btime_state *state = (btime_state *)space->machine->driver_data; + int x, y; - /* swap x and y coordinates */ - x = offset / 32; - y = offset % 32; - offset = 32 * y + x; + /* swap x and y coordinates */ + x = offset / 32; + y = offset % 32; + offset = 32 * y + x; - btime_colorram[offset] = data; + state->colorram[offset] = data; } 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; - /* dirty sprite */ - gfx_element_mark_dirty(space->machine->gfx[1], offset >> 5); + /* dirty sprite */ + gfx_element_mark_dirty(space->machine->gfx[1], offset >> 5); - /* diry char */ - gfx_element_mark_dirty(space->machine->gfx[0], offset >> 3); + /* diry char */ + gfx_element_mark_dirty(space->machine->gfx[0], offset >> 3); } 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 ) { - bnj_scroll1 = data; + btime_state *state = (btime_state *)space->machine->driver_data; + state->bnj_scroll1 = data; } 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 ) { - // Zoar video control - // - // Bit 0-2 = Unknown (always 0). Marked as MCOL on schematics - // Bit 3-4 = Palette - // Bit 7 = Flip Screen + btime_state *state = (btime_state *)space->machine->driver_data; + // Zoar video control + // + // Bit 0-2 = Unknown (always 0). Marked as MCOL on schematics + // Bit 3-4 = Palette + // Bit 7 = Flip Screen - btime_palette = (data & 0x30) >> 3; + state->btime_palette = (data & 0x30) >> 3; flip_screen_set(space->machine, data & 0x80); } WRITE8_HANDLER( btime_video_control_w ) { - // Btime video control - // - // Bit 0 = Flip screen - // Bit 1-7 = Unknown + // Btime video control + // + // Bit 0 = Flip screen + // Bit 1-7 = Unknown flip_screen_set(space->machine, data & 0x01); } WRITE8_HANDLER( bnj_video_control_w ) { - /* Bnj/Lnc works a little differently than the btime/eggs (apparently). */ - /* According to the information at: */ - /* http://www.davesclassics.com/arcade/Switch_Settings/BumpNJump.sw */ - /* SW8 is used for cocktail video selection (as opposed to controls), */ - /* but bit 7 of the input port is used for vblank input. */ - /* My guess is that this switch open circuits some connection to */ - /* the monitor hardware. */ - /* For now we just check 0x40 in DSW1, and ignore the write if we */ - /* are in upright controls mode. */ + /* Bnj/Lnc works a little differently than the btime/eggs (apparently). */ + /* According to the information at: */ + /* http://www.davesclassics.com/arcade/Switch_Settings/BumpNJump.sw */ + /* SW8 is used for cocktail video selection (as opposed to controls), */ + /* but bit 7 of the input port is used for vblank input. */ + /* My guess is that this switch open circuits some connection to */ + /* the monitor hardware. */ + /* For now we just check 0x40 in DSW1, and ignore the write if we */ + /* are in upright controls mode. */ - if (input_port_read(space->machine, "DSW1") & 0x40) /* cocktail mode */ - btime_video_control_w(space, offset, data); + if (input_port_read(space->machine, "DSW1") & 0x40) /* cocktail mode */ + btime_video_control_w(space, offset, data); } 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 */ - { 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 ) +{ + btime_state *state = (btime_state *)machine->driver_data; + offs_t offs; + + for (offs = 0; offs < videoram_size; offs++) + { + UINT8 x = 31 - (offs / 32); + UINT8 y = offs % 32; + + UINT16 code = state->videoram[offs] + 256 * (state->colorram[offs] & 3); + + /* check priority */ + if ((priority != -1) && (priority != ((code >> 7) & 0x01))) + continue; + + if (flip_screen_get(machine)) + { + x = 31 - x; + y = 33 - y; + } + + drawgfx_transpen(bitmap,cliprect,machine->gfx[0], + code, + color, + flip_screen_get(machine),flip_screen_get(machine), + 8*x,8*y, + transparency ? 0 : -1); + } +} + +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 color, + UINT8 sprite_y_adjust, UINT8 sprite_y_adjust_flip_screen, + UINT8 *sprite_ram, offs_t interleave ) +{ + int i; + offs_t offs; + + /* draw the sprites */ + for (i = 0, offs = 0; i < 8; i++, offs += 4 * interleave) + { + int x, y; + UINT8 flipx, flipy; + + if (!(sprite_ram[offs + 0] & 0x01)) continue; + + x = 240 - sprite_ram[offs + 3 * interleave]; + y = 240 - sprite_ram[offs + 2 * interleave]; + + flipx = sprite_ram[offs + 0] & 0x04; + flipy = sprite_ram[offs + 0] & 0x02; + + if (flip_screen_get(machine)) + { + x = 240 - x; + y = 256 - y + sprite_y_adjust_flip_screen; + + flipx = !flipx; + flipy = !flipy; + } + + y = y - sprite_y_adjust; + + drawgfx_transpen(bitmap,cliprect,machine->gfx[1], + sprite_ram[offs + interleave], + color, + flipx,flipy, + x, y,0); + + y = y + (flip_screen_get(machine) ? -256 : 256); + + // Wrap around + drawgfx_transpen(bitmap,cliprect,machine->gfx[1], + sprite_ram[offs + interleave], + color, + flipx,flipy, + x,y,0); } } -static void draw_chars(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 transparency, UINT8 color, int priority) +static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8* tmap, UINT8 color ) { - offs_t offs; + btime_state *state = (btime_state *)machine->driver_data; + int i; + const UINT8 *gfx = memory_region(machine, "bg_map"); + int scroll = -(state->bnj_scroll2 | ((state->bnj_scroll1 & 0x03) << 8)); - for (offs = 0; offs < btime_videoram_size; offs++) - { - UINT8 x = 31 - (offs / 32); - UINT8 y = offs % 32; - - UINT16 code = btime_videoram[offs] + 256 * (btime_colorram[offs] & 3); - - /* check priority */ - if ((priority != -1) && (priority != ((code >> 7) & 0x01))) continue; - - if (flip_screen_get(machine)) - { - x = 31 - x; - y = 33 - y; - } - - drawgfx_transpen(bitmap,cliprect,machine->gfx[0], - code, - color, - flip_screen_get(machine),flip_screen_get(machine), - 8*x,8*y, - transparency ? 0 : -1); - } -} - -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 color, - UINT8 sprite_y_adjust, UINT8 sprite_y_adjust_flip_screen, - UINT8 *sprite_ram, offs_t interleave) -{ - int i; - offs_t offs; - - /* draw the sprites */ - for (i = 0, offs = 0; i < 8; i++, offs += 4*interleave) - { - int x, y; - UINT8 flipx,flipy; - - if (!(sprite_ram[offs + 0] & 0x01)) continue; - - x = 240 - sprite_ram[offs + 3*interleave]; - y = 240 - sprite_ram[offs + 2*interleave]; - - flipx = sprite_ram[offs + 0] & 0x04; - flipy = sprite_ram[offs + 0] & 0x02; - - if (flip_screen_get(machine)) - { - x = 240 - x; - y = 256 - y + sprite_y_adjust_flip_screen; - - flipx = !flipx; - flipy = !flipy; - } - - y = y - sprite_y_adjust; - - drawgfx_transpen(bitmap,cliprect,machine->gfx[1], - sprite_ram[offs + interleave], - color, - flipx,flipy, - x, y,0); - - y = y + (flip_screen_get(machine) ? -256 : 256); - - // Wrap around - drawgfx_transpen(bitmap,cliprect,machine->gfx[1], - sprite_ram[offs + interleave], - color, - flipx,flipy, - x,y,0); - } -} - - -static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8* tmap, UINT8 color) -{ - int i; - const UINT8 *gfx = memory_region(machine, "bg_map"); - int scroll = -(bnj_scroll2 | ((bnj_scroll1 & 0x03) << 8)); - - // One extra iteration for wrap around - for (i = 0; i < 5; i++, scroll += 256) - { + // One extra iteration for wrap around + for (i = 0; i < 5; i++, scroll += 256) + { offs_t offs; - offs_t tileoffset = tmap[i & 3] * 0x100; + offs_t tileoffset = tmap[i & 3] * 0x100; - // Skip if this tile is completely off the screen - if (scroll > 256) break; - if (scroll < -256) continue; + // Skip if this tile is completely off the screen + if (scroll > 256) + break; + if (scroll < -256) + continue; - for (offs = 0; offs < 0x100; offs++) - { - int x = 240 - (16 * (offs / 16) + scroll); - int y = 16 * (offs % 16); + for (offs = 0; offs < 0x100; offs++) + { + int x = 240 - (16 * (offs / 16) + scroll); + int y = 16 * (offs % 16); - if (flip_screen_get(machine)) - { - x = 240 - x; - y = 256 - y; - } + if (flip_screen_get(machine)) + { + x = 240 - x; + y = 256 - y; + } - drawgfx_opaque(bitmap, cliprect,machine->gfx[2], - gfx[tileoffset + offs], - color, - flip_screen_get(machine),flip_screen_get(machine), - x,y); - } - } + drawgfx_opaque(bitmap, cliprect,machine->gfx[2], + gfx[tileoffset + offs], + color, + flip_screen_get(machine),flip_screen_get(machine), + x,y); + } + } } VIDEO_UPDATE( btime ) { - if (bnj_scroll1 & 0x10) - { - int i, start; + btime_state *state = (btime_state *)screen->machine->driver_data; + if (state->bnj_scroll1 & 0x10) + { + int i, start; - // Generate tile map - static UINT8 btime_tilemap[4]; + // Generate tile map + if (flip_screen_get(screen->machine)) + start = 0; + else + start = 1; - if (flip_screen_get(screen->machine)) - start = 0; - else - start = 1; + for (i = 0; i < 4; i++) + { + state->btime_tilemap[i] = start | (state->bnj_scroll1 & 0x04); + start = (start + 1) & 0x03; + } - for (i = 0; i < 4; i++) - { - btime_tilemap[i] = start | (bnj_scroll1 & 0x04); - start = (start + 1) & 0x03; - } + draw_background(screen->machine, bitmap, cliprect, state->btime_tilemap, 0); + draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, -1); + } + else + draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); - draw_background(screen->machine, bitmap, cliprect, btime_tilemap, 0); - draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, -1); - } - else - 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; } @@ -460,8 +453,9 @@ VIDEO_UPDATE( btime ) VIDEO_UPDATE( eggs ) { - draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); - draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, btime_videoram, 0x20); + btime_state *state = (btime_state *)screen->machine->driver_data; + draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); + draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, state->videoram, 0x20); return 0; } @@ -469,8 +463,9 @@ VIDEO_UPDATE( eggs ) VIDEO_UPDATE( lnc ) { - draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); - draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 2, btime_videoram, 0x20); + btime_state *state = (btime_state *)screen->machine->driver_data; + draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); + draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 2, state->videoram, 0x20); return 0; } @@ -478,17 +473,18 @@ VIDEO_UPDATE( lnc ) VIDEO_UPDATE( zoar ) { - if (bnj_scroll1 & 0x04) - { - draw_background(screen->machine, bitmap, cliprect, zoar_scrollram, btime_palette); - draw_chars(screen->machine, bitmap, cliprect, TRUE, btime_palette + 1, -1); - } - else - draw_chars(screen->machine, bitmap, cliprect, FALSE, btime_palette + 1, -1); + btime_state *state = (btime_state *)screen->machine->driver_data; + if (state->bnj_scroll1 & 0x04) + { + draw_background(screen->machine, bitmap, cliprect, state->zoar_scrollram, state->btime_palette); + draw_chars(screen->machine, bitmap, cliprect, TRUE, state->btime_palette + 1, -1); + } + else + draw_chars(screen->machine, bitmap, cliprect, FALSE, state->btime_palette + 1, -1); - /* 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, btime_palette + 1, 1, 2, btime_videoram, 0x20); + /* The order is important for correct priorities */ + draw_sprites(screen->machine, bitmap, cliprect, state->btime_palette + 1, 1, 2, state->videoram + 0x1f, 0x20); + draw_sprites(screen->machine, bitmap, cliprect, state->btime_palette + 1, 1, 2, state->videoram, 0x20); return 0; } @@ -496,48 +492,49 @@ VIDEO_UPDATE( zoar ) VIDEO_UPDATE( bnj ) { - if (bnj_scroll1) - { - int scroll, offs; + btime_state *state = (btime_state *)screen->machine->driver_data; + if (state->bnj_scroll1) + { + int scroll, offs; - for (offs = bnj_backgroundram_size-1; offs >=0; offs--) - { - int sx,sy; + for (offs = state->bnj_backgroundram_size - 1; offs >=0; offs--) + { + int sx, sy; - sx = 16 * ((offs < 0x100) ? ((offs % 0x80) / 8) : ((offs % 0x80) / 8) + 16); - sy = 16 * (((offs % 0x100) < 0x80) ? offs % 8 : (offs % 8) + 8); - sx = 496 - sx; + sx = 16 * ((offs < 0x100) ? ((offs % 0x80) / 8) : ((offs % 0x80) / 8) + 16); + sy = 16 * (((offs % 0x100) < 0x80) ? offs % 8 : (offs % 8) + 8); + sx = 496 - sx; - if (flip_screen_get(screen->machine)) - { - sx = 496 - sx; - sy = 256 - sy; - } + if (flip_screen_get(screen->machine)) + { + sx = 496 - sx; + sy = 256 - sy; + } - drawgfx_opaque(background_bitmap, 0, screen->machine->gfx[2], - (bnj_backgroundram[offs] >> 4) + ((offs & 0x80) >> 3) + 32, - 0, - flip_screen_get(screen->machine), flip_screen_get(screen->machine), - sx, sy); - } + drawgfx_opaque(state->background_bitmap, 0, screen->machine->gfx[2], + (state->bnj_backgroundram[offs] >> 4) + ((offs & 0x80) >> 3) + 32, + 0, + flip_screen_get(screen->machine), flip_screen_get(screen->machine), + sx, sy); + } - /* copy the background bitmap to the screen */ - scroll = (bnj_scroll1 & 0x02) * 128 + 511 - bnj_scroll2; - if (!flip_screen_get(screen->machine)) - scroll = 767-scroll; - copyscrollbitmap(bitmap, background_bitmap, 1, &scroll, 0, 0, cliprect); + /* copy the background bitmap to the screen */ + scroll = (state->bnj_scroll1 & 0x02) * 128 + 511 - state->bnj_scroll2; + if (!flip_screen_get(screen->machine)) + scroll = 767 - scroll; + copyscrollbitmap(bitmap, state->background_bitmap, 1, &scroll, 0, 0, cliprect); - /* copy the low priority characters followed by the sprites - then the high priority characters */ - draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, 1); - draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, btime_videoram, 0x20); - draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, 0); - } - else - { - draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); - draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, btime_videoram, 0x20); - } + /* copy the low priority characters followed by the sprites + then the high priority characters */ + draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, 1); + draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, state->videoram, 0x20); + draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, 0); + } + else + { + draw_chars(screen->machine, bitmap, cliprect, FALSE, 0, -1); + draw_sprites(screen->machine, bitmap, cliprect, 0, 0, 0, state->videoram, 0x20); + } return 0; } @@ -545,30 +542,31 @@ VIDEO_UPDATE( bnj ) VIDEO_UPDATE( cookrace ) { - int offs; + btime_state *state = (btime_state *)screen->machine->driver_data; + int offs; - for (offs = bnj_backgroundram_size-1; offs >=0; offs--) - { - int sx,sy; + for (offs = state->bnj_backgroundram_size - 1; offs >=0; offs--) + { + int sx, sy; - sx = 31 - (offs / 32); - sy = offs % 32; + sx = 31 - (offs / 32); + sy = offs % 32; - if (flip_screen_get(screen->machine)) - { - sx = 31 - sx; - sy = 33 - sy; - } + if (flip_screen_get(screen->machine)) + { + sx = 31 - sx; + sy = 33 - sy; + } - drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[2], - bnj_backgroundram[offs], - 0, - flip_screen_get(screen->machine), flip_screen_get(screen->machine), - 8*sx,8*sy); - } + drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[2], + state->bnj_backgroundram[offs], + 0, + flip_screen_get(screen->machine), flip_screen_get(screen->machine), + 8*sx,8*sy); + } - draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, -1); - draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 0, btime_videoram, 0x20); + draw_chars(screen->machine, bitmap, cliprect, TRUE, 0, -1); + draw_sprites(screen->machine, bitmap, cliprect, 0, 1, 0, state->videoram, 0x20); return 0; } @@ -576,8 +574,9 @@ VIDEO_UPDATE( cookrace ) VIDEO_UPDATE( disco ) { - draw_chars(screen->machine, bitmap, cliprect, FALSE, btime_palette, -1); - draw_sprites(screen->machine, bitmap, cliprect, btime_palette, 0, 0, spriteram, 1); + btime_state *state = (btime_state *)screen->machine->driver_data; + 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; }