summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2008-03-03 01:02:16 +0000
committer Aaron Giles <aaron@aarongiles.com>2008-03-03 01:02:16 +0000
commit8042e50f877e32178c78ed3ea2df9e3c9f876919 (patch)
treeb718d04c5bf1ae5aa22f02a70b5284f5dde3db29
parent713f03885fe7fe46870f75e454e82157af7b5d6a (diff)
Added video_screen_get_time_until_vblank_end() and
video_screen_get_time_until_update(). Fixed CCPU and QB3 to no longer rely on cpu_scalebyfcount(). Fixed busted timing in the CCPU core. Changed watchdog to count internally rather than using external watchdog support. Altered CCPU to accept interrupt signals from the driver. Updated clocks in the cinemat driver to be derived from the clock crystal.
-rw-r--r--src/emu/cpu/ccpu/ccpu.c83
-rw-r--r--src/emu/cpu/ccpu/ccpu.h4
-rw-r--r--src/emu/drivers/xtal.h7
-rw-r--r--src/emu/video.c28
-rw-r--r--src/emu/video.h6
-rw-r--r--src/mame/drivers/cinemat.c20
-rw-r--r--src/mame/includes/cinemat.h2
-rw-r--r--src/mame/video/cinemat.c11
8 files changed, 114 insertions, 47 deletions
diff --git a/src/emu/cpu/ccpu/ccpu.c b/src/emu/cpu/ccpu/ccpu.c
index 484361e15bc..608f36c34d5 100644
--- a/src/emu/cpu/ccpu/ccpu.c
+++ b/src/emu/cpu/ccpu/ccpu.c
@@ -19,24 +19,27 @@
typedef struct
{
- UINT16 PC;
- UINT16 A;
- UINT16 B;
- UINT8 I;
- UINT16 J;
- UINT8 P;
- UINT16 X;
- UINT16 Y;
- UINT16 T;
- UINT16 *acc;
-
- UINT16 a0flag, ncflag, cmpacc, cmpval;
- UINT16 miflag, nextmiflag, nextnextmiflag;
- UINT16 drflag;
-
- UINT8 (*external_input)(void);
- void (*vector_callback)(INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift);
- UINT8 scrnum;
+ UINT16 PC;
+ UINT16 A;
+ UINT16 B;
+ UINT8 I;
+ UINT16 J;
+ UINT8 P;
+ UINT16 X;
+ UINT16 Y;
+ UINT16 T;
+ UINT16 * acc;
+
+ UINT16 a0flag, ncflag, cmpacc, cmpval;
+ UINT16 miflag, nextmiflag, nextnextmiflag;
+ UINT16 drflag;
+
+ UINT8 (*external_input)(void);
+ void (*vector_callback)(INT16 sx, INT16 sy, INT16 ex, INT16 ey, UINT8 shift);
+ UINT8 scrnum;
+
+ UINT8 waiting;
+ UINT8 watchdog;
} ccpuRegs;
@@ -123,6 +126,15 @@ static UINT8 read_jmi(void)
}
+void ccpu_wdt_timer_trigger(void)
+{
+ ccpu.waiting = FALSE;
+ ccpu.watchdog++;
+ if (ccpu.watchdog >= 3)
+ ccpu.PC = 0;
+}
+
+
static void ccpu_init(int index, int clock, const void *_config, int (*irqcallback)(int))
{
const struct CCPUConfig *config = _config;
@@ -130,7 +142,7 @@ static void ccpu_init(int index, int clock, const void *_config, int (*irqcallba
/* copy input params */
ccpu.external_input = config->external_input ? config->external_input : read_jmi;
ccpu.vector_callback = config->vector_callback;
-
+
state_save_register_item("ccpu", clock, ccpu.PC);
state_save_register_item("ccpu", clock, ccpu.A);
state_save_register_item("ccpu", clock, ccpu.B);
@@ -165,6 +177,9 @@ static void ccpu_reset(void)
ccpu.cmpval = 1;
ccpu.miflag = ccpu.nextmiflag = ccpu.nextnextmiflag = 0;
ccpu.drflag = 0;
+
+ ccpu.waiting = FALSE;
+ ccpu.watchdog = 0;
}
@@ -175,8 +190,11 @@ static void ccpu_reset(void)
static int ccpu_execute(int cycles)
{
- ccpu_icount = cycles;
+ if (ccpu.waiting)
+ return cycles;
+ ccpu_icount = cycles;
+
while (ccpu_icount >= 0)
{
UINT16 tempval;
@@ -545,20 +563,15 @@ static int ccpu_execute(int cycles)
/* FRM */
case 0xe5:
case 0xf5:
-/* FIXME: once vector game video system configuration is fixed,
- remove section in brackets and uncomment line below.
- Speed Freak should run nice and smooth, with no flickering. */
-{
-// attotime scantime, abstime;
-// extern emu_timer *refresh_timer;
-// scantime = timer_starttime(refresh_timer);
-// abstime = timer_get_time();
-// while (attotime_compare(abstime, scantime) >= 0)
-// scantime = attotime_add(scantime, video_screen_get_frame_period(ccpu.scrnum));
-// cpu_spinuntil_time(attotime_sub(scantime, abstime));
-}
-/* cpu_spinuntil_time(video_screen_get_time_until_pos(ccpu.scrnum, Machine->screen[ccpu.scrnum].visarea.max_y + 1, 0)); */
- NEXT_ACC_A(); CYCLES(1);
+ ccpu.waiting = TRUE;
+ NEXT_ACC_A();
+ ccpu_icount = -1;
+
+ /* some games repeat the FRM opcode twice; it apparently does not cause
+ a second wait, so we make sure we skip any duplicate opcode at this
+ point */
+ if (READOP(ccpu.PC) == opcode)
+ ccpu.PC++;
break;
/* STAP */
@@ -570,7 +583,7 @@ static int ccpu_execute(int cycles)
/* CST */
case 0xf7:
- watchdog_reset(Machine);
+ ccpu.watchdog = 0;
/* ADDP */
case 0xe7:
tempval = RDMEM(ccpu.I);
diff --git a/src/emu/cpu/ccpu/ccpu.h b/src/emu/cpu/ccpu/ccpu.h
index 24b5962c153..46626f31eff 100644
--- a/src/emu/cpu/ccpu/ccpu.h
+++ b/src/emu/cpu/ccpu/ccpu.h
@@ -13,6 +13,7 @@
#include "cpuintrf.h"
+
/***************************************************************************
REGISTER ENUMERATION
***************************************************************************/
@@ -32,6 +33,7 @@ enum
};
+
/***************************************************************************
CONFIG STRUCTURE
***************************************************************************/
@@ -44,11 +46,13 @@ struct CCPUConfig
};
+
/***************************************************************************
PUBLIC FUNCTIONS
***************************************************************************/
void ccpu_get_info(UINT32 state, cpuinfo *info);
+void ccpu_wdt_timer_trigger(void);
#ifdef ENABLE_DEBUGGER
offs_t ccpu_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram);
diff --git a/src/emu/drivers/xtal.h b/src/emu/drivers/xtal.h
index d307ee77a47..5b78ebcedcd 100644
--- a/src/emu/drivers/xtal.h
+++ b/src/emu/drivers/xtal.h
@@ -65,7 +65,7 @@ enum
XTAL_10MHz = 10000000,
XTAL_10_595MHz = 10595000, /* Mad Alien */
XTAL_10_738635MHz = 10738635, /* TMS9918 family */
- XTAL_11MHz = 11000000, /* Mario I8039 sound */
+ XTAL_11MHz = 11000000, /* Mario I8039 sound */
XTAL_11_0592MHz = 11059200, /* Lethal Justice */
XTAL_11_2MHz = 11200000, /* New York, New York */
XTAL_11_289MHz = 11289000, /* Vanguard */
@@ -82,13 +82,14 @@ enum
XTAL_14_31818MHz = 14318180, /* Extremely common, used on 100's of PCBs */
XTAL_14_705882MHz = 14705882, /* Aleck64 */
XTAL_14_7456MHz = 14745600, /* Namco System 12 & System Super 22/23 for H8/3002 CPU */
- XTAL_15MHz = 15000000, /* Sinclair QL */
+ XTAL_15MHz = 15000000, /* Sinclair QL */
XTAL_15_468MHz = 15468000, /* Bank Panic h/w, Sega G80 */
XTAL_16MHz = 16000000, /* Extremely common, used on 100's of PCBs */
XTAL_16_9344MHz = 16934400, /* Usually used to drive 90's Yamaha OPL/FM chips */
XTAL_17_73447MHz = 17734470, /* 4 times the PAL subcarrier */
XTAL_18MHz = 18000000, /* S.A.R, Ikari Warriors 3 */
XTAL_18_432MHz = 18432000, /* Extremely common, used on 100's of PCBs */
+ XTAL_19_923MHz = 19923000, /* Cinematronics vectors */
XTAL_19_968MHz = 19968000, /* Used mostly by Space Invaders games by Taito/Midway and clones */
XTAL_20MHz = 20000000,
XTAL_21MHz = 21000000, /* Lock-On pixel clock */
@@ -142,7 +143,7 @@ enum
XTAL_400kHz = 400000, /* Used on Great Swordman h/w */
XTAL_455kHz = 455000, /* Used on Gladiator h/w */
XTAL_640kHz = 640000,
- XTAL_1_056MHz = 1056000 /* used on Trio The Punch */
+ XTAL_1_056MHz = 1056000 /* used on Trio The Punch */
};
diff --git a/src/emu/video.c b/src/emu/video.c
index c9b4dbdcabb..bf96f0ad322 100644
--- a/src/emu/video.c
+++ b/src/emu/video.c
@@ -1023,6 +1023,34 @@ attotime video_screen_get_time_until_vblank_start(int scrnum)
/*-------------------------------------------------
+ video_screen_get_time_until_vblank_end -
+ returns the amount of time remaining until
+ the end of the current VBLANK (if in progress)
+ or the end of the next VBLANK
+-------------------------------------------------*/
+
+attotime video_screen_get_time_until_vblank_end(int scrnum)
+{
+ return video_screen_get_time_until_pos(scrnum, Machine->screen[scrnum].visarea.min_y, 0);
+}
+
+
+/*-------------------------------------------------
+ video_screen_get_time_until_update -
+ returns the amount of time remaining until
+ the next VBLANK period start
+-------------------------------------------------*/
+
+attotime video_screen_get_time_until_update(int scrnum)
+{
+ if (Machine->config->video_attributes & VIDEO_UPDATE_AFTER_VBLANK)
+ return video_screen_get_time_until_vblank_end(scrnum);
+ else
+ return video_screen_get_time_until_vblank_start(scrnum);
+}
+
+
+/*-------------------------------------------------
video_screen_get_scan_period - return the
amount of time the beam takes to draw one
scanline
diff --git a/src/emu/video.h b/src/emu/video.h
index 492ed861c60..01adb8c2a1f 100644
--- a/src/emu/video.h
+++ b/src/emu/video.h
@@ -136,6 +136,12 @@ attotime video_screen_get_time_until_pos(int scrnum, int vpos, int hpos);
/* return the time when the beam will reach the start of VBLANK */
attotime video_screen_get_time_until_vblank_start(int scrnum);
+/* return the time when the beam will reach the end of VBLANK */
+attotime video_screen_get_time_until_vblank_end(int scrnum);
+
+/* return the time when the VIDEO_UPDATE function will be called */
+attotime video_screen_get_time_until_update(int scrnum);
+
/* return the amount of time the beam takes to draw one scan line */
attotime video_screen_get_scan_period(int scrnum);
diff --git a/src/mame/drivers/cinemat.c b/src/mame/drivers/cinemat.c
index 68fba3b1407..bbe3947dddd 100644
--- a/src/mame/drivers/cinemat.c
+++ b/src/mame/drivers/cinemat.c
@@ -39,6 +39,9 @@
#include "starcas.lh"
#include "solarq.lh"
+#define MASTER_CLOCK XTAL_19_923MHz
+
+
static UINT16 *rambase;
@@ -271,8 +274,12 @@ static READ8_HANDLER( boxingb_dial_r )
static READ8_HANDLER( qb3_frame_r )
{
+ attotime next_update = video_screen_get_time_until_update(0);
+ attotime frame_period = video_screen_get_frame_period(0);
+ int percent = next_update.attoseconds / (frame_period.attoseconds / 100);
+
/* note this is just an approximation... */
- return cpu_scalebyfcount(100) < 90;
+ return (percent >= 10);
}
@@ -983,7 +990,7 @@ static const struct CCPUConfig config_jmi =
static MACHINE_DRIVER_START( cinemat_nojmi_4k )
/* basic machine hardware */
- MDRV_CPU_ADD_TAG("main", CCPU, 5000000)
+ MDRV_CPU_ADD_TAG("main", CCPU, MASTER_CLOCK/4)
MDRV_CPU_CONFIG(config_nojmi)
MDRV_CPU_PROGRAM_MAP(program_map_4k,0)
MDRV_CPU_DATA_MAP(data_map,0)
@@ -994,14 +1001,15 @@ static MACHINE_DRIVER_START( cinemat_nojmi_4k )
MDRV_MACHINE_RESET(cinemat)
/* video hardware */
+ MDRV_VIDEO_ATTRIBUTES(VIDEO_ALWAYS_UPDATE)
+
MDRV_SCREEN_ADD("main", VECTOR)
- MDRV_SCREEN_REFRESH_RATE(38)
- MDRV_SCREEN_SIZE(400, 300)
+ MDRV_SCREEN_REFRESH_RATE(MASTER_CLOCK/4/16/16/16/16/2)
+ MDRV_SCREEN_SIZE(1024, 768)
MDRV_SCREEN_VISIBLE_AREA(0, 1023, 0, 767)
MDRV_VIDEO_START(cinemat_bilevel)
- MDRV_VIDEO_EOF(cinemat)
- MDRV_VIDEO_UPDATE(vector)
+ MDRV_VIDEO_UPDATE(cinemat)
MACHINE_DRIVER_END
diff --git a/src/mame/includes/cinemat.h b/src/mame/includes/cinemat.h
index 0a004de8977..a214feffdbe 100644
--- a/src/mame/includes/cinemat.h
+++ b/src/mame/includes/cinemat.h
@@ -42,6 +42,6 @@ VIDEO_START( cinemat_16level );
VIDEO_START( cinemat_64level );
VIDEO_START( cinemat_color );
VIDEO_START( cinemat_qb3color );
-VIDEO_EOF( cinemat );
+VIDEO_UPDATE( cinemat );
VIDEO_UPDATE( spacewar );
diff --git a/src/mame/video/cinemat.c b/src/mame/video/cinemat.c
index bdc105b5d56..af4bbd40df3 100644
--- a/src/mame/video/cinemat.c
+++ b/src/mame/video/cinemat.c
@@ -220,9 +220,16 @@ VIDEO_START( cinemat_qb3color )
*
*************************************/
-VIDEO_EOF( cinemat )
+VIDEO_UPDATE( cinemat )
{
+ VIDEO_UPDATE_CALL(vector);
vector_clear_list();
+
+ cpuintrf_push_context(0);
+ ccpu_wdt_timer_trigger();
+ cpuintrf_pop_context();
+
+ return 0;
}
@@ -237,7 +244,7 @@ VIDEO_UPDATE( spacewar )
{
int sw_option = readinputportbytag("INPUTS");
- VIDEO_UPDATE_CALL(vector);
+ VIDEO_UPDATE_CALL(cinemat);
/* set the state of the artwork */
output_set_value("pressed3", (~sw_option >> 0) & 1);