diff options
| author | 2008-04-14 18:06:56 +0000 | |
|---|---|---|
| committer | 2008-04-14 18:06:56 +0000 | |
| commit | e7cfe56749251ce4ffc2ff1670653995737ec055 (patch) | |
| tree | 5674fdc96b847b34952cb50e15ea88fe6a59f130 | |
| parent | 7b97535eae7913142115ef469117c5cb6e805171 (diff) | |
[CDP1802] Added machine parameter and macros for the callback functions. This seems to have fixed the player sprite flashing in Destroyer/Altair/Draco.
| -rw-r--r-- | src/emu/cpu/cdp1802/cdp1802.c | 53 | ||||
| -rw-r--r-- | src/emu/cpu/cdp1802/cdp1802.h | 82 | ||||
| -rw-r--r-- | src/emu/video/cdp1869.c | 2 | ||||
| -rw-r--r-- | src/mame/drivers/cidelsa.c | 23 |
4 files changed, 95 insertions, 65 deletions
diff --git a/src/emu/cpu/cdp1802/cdp1802.c b/src/emu/cpu/cdp1802/cdp1802.c index 9a23a2f853b..3ec2d0be7b1 100644 --- a/src/emu/cpu/cdp1802/cdp1802.c +++ b/src/emu/cpu/cdp1802/cdp1802.c @@ -3,9 +3,26 @@ #include "deprecat.h" #include "cdp1802.h" +#define CDP1802_CYCLES_RESET 8 +#define CDP1802_CYCLES_INIT 8 // really 9, but needs to be 8 to synchronize cdp1861 video timings +#define CDP1802_CYCLES_FETCH 8 +#define CDP1802_CYCLES_EXECUTE 8 +#define CDP1802_CYCLES_DMA 8 +#define CDP1802_CYCLES_INTERRUPT 8 + +enum { + CDP1802_STATE_0_FETCH, + CDP1802_STATE_1_RESET, + CDP1802_STATE_1_INIT, + CDP1802_STATE_1_EXECUTE, + CDP1802_STATE_2_DMA_IN, + CDP1802_STATE_2_DMA_OUT, + CDP1802_STATE_3_INT +}; + typedef struct { - CDP1802_CONFIG *config; + const cdp1802_interface *intf; UINT8 p, x, d, b, t; UINT16 r[16]; @@ -49,7 +66,7 @@ static void cdp1802_set_context (void *src) static void cdp1802_init(int index, int clock, const void *config, int (*irqcallback)(int)) { - cdp1802.config = (CDP1802_CONFIG *) config; + cdp1802.intf = (cdp1802_interface *) config; cdp1802.mode = CDP1802_MODE_RESET; cdp1802.prevmode = cdp1802.mode; @@ -160,9 +177,9 @@ INLINE void cdp1802_long_skip(int taken) static void cdp1802_sample_ef(void) { - if (cdp1802.config->ef_r) + if (cdp1802.intf->ef_r) { - cdp1802.ef = cdp1802.config->ef_r() & 0x0f; + cdp1802.ef = cdp1802.intf->ef_r(Machine) & 0x0f; } else { @@ -172,25 +189,25 @@ static void cdp1802_sample_ef(void) static void cdp1802_output_state_code(void) { - if (cdp1802.config->sc_w) + if (cdp1802.intf->sc_w) { switch (cdp1802.state) { case CDP1802_STATE_0_FETCH: - cdp1802.config->sc_w(CDP1802_STATE_CODE_S0_FETCH); + cdp1802.intf->sc_w(Machine, CDP1802_STATE_CODE_S0_FETCH); break; case CDP1802_STATE_1_EXECUTE: - cdp1802.config->sc_w(CDP1802_STATE_CODE_S1_EXECUTE); + cdp1802.intf->sc_w(Machine, CDP1802_STATE_CODE_S1_EXECUTE); break; case CDP1802_STATE_2_DMA_IN: case CDP1802_STATE_2_DMA_OUT: - cdp1802.config->sc_w(CDP1802_STATE_CODE_S2_DMA); + cdp1802.intf->sc_w(Machine, CDP1802_STATE_CODE_S2_DMA); break; case CDP1802_STATE_3_INT: - cdp1802.config->sc_w(CDP1802_STATE_CODE_S3_INTERRUPT); + cdp1802.intf->sc_w(Machine, CDP1802_STATE_CODE_S3_INTERRUPT); break; } } @@ -477,18 +494,18 @@ static void cdp1802_run(void) case 0xa: Q = 0; - if (cdp1802.config->q_w) + if (cdp1802.intf->q_w) { - cdp1802.config->q_w(Q); + cdp1802.intf->q_w(Machine, Q); } break; case 0xb: Q = 1; - if (cdp1802.config->q_w) + if (cdp1802.intf->q_w) { - cdp1802.config->q_w(Q); + cdp1802.intf->q_w(Machine, Q); } break; @@ -719,9 +736,9 @@ static void cdp1802_run(void) case CDP1802_STATE_2_DMA_IN: - if (cdp1802.config->dma_r) + if (cdp1802.intf->dma_r) { - MW(R[0], cdp1802.config->dma_r()); + MW(R[0], cdp1802.intf->dma_r(Machine)); } R[0] = R[0] + 1; @@ -752,9 +769,9 @@ static void cdp1802_run(void) case CDP1802_STATE_2_DMA_OUT: - if (cdp1802.config->dma_w) + if (cdp1802.intf->dma_w) { - cdp1802.config->dma_w(M(R[0])); + cdp1802.intf->dma_w(Machine, M(R[0])); } R[0] = R[0] + 1; @@ -812,7 +829,7 @@ static int cdp1802_execute(int cycles) cdp1802_ICount = cycles; cdp1802.prevmode = cdp1802.mode; - cdp1802.mode = cdp1802.config->mode_r(); + cdp1802.mode = cdp1802.intf->mode_r(Machine); do { diff --git a/src/emu/cpu/cdp1802/cdp1802.h b/src/emu/cpu/cdp1802/cdp1802.h index 813f3ced927..f525538a616 100644 --- a/src/emu/cpu/cdp1802/cdp1802.h +++ b/src/emu/cpu/cdp1802/cdp1802.h @@ -3,13 +3,6 @@ #include "cpuintrf.h" -#define CDP1802_CYCLES_RESET 8 -#define CDP1802_CYCLES_INIT 8 // really 9, but needs to be 8 to synchronize cdp1861 video timings -#define CDP1802_CYCLES_FETCH 8 -#define CDP1802_CYCLES_EXECUTE 8 -#define CDP1802_CYCLES_DMA 8 -#define CDP1802_CYCLES_INTERRUPT 8 - enum { CDP1802_INPUT_LINE_INT, CDP1802_INPUT_LINE_DMAIN, @@ -23,30 +16,22 @@ enum { EF4 = 0x08 }; -enum { - CDP1802_STATE_0_FETCH, - CDP1802_STATE_1_RESET, - CDP1802_STATE_1_INIT, - CDP1802_STATE_1_EXECUTE, - CDP1802_STATE_2_DMA_IN, - CDP1802_STATE_2_DMA_OUT, - CDP1802_STATE_3_INT +typedef enum _cdp1802_control_mode cdp1802_control_mode; +enum _cdp1802_control_mode { + CDP1802_MODE_LOAD, + CDP1802_MODE_RESET, + CDP1802_MODE_PAUSE, + CDP1802_MODE_RUN }; -enum { +typedef enum _cdp1802_state cdp1802_state; +enum _cdp1802_state { CDP1802_STATE_CODE_S0_FETCH, CDP1802_STATE_CODE_S1_EXECUTE, CDP1802_STATE_CODE_S2_DMA, CDP1802_STATE_CODE_S3_INTERRUPT }; -enum { - CDP1802_MODE_LOAD, - CDP1802_MODE_RESET, - CDP1802_MODE_PAUSE, - CDP1802_MODE_RUN -}; - // CDP1802 Registers enum { @@ -83,18 +68,49 @@ enum { void cdp1802_get_info(UINT32 state, cpuinfo *info); +typedef cdp1802_control_mode (*cdp1802_mode_read_func)(running_machine *machine); +#define CDP1802_MODE_READ(name) cdp1802_control_mode name(running_machine *machine) + +typedef UINT8 (*cdp1802_ef_read_func)(running_machine *machine); +#define CDP1802_EF_READ(name) UINT8 name(running_machine *machine) + +typedef void (*cdp1802_sc_write_func)(running_machine *machine, cdp1802_state state); +#define CDP1802_SC_WRITE(name) void name(running_machine *machine, cdp1802_state state) + +typedef void (*cdp1802_q_write_func)(running_machine *machine, int level); +#define CDP1802_Q_WRITE(name) void name(running_machine *machine, int level) + +typedef UINT8 (*cdp1802_dma_read_func)(running_machine *machine); +#define CDP1802_DMA_READ(name) UINT8 name(running_machine *machine) + +typedef void (*cdp1802_dma_write_func)(running_machine *machine, UINT8 data); +#define CDP1802_DMA_WRITE(name) void name(running_machine *machine, UINT8 data) + +/* interface */ +typedef struct _cdp1802_interface cdp1802_interface; +struct _cdp1802_interface +{ + /* if specified, this gets called for every change of the mode pins (pins 2 and 3) */ + cdp1802_mode_read_func mode_r; + + /* if specified, this gets called for every change read of the external flags (pins 21 thru 24) */ + cdp1802_ef_read_func ef_r; + + /* if specified, this gets called for every change of the processor state (pins 5 and 6) */ + cdp1802_sc_write_func sc_w; + + /* if specified, this gets called for every change of the Q pin (pin 4) */ + cdp1802_q_write_func q_w; + + /* if specified, this gets called for every DMA read */ + cdp1802_dma_read_func dma_r; + + /* if specified, this gets called for every DMA write */ + cdp1802_dma_write_func dma_w; +}; + #ifdef ENABLE_DEBUGGER offs_t cdp1802_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); #endif -typedef struct -{ - UINT8 (*mode_r)(void); - UINT8 (*ef_r)(void); - void (*sc_w)(int state); - void (*q_w)(int level); - UINT8 (*dma_r)(void); - void (*dma_w)(UINT8 data); -} CDP1802_CONFIG; - #endif diff --git a/src/emu/video/cdp1869.c b/src/emu/video/cdp1869.c index 9666fc99419..3be7abf678d 100644 --- a/src/emu/video/cdp1869.c +++ b/src/emu/video/cdp1869.c @@ -12,8 +12,6 @@ - connect to sound system when possible - white noise - scanline based update - - fix flashing spaceship in destryer/altair - - fix flashing player in draco */ diff --git a/src/mame/drivers/cidelsa.c b/src/mame/drivers/cidelsa.c index 0b97d8cfa39..e9370e7520d 100644 --- a/src/mame/drivers/cidelsa.c +++ b/src/mame/drivers/cidelsa.c @@ -1,5 +1,4 @@ #include "driver.h" -#include "deprecat.h" #include "cpu/cdp1802/cdp1802.h" #include "cpu/cop400/cop400.h" #include "video/cdp1869.h" @@ -20,14 +19,14 @@ /* CDP1802 Interface */ -static UINT8 cidelsa_mode_r(void) +static CDP1802_MODE_READ( cidelsa_mode_r ) { - cidelsa_state *state = Machine->driver_data; + cidelsa_state *state = machine->driver_data; return state->cdp1802_mode; } -static UINT8 cidelsa_ef_r(void) +static CDP1802_EF_READ( cidelsa_ef_r ) { /* EF1 CDP1869 _PRD @@ -36,17 +35,17 @@ static UINT8 cidelsa_ef_r(void) EF4 Coin 1 */ - return input_port_read(Machine, "EF"); + return input_port_read(machine, "EF"); } -static void cidelsa_q_w(int q) +static CDP1802_Q_WRITE( cidelsa_q_w ) { - cidelsa_state *state = Machine->driver_data; + cidelsa_state *state = machine->driver_data; - state->cdp1802_q = q; + state->cdp1802_q = level; } -static const CDP1802_CONFIG cidelsa_cdp1802_config = +static const cdp1802_interface cidelsa_cdp1802_config = { cidelsa_mode_r, // MODE cidelsa_ef_r, // EF @@ -669,7 +668,7 @@ ROM_END /* Game Drivers */ -GAME( 1980, destryer, 0, destryer, destryer, 0, ROT90, "Cidelsa", "Destroyer (Cidelsa) (set 1)", GAME_IMPERFECT_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) -GAME( 1980, destryea, destryer, destryea, destryer, 0, ROT90, "Cidelsa", "Destroyer (Cidelsa) (set 2)", GAME_IMPERFECT_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) -GAME( 1981, altair, 0, altair, altair, 0, ROT90, "Cidelsa", "Altair", GAME_IMPERFECT_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1980, destryer, 0, destryer, destryer, 0, ROT90, "Cidelsa", "Destroyer (Cidelsa) (set 1)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1980, destryea, destryer, destryea, destryer, 0, ROT90, "Cidelsa", "Destroyer (Cidelsa) (set 2)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) +GAME( 1981, altair, 0, altair, altair, 0, ROT90, "Cidelsa", "Altair", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) GAME( 1981, draco, 0, draco, draco, 0, ROT90, "Cidelsa", "Draco", GAME_IMPERFECT_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE ) |
