From 825cfee6a82673531102712104d06038d16e34b7 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Sun, 21 Dec 2008 07:53:28 +0000 Subject: [PATCH] From Mamesick: * ddragon3.diff - converted driver to be fully scanlines based using timers - hooked up interrupts - updated driver to new video screen raw parameters * shadfrce.diff - converted driver to be fully scanlines based using timers - implemented raster interrupt timer in the main routine - updated driver to new video screen raw parameters * wwfsstar.diff - converted driver to be fully scanlines based using timers - updated driver to new video screen raw parameters * wwfwfest.diff - converted driver to be fully scanlines based using timers - hooked up interrupts - updated driver to new video screen raw parameters --- src/mame/drivers/ddragon3.c | 49 +++++++---- src/mame/drivers/shadfrce.c | 166 +++++++++++++++++------------------- src/mame/drivers/wwfsstar.c | 51 ++++++----- src/mame/drivers/wwfwfest.c | 66 +++++++++----- 4 files changed, 187 insertions(+), 145 deletions(-) diff --git a/src/mame/drivers/ddragon3.c b/src/mame/drivers/ddragon3.c index 719f22cda4c..9de4adf5118 100644 --- a/src/mame/drivers/ddragon3.c +++ b/src/mame/drivers/ddragon3.c @@ -24,12 +24,14 @@ #include "driver.h" -#include "deprecat.h" #include "cpu/z80/z80.h" #include "cpu/m68000/m68000.h" #include "sound/2151intf.h" #include "sound/okim6295.h" +#define MASTER_CLOCK XTAL_24MHz +#define CPU_CLOCK MASTER_CLOCK / 2 +#define PIXEL_CLOCK MASTER_CLOCK / 4 extern UINT16 *ddragon3_bg_videoram16; extern UINT16 *ddragon3_fg_videoram16; @@ -76,15 +78,18 @@ static WRITE16_HANDLER( ddragon3_io16_w ) /* this gets written to on startup and at the end of IRQ6 ** possibly trigger IRQ on sound CPU */ + cpu_set_input_line(space->machine->cpu[0], 6, CLEAR_LINE); break; case 3: /* this gets written to on startup, ** and at the end of IRQ5 (input port read) */ + cpu_set_input_line(space->machine->cpu[0], 5, CLEAR_LINE); break; case 4: /* this gets written to at the end of IRQ6 only */ + cpu_set_input_line(space->machine->cpu[0], 6, CLEAR_LINE); break; default: @@ -303,7 +308,7 @@ static INPUT_PORTS_START( ctribe ) PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_SERVICE1 ) - PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_VBLANK ) + PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_VBLANK ) PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW1:7") PORT_DIPSETTING( 0x1000, DEF_STR( Off ) ) PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) @@ -467,12 +472,28 @@ static const ym2151_interface ym2151_config = * *************************************/ -static INTERRUPT_GEN( ddragon3_cpu_interrupt ) { /* 6:0x177e - 5:0x176a */ - if( cpu_getiloops(device) == 0 ){ - cpu_set_input_line(device, 6, HOLD_LINE); /* VBlank */ +static TIMER_DEVICE_CALLBACK( ddragon3_scanline ) +{ + int scanline = param; + + /* An interrupt is generated every 16 scanlines */ + if (scanline % 16 == 0) + { + video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 5, ASSERT_LINE); } - else { - cpu_set_input_line(device, 5, HOLD_LINE); /* Input Ports */ + + /* Vblank is raised on scanline 248 */ + if (scanline == 248) + { + video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 6, ASSERT_LINE); + } + + /* Adjust for next scanline */ + if (++scanline >= video_screen_get_height(timer->machine->primary_screen)) + { + scanline = 0; } } @@ -484,20 +505,17 @@ static INTERRUPT_GEN( ddragon3_cpu_interrupt ) { /* 6:0x177e - 5:0x176a */ static MACHINE_DRIVER_START( ddragon3 ) /* basic machine hardware */ - MDRV_CPU_ADD("main", M68000, 12000000) // Guess + MDRV_CPU_ADD("main", M68000, CPU_CLOCK) // Guess MDRV_CPU_PROGRAM_MAP(readmem, writemem) - MDRV_CPU_VBLANK_INT_HACK(ddragon3_cpu_interrupt, 2) + MDRV_TIMER_ADD_SCANLINE("scantimer", ddragon3_scanline, "main", 0, 1) MDRV_CPU_ADD("audio", Z80, 3579545) // Guess (confirmed on bootleg) MDRV_CPU_PROGRAM_MAP(readmem_sound, writemem_sound) /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) - MDRV_SCREEN_REFRESH_RATE(57) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(40*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1) + MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, 384, 0, 320, 272, 8, 248) /* HTOTAL and VTOTAL are guessed */ MDRV_GFXDECODE(ddragon3) MDRV_PALETTE_LENGTH(768) @@ -535,9 +553,6 @@ static MACHINE_DRIVER_START( ctribe ) MDRV_CPU_MODIFY("audio") MDRV_CPU_PROGRAM_MAP(ctribe_readmem_sound,ctribe_writemem_sound) - MDRV_SCREEN_MODIFY("main") - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) - MDRV_VIDEO_UPDATE(ctribe) MDRV_SOUND_MODIFY("ym2151") @@ -821,7 +836,7 @@ ROM_END *************************************/ GAME( 1990, ddragon3, 0, ddragon3, ddragon3, 0, ROT0, "Technos", "Double Dragon 3 - The Rosetta Stone (US)", GAME_SUPPORTS_SAVE ) -GAME( 1990, ddrago3j, ddragon3, ddragon3, ddragon3, 0, ROT0, "Technos", "Double Dragon 3 - The Rosetta Stone (Japan)", GAME_SUPPORTS_SAVE ) +GAME( 1990, ddrago3j, ddragon3, ddragon3, ddragon3, 0, ROT0, "Technos", "Double Dragon 3 - The Rosetta Stone (Japan)", GAME_SUPPORTS_SAVE ) GAME( 1990, ddrago3b, ddragon3, ddrago3b, ddrago3b, 0, ROT0, "bootleg", "Double Dragon 3 - The Rosetta Stone (bootleg)", GAME_SUPPORTS_SAVE ) GAME( 1990, ctribe, 0, ctribe, ctribe, 0, ROT0, "Technos", "The Combatribes (US)", GAME_SUPPORTS_SAVE ) GAME( 1990, ctribe1, ctribe, ctribe, ctribe, 0, ROT0, "Technos", "The Combatribes (US Set 1?)", GAME_SUPPORTS_SAVE ) diff --git a/src/mame/drivers/shadfrce.c b/src/mame/drivers/shadfrce.c index 5bece20316f..d0a9a36d835 100644 --- a/src/mame/drivers/shadfrce.c +++ b/src/mame/drivers/shadfrce.c @@ -80,10 +80,13 @@ lev 7 : 0x7c : 0000 11d0 - just rte #include "driver.h" #include "cpu/z80/z80.h" #include "cpu/m68000/m68000.h" -#include "deprecat.h" #include "sound/2151intf.h" #include "sound/okim6295.h" +#define MASTER_CLOCK XTAL_28MHz +#define CPU_CLOCK MASTER_CLOCK / 2 +#define PIXEL_CLOCK MASTER_CLOCK / 4 + UINT16 *shadfrce_fgvideoram, *shadfrce_bg0videoram, *shadfrce_bg1videoram, *shadfrce_spvideoram; /* in video */ @@ -100,8 +103,8 @@ WRITE16_HANDLER( shadfrce_bg1videoram_w ); int shadfrce_video_enable = 0; static int shadfrce_irqs_enable = 0; -static int shadfrce_scanline = 0; -static emu_timer *raster_irq_timer; +static int raster_scanline = 0; +static int raster_irq_enable = 0; static int vblank = 0; @@ -231,19 +234,6 @@ static WRITE16_HANDLER ( shadfrce_sound_brt_w ) } } -static TIMER_CALLBACK( raster_interrupt ) -{ - // force a screen partial update on the previous scanline - if (shadfrce_scanline != 0) - video_screen_update_partial(machine->primary_screen, shadfrce_scanline - 1); - - shadfrce_scanline = (shadfrce_scanline + 1) % 256; - - // fire another raster irq for the next scanline - cpu_set_input_line(machine->cpu[0], 1, ASSERT_LINE); - timer_adjust_oneshot(raster_irq_timer, video_screen_get_time_until_pos(machine->primary_screen, shadfrce_scanline, 0), 0); -} - static WRITE16_HANDLER( shadfrce_irq_ack_w ) { cpu_set_input_line(space->machine->cpu[0], offset ^ 3, CLEAR_LINE); @@ -253,26 +243,19 @@ static WRITE16_HANDLER( shadfrce_irq_w ) { static int prev_value = 0; - shadfrce_irqs_enable = data & 1; // maybe, it's set/unset inside every trap instruction which is executed - shadfrce_video_enable = data & 8; // probably + shadfrce_irqs_enable = data & 1; /* maybe, it's set/unset inside every trap instruction which is executed */ + shadfrce_video_enable = data & 8; /* probably */ - // check if there's a high transition to enable the raster timer + /* check if there's a high transition to enable the raster IRQ */ if((~prev_value & 4) && (data & 4)) { - if( !timer_enabled(raster_irq_timer) ) - { - timer_enable(raster_irq_timer, 1); - timer_adjust_oneshot(raster_irq_timer, video_screen_get_time_until_pos(space->machine->primary_screen, shadfrce_scanline, 0), 0); - } + raster_irq_enable = 1; } - // check if there's a low transition to disable the raster timer + /* check if there's a low transition to disable the raster IRQ */ if((prev_value & 4) && (~data & 4)) { - if( timer_enabled(raster_irq_timer) ) - { - timer_enable(raster_irq_timer, 0); - } + raster_irq_enable = 0; } prev_value = data; @@ -280,7 +263,60 @@ static WRITE16_HANDLER( shadfrce_irq_w ) static WRITE16_HANDLER( shadfrce_scanline_w ) { - shadfrce_scanline = data; // guess, 0 is always written + raster_scanline = data; /* guess, 0 is always written */ +} + +static TIMER_DEVICE_CALLBACK( shadfrce_scanline ) +{ + int scanline = param; + + /* Vblank is lowered on scanline 0 */ + if (scanline == 0) + { + vblank = 0; + } + /* Hack */ + else if (scanline == (248-1)) /* -1 is an hack needed to avoid deadlocks */ + { + vblank = 4; + } + + /* Raster interrupt - Perform raster effect on given scanline */ + if (raster_irq_enable) + { + if (scanline == raster_scanline) + { + raster_scanline = (raster_scanline + 1) % 240; + video_screen_update_partial(timer->machine->primary_screen, raster_scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 1, ASSERT_LINE); + } + } + + /* An interrupt is generated every 16 scanlines */ + if (shadfrce_irqs_enable) + { + if (scanline % 16 == 0) + { + video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 2, ASSERT_LINE); + } + } + + /* Vblank is raised on scanline 248 */ + if (shadfrce_irqs_enable) + { + if (scanline == 248) + { + video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 3, ASSERT_LINE); + } + } + + /* Adjust for next scanline */ + if (++scanline >= video_screen_get_height(timer->machine->primary_screen)) + { + scanline = 0; + } } @@ -349,10 +385,10 @@ ADDRESS_MAP_END static INPUT_PORTS_START( shadfrce ) - PORT_START("P1") /* Fake IN0 (player 1 inputs) */ + PORT_START("P1") /* Fake IN0 (player 1 inputs) */ SHADFRCE_PLAYER_INPUT( 1, IPT_START1 ) - PORT_START("P2") /* Fake IN1 (player 2 inputs) */ + PORT_START("P2") /* Fake IN1 (player 2 inputs) */ SHADFRCE_PLAYER_INPUT( 2, IPT_START2 ) PORT_START("EXTRA") /* Fake IN2 (players 1 & 2 extra inputs */ @@ -370,13 +406,13 @@ static INPUT_PORTS_START( shadfrce ) PORT_START("SYSTEM") /* Fake IN4 (system inputs) */ PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) - PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) /* only in "test mode" ? */ - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) /* only in "test mode" ? */ + PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) /* only in "test mode" ? */ + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 ) /* only in "test mode" ? */ PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START("MISC") /* Fake IN5 (misc) */ - PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) /* guess */ - PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* must be ACTIVE_LOW or 'shadfrcj' jumps to the end (code at 0x04902e) */ + PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SPECIAL ) /* guess */ + PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* must be ACTIVE_LOW or 'shadfrcj' jumps to the end (code at 0x04902e) */ PORT_BIT( 0xeb, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START("DSW1") /* Fake IN6 (DIP1) */ @@ -480,61 +516,17 @@ static const ym2151_interface ym2151_config = irq_handler }; -/* - Interrupts generation is guessed, but it requires the same hack as in wwfsstar.c -*/ -static INTERRUPT_GEN( shadfrce_interrupt ) -{ - int scanline = 255 - cpu_getiloops(device); - - /* Vblank is lowered on scanline 0 (8) */ - if (scanline == 0) - { - vblank = 0; - } - /* Hack */ - else if (scanline==(248-1)) - { - vblank = 4; - } - /* Vblank is raised on scanline 248 (256) */ - else if (scanline==248) - { - if(shadfrce_irqs_enable) - cpu_set_input_line(device, 3, ASSERT_LINE); - } - - /* An interrupt is generated every 16 scanlines */ - if (scanline%16 == 0) - { - if(shadfrce_irqs_enable) - cpu_set_input_line(device, 2, ASSERT_LINE); - } -} - -static MACHINE_RESET( shadfrce ) -{ - raster_irq_timer = timer_alloc(machine, raster_interrupt, NULL); - timer_enable(raster_irq_timer, 0); - shadfrce_scanline = 0; -} - static MACHINE_DRIVER_START( shadfrce ) - MDRV_CPU_ADD("main", M68000, XTAL_28MHz/2) /* verified on pcb */ + MDRV_CPU_ADD("main", M68000, CPU_CLOCK) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(shadfrce_map,0) - MDRV_CPU_VBLANK_INT_HACK(shadfrce_interrupt,256) + MDRV_TIMER_ADD_SCANLINE("scantimer", shadfrce_scanline, "main", 0, 1) - MDRV_CPU_ADD("audio", Z80, XTAL_3_579545MHz) /* verified on pcb */ + MDRV_CPU_ADD("audio", Z80, XTAL_3_579545MHz) /* verified on pcb */ MDRV_CPU_PROGRAM_MAP(shadfrce_sound_map,0) - MDRV_MACHINE_RESET(shadfrce) - MDRV_SCREEN_ADD("main", RASTER) - MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(64*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1) + MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, 432, 0, 320, 272, 8, 248) /* HTOTAL and VTOTAL are guessed */ MDRV_GFXDECODE(shadfrce) MDRV_PALETTE_LENGTH(0x4000) @@ -546,13 +538,13 @@ static MACHINE_DRIVER_START( shadfrce ) /* sound hardware */ MDRV_SPEAKER_STANDARD_STEREO("left", "right") - MDRV_SOUND_ADD("ym", YM2151, XTAL_3_579545MHz) /* verified on pcb */ + MDRV_SOUND_ADD("ym", YM2151, XTAL_3_579545MHz) /* verified on pcb */ MDRV_SOUND_CONFIG(ym2151_config) MDRV_SOUND_ROUTE(0, "left", 0.50) MDRV_SOUND_ROUTE(1, "right", 0.50) - MDRV_SOUND_ADD("oki", OKIM6295, XTAL_13_4952MHz/8) /* verified on pcb */ - MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb, pin7 is at 2.4v */ + MDRV_SOUND_ADD("oki", OKIM6295, XTAL_13_4952MHz/8) /* verified on pcb */ + MDRV_SOUND_CONFIG(okim6295_interface_pin7high) /* verified on pcb, pin7 is at 2.4v */ MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.50) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.50) MACHINE_DRIVER_END diff --git a/src/mame/drivers/wwfsstar.c b/src/mame/drivers/wwfsstar.c index 3a535f5f121..d09f5b4df3f 100644 --- a/src/mame/drivers/wwfsstar.c +++ b/src/mame/drivers/wwfsstar.c @@ -138,12 +138,15 @@ Notes: *******************************************************************************/ #include "driver.h" -#include "deprecat.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "sound/2151intf.h" #include "sound/okim6295.h" +#define MASTER_CLOCK XTAL_20MHz +#define CPU_CLOCK MASTER_CLOCK / 2 +#define PIXEL_CLOCK MASTER_CLOCK / 4 + /* in (video/wwfsstar.c) */ VIDEO_START( wwfsstar ); VIDEO_UPDATE( wwfsstar ); @@ -157,7 +160,7 @@ static WRITE16_HANDLER( wwfsstar_flipscreen_w ); static WRITE16_HANDLER ( wwfsstar_soundwrite ); static WRITE16_HANDLER ( wwfsstar_scrollwrite ); -static int vblank; +static int vblank = 0; /******************************************************************************* Memory Maps @@ -227,7 +230,7 @@ static WRITE16_HANDLER( wwfsstar_flipscreen_w ) static WRITE16_HANDLER( wwfsstar_irqack_w ) { - if(offset == 0) + if (offset == 0) cpu_set_input_line(space->machine->cpu[0], 6, CLEAR_LINE); else @@ -247,32 +250,39 @@ static WRITE16_HANDLER( wwfsstar_irqack_w ) A hack is required: raise the vblank bit a scanline early. */ -static INTERRUPT_GEN( wwfsstars_interrupt ) +static TIMER_DEVICE_CALLBACK( wwfsstar_scanline ) { - int scanline = 271 - cpu_getiloops(device); + int scanline = param; - /* Vblank is lowered on scanline 0 (8) */ + /* Vblank is lowered on scanline 0 */ if (scanline == 0) { vblank = 0; } /* Hack */ - else if (scanline==239) + else if (scanline == (240-1)) /* -1 is an hack needed to avoid deadlocks */ { vblank = 1; } - /* Vblank is raised on scanline 240 (248) */ - else if (scanline==240) - { - video_screen_update_partial(device->machine->primary_screen, scanline); - cpu_set_input_line(device, 6, ASSERT_LINE); - } /* An interrupt is generated every 16 scanlines */ - if (scanline%16 == 0) + if (scanline % 16 == 0) { - video_screen_update_partial(device->machine->primary_screen, scanline); - cpu_set_input_line(device, 5, ASSERT_LINE); + video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 5, ASSERT_LINE); + } + + /* Vblank is raised on scanline 240 */ + if (scanline == 240) + { + video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 6, ASSERT_LINE); + } + + /* Adjust for next scanline */ + if (++scanline >= video_screen_get_height(timer->machine->primary_screen)) + { + scanline = 0; } } @@ -432,20 +442,17 @@ static const ym2151_interface ym2151_config = static MACHINE_DRIVER_START( wwfsstar ) /* basic machine hardware */ - MDRV_CPU_ADD("main", M68000, XTAL_20MHz / 2) + MDRV_CPU_ADD("main", M68000, CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(main_map, 0) - MDRV_CPU_VBLANK_INT_HACK(wwfsstars_interrupt, 272) + MDRV_TIMER_ADD_SCANLINE("scantimer", wwfsstar_scanline, "main", 0, 1) MDRV_CPU_ADD("audio", Z80, XTAL_3_579545MHz) MDRV_CPU_PROGRAM_MAP(sound_map, 0) /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) - MDRV_SCREEN_REFRESH_RATE(57.44) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(32*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) + MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, 320, 0, 256, 272, 8, 248) /* HTOTAL and VTOTAL are guessed */ MDRV_GFXDECODE(wwfsstar) MDRV_PALETTE_LENGTH(384) diff --git a/src/mame/drivers/wwfwfest.c b/src/mame/drivers/wwfwfest.c index e9e0dd6d111..cb4f90b2020 100644 --- a/src/mame/drivers/wwfwfest.c +++ b/src/mame/drivers/wwfwfest.c @@ -38,13 +38,16 @@ *******************************************************************************/ #include "driver.h" -#include "deprecat.h" #include "cpu/m68000/m68000.h" #include "cpu/z80/z80.h" #include "wwfwfest.h" #include "sound/2151intf.h" #include "sound/okim6295.h" +#define MASTER_CLOCK XTAL_24MHz +#define CPU_CLOCK MASTER_CLOCK / 2 +#define PIXEL_CLOCK MASTER_CLOCK / 4 + /*- in this file -*/ static READ16_HANDLER( wwfwfest_paletteram16_xxxxBBBBGGGGRRRR_word_r ); static WRITE16_HANDLER( wwfwfest_paletteram16_xxxxBBBBGGGGRRRR_word_w ); @@ -52,11 +55,8 @@ static WRITE16_HANDLER( wwfwfest_1410_write ); /* priority write */ static WRITE16_HANDLER( wwfwfest_scroll_write ); /* scrolling write */ static WRITE8_HANDLER( oki_bankswitch_w ); static WRITE16_HANDLER ( wwfwfest_soundwrite ); - -static WRITE16_HANDLER( wwfwfest_flipscreen_w ) -{ - flip_screen_set(space->machine, data&1); -} +static WRITE16_HANDLER ( wwfwfest_flipscreen_w ); +static WRITE16_HANDLER ( wwfwfest_irq_ack_w ); /******************************************************************************* Memory Maps @@ -74,8 +74,7 @@ static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 16 ) AM_RANGE(0x082000, 0x082fff) AM_RAM_WRITE(wwfwfest_bg1_videoram_w) AM_BASE(&wwfwfest_bg1_videoram) /* BG1 Ram - 2 bytes per tile */ AM_RANGE(0x100000, 0x100007) AM_WRITE(wwfwfest_scroll_write) AM_RANGE(0x10000a, 0x10000b) AM_WRITE(wwfwfest_flipscreen_w) - AM_RANGE(0x140000, 0x140001) AM_WRITE(SMH_NOP) /* Irq 3 ack */ - AM_RANGE(0x140002, 0x140003) AM_WRITE(SMH_NOP) /* Irq 2 ack */ + AM_RANGE(0x140000, 0x140003) AM_WRITE(wwfwfest_irq_ack_w) AM_RANGE(0x14000c, 0x14000d) AM_WRITE(wwfwfest_soundwrite) AM_RANGE(0x140010, 0x140011) AM_WRITE(wwfwfest_1410_write) AM_RANGE(0x140020, 0x140021) AM_READ_PORT("P1") @@ -102,6 +101,20 @@ ADDRESS_MAP_END as used by the above memory map *******************************************************************************/ +static WRITE16_HANDLER( wwfwfest_irq_ack_w ) +{ + if (offset == 0) + cpu_set_input_line(space->machine->cpu[0], 3, CLEAR_LINE); + + else + cpu_set_input_line(space->machine->cpu[0], 2, CLEAR_LINE); +} + +static WRITE16_HANDLER( wwfwfest_flipscreen_w ) +{ + flip_screen_set(space->machine, data&1); +} + /*- Palette Reads/Writes -*/ static READ16_HANDLER( wwfwfest_paletteram16_xxxxBBBBGGGGRRRR_word_r ) @@ -331,11 +344,29 @@ GFXDECODE_END Interrupt Function *******************************************************************************/ -static INTERRUPT_GEN( wwfwfest_interrupt ) { - if( cpu_getiloops(device) == 0 ) - cpu_set_input_line(device, 3, HOLD_LINE); - else - cpu_set_input_line(device, 2, HOLD_LINE); +static TIMER_DEVICE_CALLBACK( wwfwfest_scanline ) +{ + int scanline = param; + + /* An interrupt is generated every 16 scanlines */ + if (scanline % 16 == 0) + { + video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 2, ASSERT_LINE); + } + + /* Vblank is raised on scanline 248 */ + if (scanline == 248) + { + video_screen_update_partial(timer->machine->primary_screen, scanline - 1); + cpu_set_input_line(timer->machine->cpu[0], 3, ASSERT_LINE); + } + + /* Adjust for next scanline */ + if (++scanline >= video_screen_get_height(timer->machine->primary_screen)) + { + scanline = 0; + } } /******************************************************************************* @@ -368,9 +399,9 @@ static VIDEO_EOF( wwfwfest ) static MACHINE_DRIVER_START( wwfwfest ) /* basic machine hardware */ - MDRV_CPU_ADD("main", M68000, XTAL_24MHz / 2) /* 24 crystal, 12 rated chip */ + MDRV_CPU_ADD("main", M68000, CPU_CLOCK) /* 24 crystal, 12 rated chip */ MDRV_CPU_PROGRAM_MAP(main_map,0) - MDRV_CPU_VBLANK_INT_HACK(wwfwfest_interrupt,2) + MDRV_TIMER_ADD_SCANLINE("scantimer", wwfwfest_scanline, "main", 0, 1) MDRV_CPU_ADD("audio", Z80, XTAL_3_579545MHz) MDRV_CPU_PROGRAM_MAP(sound_map,0) @@ -379,11 +410,8 @@ static MACHINE_DRIVER_START( wwfwfest ) MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) MDRV_SCREEN_ADD("main", RASTER) - MDRV_SCREEN_REFRESH_RATE(60) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(320, 256) - MDRV_SCREEN_VISIBLE_AREA(0, 319, 1*8, 31*8-1) + MDRV_SCREEN_RAW_PARAMS(PIXEL_CLOCK, 384, 0, 320, 272, 8, 248) /* HTOTAL and VTOTAL are guessed */ MDRV_GFXDECODE(wwfwfest) MDRV_PALETTE_LENGTH(8192)