diff --git a/.gitattributes b/.gitattributes index f921978e16b..445ce5e6c35 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2308,6 +2308,7 @@ src/mame/includes/1942.h svneol=native#text/plain src/mame/includes/1943.h svneol=native#text/plain src/mame/includes/20pacgal.h svneol=native#text/plain src/mame/includes/4enraya.h svneol=native#text/plain +src/mame/includes/88games.h svneol=native#text/plain src/mame/includes/actfancr.h svneol=native#text/plain src/mame/includes/aeroboto.h svneol=native#text/plain src/mame/includes/aerofgt.h svneol=native#text/plain @@ -2350,10 +2351,12 @@ src/mame/includes/bankp.h svneol=native#text/plain src/mame/includes/batman.h svneol=native#text/plain src/mame/includes/battlane.h svneol=native#text/plain src/mame/includes/battlex.h svneol=native#text/plain +src/mame/includes/battlnts.h svneol=native#text/plain src/mame/includes/beathead.h svneol=native#text/plain src/mame/includes/beezer.h svneol=native#text/plain src/mame/includes/bigevglf.h svneol=native#text/plain src/mame/includes/bionicc.h svneol=native#text/plain +src/mame/includes/bladestl.h svneol=native#text/plain src/mame/includes/blktiger.h svneol=native#text/plain src/mame/includes/blmbycar.h svneol=native#text/plain src/mame/includes/blockade.h svneol=native#text/plain @@ -2395,8 +2398,10 @@ src/mame/includes/citycon.h svneol=native#text/plain src/mame/includes/cloak.h svneol=native#text/plain src/mame/includes/cloud9.h svneol=native#text/plain src/mame/includes/cninja.h svneol=native#text/plain +src/mame/includes/combatsc.h svneol=native#text/plain src/mame/includes/commando.h svneol=native#text/plain src/mame/includes/compgolf.h svneol=native#text/plain +src/mame/includes/contra.h svneol=native#text/plain src/mame/includes/cop01.h svneol=native#text/plain src/mame/includes/copsnrob.h svneol=native#text/plain src/mame/includes/cosmic.h svneol=native#text/plain @@ -2634,6 +2639,7 @@ src/mame/includes/realbrk.h svneol=native#text/plain src/mame/includes/redalert.h svneol=native#text/plain src/mame/includes/relief.h svneol=native#text/plain src/mame/includes/retofinv.h svneol=native#text/plain +src/mame/includes/rockrage.h svneol=native#text/plain src/mame/includes/segag80r.h svneol=native#text/plain src/mame/includes/segag80v.h svneol=native#text/plain src/mame/includes/segas24.h svneol=native#text/plain diff --git a/src/mame/drivers/88games.c b/src/mame/drivers/88games.c index 16579030894..26daf3c556f 100644 --- a/src/mame/drivers/88games.c +++ b/src/mame/drivers/88games.c @@ -10,131 +10,136 @@ #include "video/konicdev.h" #include "sound/2151intf.h" #include "sound/upd7759.h" +#include "includes/88games.h" -static MACHINE_RESET( 88games ); -static MACHINE_START( 88games ); -static KONAMI_SETLINES_CALLBACK( k88games_banking ); - -static UINT8 *ram; -static UINT8 *banked_rom; static UINT8 *paletteram_1000; -static int videobank; -extern int k88games_priority; -extern void _88games_sprite_callback(int *code,int *color,int *priority,int *shadow); -extern void _88games_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority); -extern void _88games_zoom_callback(int *code,int *color,int *flags); - -VIDEO_START( 88games ); -VIDEO_UPDATE( 88games ); +/************************************* + * + * Memory handlers + * + *************************************/ static INTERRUPT_GEN( k88games_interrupt ) { - const device_config *k052109 = devtag_get_device(device->machine, "k052109"); + _88games_state *state = (_88games_state *)device->machine->driver_data; - if (k052109_is_IRQ_enabled(k052109)) + if (k052109_is_irq_enabled(state->k052109)) irq0_line_hold(device); } -static int zoomreadroms; - static READ8_HANDLER( bankedram_r ) { - const device_config *k051316 = devtag_get_device(space->machine, "k051316"); - if (videobank) return ram[offset]; + _88games_state *state = (_88games_state *)space->machine->driver_data; + + if (state->videobank) + return state->ram[offset]; else { - if (zoomreadroms) - return k051316_rom_r(k051316, offset); + if (state->zoomreadroms) + return k051316_rom_r(state->k051316, offset); else - return k051316_r(k051316, offset); + return k051316_r(state->k051316, offset); } } static WRITE8_HANDLER( bankedram_w ) { - const device_config *k051316 = devtag_get_device(space->machine, "k051316"); - if (videobank) ram[offset] = data; - else k051316_w(k051316, offset, data); + _88games_state *state = (_88games_state *)space->machine->driver_data; + + if (state->videobank) + state->ram[offset] = data; + else + k051316_w(state->k051316, offset, data); } static WRITE8_HANDLER( k88games_5f84_w ) { + _88games_state *state = (_88games_state *)space->machine->driver_data; + /* bits 0/1 coin counters */ - coin_counter_w(space->machine, 0,data & 0x01); - coin_counter_w(space->machine, 1,data & 0x02); + coin_counter_w(space->machine, 0, data & 0x01); + coin_counter_w(space->machine, 1, data & 0x02); /* bit 2 enables ROM reading from the 051316 */ /* also 5fce == 2 read roms, == 3 read ram */ - zoomreadroms = data & 0x04; + state->zoomreadroms = data & 0x04; if (data & 0xf8) - popmessage("5f84 = %02x",data); + popmessage("5f84 = %02x", data); } static WRITE8_HANDLER( k88games_sh_irqtrigger_w ) { - cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff); + _88games_state *state = (_88games_state *)space->machine->driver_data; + cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff); } -static UINT8 speech_chip[8]; + static WRITE8_HANDLER( speech_control_w ) { + _88games_state *state = (_88games_state *)space->machine->driver_data; const device_config *upd; - strcpy((char *)speech_chip, ( data & 4 ) ? "upd2" : "upd1"); + state->speech_chip = (data & 4) ? 1 : 0; + upd = state->speech_chip ? state->upd_2 : state->upd_1; - upd = devtag_get_device(space->machine, (char *)speech_chip); - upd7759_reset_w( upd, data & 2 ); - upd7759_start_w( upd, data & 1 ); + upd7759_reset_w(upd, data & 2); + upd7759_start_w(upd, data & 1); } static WRITE8_HANDLER( speech_msg_w ) { - upd7759_port_w( devtag_get_device(space->machine, (char *)speech_chip), 0, data ); + _88games_state *state = (_88games_state *)space->machine->driver_data; + const device_config *upd = state->speech_chip ? state->upd_2 : state->upd_1; + + upd7759_port_w(upd, 0, data); } /* special handlers to combine 052109 & 051960 */ - static READ8_HANDLER( k052109_051960_r ) { - const device_config *k052109 = devtag_get_device(space->machine, "k052109"); - const device_config *k051960 = devtag_get_device(space->machine, "k051960"); + _88games_state *state = (_88games_state *)space->machine->driver_data; - if (k052109_get_RMRD_line(k052109) == CLEAR_LINE) + if (k052109_get_rmrd_line(state->k052109) == CLEAR_LINE) { if (offset >= 0x3800 && offset < 0x3808) - return k051937_r(k051960, offset - 0x3800); + return k051937_r(state->k051960, offset - 0x3800); else if (offset < 0x3c00) - return k052109_r(k052109, offset); + return k052109_r(state->k052109, offset); else - return k051960_r(k051960, offset - 0x3c00); + return k051960_r(state->k051960, offset - 0x3c00); } else - return k052109_r(k052109, offset); + return k052109_r(state->k052109, offset); } static WRITE8_HANDLER( k052109_051960_w ) { - const device_config *k052109 = devtag_get_device(space->machine, "k052109"); - const device_config *k051960 = devtag_get_device(space->machine, "k051960"); + _88games_state *state = (_88games_state *)space->machine->driver_data; if (offset >= 0x3800 && offset < 0x3808) - k051937_w(k051960, offset - 0x3800, data); + k051937_w(state->k051960, offset - 0x3800, data); else if (offset < 0x3c00) - k052109_w(k052109, offset, data); + k052109_w(state->k052109, offset, data); else - k051960_w(k051960, offset - 0x3c00, data); + k051960_w(state->k051960, offset - 0x3c00, data); } +/************************************* + * + * Address maps + * + *************************************/ + static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE(&banked_rom) /* banked ROM + palette RAM */ + AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE_MEMBER(_88games_state, banked_rom) /* banked ROM + palette RAM */ AM_RANGE(0x1000, 0x1fff) AM_RAM_WRITE(paletteram_xBBBBBGGGGGRRRRR_be_w) AM_BASE(&paletteram_1000) /* banked ROM + palette RAM */ AM_RANGE(0x2000, 0x2fff) AM_RAM AM_RANGE(0x3000, 0x37ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) - AM_RANGE(0x3800, 0x3fff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE(&ram) + AM_RANGE(0x3800, 0x3fff) AM_READWRITE(bankedram_r, bankedram_w) AM_BASE_MEMBER(_88games_state, ram) AM_RANGE(0x5f84, 0x5f84) AM_WRITE(k88games_5f84_w) AM_RANGE(0x5f88, 0x5f88) AM_WRITE(watchdog_reset_w) AM_RANGE(0x5f8c, 0x5f8c) AM_WRITE(soundlatch_w) @@ -160,11 +165,11 @@ ADDRESS_MAP_END -/*************************************************************************** - - Input Ports - -***************************************************************************/ +/************************************* + * + * Input ports + * + *************************************/ static INPUT_PORTS_START( 88games ) PORT_START("IN0") @@ -260,6 +265,91 @@ static INPUT_PORTS_START( 88games ) INPUT_PORTS_END +/************************************* + * + * Machine driver + * + *************************************/ + +static KONAMI_SETLINES_CALLBACK( k88games_banking ) +{ + _88games_state *state = (_88games_state *)device->machine->driver_data; + UINT8 *RAM = memory_region(device->machine, "maincpu"); + int offs; + + logerror("%04x: bank select %02x\n", cpu_get_pc(device), lines); + + /* bits 0-2 select ROM bank for 0000-1fff */ + /* bit 3: when 1, palette RAM at 1000-1fff */ + /* bit 4: when 0, 051316 RAM at 3800-3fff; when 1, work RAM at 2000-3fff (NVRAM 3370-37ff) */ + offs = 0x10000 + (lines & 0x07) * 0x2000; + memcpy(state->banked_rom, &RAM[offs], 0x1000); + if (lines & 0x08) + { + if (device->machine->generic.paletteram.u8 != paletteram_1000) + { + memcpy(paletteram_1000, device->machine->generic.paletteram.u8, 0x1000); + device->machine->generic.paletteram.u8 = paletteram_1000; + } + } + else + { + if (device->machine->generic.paletteram.u8 != &RAM[0x20000]) + { + memcpy(&RAM[0x20000], device->machine->generic.paletteram.u8, 0x1000); + device->machine->generic.paletteram.u8 = &RAM[0x20000]; + } + memcpy(paletteram_1000, &RAM[offs+0x1000], 0x1000); + } + + state->videobank = lines & 0x10; + + /* bit 5 = enable char ROM reading through the video RAM */ + k052109_set_rmrd_line(state->k052109, (lines & 0x20) ? ASSERT_LINE : CLEAR_LINE); + + /* bit 6 is unknown, 1 most of the time */ + + /* bit 7 controls layer priority */ + state->k88games_priority = lines & 0x80; +} + +static MACHINE_START( 88games ) +{ + _88games_state *state = (_88games_state *)machine->driver_data; + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k052109 = devtag_get_device(machine, "k052109"); + state->k051960 = devtag_get_device(machine, "k051960"); + state->k051316 = devtag_get_device(machine, "k051316"); + state->upd_1 = devtag_get_device(machine, "upd1"); + state->upd_2 = devtag_get_device(machine, "upd2"); + + state_save_register_global(machine, state->videobank); + state_save_register_global(machine, state->zoomreadroms); + state_save_register_global(machine, state->speech_chip); + state_save_register_global_array(machine, state->layer_colorbase); + state_save_register_global(machine, state->k88games_priority); + state_save_register_global(machine, state->sprite_colorbase); + state_save_register_global(machine, state->zoom_colorbase); +} + +static MACHINE_RESET( 88games ) +{ + _88games_state *state = (_88games_state *)machine->driver_data; + + konami_configure_set_lines(devtag_get_device(machine, "maincpu"), k88games_banking); + machine->generic.paletteram.u8 = &memory_region(machine, "maincpu")[0x20000]; + + state->videobank = 0; + state->zoomreadroms = 0; + state->speech_chip = 0; + state->k88games_priority = 0; + state->layer_colorbase[0] = 64; + state->layer_colorbase[1] = 0; + state->layer_colorbase[2] = 16; + state->sprite_colorbase = 32; + state->zoom_colorbase = 48; +} static const k052109_interface _88games_k052109_intf = { @@ -284,6 +374,9 @@ static const k051316_interface _88games_k051316_intf = static MACHINE_DRIVER_START( 88games ) + /* driver data */ + MDRV_DRIVER_DATA(_88games_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", KONAMI, 3000000) /* ? */ MDRV_CPU_PROGRAM_MAP(main_map) @@ -292,7 +385,9 @@ static MACHINE_DRIVER_START( 88games ) MDRV_CPU_ADD("audiocpu", Z80, 3579545) MDRV_CPU_PROGRAM_MAP(sound_map) + MDRV_MACHINE_START(88games) MDRV_MACHINE_RESET(88games) + MDRV_NVRAM_HANDLER(generic_0fill) /* video hardware */ @@ -310,11 +405,8 @@ static MACHINE_DRIVER_START( 88games ) MDRV_K051960_ADD("k051960", _88games_k051960_intf) MDRV_K051316_ADD("k051316", _88games_k051316_intf) - MDRV_VIDEO_START(88games) MDRV_VIDEO_UPDATE(88games) - MDRV_MACHINE_START(88games) - /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -331,15 +423,15 @@ MACHINE_DRIVER_END -/*************************************************************************** - - Game ROMs - -***************************************************************************/ +/************************************* + * + * ROM definition(s) + * + *************************************/ ROM_START( 88games ) ROM_REGION( 0x21000, "maincpu", 0 ) /* code + banked roms + space for banked ram */ - ROM_LOAD( "861m01.k18", 0x08000, 0x08000, CRC(4a4e2959) SHA1(95572686bef48b5c1ce1dedf0afc891d92aff00d) ) + ROM_LOAD( "861m01.k18", 0x08000, 0x08000, CRC(4a4e2959) SHA1(95572686bef48b5c1ce1dedf0afc891d92aff00d) ) ROM_LOAD( "861m02.k16", 0x10000, 0x10000, CRC(e19f15f6) SHA1(6c801b274e87eaff7f40148381ade5b38120cc12) ) ROM_REGION( 0x10000, "audiocpu", 0 ) /* Z80 code */ @@ -500,60 +592,11 @@ ROM_START( hypsptsp ) ROM_END - -static KONAMI_SETLINES_CALLBACK( k88games_banking ) -{ - const device_config *k052109 = devtag_get_device(device->machine, "k052109"); - UINT8 *RAM = memory_region(device->machine, "maincpu"); - int offs; - -logerror("%04x: bank select %02x\n",cpu_get_pc(device),lines); - - /* bits 0-2 select ROM bank for 0000-1fff */ - /* bit 3: when 1, palette RAM at 1000-1fff */ - /* bit 4: when 0, 051316 RAM at 3800-3fff; when 1, work RAM at 2000-3fff (NVRAM 3370-37ff) */ - offs = 0x10000 + (lines & 0x07) * 0x2000; - memcpy(banked_rom,&RAM[offs],0x1000); - if (lines & 0x08) - { - if (device->machine->generic.paletteram.u8 != paletteram_1000) - { - memcpy(paletteram_1000,device->machine->generic.paletteram.u8,0x1000); - device->machine->generic.paletteram.u8 = paletteram_1000; - } - } - else - { - if (device->machine->generic.paletteram.u8 != &RAM[0x20000]) - { - memcpy(&RAM[0x20000],device->machine->generic.paletteram.u8,0x1000); - device->machine->generic.paletteram.u8 = &RAM[0x20000]; - } - memcpy(paletteram_1000,&RAM[offs+0x1000],0x1000); - } - videobank = lines & 0x10; - - /* bit 5 = enable char ROM reading through the video RAM */ - k052109_set_RMRD_line(k052109, (lines & 0x20) ? ASSERT_LINE : CLEAR_LINE); - - /* bit 6 is unknown, 1 most of the time */ - - /* bit 7 controls layer priority */ - k88games_priority = lines & 0x80; -} - -static MACHINE_RESET( 88games ) -{ - konami_configure_set_lines(cputag_get_cpu(machine, "maincpu"), k88games_banking); - machine->generic.paletteram.u8 = &memory_region(machine, "maincpu")[0x20000]; -} - -static MACHINE_START( 88games ) -{ - state_save_register_global(machine, videobank); - state_save_register_global(machine, zoomreadroms); - state_save_register_global_array(machine, speech_chip); -} +/************************************* + * + * Driver initialization + * + *************************************/ static DRIVER_INIT( 88games ) { @@ -562,6 +605,11 @@ static DRIVER_INIT( 88games ) } +/************************************* + * + * Game driver(s) + * + *************************************/ GAME( 1988, 88games, 0, 88games, 88games, 88games, ROT0, "Konami", "'88 Games", GAME_SUPPORTS_SAVE ) GAME( 1988, konami88, 88games, 88games, 88games, 88games, ROT0, "Konami", "Konami '88", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/asterix.c b/src/mame/drivers/asterix.c index 02ad9c4d1e1..837c7b46c83 100644 --- a/src/mame/drivers/asterix.c +++ b/src/mame/drivers/asterix.c @@ -11,17 +11,19 @@ colour, including the word "Konami" #include "driver.h" #include "cpu/m68000/m68000.h" -#include "video/konamiic.h" #include "cpu/z80/z80.h" #include "machine/eeprom.h" #include "sound/2151intf.h" #include "sound/k053260.h" -#include "konamipt.h" +#include "video/konicdev.h" +#include "includes/konamipt.h" -VIDEO_START( asterix ); VIDEO_UPDATE( asterix ); WRITE16_HANDLER( asterix_spritebank_w ); +extern void asterix_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags); +extern void asterix_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask); + static UINT8 cur_control2; static int init_eeprom_count; @@ -83,6 +85,8 @@ static READ16_HANDLER( control2_r ) static WRITE16_HANDLER( control2_w ) { + const device_config *k056832 = devtag_get_device(space->machine, "k056832"); + if (ACCESSING_BITS_0_7) { cur_control2 = data; @@ -95,14 +99,16 @@ static WRITE16_HANDLER( control2_w ) eeprom_set_clock_line((data & 0x04) ? ASSERT_LINE : CLEAR_LINE); /* bit 5 is select tile bank */ - K056832_set_tile_bank((data & 0x20) >> 5); + k056832_set_tile_bank(k056832, (data & 0x20) >> 5); } } static INTERRUPT_GEN( asterix_interrupt ) { + const device_config *k056832 = devtag_get_device(device->machine, "k056832"); + // global interrupt masking - if (!K056832_is_IRQ_enabled(0)) return; + if (!k056832_is_irq_enabled(k056832, 0)) return; cpu_set_input_line(device, 5, HOLD_LINE); /* ??? All irqs have the same vector, and the mask used is 0 or 7 */ @@ -179,24 +185,24 @@ static WRITE16_HANDLER( protection_w ) static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x0fffff) AM_ROM AM_RANGE(0x100000, 0x107fff) AM_RAM - AM_RANGE(0x180000, 0x1807ff) AM_READWRITE(K053245_word_r, K053245_word_w) + AM_RANGE(0x180000, 0x1807ff) AM_DEVREADWRITE("k053244", k053245_word_r, k053245_word_w) AM_RANGE(0x180800, 0x180fff) AM_RAM // extra RAM, or mirror for the above? - AM_RANGE(0x200000, 0x20000f) AM_READWRITE(K053244_word_r, K053244_word_w) + AM_RANGE(0x200000, 0x20000f) AM_DEVREADWRITE("k053244", k053244_word_r, k053244_word_w) AM_RANGE(0x280000, 0x280fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram) - AM_RANGE(0x300000, 0x30001f) AM_READWRITE(K053244_lsb_r, K053244_lsb_w) + AM_RANGE(0x300000, 0x30001f) AM_DEVREADWRITE("k053244", k053244_lsb_r, k053244_lsb_w) AM_RANGE(0x380000, 0x380001) AM_READ_PORT("IN0") AM_RANGE(0x380002, 0x380003) AM_READ(control1_r) AM_RANGE(0x380100, 0x380101) AM_WRITE(control2_w) AM_RANGE(0x380200, 0x380203) AM_DEVREADWRITE8("konami", asterix_sound_r, k053260_w, 0x00ff) AM_RANGE(0x380300, 0x380301) AM_WRITE(sound_irq_w) AM_RANGE(0x380400, 0x380401) AM_WRITE(asterix_spritebank_w) - AM_RANGE(0x380500, 0x38051f) AM_WRITE(K053251_lsb_w) + AM_RANGE(0x380500, 0x38051f) AM_DEVWRITE("k053251", k053251_lsb_w) AM_RANGE(0x380600, 0x380601) AM_NOP // Watchdog - AM_RANGE(0x380700, 0x380707) AM_WRITE(K056832_b_word_w) + AM_RANGE(0x380700, 0x380707) AM_DEVWRITE("k056832", k056832_b_word_w) AM_RANGE(0x380800, 0x380803) AM_WRITE(protection_w) - AM_RANGE(0x400000, 0x400fff) AM_READWRITE(K056832_ram_half_word_r, K056832_ram_half_word_w) - AM_RANGE(0x420000, 0x421fff) AM_READ(K056832_old_rom_word_r) // Passthrough to tile roms - AM_RANGE(0x440000, 0x44003f) AM_WRITE(K056832_word_w) + AM_RANGE(0x400000, 0x400fff) AM_DEVREADWRITE("k056832", k056832_ram_half_word_r, k056832_ram_half_word_w) + AM_RANGE(0x420000, 0x421fff) AM_DEVREAD("k056832", k056832_old_rom_word_r) // Passthrough to tile roms + AM_RANGE(0x440000, 0x44003f) AM_DEVWRITE("k056832", k056832_word_w) ADDRESS_MAP_END static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) @@ -226,6 +232,25 @@ static INPUT_PORTS_START( asterix ) PORT_BIT( 0xf800, IP_ACTIVE_HIGH, IPT_UNKNOWN ) INPUT_PORTS_END + +static const k056832_interface asterix_k056832_intf = +{ + "gfx1", + K056832_BPP_4, + 1, 1, + KONAMI_ROM_DEINTERLEAVE_2, + asterix_tile_callback, "none" +}; + +static const k05324x_interface asterix_k05324x_intf = +{ + "gfx2", + NORMAL_PLANE_ORDER, + -3, -1, + KONAMI_ROM_DEINTERLEAVE_2, + asterix_sprite_callback +}; + static MACHINE_DRIVER_START( asterix ) /* basic machine hardware */ @@ -249,9 +274,12 @@ static MACHINE_DRIVER_START( asterix ) MDRV_SCREEN_VISIBLE_AREA(14*8, (64-14)*8-1, 2*8, 30*8-1 ) MDRV_PALETTE_LENGTH(2048) - MDRV_VIDEO_START(asterix) MDRV_VIDEO_UPDATE(asterix) + MDRV_K056832_ADD("k056832", asterix_k056832_intf) + MDRV_K053244_ADD("k053244", asterix_k05324x_intf) + MDRV_K053251_ADD("k053251") + /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") @@ -356,9 +384,6 @@ ROM_END static DRIVER_INIT( asterix ) { - konami_rom_deinterleave_2(machine, "gfx1"); - konami_rom_deinterleave_2(machine, "gfx2"); - #if 0 *(UINT16 *)(memory_region(machine, "maincpu") + 0x07f34) = 0x602a; *(UINT16 *)(memory_region(machine, "maincpu") + 0x00008) = 0x0400; diff --git a/src/mame/drivers/battlnts.c b/src/mame/drivers/battlnts.c index c17ec147e0f..b7d8f876b3e 100644 --- a/src/mame/drivers/battlnts.c +++ b/src/mame/drivers/battlnts.c @@ -1,12 +1,12 @@ /*************************************************************************** -Konami Battlantis Hardware + Konami Battlantis Hardware -Supports: - GX765 - Rack 'em Up/The Hustler (c) 1987 Konami - GX777 - Battlantis (c) 1987 Konami + Supports: + GX765 - Rack 'em Up/The Hustler (c) 1987 Konami + GX777 - Battlantis (c) 1987 Konami -Preliminary driver by: Manuel Abadia + Preliminary driver by: Manuel Abadia ***************************************************************************/ @@ -16,44 +16,47 @@ Preliminary driver by: Manuel Abadia #include "sound/3812intf.h" #include "video/konicdev.h" #include "includes/konamipt.h" +#include "includes/battlnts.h" -/* from video */ -WRITE8_HANDLER( battlnts_spritebank_w ); -VIDEO_START( battlnts ); -VIDEO_UPDATE( battlnts ); - -extern void battlnts_tile_callback(int layer, int bank, int *code, int *color, int *flags); -extern void battlnts_sprite_callback(int *code, int *color); +/************************************* + * + * Memory handlers + * + *************************************/ static INTERRUPT_GEN( battlnts_interrupt ) { - const device_config *k007342 = devtag_get_device(device->machine, "k007342"); - if (k007342_is_int_enabled(k007342)) + battlnts_state *state = (battlnts_state *)device->machine->driver_data; + if (k007342_is_int_enabled(state->k007342)) cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE); } static WRITE8_HANDLER( battlnts_sh_irqtrigger_w ) { - cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff); + battlnts_state *state = (battlnts_state *)space->machine->driver_data; + cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff); } static WRITE8_HANDLER( battlnts_bankswitch_w ) { - UINT8 *RAM = memory_region(space->machine, "maincpu"); - UINT32 bankaddress; - /* bits 6 & 7 = bank number */ - bankaddress = 0x10000 + ((data & 0xc0) >> 6) * 0x4000; - memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]); + memory_set_bank(space->machine, "bank1", (data & 0xc0) >> 6); /* bits 4 & 5 = coin counters */ - coin_counter_w(space->machine, 0,data & 0x10); - coin_counter_w(space->machine, 1,data & 0x20); + coin_counter_w(space->machine, 0, data & 0x10); + coin_counter_w(space->machine, 1, data & 0x20); /* other bits unknown */ } + +/************************************* + * + * Address maps + * + *************************************/ + static ADDRESS_MAP_START( battlnts_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_DEVREADWRITE("k007342", k007342_r, k007342_w) /* Color RAM + Video RAM */ AM_RANGE(0x2000, 0x21ff) AM_DEVREADWRITE("k007420", k007420_r, k007420_w) /* Sprite RAM */ @@ -82,11 +85,11 @@ static ADDRESS_MAP_START( battlnts_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0xe000, 0xe000) AM_READ(soundlatch_r) /* soundlatch_r */ ADDRESS_MAP_END -/*************************************************************************** - - Input Ports - -***************************************************************************/ +/************************************* + * + * Input ports + * + *************************************/ static INPUT_PORTS_START( battlnts ) PORT_START("DSW1") @@ -163,6 +166,12 @@ static INPUT_PORTS_START( thehustj ) INPUT_PORTS_END +/************************************* + * + * Graphics definitions + * + *************************************/ + static const gfx_layout charlayout = { 8,8, /* 8 x 8 characters */ @@ -191,11 +200,12 @@ static GFXDECODE_START( battlnts ) GFXDECODE_ENTRY( "gfx2", 0, spritelayout, 4*16, 1 ) /* colors 64-79 */ GFXDECODE_END -/*************************************************************************** - Machine Driver - -***************************************************************************/ +/************************************* + * + * Machine driver + * + *************************************/ static const k007342_interface bladestl_k007342_intf = { @@ -208,8 +218,35 @@ static const k007420_interface bladestl_k007420_intf = }; +static MACHINE_START( battlnts ) +{ + battlnts_state *state = (battlnts_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x4000); + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k007342 = devtag_get_device(machine, "k007342"); + state->k007420 = devtag_get_device(machine, "k007420"); + + state_save_register_global(machine, state->spritebank); + state_save_register_global_array(machine, state->layer_colorbase); +} + +static MACHINE_RESET( battlnts ) +{ + battlnts_state *state = (battlnts_state *)machine->driver_data; + + state->layer_colorbase[0] = 0; + state->layer_colorbase[1] = 0; + state->spritebank = 0; +} + static MACHINE_DRIVER_START( battlnts ) + /* driver data */ + MDRV_DRIVER_DATA(battlnts_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", HD6309, XTAL_24MHz / 2 /* 3000000*4? */) MDRV_CPU_PROGRAM_MAP(battlnts_map) @@ -218,6 +255,9 @@ static MACHINE_DRIVER_START( battlnts ) MDRV_CPU_ADD("audiocpu", Z80, XTAL_24MHz / 6 /* 3579545? */) MDRV_CPU_PROGRAM_MAP(battlnts_sound_map) + MDRV_MACHINE_START(battlnts) + MDRV_MACHINE_RESET(battlnts) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -228,7 +268,6 @@ static MACHINE_DRIVER_START( battlnts ) MDRV_GFXDECODE(battlnts) MDRV_PALETTE_LENGTH(128) - MDRV_VIDEO_START(battlnts) MDRV_VIDEO_UPDATE(battlnts) MDRV_K007342_ADD("k007342", bladestl_k007342_intf) @@ -245,11 +284,11 @@ static MACHINE_DRIVER_START( battlnts ) MACHINE_DRIVER_END -/*************************************************************************** - - Game ROMs - -***************************************************************************/ +/************************************* + * + * ROM definition(s) + * + *************************************/ ROM_START( battlnts ) ROM_REGION( 0x20000, "maincpu", 0 ) /* code + banked roms */ @@ -327,44 +366,58 @@ ROM_START( thehustlj ) ROM_END +/************************************* + * + * Driver initialization + * + *************************************/ + /* This recursive function doesn't use additional memory (it could be easily converted into an iterative one). It's called shuffle because it mimics the shuffling of a deck of cards. */ -static void shuffle(UINT8 *buf,int len) +static void shuffle( UINT8 *buf, int len ) { int i; UINT8 t; - if (len == 2) return; + if (len == 2) + return; - if (len % 4) fatalerror("shuffle() - not modulo 4"); /* must not happen */ + if (len % 4) + fatalerror("shuffle() - not modulo 4"); /* must not happen */ len /= 2; - for (i = 0;i < len/2;i++) + for (i = 0; i < len / 2; i++) { - t = buf[len/2 + i]; - buf[len/2 + i] = buf[len + i]; + t = buf[len / 2 + i]; + buf[len / 2 + i] = buf[len + i]; buf[len + i] = t; } - shuffle(buf,len); - shuffle(buf + len,len); + shuffle(buf, len); + shuffle(buf + len, len); } static DRIVER_INIT( rackemup ) { /* rearrange char ROM */ - shuffle(memory_region(machine, "gfx1"),memory_region_length(machine, "gfx1")); + shuffle(memory_region(machine, "gfx1"), memory_region_length(machine, "gfx1")); } -GAME( 1987, battlnts, 0, battlnts, battlnts, 0, ROT90, "Konami", "Battlantis", 0 ) -GAME( 1987, battlntsj,battlnts, battlnts, battlnts, 0, ROT90, "Konami", "Battlantis (Japan)", 0 ) -GAME( 1987, rackemup, 0, battlnts, thehustj, rackemup, ROT90, "Konami", "Rack 'em Up", GAME_NO_COCKTAIL ) -GAME( 1987, thehustl, rackemup, battlnts, thehustj, 0, ROT90, "Konami", "The Hustler (Japan version M)", GAME_NO_COCKTAIL ) -GAME( 1987, thehustlj,rackemup, battlnts, thehustj, 0, ROT90, "Konami", "The Hustler (Japan version J)", GAME_NO_COCKTAIL ) +/************************************* + * + * Game driver(s) + * + *************************************/ + +GAME( 1987, battlnts, 0, battlnts, battlnts, 0, ROT90, "Konami", "Battlantis", GAME_SUPPORTS_SAVE ) +GAME( 1987, battlntsj, battlnts, battlnts, battlnts, 0, ROT90, "Konami", "Battlantis (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1987, rackemup, 0, battlnts, thehustj, rackemup, ROT90, "Konami", "Rack 'em Up", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) +GAME( 1987, thehustl, rackemup, battlnts, thehustj, 0, ROT90, "Konami", "The Hustler (Japan version M)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) +GAME( 1987, thehustlj, rackemup, battlnts, thehustj, 0, ROT90, "Konami", "The Hustler (Japan version J)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/bladestl.c b/src/mame/drivers/bladestl.c index b88f4720064..fe858a624a4 100644 --- a/src/mame/drivers/bladestl.c +++ b/src/mame/drivers/bladestl.c @@ -1,27 +1,27 @@ /*************************************************************************** -Blades of Steel(GX797) (c) 1987 Konami + Blades of Steel (GX797) (c) 1987 Konami -Driver by Manuel Abadia + Driver by Manuel Abadia -Interrupts: + Interrupts: - CPU #0 (6309): - -------------- - * IRQ: not used. - * FIRQ: generated by VBLANK. - * NMI: writes the sound command to the 6809. + CPU #0 (6309): + -------------- + * IRQ: not used. + * FIRQ: generated by VBLANK. + * NMI: writes the sound command to the 6809. - CPU #1 (6809): - -------------- - * IRQ: triggered by the 6309 when a sound command is written. - * FIRQ: not used. - * NMI: not used. + CPU #1 (6809): + -------------- + * IRQ: triggered by the 6309 when a sound command is written. + * FIRQ: not used. + * NMI: not used. -Notes: - * The protection is not fully understood(Konami 051733). The - game is playable, but is not 100% accurate. - * Missing samples. + Notes: + * The protection is not fully understood(Konami 051733). The + game is playable, but is not 100% accurate. + * Missing samples. ***************************************************************************/ @@ -33,24 +33,16 @@ Notes: #include "sound/upd7759.h" #include "video/konicdev.h" #include "includes/konamipt.h" - -/* from video */ -int bladestl_spritebank; -PALETTE_INIT( bladestl ); -VIDEO_START( bladestl ); -VIDEO_UPDATE( bladestl ); - -extern void bladestl_tile_callback(int layer, int bank, int *code, int *color, int *flags); -extern void bladestl_sprite_callback(int *code, int *color); +#include "includes/bladestl.h" static INTERRUPT_GEN( bladestl_interrupt ) { - const device_config *k007342 = devtag_get_device(device->machine, "k007342"); + bladestl_state *state = (bladestl_state *)device->machine->driver_data; if (cpu_getiloops(device) == 0) { - if (k007342_is_int_enabled(k007342)) + if (k007342_is_int_enabled(state->k007342)) cpu_set_input_line(device, HD6309_FIRQ_LINE, HOLD_LINE); } else if (cpu_getiloops(device) % 2) @@ -59,22 +51,28 @@ static INTERRUPT_GEN( bladestl_interrupt ) } } +/************************************* + * + * Memory handlers + * + *************************************/ + static READ8_HANDLER( trackball_r ) { - static int last[4]; - int curr,delta; + bladestl_state *state = (bladestl_state *)space->machine->driver_data; static const char *const port[] = { "TRACKBALL_P1_1", "TRACKBALL_P1_2", "TRACKBALL_P2_1", "TRACKBALL_P1_2" }; + int curr, delta; curr = input_port_read(space->machine, port[offset]); - delta = (curr - last[offset]) & 0xff; - last[offset] = curr; + delta = (curr - state->last_track[offset]) & 0xff; + state->last_track[offset] = curr; + return (delta & 0x80) | (curr >> 1); } static WRITE8_HANDLER( bladestl_bankswitch_w ) { - UINT8 *RAM = memory_region(space->machine, "maincpu"); - int bankaddress; + bladestl_state *state = (bladestl_state *)space->machine->driver_data; /* bits 0 & 1 = coin counters */ coin_counter_w(space->machine, 0,data & 0x01); @@ -87,40 +85,50 @@ static WRITE8_HANDLER( bladestl_bankswitch_w ) /* bit 4 = relay (???) */ /* bits 5-6 = bank number */ - bankaddress = 0x10000 + ((data & 0x60) >> 5) * 0x2000; - memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]); + memory_set_bank(space->machine, "bank1", (data & 0x60) >> 5); /* bit 7 = select sprite bank */ - bladestl_spritebank = (data & 0x80) << 3; + state->spritebank = (data & 0x80) << 3; } static WRITE8_HANDLER( bladestl_sh_irqtrigger_w ) { + bladestl_state *state = (bladestl_state *)space->machine->driver_data; + soundlatch_w(space, offset, data); - cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, HOLD_LINE); + cpu_set_input_line(state->audiocpu, M6809_IRQ_LINE, HOLD_LINE); //logerror("(sound) write %02x\n", data); } -static WRITE8_DEVICE_HANDLER( bladestl_port_B_w ){ +static WRITE8_DEVICE_HANDLER( bladestl_port_B_w ) +{ /* bit 1, 2 unknown */ - upd7759_set_bank_base(device, ((data & 0x38) >> 3)*0x20000); + upd7759_set_bank_base(device, ((data & 0x38) >> 3) * 0x20000); } -static READ8_DEVICE_HANDLER( bladestl_speech_busy_r ){ +static READ8_DEVICE_HANDLER( bladestl_speech_busy_r ) +{ return upd7759_busy_r(device) ? 1 : 0; } -static WRITE8_DEVICE_HANDLER( bladestl_speech_ctrl_w ){ +static WRITE8_DEVICE_HANDLER( bladestl_speech_ctrl_w ) +{ upd7759_reset_w(device, data & 1); upd7759_start_w(device, data & 2); } +/************************************* + * + * Address maps + * + *************************************/ + static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_DEVREADWRITE("k007342", k007342_r, k007342_w) /* Color RAM + Video RAM */ AM_RANGE(0x2000, 0x21ff) AM_DEVREADWRITE("k007420", k007420_r, k007420_w) /* Sprite RAM */ AM_RANGE(0x2200, 0x23ff) AM_DEVREADWRITE("k007342", k007342_scroll_r, k007342_scroll_w) /* Scroll RAM */ - AM_RANGE(0x2400, 0x245f) AM_RAM AM_BASE_GENERIC(paletteram) /* palette */ + AM_RANGE(0x2400, 0x245f) AM_RAM AM_BASE_MEMBER(bladestl_state, paletteram) /* palette */ AM_RANGE(0x2600, 0x2607) AM_DEVWRITE("k007342", k007342_vreg_w) /* Video Registers */ AM_RANGE(0x2e00, 0x2e00) AM_READ_PORT("COINSW") /* DIPSW #3, coinsw, startsw */ AM_RANGE(0x2e01, 0x2e01) AM_READ_PORT("P1") /* 1P controls */ @@ -148,11 +156,12 @@ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x8000, 0xffff) AM_ROM ADDRESS_MAP_END -/*************************************************************************** - Input Ports - -***************************************************************************/ +/************************************* + * + * Input ports + * + *************************************/ static INPUT_PORTS_START( bladestl ) PORT_START("DSW1") @@ -231,6 +240,12 @@ INPUT_PORTS_END +/************************************* + * + * Graphics definitions + * + *************************************/ + static const gfx_layout charlayout = { 8,8, /* 8 x 8 characters */ @@ -258,11 +273,12 @@ static GFXDECODE_START( bladestl ) GFXDECODE_ENTRY( "gfx1", 0x040000, spritelayout, 32, 16 ) /* colors 32..47 but using lookup table */ GFXDECODE_END -/*************************************************************************** - Machine Driver - -***************************************************************************/ +/************************************* + * + * Machine driver + * + *************************************/ static const ym2203_interface ym2203_config = { @@ -288,8 +304,40 @@ static const k007420_interface bladestl_k007420_intf = }; +static MACHINE_START( bladestl ) +{ + bladestl_state *state = (bladestl_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x2000); + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k007342 = devtag_get_device(machine, "k007342"); + state->k007420 = devtag_get_device(machine, "k007420"); + + state_save_register_global(machine, state->spritebank); + state_save_register_global_array(machine, state->layer_colorbase); + state_save_register_global_array(machine, state->last_track); +} + +static MACHINE_RESET( bladestl ) +{ + bladestl_state *state = (bladestl_state *)machine->driver_data; + int i; + + state->layer_colorbase[0] = 0; + state->layer_colorbase[1] = 1; + state->spritebank = 0; + + for (i = 0; i < 4 ; i++) + state->last_track[i] = 0; +} + static MACHINE_DRIVER_START( bladestl ) + /* driver data */ + MDRV_DRIVER_DATA(bladestl_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", HD6309, 24000000/2) /* 24MHz/2 (?) */ MDRV_CPU_PROGRAM_MAP(main_map) @@ -300,6 +348,9 @@ static MACHINE_DRIVER_START( bladestl ) MDRV_QUANTUM_TIME(HZ(600)) + MDRV_MACHINE_START(bladestl) + MDRV_MACHINE_RESET(bladestl) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -312,7 +363,6 @@ static MACHINE_DRIVER_START( bladestl ) MDRV_PALETTE_INIT(bladestl) MDRV_PALETTE_LENGTH(32 + 16*16) - MDRV_VIDEO_START(bladestl) MDRV_VIDEO_UPDATE(bladestl) MDRV_K007342_ADD("k007342", bladestl_k007342_intf) @@ -332,11 +382,12 @@ static MACHINE_DRIVER_START( bladestl ) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.45) MACHINE_DRIVER_END -/*************************************************************************** - Game ROMs - -***************************************************************************/ +/************************************* + * + * ROM definition(s) + * + *************************************/ ROM_START( bladestl ) ROM_REGION( 0x18000, "maincpu", 0 ) /* code + banked roms */ @@ -379,5 +430,11 @@ ROM_START( bladestle ) ROM_END -GAME( 1987, bladestl, 0, bladestl, bladestl, 0, ROT90, "Konami", "Blades of Steel (version T)", 0 ) -GAME( 1987, bladestle,bladestl, bladestl, bladstle, 0, ROT90, "Konami", "Blades of Steel (version E)", 0 ) +/************************************* + * + * Game driver(s) + * + *************************************/ + +GAME( 1987, bladestl, 0, bladestl, bladestl, 0, ROT90, "Konami", "Blades of Steel (version T)", GAME_SUPPORTS_SAVE ) +GAME( 1987, bladestle, bladestl, bladestl, bladstle, 0, ROT90, "Konami", "Blades of Steel (version E)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/combatsc.c b/src/mame/drivers/combatsc.c index c18e70fe6c1..51d24e67158 100644 --- a/src/mame/drivers/combatsc.c +++ b/src/mame/drivers/combatsc.c @@ -3,14 +3,14 @@ "Combat School" (also known as "Boot Camp") - (Konami GX611) TODO: -- in combasc (and more generally the 007121) the number of sprites can be +- in combatsc (and more generally the 007121) the number of sprites can be increased from 0x40 to 0x80. There is a hack in konamiic.c to handle that, but it is wrong. If you don't pass the Iron Man stage, a few sprites are left dangling on the screen.(*not a bug, 64 sprites are the maximum) - it seems that to get correct target colors in firing range III we have to use the WRONG lookup table (the one for tiles instead of the one for sprites). -- in combascb, wrong sprite/char priority (see cpu head at beginning of arm +- in combatscb, wrong sprite/char priority (see cpu head at beginning of arm wrestling, and heads in intermission after firing range III) - hook up sound in bootleg (the current sound is a hack, making use of the Konami ROMset) @@ -127,46 +127,135 @@ Dip location and recommended settings verified with the US manual #include "sound/2203intf.h" #include "sound/upd7759.h" #include "video/konicdev.h" - -/* from video/combasc.c */ -PALETTE_INIT( combasc ); -PALETTE_INIT( combascb ); -READ8_HANDLER( combasc_video_r ); -WRITE8_HANDLER( combasc_video_w ); -VIDEO_START( combasc ); -VIDEO_START( combascb ); - -WRITE8_HANDLER( combascb_bankselect_w ); -WRITE8_HANDLER( combasc_bankselect_w ); -MACHINE_RESET( combasc ); -WRITE8_HANDLER( combasc_pf_control_w ); -READ8_HANDLER( combasc_scrollram_r ); -WRITE8_HANDLER( combasc_scrollram_w ); - -VIDEO_UPDATE( combascb ); -VIDEO_UPDATE( combasc ); -WRITE8_HANDLER( combasc_vreg_w ); +#include "includes/combatsc.h" +/************************************* + * + * Memory handlers + * + *************************************/ +WRITE8_HANDLER( combatsc_vreg_w ) +{ + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + if (data != state->vreg) + { + tilemap_mark_all_tiles_dirty(state->textlayer); + if ((data & 0x0f) != (state->vreg & 0x0f)) + tilemap_mark_all_tiles_dirty(state->bg_tilemap[0]); + if ((data >> 4) != (state->vreg >> 4)) + tilemap_mark_all_tiles_dirty(state->bg_tilemap[1]); + state->vreg = data; + } +} -static WRITE8_HANDLER( combasc_coin_counter_w ) +static WRITE8_HANDLER( combatscb_sh_irqtrigger_w ) +{ + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + soundlatch_w(space, offset, data); + cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff); +} + +static READ8_HANDLER( combatscb_io_r ) +{ + static const char *const portnames[] = { "IN0", "IN1", "DSW1", "DSW2" }; + + return input_port_read(space->machine, portnames[offset]); +} + +static WRITE8_HANDLER( combatscb_priority_w ) +{ + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + state->priority = data & 0x20; +} + +WRITE8_HANDLER( combatsc_bankselect_w ) +{ + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + + if (data & 0x40) + { + state->video_circuit = 1; + state->videoram = state->page[1]; + state->scrollram = state->scrollram1; + } + else + { + state->video_circuit = 0; + state->videoram = state->page[0]; + state->scrollram = state->scrollram0; + } + + state->priority = data & 0x20; + + if (data & 0x10) + memory_set_bank(space->machine, "bank1", (data & 0x0e) >> 1); + else + memory_set_bank(space->machine, "bank1", 8 + (data & 1)); +} + +WRITE8_HANDLER( combatscb_bankselect_w ) +{ + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + + if (data & 0x40) + { + state->video_circuit = 1; + state->videoram = state->page[1]; + } + else + { + state->video_circuit = 0; + state->videoram = state->page[0]; + } + + data = data & 0x1f; + + if (data != state->bank_select) + { + state->bank_select = data; + + if (data & 0x10) + memory_set_bank(space->machine, "bank1", (data & 0x0e) >> 1); + else + memory_set_bank(space->machine, "bank1", 8 + (data & 1)); + + if (data == 0x1f) + { + memory_set_bank(space->machine, "bank1", 8 + (data & 1)); + memory_install_read8_handler(space, 0x4400, 0x4403, 0, 0, combatscb_io_r);/* IO RAM & Video Registers */ + memory_install_write8_handler(space, 0x4400, 0x4400, 0, 0, combatscb_priority_w); + memory_install_write8_handler(space, 0x4800, 0x4800, 0, 0, combatscb_sh_irqtrigger_w); + memory_install_write8_handler(space, 0x4c00, 0x4c00, 0, 0, combatsc_vreg_w); + } + else + { + memory_install_read_bank(space, 0x4000, 0x7fff, 0, 0, "bank1"); /* banked ROM */ + memory_unmap_write(space, 0x4000, 0x7fff, 0, 0); /* banked ROM */ + } + } +} + +/****************************************************************************/ + +static WRITE8_HANDLER( combatsc_coin_counter_w ) { /* b7-b3: unused? */ /* b1: coin counter 2 */ /* b0: coin counter 1 */ - coin_counter_w(space->machine, 0,data & 0x01); - coin_counter_w(space->machine, 1,data & 0x02); + coin_counter_w(space->machine, 0, data & 0x01); + coin_counter_w(space->machine, 1, data & 0x02); } static READ8_HANDLER( trackball_r ) { - static UINT8 pos[4],sign[4]; + combatsc_state *state = (combatsc_state *)space->machine->driver_data; if (offset == 0) { - int i,dir[4]; + int i, dir[4]; static const char *const tracknames[] = { "TRACK0_Y", "TRACK0_X", "TRACK1_Y", "TRACK1_X" }; for (i = 0; i < 4; i++) @@ -175,38 +264,38 @@ static READ8_HANDLER( trackball_r ) curr = input_port_read_safe(space->machine, tracknames[i], 0xff); - dir[i] = curr - pos[i]; - sign[i] = dir[i] & 0x80; - pos[i] = curr; + dir[i] = curr - state->pos[i]; + state->sign[i] = dir[i] & 0x80; + state->pos[i] = curr; } /* fix sign for orthogonal movements */ if (dir[0] || dir[1]) { - if (!dir[0]) sign[0] = sign[1] ^ 0x80; - if (!dir[1]) sign[1] = sign[0]; + if (!dir[0]) state->sign[0] = state->sign[1] ^ 0x80; + if (!dir[1]) state->sign[1] = state->sign[0]; } if (dir[2] || dir[3]) { - if (!dir[2]) sign[2] = sign[3] ^ 0x80; - if (!dir[3]) sign[3] = sign[2]; + if (!dir[2]) state->sign[2] = state->sign[3] ^ 0x80; + if (!dir[3]) state->sign[3] = state->sign[2]; } } - return sign[offset] | (pos[offset] & 0x7f); + return state->sign[offset] | (state->pos[offset] & 0x7f); } /* the protection is a simple multiply */ -static int prot[2]; - static WRITE8_HANDLER( protection_w ) { - prot[offset] = data; + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + state->prot[offset] = data; } static READ8_HANDLER( protection_r ) { - return ((prot[0] * prot[1]) >> (offset * 8)) & 0xff; + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + return ((state->prot[0] * state->prot[1]) >> (offset * 8)) & 0xff; } static WRITE8_HANDLER( protection_clock_w ) { @@ -216,60 +305,63 @@ static WRITE8_HANDLER( protection_clock_w ) /****************************************************************************/ -static WRITE8_HANDLER( combasc_sh_irqtrigger_w ) +static WRITE8_HANDLER( combatsc_sh_irqtrigger_w ) { - cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff); + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff); } -static READ8_DEVICE_HANDLER( combasc_busy_r ) +static READ8_DEVICE_HANDLER( combatsc_busy_r ) { return upd7759_busy_r(device) ? 1 : 0; } -static WRITE8_DEVICE_HANDLER( combasc_play_w ) +static WRITE8_DEVICE_HANDLER( combatsc_play_w ) { upd7759_start_w(device, data & 2); } -static WRITE8_DEVICE_HANDLER( combasc_voice_reset_w ) +static WRITE8_DEVICE_HANDLER( combatsc_voice_reset_w ) { - upd7759_reset_w(device,data & 1); + upd7759_reset_w(device,data & 1); } -static WRITE8_DEVICE_HANDLER( combasc_portA_w ) +static WRITE8_DEVICE_HANDLER( combatsc_portA_w ) { /* unknown. always write 0 */ } -static int boost; -static emu_timer *combasc_interleave_timer; - -static READ8_DEVICE_HANDLER ( combasc_ym2203_r ) +static READ8_DEVICE_HANDLER ( combatsc_ym2203_r ) { + combatsc_state *state = (combatsc_state *)device->machine->driver_data; int status = ym2203_r(device,offset); - if (cpu_get_pc(cputag_get_cpu(device->machine, "audiocpu")) == 0x334) + if (cpu_get_pc(state->audiocpu) == 0x334) { - if (boost) + if (state->boost) { - boost = 0; - timer_adjust_periodic(combasc_interleave_timer, attotime_zero, 0, cputag_clocks_to_attotime(device->machine, "audiocpu", 80)); + state->boost = 0; + timer_adjust_periodic(state->interleave_timer, attotime_zero, 0, cpu_clocks_to_attotime(state->audiocpu, 80)); } else if (status & 2) { - boost = 1; - timer_adjust_oneshot(combasc_interleave_timer, attotime_zero, 0); + state->boost = 1; + timer_adjust_oneshot(state->interleave_timer, attotime_zero, 0); } } - return(status); + return status; } -/****************************************************************************/ +/************************************* + * + * Address maps + * + *************************************/ -static ADDRESS_MAP_START( combasc_map, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x0007) AM_WRITE(combasc_pf_control_w) - AM_RANGE(0x0020, 0x005f) AM_READWRITE(combasc_scrollram_r, combasc_scrollram_w) +static ADDRESS_MAP_START( combatsc_map, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x0007) AM_WRITE(combatsc_pf_control_w) + AM_RANGE(0x0020, 0x005f) AM_READWRITE(combatsc_scrollram_r, combatsc_scrollram_w) // AM_RANGE(0x0060, 0x00ff) AM_WRITEONLY /* RAM */ AM_RANGE(0x0200, 0x0201) AM_READWRITE(protection_r, protection_w) @@ -280,26 +372,26 @@ static ADDRESS_MAP_START( combasc_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0402, 0x0402) AM_READ_PORT("DSW1") /* DSW #1 */ AM_RANGE(0x0403, 0x0403) AM_READ_PORT("DSW2") /* DSW #2 */ AM_RANGE(0x0404, 0x0407) AM_READ(trackball_r) /* 1P & 2P controls / trackball */ - AM_RANGE(0x0408, 0x0408) AM_WRITE(combasc_coin_counter_w) /* coin counters */ - AM_RANGE(0x040c, 0x040c) AM_WRITE(combasc_vreg_w) - AM_RANGE(0x0410, 0x0410) AM_WRITE(combasc_bankselect_w) + AM_RANGE(0x0408, 0x0408) AM_WRITE(combatsc_coin_counter_w) /* coin counters */ + AM_RANGE(0x040c, 0x040c) AM_WRITE(combatsc_vreg_w) + AM_RANGE(0x0410, 0x0410) AM_WRITE(combatsc_bankselect_w) AM_RANGE(0x0414, 0x0414) AM_WRITE(soundlatch_w) - AM_RANGE(0x0418, 0x0418) AM_WRITE(combasc_sh_irqtrigger_w) + AM_RANGE(0x0418, 0x0418) AM_WRITE(combatsc_sh_irqtrigger_w) AM_RANGE(0x041c, 0x041c) AM_WRITE(watchdog_reset_w) /* watchdog reset? */ - AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_GENERIC(paletteram) /* palette */ + AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_MEMBER(combatsc_state, paletteram) /* palette */ AM_RANGE(0x0800, 0x1fff) AM_RAM /* RAM */ - AM_RANGE(0x2000, 0x3fff) AM_READWRITE(combasc_video_r, combasc_video_w) + AM_RANGE(0x2000, 0x3fff) AM_READWRITE(combatsc_video_r, combatsc_video_w) AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1") /* banked ROM area */ AM_RANGE(0x8000, 0xffff) AM_ROM /* ROM */ ADDRESS_MAP_END -static ADDRESS_MAP_START( combascb_map, ADDRESS_SPACE_PROGRAM, 8 ) +static ADDRESS_MAP_START( combatscb_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x04ff) AM_RAM - AM_RANGE(0x0500, 0x0500) AM_WRITE(combascb_bankselect_w) - AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_GENERIC(paletteram) /* palette */ + AM_RANGE(0x0500, 0x0500) AM_WRITE(combatscb_bankselect_w) + AM_RANGE(0x0600, 0x06ff) AM_RAM AM_BASE_MEMBER(combatsc_state, paletteram) /* palette */ AM_RANGE(0x0800, 0x1fff) AM_RAM - AM_RANGE(0x2000, 0x3fff) AM_READWRITE(combasc_video_r, combasc_video_w) + AM_RANGE(0x2000, 0x3fff) AM_READWRITE(combatsc_video_r, combatsc_video_w) AM_RANGE(0x4000, 0x7fff) AM_ROMBANK("bank1") /* banked ROM/RAM area */ AM_RANGE(0x8000, 0xffff) AM_ROM /* ROM */ ADDRESS_MAP_END @@ -317,20 +409,26 @@ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_END #endif -static ADDRESS_MAP_START( combasc_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) +static ADDRESS_MAP_START( combatsc_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x7fff) AM_ROM /* ROM */ AM_RANGE(0x8000, 0x87ff) AM_RAM /* RAM */ - AM_RANGE(0x9000, 0x9000) AM_DEVWRITE("upd", combasc_play_w) /* upd7759 play voice */ + AM_RANGE(0x9000, 0x9000) AM_DEVWRITE("upd", combatsc_play_w) /* upd7759 play voice */ AM_RANGE(0xa000, 0xa000) AM_DEVWRITE("upd", upd7759_port_w) /* upd7759 voice select */ - AM_RANGE(0xb000, 0xb000) AM_DEVREAD("upd", combasc_busy_r) /* upd7759 busy? */ - AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("upd", combasc_voice_reset_w) /* upd7759 reset? */ + AM_RANGE(0xb000, 0xb000) AM_DEVREAD("upd", combatsc_busy_r) /* upd7759 busy? */ + AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("upd", combatsc_voice_reset_w) /* upd7759 reset? */ AM_RANGE(0xd000, 0xd000) AM_READ(soundlatch_r) /* soundlatch_r? */ - AM_RANGE(0xe000, 0xe001) AM_DEVREADWRITE("ymsnd", combasc_ym2203_r, ym2203_w) /* YM 2203 intercepted */ + AM_RANGE(0xe000, 0xe001) AM_DEVREADWRITE("ymsnd", combatsc_ym2203_r, ym2203_w) /* YM 2203 intercepted */ ADDRESS_MAP_END +/************************************* + * + * Input ports + * + *************************************/ + static INPUT_PORTS_START( common_inputs ) PORT_START("IN0") PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) @@ -411,7 +509,7 @@ static INPUT_PORTS_START( dips ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) INPUT_PORTS_END -static INPUT_PORTS_START( combasc ) +static INPUT_PORTS_START( combatsc ) PORT_INCLUDE( dips ) PORT_INCLUDE( common_inputs ) @@ -427,7 +525,7 @@ static INPUT_PORTS_START( combasc ) PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) INPUT_PORTS_END -static INPUT_PORTS_START( combasct ) +static INPUT_PORTS_START( combatsct ) PORT_INCLUDE( dips ) PORT_INCLUDE( common_inputs ) @@ -447,7 +545,7 @@ static INPUT_PORTS_START( combasct ) PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(10) PORT_KEYDELTA(10) PORT_PLAYER(2) INPUT_PORTS_END -static INPUT_PORTS_START( combascb ) +static INPUT_PORTS_START( combatscb ) PORT_INCLUDE( dips ) PORT_MODIFY("DSW2") @@ -479,6 +577,12 @@ INPUT_PORTS_END +/************************************* + * + * Graphics definitions + * + *************************************/ + static const gfx_layout gfxlayout = { 8,8, @@ -518,18 +622,25 @@ static const gfx_layout sprite_layout = 8*8*4 }; -static GFXDECODE_START( combasc ) +static GFXDECODE_START( combatsc ) GFXDECODE_ENTRY( "gfx1", 0x00000, gfxlayout, 0, 8*16 ) GFXDECODE_ENTRY( "gfx2", 0x00000, gfxlayout, 0, 8*16 ) GFXDECODE_END -static GFXDECODE_START( combascb ) +static GFXDECODE_START( combatscb ) GFXDECODE_ENTRY( "gfx1", 0x00000, tile_layout, 0, 8*16 ) GFXDECODE_ENTRY( "gfx1", 0x40000, tile_layout, 0, 8*16 ) GFXDECODE_ENTRY( "gfx2", 0x00000, sprite_layout, 0, 8*16 ) GFXDECODE_ENTRY( "gfx2", 0x40000, sprite_layout, 0, 8*16 ) GFXDECODE_END + +/************************************* + * + * Machine driver + * + *************************************/ + static const ym2203_interface ym2203_config = { { @@ -537,27 +648,84 @@ static const ym2203_interface ym2203_config = AY8910_DEFAULT_LOADS, DEVCB_NULL, DEVCB_NULL, - DEVCB_HANDLER(combasc_portA_w), + DEVCB_HANDLER(combatsc_portA_w), DEVCB_NULL }, NULL }; +static MACHINE_START( combatsc ) +{ + combatsc_state *state = (combatsc_state *)machine->driver_data; + UINT8 *MEM = memory_region(machine, "maincpu") + 0x38000; + + state->io_ram = MEM + 0x0000; + state->page[0] = MEM + 0x4000; + state->page[1] = MEM + 0x6000; + + state->interleave_timer = timer_alloc(machine, NULL, NULL); + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k007121_1 = devtag_get_device(machine, "k007121_1"); + state->k007121_2 = devtag_get_device(machine, "k007121_2"); + + memory_configure_bank(machine, "bank1", 0, 10, memory_region(machine, "maincpu") + 0x10000, 0x4000); + + state_save_register_global(machine, state->priority); + state_save_register_global(machine, state->vreg); + state_save_register_global(machine, state->bank_select); + state_save_register_global(machine, state->video_circuit); + state_save_register_global(machine, state->boost); + state_save_register_global_array(machine, state->prot); + state_save_register_global_array(machine, state->pos); + state_save_register_global_array(machine, state->sign); +} + + +static MACHINE_RESET( combatsc ) +{ + combatsc_state *state = (combatsc_state *)machine->driver_data; + const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); + int i; + + memset(state->io_ram, 0x00, 0x4000); + memset(state->page[0], 0x00, 0x2000); + memset(state->page[1], 0x00, 0x2000); + + state->vreg = -1; + state->boost = 1; + state->bank_select = -1; + state->prot[0] = 0; + state->prot[1] = 0; + + for (i = 0; i < 4; i++) + { + state->pos[i] = 0; + state->sign[i] = 0; + } + + combatsc_bankselect_w(space, 0, 0); +} + /* combat school (original) */ -static MACHINE_DRIVER_START( combasc ) +static MACHINE_DRIVER_START( combatsc ) + + /* driver data */ + MDRV_DRIVER_DATA(combatsc_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", HD6309, 3000000*4) /* 3 MHz? */ - MDRV_CPU_PROGRAM_MAP(combasc_map) + MDRV_CPU_PROGRAM_MAP(combatsc_map) MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) MDRV_CPU_ADD("audiocpu", Z80,3579545) /* 3.579545 MHz */ - MDRV_CPU_PROGRAM_MAP(combasc_sound_map) + MDRV_CPU_PROGRAM_MAP(combatsc_sound_map) MDRV_QUANTUM_TIME(HZ(1200)) - MDRV_MACHINE_RESET(combasc) + MDRV_MACHINE_START(combatsc) + MDRV_MACHINE_RESET(combatsc) /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) @@ -567,12 +735,12 @@ static MACHINE_DRIVER_START( combasc ) MDRV_SCREEN_SIZE(32*8, 32*8) MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) - MDRV_GFXDECODE(combasc) + MDRV_GFXDECODE(combatsc) MDRV_PALETTE_LENGTH(8*16*16) - MDRV_PALETTE_INIT(combasc) - MDRV_VIDEO_START(combasc) - MDRV_VIDEO_UPDATE(combasc) + MDRV_PALETTE_INIT(combatsc) + MDRV_VIDEO_START(combatsc) + MDRV_VIDEO_UPDATE(combatsc) MDRV_K007121_ADD("k007121_1") MDRV_K007121_ADD("k007121_2") @@ -589,19 +757,23 @@ static MACHINE_DRIVER_START( combasc ) MACHINE_DRIVER_END /* combat school (bootleg on different hardware) */ -static MACHINE_DRIVER_START( combascb ) +static MACHINE_DRIVER_START( combatscb ) + + /* driver data */ + MDRV_DRIVER_DATA(combatsc_state) /* basic machine hardware */ MDRV_CPU_ADD("maincpu", HD6309, 3000000*4) /* 3 MHz? */ - MDRV_CPU_PROGRAM_MAP(combascb_map) + MDRV_CPU_PROGRAM_MAP(combatscb_map) MDRV_CPU_VBLANK_INT("screen", irq0_line_hold) MDRV_CPU_ADD("audiocpu", Z80,3579545) /* 3.579545 MHz */ - MDRV_CPU_PROGRAM_MAP(combasc_sound_map) /* FAKE */ + MDRV_CPU_PROGRAM_MAP(combatsc_sound_map) /* FAKE */ MDRV_QUANTUM_TIME(HZ(1200)) - MDRV_MACHINE_RESET(combasc) + MDRV_MACHINE_START(combatsc) + MDRV_MACHINE_RESET(combatsc) /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) @@ -611,12 +783,12 @@ static MACHINE_DRIVER_START( combascb ) MDRV_SCREEN_SIZE(32*8, 32*8) MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1) - MDRV_GFXDECODE(combascb) + MDRV_GFXDECODE(combatscb) MDRV_PALETTE_LENGTH(8*16*16) - MDRV_PALETTE_INIT(combascb) - MDRV_VIDEO_START(combascb) - MDRV_VIDEO_UPDATE(combascb) + MDRV_PALETTE_INIT(combatscb) + MDRV_VIDEO_START(combatscb) + MDRV_VIDEO_UPDATE(combatscb) /* We are using the original sound subsystem */ MDRV_SPEAKER_STANDARD_MONO("mono") @@ -631,7 +803,13 @@ MACHINE_DRIVER_END -ROM_START( combasc ) +/************************************* + * + * ROM definition(s) + * + *************************************/ + +ROM_START( combatsc ) ROM_REGION( 0x40000, "maincpu", 0 ) /* 6309 code */ ROM_LOAD( "611g01.rom", 0x30000, 0x08000, CRC(857ffffe) SHA1(de7566d58314df4b7fdc07eb31a3f9bdd12d1a73) ) ROM_CONTINUE( 0x08000, 0x08000 ) @@ -664,7 +842,7 @@ ROM_START( combasc ) ROM_LOAD( "pal20l8.8h", 0x0400, 0x0144, NO_DUMP ) /* PAL is read protected */ ROM_END -ROM_START( combasct ) +ROM_START( combatsct ) ROM_REGION( 0x40000, "maincpu", 0 ) /* 6309 code */ ROM_LOAD( "g01.rom", 0x30000, 0x08000, CRC(489c132f) SHA1(c717195f89add4be4a21ecc1ddd58361b0ab4a74) ) ROM_CONTINUE( 0x08000, 0x08000 ) @@ -692,7 +870,7 @@ ROM_START( combasct ) ROM_LOAD( "611g04.rom", 0x00000, 0x20000, CRC(2987e158) SHA1(87c5129161d3be29a339083349807e60b625c3f7) ) ROM_END -ROM_START( combascj ) +ROM_START( combatscj ) ROM_REGION( 0x40000, "maincpu", 0 ) /* 6309 code */ ROM_LOAD( "611p01.a14", 0x30000, 0x08000, CRC(d748268e) SHA1(91588b6a0d3af47065204b980a56544a9f29b6d9) ) ROM_CONTINUE( 0x08000, 0x08000 ) @@ -748,7 +926,7 @@ ROM_START( bootcamp ) ROM_LOAD( "611g04.rom", 0x00000, 0x20000, CRC(2987e158) SHA1(87c5129161d3be29a339083349807e60b625c3f7) ) ROM_END -ROM_START( combascb ) +ROM_START( combatscb ) ROM_REGION( 0x40000, "maincpu", 0 ) /* 6809 code */ ROM_LOAD( "combat.002", 0x30000, 0x08000, CRC(0996755d) SHA1(bb6bbbf7ab3b5fab5e1c6cebc7b3f0d720493c3b) ) ROM_CONTINUE( 0x08000, 0x08000 ) @@ -789,35 +967,27 @@ ROM_START( combascb ) ROM_END +/************************************* + * + * Driver initialization + * + *************************************/ -static void combasc_init_common(running_machine *machine) -{ - boost = 1; - combasc_interleave_timer = timer_alloc(machine, NULL, NULL); -} - -static DRIVER_INIT( combasct ) -{ - combasc_init_common(machine); -} - -static DRIVER_INIT( combasc ) +static DRIVER_INIT( combatsc ) { /* joystick instead of trackball */ memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0404, 0x0404, 0, 0, "IN1"); - - combasc_init_common(machine); -} - -static DRIVER_INIT( combascb ) -{ - combasc_init_common(machine); } +/************************************* + * + * Game driver(s) + * + *************************************/ -GAME( 1988, combasc, 0, combasc, combasc, combasc, ROT0, "Konami", "Combat School (joystick)", 0 ) -GAME( 1987, combasct, combasc, combasc, combasct, combasct, ROT0, "Konami", "Combat School (trackball)", 0 ) -GAME( 1987, combascj, combasc, combasc, combasct, combasct, ROT0, "Konami", "Combat School (Japan trackball)", 0 ) -GAME( 1987, bootcamp, combasc, combasc, combasct, combasct, ROT0, "Konami", "Boot Camp", 0 ) -GAME( 1988, combascb, combasc, combascb, combascb, combascb, ROT0, "bootleg", "Combat School (bootleg)", GAME_IMPERFECT_COLORS ) +GAME( 1988, combatsc, 0, combatsc, combatsc, combatsc, ROT0, "Konami", "Combat School (joystick)", 0 ) +GAME( 1987, combatsct, combatsc, combatsc, combatsct, 0, ROT0, "Konami", "Combat School (trackball)", 0 ) +GAME( 1987, combatscj, combatsc, combatsc, combatsct, 0, ROT0, "Konami", "Combat School (Japan trackball)", 0 ) +GAME( 1987, bootcamp, combatsc, combatsc, combatsct, 0, ROT0, "Konami", "Boot Camp", 0 ) +GAME( 1988, combatscb, combatsc, combatscb, combatscb, 0, ROT0, "bootleg", "Combat School (bootleg)", GAME_IMPERFECT_COLORS ) diff --git a/src/mame/drivers/contra.c b/src/mame/drivers/contra.c index 07d549308e2..e793b657acf 100644 --- a/src/mame/drivers/contra.c +++ b/src/mame/drivers/contra.c @@ -19,53 +19,35 @@ Dip locations and factory settings verified with manual #include "driver.h" #include "cpu/m6809/m6809.h" #include "sound/2151intf.h" -#include "includes/konamipt.h" #include "video/konicdev.h" - -extern UINT8 *contra_fg_vram,*contra_fg_cram; -extern UINT8 *contra_bg_vram,*contra_bg_cram; -extern UINT8 *contra_text_vram,*contra_text_cram; - -PALETTE_INIT( contra ); - -WRITE8_HANDLER( contra_fg_vram_w ); -WRITE8_HANDLER( contra_fg_cram_w ); -WRITE8_HANDLER( contra_bg_vram_w ); -WRITE8_HANDLER( contra_bg_cram_w ); -WRITE8_HANDLER( contra_text_vram_w ); -WRITE8_HANDLER( contra_text_cram_w ); - -WRITE8_HANDLER( contra_K007121_ctrl_0_w ); -WRITE8_HANDLER( contra_K007121_ctrl_1_w ); -VIDEO_UPDATE( contra ); -VIDEO_START( contra ); +#include "includes/konamipt.h" +#include "includes/contra.h" static WRITE8_HANDLER( contra_bankswitch_w ) { - UINT32 bankaddress; - UINT8 *RAM = memory_region(space->machine, "maincpu"); - - - bankaddress = 0x10000 + (data & 0x0f) * 0x2000; - if (bankaddress < 0x28000) /* for safety */ - memory_set_bankptr(space->machine, "bank1",&RAM[bankaddress]); + if ((data & 0x0f) < 12) /* for safety */ + memory_set_bank(space->machine, "bank1", data & 0x0f); } static WRITE8_HANDLER( contra_sh_irqtrigger_w ) { - cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, HOLD_LINE); + contra_state *state = (contra_state *)space->machine->driver_data; + cpu_set_input_line(state->audiocpu, M6809_IRQ_LINE, HOLD_LINE); } static WRITE8_HANDLER( contra_coin_counter_w ) { - if (data & 0x01) coin_counter_w(space->machine, 0,data & 0x01); - if (data & 0x02) coin_counter_w(space->machine, 1,(data & 0x02) >> 1); + if (data & 0x01) + coin_counter_w(space->machine, 0, data & 0x01); + + if (data & 0x02) + coin_counter_w(space->machine, 1, (data & 0x02) >> 1); } static WRITE8_HANDLER( cpu_sound_command_w ) { - soundlatch_w(space,offset,data); + soundlatch_w(space, offset, data); } @@ -86,19 +68,19 @@ static ADDRESS_MAP_START( contra_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x001e, 0x001e) AM_WRITENOP /* ? */ AM_RANGE(0x0060, 0x0067) AM_WRITE(contra_K007121_ctrl_1_w) - AM_RANGE(0x0c00, 0x0cff) AM_RAM AM_BASE_GENERIC(paletteram) + AM_RANGE(0x0c00, 0x0cff) AM_RAM AM_BASE_MEMBER(contra_state, paletteram) AM_RANGE(0x1000, 0x1fff) AM_RAM AM_RANGE(0x2000, 0x5fff) AM_READONLY - AM_RANGE(0x2000, 0x23ff) AM_WRITE(contra_fg_cram_w) AM_BASE(&contra_fg_cram) - AM_RANGE(0x2400, 0x27ff) AM_WRITE(contra_fg_vram_w) AM_BASE(&contra_fg_vram) - AM_RANGE(0x2800, 0x2bff) AM_WRITE(contra_text_cram_w) AM_BASE(&contra_text_cram) - AM_RANGE(0x2c00, 0x2fff) AM_WRITE(contra_text_vram_w) AM_BASE(&contra_text_vram) + AM_RANGE(0x2000, 0x23ff) AM_WRITE(contra_fg_cram_w) AM_BASE_MEMBER(contra_state, fg_cram) + AM_RANGE(0x2400, 0x27ff) AM_WRITE(contra_fg_vram_w) AM_BASE_MEMBER(contra_state, fg_vram) + AM_RANGE(0x2800, 0x2bff) AM_WRITE(contra_text_cram_w) AM_BASE_MEMBER(contra_state, tx_cram) + AM_RANGE(0x2c00, 0x2fff) AM_WRITE(contra_text_vram_w) AM_BASE_MEMBER(contra_state, tx_vram) AM_RANGE(0x3000, 0x37ff) AM_WRITEONLY AM_BASE_GENERIC(spriteram)/* 2nd bank is at 0x5000 */ AM_RANGE(0x3800, 0x3fff) AM_WRITEONLY // second sprite buffer - AM_RANGE(0x4000, 0x43ff) AM_WRITE(contra_bg_cram_w) AM_BASE(&contra_bg_cram) - AM_RANGE(0x4400, 0x47ff) AM_WRITE(contra_bg_vram_w) AM_BASE(&contra_bg_vram) + AM_RANGE(0x4000, 0x43ff) AM_WRITE(contra_bg_cram_w) AM_BASE_MEMBER(contra_state, bg_cram) + AM_RANGE(0x4400, 0x47ff) AM_WRITE(contra_bg_vram_w) AM_BASE_MEMBER(contra_state, bg_vram) AM_RANGE(0x4800, 0x5fff) AM_WRITEONLY AM_RANGE(0x6000, 0x7fff) AM_ROMBANK("bank1") @@ -187,8 +169,23 @@ GFXDECODE_END +static MACHINE_START( contra ) +{ + contra_state *state = (contra_state *)machine->driver_data; + UINT8 *ROM = memory_region(machine, "maincpu"); + + memory_configure_bank(machine, "bank1", 0, 12, &ROM[0x10000], 0x2000); + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k007121_1 = devtag_get_device(machine, "k007121_1"); + state->k007121_2 = devtag_get_device(machine, "k007121_2"); +} + static MACHINE_DRIVER_START( contra ) + /* driver data */ + MDRV_DRIVER_DATA(contra_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M6809, XTAL_24MHz/16) /* 1500000? */ MDRV_CPU_PROGRAM_MAP(contra_map) @@ -199,6 +196,8 @@ static MACHINE_DRIVER_START( contra ) MDRV_QUANTUM_TIME(HZ(600)) /* 10 CPU slices per frame - enough for the sound CPU to read all commands */ + MDRV_MACHINE_START(contra) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -441,10 +440,10 @@ ROM_END -GAME( 1987, contra, 0, contra, contra, 0, ROT90, "Konami", "Contra (US, Set 1)", 0 ) -GAME( 1987, contra1, contra, contra, contra, 0, ROT90, "Konami", "Contra (US, Set 2)", 0 ) -GAME( 1987, contrab, contra, contra, contra, 0, ROT90, "bootleg", "Contra (bootleg)", 0 ) -GAME( 1987, contraj, contra, contra, contra, 0, ROT90, "Konami", "Contra (Japan)", 0 ) -GAME( 1987, contrajb, contra, contra, contra, 0, ROT90, "bootleg", "Contra (Japan bootleg)", 0 ) -GAME( 1987, gryzor, contra, contra, contra, 0, ROT90, "Konami", "Gryzor (Set 1)", 0 ) -GAME( 1987, gryzora, contra, contra, contra, 0, ROT90, "Konami", "Gryzor (Set 2)", 0 ) +GAME( 1987, contra, 0, contra, contra, 0, ROT90, "Konami", "Contra (US, Set 1)", GAME_SUPPORTS_SAVE ) +GAME( 1987, contra1, contra, contra, contra, 0, ROT90, "Konami", "Contra (US, Set 2)", GAME_SUPPORTS_SAVE ) +GAME( 1987, contrab, contra, contra, contra, 0, ROT90, "bootleg", "Contra (bootleg)", GAME_SUPPORTS_SAVE ) +GAME( 1987, contraj, contra, contra, contra, 0, ROT90, "Konami", "Contra (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1987, contrajb, contra, contra, contra, 0, ROT90, "bootleg", "Contra (Japan bootleg)", GAME_SUPPORTS_SAVE ) +GAME( 1987, gryzor, contra, contra, contra, 0, ROT90, "Konami", "Gryzor (Set 1)", GAME_SUPPORTS_SAVE ) +GAME( 1987, gryzora, contra, contra, contra, 0, ROT90, "Konami", "Gryzor (Set 2)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/crshrace.c b/src/mame/drivers/crshrace.c index 1ff87a80d08..bd3e7de988a 100644 --- a/src/mame/drivers/crshrace.c +++ b/src/mame/drivers/crshrace.c @@ -143,7 +143,7 @@ static READ16_HANDLER( extrarom1_r ) offset *= 2; - return rom[offset] | (rom[offset+1] << 8); + return rom[offset] | (rom[offset + 1] << 8); } static READ16_HANDLER( extrarom2_r ) @@ -152,7 +152,7 @@ static READ16_HANDLER( extrarom2_r ) offset *= 2; - return rom[offset] | (rom[offset+1] << 8); + return rom[offset] | (rom[offset + 1] << 8); } static WRITE8_HANDLER( crshrace_sh_bankswitch_w ) @@ -163,26 +163,28 @@ static WRITE8_HANDLER( crshrace_sh_bankswitch_w ) } -static int pending_command; - static WRITE16_HANDLER( sound_command_w ) { + crshrace_state *state = (crshrace_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) { - pending_command = 1; - soundlatch_w(space,offset,data & 0xff); - cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); + state->pending_command = 1; + soundlatch_w(space, offset, data & 0xff); + cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE); } } static CUSTOM_INPUT( country_sndpending_r ) { - return pending_command; + crshrace_state *state = (crshrace_state *)field->port->machine->driver_data; + return state->pending_command; } static WRITE8_HANDLER( pending_command_clear_w ) { - pending_command = 0; + crshrace_state *state = (crshrace_state *)space->machine->driver_data; + state->pending_command = 0; } @@ -193,11 +195,11 @@ static ADDRESS_MAP_START( crshrace_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x400000, 0x4fffff) AM_READ(extrarom2_r) AM_RANGE(0x500000, 0x5fffff) AM_READ(extrarom2_r) /* mirror */ AM_RANGE(0xa00000, 0xa0ffff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2) - AM_RANGE(0xd00000, 0xd01fff) AM_RAM_WRITE(crshrace_videoram1_w) AM_BASE(&crshrace_videoram1) + AM_RANGE(0xd00000, 0xd01fff) AM_RAM_WRITE(crshrace_videoram1_w) AM_BASE_MEMBER(crshrace_state, videoram1) AM_RANGE(0xe00000, 0xe01fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) AM_RANGE(0xfe0000, 0xfeffff) AM_RAM AM_RANGE(0xffc000, 0xffc001) AM_WRITE(crshrace_roz_bank_w) - AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(crshrace_videoram2_w) AM_BASE(&crshrace_videoram2) + AM_RANGE(0xffd000, 0xffdfff) AM_RAM_WRITE(crshrace_videoram2_w) AM_BASE_MEMBER(crshrace_state, videoram2) AM_RANGE(0xffe000, 0xffefff) AM_RAM_WRITE(paletteram16_xGGGGGBBBBBRRRRR_word_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0xfff000, 0xfff001) AM_READ_PORT("P1") AM_WRITE(crshrace_gfxctrl_w) AM_RANGE(0xfff002, 0xfff003) AM_READ_PORT("P2") @@ -426,9 +428,10 @@ GFXDECODE_END -static void irqhandler(const device_config *device, int irq) +static void irqhandler( const device_config *device, int irq ) { - cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE); + crshrace_state *state = (crshrace_state *)device->machine->driver_data; + cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE); } static const ym2610_interface ym2610_config = @@ -443,8 +446,34 @@ static const k053936_interface crshrace_k053936_intf = }; +static MACHINE_START( crshrace ) +{ + crshrace_state *state = (crshrace_state *)machine->driver_data; + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k053936 = devtag_get_device(machine, "k053936"); + + state_save_register_global(machine, state->roz_bank); + state_save_register_global(machine, state->gfxctrl); + state_save_register_global(machine, state->flipscreen); + state_save_register_global(machine, state->pending_command); +} + +static MACHINE_RESET( crshrace ) +{ + crshrace_state *state = (crshrace_state *)machine->driver_data; + + state->roz_bank = 0; + state->gfxctrl = 0; + state->flipscreen = 0; + state->pending_command = 0; +} + static MACHINE_DRIVER_START( crshrace ) + /* driver data */ + MDRV_DRIVER_DATA(crshrace_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", M68000,16000000) /* 16 MHz ??? */ MDRV_CPU_PROGRAM_MAP(crshrace_map) @@ -454,6 +483,9 @@ static MACHINE_DRIVER_START( crshrace ) MDRV_CPU_PROGRAM_MAP(sound_map) MDRV_CPU_IO_MAP(sound_io_map) + MDRV_MACHINE_START(crshrace) + MDRV_MACHINE_RESET(crshrace) + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) @@ -554,7 +586,7 @@ ROM_END #ifdef UNUSED_FUNCTION -void crshrace_patch_code(UINT16 offset) +void crshrace_patch_code( UINT16 offset ) { /* A hack which shows 3 player mode in code which is disabled */ UINT16 *RAM = (UINT16 *)memory_region(machine, "maincpu"); @@ -580,6 +612,5 @@ static DRIVER_INIT( crshrac2 ) } -GAME( 1993, crshrace, 0, crshrace, crshrace, crshrace, ROT270, "Video System Co.", "Lethal Crash Race (set 1)", GAME_NO_COCKTAIL ) -GAME( 1993, crshrace2,crshrace, crshrace, crshrac2, crshrac2, ROT270, "Video System Co.", "Lethal Crash Race (set 2)", GAME_NO_COCKTAIL ) - +GAME( 1993, crshrace, 0, crshrace, crshrace, crshrace, ROT270, "Video System Co.", "Lethal Crash Race (set 1)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) +GAME( 1993, crshrace2,crshrace, crshrace, crshrac2, crshrac2, ROT270, "Video System Co.", "Lethal Crash Race (set 2)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/moo.c b/src/mame/drivers/moo.c index ff164b3cfa1..4ea76860942 100644 --- a/src/mame/drivers/moo.c +++ b/src/mame/drivers/moo.c @@ -42,14 +42,14 @@ Bucky: ***************************************************************************/ #include "driver.h" -#include "video/konamiic.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "machine/eeprom.h" #include "sound/2151intf.h" #include "sound/okim6295.h" #include "sound/k054539.h" -#include "konamipt.h" +#include "video/konicdev.h" +#include "includes/konamipt.h" VIDEO_START(moo); VIDEO_UPDATE(moo); @@ -59,6 +59,9 @@ static UINT16 *workram; static UINT16 protram[16]; static UINT16 cur_control2; +extern void moo_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags); +extern void moo_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask); + static const eeprom_interface eeprom_intf = { @@ -123,6 +126,8 @@ static WRITE16_HANDLER( control2_w ) /* bit 10 is watchdog */ /* bit 11 is enable irq 4 (unconfirmed) */ + const device_config *k053246 = devtag_get_device(space->machine, "k053246"); + COMBINE_DATA(&cur_control2); eeprom_write_bit(cur_control2 & 0x01); @@ -131,21 +136,23 @@ static WRITE16_HANDLER( control2_w ) if (data & 0x100) { - K053246_set_OBJCHA_line(ASSERT_LINE); + k053246_set_objcha_line(k053246, ASSERT_LINE); } else { - K053246_set_OBJCHA_line(CLEAR_LINE); + k053246_set_objcha_line(k053246, CLEAR_LINE); } } static void moo_objdma(running_machine *machine, int type) { - int counter, num_inactive; + int num_inactive; UINT16 *src, *dst, zmask; + const device_config *k053246 = devtag_get_device(machine, "k053246"); + int counter = k053247_get_dy(k053246); - K053247_export_config(&dst, 0, 0, 0, &counter); + k053247_get_ram(k053246, &dst); src = machine->generic.spriteram.u16; num_inactive = counter = 256; @@ -173,7 +180,9 @@ static TIMER_CALLBACK( dmaend_callback ) static INTERRUPT_GEN(moo_interrupt) { - if (K053246_is_IRQ_enabled()) + const device_config *k053246 = devtag_get_device(device->machine, "k053246"); + + if (k053246_is_irq_enabled(k053246)) { moo_objdma(device->machine, game_type); @@ -234,24 +243,28 @@ static WRITE8_HANDLER( sound_bankswitch_w ) /* of RAM, but they put 0x10000 there. The CPU can access them all. */ static READ16_HANDLER( K053247_scattered_word_r ) { + const device_config *k053246 = devtag_get_device(device->machine, "k053246"); + if (offset & 0x0078) return space->machine->generic.spriteram.u16[offset]; else { offset = (offset & 0x0007) | ((offset & 0x7f80) >> 4); - return K053247_word_r(space,offset,mem_mask); + return k053247_word_r(k053246, offset, mem_mask); } } static WRITE16_HANDLER( K053247_scattered_word_w ) { + const device_config *k053246 = devtag_get_device(device->machine, "k053246"); + if (offset & 0x0078) COMBINE_DATA(space->machine->generic.spriteram.u16+offset); else { offset = (offset & 0x0007) | ((offset & 0x7f80) >> 4); - K053247_word_w(space,offset,data,mem_mask); + k053247_word_w(k053246, offset, data, mem_mask); } } @@ -297,12 +310,12 @@ static WRITE16_DEVICE_HANDLER( moobl_oki_bank_w ) static ADDRESS_MAP_START( moo_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM - AM_RANGE(0x0c0000, 0x0c003f) AM_WRITE(K056832_word_w) - AM_RANGE(0x0c2000, 0x0c2007) AM_WRITE(K053246_word_w) + AM_RANGE(0x0c0000, 0x0c003f) AM_DEVWRITE("k056832", k056832_word_w) + AM_RANGE(0x0c2000, 0x0c2007) AM_DEVWRITE("k053246", k053246_word_w) - AM_RANGE(0x0c4000, 0x0c4001) AM_READ(K053246_word_r) - AM_RANGE(0x0ca000, 0x0ca01f) AM_WRITE(K054338_word_w) /* K054338 alpha blending engine */ - AM_RANGE(0x0cc000, 0x0cc01f) AM_WRITE(K053251_lsb_w) + AM_RANGE(0x0c4000, 0x0c4001) AM_DEVREAD("k053246", k053246_word_r) + AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVWRITE("k054338", k054338_word_w) /* K054338 alpha blending engine */ + AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVWRITE("k053251", k053251_lsb_w) AM_RANGE(0x0ce000, 0x0ce01f) AM_WRITE(moo_prot_w) AM_RANGE(0x0d0000, 0x0d001f) AM_WRITEONLY /* CCU regs (ignored) */ AM_RANGE(0x0d4000, 0x0d4001) AM_WRITE(sound_irq_w) @@ -310,41 +323,41 @@ static ADDRESS_MAP_START( moo_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x0d600e, 0x0d600f) AM_WRITE(sound_cmd2_w) AM_RANGE(0x0d6014, 0x0d6015) AM_READ(sound_status_r) AM_RANGE(0x0d6000, 0x0d601f) AM_RAM /* sound regs fall through */ - AM_RANGE(0x0d8000, 0x0d8007) AM_WRITE(K056832_b_word_w) /* VSCCS regs */ + AM_RANGE(0x0d8000, 0x0d8007) AM_DEVWRITE("k056832", k056832_b_word_w) /* VSCCS regs */ AM_RANGE(0x0da000, 0x0da001) AM_READ_PORT("P1_P3") AM_RANGE(0x0da002, 0x0da003) AM_READ_PORT("P2_P4") AM_RANGE(0x0dc000, 0x0dc001) AM_READ_PORT("IN0") AM_RANGE(0x0dc002, 0x0dc003) AM_READ(control1_r) - AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r,control2_w) + AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r, control2_w) AM_RANGE(0x100000, 0x17ffff) AM_ROM AM_RANGE(0x180000, 0x18ffff) AM_RAM AM_BASE(&workram) /* Work RAM */ AM_RANGE(0x190000, 0x19ffff) AM_RAM AM_BASE_GENERIC(spriteram) /* Sprite RAM */ - AM_RANGE(0x1a0000, 0x1a1fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w) /* Graphic planes */ - AM_RANGE(0x1a2000, 0x1a3fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w) /* Graphic planes mirror */ - AM_RANGE(0x1b0000, 0x1b1fff) AM_READ(K056832_rom_word_r) /* Passthrough to tile roms */ + AM_RANGE(0x1a0000, 0x1a1fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w) /* Graphic planes */ + AM_RANGE(0x1a2000, 0x1a3fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w) /* Graphic planes mirror */ + AM_RANGE(0x1b0000, 0x1b1fff) AM_DEVREAD("k056832", k056832_rom_word_r) /* Passthrough to tile roms */ AM_RANGE(0x1c0000, 0x1c1fff) AM_RAM_WRITE(paletteram16_xrgb_word_be_w) AM_BASE_GENERIC(paletteram) #if MOO_DEBUG - AM_RANGE(0x0c0000, 0x0c003f) AM_READ(K056832_word_r) - AM_RANGE(0x0c2000, 0x0c2007) AM_READ(K053246_reg_word_r) - AM_RANGE(0x0ca000, 0x0ca01f) AM_READ(K054338_word_r) - AM_RANGE(0x0cc000, 0x0cc01f) AM_READ(K053251_lsb_r) + AM_RANGE(0x0c0000, 0x0c003f) AM_DEVREAD("k056832", k056832_word_r) + AM_RANGE(0x0c2000, 0x0c2007) AM_DEVREAD("k053246", k053246_reg_word_r) + AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVREAD("k054338", k054338_word_r) + AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVREAD("k053251", k053251_lsb_r) AM_RANGE(0x0d0000, 0x0d001f) AM_RAM - AM_RANGE(0x0d8000, 0x0d8007) AM_READ(K056832_b_word_r) + AM_RANGE(0x0d8000, 0x0d8007) AM_DEVREAD("k056832", k056832_b_word_r) #endif ADDRESS_MAP_END static ADDRESS_MAP_START( moobl_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x000000, 0x07ffff) AM_ROM - AM_RANGE(0x0c0000, 0x0c003f) AM_WRITE(K056832_word_w) - AM_RANGE(0x0c2000, 0x0c2007) AM_WRITE(K053246_word_w) + AM_RANGE(0x0c0000, 0x0c003f) AM_DEVWRITE("k056832", k056832_word_w) + AM_RANGE(0x0c2000, 0x0c2007) AM_DEVWRITE("k053246", k053246_word_w) AM_RANGE(0x0c2f00, 0x0c2f01) AM_READNOP /* heck if I know, but it's polled constantly */ - AM_RANGE(0x0c4000, 0x0c4001) AM_READ(K053246_word_r) - AM_RANGE(0x0ca000, 0x0ca01f) AM_WRITE(K054338_word_w) /* K054338 alpha blending engine */ - AM_RANGE(0x0cc000, 0x0cc01f) AM_WRITE(K053251_lsb_w) + AM_RANGE(0x0c4000, 0x0c4001) AM_DEVREAD("k053246", k053246_word_r) + AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVWRITE("k054338", k054338_word_w) /* K054338 alpha blending engine */ + AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVWRITE("k053251", k053251_lsb_w) AM_RANGE(0x0d0000, 0x0d001f) AM_WRITEONLY /* CCU regs (ignored) */ AM_RANGE(0x0d6ffc, 0x0d6ffd) AM_DEVWRITE("oki", moobl_oki_bank_w) AM_RANGE(0x0d6ffe, 0x0d6fff) AM_DEVREADWRITE8("oki", okim6295_r,okim6295_w, 0x00ff) - AM_RANGE(0x0d8000, 0x0d8007) AM_WRITE(K056832_b_word_w) /* VSCCS regs */ + AM_RANGE(0x0d8000, 0x0d8007) AM_DEVWRITE("k056832", k056832_b_word_w) /* VSCCS regs */ AM_RANGE(0x0da000, 0x0da001) AM_READ_PORT("P1_P3") AM_RANGE(0x0da002, 0x0da003) AM_READ_PORT("P2_P4") AM_RANGE(0x0dc000, 0x0dc001) AM_READ_PORT("IN0") @@ -353,9 +366,9 @@ static ADDRESS_MAP_START( moobl_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x100000, 0x17ffff) AM_ROM AM_RANGE(0x180000, 0x18ffff) AM_RAM AM_BASE(&workram) /* Work RAM */ AM_RANGE(0x190000, 0x19ffff) AM_RAM AM_BASE_GENERIC(spriteram) /* Sprite RAM */ - AM_RANGE(0x1a0000, 0x1a1fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w) /* Graphic planes */ - AM_RANGE(0x1a2000, 0x1a3fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w) /* Graphic planes mirror */ - AM_RANGE(0x1b0000, 0x1b1fff) AM_READ(K056832_rom_word_r) /* Passthrough to tile roms */ + AM_RANGE(0x1a0000, 0x1a1fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w) /* Graphic planes */ + AM_RANGE(0x1a2000, 0x1a3fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w) /* Graphic planes mirror */ + AM_RANGE(0x1b0000, 0x1b1fff) AM_DEVREAD("k056832", k056832_rom_word_r) /* Passthrough to tile roms */ AM_RANGE(0x1c0000, 0x1c1fff) AM_RAM_WRITE(paletteram16_xrgb_word_be_w) AM_BASE_GENERIC(paletteram) ADDRESS_MAP_END @@ -364,38 +377,38 @@ static ADDRESS_MAP_START( bucky_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x080000, 0x08ffff) AM_RAM AM_RANGE(0x090000, 0x09ffff) AM_RAM AM_BASE_GENERIC(spriteram) /* Sprite RAM */ AM_RANGE(0x0a0000, 0x0affff) AM_RAM /* extra sprite RAM? */ - AM_RANGE(0x0c0000, 0x0c003f) AM_WRITE(K056832_word_w) - AM_RANGE(0x0c2000, 0x0c2007) AM_WRITE(K053246_word_w) - AM_RANGE(0x0c4000, 0x0c4001) AM_READ(K053246_word_r) - AM_RANGE(0x0ca000, 0x0ca01f) AM_WRITE(K054338_word_w) /* K054338 alpha blending engine */ - AM_RANGE(0x0cc000, 0x0cc01f) AM_WRITE(K053251_lsb_w) + AM_RANGE(0x0c0000, 0x0c003f) AM_DEVWRITE("k056832", k056832_word_w) + AM_RANGE(0x0c2000, 0x0c2007) AM_DEVWRITE("k053246", k053246_word_w) + AM_RANGE(0x0c4000, 0x0c4001) AM_DEVREAD("k053246", k053246_word_r) + AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVWRITE("k054338", k054338_word_w) /* K054338 alpha blending engine */ + AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVWRITE("k053251", k053251_lsb_w) AM_RANGE(0x0ce000, 0x0ce01f) AM_WRITE(moo_prot_w) AM_RANGE(0x0d0000, 0x0d001f) AM_WRITEONLY /* CCU regs (ignored) */ - AM_RANGE(0x0d2000, 0x0d20ff) AM_READWRITE(K054000_lsb_r,K054000_lsb_w) + AM_RANGE(0x0d2000, 0x0d20ff) AM_DEVREADWRITE("k054000", k054000_lsb_r, k054000_lsb_w) AM_RANGE(0x0d4000, 0x0d4001) AM_WRITE(sound_irq_w) AM_RANGE(0x0d600c, 0x0d600d) AM_WRITE(sound_cmd1_w) AM_RANGE(0x0d600e, 0x0d600f) AM_WRITE(sound_cmd2_w) AM_RANGE(0x0d6014, 0x0d6015) AM_READ(sound_status_r) AM_RANGE(0x0d6000, 0x0d601f) AM_RAM /* sound regs fall through */ - AM_RANGE(0x0d8000, 0x0d8007) AM_WRITE(K056832_b_word_w) /* VSCCS regs */ + AM_RANGE(0x0d8000, 0x0d8007) AM_DEVWRITE("k056832", k056832_b_word_w) /* VSCCS regs */ AM_RANGE(0x0da000, 0x0da001) AM_READ_PORT("P1_P3") AM_RANGE(0x0da002, 0x0da003) AM_READ_PORT("P2_P4") AM_RANGE(0x0dc000, 0x0dc001) AM_READ_PORT("IN0") AM_RANGE(0x0dc002, 0x0dc003) AM_READ(control1_r) AM_RANGE(0x0de000, 0x0de001) AM_READWRITE(control2_r,control2_w) - AM_RANGE(0x180000, 0x181fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w) /* Graphic planes */ - AM_RANGE(0x182000, 0x183fff) AM_READWRITE(K056832_ram_word_r,K056832_ram_word_w) /* Graphic planes mirror */ + AM_RANGE(0x180000, 0x181fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w) /* Graphic planes */ + AM_RANGE(0x182000, 0x183fff) AM_DEVREADWRITE("k056832", k056832_ram_word_r, k056832_ram_word_w) /* Graphic planes mirror */ AM_RANGE(0x184000, 0x187fff) AM_RAM /* extra tile RAM? */ - AM_RANGE(0x190000, 0x191fff) AM_READ(K056832_rom_word_r) /* Passthrough to tile roms */ + AM_RANGE(0x190000, 0x191fff) AM_DEVREAD("k056832", k056832_rom_word_r) /* Passthrough to tile roms */ AM_RANGE(0x1b0000, 0x1b3fff) AM_RAM_WRITE(paletteram16_xrgb_word_be_w) AM_BASE_GENERIC(paletteram) AM_RANGE(0x200000, 0x23ffff) AM_ROM /* data */ #if MOO_DEBUG - AM_RANGE(0x0c0000, 0x0c003f) AM_READ(K056832_word_r) - AM_RANGE(0x0c2000, 0x0c2007) AM_READ(K053246_reg_word_r) - AM_RANGE(0x0ca000, 0x0ca01f) AM_READ(K054338_word_r) - AM_RANGE(0x0cc000, 0x0cc01f) AM_READ(K053251_lsb_r) + AM_RANGE(0x0c0000, 0x0c003f) AM_DEVREAD("k056832", k056832_word_r) + AM_RANGE(0x0c2000, 0x0c2007) AM_DEVREAD("k053246", k053246_reg_word_r) + AM_RANGE(0x0ca000, 0x0ca01f) AM_DEVREAD("k054338", k054338_word_r) + AM_RANGE(0x0cc000, 0x0cc01f) AM_DEVREAD("k053251", k053251_lsb_r) AM_RANGE(0x0d0000, 0x0d001f) AM_RAM - AM_RANGE(0x0d8000, 0x0d8007) AM_READ(K056832_b_word_r) + AM_RANGE(0x0d8000, 0x0d8007) AM_DEVREAD("k056832", k056832_b_word_r) #endif ADDRESS_MAP_END @@ -473,6 +486,43 @@ static MACHINE_RESET( moo ) } +static const k056832_interface moo_k056832_intf = +{ + "gfx1", + K056832_BPP_4, + 1, 0, + KONAMI_ROM_DEINTERLEAVE_2, + moo_tile_callback, "none" +}; + +static const k053247_interface moo_k053247_intf = +{ + "screen", + "gfx2", + NORMAL_PLANE_ORDER, + -48+1, 23, + KONAMI_ROM_DEINTERLEAVE_4, + moo_sprite_callback +}; + +static const k053247_interface bucky_k053247_intf = +{ + "screen", + "gfx2", + NORMAL_PLANE_ORDER, + -48, 23, + KONAMI_ROM_DEINTERLEAVE_4, + moo_sprite_callback +}; + +static const k054338_interface moo_k054338_intf = +{ + "screen", + 0, + "none" +}; + + static MACHINE_DRIVER_START( moo ) /* basic machine hardware */ @@ -503,6 +553,11 @@ static MACHINE_DRIVER_START( moo ) MDRV_VIDEO_START(moo) MDRV_VIDEO_UPDATE(moo) + MDRV_K053247_ADD("k053246", moo_k053247_intf) + MDRV_K056832_ADD("k056832", moo_k056832_intf) + MDRV_K053251_ADD("k053251") + MDRV_K054338_ADD("k054338", moo_k054338_intf) + /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") @@ -541,6 +596,11 @@ static MACHINE_DRIVER_START( moobl ) MDRV_VIDEO_START(moo) MDRV_VIDEO_UPDATE(moo) + MDRV_K053247_ADD("k053246", moo_k053247_intf) + MDRV_K056832_ADD("k056832", moo_k056832_intf) + MDRV_K053251_ADD("k053251") + MDRV_K054338_ADD("k054338", moo_k054338_intf) + /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") @@ -556,6 +616,11 @@ static MACHINE_DRIVER_START( bucky ) MDRV_CPU_MODIFY("maincpu") MDRV_CPU_PROGRAM_MAP(bucky_map) + MDRV_K054000_ADD("k054000") + + MDRV_DEVICE_REMOVE("k053246") + MDRV_K053247_ADD("k053246", bucky_k053247_intf) // diff x offset + /* video hardware */ MDRV_PALETTE_LENGTH(4096) MACHINE_DRIVER_END @@ -749,7 +814,7 @@ ROM_START( buckyaa ) ROM_LOAD( "173a10.b8", 0x000000, 0x200000, CRC(42fb0a0c) SHA1(d68c932cfabdec7896698b433525fe47ef4698d0) ) ROM_LOAD( "173a11.a8", 0x200000, 0x200000, CRC(b0d747c4) SHA1(0cf1ee1b9a35ded31a81c321df2a076f7b588971) ) ROM_LOAD( "173a12.b10", 0x400000, 0x200000, CRC(0fc2ad24) SHA1(6eda1043ee1266b8ba938a03a90bc7787210a936) ) - ROM_LOAD( "173a13.a10", 0x600000, 0x200000, CRC(4cf85439) SHA1(8c298bf0e659a830a1830a1180f4ce71215ade45) ) + ROM_LOAD( "173a13.a10", 0x600000, 0x200000, CRC(4cf85439) SHA1(8c298bf0e659a830a1830a1180f4ce71215ade45) ) ROM_REGION( 0x400000, "konami", 0 ) /* K054539 samples */ @@ -760,9 +825,6 @@ ROM_END static DRIVER_INIT( moo ) { - konami_rom_deinterleave_2(machine, "gfx1"); - konami_rom_deinterleave_4(machine, "gfx2"); - game_type = (!strcmp(machine->gamedrv->name, "bucky") || !strcmp(machine->gamedrv->name, "buckyua")); } diff --git a/src/mame/drivers/rockrage.c b/src/mame/drivers/rockrage.c index 91404dae056..57dcf2a5783 100644 --- a/src/mame/drivers/rockrage.c +++ b/src/mame/drivers/rockrage.c @@ -53,21 +53,13 @@ Notes: #include "sound/2151intf.h" #include "sound/vlm5030.h" #include "video/konicdev.h" - -/* from video */ -VIDEO_START( rockrage ); -VIDEO_UPDATE( rockrage ); -WRITE8_HANDLER( rockrage_vreg_w ); -PALETTE_INIT( rockrage ); - -extern void rockrage_tile_callback(int layer, int bank, int *code, int *color, int *flags); -extern void rockrage_sprite_callback(int *code, int *color); +#include "includes/rockrage.h" static INTERRUPT_GEN( rockrage_interrupt ) { - const device_config *k007342 = devtag_get_device(device->machine, "k007342"); - if (k007342_is_int_enabled(k007342)) + rockrage_state *state = (rockrage_state *)device->machine->driver_data; + if (k007342_is_int_enabled(state->k007342)) cpu_set_input_line(device, HD6309_IRQ_LINE, HOLD_LINE); } @@ -89,27 +81,28 @@ static WRITE8_HANDLER( rockrage_bankswitch_w ) static WRITE8_HANDLER( rockrage_sh_irqtrigger_w ) { + rockrage_state *state = (rockrage_state *)space->machine->driver_data; soundlatch_w(space, offset, data); - cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, HOLD_LINE); + cpu_set_input_line(state->audiocpu, M6809_IRQ_LINE, HOLD_LINE); } static READ8_DEVICE_HANDLER( rockrage_VLM5030_busy_r ) { - return ( vlm5030_bsy(device) ? 1 : 0 ); + return (vlm5030_bsy(device) ? 1 : 0); } static WRITE8_DEVICE_HANDLER( rockrage_speech_w ) { /* bit2 = data bus enable */ - vlm5030_rst( device, ( data >> 1 ) & 0x01 ); - vlm5030_st( device, ( data >> 0 ) & 0x01 ); + vlm5030_rst(device, (data >> 1) & 0x01); + vlm5030_st(device, (data >> 0) & 0x01); } static ADDRESS_MAP_START( rockrage_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x1fff) AM_DEVREADWRITE("k007342", k007342_r, k007342_w) /* Color RAM + Video RAM */ AM_RANGE(0x2000, 0x21ff) AM_DEVREADWRITE("k007420", k007420_r, k007420_w) /* Sprite RAM */ AM_RANGE(0x2200, 0x23ff) AM_DEVREADWRITE("k007342", k007342_scroll_r, k007342_scroll_w) /* Scroll RAM */ - AM_RANGE(0x2400, 0x247f) AM_RAM AM_BASE_GENERIC(paletteram) /* Palette */ + AM_RANGE(0x2400, 0x247f) AM_RAM AM_BASE_MEMBER(rockrage_state, paletteram) /* Palette */ AM_RANGE(0x2600, 0x2607) AM_DEVWRITE("k007342", k007342_vreg_w) /* Video Registers */ AM_RANGE(0x2e00, 0x2e00) AM_READ_PORT("SYSTEM") AM_RANGE(0x2e01, 0x2e01) AM_READ_PORT("P1") @@ -282,8 +275,32 @@ static const k007420_interface rockrage_k007420_intf = }; +static MACHINE_START( rockrage ) +{ + rockrage_state *state = (rockrage_state *)machine->driver_data; + + state->audiocpu = devtag_get_device(machine, "audiocpu"); + state->k007342 = devtag_get_device(machine, "k007342"); + state->k007420 = devtag_get_device(machine, "k007420"); + + state_save_register_global(machine, state->vreg); + state_save_register_global_array(machine, state->layer_colorbase); +} + +static MACHINE_RESET( rockrage ) +{ + rockrage_state *state = (rockrage_state *)machine->driver_data; + + state->vreg = 0; + state->layer_colorbase[0] = 0x00; + state->layer_colorbase[1] = 0x10; +} + static MACHINE_DRIVER_START( rockrage ) + /* driver data */ + MDRV_DRIVER_DATA(rockrage_state) + /* basic machine hardware */ MDRV_CPU_ADD("maincpu", HD6309, 3000000*4) /* 24MHz/8 */ MDRV_CPU_PROGRAM_MAP(rockrage_map) @@ -292,6 +309,9 @@ static MACHINE_DRIVER_START( rockrage ) MDRV_CPU_ADD("audiocpu", M6809, 1500000) /* 24MHz/16 */ MDRV_CPU_PROGRAM_MAP(rockrage_sound_map) + MDRV_MACHINE_START(rockrage) + MDRV_MACHINE_RESET(rockrage) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) @@ -307,7 +327,6 @@ static MACHINE_DRIVER_START( rockrage ) MDRV_PALETTE_LENGTH(64 + 2*16*16) MDRV_PALETTE_INIT(rockrage) - MDRV_VIDEO_START(rockrage) MDRV_VIDEO_UPDATE(rockrage) /* sound hardware */ diff --git a/src/mame/includes/88games.h b/src/mame/includes/88games.h new file mode 100644 index 00000000000..c3cad7fbb1f --- /dev/null +++ b/src/mame/includes/88games.h @@ -0,0 +1,39 @@ +/************************************************************************* + + 88 Games + +*************************************************************************/ + +typedef struct __88games_state _88games_state; +struct __88games_state +{ + /* memory pointers */ + UINT8 * ram; + UINT8 * banked_rom; +// UINT8 * paletteram_1000; // this currently uses generic palette handling +// UINT8 * nvram; // this currently uses generic nvram handling + + /* video-related */ + int k88games_priority; + int layer_colorbase[3], sprite_colorbase, zoom_colorbase; + int videobank; + int zoomreadroms; + int speech_chip; + + /* devices */ + const device_config *audiocpu; + const device_config *k052109; + const device_config *k051960; + const device_config *k051316; + const device_config *upd_1; + const device_config *upd_2; +}; + + +/*----------- defined in video/88games.c -----------*/ + +void _88games_sprite_callback(running_machine *machine, int *code, int *color, int *priority, int *shadow); +void _88games_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags, int *priority); +void _88games_zoom_callback(running_machine *machine, int *code, int *color, int *flags); + +VIDEO_UPDATE( 88games ); diff --git a/src/mame/includes/battlnts.h b/src/mame/includes/battlnts.h new file mode 100644 index 00000000000..e575003bac1 --- /dev/null +++ b/src/mame/includes/battlnts.h @@ -0,0 +1,31 @@ +/************************************************************************* + + Konami Battlantis Hardware + +*************************************************************************/ + +typedef struct _battlnts_state battlnts_state; +struct _battlnts_state +{ + /* memory pointers */ +// UINT8 * paletteram; // this currently uses generic palette handling + + /* video-related */ + int spritebank; + int layer_colorbase[2]; + + + /* devices */ + const device_config *audiocpu; + const device_config *k007342; + const device_config *k007420; +}; + +/*----------- defined in video/battlnts.c -----------*/ + +WRITE8_HANDLER( battlnts_spritebank_w ); + +VIDEO_UPDATE( battlnts ); + +void battlnts_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags); +void battlnts_sprite_callback(running_machine *machine, int *code, int *color); diff --git a/src/mame/includes/bladestl.h b/src/mame/includes/bladestl.h new file mode 100644 index 00000000000..76d1b1afa1d --- /dev/null +++ b/src/mame/includes/bladestl.h @@ -0,0 +1,35 @@ +/************************************************************************* + + Blades of Steel + +*************************************************************************/ + +typedef struct _bladestl_state bladestl_state; +struct _bladestl_state +{ + /* memory pointers */ + UINT8 * paletteram; + + /* video-related */ + int spritebank; + int layer_colorbase[2]; + + /* misc */ + int last_track[4]; + + /* devices */ + const device_config *audiocpu; + const device_config *k007342; + const device_config *k007420; +}; + + + +/*----------- defined in video/bladestl.c -----------*/ + +PALETTE_INIT( bladestl ); + +VIDEO_UPDATE( bladestl ); + +void bladestl_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags); +void bladestl_sprite_callback(running_machine *machine, int *code, int *color); diff --git a/src/mame/includes/combatsc.h b/src/mame/includes/combatsc.h new file mode 100644 index 00000000000..d98a6cedc4f --- /dev/null +++ b/src/mame/includes/combatsc.h @@ -0,0 +1,56 @@ +/************************************************************************* + + Combat School + +*************************************************************************/ + +typedef struct _combatsc_state combatsc_state; +struct _combatsc_state +{ + /* memory pointers */ + UINT8 * videoram; + UINT8 * scrollram; + UINT8 * io_ram; + UINT8 * paletteram; + UINT8 * spriteram[2]; + + /* video-related */ + tilemap *bg_tilemap[2], *textlayer; + UINT8 scrollram0[0x40]; + UINT8 scrollram1[0x40]; + int priority; + + int vreg; + int bank_select; /* 0x00..0x1f */ + int video_circuit; /* 0 or 1 */ + UINT8 *page[2]; + + /* misc */ + UINT8 pos[4],sign[4]; + int prot[2]; + int boost; + emu_timer *interleave_timer; + + + /* devices */ + const device_config *audiocpu; + const device_config *k007121_1; + const device_config *k007121_2; +}; + + +/*----------- defined in video/combatsc.c -----------*/ + +READ8_HANDLER( combatsc_video_r ); +WRITE8_HANDLER( combatsc_video_w ); + +WRITE8_HANDLER( combatsc_pf_control_w ); +READ8_HANDLER( combatsc_scrollram_r ); +WRITE8_HANDLER( combatsc_scrollram_w ); + +PALETTE_INIT( combatsc ); +PALETTE_INIT( combatscb ); +VIDEO_START( combatsc ); +VIDEO_START( combatscb ); +VIDEO_UPDATE( combatscb ); +VIDEO_UPDATE( combatsc ); diff --git a/src/mame/includes/contra.h b/src/mame/includes/contra.h new file mode 100644 index 00000000000..5fc8d1df62b --- /dev/null +++ b/src/mame/includes/contra.h @@ -0,0 +1,48 @@ +/************************************************************************* + + Contra / Gryzor + +*************************************************************************/ + +typedef struct _contra_state contra_state; +struct _contra_state +{ + /* memory pointers */ + UINT8 * spriteram; + UINT8 * spriteram_2; + UINT8 * paletteram; + UINT8 * bg_vram; + UINT8 * bg_cram; + UINT8 * fg_vram; + UINT8 * fg_cram; + UINT8 * tx_vram; + UINT8 * tx_cram; + // this driver also uses a large generic spriteram region... + + /* video-related */ + tilemap *bg_tilemap, *fg_tilemap, *tx_tilemap; + rectangle bg_clip, fg_clip, tx_clip; + + /* devices */ + const device_config *audiocpu; + const device_config *k007121_1; + const device_config *k007121_2; +}; + + +/*----------- defined in video/contra.c -----------*/ + +PALETTE_INIT( contra ); + +WRITE8_HANDLER( contra_fg_vram_w ); +WRITE8_HANDLER( contra_fg_cram_w ); +WRITE8_HANDLER( contra_bg_vram_w ); +WRITE8_HANDLER( contra_bg_cram_w ); +WRITE8_HANDLER( contra_text_vram_w ); +WRITE8_HANDLER( contra_text_cram_w ); + +WRITE8_HANDLER( contra_K007121_ctrl_0_w ); +WRITE8_HANDLER( contra_K007121_ctrl_1_w ); + +VIDEO_UPDATE( contra ); +VIDEO_START( contra ); diff --git a/src/mame/includes/crshrace.h b/src/mame/includes/crshrace.h index 9908e49c1aa..5e145f9d80e 100644 --- a/src/mame/includes/crshrace.h +++ b/src/mame/includes/crshrace.h @@ -1,6 +1,27 @@ -/*----------- defined in video/crshrace.c -----------*/ -extern UINT16 *crshrace_videoram1,*crshrace_videoram2; +typedef struct _crshrace_state crshrace_state; +struct _crshrace_state +{ + /* memory pointers */ + UINT16 * videoram1; + UINT16 * videoram2; +// UINT16 * spriteram1; // currently this uses generic buffered spriteram +// UINT16 * spriteram2; // currently this uses generic buffered spriteram +// UINT16 * paletteram; // currently this uses generic palette handling + + /* video-related */ + tilemap *tilemap1, *tilemap2; + int roz_bank, gfxctrl, flipscreen; + + /* misc */ + int pending_command; + + /* devices */ + const device_config *audiocpu; + const device_config *k053936; +}; + +/*----------- defined in video/crshrace.c -----------*/ WRITE16_HANDLER( crshrace_videoram1_w ); WRITE16_HANDLER( crshrace_videoram2_w ); diff --git a/src/mame/includes/rockrage.h b/src/mame/includes/rockrage.h new file mode 100644 index 00000000000..f8ced327cd4 --- /dev/null +++ b/src/mame/includes/rockrage.h @@ -0,0 +1,32 @@ +/************************************************************************* + + Rock'n Rage + +*************************************************************************/ + +typedef struct _rockrage_state rockrage_state; +struct _rockrage_state +{ + /* memory pointers */ + UINT8 * paletteram; + + /* video-related */ + int layer_colorbase[2]; + int vreg; + + /* devices */ + const device_config *audiocpu; + const device_config *k007342; + const device_config *k007420; +}; + + +/*----------- defined in video/rockrage.c -----------*/ + +WRITE8_HANDLER( rockrage_vreg_w ); + +VIDEO_UPDATE( rockrage ); +PALETTE_INIT( rockrage ); + +void rockrage_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags); +void rockrage_sprite_callback(running_machine *machine, int *code, int *color); diff --git a/src/mame/mamedriv.c b/src/mame/mamedriv.c index cdf3b4da042..36220ea8449 100644 --- a/src/mame/mamedriv.c +++ b/src/mame/mamedriv.c @@ -5288,11 +5288,11 @@ BOMULEUL CHAJARA SEGA ST-V 1997/04/11 DRIVER( contrajb ) /* bootleg */ DRIVER( gryzor ) /* GX633 (c) 1987 */ DRIVER( gryzora ) /* GX633 (c) 1987 */ - DRIVER( combasc ) /* GX611 (c) 1988 */ - DRIVER( combasct ) /* GX611 (c) 1987 */ - DRIVER( combascj ) /* GX611 (c) 1987 (Japan) */ + DRIVER( combatsc ) /* GX611 (c) 1988 */ + DRIVER( combatsct ) /* GX611 (c) 1987 */ + DRIVER( combatscj ) /* GX611 (c) 1987 (Japan) */ DRIVER( bootcamp ) /* GX611 (c) 1987 */ - DRIVER( combascb ) /* bootleg */ + DRIVER( combatscb ) /* bootleg */ DRIVER( rockrage ) /* GX620 (c) 1986 (World?) */ DRIVER( rockragea ) /* GX620 (c) 1986 (Prototype?) */ DRIVER( rockragej ) /* GX620 (c) 1986 (Japan) */ diff --git a/src/mame/video/88games.c b/src/mame/video/88games.c index eb76f6e783d..934ef17bf9a 100644 --- a/src/mame/video/88games.c +++ b/src/mame/video/88games.c @@ -1,11 +1,6 @@ #include "driver.h" #include "video/konicdev.h" - - -int k88games_priority; - -static int layer_colorbase[3],sprite_colorbase,zoom_colorbase; - +#include "includes/88games.h" /*************************************************************************** @@ -14,10 +9,12 @@ static int layer_colorbase[3],sprite_colorbase,zoom_colorbase; ***************************************************************************/ -void _88games_tile_callback(int layer,int bank,int *code,int *color,int *flags,int *priority) +void _88games_tile_callback( running_machine *machine, int layer, int bank, int *code, int *color, int *flags, int *priority ) { + _88games_state *state = (_88games_state *)machine->driver_data; + *code |= ((*color & 0x0f) << 8) | (bank << 12); - *color = layer_colorbase[layer] + ((*color & 0xf0) >> 4); + *color = state->layer_colorbase[layer] + ((*color & 0xf0) >> 4); } @@ -27,10 +24,12 @@ void _88games_tile_callback(int layer,int bank,int *code,int *color,int *flags,i ***************************************************************************/ -void _88games_sprite_callback(int *code,int *color,int *priority,int *shadow) +void _88games_sprite_callback( running_machine *machine, int *code, int *color, int *priority, int *shadow ) { + _88games_state *state = (_88games_state *)machine->driver_data; + *priority = (*color & 0x20) >> 5; /* ??? */ - *color = sprite_colorbase + (*color & 0x0f); + *color = state->sprite_colorbase + (*color & 0x0f); } @@ -40,35 +39,15 @@ void _88games_sprite_callback(int *code,int *color,int *priority,int *shadow) ***************************************************************************/ -void _88games_zoom_callback(int *code,int *color,int *flags) +void _88games_zoom_callback( running_machine *machine, int *code, int *color, int *flags ) { + _88games_state *state = (_88games_state *)machine->driver_data; + *flags = (*color & 0x40) ? TILE_FLIPX : 0; *code |= ((*color & 0x07) << 8); - *color = zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4); + *color = state->zoom_colorbase + ((*color & 0x38) >> 3) + ((*color & 0x80) >> 4); } -/*************************************************************************** - - Start the video hardware emulation. - -***************************************************************************/ - -VIDEO_START( 88games ) -{ - layer_colorbase[0] = 64; - layer_colorbase[1] = 0; - layer_colorbase[2] = 16; - sprite_colorbase = 32; - zoom_colorbase = 48; - - state_save_register_global_array(machine, layer_colorbase); - state_save_register_global(machine, k88games_priority); - state_save_register_global(machine, sprite_colorbase); - state_save_register_global(machine, zoom_colorbase); -} - - - /*************************************************************************** Display refresh @@ -77,29 +56,28 @@ VIDEO_START( 88games ) VIDEO_UPDATE( 88games ) { - const device_config *k052109 = devtag_get_device(screen->machine, "k052109"); - const device_config *k051960 = devtag_get_device(screen->machine, "k051960"); - const device_config *k051316 = devtag_get_device(screen->machine, "k051316"); + _88games_state *state = (_88games_state *)screen->machine->driver_data; - k052109_tilemap_update(k052109); + k052109_tilemap_update(state->k052109); - if (k88games_priority) + if (state->k88games_priority) { - k052109_tilemap_draw(k052109, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0); // tile 0 - k051960_sprites_draw(k051960, bitmap,cliprect, 1, 1); - k052109_tilemap_draw(k052109, bitmap, cliprect, 2, 0, 0); // tile 2 - k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 0); // tile 1 - k051960_sprites_draw(k051960, bitmap, cliprect, 0, 0); - k051316_zoom_draw(k051316, bitmap, cliprect, 0, 0); + k052109_tilemap_draw(state->k052109, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0); // tile 0 + k051960_sprites_draw(state->k051960, bitmap,cliprect, 1, 1); + k052109_tilemap_draw(state->k052109, bitmap, cliprect, 2, 0, 0); // tile 2 + k052109_tilemap_draw(state->k052109, bitmap, cliprect, 1, 0, 0); // tile 1 + k051960_sprites_draw(state->k051960, bitmap, cliprect, 0, 0); + k051316_zoom_draw(state->k051316, bitmap, cliprect, 0, 0); } else { - k052109_tilemap_draw(k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 0); // tile 2 - k051316_zoom_draw(k051316, bitmap, cliprect, 0, 0); - k051960_sprites_draw(k051960, bitmap, cliprect, 0, 0); - k052109_tilemap_draw(k052109, bitmap, cliprect, 1, 0, 0); // tile 1 - k051960_sprites_draw(k051960, bitmap, cliprect, 1, 1); - k052109_tilemap_draw(k052109, bitmap, cliprect, 0, 0, 0); // tile 0 + k052109_tilemap_draw(state->k052109, bitmap, cliprect, 2, TILEMAP_DRAW_OPAQUE, 0); // tile 2 + k051316_zoom_draw(state->k051316, bitmap, cliprect, 0, 0); + k051960_sprites_draw(state->k051960, bitmap, cliprect, 0, 0); + k052109_tilemap_draw(state->k052109, bitmap, cliprect, 1, 0, 0); // tile 1 + k051960_sprites_draw(state->k051960, bitmap, cliprect, 1, 1); + k052109_tilemap_draw(state->k052109, bitmap, cliprect, 0, 0, 0); // tile 0 } + return 0; } diff --git a/src/mame/video/asterix.c b/src/mame/video/asterix.c index 9585bb74c55..4f31c4f8fdd 100644 --- a/src/mame/video/asterix.c +++ b/src/mame/video/asterix.c @@ -1,5 +1,5 @@ #include "driver.h" -#include "video/konamiic.h" +#include "video/konicdev.h" static int sprite_colorbase; @@ -8,9 +8,10 @@ static UINT16 spritebank; static int tilebanks[4]; static int spritebanks[4]; -static void reset_spritebank(void) +static void reset_spritebank( running_machine *machine ) { - K053244_bankselect(0, spritebank & 7); + const device_config *k053244 = devtag_get_device(machine, "k053244"); + k053244_bankselect(k053244, spritebank & 7); spritebanks[0] = (spritebank << 12) & 0x7000; spritebanks[1] = (spritebank << 9) & 0x7000; spritebanks[2] = (spritebank << 6) & 0x7000; @@ -20,10 +21,10 @@ static void reset_spritebank(void) WRITE16_HANDLER( asterix_spritebank_w ) { COMBINE_DATA(&spritebank); - reset_spritebank(); + reset_spritebank(space->machine); } -static void asterix_sprite_callback(int *code, int *color, int *priority_mask) +void asterix_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask) { int pri = (*color & 0x00e0) >> 2; if (pri <= layerpri[2]) *priority_mask = 0; @@ -35,22 +36,13 @@ static void asterix_sprite_callback(int *code, int *color, int *priority_mask) } -static void asterix_tile_callback(int layer, int *code, int *color, int *flags) +void asterix_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags) { *flags = *code & 0x1000 ? TILE_FLIPX : 0; *color = (layer_colorbase[layer] + ((*code & 0xe000) >> 13)) & 0x7f; *code = (*code & 0x03ff) | tilebanks[(*code >> 10) & 3]; } -VIDEO_START( asterix ) -{ - K053251_vh_start(machine); - K056832_vh_start(machine, "gfx1", K056832_BPP_4, 1, NULL, asterix_tile_callback, 1); - K053245_vh_start(machine,0, "gfx2",NORMAL_PLANE_ORDER, asterix_sprite_callback); - - K053245_set_SpriteOffset(0,-3,-1); -} - /* useful function to sort the three tile layers by priority order */ static void sortlayers(int *layer,int *pri) { @@ -70,63 +62,66 @@ static void sortlayers(int *layer,int *pri) VIDEO_UPDATE( asterix ) { static const int K053251_CI[4] = { K053251_CI0, K053251_CI2, K053251_CI3, K053251_CI4 }; + const device_config *k053244 = devtag_get_device(screen->machine, "k053244"); + const device_config *k056832 = devtag_get_device(screen->machine, "k056832"); + const device_config *k053251 = devtag_get_device(screen->machine, "k053251"); int layer[3], plane, new_colorbase; /* Layer offsets are different if horizontally flipped */ - if (K056832_read_register(0x0) & 0x10) + if (k056832_read_register(k056832, 0x0) & 0x10) { - K056832_set_LayerOffset(0, 89-176, 0); - K056832_set_LayerOffset(1, 91-176, 0); - K056832_set_LayerOffset(2, 89-176, 0); - K056832_set_LayerOffset(3, 95-176, 0); + k056832_set_layer_offs(k056832, 0, 89 - 176, 0); + k056832_set_layer_offs(k056832, 1, 91 - 176, 0); + k056832_set_layer_offs(k056832, 2, 89 - 176, 0); + k056832_set_layer_offs(k056832, 3, 95 - 176, 0); } else { - K056832_set_LayerOffset(0, 89, 0); - K056832_set_LayerOffset(1, 91, 0); - K056832_set_LayerOffset(2, 89, 0); - K056832_set_LayerOffset(3, 95, 0); + k056832_set_layer_offs(k056832, 0, 89, 0); + k056832_set_layer_offs(k056832, 1, 91, 0); + k056832_set_layer_offs(k056832, 2, 89, 0); + k056832_set_layer_offs(k056832, 3, 95, 0); } - tilebanks[0] = (K056832_get_lookup(0) << 10); - tilebanks[1] = (K056832_get_lookup(1) << 10); - tilebanks[2] = (K056832_get_lookup(2) << 10); - tilebanks[3] = (K056832_get_lookup(3) << 10); + tilebanks[0] = (k056832_get_lookup(k056832, 0) << 10); + tilebanks[1] = (k056832_get_lookup(k056832, 1) << 10); + tilebanks[2] = (k056832_get_lookup(k056832, 2) << 10); + tilebanks[3] = (k056832_get_lookup(k056832, 3) << 10); // update color info and refresh tilemaps - sprite_colorbase = K053251_get_palette_index(K053251_CI1); + sprite_colorbase = k053251_get_palette_index(k053251, K053251_CI1); - for (plane=0; plane<4; plane++) + for (plane = 0; plane < 4; plane++) { - new_colorbase = K053251_get_palette_index(K053251_CI[plane]); + new_colorbase = k053251_get_palette_index(k053251, K053251_CI[plane]); if (layer_colorbase[plane] != new_colorbase) { layer_colorbase[plane] = new_colorbase; - K056832_mark_plane_dirty(plane); + k056832_mark_plane_dirty(k056832, plane); } } layer[0] = 0; - layerpri[0] = K053251_get_priority(K053251_CI0); + layerpri[0] = k053251_get_priority(k053251, K053251_CI0); layer[1] = 1; - layerpri[1] = K053251_get_priority(K053251_CI2); + layerpri[1] = k053251_get_priority(k053251, K053251_CI2); layer[2] = 3; - layerpri[2] = K053251_get_priority(K053251_CI4); + layerpri[2] = k053251_get_priority(k053251, K053251_CI4); sortlayers(layer, layerpri); bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); bitmap_fill(bitmap, cliprect, 0); - K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[0], 0, 1); - K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[1], 0, 2); - K056832_tilemap_draw(screen->machine, bitmap, cliprect, layer[2], 0, 4); + k056832_tilemap_draw(k056832, bitmap, cliprect, layer[0], 0, 1); + k056832_tilemap_draw(k056832, bitmap, cliprect, layer[1], 0, 2); + k056832_tilemap_draw(k056832, bitmap, cliprect, layer[2], 0, 4); /* this isn't supported anymore and it is unsure if still needed; keeping here for reference pdrawgfx_shadow_lowpri = 1; fix shadows in front of feet */ - K053245_sprites_draw(screen->machine, 0, bitmap, cliprect); + k053245_sprites_draw(k053244, bitmap, cliprect); - K056832_tilemap_draw(screen->machine, bitmap, cliprect, 2, 0, 0); + k056832_tilemap_draw(k056832, bitmap, cliprect, 2, 0, 0); return 0; } diff --git a/src/mame/video/battlnts.c b/src/mame/video/battlnts.c index 383db1722ac..517a051186c 100644 --- a/src/mame/video/battlnts.c +++ b/src/mame/video/battlnts.c @@ -1,9 +1,6 @@ #include "driver.h" #include "video/konicdev.h" - -static int spritebank; - -static int layer_colorbase[2]; +#include "includes/battlnts.h" /*************************************************************************** @@ -11,10 +8,12 @@ static int layer_colorbase[2]; ***************************************************************************/ -void battlnts_tile_callback(int layer, int bank, int *code, int *color, int *flags) +void battlnts_tile_callback(running_machine *machine, int layer, int bank, int *code, int *color, int *flags) { + battlnts_state *state = (battlnts_state *)machine->driver_data; + *code |= ((*color & 0x0f) << 9) | ((*color & 0x40) << 2); - *color = layer_colorbase[layer]; + *color = state->layer_colorbase[layer]; } /*************************************************************************** @@ -23,28 +22,19 @@ void battlnts_tile_callback(int layer, int bank, int *code, int *color, int *fla ***************************************************************************/ -void battlnts_sprite_callback(int *code,int *color) +void battlnts_sprite_callback(running_machine *machine, int *code,int *color) { - *code |= ((*color & 0xc0) << 2) | spritebank; + battlnts_state *state = (battlnts_state *)machine->driver_data; + + *code |= ((*color & 0xc0) << 2) | state->spritebank; *code = (*code << 2) | ((*color & 0x30) >> 4); *color = 0; } WRITE8_HANDLER( battlnts_spritebank_w ) { - spritebank = 1024 * (data & 1); -} - -/*************************************************************************** - - Start the video hardware emulation. - -***************************************************************************/ - -VIDEO_START( battlnts ) -{ - layer_colorbase[0] = 0; - layer_colorbase[1] = 0; + battlnts_state *state = (battlnts_state *)space->machine->driver_data; + state->spritebank = 1024 * (data & 1); } /*************************************************************************** @@ -55,13 +45,12 @@ VIDEO_START( battlnts ) VIDEO_UPDATE( battlnts ) { - const device_config *k007342 = devtag_get_device(screen->machine, "k007342"); - const device_config *k007420 = devtag_get_device(screen->machine, "k007420"); + battlnts_state *state = (battlnts_state *)screen->machine->driver_data; - k007342_tilemap_update(k007342); + k007342_tilemap_update(state->k007342); - k007342_tilemap_draw(k007342, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE ,0); - k007420_sprites_draw(k007420, bitmap, cliprect, screen->machine->gfx[1]); - k007342_tilemap_draw(k007342, bitmap, cliprect, 0, 1 | TILEMAP_DRAW_OPAQUE ,0); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE ,0); + k007420_sprites_draw(state->k007420, bitmap, cliprect, screen->machine->gfx[1]); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, 1 | TILEMAP_DRAW_OPAQUE ,0); return 0; } diff --git a/src/mame/video/bladestl.c b/src/mame/video/bladestl.c index ceaaef53c84..648e88fae16 100644 --- a/src/mame/video/bladestl.c +++ b/src/mame/video/bladestl.c @@ -1,8 +1,6 @@ #include "driver.h" #include "video/konicdev.h" - -static int layer_colorbase[2]; -extern int bladestl_spritebank; +#include "includes/bladestl.h" PALETTE_INIT( bladestl ) @@ -25,13 +23,14 @@ PALETTE_INIT( bladestl ) } -static void set_pens(running_machine *machine) +static void set_pens( running_machine *machine ) { + bladestl_state *state = (bladestl_state *)machine->driver_data; int i; for (i = 0x00; i < 0x60; i += 2) { - UINT16 data = machine->generic.paletteram.u8[i | 1] | (machine->generic.paletteram.u8[i] << 8); + UINT16 data = state->paletteram[i | 1] | (state->paletteram[i] << 8); rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); @@ -47,10 +46,12 @@ static void set_pens(running_machine *machine) ***************************************************************************/ -void bladestl_tile_callback(int layer, int bank, int *code, int *color, int *flags) +void bladestl_tile_callback( running_machine *machine, int layer, int bank, int *code, int *color, int *flags ) { + bladestl_state *state = (bladestl_state *)machine->driver_data; + *code |= ((*color & 0x0f) << 8) | ((*color & 0x40) << 6); - *color = layer_colorbase[layer]; + *color = state->layer_colorbase[layer]; } /*************************************************************************** @@ -59,26 +60,16 @@ void bladestl_tile_callback(int layer, int bank, int *code, int *color, int *fla ***************************************************************************/ -void bladestl_sprite_callback(int *code,int *color) +void bladestl_sprite_callback( running_machine *machine, int *code,int *color ) { - *code |= ((*color & 0xc0) << 2) + bladestl_spritebank; + bladestl_state *state = (bladestl_state *)machine->driver_data; + + *code |= ((*color & 0xc0) << 2) + state->spritebank; *code = (*code << 2) | ((*color & 0x30) >> 4); *color = 0 + (*color & 0x0f); } -/*************************************************************************** - - Start the video hardware emulation. - -***************************************************************************/ - -VIDEO_START( bladestl ) -{ - layer_colorbase[0] = 0; - layer_colorbase[1] = 1; -} - /*************************************************************************** Screen Refresh @@ -87,16 +78,15 @@ VIDEO_START( bladestl ) VIDEO_UPDATE( bladestl ) { - const device_config *k007342 = devtag_get_device(screen->machine, "k007342"); - const device_config *k007420 = devtag_get_device(screen->machine, "k007420"); + bladestl_state *state = (bladestl_state *)screen->machine->driver_data; set_pens(screen->machine); - k007342_tilemap_update(k007342); + k007342_tilemap_update(state->k007342); - k007342_tilemap_draw(k007342, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE ,0); - k007420_sprites_draw(k007420, bitmap, cliprect, screen->machine->gfx[1]); - k007342_tilemap_draw(k007342, bitmap, cliprect, 1, 1 | TILEMAP_DRAW_OPAQUE ,0); - k007342_tilemap_draw(k007342, bitmap, cliprect, 0, 0 ,0); - k007342_tilemap_draw(k007342, bitmap, cliprect, 0, 1 ,0); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 1, TILEMAP_DRAW_OPAQUE ,0); + k007420_sprites_draw(state->k007420, bitmap, cliprect, screen->machine->gfx[1]); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 1, 1 | TILEMAP_DRAW_OPAQUE ,0); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, 0 ,0); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, 1 ,0); return 0; } diff --git a/src/mame/video/combatsc.c b/src/mame/video/combatsc.c index 9c5ca856c07..5934f3e8a8b 100644 --- a/src/mame/video/combatsc.c +++ b/src/mame/video/combatsc.c @@ -8,24 +8,9 @@ #include "driver.h" #include "video/konicdev.h" +#include "includes/combatsc.h" -static tilemap *bg_tilemap[2]; -static tilemap *textlayer; -static UINT8 *private_spriteram[2]; -static int priority; - -static UINT8 *combasc_io_ram; -static int combasc_vreg; - -static int combasc_bank_select; /* 0x00..0x1f */ -static int combasc_video_circuit; /* 0 or 1 */ -static UINT8 *combasc_page[2]; -static UINT8 combasc_scrollram0[0x40]; -static UINT8 combasc_scrollram1[0x40]; -static UINT8 *combasc_scrollram; - - -PALETTE_INIT( combasc ) +PALETTE_INIT( combatsc ) { int pal; @@ -75,7 +60,7 @@ PALETTE_INIT( combasc ) } -PALETTE_INIT( combascb ) +PALETTE_INIT( combatscb ) { int pal; @@ -103,13 +88,14 @@ PALETTE_INIT( combascb ) } -static void set_pens(running_machine *machine) +static void set_pens( running_machine *machine ) { + combatsc_state *state = (combatsc_state *)machine->driver_data; int i; for (i = 0x00; i < 0x100; i += 2) { - UINT16 data = machine->generic.paletteram.u8[i] | (machine->generic.paletteram.u8[i | 1] << 8); + UINT16 data = state->paletteram[i] | (state->paletteram[i | 1] << 8); rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); @@ -127,22 +113,30 @@ static void set_pens(running_machine *machine) static TILE_GET_INFO( get_tile_info0 ) { - const device_config *k007121 = devtag_get_device(machine, "k007121_1"); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); - UINT8 attributes = combasc_page[0][tile_index]; - int bank = 4*((combasc_vreg & 0x0f) - 1); - int number,color; + combatsc_state *state = (combatsc_state *)machine->driver_data; + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6); + UINT8 attributes = state->page[0][tile_index]; + int bank = 4 * ((state->vreg & 0x0f) - 1); + int number, color; - if (bank < 0) bank = 0; - if ((attributes & 0xb0) == 0) bank = 0; /* text bank */ + if (bank < 0) + bank = 0; - if (attributes & 0x80) bank += 1; - if (attributes & 0x10) bank += 2; - if (attributes & 0x20) bank += 4; + if ((attributes & 0xb0) == 0) + bank = 0; /* text bank */ + + if (attributes & 0x80) + bank += 1; + + if (attributes & 0x10) + bank += 2; + + if (attributes & 0x20) + bank += 4; color = ((ctrl_6 & 0x10) * 2 + 16) + (attributes & 0x0f); - number = combasc_page[0][tile_index + 0x400] + 256*bank; + number = state->page[0][tile_index + 0x400] + 256 * bank; SET_TILE_INFO( 0, @@ -154,22 +148,30 @@ static TILE_GET_INFO( get_tile_info0 ) static TILE_GET_INFO( get_tile_info1 ) { - const device_config *k007121 = devtag_get_device(machine, "k007121_2"); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); - UINT8 attributes = combasc_page[1][tile_index]; - int bank = 4*((combasc_vreg >> 4) - 1); + combatsc_state *state = (combatsc_state *)machine->driver_data; + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_2, 6); + UINT8 attributes = state->page[1][tile_index]; + int bank = 4 * ((state->vreg >> 4) - 1); int number, color; - if (bank < 0) bank = 0; - if ((attributes & 0xb0) == 0) bank = 0; /* text bank */ + if (bank < 0) + bank = 0; - if (attributes & 0x80) bank += 1; - if (attributes & 0x10) bank += 2; - if (attributes & 0x20) bank += 4; + if ((attributes & 0xb0) == 0) + bank = 0; /* text bank */ + + if (attributes & 0x80) + bank += 1; + + if (attributes & 0x10) + bank += 2; + + if (attributes & 0x20) + bank += 4; color = ((ctrl_6 & 0x10) * 2 + 16 + 4 * 16) + (attributes & 0x0f); - number = combasc_page[1][tile_index + 0x400] + 256*bank; + number = state->page[1][tile_index + 0x400] + 256 * bank; SET_TILE_INFO( 1, @@ -181,8 +183,9 @@ static TILE_GET_INFO( get_tile_info1 ) static TILE_GET_INFO( get_text_info ) { - UINT8 attributes = combasc_page[0][tile_index + 0x800]; - int number = combasc_page[0][tile_index + 0xc00]; + combatsc_state *state = (combatsc_state *)machine->driver_data; + UINT8 attributes = state->page[0][tile_index + 0x800]; + int number = state->page[0][tile_index + 0xc00]; int color = 16 + (attributes & 0x0f); SET_TILE_INFO( @@ -195,20 +198,29 @@ static TILE_GET_INFO( get_text_info ) static TILE_GET_INFO( get_tile_info0_bootleg ) { - UINT8 attributes = combasc_page[0][tile_index]; - int bank = 4*((combasc_vreg & 0x0f) - 1); + combatsc_state *state = (combatsc_state *)machine->driver_data; + UINT8 attributes = state->page[0][tile_index]; + int bank = 4 * ((state->vreg & 0x0f) - 1); int number, pal, color; - if (bank < 0) bank = 0; - if ((attributes & 0xb0) == 0) bank = 0; /* text bank */ + if (bank < 0) + bank = 0; - if (attributes & 0x80) bank += 1; - if (attributes & 0x10) bank += 2; - if (attributes & 0x20) bank += 4; + if ((attributes & 0xb0) == 0) + bank = 0; /* text bank */ + + if (attributes & 0x80) + bank += 1; + + if (attributes & 0x10) + bank += 2; + + if (attributes & 0x20) + bank += 4; pal = (bank == 0 || bank >= 0x1c || (attributes & 0x40)) ? 1 : 3; color = pal*16;// + (attributes & 0x0f); - number = combasc_page[0][tile_index + 0x400] + 256*bank; + number = state->page[0][tile_index + 0x400] + 256 * bank; SET_TILE_INFO( 0, @@ -219,20 +231,29 @@ static TILE_GET_INFO( get_tile_info0_bootleg ) static TILE_GET_INFO( get_tile_info1_bootleg ) { - UINT8 attributes = combasc_page[1][tile_index]; - int bank = 4*((combasc_vreg >> 4) - 1); + combatsc_state *state = (combatsc_state *)machine->driver_data; + UINT8 attributes = state->page[1][tile_index]; + int bank = 4*((state->vreg >> 4) - 1); int number, pal, color; - if (bank < 0) bank = 0; - if ((attributes & 0xb0) == 0) bank = 0; /* text bank */ + if (bank < 0) + bank = 0; - if (attributes & 0x80) bank += 1; - if (attributes & 0x10) bank += 2; - if (attributes & 0x20) bank += 4; + if ((attributes & 0xb0) == 0) + bank = 0; /* text bank */ + + if (attributes & 0x80) + bank += 1; + + if (attributes & 0x10) + bank += 2; + + if (attributes & 0x20) + bank += 4; pal = (bank == 0 || bank >= 0x1c || (attributes & 0x40)) ? 5 : 7; - color = pal*16;// + (attributes & 0x0f); - number = combasc_page[1][tile_index + 0x400] + 256*bank; + color = pal * 16;// + (attributes & 0x0f); + number = state->page[1][tile_index + 0x400] + 256 * bank; SET_TILE_INFO( 1, @@ -243,8 +264,9 @@ static TILE_GET_INFO( get_tile_info1_bootleg ) static TILE_GET_INFO( get_text_info_bootleg ) { -// UINT8 attributes = combasc_page[0][tile_index + 0x800]; - int number = combasc_page[0][tile_index + 0xc00]; + combatsc_state *state = (combatsc_state *)machine->driver_data; +// UINT8 attributes = state->page[0][tile_index + 0x800]; + int number = state->page[0][tile_index + 0xc00]; int color = 16;// + (attributes & 0x0f); SET_TILE_INFO( @@ -260,41 +282,47 @@ static TILE_GET_INFO( get_text_info_bootleg ) ***************************************************************************/ -VIDEO_START( combasc ) +VIDEO_START( combatsc ) { - combasc_vreg = -1; + combatsc_state *state = (combatsc_state *)machine->driver_data; - bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,32,32); - bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,8,8,32,32); - textlayer = tilemap_create(machine, get_text_info, tilemap_scan_rows, 8,8,32,32); + state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 8, 8, 32, 32); + state->textlayer = tilemap_create(machine, get_text_info, tilemap_scan_rows, 8, 8, 32, 32); - private_spriteram[0] = auto_alloc_array_clear(machine, UINT8, 0x800); - private_spriteram[1] = auto_alloc_array_clear(machine, UINT8, 0x800); + state->spriteram[0] = auto_alloc_array_clear(machine, UINT8, 0x800); + state->spriteram[1] = auto_alloc_array_clear(machine, UINT8, 0x800); - tilemap_set_transparent_pen(bg_tilemap[0],0); - tilemap_set_transparent_pen(bg_tilemap[1],0); - tilemap_set_transparent_pen(textlayer,0); + tilemap_set_transparent_pen(state->bg_tilemap[0], 0); + tilemap_set_transparent_pen(state->bg_tilemap[1], 0); + tilemap_set_transparent_pen(state->textlayer, 0); - tilemap_set_scroll_rows(textlayer,32); + tilemap_set_scroll_rows(state->textlayer, 32); + + state_save_register_global_pointer(machine, state->spriteram[0], 0x800); + state_save_register_global_pointer(machine, state->spriteram[1], 0x800); } -VIDEO_START( combascb ) +VIDEO_START( combatscb ) { - combasc_vreg = -1; + combatsc_state *state = (combatsc_state *)machine->driver_data; - bg_tilemap[0] = tilemap_create(machine, get_tile_info0_bootleg,tilemap_scan_rows,8,8,32,32); - bg_tilemap[1] = tilemap_create(machine, get_tile_info1_bootleg,tilemap_scan_rows,8,8,32,32); - textlayer = tilemap_create(machine, get_text_info_bootleg, tilemap_scan_rows,8,8,32,32); + state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0_bootleg, tilemap_scan_rows, 8, 8, 32, 32); + state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1_bootleg, tilemap_scan_rows, 8, 8, 32, 32); + state->textlayer = tilemap_create(machine, get_text_info_bootleg, tilemap_scan_rows, 8, 8, 32, 32); - private_spriteram[0] = auto_alloc_array_clear(machine, UINT8, 0x800); - private_spriteram[1] = auto_alloc_array_clear(machine, UINT8, 0x800); + state->spriteram[0] = auto_alloc_array_clear(machine, UINT8, 0x800); + state->spriteram[1] = auto_alloc_array_clear(machine, UINT8, 0x800); - tilemap_set_transparent_pen(bg_tilemap[0],0); - tilemap_set_transparent_pen(bg_tilemap[1],0); - tilemap_set_transparent_pen(textlayer,0); + tilemap_set_transparent_pen(state->bg_tilemap[0], 0); + tilemap_set_transparent_pen(state->bg_tilemap[1], 0); + tilemap_set_transparent_pen(state->textlayer, 0); - tilemap_set_scroll_rows(bg_tilemap[0],32); - tilemap_set_scroll_rows(bg_tilemap[1],32); + tilemap_set_scroll_rows(state->bg_tilemap[0], 32); + tilemap_set_scroll_rows(state->bg_tilemap[1], 32); + + state_save_register_global_pointer(machine, state->spriteram[0], 0x800); + state_save_register_global_pointer(machine, state->spriteram[1], 0x800); } /*************************************************************************** @@ -303,175 +331,58 @@ VIDEO_START( combascb ) ***************************************************************************/ -READ8_HANDLER( combasc_video_r ) +READ8_HANDLER( combatsc_video_r ) { - return space->machine->generic.videoram.u8[offset]; + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + return state->videoram[offset]; } -WRITE8_HANDLER( combasc_video_w ) +WRITE8_HANDLER( combatsc_video_w ) { - space->machine->generic.videoram.u8[offset] = data; - if( offset<0x800 ) + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + state->videoram[offset] = data; + + if (offset < 0x800) { - if (combasc_video_circuit) - tilemap_mark_tile_dirty(bg_tilemap[1],offset & 0x3ff); + if (state->video_circuit) + tilemap_mark_tile_dirty(state->bg_tilemap[1], offset & 0x3ff); else - tilemap_mark_tile_dirty(bg_tilemap[0],offset & 0x3ff); + tilemap_mark_tile_dirty(state->bg_tilemap[0], offset & 0x3ff); } - else if( offset<0x1000 && combasc_video_circuit==0 ) + else if (offset < 0x1000 && state->video_circuit == 0) { - tilemap_mark_tile_dirty( textlayer,offset & 0x3ff); + tilemap_mark_tile_dirty(state->textlayer, offset & 0x3ff); } } - -WRITE8_HANDLER( combasc_vreg_w ) +WRITE8_HANDLER( combatsc_pf_control_w ) { - if (data != combasc_vreg) - { - tilemap_mark_all_tiles_dirty( textlayer ); - if ((data & 0x0f) != (combasc_vreg & 0x0f)) - tilemap_mark_all_tiles_dirty( bg_tilemap[0] ); - if ((data >> 4) != (combasc_vreg >> 4)) - tilemap_mark_all_tiles_dirty( bg_tilemap[1] ); - combasc_vreg = data; - } -} - -static WRITE8_HANDLER( combascb_sh_irqtrigger_w ) -{ - soundlatch_w(space, offset, data); - cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff); -} - -static READ8_HANDLER( combascb_io_r ) -{ - static const char *const portnames[] = { "IN0", "IN1", "DSW1", "DSW2" }; - - return input_port_read(space->machine, portnames[offset]); -} - -static WRITE8_HANDLER( combascb_priority_w ) -{ - priority = data & 0x20; -} - -WRITE8_HANDLER( combasc_bankselect_w ) -{ - UINT8 *page = memory_region(space->machine, "maincpu") + 0x10000; - - if (data & 0x40) - { - combasc_video_circuit = 1; - space->machine->generic.videoram.u8 = combasc_page[1]; - combasc_scrollram = combasc_scrollram1; - } - else - { - combasc_video_circuit = 0; - space->machine->generic.videoram.u8 = combasc_page[0]; - combasc_scrollram = combasc_scrollram0; - } - - priority = data & 0x20; - - if (data & 0x10) - { - memory_set_bankptr(space->machine, "bank1",page + 0x4000 * ((data & 0x0e) >> 1)); - } - else - { - memory_set_bankptr(space->machine, "bank1",page + 0x20000 + 0x4000 * (data & 1)); - } -} - -WRITE8_HANDLER( combascb_bankselect_w ) -{ - if (data & 0x40) - { - combasc_video_circuit = 1; - space->machine->generic.videoram.u8 = combasc_page[1]; - } - else - { - combasc_video_circuit = 0; - space->machine->generic.videoram.u8 = combasc_page[0]; - } - - data = data & 0x1f; - if( data != combasc_bank_select ) - { - UINT8 *page = memory_region(space->machine, "maincpu") + 0x10000; - combasc_bank_select = data; - - if (data & 0x10) - { - memory_set_bankptr(space->machine, "bank1",page + 0x4000 * ((data & 0x0e) >> 1)); - } - else - { - memory_set_bankptr(space->machine, "bank1",page + 0x20000 + 0x4000 * (data & 1)); - } - - if (data == 0x1f) - { - memory_set_bankptr(space->machine, "bank1",page + 0x20000 + 0x4000 * (data & 1)); - memory_install_read8_handler(space, 0x4400, 0x4403, 0, 0, combascb_io_r);/* IO RAM & Video Registers */ - memory_install_write8_handler(space, 0x4400, 0x4400, 0, 0, combascb_priority_w); - memory_install_write8_handler(space, 0x4800, 0x4800, 0, 0, combascb_sh_irqtrigger_w); - memory_install_write8_handler(space, 0x4c00, 0x4c00, 0, 0, combasc_vreg_w); - } - else - { - memory_install_read_bank(space, 0x4000, 0x7fff, 0, 0, "bank1"); /* banked ROM */ - memory_unmap_write(space, 0x4000, 0x7fff, 0, 0); /* banked ROM */ - } - } -} - -MACHINE_RESET( combasc ) -{ - UINT8 *MEM = memory_region(machine, "maincpu") + 0x38000; - const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - - combasc_io_ram = MEM + 0x0000; - combasc_page[0] = MEM + 0x4000; - combasc_page[1] = MEM + 0x6000; - - memset( combasc_io_ram, 0x00, 0x4000 ); - memset( combasc_page[0], 0x00, 0x2000 ); - memset( combasc_page[1], 0x00, 0x2000 ); - - combasc_bank_select = -1; - combasc_bankselect_w(space, 0, 0); -} - -WRITE8_HANDLER( combasc_pf_control_w ) -{ - const char *chiptag = combasc_video_circuit ? "k007121_2" : "k007121_1"; - const device_config *k007121 = devtag_get_device(space->machine, chiptag); + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + const device_config *k007121 = state->video_circuit ? state->k007121_2 : state->k007121_1; k007121_ctrl_w(k007121, offset, data); if (offset == 7) - tilemap_set_flip(bg_tilemap[combasc_video_circuit],(data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + tilemap_set_flip(state->bg_tilemap[state->video_circuit],(data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); if (offset == 3) { if (data & 0x08) - memcpy(private_spriteram[combasc_video_circuit],combasc_page[combasc_video_circuit]+0x1000,0x800); + memcpy(state->spriteram[state->video_circuit], state->page[state->video_circuit] + 0x1000, 0x800); else - memcpy(private_spriteram[combasc_video_circuit],combasc_page[combasc_video_circuit]+0x1800,0x800); + memcpy(state->spriteram[state->video_circuit], state->page[state->video_circuit] + 0x1800, 0x800); } } -READ8_HANDLER( combasc_scrollram_r ) +READ8_HANDLER( combatsc_scrollram_r ) { - return combasc_scrollram[offset]; + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + return state->scrollram[offset]; } -WRITE8_HANDLER( combasc_scrollram_w ) +WRITE8_HANDLER( combatsc_scrollram_w ) { - combasc_scrollram[offset] = data; + combatsc_state *state = (combatsc_state *)space->machine->driver_data; + state->scrollram[offset] = data; } @@ -482,97 +393,96 @@ WRITE8_HANDLER( combasc_scrollram_w ) ***************************************************************************/ -static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source,int circuit,UINT32 pri_mask) +static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source, int circuit, UINT32 pri_mask ) { - const char *chiptag = circuit ? "k007121_2" : "k007121_1"; - const device_config *k007121 = devtag_get_device(machine, chiptag); + combatsc_state *state = (combatsc_state *)machine->driver_data; + const device_config *k007121 = circuit ? state->k007121_2 : state->k007121_1; int base_color = (circuit * 4) * 16 + (k007121_ctrlram_r(k007121, 6) & 0x10) * 2; k007121_sprites_draw(k007121, bitmap, cliprect, machine->gfx[circuit], machine->colortable, source, base_color, 0, 0, pri_mask); } -VIDEO_UPDATE( combasc ) +VIDEO_UPDATE( combatsc ) { - const device_config *k007121_1 = devtag_get_device(screen->machine, "k007121_1"); - const device_config *k007121_2 = devtag_get_device(screen->machine, "k007121_2"); + combatsc_state *state = (combatsc_state *)screen->machine->driver_data; int i; set_pens(screen->machine); - if (k007121_ctrlram_r(k007121_1, 1) & 0x02) + if (k007121_ctrlram_r(state->k007121_1, 1) & 0x02) { - tilemap_set_scroll_rows(bg_tilemap[0],32); - for (i = 0;i < 32;i++) - tilemap_set_scrollx(bg_tilemap[0],i,combasc_scrollram0[i]); + tilemap_set_scroll_rows(state->bg_tilemap[0], 32); + for (i = 0; i < 32; i++) + tilemap_set_scrollx(state->bg_tilemap[0], i, state->scrollram0[i]); } else { - tilemap_set_scroll_rows(bg_tilemap[0],1); - tilemap_set_scrollx(bg_tilemap[0],0,k007121_ctrlram_r(k007121_1, 0) | ((k007121_ctrlram_r(k007121_1, 1) & 0x01) << 8)); + tilemap_set_scroll_rows(state->bg_tilemap[0], 1); + tilemap_set_scrollx(state->bg_tilemap[0], 0, k007121_ctrlram_r(state->k007121_1, 0) | ((k007121_ctrlram_r(state->k007121_1, 1) & 0x01) << 8)); } - if (k007121_ctrlram_r(k007121_2, 1) & 0x02) + if (k007121_ctrlram_r(state->k007121_2, 1) & 0x02) { - tilemap_set_scroll_rows(bg_tilemap[1],32); - for (i = 0;i < 32;i++) - tilemap_set_scrollx(bg_tilemap[1],i,combasc_scrollram1[i]); + tilemap_set_scroll_rows(state->bg_tilemap[1], 32); + for (i = 0; i < 32; i++) + tilemap_set_scrollx(state->bg_tilemap[1], i, state->scrollram1[i]); } else { - tilemap_set_scroll_rows(bg_tilemap[1],1); - tilemap_set_scrollx(bg_tilemap[1],0,k007121_ctrlram_r(k007121_2, 0) | ((k007121_ctrlram_r(k007121_2, 1) & 0x01) << 8)); + tilemap_set_scroll_rows(state->bg_tilemap[1], 1); + tilemap_set_scrollx(state->bg_tilemap[1], 0, k007121_ctrlram_r(state->k007121_2, 0) | ((k007121_ctrlram_r(state->k007121_2, 1) & 0x01) << 8)); } - tilemap_set_scrolly(bg_tilemap[0],0,k007121_ctrlram_r(k007121_1, 2)); - tilemap_set_scrolly(bg_tilemap[1],0,k007121_ctrlram_r(k007121_2, 2)); + tilemap_set_scrolly(state->bg_tilemap[0], 0, k007121_ctrlram_r(state->k007121_1, 2)); + tilemap_set_scrolly(state->bg_tilemap[1], 0, k007121_ctrlram_r(state->k007121_2, 2)); - bitmap_fill(screen->machine->priority_bitmap,cliprect,0); + bitmap_fill(screen->machine->priority_bitmap, cliprect, 0); - if (priority == 0) + if (state->priority == 0) { - tilemap_draw(bitmap,cliprect,bg_tilemap[1],TILEMAP_DRAW_OPAQUE|0,4); - tilemap_draw(bitmap,cliprect,bg_tilemap[1],TILEMAP_DRAW_OPAQUE|1,8); - tilemap_draw(bitmap,cliprect,bg_tilemap[0],0,1); - tilemap_draw(bitmap,cliprect,bg_tilemap[0],1,2); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], TILEMAP_DRAW_OPAQUE | 0, 4); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], TILEMAP_DRAW_OPAQUE | 1, 8); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], 0, 1); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], 1, 2); /* we use the priority buffer so sprites are drawn front to back */ - draw_sprites(screen->machine,bitmap,cliprect,private_spriteram[1],1,0x0f00); - draw_sprites(screen->machine,bitmap,cliprect,private_spriteram[0],0,0x4444); + draw_sprites(screen->machine, bitmap, cliprect, state->spriteram[1], 1, 0x0f00); + draw_sprites(screen->machine, bitmap, cliprect, state->spriteram[0], 0, 0x4444); } else { - tilemap_draw(bitmap,cliprect,bg_tilemap[0],TILEMAP_DRAW_OPAQUE|0,1); - tilemap_draw(bitmap,cliprect,bg_tilemap[0],TILEMAP_DRAW_OPAQUE|1,2); - tilemap_draw(bitmap,cliprect,bg_tilemap[1],1,4); - tilemap_draw(bitmap,cliprect,bg_tilemap[1],0,8); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], TILEMAP_DRAW_OPAQUE | 0, 1); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], TILEMAP_DRAW_OPAQUE | 1, 2); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], 1, 4); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], 0, 8); /* we use the priority buffer so sprites are drawn front to back */ - draw_sprites(screen->machine,bitmap,cliprect,private_spriteram[1],1,0x0f00); - draw_sprites(screen->machine,bitmap,cliprect,private_spriteram[0],0,0x4444); + draw_sprites(screen->machine, bitmap, cliprect, state->spriteram[1], 1, 0x0f00); + draw_sprites(screen->machine, bitmap, cliprect, state->spriteram[0], 0, 0x4444); } - if (k007121_ctrlram_r(k007121_1, 1) & 0x08) + if (k007121_ctrlram_r(state->k007121_1, 1) & 0x08) { - for (i = 0;i < 32;i++) + for (i = 0; i < 32; i++) { - tilemap_set_scrollx(textlayer,i,combasc_scrollram0[0x20+i] ? 0 : TILE_LINE_DISABLED); - tilemap_draw(bitmap,cliprect,textlayer,0,0); + tilemap_set_scrollx(state->textlayer, i, state->scrollram0[0x20 + i] ? 0 : TILE_LINE_DISABLED); + tilemap_draw(bitmap, cliprect, state->textlayer, 0, 0); } } /* chop the extreme columns if necessary */ - if (k007121_ctrlram_r(k007121_1, 3) & 0x40) + if (k007121_ctrlram_r(state->k007121_1, 3) & 0x40) { rectangle clip; clip = *cliprect; clip.max_x = clip.min_x + 7; - bitmap_fill(bitmap,&clip,0); + bitmap_fill(bitmap, &clip, 0); clip = *cliprect; clip.min_x = clip.max_x - 7; - bitmap_fill(bitmap,&clip,0); + bitmap_fill(bitmap, &clip, 0); } return 0; } @@ -605,22 +515,23 @@ byte #4: ***************************************************************************/ -static void bootleg_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source, int circuit ) +static void bootleg_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT8 *source, int circuit ) { const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - const gfx_element *gfx = machine->gfx[circuit+2]; + const gfx_element *gfx = machine->gfx[circuit + 2]; - int limit = ( circuit) ? (memory_read_byte(space, 0xc2)*256 + memory_read_byte(space, 0xc3)) : (memory_read_byte(space, 0xc0)*256 + memory_read_byte(space, 0xc1)); + int limit = circuit ? (memory_read_byte(space, 0xc2) * 256 + memory_read_byte(space, 0xc3)) : (memory_read_byte(space, 0xc0) * 256 + memory_read_byte(space, 0xc1)); const UINT8 *finish; - source+=0x1000; + source += 0x1000; finish = source; - source+=0x400; - limit = (0x3400-limit)/8; - if( limit>=0 ) finish = source-limit*8; - source-=8; + source += 0x400; + limit = (0x3400 - limit) / 8; + if (limit >= 0) + finish = source - limit * 8; + source -= 8; - while( source>finish ) + while (source > finish) { UINT8 attributes = source[3]; /* PBxF ?xxX */ { @@ -632,14 +543,14 @@ static void bootleg_draw_sprites(running_machine *machine, bitmap_t *bitmap, con int bank = (color & 0x03) | ((attributes & 0x40) >> 4); number = ((number & 0x02) << 1) | ((number & 0x04) >> 1) | (number & (~6)); - number += 256*bank; + number += 256 * bank; - color = (circuit*4)*16 + (color >> 4); + color = (circuit * 4) * 16 + (color >> 4); /* hacks to select alternate palettes */ -// if(combasc_vreg == 0x40 && (attributes & 0x40)) color += 1*16; -// if(combasc_vreg == 0x23 && (attributes & 0x02)) color += 1*16; -// if(combasc_vreg == 0x66 ) color += 2*16; +// if(state->vreg == 0x40 && (attributes & 0x40)) color += 1*16; +// if(state->vreg == 0x23 && (attributes & 0x02)) color += 1*16; +// if(state->vreg == 0x66 ) color += 2*16; drawgfx_transpen( bitmap, cliprect, gfx, number, color, @@ -650,37 +561,38 @@ static void bootleg_draw_sprites(running_machine *machine, bitmap_t *bitmap, con } } -VIDEO_UPDATE( combascb ) +VIDEO_UPDATE( combatscb ) { + combatsc_state *state = (combatsc_state *)screen->machine->driver_data; int i; set_pens(screen->machine); - for( i=0; i<32; i++ ) + for (i = 0; i < 32; i++) { - tilemap_set_scrollx( bg_tilemap[0],i, combasc_io_ram[0x040+i]+5 ); - tilemap_set_scrollx( bg_tilemap[1],i, combasc_io_ram[0x060+i]+3 ); + tilemap_set_scrollx(state->bg_tilemap[0], i, state->io_ram[0x040 + i] + 5); + tilemap_set_scrollx(state->bg_tilemap[1], i, state->io_ram[0x060 + i] + 3); } - tilemap_set_scrolly( bg_tilemap[0],0, combasc_io_ram[0x000] ); - tilemap_set_scrolly( bg_tilemap[1],0, combasc_io_ram[0x020] ); + tilemap_set_scrolly(state->bg_tilemap[0], 0, state->io_ram[0x000]); + tilemap_set_scrolly(state->bg_tilemap[1], 0, state->io_ram[0x020]); - if (priority == 0) + if (state->priority == 0) { - tilemap_draw( bitmap,cliprect,bg_tilemap[1],TILEMAP_DRAW_OPAQUE,0); - bootleg_draw_sprites(screen->machine, bitmap,cliprect, combasc_page[1], 1 ); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[1], TILEMAP_DRAW_OPAQUE,0); + bootleg_draw_sprites(screen->machine, bitmap,cliprect, state->page[1], 1); - tilemap_draw( bitmap,cliprect,bg_tilemap[0],0 ,0); - bootleg_draw_sprites(screen->machine, bitmap,cliprect, combasc_page[0], 0 ); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], 0 ,0); + bootleg_draw_sprites(screen->machine, bitmap, cliprect, state->page[0], 0); } else { - tilemap_draw( bitmap,cliprect,bg_tilemap[0],TILEMAP_DRAW_OPAQUE,0); - bootleg_draw_sprites(screen->machine, bitmap,cliprect, combasc_page[0], 0 ); + tilemap_draw(bitmap, cliprect, state->bg_tilemap[0], TILEMAP_DRAW_OPAQUE, 0); + bootleg_draw_sprites(screen->machine, bitmap,cliprect, state->page[0], 0); - tilemap_draw( bitmap,cliprect,bg_tilemap[1],0 ,0); - bootleg_draw_sprites(screen->machine, bitmap,cliprect, combasc_page[1], 1 ); + tilemap_draw(bitmap,cliprect, state->bg_tilemap[1], 0, 0); + bootleg_draw_sprites(screen->machine, bitmap,cliprect, state->page[1], 1); } - tilemap_draw( bitmap,cliprect,textlayer,0,0); + tilemap_draw(bitmap, cliprect, state->textlayer, 0, 0); return 0; } diff --git a/src/mame/video/contra.c b/src/mame/video/contra.c index 22ca84c91de..216edd61a9c 100644 --- a/src/mame/video/contra.c +++ b/src/mame/video/contra.c @@ -6,16 +6,8 @@ #include "driver.h" #include "video/konicdev.h" +#include "includes/contra.h" -//static int spriteram_offset; -static UINT8 *private_spriteram_2,*private_spriteram; - -UINT8 *contra_fg_vram,*contra_fg_cram; -UINT8 *contra_text_vram,*contra_text_cram; -UINT8 *contra_bg_vram,*contra_bg_cram; - -static tilemap *bg_tilemap, *fg_tilemap, *tx_tilemap; -static rectangle bg_clip, fg_clip, tx_clip; /*************************************************************************** ** @@ -60,13 +52,14 @@ PALETTE_INIT( contra ) } -static void set_pens(running_machine *machine) +static void set_pens( running_machine *machine ) { + contra_state *state = (contra_state *)machine->driver_data; int i; for (i = 0x00; i < 0x100; i += 2) { - UINT16 data = machine->generic.paletteram.u8[i] | (machine->generic.paletteram.u8[i | 1] << 8); + UINT16 data = state->paletteram[i] | (state->paletteram[i | 1] << 8); rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); @@ -84,12 +77,12 @@ static void set_pens(running_machine *machine) static TILE_GET_INFO( get_fg_tile_info ) { - const device_config *k007121 = devtag_get_device(machine, "k007121_1"); - UINT8 ctrl_3 = k007121_ctrlram_r(k007121, 3); - UINT8 ctrl_4 = k007121_ctrlram_r(k007121, 4); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); - int attr = contra_fg_cram[tile_index]; + contra_state *state = (contra_state *)machine->driver_data; + UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121_1, 3); + UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121_1, 4); + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_1, 5); + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6); + int attr = state->fg_cram[tile_index]; int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; @@ -106,19 +99,19 @@ static TILE_GET_INFO( get_fg_tile_info ) SET_TILE_INFO( 0, - contra_fg_vram[tile_index] + bank * 256, + state->fg_vram[tile_index] + bank * 256, ((ctrl_6 & 0x30) * 2 + 16) + (attr & 7), 0); } static TILE_GET_INFO( get_bg_tile_info ) { - const device_config *k007121 = devtag_get_device(machine, "k007121_2"); - UINT8 ctrl_3 = k007121_ctrlram_r(k007121, 3); - UINT8 ctrl_4 = k007121_ctrlram_r(k007121, 4); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); - int attr = contra_bg_cram[tile_index]; + contra_state *state = (contra_state *)machine->driver_data; + UINT8 ctrl_3 = k007121_ctrlram_r(state->k007121_2, 3); + UINT8 ctrl_4 = k007121_ctrlram_r(state->k007121_2, 4); + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_2, 5); + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_2, 6); + int attr = state->bg_cram[tile_index]; int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; @@ -136,17 +129,17 @@ static TILE_GET_INFO( get_bg_tile_info ) SET_TILE_INFO( 1, - contra_bg_vram[tile_index] + bank * 256, + state->bg_vram[tile_index] + bank * 256, ((ctrl_6 & 0x30) * 2 + 16) + (attr & 7), 0); } static TILE_GET_INFO( get_tx_tile_info ) { - const device_config *k007121 = devtag_get_device(machine, "k007121_1"); - UINT8 ctrl_5 = k007121_ctrlram_r(k007121, 5); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); - int attr = contra_text_cram[tile_index]; + contra_state *state = (contra_state *)machine->driver_data; + UINT8 ctrl_5 = k007121_ctrlram_r(state->k007121_1, 5); + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6); + int attr = state->tx_cram[tile_index]; int bit0 = (ctrl_5 >> 0) & 0x03; int bit1 = (ctrl_5 >> 2) & 0x03; int bit2 = (ctrl_5 >> 4) & 0x03; @@ -159,7 +152,7 @@ static TILE_GET_INFO( get_tx_tile_info ) SET_TILE_INFO( 0, - contra_text_vram[tile_index] + bank * 256, + state->tx_vram[tile_index] + bank * 256, ((ctrl_6 & 0x30) * 2 + 16) + (attr & 7), 0); } @@ -173,23 +166,28 @@ static TILE_GET_INFO( get_tx_tile_info ) VIDEO_START( contra ) { - bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows, 8,8,32,32); - fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32); - tx_tilemap = tilemap_create(machine, get_tx_tile_info,tilemap_scan_rows, 8,8,32,32); + contra_state *state = (contra_state *)machine->driver_data; - private_spriteram = auto_alloc_array(machine, UINT8, 0x800); - private_spriteram_2 = auto_alloc_array(machine, UINT8, 0x800); + state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + state->tx_tilemap = tilemap_create(machine, get_tx_tile_info, tilemap_scan_rows, 8, 8, 32, 32); - bg_clip = *video_screen_get_visible_area(machine->primary_screen); - bg_clip.min_x += 40; + state->spriteram = auto_alloc_array(machine, UINT8, 0x800); + state->spriteram_2 = auto_alloc_array(machine, UINT8, 0x800); - fg_clip = bg_clip; + state->bg_clip = *video_screen_get_visible_area(machine->primary_screen); + state->bg_clip.min_x += 40; - tx_clip = *video_screen_get_visible_area(machine->primary_screen); - tx_clip.max_x = 39; - tx_clip.min_x = 0; + state->fg_clip = state->bg_clip; - tilemap_set_transparent_pen(fg_tilemap,0); + state->tx_clip = *video_screen_get_visible_area(machine->primary_screen); + state->tx_clip.max_x = 39; + state->tx_clip.min_x = 0; + + tilemap_set_transparent_pen(state->fg_tilemap, 0); + + state_save_register_global_pointer(machine, state->spriteram, 0x800); + state_save_register_global_pointer(machine, state->spriteram_2, 0x800); } @@ -201,83 +199,98 @@ VIDEO_START( contra ) WRITE8_HANDLER( contra_fg_vram_w ) { - contra_fg_vram[offset] = data; - tilemap_mark_tile_dirty(fg_tilemap,offset); + contra_state *state = (contra_state *)space->machine->driver_data; + + state->fg_vram[offset] = data; + tilemap_mark_tile_dirty(state->fg_tilemap, offset); } -WRITE8_HANDLER( contra_fg_cram_w ){ - contra_fg_cram[offset] = data; - tilemap_mark_tile_dirty(fg_tilemap,offset); +WRITE8_HANDLER( contra_fg_cram_w ) +{ + contra_state *state = (contra_state *)space->machine->driver_data; + + state->fg_cram[offset] = data; + tilemap_mark_tile_dirty(state->fg_tilemap, offset); } WRITE8_HANDLER( contra_bg_vram_w ) { - contra_bg_vram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap,offset); + contra_state *state = (contra_state *)space->machine->driver_data; + + state->bg_vram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset); } WRITE8_HANDLER( contra_bg_cram_w ) { - contra_bg_cram[offset] = data; - tilemap_mark_tile_dirty(bg_tilemap,offset); + contra_state *state = (contra_state *)space->machine->driver_data; + + state->bg_cram[offset] = data; + tilemap_mark_tile_dirty(state->bg_tilemap, offset); } WRITE8_HANDLER( contra_text_vram_w ) { - contra_text_vram[offset] = data; - tilemap_mark_tile_dirty(tx_tilemap,offset); + contra_state *state = (contra_state *)space->machine->driver_data; + + state->tx_vram[offset] = data; + tilemap_mark_tile_dirty(state->tx_tilemap, offset); } WRITE8_HANDLER( contra_text_cram_w ) { - contra_text_cram[offset] = data; - tilemap_mark_tile_dirty(tx_tilemap,offset); + contra_state *state = (contra_state *)space->machine->driver_data; + + state->tx_cram[offset] = data; + tilemap_mark_tile_dirty(state->tx_tilemap, offset); } WRITE8_HANDLER( contra_K007121_ctrl_0_w ) { - const device_config *k007121 = devtag_get_device(space->machine, "k007121_1"); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); + contra_state *state = (contra_state *)space->machine->driver_data; + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_1, 6); if (offset == 3) { if ((data & 0x8) == 0) - memcpy(private_spriteram,space->machine->generic.spriteram.u8+0x800,0x800); + memcpy(state->spriteram, space->machine->generic.spriteram.u8 + 0x800, 0x800); else - memcpy(private_spriteram,space->machine->generic.spriteram.u8,0x800); + memcpy(state->spriteram, space->machine->generic.spriteram.u8, 0x800); } + if (offset == 6) { if (ctrl_6 != data) - tilemap_mark_all_tiles_dirty(fg_tilemap); + tilemap_mark_all_tiles_dirty(state->fg_tilemap); } - if (offset == 7) - tilemap_set_flip(fg_tilemap,(data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - k007121_ctrl_w(k007121, offset, data); + if (offset == 7) + tilemap_set_flip(state->fg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + + k007121_ctrl_w(state->k007121_1, offset, data); } WRITE8_HANDLER( contra_K007121_ctrl_1_w ) { - const device_config *k007121 = devtag_get_device(space->machine, "k007121_2"); - UINT8 ctrl_6 = k007121_ctrlram_r(k007121, 6); + contra_state *state = (contra_state *)space->machine->driver_data; + UINT8 ctrl_6 = k007121_ctrlram_r(state->k007121_2, 6); if (offset == 3) { if ((data & 0x8) == 0) - memcpy(private_spriteram_2,space->machine->generic.spriteram.u8+0x2800,0x800); + memcpy(state->spriteram_2, space->machine->generic.spriteram.u8 + 0x2800, 0x800); else - memcpy(private_spriteram_2,space->machine->generic.spriteram.u8+0x2000,0x800); + memcpy(state->spriteram_2, space->machine->generic.spriteram.u8 + 0x2000, 0x800); } if (offset == 6) { if (ctrl_6 != data ) - tilemap_mark_all_tiles_dirty(bg_tilemap); + tilemap_mark_all_tiles_dirty(state->bg_tilemap); } if (offset == 7) - tilemap_set_flip(bg_tilemap,(data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); + tilemap_set_flip(state->bg_tilemap, (data & 0x08) ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0); - k007121_ctrl_w(k007121, offset, data); + k007121_ctrl_w(state->k007121_2, offset, data); } @@ -290,28 +303,29 @@ WRITE8_HANDLER( contra_K007121_ctrl_1_w ) static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int bank ) { - const char *chiptag = bank ? "k007121_2" : "k007121_1"; - const device_config *k007121 = devtag_get_device(machine, chiptag); + contra_state *state = (contra_state *)machine->driver_data; + const device_config *k007121 = bank ? state->k007121_2 : state->k007121_1; int base_color = (k007121_ctrlram_r(k007121, 6) & 0x30) * 2; const UINT8 *source; - if (bank==0) source=private_spriteram; - else source=private_spriteram_2; + if (bank == 0) + source = state->spriteram; + else + source = state->spriteram_2; - k007121_sprites_draw(k007121,bitmap,cliprect,machine->gfx[bank],machine->colortable,source,base_color,40,0,-1); + k007121_sprites_draw(k007121, bitmap, cliprect, machine->gfx[bank], machine->colortable, source, base_color, 40, 0, -1); } VIDEO_UPDATE( contra ) { - const device_config *k007121_1 = devtag_get_device(screen->machine, "k007121_1"); - const device_config *k007121_2 = devtag_get_device(screen->machine, "k007121_2"); - UINT8 ctrl_1_0 = k007121_ctrlram_r(k007121_1, 0); - UINT8 ctrl_1_2 = k007121_ctrlram_r(k007121_1, 2); - UINT8 ctrl_2_0 = k007121_ctrlram_r(k007121_2, 0); - UINT8 ctrl_2_2 = k007121_ctrlram_r(k007121_2, 2); - rectangle bg_finalclip = bg_clip; - rectangle fg_finalclip = fg_clip; - rectangle tx_finalclip = tx_clip; + contra_state *state = (contra_state *)screen->machine->driver_data; + UINT8 ctrl_1_0 = k007121_ctrlram_r(state->k007121_1, 0); + UINT8 ctrl_1_2 = k007121_ctrlram_r(state->k007121_1, 2); + UINT8 ctrl_2_0 = k007121_ctrlram_r(state->k007121_2, 0); + UINT8 ctrl_2_2 = k007121_ctrlram_r(state->k007121_2, 2); + rectangle bg_finalclip = state->bg_clip; + rectangle fg_finalclip = state->fg_clip; + rectangle tx_finalclip = state->tx_clip; sect_rect(&bg_finalclip, cliprect); sect_rect(&fg_finalclip, cliprect); @@ -319,15 +333,15 @@ VIDEO_UPDATE( contra ) set_pens(screen->machine); - tilemap_set_scrollx( fg_tilemap, 0, ctrl_1_0 - 40 ); - tilemap_set_scrolly( fg_tilemap, 0, ctrl_1_2 ); - tilemap_set_scrollx( bg_tilemap, 0, ctrl_2_0 - 40 ); - tilemap_set_scrolly( bg_tilemap, 0, ctrl_2_2 ); + tilemap_set_scrollx(state->fg_tilemap, 0, ctrl_1_0 - 40); + tilemap_set_scrolly(state->fg_tilemap, 0, ctrl_1_2); + tilemap_set_scrollx(state->bg_tilemap, 0, ctrl_2_0 - 40); + tilemap_set_scrolly(state->bg_tilemap, 0, ctrl_2_2); - tilemap_draw( bitmap,&bg_finalclip, bg_tilemap, 0 ,0); - tilemap_draw( bitmap,&fg_finalclip, fg_tilemap, 0 ,0); - draw_sprites( screen->machine,bitmap,cliprect, 0 ); - draw_sprites( screen->machine,bitmap,cliprect, 1 ); - tilemap_draw( bitmap,&tx_finalclip, tx_tilemap, 0 ,0); + tilemap_draw(bitmap, &bg_finalclip, state->bg_tilemap, 0 ,0); + tilemap_draw(bitmap, &fg_finalclip, state->fg_tilemap, 0 ,0); + draw_sprites(screen->machine,bitmap,cliprect, 0); + draw_sprites(screen->machine,bitmap,cliprect, 1); + tilemap_draw(bitmap, &tx_finalclip, state->tx_tilemap, 0 ,0); return 0; } diff --git a/src/mame/video/crshrace.c b/src/mame/video/crshrace.c index f9205ead434..ab9769440bb 100644 --- a/src/mame/video/crshrace.c +++ b/src/mame/video/crshrace.c @@ -3,15 +3,6 @@ #include "includes/crshrace.h" -UINT16 *crshrace_videoram1,*crshrace_videoram2; -//UINT16 *crshrace_roz_ctrl1,*crshrace_roz_ctrl2; - -static int roz_bank,gfxctrl,flipscreen; - -static tilemap *tilemap1,*tilemap2; - - - /*************************************************************************** Callbacks for the TileMap code @@ -20,16 +11,18 @@ static tilemap *tilemap1,*tilemap2; static TILE_GET_INFO( get_tile_info1 ) { - int code = crshrace_videoram1[tile_index]; + crshrace_state *state = (crshrace_state *)machine->driver_data; + int code = state->videoram1[tile_index]; - SET_TILE_INFO(1,(code & 0xfff) + (roz_bank << 12),code >> 12,0); + SET_TILE_INFO(1, (code & 0xfff) + (state->roz_bank << 12), code >> 12, 0); } static TILE_GET_INFO( get_tile_info2 ) { - int code = crshrace_videoram2[tile_index]; + crshrace_state *state = (crshrace_state *)machine->driver_data; + int code = state->videoram2[tile_index]; - SET_TILE_INFO(0,code,0,0); + SET_TILE_INFO(0, code, 0, 0); } @@ -41,11 +34,13 @@ static TILE_GET_INFO( get_tile_info2 ) VIDEO_START( crshrace ) { - tilemap1 = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,64,64); - tilemap2 = tilemap_create(machine, get_tile_info2,tilemap_scan_rows, 8, 8,64,64); + crshrace_state *state = (crshrace_state *)machine->driver_data; - tilemap_set_transparent_pen(tilemap1,0x0f); - tilemap_set_transparent_pen(tilemap2,0xff); + state->tilemap1 = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 16, 16, 64, 64); + state->tilemap2 = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 8, 8, 64, 64); + + tilemap_set_transparent_pen(state->tilemap1, 0x0f); + tilemap_set_transparent_pen(state->tilemap2, 0xff); } @@ -57,24 +52,30 @@ VIDEO_START( crshrace ) WRITE16_HANDLER( crshrace_videoram1_w ) { - COMBINE_DATA(&crshrace_videoram1[offset]); - tilemap_mark_tile_dirty(tilemap1,offset); + crshrace_state *state = (crshrace_state *)space->machine->driver_data; + + COMBINE_DATA(&state->videoram1[offset]); + tilemap_mark_tile_dirty(state->tilemap1, offset); } WRITE16_HANDLER( crshrace_videoram2_w ) { - COMBINE_DATA(&crshrace_videoram2[offset]); - tilemap_mark_tile_dirty(tilemap2,offset); + crshrace_state *state = (crshrace_state *)space->machine->driver_data; + + COMBINE_DATA(&state->videoram2[offset]); + tilemap_mark_tile_dirty(state->tilemap2, offset); } WRITE16_HANDLER( crshrace_roz_bank_w ) { + crshrace_state *state = (crshrace_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) { - if (roz_bank != (data & 0xff)) + if (state->roz_bank != (data & 0xff)) { - roz_bank = data & 0xff; - tilemap_mark_all_tiles_dirty(tilemap1); + state->roz_bank = data & 0xff; + tilemap_mark_all_tiles_dirty(state->tilemap1); } } } @@ -82,10 +83,12 @@ WRITE16_HANDLER( crshrace_roz_bank_w ) WRITE16_HANDLER( crshrace_gfxctrl_w ) { + crshrace_state *state = (crshrace_state *)space->machine->driver_data; + if (ACCESSING_BITS_0_7) { - gfxctrl = data & 0xdf; - flipscreen = data & 0x20; + state->gfxctrl = data & 0xdf; + state->flipscreen = data & 0x20; } } @@ -98,57 +101,57 @@ WRITE16_HANDLER( crshrace_gfxctrl_w ) static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect) { - UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16; - UINT16 *buffered_spriteram16_2 = machine->generic.buffered_spriteram2.u16; + crshrace_state *state = (crshrace_state *)machine->driver_data; + UINT16 *buffered_spriteram = machine->generic.buffered_spriteram.u16; + UINT16 *buffered_spriteram_2 = machine->generic.buffered_spriteram2.u16; int offs; - offs = 0; - while (offs < 0x0400 && (buffered_spriteram16[offs] & 0x4000) == 0) + while (offs < 0x0400 && (buffered_spriteram[offs] & 0x4000) == 0) { int attr_start; int map_start; - int ox,oy,x,y,xsize,ysize,zoomx,zoomy,flipx,flipy,color; + int ox, oy, x, y, xsize, ysize, zoomx, zoomy, flipx, flipy, color; /* table hand made by looking at the ship explosion in aerofgt attract mode */ /* it's almost a logarithmic scale but not exactly */ static const int zoomtable[16] = { 0,7,14,20,25,30,34,38,42,46,49,52,54,57,59,61 }; - attr_start = 4 * (buffered_spriteram16[offs++] & 0x03ff); + attr_start = 4 * (buffered_spriteram[offs++] & 0x03ff); - ox = buffered_spriteram16[attr_start + 1] & 0x01ff; - xsize = (buffered_spriteram16[attr_start + 1] & 0x0e00) >> 9; - zoomx = (buffered_spriteram16[attr_start + 1] & 0xf000) >> 12; - oy = buffered_spriteram16[attr_start + 0] & 0x01ff; - ysize = (buffered_spriteram16[attr_start + 0] & 0x0e00) >> 9; - zoomy = (buffered_spriteram16[attr_start + 0] & 0xf000) >> 12; - flipx = buffered_spriteram16[attr_start + 2] & 0x4000; - flipy = buffered_spriteram16[attr_start + 2] & 0x8000; - color = (buffered_spriteram16[attr_start + 2] & 0x1f00) >> 8; - map_start = buffered_spriteram16[attr_start + 3] & 0x7fff; + ox = buffered_spriteram[attr_start + 1] & 0x01ff; + xsize = (buffered_spriteram[attr_start + 1] & 0x0e00) >> 9; + zoomx = (buffered_spriteram[attr_start + 1] & 0xf000) >> 12; + oy = buffered_spriteram[attr_start + 0] & 0x01ff; + ysize = (buffered_spriteram[attr_start + 0] & 0x0e00) >> 9; + zoomy = (buffered_spriteram[attr_start + 0] & 0xf000) >> 12; + flipx = buffered_spriteram[attr_start + 2] & 0x4000; + flipy = buffered_spriteram[attr_start + 2] & 0x8000; + color = (buffered_spriteram[attr_start + 2] & 0x1f00) >> 8; + map_start = buffered_spriteram[attr_start + 3] & 0x7fff; - zoomx = 16 - zoomtable[zoomx]/8; - zoomy = 16 - zoomtable[zoomy]/8; + zoomx = 16 - zoomtable[zoomx] / 8; + zoomy = 16 - zoomtable[zoomy] / 8; - if (buffered_spriteram16[attr_start + 2] & 0x20ff) color = mame_rand(machine); + if (buffered_spriteram[attr_start + 2] & 0x20ff) color = mame_rand(machine); - for (y = 0;y <= ysize;y++) + for (y = 0; y <= ysize; y++) { int sx,sy; if (flipy) sy = ((oy + zoomy * (ysize - y) + 16) & 0x1ff) - 16; else sy = ((oy + zoomy * y + 16) & 0x1ff) - 16; - for (x = 0;x <= xsize;x++) + for (x = 0; x <= xsize; x++) { int code; if (flipx) sx = ((ox + zoomx * (xsize - x) + 16) & 0x1ff) - 16; else sx = ((ox + zoomx * x + 16) & 0x1ff) - 16; - code = buffered_spriteram16_2[map_start & 0x7fff]; + code = buffered_spriteram_2[map_start & 0x7fff]; map_start++; - if (flipscreen) + if (state->flipscreen) drawgfxzoom_transpen(bitmap,cliprect,machine->gfx[2], code, color, @@ -168,44 +171,47 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectan } -static void draw_bg(bitmap_t *bitmap,const rectangle *cliprect) +static void draw_bg( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect ) { - tilemap_draw(bitmap,cliprect,tilemap2,0,0); + crshrace_state *state = (crshrace_state *)machine->driver_data; + tilemap_draw(bitmap, cliprect, state->tilemap2, 0, 0); } static void draw_fg(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { - const device_config *k053936 = devtag_get_device(machine, "k053936"); - k053936_zoom_draw(k053936, bitmap,cliprect,tilemap1,0,0,1); + crshrace_state *state = (crshrace_state *)machine->driver_data; + k053936_zoom_draw(state->k053936, bitmap, cliprect, state->tilemap1, 0, 0, 1); } VIDEO_UPDATE( crshrace ) { - if (gfxctrl & 0x04) /* display disable? */ + crshrace_state *state = (crshrace_state *)screen->machine->driver_data; + + if (state->gfxctrl & 0x04) /* display disable? */ { - bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine)); + bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine)); return 0; } - bitmap_fill(bitmap,cliprect,0x1ff); + bitmap_fill(bitmap, cliprect, 0x1ff); - switch (gfxctrl & 0xfb) + switch (state->gfxctrl & 0xfb) { case 0x00: /* high score screen */ - draw_sprites(screen->machine,bitmap,cliprect); - draw_bg(bitmap,cliprect); - draw_fg(screen->machine,bitmap,cliprect); + draw_sprites(screen->machine, bitmap, cliprect); + draw_bg(screen->machine, bitmap, cliprect); + draw_fg(screen->machine, bitmap, cliprect); break; case 0x01: case 0x02: - draw_bg(bitmap,cliprect); - draw_fg(screen->machine,bitmap,cliprect); - draw_sprites(screen->machine,bitmap,cliprect); + draw_bg(screen->machine, bitmap, cliprect); + draw_fg(screen->machine, bitmap, cliprect); + draw_sprites(screen->machine, bitmap, cliprect); break; default: -popmessage("gfxctrl = %02x",gfxctrl); + popmessage("gfxctrl = %02x", state->gfxctrl); break; } return 0; @@ -215,6 +221,6 @@ VIDEO_EOF( crshrace ) { const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); - buffer_spriteram16_w(space,0,0,0xffff); - buffer_spriteram16_2_w(space,0,0,0xffff); + buffer_spriteram16_w(space, 0, 0, 0xffff); + buffer_spriteram16_2_w(space, 0, 0, 0xffff); } diff --git a/src/mame/video/konicdev.c b/src/mame/video/konicdev.c index 521e86c2622..a3fae89acdb 100644 --- a/src/mame/video/konicdev.c +++ b/src/mame/video/konicdev.c @@ -1707,7 +1707,7 @@ INLINE void k007342_get_tile_info( const device_config *device, tile_data *tilei tileinfo->category = (color & 0x80) >> 7; - k007342->callback(layer, k007342->regs[1], &code, &color, &flags); + k007342->callback(device->machine, layer, k007342->regs[1], &code, &color, &flags); SET_TILE_INFO_DEVICE( k007342->gfxnum, @@ -1878,7 +1878,7 @@ void k007420_sprites_draw( const device_config *device, bitmap_t *bitmap, const flipx = k007420->ram[offs + 4] & 0x04; flipy = k007420->ram[offs + 4] & 0x08; - k007420->callback(&code,&color); + k007420->callback(device->machine, &code, &color); bank = code & bankmask; code &= codemask; @@ -2026,9 +2026,9 @@ static DEVICE_START( k007420 ) k007420->callback = intf->callback; k007420->banklimit = intf->banklimit; - k007420->ram = auto_alloc_array_clear(device->machine, UINT8, 0x200); + k007420->ram = auto_alloc_array(device->machine, UINT8, 0x200); - state_save_register_device_item_pointer(device, 0, k007420->ram, 0x0200); + state_save_register_device_item_pointer(device, 0, k007420->ram, 0x200); state_save_register_device_item(device, 0, k007420->flipscreen); // current one uses 7342 one state_save_register_device_item_array(device, 0, k007420->regs); // current one uses 7342 ones } @@ -2038,6 +2038,8 @@ static DEVICE_RESET( k007420 ) k007420_state *k007420 = k007420_get_safe_token(device); int i; + memset(k007420->ram, 0, 0x200); + k007420->flipscreen = 0; for (i = 0; i < 8; i++) k007420->regs[i] = 0; @@ -2142,7 +2144,7 @@ READ8_DEVICE_HANDLER( k052109_r ) if (k052109->has_extra_video_ram) code |= color << 8; /* kludge for X-Men */ else - k052109->callback(0, bank, &code, &color, &flags, &priority); + k052109->callback(device->machine, 0, bank, &code, &color, &flags, &priority); addr = (code << 5) + (offset & 0x1f); addr &= memory_region_length(device->machine, k052109->memory_region) - 1; @@ -2305,13 +2307,13 @@ WRITE16_DEVICE_HANDLER( k052109_lsb_w ) k052109_w(device, offset, data & 0xff); } -void k052109_set_RMRD_line( const device_config *device, int state ) +void k052109_set_rmrd_line( const device_config *device, int state ) { k052109_state *k052109 = k052109_get_safe_token(device); k052109->RMRD_line = state; } -int k052109_get_RMRD_line(const device_config *device ) +int k052109_get_rmrd_line(const device_config *device ) { k052109_state *k052109 = k052109_get_safe_token(device); return k052109->RMRD_line; @@ -2476,7 +2478,7 @@ void k052109_tilemap_draw( const device_config *device, bitmap_t *bitmap, const tilemap_draw(bitmap, cliprect, k052109->tilemap[tmap_num], flags, priority); } -int k052109_is_IRQ_enabled( const device_config *device ) +int k052109_is_irq_enabled( const device_config *device ) { k052109_state *k052109 = k052109_get_safe_token(device); @@ -2526,7 +2528,7 @@ INLINE void k052109_get_tile_info( const device_config *device, tile_data *tilei flipy = color & 0x02; - k052109->callback(layer, bank, &code, &color, &flags, &priority); + k052109->callback(device->machine, layer, bank, &code, &color, &flags, &priority); /* if the callback set flip X but it is not enabled, turn it off */ if (!(k052109->tileflip_enable & 1)) @@ -2744,7 +2746,7 @@ static int k051960_fetchromdata( const device_config *device, int byte ) color = ((k051960->spriterombank[1] & 0xfc) >> 2) + ((k051960->spriterombank[2] & 0x03) << 6); pri = 0; shadow = color & 0x80; - k051960->callback(&code, &color, &pri, &shadow); + k051960->callback(device->machine, &code, &color, &pri, &shadow); addr = (code << 7) | (off1 << 2) | byte; addr &= memory_region_length(device->machine, k051960->memory_region) - 1; @@ -2966,7 +2968,7 @@ void k051960_sprites_draw( const device_config *device, bitmap_t *bitmap, const color = k051960->ram[offs + 3] & 0xff; pri = 0; shadow = color & 0x80; - k051960->callback(&code, &color, &pri, &shadow); + k051960->callback(device->machine, &code, &color, &pri, &shadow); if (max_priority != -1) if (pri < min_priority || pri > max_priority) @@ -3541,7 +3543,7 @@ void k053245_sprites_draw( const device_config *device, bitmap_t *bitmap, const color = k053245->buffer[offs + 6] & 0x00ff; pri = 0; - k053245->callback(&code, &color, &pri); + k053245->callback(device->machine, &code, &color, &pri); size = (k053245->buffer[offs] & 0x0f00) >> 8; @@ -3795,7 +3797,7 @@ void k053245_sprites_draw_lethal( const device_config *device, bitmap_t *bitmap, color = k053245->buffer[offs + 6] & 0x00ff; pri = 0; - k053245->callback(&code, &color, &pri); + k053245->callback(device->machine, &code, &color, &pri); size = (k053245->buffer[offs] & 0x0f00) >> 8; @@ -3990,22 +3992,6 @@ static DEVICE_START( k05324x ) 128*8 }; - /* deinterleave the graphics, if needed */ - switch (intf->deinterleave) - { - case KONAMI_ROM_DEINTERLEAVE_NONE: - break; - case KONAMI_ROM_DEINTERLEAVE_2: - konamid_rom_deinterleave_2(machine, intf->gfx_memory_region); - break; - case KONAMI_ROM_DEINTERLEAVE_2_HALF: - konamid_rom_deinterleave_2_half(machine, intf->gfx_memory_region); - break; - case KONAMI_ROM_DEINTERLEAVE_4: - konamid_rom_deinterleave_4(machine, intf->gfx_memory_region); - break; - } - /* find first empty slot to decode gfx */ for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) @@ -4013,7 +3999,6 @@ static DEVICE_START( k05324x ) break; assert(gfx_index != MAX_GFX_ELEMENTS); - /* decode the graphics */ switch (intf->plane_order) { @@ -4029,6 +4014,22 @@ static DEVICE_START( k05324x ) if (VERBOSE && !(machine->config->video_attributes & VIDEO_HAS_SHADOWS)) popmessage("driver should use VIDEO_HAS_SHADOWS"); + /* deinterleave the graphics, if needed */ + switch (intf->deinterleave) + { + case KONAMI_ROM_DEINTERLEAVE_NONE: + break; + case KONAMI_ROM_DEINTERLEAVE_2: + konamid_rom_deinterleave_2(machine, intf->gfx_memory_region); + break; + case KONAMI_ROM_DEINTERLEAVE_2_HALF: + konamid_rom_deinterleave_2_half(machine, intf->gfx_memory_region); + break; + case KONAMI_ROM_DEINTERLEAVE_4: + konamid_rom_deinterleave_4(machine, intf->gfx_memory_region); + break; + } + k05324x->ramsize = 0x800; k05324x->memory_region = intf->gfx_memory_region; @@ -4036,9 +4037,9 @@ static DEVICE_START( k05324x ) k05324x->dx = intf->dx; k05324x->dy = intf->dy; k05324x->callback = intf->callback; - k05324x->ram = auto_alloc_array_clear(machine, UINT16, k05324x->ramsize / 2); + k05324x->ram = auto_alloc_array(machine, UINT16, k05324x->ramsize / 2); - k05324x->buffer = auto_alloc_array_clear(machine, UINT16, k05324x->ramsize / 2); + k05324x->buffer = auto_alloc_array(machine, UINT16, k05324x->ramsize / 2); state_save_register_device_item_pointer(device, 0, k05324x->ram, k05324x->ramsize / 2); state_save_register_device_item_pointer(device, 0, k05324x->buffer, k05324x->ramsize / 2); @@ -4052,6 +4053,9 @@ static DEVICE_RESET( k05324x ) k05324x_state *k05324x = k05324x_get_safe_token(device); int i; + memset(k05324x->ram, 0, k05324x->ramsize / 2); + memset(k05324x->buffer, 0, k05324x->ramsize / 2); + k05324x->z_rejection = -1; k05324x->rombank = 0; @@ -4556,7 +4560,7 @@ void k053247_sprites_draw( const device_config *device, bitmap_t *bitmap, const shadow = color = k053246->ram[offs + 6]; primask = 0; - k053246->callback(&code, &color, &primask); + k053246->callback(device->machine, &code, &color, &primask); temp = k053246->ram[offs]; @@ -4833,24 +4837,6 @@ static DEVICE_START( k053247 ) k053247->screen = devtag_get_device(device->machine, intf->screen); - - /* deinterleave the graphics, if needed */ - switch (intf->deinterleave) - { - case KONAMI_ROM_DEINTERLEAVE_NONE: - break; - case KONAMI_ROM_DEINTERLEAVE_2: - konamid_rom_deinterleave_2(machine, intf->gfx_memory_region); - break; - case KONAMI_ROM_DEINTERLEAVE_2_HALF: - konamid_rom_deinterleave_2_half(machine, intf->gfx_memory_region); - break; - case KONAMI_ROM_DEINTERLEAVE_4: - konamid_rom_deinterleave_4(machine, intf->gfx_memory_region); - break; - } - - /* find first empty slot to decode gfx */ for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) if (machine->gfx[gfx_index] == 0) @@ -4884,6 +4870,22 @@ static DEVICE_START( k053247 ) } } + /* deinterleave the graphics, if needed */ + switch (intf->deinterleave) + { + case KONAMI_ROM_DEINTERLEAVE_NONE: + break; + case KONAMI_ROM_DEINTERLEAVE_2: + konamid_rom_deinterleave_2(machine, intf->gfx_memory_region); + break; + case KONAMI_ROM_DEINTERLEAVE_2_HALF: + konamid_rom_deinterleave_2_half(machine, intf->gfx_memory_region); + break; + case KONAMI_ROM_DEINTERLEAVE_4: + konamid_rom_deinterleave_4(machine, intf->gfx_memory_region); + break; + } + k053247->dx = intf->dx; k053247->dy = intf->dy; k053247->memory_region = intf->gfx_memory_region; @@ -5190,7 +5192,7 @@ INLINE void k051316_get_tile_info( const device_config *device, tile_data *tilei int color = k051316->ram[tile_index + 0x400]; int flags = 0; - k051316->callback(&code, &color, &flags); + k051316->callback(device->machine, &code, &color, &flags); SET_TILE_INFO_DEVICE( k051316->gfxnum, @@ -6254,7 +6256,7 @@ INLINE void k056832_get_tile_info( const device_config *device, tile_data *tilei color = (attr & smptr->palm1) | (attr >> smptr->pals2 & smptr->palm2); flags = TILE_FLIPYX(flip); - k056832->callback(layer, &code, &color, &flags); + k056832->callback(device->machine, layer, &code, &color, &flags); SET_TILE_INFO_DEVICE( k056832->gfxnum, @@ -7707,6 +7709,8 @@ void k056832_postload( const device_config *device ) DEVICE INTERFACE *****************************************************************************/ +/* TODO: understand which elements MUST be init here (to keep correct layer + associations) and which ones can can be init at RESET, if any */ static DEVICE_START( k056832 ) { k056832_state *k056832 = k056832_get_safe_token(device); @@ -7779,28 +7783,12 @@ static DEVICE_START( k056832 ) }; - /* deinterleave the graphics, if needed */ - switch (intf->deinterleave) - { - case KONAMI_ROM_DEINTERLEAVE_NONE: - break; - case KONAMI_ROM_DEINTERLEAVE_2: - konamid_rom_deinterleave_2(machine, intf->gfx_memory_region); - break; - case KONAMI_ROM_DEINTERLEAVE_2_HALF: - konamid_rom_deinterleave_2_half(machine, intf->gfx_memory_region); - break; - case KONAMI_ROM_DEINTERLEAVE_4: - konamid_rom_deinterleave_4(machine, intf->gfx_memory_region); - break; - } - - /* find first empty slot to decode gfx */ for (gfx_index = 0; gfx_index < MAX_GFX_ELEMENTS; gfx_index++) { if (machine->gfx[gfx_index] == 0) break; } + assert(gfx_index != MAX_GFX_ELEMENTS); @@ -7847,6 +7835,22 @@ static DEVICE_START( k056832 ) machine->gfx[gfx_index]->color_granularity = 16; /* override */ + /* deinterleave the graphics, if needed */ + switch (intf->deinterleave) + { + case KONAMI_ROM_DEINTERLEAVE_NONE: + break; + case KONAMI_ROM_DEINTERLEAVE_2: + konamid_rom_deinterleave_2(machine, intf->gfx_memory_region); + break; + case KONAMI_ROM_DEINTERLEAVE_2_HALF: + konamid_rom_deinterleave_2_half(machine, intf->gfx_memory_region); + break; + case KONAMI_ROM_DEINTERLEAVE_4: + konamid_rom_deinterleave_4(machine, intf->gfx_memory_region); + break; + } + k056832->memory_region = intf->gfx_memory_region; k056832->gfxnum = gfx_index; k056832->callback = intf->callback; @@ -7855,9 +7859,40 @@ static DEVICE_START( k056832 ) k056832->num_gfx_banks = memory_region_length(machine, intf->gfx_memory_region) / 0x2000; k056832->djmain_hack = intf->djmain_hack; + k056832->cur_gfx_banks = 0; + k056832->use_ext_linescroll = 0; + k056832->uses_tile_banks = 0; + + for (i = 0; i < 4; i++) + { + k056832->layer_offs[i][0] = 0; + k056832->layer_offs[i][1] = 0; + k056832->lsram_page[i][0] = i; + k056832->lsram_page[i][1] = i << 11; + k056832->x[i] = 0; + k056832->y[i] = 0; + k056832->w[i] = 0; + k056832->h[i] = 0; + k056832->dx[i] = 0; + k056832->dy[i] = 0; + k056832->layer_tile_mode[i] = 1; + } + + k056832->default_layer_association = 1; + k056832->active_layer = 0; + k056832->linemap_enabled = 0; + k056832->k055555 = devtag_get_device(device->machine, intf->k055555); - k056832->videoram = auto_alloc_array(machine, UINT16, 0x2000 * (K056832_PAGE_COUNT+1) / 2); + memset(k056832->line_dirty, 0, sizeof(UINT32) * K056832_PAGE_COUNT * 8); + + for (i = 0; i < K056832_PAGE_COUNT; i++) + { + k056832->all_lines_dirty[i] = 0; + k056832->page_tile_mode[i] = 1; + } + + k056832->videoram = auto_alloc_array(machine, UINT16, 0x2000 * (K056832_PAGE_COUNT + 1) / 2); k056832->tilemap[0x0] = tilemap_create_device(device, k056832_get_tile_info0, tilemap_scan_rows, 8, 8, 64, 32); k056832->tilemap[0x1] = tilemap_create_device(device, k056832_get_tile_info1, tilemap_scan_rows, 8, 8, 64, 32); @@ -7885,6 +7920,10 @@ static DEVICE_START( k056832 ) tilemap_set_transparent_pen(tmap, 0); } + memset(k056832->videoram, 0x00, 0x20000); + memset(k056832->regs, 0x00, sizeof(k056832->regs) ); + memset(k056832->regsb, 0x00, sizeof(k056832->regsb) ); + k056832_update_page_layout(device); k056832_change_rambank(device); @@ -7916,48 +7955,6 @@ static DEVICE_START( k056832 ) // state_save_register_postload(device->machine, k056832_postload, NULL); } -static DEVICE_RESET( k056832 ) -{ - k056832_state *k056832 = k056832_get_safe_token(device); - int i; - - k056832->cur_gfx_banks = 0; - k056832->use_ext_linescroll = 0; - k056832->uses_tile_banks = 0; - - for (i = 0; i < 4; i++) - { - k056832->layer_offs[i][0] = 0; - k056832->layer_offs[i][1] = 0; - k056832->lsram_page[i][0] = i; - k056832->lsram_page[i][1] = i << 11; - k056832->x[i] = 0; - k056832->y[i] = 0; - k056832->w[i] = 0; - k056832->h[i] = 0; - k056832->dx[i] = 0; - k056832->dy[i] = 0; - k056832->layer_tile_mode[i] = 1; - } - - k056832->default_layer_association = 1; - k056832->active_layer = 0; - k056832->linemap_enabled = 0; - - memset(k056832->line_dirty, 0, sizeof(UINT32) * K056832_PAGE_COUNT * 8); - - for (i = 0; i < K056832_PAGE_COUNT; i++) - { - k056832->all_lines_dirty[i] = 0; - k056832->page_tile_mode[i] = 1; - } - - memset(k056832->videoram, 0x00, 0x20000); - memset(k056832->regs, 0x00, sizeof(k056832->regs) ); - memset(k056832->regsb, 0x00, sizeof(k056832->regsb) ); - -} - /***************************************************************************/ /* */ /* 055555 */ @@ -9387,8 +9384,8 @@ DEVICE_GET_INFO( k056832 ) /* --- the following bits of info are returned as pointers to data or functions --- */ case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(k056832); break; - case DEVINFO_FCT_STOP: /* Nothing */ break; - case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(k056832); break; + case DEVINFO_FCT_STOP: /* Nothing */ break; + case DEVINFO_FCT_RESET: /* Nothing */ break; /* --- the following bits of info are returned as NULL-terminated strings --- */ case DEVINFO_STR_NAME: strcpy(info->s, "Konami 056832"); break; diff --git a/src/mame/video/konicdev.h b/src/mame/video/konicdev.h index e0599857e9d..55019992d12 100644 --- a/src/mame/video/konicdev.h +++ b/src/mame/video/konicdev.h @@ -13,13 +13,13 @@ TYPE DEFINITIONS ***************************************************************************/ -typedef void (*k007342_callback)(int tmap, int bank, int *code, int *color, int *flags); -typedef void (*k007420_callback)(int *code, int *color); -typedef void (*k052109_callback)(int layer, int bank, int *code, int *color, int *flags, int *priority); -typedef void (*k051960_callback)(int *code, int *color, int *priority, int *shadow); -typedef void (*k05324x_callback)(int *code, int *color, int *priority); -typedef void (*k051316_callback)(int *code, int *color, int *flags); -typedef void (*k056832_callback)(int layer, int *code, int *color, int *flags); +typedef void (*k007342_callback)(running_machine *machine, int tmap, int bank, int *code, int *color, int *flags); +typedef void (*k007420_callback)(running_machine *machine, int *code, int *color); +typedef void (*k052109_callback)(running_machine *machine, int layer, int bank, int *code, int *color, int *flags, int *priority); +typedef void (*k051960_callback)(running_machine *machine, int *code, int *color, int *priority, int *shadow); +typedef void (*k05324x_callback)(running_machine *machine, int *code, int *color, int *priority); +typedef void (*k051316_callback)(running_machine *machine, int *code, int *color, int *flags); +typedef void (*k056832_callback)(running_machine *machine, int layer, int *code, int *color, int *flags); typedef struct _k007342_interface k007342_interface; @@ -349,10 +349,10 @@ WRITE16_DEVICE_HANDLER( k052109_word_w ); READ16_DEVICE_HANDLER( k052109_lsb_r ); WRITE16_DEVICE_HANDLER( k052109_lsb_w ); -void k052109_set_RMRD_line(const device_config *device, int state); -int k052109_get_RMRD_line(const device_config *device); +void k052109_set_rmrd_line(const device_config *device, int state); +int k052109_get_rmrd_line(const device_config *device); void k052109_tilemap_update(const device_config *device); -int k052109_is_IRQ_enabled(const device_config *device); +int k052109_is_irq_enabled(const device_config *device); void k052109_set_layer_offsets(const device_config *device, int layer, int dx, int dy); void k052109_tilemap_draw(const device_config *device, bitmap_t *bitmap, const rectangle *cliprect, int tmap_num, UINT32 flags, UINT8 priority); diff --git a/src/mame/video/moo.c b/src/mame/video/moo.c index 4b9a8e44fe0..3d1cfa94845 100644 --- a/src/mame/video/moo.c +++ b/src/mame/video/moo.c @@ -9,7 +9,7 @@ ***************************************************************************/ #include "driver.h" -#include "video/konamiic.h" +#include "video/konicdev.h" static int sprite_colorbase; static int layer_colorbase[4], layerpri[3]; @@ -22,7 +22,7 @@ void moo_set_alpha(int on) } #endif -static void moo_sprite_callback(int *code, int *color, int *priority_mask) +void moo_sprite_callback(running_machine *machine, int *code, int *color, int *priority_mask) { int pri = (*color & 0x03e0) >> 4; @@ -34,52 +34,36 @@ static void moo_sprite_callback(int *code, int *color, int *priority_mask) *color = sprite_colorbase | (*color & 0x001f); } -static void moo_tile_callback(int layer, int *code, int *color, int *flags) +void moo_tile_callback(running_machine *machine, int layer, int *code, int *color, int *flags) { *color = layer_colorbase[layer] | (*color>>2 & 0x0f); } VIDEO_START(moo) { - int offsx, offsy; - + const device_config *k056832 = devtag_get_device(machine, "k056832"); assert(video_screen_get_format(machine->primary_screen) == BITMAP_FORMAT_RGB32); alpha_enabled = 0; - K053251_vh_start(machine); - K054338_vh_start(machine); - - K056832_vh_start(machine, "gfx1", K056832_BPP_4, 1, NULL, moo_tile_callback, 0); - if (!strcmp(machine->gamedrv->name, "bucky") || !strcmp(machine->gamedrv->name, "buckyua") || !strcmp(machine->gamedrv->name, "buckyaa")) { // Bucky doesn't chain tilemaps - K056832_set_LayerAssociation(0); + k056832_set_layer_association(k056832, 0); - K056832_set_LayerOffset(0, -2, 0); - K056832_set_LayerOffset(1, 2, 0); - K056832_set_LayerOffset(2, 4, 0); - K056832_set_LayerOffset(3, 6, 0); - - offsx = -48; - offsy = 23; + k056832_set_layer_offs(k056832, 0, -2, 0); + k056832_set_layer_offs(k056832, 1, 2, 0); + k056832_set_layer_offs(k056832, 2, 4, 0); + k056832_set_layer_offs(k056832, 3, 6, 0); } else { // other than the intro showing one blank line alignment is good through the game - K056832_set_LayerOffset(0, -2+1, 0); - K056832_set_LayerOffset(1, 2+1, 0); - K056832_set_LayerOffset(2, 4+1, 0); - K056832_set_LayerOffset(3, 6+1, 0); - - offsx = -48+1; - offsy = 23; + k056832_set_layer_offs(k056832, 0, -2+1, 0); + k056832_set_layer_offs(k056832, 1, 2+1, 0); + k056832_set_layer_offs(k056832, 2, 4+1, 0); + k056832_set_layer_offs(k056832, 3, 6+1, 0); } - - K053247_vh_start(machine, "gfx2", offsx, offsy, NORMAL_PLANE_ORDER, moo_sprite_callback); - - K054338_invert_alpha(0); } /* useful function to sort the three tile layers by priority order */ @@ -100,70 +84,75 @@ static void sortlayers(int *layer,int *pri) VIDEO_UPDATE(moo) { + const device_config *k053246 = devtag_get_device(screen->machine, "k053246"); + const device_config *k056832 = devtag_get_device(screen->machine, "k056832"); + const device_config *k053251 = devtag_get_device(screen->machine, "k053251"); + const device_config *k054338 = devtag_get_device(screen->machine, "k054338"); static const int K053251_CI[4] = { K053251_CI1, K053251_CI2, K053251_CI3, K053251_CI4 }; int layers[3]; int bg_colorbase, new_colorbase, plane, dirty, alpha; - bg_colorbase = K053251_get_palette_index(K053251_CI1); - sprite_colorbase = K053251_get_palette_index(K053251_CI0); + bg_colorbase = k053251_get_palette_index(k053251, K053251_CI1); + sprite_colorbase = k053251_get_palette_index(k053251, K053251_CI0); layer_colorbase[0] = 0x70; - if (K056832_get_LayerAssociation()) + if (k056832_get_layer_association(k056832)) { - for (plane=1; plane<4; plane++) + for (plane = 1; plane < 4; plane++) { - new_colorbase = K053251_get_palette_index(K053251_CI[plane]); + new_colorbase = k053251_get_palette_index(k053251, K053251_CI[plane]); if (layer_colorbase[plane] != new_colorbase) { layer_colorbase[plane] = new_colorbase; - K056832_mark_plane_dirty(plane); + k056832_mark_plane_dirty(k056832, plane); } } } else { - for (dirty=0, plane=1; plane<4; plane++) + for (dirty = 0, plane = 1; plane < 4; plane++) { - new_colorbase = K053251_get_palette_index(K053251_CI[plane]); + new_colorbase = k053251_get_palette_index(k053251, K053251_CI[plane]); if (layer_colorbase[plane] != new_colorbase) { layer_colorbase[plane] = new_colorbase; dirty = 1; } } - if (dirty) K056832_MarkAllTilemapsDirty(); + if (dirty) + k056832_mark_all_tmaps_dirty(k056832); } layers[0] = 1; - layerpri[0] = K053251_get_priority(K053251_CI2); + layerpri[0] = k053251_get_priority(k053251, K053251_CI2); layers[1] = 2; - layerpri[1] = K053251_get_priority(K053251_CI3); + layerpri[1] = k053251_get_priority(k053251, K053251_CI3); layers[2] = 3; - layerpri[2] = K053251_get_priority(K053251_CI4); + layerpri[2] = k053251_get_priority(k053251, K053251_CI4); sortlayers(layers, layerpri); - K054338_update_all_shadows(screen->machine, 0); - K054338_fill_backcolor(screen->machine, bitmap, 0); + k054338_update_all_shadows(k054338, 0); + k054338_fill_backcolor(k054338, bitmap, 0); bitmap_fill(screen->machine->priority_bitmap,cliprect,0); - if (layerpri[0] < K053251_get_priority(K053251_CI1)) /* bucky hides back layer behind background */ - K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[0], 0, 1); + if (layerpri[0] < k053251_get_priority(k053251, K053251_CI1)) /* bucky hides back layer behind background */ + k056832_tilemap_draw(k056832, bitmap, cliprect, layers[0], 0, 1); - K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[1], 0, 2); + k056832_tilemap_draw(k056832, bitmap, cliprect, layers[1], 0, 2); // Enabling alpha improves fog and fading in Moo but causes other things to disappear. // There is probably a control bit somewhere to turn off alpha blending. - alpha_enabled = K054338_read_register(K338_REG_CONTROL) & K338_CTL_MIXPRI; // DUMMY + alpha_enabled = k054338_register_r(k054338, K338_REG_CONTROL) & K338_CTL_MIXPRI; // DUMMY - alpha = (alpha_enabled) ? K054338_set_alpha_level(1) : 255; + alpha = (alpha_enabled) ? k054338_set_alpha_level(k054338, 1) : 255; if (alpha > 0) - K056832_tilemap_draw(screen->machine, bitmap, cliprect, layers[2], TILEMAP_DRAW_ALPHA(alpha), 4); + k056832_tilemap_draw(k056832, bitmap, cliprect, layers[2], TILEMAP_DRAW_ALPHA(alpha), 4); - K053247_sprites_draw(screen->machine, bitmap,cliprect); + k053247_sprites_draw(k053246, bitmap, cliprect); - K056832_tilemap_draw(screen->machine, bitmap, cliprect, 0, 0, 0); + k056832_tilemap_draw(k056832, bitmap, cliprect, 0, 0, 0); return 0; } diff --git a/src/mame/video/rockrage.c b/src/mame/video/rockrage.c index 6d612830016..7f95d4f0df0 100644 --- a/src/mame/video/rockrage.c +++ b/src/mame/video/rockrage.c @@ -1,9 +1,6 @@ #include "driver.h" #include "video/konicdev.h" - -static int layer_colorbase[2]; -static int rockrage_vreg; - +#include "includes/rockrage.h" PALETTE_INIT( rockrage ) { @@ -30,13 +27,14 @@ PALETTE_INIT( rockrage ) } -static void set_pens(running_machine *machine) +static void set_pens( running_machine *machine ) { + rockrage_state *state = (rockrage_state *)machine->driver_data; int i; for (i = 0x00; i < 0x80; i += 2) { - UINT16 data = machine->generic.paletteram.u8[i] | (machine->generic.paletteram.u8[i | 1] << 8); + UINT16 data = state->paletteram[i] | (state->paletteram[i | 1] << 8); rgb_t color = MAKE_RGB(pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10)); @@ -51,13 +49,15 @@ static void set_pens(running_machine *machine) ***************************************************************************/ -void rockrage_tile_callback(int layer, int bank, int *code, int *color, int *flags) +void rockrage_tile_callback( running_machine *machine, int layer, int bank, int *code, int *color, int *flags ) { + rockrage_state *state = (rockrage_state *)machine->driver_data; + if (layer == 1) *code |= ((*color & 0x40) << 2) | ((bank & 0x01) << 9); else - *code |= ((*color & 0x40) << 2) | ((bank & 0x03) << 10) | ((rockrage_vreg & 0x04) << 7) | ((rockrage_vreg & 0x08) << 9); - *color = layer_colorbase[layer] + (*color & 0x0f); + *code |= ((*color & 0x40) << 2) | ((bank & 0x03) << 10) | ((state->vreg & 0x04) << 7) | ((state->vreg & 0x08) << 9); + *color = state->layer_colorbase[layer] + (*color & 0x0f); } /*************************************************************************** @@ -66,39 +66,30 @@ void rockrage_tile_callback(int layer, int bank, int *code, int *color, int *fla ***************************************************************************/ -void rockrage_sprite_callback(int *code,int *color) +void rockrage_sprite_callback( running_machine *machine, int *code, int *color ) { - *code |= ((*color & 0x40) << 2) | ((*color & 0x80) << 1)*((rockrage_vreg & 0x03) << 1); + rockrage_state *state = (rockrage_state *)machine->driver_data; + + *code |= ((*color & 0x40) << 2) | ((*color & 0x80) << 1) * ((state->vreg & 0x03) << 1); *code = (*code << 2) | ((*color & 0x30) >> 4); *color = 0; } -WRITE8_HANDLER( rockrage_vreg_w ){ +WRITE8_HANDLER( rockrage_vreg_w ) +{ /* bits 4-7: unused */ /* bit 3: bit 4 of bank # (layer 0) */ /* bit 2: bit 1 of bank # (layer 0) */ /* bits 0-1: sprite bank select */ + rockrage_state *state = (rockrage_state *)space->machine->driver_data; - if ((data & 0x0c) != (rockrage_vreg & 0x0c)) + if ((data & 0x0c) != (state->vreg & 0x0c)) tilemap_mark_all_tiles_dirty_all(space->machine); - rockrage_vreg = data; + state->vreg = data; } -/*************************************************************************** - - Start the video hardware emulation. - -***************************************************************************/ - -VIDEO_START( rockrage ) -{ - layer_colorbase[0] = 0x00; - layer_colorbase[1] = 0x10; -} - - /*************************************************************************** Screen Refresh @@ -107,16 +98,16 @@ VIDEO_START( rockrage ) VIDEO_UPDATE( rockrage ) { - const device_config *k007342 = devtag_get_device(screen->machine, "k007342"); - const device_config *k007420 = devtag_get_device(screen->machine, "k007420"); + rockrage_state *state = (rockrage_state *)screen->machine->driver_data; + set_pens(screen->machine); - k007342_tilemap_update(k007342); + k007342_tilemap_update(state->k007342); - k007342_tilemap_draw(k007342, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0); - k007420_sprites_draw(k007420, bitmap, cliprect, screen->machine->gfx[1]); - k007342_tilemap_draw(k007342, bitmap, cliprect, 0, 1 | TILEMAP_DRAW_OPAQUE, 0); - k007342_tilemap_draw(k007342, bitmap, cliprect, 1, 0, 0); - k007342_tilemap_draw(k007342, bitmap, cliprect, 1, 1, 0); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, TILEMAP_DRAW_OPAQUE, 0); + k007420_sprites_draw(state->k007420, bitmap, cliprect, screen->machine->gfx[1]); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 0, 1 | TILEMAP_DRAW_OPAQUE, 0); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 1, 0, 0); + k007342_tilemap_draw(state->k007342, bitmap, cliprect, 1, 1, 0); return 0; }