From d0af9ba1e81ffc035547bbfd27359af51c42741a Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Sun, 20 Dec 2009 23:57:25 +0000 Subject: [PATCH] First round of fixes for post-initialization allocs. In the process, converted 7474, 74148, and 74153 to devices. --- src/emu/cpu/z180/z180.c | 5 +- src/emu/machine/68681.c | 33 ++-- src/emu/machine/74148.c | 207 ++++++++++++---------- src/emu/machine/74148.h | 29 +-- src/emu/machine/74153.c | 156 +++++++++------- src/emu/machine/74153.h | 28 +-- src/emu/machine/7474.c | 150 +++++++++------- src/emu/machine/7474.h | 32 ++-- src/emu/restrack.c | 2 +- src/emu/sound/tms5110.c | 11 +- src/mame/audio/jaguar.c | 39 +--- src/mame/audio/scramble.c | 44 ++--- src/mame/drivers/artmagic.c | 1 - src/mame/drivers/badlands.c | 6 +- src/mame/drivers/carpolo.c | 19 ++ src/mame/drivers/cninja.c | 22 ++- src/mame/drivers/cojag.c | 8 +- src/mame/drivers/coolpool.c | 22 +-- src/mame/drivers/galaxold.c | 4 + src/mame/drivers/scobra.c | 5 + src/mame/drivers/scramble.c | 9 + src/mame/drivers/vertigo.c | 3 + src/mame/includes/carpolo.h | 7 + src/mame/includes/galaxold.h | 4 + src/mame/includes/jaguar.h | 2 + src/mame/includes/vertigo.h | 2 + src/mame/machine/carpolo.c | 335 +++++++++++++++++------------------ src/mame/machine/galaxold.c | 49 +++-- src/mame/machine/vertigo.c | 30 ++-- src/mame/video/artmagic.c | 1 + 30 files changed, 676 insertions(+), 589 deletions(-) diff --git a/src/emu/cpu/z180/z180.c b/src/emu/cpu/z180/z180.c index 6bdc2c32aec..3f0836d0596 100644 --- a/src/emu/cpu/z180/z180.c +++ b/src/emu/cpu/z180/z180.c @@ -2019,6 +2019,9 @@ static CPU_INIT( z180 ) cpustate->daisy = z80daisy_init(device, (const z80_daisy_chain *)device->static_config); cpustate->irq_callback = irqcallback; + SZHVC_add = auto_alloc_array(device->machine, UINT8, 2*256*256); + SZHVC_sub = auto_alloc_array(device->machine, UINT8, 2*256*256); + /* set up the state table */ cpustate->state = state_table_template; cpustate->state.baseptr = cpustate; @@ -2064,8 +2067,6 @@ static CPU_RESET( z180 ) int oldval, newval, val; UINT8 *padd, *padc, *psub, *psbc; /* allocate big flag arrays once */ - SZHVC_add = auto_alloc_array(device->machine, UINT8, 2*256*256); - SZHVC_sub = auto_alloc_array(device->machine, UINT8, 2*256*256); padd = &SZHVC_add[ 0*256]; padc = &SZHVC_add[256*256]; psub = &SZHVC_sub[ 0*256]; diff --git a/src/emu/machine/68681.c b/src/emu/machine/68681.c index 4136c2e9bb9..7ae0be7be0f 100644 --- a/src/emu/machine/68681.c +++ b/src/emu/machine/68681.c @@ -691,6 +691,13 @@ static DEVICE_START(duart68681) assert(device != NULL); assert(device->tag != NULL); + duart68681->duart_config = (const duart68681_config *)device->static_config; + duart68681->device = device; + + duart68681->channel[0].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device); + duart68681->channel[1].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device); + duart68681->duart_timer = timer_alloc(device->machine, duart_timer_callback, (void*)device); + state_save_register_device_item(device, 0, duart68681->ACR); state_save_register_device_item(device, 0, duart68681->IMR); state_save_register_device_item(device, 0, duart68681->ISR); @@ -739,29 +746,29 @@ static DEVICE_START(duart68681) static DEVICE_RESET(duart68681) { duart68681_state *duart68681 = get_safe_token(device); + emu_timer *save0, *save1; - memset(duart68681, 0, sizeof(duart68681_state)); - duart68681->duart_config = (const duart68681_config *)device->static_config; - duart68681->device = device; + duart68681->ACR = 0; /* Interrupt Vector Register */ duart68681->IVR = 0x0f; /* Interrupt Vector Register */ - // "reset clears internal registers (SRA, SRB, IMR, ISR, OPR, OPCR) puts OP0-7 in the high state, stops the counter/timer, and puts channels a/b in the inactive state" - duart68681->channel[0].SR = 0; - duart68681->channel[1].SR = 0; duart68681->IMR = 0; /* Interrupt Mask Register */ duart68681->ISR = 0; /* Interrupt Status Register */ duart68681->OPCR = 0; /* Output Port Conf. Register */ duart68681->OPR = 0; /* Output Port Register */ + duart68681->CTR.d = 0; /* Counter/Timer Preset Value */ + duart68681->IP_last_state = 0; /* last state of IP bits */ + // "reset clears internal registers (SRA, SRB, IMR, ISR, OPR, OPCR) puts OP0-7 in the high state, stops the counter/timer, and puts channels a/b in the inactive state" + save0 = duart68681->channel[0].tx_timer; + save1 = duart68681->channel[1].tx_timer; + memset(duart68681->channel, 0, sizeof(duart68681->channel)); + duart68681->channel[0].tx_timer = save0; + duart68681->channel[1].tx_timer = save1; + if (duart68681->duart_config->output_port_write) - duart68681->duart_config->output_port_write(duart68681->device, duart68681->OPR ^ 0xff); + duart68681->duart_config->output_port_write(duart68681->device, duart68681->OPR ^ 0xff); - // allocate timers - duart68681->channel[0].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device); + // reset timers timer_adjust_oneshot(duart68681->channel[0].tx_timer, attotime_never, 0); - - duart68681->channel[1].tx_timer = timer_alloc(device->machine, tx_timer_callback, (void*)device); timer_adjust_oneshot(duart68681->channel[1].tx_timer, attotime_never, 1); - - duart68681->duart_timer = timer_alloc(device->machine, duart_timer_callback, (void*)device); } /*------------------------------------------------- diff --git a/src/emu/machine/74148.c b/src/emu/machine/74148.c index 1f5e98d8acf..71ba8b8a005 100644 --- a/src/emu/machine/74148.c +++ b/src/emu/machine/74148.c @@ -42,12 +42,11 @@ #include "machine/74148.h" -#define MAX_TTL74148 4 - -struct TTL74148 +typedef struct _ttl74148_state ttl74148_state; +struct _ttl74148_state { /* callback */ - void (*output_cb)(running_machine *machine); + void (*output_cb)(const device_config *device); /* inputs */ int input_lines[8]; /* pins 1-4,10-13 */ @@ -64,139 +63,163 @@ struct TTL74148 int last_enable_output; }; -static struct TTL74148 chips[MAX_TTL74148]; - -void TTL74148_update(running_machine *machine, int which) +INLINE ttl74148_state *get_safe_token(const device_config *device) { - if (chips[which].enable_input) + assert(device != NULL); + assert(device->token != NULL); + assert(device->type == ttl74148); + + return (ttl74148_state *)device->token; +} + +void ttl74148_update(const device_config *device) +{ + ttl74148_state *state = get_safe_token(device); + + if (state->enable_input) { // row 1 in truth table - chips[which].output = 0x07; - chips[which].output_valid = 1; - chips[which].enable_output = 1; + state->output = 0x07; + state->output_valid = 1; + state->enable_output = 1; } else { int bit0, bit1, bit2; /* this comes straight off the data sheet schematics */ - bit0 = !(((!chips[which].input_lines[1]) & - chips[which].input_lines[2] & - chips[which].input_lines[4] & - chips[which].input_lines[6]) | - ((!chips[which].input_lines[3]) & - chips[which].input_lines[4] & - chips[which].input_lines[6]) | - ((!chips[which].input_lines[5]) & - chips[which].input_lines[6]) | - (!chips[which].input_lines[7])); + bit0 = !(((!state->input_lines[1]) & + state->input_lines[2] & + state->input_lines[4] & + state->input_lines[6]) | + ((!state->input_lines[3]) & + state->input_lines[4] & + state->input_lines[6]) | + ((!state->input_lines[5]) & + state->input_lines[6]) | + (!state->input_lines[7])); - bit1 = !(((!chips[which].input_lines[2]) & - chips[which].input_lines[4] & - chips[which].input_lines[5]) | - ((!chips[which].input_lines[3]) & - chips[which].input_lines[4] & - chips[which].input_lines[5]) | - (!chips[which].input_lines[6]) | - (!chips[which].input_lines[7])); + bit1 = !(((!state->input_lines[2]) & + state->input_lines[4] & + state->input_lines[5]) | + ((!state->input_lines[3]) & + state->input_lines[4] & + state->input_lines[5]) | + (!state->input_lines[6]) | + (!state->input_lines[7])); - bit2 = !((!chips[which].input_lines[4]) | - (!chips[which].input_lines[5]) | - (!chips[which].input_lines[6]) | - (!chips[which].input_lines[7])); + bit2 = !((!state->input_lines[4]) | + (!state->input_lines[5]) | + (!state->input_lines[6]) | + (!state->input_lines[7])); - chips[which].output = (bit2 << 2) | (bit1 << 1) | bit0; + state->output = (bit2 << 2) | (bit1 << 1) | bit0; - chips[which].output_valid = (chips[which].input_lines[0] & - chips[which].input_lines[1] & - chips[which].input_lines[2] & - chips[which].input_lines[3] & - chips[which].input_lines[4] & - chips[which].input_lines[5] & - chips[which].input_lines[6] & - chips[which].input_lines[7]); + state->output_valid = (state->input_lines[0] & + state->input_lines[1] & + state->input_lines[2] & + state->input_lines[3] & + state->input_lines[4] & + state->input_lines[5] & + state->input_lines[6] & + state->input_lines[7]); - chips[which].enable_output = !chips[which].output_valid; + state->enable_output = !state->output_valid; } /* call callback if any of the outputs changed */ - if ( chips[which].output_cb && - ((chips[which].output != chips[which].last_output) || - (chips[which].output_valid != chips[which].last_output_valid) || - (chips[which].enable_output != chips[which].last_enable_output))) + if ( state->output_cb && + ((state->output != state->last_output) || + (state->output_valid != state->last_output_valid) || + (state->enable_output != state->last_enable_output))) { - chips[which].last_output = chips[which].output; - chips[which].last_output_valid = chips[which].output_valid; - chips[which].last_enable_output = chips[which].enable_output; + state->last_output = state->output; + state->last_output_valid = state->output_valid; + state->last_enable_output = state->enable_output; - chips[which].output_cb(machine); + state->output_cb(device); } } -void TTL74148_input_line_w(int which, int input_line, int data) +void ttl74148_input_line_w(const device_config *device, int input_line, int data) { - chips[which].input_lines[input_line] = data ? 1 : 0; + ttl74148_state *state = get_safe_token(device); + state->input_lines[input_line] = data ? 1 : 0; } -void TTL74148_enable_input_w(int which, int data) +void ttl74148_enable_input_w(const device_config *device, int data) { - chips[which].enable_input = data ? 1 : 0; + ttl74148_state *state = get_safe_token(device); + state->enable_input = data ? 1 : 0; } -int TTL74148_output_r(int which) +int ttl74148_output_r(const device_config *device) { - return chips[which].output; + ttl74148_state *state = get_safe_token(device); + return state->output; } -int TTL74148_output_valid_r(int which) +int ttl74148_output_valid_r(const device_config *device) { - return chips[which].output_valid; + ttl74148_state *state = get_safe_token(device); + return state->output_valid; } -int TTL74148_enable_output_r(int which) +int ttl74148_enable_output_r(const device_config *device) { - return chips[which].enable_output; + ttl74148_state *state = get_safe_token(device); + return state->enable_output; } - -void TTL74148_config(running_machine *machine, int which, const struct TTL74148_interface *intf) +static DEVICE_START( ttl74148 ) { - if (which >= MAX_TTL74148) - { - logerror("Only %d 74148's are supported at this time.\n", MAX_TTL74148); - return; - } + ttl74148_config *config = (ttl74148_config *)device->inline_config; + ttl74148_state *state = get_safe_token(device); + state->output_cb = config->output_cb; - - chips[which].output_cb = (intf ? intf->output_cb : 0); - chips[which].enable_input = 1; - chips[which].input_lines[0] = 1; - chips[which].input_lines[1] = 1; - chips[which].input_lines[2] = 1; - chips[which].input_lines[3] = 1; - chips[which].input_lines[4] = 1; - chips[which].input_lines[5] = 1; - chips[which].input_lines[6] = 1; - chips[which].input_lines[7] = 1; - - chips[which].last_output = -1; - chips[which].last_output_valid = -1; - chips[which].last_enable_output = -1; - - state_save_register_item_array(machine, "ttl74148", NULL, which, chips[which].input_lines); - state_save_register_item(machine, "ttl74148", NULL, which, chips[which].enable_input); - state_save_register_item(machine, "ttl74148", NULL, which, chips[which].output); - state_save_register_item(machine, "ttl74148", NULL, which, chips[which].output_valid); - state_save_register_item(machine, "ttl74148", NULL, which, chips[which].enable_output); - state_save_register_item(machine, "ttl74148", NULL, which, chips[which].last_output); - state_save_register_item(machine, "ttl74148", NULL, which, chips[which].last_output_valid); - state_save_register_item(machine, "ttl74148", NULL, which, chips[which].last_enable_output); + state_save_register_device_item_array(device, 0, state->input_lines); + state_save_register_device_item(device, 0, state->enable_input); + state_save_register_device_item(device, 0, state->output); + state_save_register_device_item(device, 0, state->output_valid); + state_save_register_device_item(device, 0, state->enable_output); + state_save_register_device_item(device, 0, state->last_output); + state_save_register_device_item(device, 0, state->last_output_valid); + state_save_register_device_item(device, 0, state->last_enable_output); } + + +static DEVICE_RESET( ttl74148 ) +{ + ttl74148_state *state = get_safe_token(device); + + state->enable_input = 1; + state->input_lines[0] = 1; + state->input_lines[1] = 1; + state->input_lines[2] = 1; + state->input_lines[3] = 1; + state->input_lines[4] = 1; + state->input_lines[5] = 1; + state->input_lines[6] = 1; + state->input_lines[7] = 1; + + state->last_output = -1; + state->last_output_valid = -1; + state->last_enable_output = -1; +} + + +static const char DEVTEMPLATE_SOURCE[] = __FILE__; + +#define DEVTEMPLATE_ID(p,s) p##ttl74148##s +#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG +#define DEVTEMPLATE_NAME "74148" +#define DEVTEMPLATE_FAMILY "TTL" +#include "devtempl.h" diff --git a/src/emu/machine/74148.h b/src/emu/machine/74148.h index 30cead0d9f4..30b13ae7a7c 100644 --- a/src/emu/machine/74148.h +++ b/src/emu/machine/74148.h @@ -42,22 +42,29 @@ #define TTL74148_H -/* The interface structure */ -struct TTL74148_interface +typedef struct _ttl74148_config ttl74148_config; +struct _ttl74148_config { - void (*output_cb)(running_machine *machine); + void (*output_cb)(const device_config *device); }; -void TTL74148_config(running_machine *machine, int which, const struct TTL74148_interface *intf); +#define MDRV_74148_ADD(_tag, _output_cb) \ + MDRV_DEVICE_ADD(_tag, TTL74148, 0) \ + MDRV_DEVICE_CONFIG_DATAPTR(ttl74148_config, output_cb, _output_cb) -/* must call TTL74148_update() after setting the inputs */ -void TTL74148_update(running_machine *machine, int which); -void TTL74148_input_line_w(int which, int input_line, int data); -void TTL74148_enable_input_w(int which, int data); -int TTL74148_output_r(int which); -int TTL74148_output_valid_r(int which); -int TTL74148_enable_output_r(int which); +/* must call ttl74148_update() after setting the inputs */ +void ttl74148_update(const device_config *device); + +void ttl74148_input_line_w(const device_config *device, int input_line, int data); +void ttl74148_enable_input_w(const device_config *device, int data); +int ttl74148_output_r(const device_config *device); +int ttl74148_output_valid_r(const device_config *device); +int ttl74148_enable_output_r(const device_config *device); + +/* device get info callback */ +#define TTL74148 DEVICE_GET_INFO_NAME(ttl74148) +DEVICE_GET_INFO( ttl74148 ); #endif diff --git a/src/emu/machine/74153.c b/src/emu/machine/74153.c index 8ca40cffd12..982684d8db6 100644 --- a/src/emu/machine/74153.c +++ b/src/emu/machine/74153.c @@ -37,14 +37,11 @@ #include "machine/74153.h" -#define MAX_TTL74153 9 - -struct TTL74153 +typedef struct _ttl74153_state ttl74153_state; +struct _ttl74153_state { - running_machine *machine; - /* callback */ - void (*output_cb)(running_machine *machine); + void (*output_cb)(const device_config *device); /* inputs */ int a; /* pin 14 */ @@ -59,109 +56,132 @@ struct TTL74153 int last_output[2]; }; -static struct TTL74153 chips[MAX_TTL74153]; - - -void TTL74153_update(int which) +INLINE ttl74153_state *get_safe_token(const device_config *device) { + assert(device != NULL); + assert(device->token != NULL); + assert(device->type == TTL74153); + + return (ttl74153_state *)device->token; +} + + + +void ttl74153_update(const device_config *device) +{ + ttl74153_state *state = get_safe_token(device); int sel; int section; - sel = (chips[which].b << 1) | chips[which].a; + sel = (state->b << 1) | state->a; /* process both sections */ for (section = 0; section < 2; section++) { - if (chips[which].enable[section]) - chips[which].output[section] = 0; // row 1 in truth table + if (state->enable[section]) + state->output[section] = 0; // row 1 in truth table else - chips[which].output[section] = chips[which].input_lines[section][sel]; + state->output[section] = state->input_lines[section][sel]; } /* call callback if either of the outputs changed */ - if ( chips[which].output_cb && - ((chips[which].output[0] != chips[which].last_output[0]) || - (chips[which].output[1] != chips[which].last_output[1]))) + if ( state->output_cb && + ((state->output[0] != state->last_output[0]) || + (state->output[1] != state->last_output[1]))) { - chips[which].last_output[0] = chips[which].output[0]; - chips[which].last_output[1] = chips[which].output[1]; + state->last_output[0] = state->output[0]; + state->last_output[1] = state->output[1]; - chips[which].output_cb(chips[which].machine); + state->output_cb(device); } } -void TTL74153_a_w(int which, int data) +void ttl74153_a_w(const device_config *device, int data) { - chips[which].a = data ? 1 : 0; + ttl74153_state *state = get_safe_token(device); + state->a = data ? 1 : 0; } -void TTL74153_b_w(int which, int data) +void ttl74153_b_w(const device_config *device, int data) { - chips[which].b = data ? 1 : 0; + ttl74153_state *state = get_safe_token(device); + state->b = data ? 1 : 0; } -void TTL74153_input_line_w(int which, int section, int input_line, int data) +void ttl74153_input_line_w(const device_config *device, int section, int input_line, int data) { - chips[which].input_lines[section][input_line] = data ? 1 : 0; + ttl74153_state *state = get_safe_token(device); + state->input_lines[section][input_line] = data ? 1 : 0; } -void TTL74153_enable_w(int which, int section, int data) +void ttl74153_enable_w(const device_config *device, int section, int data) { - chips[which].enable[section] = data ? 1 : 0; + ttl74153_state *state = get_safe_token(device); + state->enable[section] = data ? 1 : 0; } -int TTL74153_output_r(int which, int section) +int ttl74153_output_r(const device_config *device, int section) { - return chips[which].output[section]; + ttl74153_state *state = get_safe_token(device); + return state->output[section]; } - -void TTL74153_config(running_machine *machine, int which, const struct TTL74153_interface *intf) +static DEVICE_START( ttl74153 ) { - if (which >= MAX_TTL74153) - { - logerror("Only %d 74153's are supported at this time.\n", MAX_TTL74153); - return; - } + ttl74153_config *config = (ttl74153_config *)device->inline_config; + ttl74153_state *state = get_safe_token(device); + state->output_cb = config->output_cb; - - chips[which].machine = machine; - chips[which].output_cb = (intf ? intf->output_cb : 0); - chips[which].a = 1; - chips[which].b = 1; - chips[which].enable[0] = 1; - chips[which].enable[1] = 1; - chips[which].input_lines[0][0] = 1; - chips[which].input_lines[0][1] = 1; - chips[which].input_lines[0][2] = 1; - chips[which].input_lines[0][3] = 1; - chips[which].input_lines[1][0] = 1; - chips[which].input_lines[1][1] = 1; - chips[which].input_lines[1][2] = 1; - chips[which].input_lines[1][3] = 1; - - chips[which].last_output[0] = -1; - chips[which].last_output[1] = -1; - - state_save_register_item_array(machine, "ttl74153", NULL, which, chips[which].enable); - state_save_register_item_array(machine, "ttl74153", NULL, which, chips[which].last_output); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[0][0]); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[0][1]); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[0][2]); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[0][3]); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[1][0]); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[1][1]); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[1][2]); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].input_lines[1][3]); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].a); - state_save_register_item(machine, "ttl74153", NULL, which, chips[which].b); + state_save_register_device_item_array(device, 0, state->enable); + state_save_register_device_item_array(device, 0, state->last_output); + state_save_register_device_item(device, 0, state->input_lines[0][0]); + state_save_register_device_item(device, 0, state->input_lines[0][1]); + state_save_register_device_item(device, 0, state->input_lines[0][2]); + state_save_register_device_item(device, 0, state->input_lines[0][3]); + state_save_register_device_item(device, 0, state->input_lines[1][0]); + state_save_register_device_item(device, 0, state->input_lines[1][1]); + state_save_register_device_item(device, 0, state->input_lines[1][2]); + state_save_register_device_item(device, 0, state->input_lines[1][3]); + state_save_register_device_item(device, 0, state->a); + state_save_register_device_item(device, 0, state->b); } + + +static DEVICE_RESET( ttl74153 ) +{ + ttl74153_state *state = get_safe_token(device); + + state->a = 1; + state->b = 1; + state->enable[0] = 1; + state->enable[1] = 1; + state->input_lines[0][0] = 1; + state->input_lines[0][1] = 1; + state->input_lines[0][2] = 1; + state->input_lines[0][3] = 1; + state->input_lines[1][0] = 1; + state->input_lines[1][1] = 1; + state->input_lines[1][2] = 1; + state->input_lines[1][3] = 1; + + state->last_output[0] = -1; + state->last_output[1] = -1; +} + + +static const char DEVTEMPLATE_SOURCE[] = __FILE__; + +#define DEVTEMPLATE_ID(p,s) p##ttl74153##s +#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG +#define DEVTEMPLATE_NAME "74153" +#define DEVTEMPLATE_FAMILY "TTL" +#include "devtempl.h" diff --git a/src/emu/machine/74153.h b/src/emu/machine/74153.h index b70d8e2a555..84e0be091b4 100644 --- a/src/emu/machine/74153.h +++ b/src/emu/machine/74153.h @@ -37,22 +37,30 @@ #define TTL74153_H -/* The interface structure */ -struct TTL74153_interface +typedef struct _ttl74153_config ttl74153_config; +struct _ttl74153_config { - void (*output_cb)(running_machine *machine); + void (*output_cb)(const device_config *device); }; -void TTL74153_config(running_machine *machine, int which, const struct TTL74153_interface *intf); +#define MDRV_74153_ADD(_tag, _output_cb) \ + MDRV_DEVICE_ADD(_tag, TTL74153, 0) \ + MDRV_DEVICE_CONFIG_DATAPTR(ttl74153_config, output_cb, _output_cb) + + /* must call TTL74153_update() after setting the inputs */ -void TTL74153_update(int which); +void ttl74153_update(const device_config *device); -void TTL74153_a_w(int which, int data); -void TTL74153_b_w(int which, int data); -void TTL74153_input_line_w(int which, int section, int input_line, int data); -void TTL74153_enable_w(int which, int section, int data); -int TTL74153_output_r(int which, int section); +void ttl74153_a_w(const device_config *device, int data); +void ttl74153_b_w(const device_config *device, int data); +void ttl74153_input_line_w(const device_config *device, int section, int input_line, int data); +void ttl74153_enable_w(const device_config *device, int section, int data); +int ttl74153_output_r(const device_config *device, int section); + +/* device get info callback */ +#define TTL74153 DEVICE_GET_INFO_NAME(ttl74153) +DEVICE_GET_INFO( ttl74153 ); #endif diff --git a/src/emu/machine/7474.c b/src/emu/machine/7474.c index dd083932d29..bcfbeccfc4a 100644 --- a/src/emu/machine/7474.c +++ b/src/emu/machine/7474.c @@ -41,12 +41,11 @@ #include "7474.h" -#define MAX_TTL7474 12 - -struct TTL7474 +typedef struct _ttl7474_state ttl7474_state; +struct _ttl7474_state { /* callback */ - void (*output_cb)(running_machine *); + void (*output_cb)(const device_config *); /* inputs */ UINT8 clear; /* pin 1/13 */ @@ -64,108 +63,133 @@ struct TTL7474 UINT8 last_output_comp; }; -static struct TTL7474 chips[MAX_TTL7474]; - - -void TTL7474_update(running_machine *machine, int which) +INLINE ttl7474_state *get_safe_token(const device_config *device) { - if (!chips[which].preset && chips[which].clear) /* line 1 in truth table */ + assert(device != NULL); + assert(device->token != NULL); + assert(device->type == TTL7474); + + return (ttl7474_state *)device->token; +} + + +void ttl7474_update(const device_config *device) +{ + ttl7474_state *state = get_safe_token(device); + + if (!state->preset && state->clear) /* line 1 in truth table */ { - chips[which].output = 1; - chips[which].output_comp = 0; + state->output = 1; + state->output_comp = 0; } - else if (chips[which].preset && !chips[which].clear) /* line 2 in truth table */ + else if (state->preset && !state->clear) /* line 2 in truth table */ { - chips[which].output = 0; - chips[which].output_comp = 1; + state->output = 0; + state->output_comp = 1; } - else if (!chips[which].preset && !chips[which].clear) /* line 3 in truth table */ + else if (!state->preset && !state->clear) /* line 3 in truth table */ { - chips[which].output = 1; - chips[which].output_comp = 1; + state->output = 1; + state->output_comp = 1; } - else if (!chips[which].last_clock && chips[which].clock) /* line 4 in truth table */ + else if (!state->last_clock && state->clock) /* line 4 in truth table */ { - chips[which].output = chips[which].d; - chips[which].output_comp = !chips[which].d; + state->output = state->d; + state->output_comp = !state->d; } - chips[which].last_clock = chips[which].clock; + state->last_clock = state->clock; /* call callback if any of the outputs changed */ - if ( chips[which].output_cb && - ((chips[which].output != chips[which].last_output) || - (chips[which].output_comp != chips[which].last_output_comp))) + if ( state->output_cb && + ((state->output != state->last_output) || + (state->output_comp != state->last_output_comp))) { - chips[which].last_output = chips[which].output; - chips[which].last_output_comp = chips[which].output_comp; + state->last_output = state->output; + state->last_output_comp = state->output_comp; - chips[which].output_cb(machine); + state->output_cb(device); } } -void TTL7474_clear_w(int which, int data) +void ttl7474_clear_w(const device_config *device, int data) { - chips[which].clear = data ? 1 : 0; + ttl7474_state *state = get_safe_token(device); + state->clear = data ? 1 : 0; } -void TTL7474_preset_w(int which, int data) +void ttl7474_preset_w(const device_config *device, int data) { - chips[which].preset = data ? 1 : 0; + ttl7474_state *state = get_safe_token(device); + state->preset = data ? 1 : 0; } -void TTL7474_clock_w(int which, int data) +void ttl7474_clock_w(const device_config *device, int data) { - chips[which].clock = data ? 1 : 0; + ttl7474_state *state = get_safe_token(device); + state->clock = data ? 1 : 0; } -void TTL7474_d_w(int which, int data) +void ttl7474_d_w(const device_config *device, int data) { - chips[which].d = data ? 1 : 0; + ttl7474_state *state = get_safe_token(device); + state->d = data ? 1 : 0; } -int TTL7474_output_r(int which) +int ttl7474_output_r(const device_config *device) { - return chips[which].output; + ttl7474_state *state = get_safe_token(device); + return state->output; } -int TTL7474_output_comp_r(int which) +int ttl7474_output_comp_r(const device_config *device) { - return chips[which].output_comp; + ttl7474_state *state = get_safe_token(device); + return state->output_comp; } -void TTL7474_config(running_machine *machine, int which, const struct TTL7474_interface *intf) +static DEVICE_START( ttl7474 ) { - if (which >= MAX_TTL7474) - { - logerror("Only %d 7474's are supported at this time.\n", MAX_TTL7474); - return; - } + ttl7474_config *config = (ttl7474_config *)device->inline_config; + ttl7474_state *state = get_safe_token(device); + state->output_cb = config->output_cb; + + state_save_register_device_item(device, 0, state->clear); + state_save_register_device_item(device, 0, state->preset); + state_save_register_device_item(device, 0, state->clock); + state_save_register_device_item(device, 0, state->d); + state_save_register_device_item(device, 0, state->output); + state_save_register_device_item(device, 0, state->output_comp); + state_save_register_device_item(device, 0, state->last_clock); + state_save_register_device_item(device, 0, state->last_output); + state_save_register_device_item(device, 0, state->last_output_comp); +} - chips[which].output_cb = (intf ? intf->output_cb : 0); +static DEVICE_RESET( ttl7474 ) +{ + ttl7474_state *state = get_safe_token(device); /* all inputs are open first */ - chips[which].clear = 1; - chips[which].preset = 1; - chips[which].clock = 1; - chips[which].d = 1; + state->clear = 1; + state->preset = 1; + state->clock = 1; + state->d = 1; - chips[which].last_clock = 1; - chips[which].last_output = -1; - chips[which].last_output_comp = -1; - - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].clear); - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].preset); - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].clock); - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].d); - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].output); - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].output_comp); - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].last_clock); - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].last_output); - state_save_register_item(machine, "ttl7474", NULL, which, chips[which].last_output_comp); + state->last_clock = 1; + state->last_output = -1; + state->last_output_comp = -1; } + + +static const char DEVTEMPLATE_SOURCE[] = __FILE__; + +#define DEVTEMPLATE_ID(p,s) p##ttl7474##s +#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET | DT_HAS_INLINE_CONFIG +#define DEVTEMPLATE_NAME "7474" +#define DEVTEMPLATE_FAMILY "TTL" +#include "devtempl.h" diff --git a/src/emu/machine/7474.h b/src/emu/machine/7474.h index 5c4a9ce5702..3e71851ae0f 100644 --- a/src/emu/machine/7474.h +++ b/src/emu/machine/7474.h @@ -25,7 +25,7 @@ H L X X | L H L L X X | H H (Note 1) H H _- X | D /D - H H L X | Q0 /Q0 + H H L X | Q0 /Q01 --------------+------- L = lo (0) H = hi (1) @@ -41,23 +41,31 @@ #define TTL7474_H -/* The interface structure */ -struct TTL7474_interface +typedef struct _ttl7474_config ttl7474_config; +struct _ttl7474_config { - void (*output_cb)(running_machine *machine); + void (*output_cb)(const device_config *device); }; -void TTL7474_config(running_machine *machine, int which, const struct TTL7474_interface *intf); +#define MDRV_7474_ADD(_tag, _output_cb) \ + MDRV_DEVICE_ADD(_tag, TTL7474, 0) \ + MDRV_DEVICE_CONFIG_DATAPTR(ttl7474_config, output_cb, _output_cb) + + /* must call TTL7474_update() after setting the inputs */ -void TTL7474_update(running_machine *machine, int which); +void ttl7474_update(const device_config *device); -void TTL7474_clear_w(int which, int data); -void TTL7474_preset_w(int which, int data); -void TTL7474_clock_w(int which, int data); -void TTL7474_d_w(int which, int data); -int TTL7474_output_r(int which); -int TTL7474_output_comp_r(int which); /* NOT strictly the same as !TTL7474_output_r() */ +void ttl7474_clear_w(const device_config *device, int data); +void ttl7474_preset_w(const device_config *device, int data); +void ttl7474_clock_w(const device_config *device, int data); +void ttl7474_d_w(const device_config *device, int data); +int ttl7474_output_r(const device_config *device); +int ttl7474_output_comp_r(const device_config *device); /* NOT strictly the same as !ttl7474_output_r() */ + +/* device get info callback */ +#define TTL7474 DEVICE_GET_INFO_NAME(ttl7474) +DEVICE_GET_INFO( ttl7474 ); #endif diff --git a/src/emu/restrack.c b/src/emu/restrack.c index ce3329f6035..c3cc5deae11 100644 --- a/src/emu/restrack.c +++ b/src/emu/restrack.c @@ -218,7 +218,6 @@ if (resource_tracking_tag == 2) mame_printf_warning("auto_malloc(%ld) called wit void *auto_realloc_file_line(running_machine *machine, void *ptr, size_t size, const char *file, int line) { object_pool *pool = current_pool(); -if (resource_tracking_tag == 2) mame_printf_warning("auto_realloc(%p, %ld) called within reset scope by %s, line %d\n", ptr, (long) size, file, line); if (ptr != NULL) { int tag = resource_tracking_tag; @@ -230,6 +229,7 @@ if (resource_tracking_tag == 2) mame_printf_warning("auto_realloc(%p, %ld) calle } assert_always(tag > 0, "Failed to find alloc in pool"); } +else if (resource_tracking_tag == 2) mame_printf_warning("auto_realloc(%p, %ld) called within reset scope by %s, line %d\n", ptr, (long) size, file, line); return pool_realloc_file_line(pool, ptr, size, file, line); } diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index 42724df1a54..dc2143ec9da 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -175,6 +175,7 @@ struct _tms5110_state INT32 speech_rom_bitnum; emu_timer *romclk_timer; + UINT8 romclk_timer_started; UINT8 romclk_state; }; @@ -206,6 +207,7 @@ static void tms5110_PDC_set(tms5110_state *tms, int data); static void tms5110_process(tms5110_state *tms, INT16 *buffer, unsigned int size); static void parse_frame(tms5110_state *tms); static STREAM_UPDATE( tms5110_update ); +static TIMER_CALLBACK( romclk_timer_cb ); #define DEBUG_5110 0 @@ -964,6 +966,7 @@ static DEVICE_START( tms5110 ) } tms->state = CTL_STATE_INPUT; /* most probably not defined */ + tms->romclk_timer = timer_alloc(device->machine, romclk_timer_cb, (void *) device); register_for_save_states(tms); } @@ -1139,11 +1142,11 @@ READ8_DEVICE_HANDLER( tms5110_romclk_r ) stream_update(tms->stream); /* create and start timer if necessary */ - if (tms->romclk_timer == NULL) + if (!tms->romclk_timer_started) { - tms->romclk_timer = timer_alloc(device->machine, romclk_timer_cb, (void *) device); - timer_adjust_periodic(tms->romclk_timer, ATTOTIME_IN_HZ(device->clock / 40), 0, ATTOTIME_IN_HZ(device->clock / 40)); - } + tms->romclk_timer_started = TRUE; + timer_adjust_periodic(tms->romclk_timer, ATTOTIME_IN_HZ(device->clock / 40), 0, ATTOTIME_IN_HZ(device->clock / 40)); + } return tms->romclk_state; } diff --git a/src/mame/audio/jaguar.c b/src/mame/audio/jaguar.c index cb89e919e65..3861216fef2 100644 --- a/src/mame/audio/jaguar.c +++ b/src/mame/audio/jaguar.c @@ -166,19 +166,11 @@ enum static UINT16 dsp_regs[DSP_REGS]; static UINT16 serial_frequency; -static emu_timer *serial_timer; static UINT8 gpu_irq_state; #if ENABLE_SPEEDUP_HACKS - -static TIMER_CALLBACK( serial_chunky_callback ); static WRITE32_HANDLER( dsp_flags_w ); - -#else - -static TIMER_CALLBACK( serial_callback ); - #endif @@ -276,23 +268,6 @@ void cojag_sound_init(running_machine *machine) -/************************************* - * - * Sound reset - * - *************************************/ - -void cojag_sound_reset(running_machine *machine) -{ -#if ENABLE_SPEEDUP_HACKS - serial_timer = timer_alloc(machine, serial_chunky_callback, NULL); -#else - serial_timer = timer_alloc(machine, serial_callback, NULL); -#endif -} - - - /************************************* * * Jerry 16-bit register access @@ -390,11 +365,11 @@ static WRITE32_HANDLER( dsp_flags_w ) #if ENABLE_SPEEDUP_HACKS -static TIMER_CALLBACK( serial_chunky_callback ) +TIMER_DEVICE_CALLBACK( jaguar_serial_callback ) { /* assert the A2S IRQ on CPU #2 (DSP) */ - cputag_set_input_line(machine, "audiocpu", 1, ASSERT_LINE); - jaguar_dsp_resume(machine); + cputag_set_input_line(timer->machine, "audiocpu", 1, ASSERT_LINE); + jaguar_dsp_resume(timer->machine); /* fix flaky code in interrupt handler which thwarts our speedup */ if ((jaguar_dsp_ram[0x3e/4] & 0xffff) == 0xbfbc && @@ -409,11 +384,11 @@ static TIMER_CALLBACK( serial_chunky_callback ) #else -static TIMER_CALLBACK( serial_callback ) +TIMER_DEVICE_CALLBACK( jaguar_serial_callback ) { /* assert the A2S IRQ on CPU #2 (DSP) */ - cputag_set_input_line(machine, "audiocpu", 1, ASSERT_LINE); - jaguar_dsp_resume(machine); + cputag_set_input_line(timer->machine, "audiocpu", 1, ASSERT_LINE); + jaguar_dsp_resume(timer->machine); } #endif @@ -459,7 +434,7 @@ WRITE32_HANDLER( jaguar_serial_w ) if ((data & 0x3f) == 0x15) { attotime rate = attotime_mul(ATTOTIME_IN_HZ(26000000), 32 * 2 * (serial_frequency + 1)); - timer_adjust_periodic(serial_timer, rate, 0, rate); + timer_device_adjust_periodic(devtag_get_device(space->machine, "serial_timer"), rate, 0, rate); } break; diff --git a/src/mame/audio/scramble.c b/src/mame/audio/scramble.c index dd8504ff48c..4ee9c4d8f93 100644 --- a/src/mame/audio/scramble.c +++ b/src/mame/audio/scramble.c @@ -79,9 +79,11 @@ READ8_DEVICE_HANDLER( frogger_portB_r ) WRITE8_DEVICE_HANDLER( scramble_sh_irqtrigger_w ) { + const device_config *target = devtag_get_device(device->machine, "konami_7474"); + /* the complement of bit 3 is connected to the flip-flop's clock */ - TTL7474_clock_w(2, ~data & 0x08); - TTL7474_update(device->machine, 2); + ttl7474_clock_w(target, ~data & 0x08); + ttl7474_update(target); /* bit 4 is sound disable */ sound_global_enable(device->machine, ~data & 0x10); @@ -89,39 +91,34 @@ WRITE8_DEVICE_HANDLER( scramble_sh_irqtrigger_w ) WRITE8_DEVICE_HANDLER( mrkougar_sh_irqtrigger_w ) { - /* the complement of bit 3 is connected to the flip-flop's clock */ - TTL7474_clock_w(2, ~data & 0x08); - TTL7474_update(device->machine, 2); -} + const device_config *target = devtag_get_device(device->machine, "konami_7474"); -#ifdef UNUSED_FUNCTION -WRITE8_HANDLER( froggrmc_sh_irqtrigger_w ) -{ - /* the complement of bit 0 is connected to the flip-flop's clock */ - TTL7474_clock_w(2, ~data & 0x01); - TTL7474_update(space->machine, 2); + /* the complement of bit 3 is connected to the flip-flop's clock */ + ttl7474_clock_w(target, ~data & 0x08); + ttl7474_update(target); } -#endif static IRQ_CALLBACK(scramble_sh_irq_callback) { + const device_config *target = devtag_get_device(device->machine, "konami_7474"); + /* interrupt acknowledge clears the flip-flop -- we need to pulse the CLR line because MAME's core never clears this line, only asserts it */ - TTL7474_clear_w(2, 0); - TTL7474_update(device->machine, 2); + ttl7474_clear_w(target, 0); + ttl7474_update(target); - TTL7474_clear_w(2, 1); - TTL7474_update(device->machine, 2); + ttl7474_clear_w(target, 1); + ttl7474_update(target); return 0xff; } -static void scramble_sh_7474_callback(running_machine *machine) +void scramble_sh_7474_callback(const device_config *device) { /* the Q bar is connected to the Z80's INT line. But since INT is complemented, */ /* we need to complement Q bar */ - cputag_set_input_line(machine, "audiocpu", 0, !TTL7474_output_comp_r(2) ? ASSERT_LINE : CLEAR_LINE); + cputag_set_input_line(device->machine, "audiocpu", 0, !ttl7474_output_comp_r(device) ? ASSERT_LINE : CLEAR_LINE); } WRITE8_HANDLER( hotshock_sh_irqtrigger_w ) @@ -166,19 +163,12 @@ WRITE8_HANDLER( frogger_filter_w ) filter_w(devtag_get_device(space->machine, "filter.0.2"), (offset >> 10) & 3); } -static const struct TTL7474_interface scramble_sh_7474_intf = -{ - scramble_sh_7474_callback -}; - void scramble_sh_init(running_machine *machine) { cpu_set_irq_callback(cputag_get_cpu(machine, "audiocpu"), scramble_sh_irq_callback); - TTL7474_config(machine, 2, &scramble_sh_7474_intf); - /* PR is always 0, D is always 1 */ - TTL7474_d_w(2, 1); + ttl7474_d_w(devtag_get_device(machine, "konami_7474"), 1); } diff --git a/src/mame/drivers/artmagic.c b/src/mame/drivers/artmagic.c index 74381098553..91d1c299e64 100644 --- a/src/mame/drivers/artmagic.c +++ b/src/mame/drivers/artmagic.c @@ -94,7 +94,6 @@ static MACHINE_RESET( artmagic ) tms_irq = hack_irq = 0; update_irq_state(machine); tlc34076_reset(6); - tlc34076_state_save(machine); } diff --git a/src/mame/drivers/badlands.c b/src/mame/drivers/badlands.c index dd84a02994b..7062171be26 100644 --- a/src/mame/drivers/badlands.c +++ b/src/mame/drivers/badlands.c @@ -198,7 +198,11 @@ static void scanline_update(const device_config *screen, int scanline) static MACHINE_START( badlands ) { + badlands_state *state = (badlands_state *)machine->driver_data; + atarigen_init(machine); + + state_save_register_global_array(machine, state->pedal_value); } @@ -214,8 +218,6 @@ static MACHINE_RESET( badlands ) atarigen_sound_io_reset(cputag_get_cpu(machine, "audiocpu")); memcpy(state->bank_base, &state->bank_source_data[0x0000], 0x1000); - - state_save_register_global_array(machine, state->pedal_value); } diff --git a/src/mame/drivers/carpolo.c b/src/mame/drivers/carpolo.c index 01de4e105fa..57c8e96ba6b 100644 --- a/src/mame/drivers/carpolo.c +++ b/src/mame/drivers/carpolo.c @@ -18,6 +18,9 @@ #include "driver.h" #include "cpu/m6502/m6502.h" +#include "machine/7474.h" +#include "machine/74148.h" +#include "machine/74153.h" #include "machine/6821pia.h" #include "carpolo.h" @@ -241,6 +244,22 @@ static MACHINE_DRIVER_START( carpolo ) MDRV_PIA6821_ADD("pia0", carpolo_pia0_intf) MDRV_PIA6821_ADD("pia1", carpolo_pia1_intf) + MDRV_7474_ADD("7474_2s_1", carpolo_7474_2s_1_cb) + MDRV_7474_ADD("7474_2s_2", carpolo_7474_2s_2_cb) + MDRV_7474_ADD("7474_2u_1", carpolo_7474_2u_1_cb) + MDRV_7474_ADD("7474_2u_2", carpolo_7474_2u_2_cb) + MDRV_7474_ADD("7474_1f_1", NULL) + MDRV_7474_ADD("7474_1f_2", NULL) + MDRV_7474_ADD("7474_1d_1", NULL) + MDRV_7474_ADD("7474_1d_2", NULL) + MDRV_7474_ADD("7474_1c_1", NULL) + MDRV_7474_ADD("7474_1c_2", NULL) + MDRV_7474_ADD("7474_1a_1", NULL) + MDRV_7474_ADD("7474_1a_2", NULL) + + MDRV_74148_ADD("74148_3s", carpolo_74148_3s_cb) + MDRV_74153_ADD("74153_1k", NULL) + /* video hardware */ MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_REFRESH_RATE(60) diff --git a/src/mame/drivers/cninja.c b/src/mame/drivers/cninja.c index c72d706fd03..87241c66f75 100644 --- a/src/mame/drivers/cninja.c +++ b/src/mame/drivers/cninja.c @@ -53,7 +53,7 @@ Note about version levels using Mutant Fighter as the example: #include "sound/okim6295.h" static int cninja_scanline, cninja_irq_mask; -static emu_timer *raster_irq_timer; +static const device_config *raster_irq_timer; static UINT16 *cninja_ram; /**********************************************************************************/ @@ -70,7 +70,7 @@ static WRITE16_HANDLER( stoneage_sound_w ) cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE); } -static TIMER_CALLBACK( interrupt_gen ) +static TIMER_DEVICE_CALLBACK( interrupt_gen ) { int scanline = param; @@ -85,8 +85,8 @@ static TIMER_CALLBACK( interrupt_gen ) deco16_raster_display_list[deco16_raster_display_position++] = deco16_pf34_control[3] & 0xffff; deco16_raster_display_list[deco16_raster_display_position++] = deco16_pf34_control[4] & 0xffff; - cputag_set_input_line(machine, "maincpu", (cninja_irq_mask&0x10) ? 3 : 4, ASSERT_LINE); - timer_adjust_oneshot(raster_irq_timer, attotime_never, 0); + cputag_set_input_line(timer->machine, "maincpu", (cninja_irq_mask&0x10) ? 3 : 4, ASSERT_LINE); + timer_device_adjust_oneshot(raster_irq_timer, attotime_never, 0); } static READ16_HANDLER( cninja_irq_r ) @@ -122,9 +122,9 @@ static WRITE16_HANDLER( cninja_irq_w ) case 1: /* Raster IRQ scanline position, only valid for values between 1 & 239 (0 and 240-256 do NOT generate IRQ's) */ cninja_scanline=data&0xff; if ((cninja_irq_mask&0x2)==0 && cninja_scanline>0 && cninja_scanline<240) - timer_adjust_oneshot(raster_irq_timer, video_screen_get_time_until_pos(space->machine->primary_screen, cninja_scanline, 0), cninja_scanline); + timer_device_adjust_oneshot(raster_irq_timer, video_screen_get_time_until_pos(space->machine->primary_screen, cninja_scanline, 0), cninja_scanline); else - timer_adjust_oneshot(raster_irq_timer,attotime_never,0); + timer_device_adjust_oneshot(raster_irq_timer,attotime_never,0); return; case 2: /* VBL irq ack */ @@ -654,7 +654,7 @@ GFXDECODE_END static MACHINE_RESET( cninja ) { - raster_irq_timer = timer_alloc(machine, interrupt_gen, NULL); + raster_irq_timer = devtag_get_device(machine, "raster_timer"); cninja_scanline=0; cninja_irq_mask=0; } @@ -699,6 +699,8 @@ static MACHINE_DRIVER_START( cninja ) MDRV_CPU_PROGRAM_MAP(sound_map) MDRV_MACHINE_RESET(cninja) + + MDRV_TIMER_ADD("raster_timer", interrupt_gen) /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) @@ -748,6 +750,8 @@ static MACHINE_DRIVER_START( stoneage ) MDRV_MACHINE_RESET(cninja) + MDRV_TIMER_ADD("raster_timer", interrupt_gen) + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) @@ -793,6 +797,8 @@ static MACHINE_DRIVER_START( edrandy ) MDRV_MACHINE_RESET(cninja) + MDRV_TIMER_ADD("raster_timer", interrupt_gen) + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) @@ -841,6 +847,8 @@ static MACHINE_DRIVER_START( robocop2 ) MDRV_MACHINE_RESET(cninja) + MDRV_TIMER_ADD("raster_timer", interrupt_gen) + /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) diff --git a/src/mame/drivers/cojag.c b/src/mame/drivers/cojag.c index 72fafaf7d33..b364d1f7fe7 100644 --- a/src/mame/drivers/cojag.c +++ b/src/mame/drivers/cojag.c @@ -371,12 +371,6 @@ static MACHINE_RESET( cojag ) /* halt the CPUs */ jaguargpu_ctrl_w(cputag_get_cpu(machine, "gpu"), G_CTRL, 0, 0xffffffff); jaguardsp_ctrl_w(cputag_get_cpu(machine, "audiocpu"), D_CTRL, 0, 0xffffffff); - - /* init the sound system */ - cojag_sound_reset(machine); - - /* reset the IDE controller */ - devtag_reset(machine, "ide"); } @@ -1122,6 +1116,8 @@ static MACHINE_DRIVER_START( cojagr3k ) MDRV_NVRAM_HANDLER(generic_1fill) MDRV_IDE_CONTROLLER_ADD("ide", jaguar_external_int) + + MDRV_TIMER_ADD("serial_timer", jaguar_serial_callback) /* video hardware */ MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) diff --git a/src/mame/drivers/coolpool.c b/src/mame/drivers/coolpool.c index b8361e6c12d..b3a078a01e5 100644 --- a/src/mame/drivers/coolpool.c +++ b/src/mame/drivers/coolpool.c @@ -54,18 +54,6 @@ static const UINT16 nvram_unlock_seq[] = #define NVRAM_UNLOCK_SEQ_LEN (ARRAY_LENGTH(nvram_unlock_seq)) static UINT16 nvram_write_seq[NVRAM_UNLOCK_SEQ_LEN]; static UINT8 nvram_write_enable; -static emu_timer *nvram_write_timer; - - - -/************************************* - * - * Prototypes - * - *************************************/ - -static TIMER_CALLBACK( nvram_write_timeout ); - @@ -148,7 +136,6 @@ static void coolpool_from_shiftreg(const address_space *space, UINT32 address, U static MACHINE_RESET( amerdart ) { nvram_write_enable = 0; - nvram_write_timer = timer_alloc(machine, nvram_write_timeout, NULL); } @@ -156,7 +143,6 @@ static MACHINE_RESET( coolpool ) { tlc34076_reset(6); nvram_write_enable = 0; - nvram_write_timer = timer_alloc(machine, nvram_write_timeout, NULL); } @@ -167,7 +153,7 @@ static MACHINE_RESET( coolpool ) * *************************************/ -static TIMER_CALLBACK( nvram_write_timeout ) +static TIMER_DEVICE_CALLBACK( nvram_write_timeout ) { nvram_write_enable = 0; } @@ -183,7 +169,7 @@ static WRITE16_HANDLER( nvram_thrash_w ) if (!memcmp(nvram_unlock_seq, nvram_write_seq, sizeof(nvram_unlock_seq))) { nvram_write_enable = 1; - timer_adjust_oneshot(nvram_write_timer, ATTOTIME_IN_MSEC(1000), 0); + timer_device_adjust_oneshot(devtag_get_device(space->machine, "nvram_timer"), ATTOTIME_IN_MSEC(1000), 0); } } @@ -695,6 +681,8 @@ static MACHINE_DRIVER_START( amerdart ) MDRV_MACHINE_RESET(amerdart) MDRV_NVRAM_HANDLER(generic_0fill) + MDRV_TIMER_ADD("nvram_timer", nvram_write_timeout) + /* video hardware */ MDRV_VIDEO_UPDATE(tms340x0) @@ -724,6 +712,8 @@ static MACHINE_DRIVER_START( coolpool ) MDRV_MACHINE_RESET(coolpool) MDRV_NVRAM_HANDLER(generic_0fill) + MDRV_TIMER_ADD("nvram_timer", nvram_write_timeout) + /* video hardware */ MDRV_VIDEO_UPDATE(tms340x0) diff --git a/src/mame/drivers/galaxold.c b/src/mame/drivers/galaxold.c index b8700fdfefd..b0638014132 100644 --- a/src/mame/drivers/galaxold.c +++ b/src/mame/drivers/galaxold.c @@ -351,6 +351,7 @@ TO DO : #include "cpu/z80/z80.h" #include "cpu/s2650/s2650.h" #include "galaxold.h" +#include "machine/7474.h" #include "sound/ay8910.h" #include "sound/sn76496.h" #include "sound/dac.h" @@ -2107,6 +2108,9 @@ static MACHINE_DRIVER_START( galaxold_base ) MDRV_CPU_PROGRAM_MAP(galaxold_map) MDRV_MACHINE_RESET(galaxold) + + MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback) + MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback) /* video hardware */ MDRV_GFXDECODE(galaxian) diff --git a/src/mame/drivers/scobra.c b/src/mame/drivers/scobra.c index 8b92e88dc22..05929f37f6b 100644 --- a/src/mame/drivers/scobra.c +++ b/src/mame/drivers/scobra.c @@ -35,6 +35,7 @@ Notes/Tidbits: #include "driver.h" #include "cpu/z80/z80.h" #include "machine/8255ppi.h" +#include "machine/7474.h" #include "galaxold.h" #include "sound/ay8910.h" @@ -859,6 +860,8 @@ static MACHINE_DRIVER_START( type1 ) MDRV_CPU_PROGRAM_MAP(scobra_sound_map) MDRV_CPU_IO_MAP(scobra_sound_io_map) + MDRV_7474_ADD("konami_7474", scramble_sh_7474_callback) + MDRV_MACHINE_RESET(scramble) MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf ) @@ -983,6 +986,8 @@ static MACHINE_DRIVER_START( hustler ) MDRV_CPU_PROGRAM_MAP(hustler_sound_map) MDRV_CPU_IO_MAP(hustler_sound_io_map) + MDRV_7474_ADD("konami_7474", scramble_sh_7474_callback) + MDRV_MACHINE_RESET(scramble) /* device config overrides */ diff --git a/src/mame/drivers/scramble.c b/src/mame/drivers/scramble.c index 969bd289ddd..f28f39f783b 100644 --- a/src/mame/drivers/scramble.c +++ b/src/mame/drivers/scramble.c @@ -31,6 +31,7 @@ Notes: #include "sound/ay8910.h" #include "sound/dac.h" #include "sound/flt_rc.h" +#include "machine/7474.h" #include "machine/8255ppi.h" #include "galaxold.h" @@ -1242,6 +1243,10 @@ static MACHINE_DRIVER_START( scramble ) MDRV_CPU_PROGRAM_MAP(scramble_sound_map) MDRV_CPU_IO_MAP(scramble_sound_io_map) + MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback) + MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback) + MDRV_7474_ADD("konami_7474", scramble_sh_7474_callback) + MDRV_MACHINE_RESET(scramble) MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf ) @@ -1471,6 +1476,10 @@ static MACHINE_DRIVER_START( ad2083 ) MDRV_CPU_ADD("maincpu", Z80, 18432000/6) /* 3.072 MHz */ MDRV_CPU_PROGRAM_MAP(ad2083_map) + MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback) + MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback) + MDRV_7474_ADD("konami_7474", scramble_sh_7474_callback) + MDRV_MACHINE_RESET(galaxold) /* video hardware */ diff --git a/src/mame/drivers/vertigo.c b/src/mame/drivers/vertigo.c index 82803919b15..b58fe014054 100644 --- a/src/mame/drivers/vertigo.c +++ b/src/mame/drivers/vertigo.c @@ -15,6 +15,7 @@ #include "video/vector.h" #include "vertigo.h" #include "exidy440.h" +#include "machine/74148.h" #include "machine/pit8253.h" @@ -113,6 +114,8 @@ static MACHINE_DRIVER_START( vertigo ) MDRV_IMPORT_FROM(exidy440_audio) MDRV_PIT8254_ADD( "pit8254", vertigo_pit8254_config ) + + MDRV_74148_ADD( "74148", vertigo_update_irq ) /* motor controller */ /* diff --git a/src/mame/includes/carpolo.h b/src/mame/includes/carpolo.h index af54fcfb135..9187ea1d08f 100644 --- a/src/mame/includes/carpolo.h +++ b/src/mame/includes/carpolo.h @@ -13,6 +13,13 @@ extern const pia6821_interface carpolo_pia0_intf; extern const pia6821_interface carpolo_pia1_intf; +void carpolo_74148_3s_cb(const device_config *device); + +void carpolo_7474_2s_1_cb(const device_config *device); +void carpolo_7474_2s_2_cb(const device_config *device); +void carpolo_7474_2u_1_cb(const device_config *device); +void carpolo_7474_2u_2_cb(const device_config *device); + MACHINE_START( carpolo ); MACHINE_RESET( carpolo ); diff --git a/src/mame/includes/galaxold.h b/src/mame/includes/galaxold.h index a582978133f..33437a9b397 100644 --- a/src/mame/includes/galaxold.h +++ b/src/mame/includes/galaxold.h @@ -98,6 +98,9 @@ WRITE8_HANDLER( galaxold_flip_screen_y_w ); /*----------- defined in machine/galaxold.c -----------*/ +void galaxold_7474_9m_2_callback(const device_config *device); +void galaxold_7474_9m_1_callback(const device_config *device); + DRIVER_INIT( 4in1 ); DRIVER_INIT( ladybugg ); @@ -167,6 +170,7 @@ CUSTOM_INPUT( darkplnt_custom_r ); /*----------- defined in audio/scramble.c -----------*/ void scramble_sh_init(running_machine *machine); +void scramble_sh_7474_callback(const device_config *device); WRITE8_HANDLER( scramble_filter_w ); WRITE8_HANDLER( frogger_filter_w ); diff --git a/src/mame/includes/jaguar.h b/src/mame/includes/jaguar.h index a1b0988c21d..47ab05cc959 100644 --- a/src/mame/includes/jaguar.h +++ b/src/mame/includes/jaguar.h @@ -29,6 +29,8 @@ extern UINT32 *jaguar_wave_rom; /*----------- defined in audio/jaguar.c -----------*/ +TIMER_DEVICE_CALLBACK( jaguar_serial_callback ); + void jaguar_dsp_suspend(running_machine *machine); void jaguar_dsp_resume(running_machine *machine); diff --git a/src/mame/includes/vertigo.h b/src/mame/includes/vertigo.h index d98b99fbd29..9a8550e240f 100644 --- a/src/mame/includes/vertigo.h +++ b/src/mame/includes/vertigo.h @@ -6,6 +6,8 @@ /*----------- defined in machine/vertigo.c -----------*/ +void vertigo_update_irq(const device_config *device); + extern const struct pit8253_config vertigo_pit8254_config; READ16_HANDLER( vertigo_io_convert ); diff --git a/src/mame/machine/carpolo.c b/src/mame/machine/carpolo.c index 99fea0576c4..7b5b47d27a7 100644 --- a/src/mame/machine/carpolo.c +++ b/src/mame/machine/carpolo.c @@ -58,23 +58,6 @@ #define CAR_BORDER_EXTRA_BITS 0x50 -#define TTL74148_3S 0 - -#define TTL74153_1K 0 - -#define TTL7474_2S_1 0 -#define TTL7474_2S_2 1 -#define TTL7474_2U_1 2 -#define TTL7474_2U_2 3 -#define TTL7474_1F_1 4 -#define TTL7474_1F_2 5 -#define TTL7474_1D_1 6 -#define TTL7474_1D_2 7 -#define TTL7474_1C_1 8 -#define TTL7474_1C_2 9 -#define TTL7474_1A_1 10 -#define TTL7474_1A_2 11 - static UINT8 ball_screen_collision_cause; static UINT8 car_ball_collision_x; @@ -86,36 +69,53 @@ static UINT8 car_border_collision_cause; static UINT8 priority_0_extension; static UINT8 last_wheel_value[4]; +static const device_config *ttl74148_3s; -static void TTL74148_3S_cb(running_machine *machine) +static const device_config *ttl74153_1k; + +static const device_config *ttl7474_2s_1; +static const device_config *ttl7474_2s_2; +static const device_config *ttl7474_2u_1; +static const device_config *ttl7474_2u_2; +static const device_config *ttl7474_1f_1; +static const device_config *ttl7474_1f_2; +static const device_config *ttl7474_1d_1; +static const device_config *ttl7474_1d_2; +static const device_config *ttl7474_1c_1; +static const device_config *ttl7474_1c_2; +static const device_config *ttl7474_1a_1; +static const device_config *ttl7474_1a_2; + + +void carpolo_74148_3s_cb(const device_config *device) { - cputag_set_input_line(machine, "maincpu", M6502_IRQ_LINE, TTL74148_output_valid_r(TTL74148_3S) ? CLEAR_LINE : ASSERT_LINE); + cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, ttl74148_output_valid_r(device) ? CLEAR_LINE : ASSERT_LINE); } /* the outputs of the flip-flops are connected to the priority encoder */ -static void TTL7474_2S_1_cb(running_machine *machine) +void carpolo_7474_2s_1_cb(const device_config *device) { - TTL74148_input_line_w(TTL74148_3S, COIN1_PRIORITY_LINE, TTL7474_output_comp_r(TTL7474_2S_1)); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, COIN1_PRIORITY_LINE, ttl7474_output_comp_r(device)); + ttl74148_update(ttl74148_3s); } -static void TTL7474_2S_2_cb(running_machine *machine) +void carpolo_7474_2s_2_cb(const device_config *device) { - TTL74148_input_line_w(TTL74148_3S, COIN2_PRIORITY_LINE, TTL7474_output_comp_r(TTL7474_2S_2)); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, COIN2_PRIORITY_LINE, ttl7474_output_comp_r(device)); + ttl74148_update(ttl74148_3s); } -static void TTL7474_2U_1_cb(running_machine *machine) +void carpolo_7474_2u_1_cb(const device_config *device) { - TTL74148_input_line_w(TTL74148_3S, COIN3_PRIORITY_LINE, TTL7474_output_comp_r(TTL7474_2U_1)); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, COIN3_PRIORITY_LINE, ttl7474_output_comp_r(device)); + ttl74148_update(ttl74148_3s); } -static void TTL7474_2U_2_cb(running_machine *machine) +void carpolo_7474_2u_2_cb(const device_config *device) { - TTL74148_input_line_w(TTL74148_3S, COIN4_PRIORITY_LINE, TTL7474_output_comp_r(TTL7474_2U_2)); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, COIN4_PRIORITY_LINE, ttl7474_output_comp_r(device)); + ttl74148_update(ttl74148_3s); } @@ -123,24 +123,24 @@ void carpolo_generate_ball_screen_interrupt(running_machine *machine, UINT8 caus { ball_screen_collision_cause = cause; - TTL74148_input_line_w(TTL74148_3S, BALL_SCREEN_PRIORITY_LINE, 0); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, BALL_SCREEN_PRIORITY_LINE, 0); + ttl74148_update(ttl74148_3s); } void carpolo_generate_car_car_interrupt(running_machine *machine, int car1, int car2) { car_car_collision_cause = ~((1 << (3 - car1)) | (1 << (3 - car2))); - TTL74148_input_line_w(TTL74148_3S, CAR_CAR_PRIORITY_LINE, 0); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, CAR_CAR_PRIORITY_LINE, 0); + ttl74148_update(ttl74148_3s); } void carpolo_generate_car_goal_interrupt(running_machine *machine, int car, int right_goal) { car_goal_collision_cause = car | (right_goal ? 0x08 : 0x00); - TTL74148_input_line_w(TTL74148_3S, CAR_GOAL_PRIORITY_LINE, 0); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, CAR_GOAL_PRIORITY_LINE, 0); + ttl74148_update(ttl74148_3s); } void carpolo_generate_car_ball_interrupt(running_machine *machine, int car, int car_x, int car_y) @@ -151,8 +151,8 @@ void carpolo_generate_car_ball_interrupt(running_machine *machine, int car, int priority_0_extension = CAR_BALL_EXTRA_BITS; - TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 0); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 0); + ttl74148_update(ttl74148_3s); } void carpolo_generate_car_border_interrupt(running_machine *machine, int car, int horizontal_border) @@ -161,8 +161,8 @@ void carpolo_generate_car_border_interrupt(running_machine *machine, int car, in priority_0_extension = CAR_BORDER_EXTRA_BITS; - TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 0); - TTL74148_update(machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 0); + ttl74148_update(ttl74148_3s); } @@ -222,7 +222,7 @@ READ8_HANDLER( carpolo_car_border_collision_cause_r ) READ8_HANDLER( carpolo_interrupt_cause_r ) { /* the output of the 148 goes to bits 1-3 (which is priority ^ 7) */ - return (TTL74148_output_r(TTL74148_3S) << 1) | priority_0_extension; + return (ttl74148_output_r(ttl74148_3s) << 1) | priority_0_extension; } @@ -233,49 +233,57 @@ INTERRUPT_GEN( carpolo_timer_interrupt ) /* cause the timer interrupt */ - TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 0); + ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 0); priority_0_extension = TIMER_EXTRA_BITS; - TTL74148_update(device->machine, TTL74148_3S); + ttl74148_update(ttl74148_3s); /* check the coins here as well - they drive the clock of the flip-flops */ port_value = input_port_read(device->machine, "IN0"); - TTL7474_clock_w(TTL7474_2S_1, port_value & 0x01); - TTL7474_clock_w(TTL7474_2S_2, port_value & 0x02); - TTL7474_clock_w(TTL7474_2U_1, port_value & 0x04); - TTL7474_clock_w(TTL7474_2U_2, port_value & 0x08); + ttl7474_clock_w(ttl7474_2s_1, port_value & 0x01); + ttl7474_clock_w(ttl7474_2s_2, port_value & 0x02); + ttl7474_clock_w(ttl7474_2u_1, port_value & 0x04); + ttl7474_clock_w(ttl7474_2u_2, port_value & 0x08); - TTL7474_update(device->machine, TTL7474_2S_1); - TTL7474_update(device->machine, TTL7474_2S_2); - TTL7474_update(device->machine, TTL7474_2U_1); - TTL7474_update(device->machine, TTL7474_2U_2); + ttl7474_update(ttl7474_2s_1); + ttl7474_update(ttl7474_2s_2); + ttl7474_update(ttl7474_2u_1); + ttl7474_update(ttl7474_2u_2); /* read the steering controls */ for (player = 0; player < 4; player++) { - int movement_flip_flop = TTL7474_1F_1 + (2 * player); - int dir_flip_flop = movement_flip_flop + 1; static const char *const portnames[] = { "DIAL0", "DIAL1", "DIAL2", "DIAL3" }; + const device_config *movement_flip_flop; + const device_config *dir_flip_flop; + + switch (player) + { + case 0: movement_flip_flop = ttl7474_1f_1; dir_flip_flop = ttl7474_1f_2; break; + case 1: movement_flip_flop = ttl7474_1d_1; dir_flip_flop = ttl7474_1d_2; break; + case 2: movement_flip_flop = ttl7474_1c_1; dir_flip_flop = ttl7474_1c_2; break; + case 3: movement_flip_flop = ttl7474_1a_1; dir_flip_flop = ttl7474_1a_2; break; + } port_value = input_port_read(device->machine, portnames[player]); if (port_value != last_wheel_value[player]) { /* set the movement direction */ - TTL7474_d_w(dir_flip_flop, ((port_value - last_wheel_value[player]) & 0x80) ? 1 : 0); + ttl7474_d_w(dir_flip_flop, ((port_value - last_wheel_value[player]) & 0x80) ? 1 : 0); last_wheel_value[player] = port_value; } /* as the wheel moves, both flip-flops are clocked */ - TTL7474_clock_w(movement_flip_flop, port_value & 0x01); - TTL7474_clock_w(dir_flip_flop, port_value & 0x01); + ttl7474_clock_w(movement_flip_flop, port_value & 0x01); + ttl7474_clock_w(dir_flip_flop, port_value & 0x01); - TTL7474_update(device->machine, movement_flip_flop); - TTL7474_update(device->machine, dir_flip_flop); + ttl7474_update(movement_flip_flop); + ttl7474_update(dir_flip_flop); } @@ -289,85 +297,85 @@ INTERRUPT_GEN( carpolo_timer_interrupt ) how much, resulting in only two different possible levels */ if (port_value & 0x01) { - TTL74153_input_line_w(TTL74153_1K, 0, player, 1); - TTL74153_input_line_w(TTL74153_1K, 1, player, 0); + ttl74153_input_line_w(ttl74153_1k, 0, player, 1); + ttl74153_input_line_w(ttl74153_1k, 1, player, 0); } else if (port_value & 0x02) { - TTL74153_input_line_w(TTL74153_1K, 0, player, 1); - TTL74153_input_line_w(TTL74153_1K, 1, player, 1); + ttl74153_input_line_w(ttl74153_1k, 0, player, 1); + ttl74153_input_line_w(ttl74153_1k, 1, player, 1); } else { - TTL74153_input_line_w(TTL74153_1K, 0, player, 0); + ttl74153_input_line_w(ttl74153_1k, 0, player, 0); /* the other line is irrelevant */ } port_value >>= 2; } - TTL74153_update(TTL74153_1K); + ttl74153_update(ttl74153_1k); } static WRITE_LINE_DEVICE_HANDLER( coin1_interrupt_clear_w ) { - TTL7474_clear_w(TTL7474_2S_1, state); - TTL7474_update(device->machine, TTL7474_2S_1); + ttl7474_clear_w(ttl7474_2s_1, state); + ttl7474_update(ttl7474_2s_1); } static WRITE_LINE_DEVICE_HANDLER( coin2_interrupt_clear_w ) { - TTL7474_clear_w(TTL7474_2S_2, state); - TTL7474_update(device->machine, TTL7474_2S_2); + ttl7474_clear_w(ttl7474_2s_2, state); + ttl7474_update(ttl7474_2s_2); } static WRITE_LINE_DEVICE_HANDLER( coin3_interrupt_clear_w ) { - TTL7474_clear_w(TTL7474_2U_1, state); - TTL7474_update(device->machine, TTL7474_2U_1); + ttl7474_clear_w(ttl7474_2u_1, state); + ttl7474_update(ttl7474_2u_1); } static WRITE_LINE_DEVICE_HANDLER( coin4_interrupt_clear_w ) { - TTL7474_clear_w(TTL7474_2U_2, state); - TTL7474_update(device->machine, TTL7474_2U_2); + ttl7474_clear_w(ttl7474_2u_2, state); + ttl7474_update(ttl7474_2u_2); } WRITE8_HANDLER( carpolo_ball_screen_interrupt_clear_w ) { - TTL74148_input_line_w(TTL74148_3S, BALL_SCREEN_PRIORITY_LINE, 1); - TTL74148_update(space->machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, BALL_SCREEN_PRIORITY_LINE, 1); + ttl74148_update(ttl74148_3s); } WRITE8_HANDLER( carpolo_car_car_interrupt_clear_w ) { - TTL74148_input_line_w(TTL74148_3S, CAR_CAR_PRIORITY_LINE, 1); - TTL74148_update(space->machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, CAR_CAR_PRIORITY_LINE, 1); + ttl74148_update(ttl74148_3s); } WRITE8_HANDLER( carpolo_car_goal_interrupt_clear_w ) { - TTL74148_input_line_w(TTL74148_3S, CAR_GOAL_PRIORITY_LINE, 1); - TTL74148_update(space->machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, CAR_GOAL_PRIORITY_LINE, 1); + ttl74148_update(ttl74148_3s); } WRITE8_HANDLER( carpolo_car_ball_interrupt_clear_w ) { - TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 1); - TTL74148_update(space->machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 1); + ttl74148_update(ttl74148_3s); } WRITE8_HANDLER( carpolo_car_border_interrupt_clear_w ) { - TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 1); - TTL74148_update(space->machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 1); + ttl74148_update(ttl74148_3s); } WRITE8_HANDLER( carpolo_timer_interrupt_clear_w ) { - TTL74148_input_line_w(TTL74148_3S, PRI0_PRIORTITY_LINE, 1); - TTL74148_update(space->machine, TTL74148_3S); + ttl74148_input_line_w(ttl74148_3s, PRI0_PRIORTITY_LINE, 1); + ttl74148_update(ttl74148_3s); } @@ -391,15 +399,15 @@ static WRITE8_DEVICE_HANDLER( pia_0_port_a_w ) coin_counter_w(device->machine, 0, data & 0x01); - TTL7474_clear_w(TTL7474_1F_1, data & 0x08); - TTL7474_clear_w(TTL7474_1D_1, data & 0x08); - TTL7474_clear_w(TTL7474_1C_1, data & 0x08); - TTL7474_clear_w(TTL7474_1A_1, data & 0x08); + ttl7474_clear_w(ttl7474_1f_1, data & 0x08); + ttl7474_clear_w(ttl7474_1d_1, data & 0x08); + ttl7474_clear_w(ttl7474_1c_1, data & 0x08); + ttl7474_clear_w(ttl7474_1a_1, data & 0x08); - TTL7474_update(device->machine, TTL7474_1F_1); - TTL7474_update(device->machine, TTL7474_1D_1); - TTL7474_update(device->machine, TTL7474_1C_1); - TTL7474_update(device->machine, TTL7474_1A_1); + ttl7474_update(ttl7474_1f_1); + ttl7474_update(ttl7474_1d_1); + ttl7474_update(ttl7474_1c_1); + ttl7474_update(ttl7474_1a_1); } @@ -412,10 +420,10 @@ static WRITE8_DEVICE_HANDLER( pia_0_port_b_w ) bit 6 - Select pedal 0 bit 7 - Select pdeal 1 */ - TTL74153_a_w(TTL74153_1K, data & 0x40); - TTL74153_b_w(TTL74153_1K, data & 0x80); + ttl74153_a_w(ttl74153_1k, data & 0x40); + ttl74153_b_w(ttl74153_1k, data & 0x80); - TTL74153_update(TTL74153_1K); + ttl74153_update(ttl74153_1k); } static READ8_DEVICE_HANDLER( pia_0_port_b_r ) @@ -423,8 +431,8 @@ static READ8_DEVICE_HANDLER( pia_0_port_b_r ) /* bit 4 - Pedal bit 0 bit 5 - Pedal bit 1 */ - return (TTL74153_output_r(TTL74153_1K, 0) << 5) | - (TTL74153_output_r(TTL74153_1K, 1) << 4); + return (ttl74153_output_r(ttl74153_1k, 0) << 5) | + (ttl74153_output_r(ttl74153_1k, 1) << 4); } @@ -441,10 +449,10 @@ static READ8_DEVICE_HANDLER( pia_1_port_a_r ) bit 6 - Player 2 forward/reverse input bit 7 - Player 1 forward/reverse input */ - ret = (TTL7474_output_r(TTL7474_1A_2) ? 0x01 : 0x00) | - (TTL7474_output_r(TTL7474_1C_2) ? 0x02 : 0x00) | - (TTL7474_output_r(TTL7474_1D_2) ? 0x04 : 0x00) | - (TTL7474_output_r(TTL7474_1F_2) ? 0x08 : 0x00) | + ret = (ttl7474_output_r(ttl7474_1a_2) ? 0x01 : 0x00) | + (ttl7474_output_r(ttl7474_1c_2) ? 0x02 : 0x00) | + (ttl7474_output_r(ttl7474_1d_2) ? 0x04 : 0x00) | + (ttl7474_output_r(ttl7474_1f_2) ? 0x08 : 0x00) | (input_port_read(device->machine, "IN2") & 0xf0); return ret; @@ -460,10 +468,10 @@ static READ8_DEVICE_HANDLER( pia_1_port_b_r ) bit 6 - Player 2 steering input (wheel moving or stopped) bit 7 - Player 1 steering input (wheel moving or stopped) */ - ret = (TTL7474_output_r(TTL7474_1A_1) ? 0x10 : 0x00) | - (TTL7474_output_r(TTL7474_1C_1) ? 0x20 : 0x00) | - (TTL7474_output_r(TTL7474_1D_1) ? 0x40 : 0x00) | - (TTL7474_output_r(TTL7474_1F_1) ? 0x80 : 0x00); + ret = (ttl7474_output_r(ttl7474_1a_1) ? 0x10 : 0x00) | + (ttl7474_output_r(ttl7474_1c_1) ? 0x20 : 0x00) | + (ttl7474_output_r(ttl7474_1d_1) ? 0x40 : 0x00) | + (ttl7474_output_r(ttl7474_1f_1) ? 0x80 : 0x00); return ret; } @@ -502,34 +510,25 @@ const pia6821_interface carpolo_pia1_intf = DEVCB_NULL /* IRQB */ }; -static const struct TTL74148_interface TTL74148_3S_intf = -{ - TTL74148_3S_cb -}; - -static const struct TTL7474_interface TTL7474_2S_1_intf = -{ - TTL7474_2S_1_cb -}; - -static const struct TTL7474_interface TTL7474_2S_2_intf = -{ - TTL7474_2S_2_cb -}; - -static const struct TTL7474_interface TTL7474_2U_1_intf = -{ - TTL7474_2U_1_cb -}; - -static const struct TTL7474_interface TTL7474_2U_2_intf = -{ - TTL7474_2U_2_cb -}; - - MACHINE_START( carpolo ) { + /* find flip-flops */ + ttl7474_2s_1 = devtag_get_device(machine, "7474_2s_1"); + ttl7474_2s_2 = devtag_get_device(machine, "7474_2s_2"); + ttl7474_2u_1 = devtag_get_device(machine, "7474_2u_1"); + ttl7474_2u_2 = devtag_get_device(machine, "7474_2u_2"); + ttl7474_1f_1 = devtag_get_device(machine, "7474_1f_1"); + ttl7474_1f_2 = devtag_get_device(machine, "7474_1f_2"); + ttl7474_1d_1 = devtag_get_device(machine, "7474_1d_1"); + ttl7474_1d_2 = devtag_get_device(machine, "7474_1d_2"); + ttl7474_1c_1 = devtag_get_device(machine, "7474_1c_1"); + ttl7474_1c_2 = devtag_get_device(machine, "7474_1c_2"); + ttl7474_1a_1 = devtag_get_device(machine, "7474_1a_1"); + ttl7474_1a_2 = devtag_get_device(machine, "7474_1a_2"); + + ttl74148_3s = devtag_get_device(machine, "74148_3s"); + ttl74153_1k = devtag_get_device(machine, "74153_1k"); + state_save_register_global(machine, ball_screen_collision_cause); state_save_register_global(machine, car_ball_collision_x); state_save_register_global(machine, car_ball_collision_y); @@ -544,67 +543,49 @@ MACHINE_START( carpolo ) MACHINE_RESET( carpolo ) { /* set up the priority encoder */ - TTL74148_config(machine, TTL74148_3S, &TTL74148_3S_intf); - TTL74148_enable_input_w(TTL74148_3S, 0); /* always enabled */ - + ttl74148_enable_input_w(ttl74148_3s, 0); /* always enabled */ /* set up the coin handling flip-flops */ - TTL7474_config(machine, TTL7474_2S_1, &TTL7474_2S_1_intf); - TTL7474_config(machine, TTL7474_2S_2, &TTL7474_2S_2_intf); - TTL7474_config(machine, TTL7474_2U_1, &TTL7474_2U_1_intf); - TTL7474_config(machine, TTL7474_2U_2, &TTL7474_2U_2_intf); + ttl7474_d_w (ttl7474_2s_1, 1); + ttl7474_preset_w(ttl7474_2s_1, 1); - TTL7474_d_w (TTL7474_2S_1, 1); - TTL7474_preset_w(TTL7474_2S_1, 1); + ttl7474_d_w (ttl7474_2s_2, 1); + ttl7474_preset_w(ttl7474_2s_2, 1); - TTL7474_d_w (TTL7474_2S_2, 1); - TTL7474_preset_w(TTL7474_2S_2, 1); + ttl7474_d_w (ttl7474_2u_1, 1); + ttl7474_preset_w(ttl7474_2u_1, 1); - TTL7474_d_w (TTL7474_2U_1, 1); - TTL7474_preset_w(TTL7474_2U_1, 1); - - TTL7474_d_w (TTL7474_2U_2, 1); - TTL7474_preset_w(TTL7474_2U_2, 1); + ttl7474_d_w (ttl7474_2u_2, 1); + ttl7474_preset_w(ttl7474_2u_2, 1); /* set up the steering handling flip-flops */ - TTL7474_config(machine, TTL7474_1F_1, 0); - TTL7474_config(machine, TTL7474_1F_2, 0); - TTL7474_config(machine, TTL7474_1D_1, 0); - TTL7474_config(machine, TTL7474_1D_2, 0); - TTL7474_config(machine, TTL7474_1C_1, 0); - TTL7474_config(machine, TTL7474_1C_2, 0); - TTL7474_config(machine, TTL7474_1A_1, 0); - TTL7474_config(machine, TTL7474_1A_2, 0); + ttl7474_d_w (ttl7474_1f_1, 1); + ttl7474_preset_w(ttl7474_1f_1, 1); - TTL7474_d_w (TTL7474_1F_1, 1); - TTL7474_preset_w(TTL7474_1F_1, 1); + ttl7474_clear_w (ttl7474_1f_2, 1); + ttl7474_preset_w(ttl7474_1f_2, 1); - TTL7474_clear_w (TTL7474_1F_2, 1); - TTL7474_preset_w(TTL7474_1F_2, 1); + ttl7474_d_w (ttl7474_1d_1, 1); + ttl7474_preset_w(ttl7474_1d_1, 1); - TTL7474_d_w (TTL7474_1D_1, 1); - TTL7474_preset_w(TTL7474_1D_1, 1); + ttl7474_clear_w (ttl7474_1d_2, 1); + ttl7474_preset_w(ttl7474_1d_2, 1); - TTL7474_clear_w (TTL7474_1D_2, 1); - TTL7474_preset_w(TTL7474_1D_2, 1); + ttl7474_d_w (ttl7474_1c_1, 1); + ttl7474_preset_w(ttl7474_1c_1, 1); - TTL7474_d_w (TTL7474_1C_1, 1); - TTL7474_preset_w(TTL7474_1C_1, 1); + ttl7474_clear_w (ttl7474_1c_2, 1); + ttl7474_preset_w(ttl7474_1c_2, 1); - TTL7474_clear_w (TTL7474_1C_2, 1); - TTL7474_preset_w(TTL7474_1C_2, 1); + ttl7474_d_w (ttl7474_1a_1, 1); + ttl7474_preset_w(ttl7474_1a_1, 1); - TTL7474_d_w (TTL7474_1A_1, 1); - TTL7474_preset_w(TTL7474_1A_1, 1); - - TTL7474_clear_w (TTL7474_1A_2, 1); - TTL7474_preset_w(TTL7474_1A_2, 1); + ttl7474_clear_w (ttl7474_1a_2, 1); + ttl7474_preset_w(ttl7474_1a_2, 1); /* set up the pedal handling chips */ - TTL74153_config(machine, TTL74153_1K, 0); - - TTL74153_enable_w(TTL74153_1K, 0, 0); - TTL74153_enable_w(TTL74153_1K, 1, 0); + ttl74153_enable_w(ttl74153_1k, 0, 0); + ttl74153_enable_w(ttl74153_1k, 1, 0); } diff --git a/src/mame/machine/galaxold.c b/src/mame/machine/galaxold.c index d85b848e1e5..579ba767969 100644 --- a/src/mame/machine/galaxold.c +++ b/src/mame/machine/galaxold.c @@ -16,67 +16,60 @@ static emu_timer *int_timer; static UINT8 _4in1_bank; -static void galaxold_7474_9M_2_callback(running_machine *machine) +void galaxold_7474_9m_2_callback(const device_config *device) { /* Q bar clocks the other flip-flop, Q is VBLANK (not visible to the CPU) */ - TTL7474_clock_w(1, TTL7474_output_comp_r(0)); - TTL7474_update(machine, 1); + const device_config *target = devtag_get_device(device->machine, "7474_9m_1"); + ttl7474_clock_w(target, ttl7474_output_comp_r(device)); + ttl7474_update(target); } -static void galaxold_7474_9M_1_callback(running_machine *machine) +void galaxold_7474_9m_1_callback(const device_config *device) { /* Q goes to the NMI line */ - cputag_set_input_line(machine, "maincpu", irq_line, TTL7474_output_r(1) ? CLEAR_LINE : ASSERT_LINE); + cputag_set_input_line(device->machine, "maincpu", irq_line, ttl7474_output_r(device) ? CLEAR_LINE : ASSERT_LINE); } -static const struct TTL7474_interface galaxold_7474_9M_2_intf = -{ - galaxold_7474_9M_2_callback -}; - -static const struct TTL7474_interface galaxold_7474_9M_1_intf = -{ - galaxold_7474_9M_1_callback -}; - - WRITE8_HANDLER( galaxold_nmi_enable_w ) { - TTL7474_preset_w(1, data); - TTL7474_update(space->machine, 1); + const device_config *target = devtag_get_device(space->machine, "7474_9m_1"); + ttl7474_preset_w(target, data); + ttl7474_update(target); } static TIMER_CALLBACK( interrupt_timer ) { + const device_config *target = devtag_get_device(machine, "7474_9m_2"); + /* 128V, 64V and 32V go to D */ - TTL7474_d_w(0, (param & 0xe0) != 0xe0); + ttl7474_d_w(target, (param & 0xe0) != 0xe0); /* 16V clocks the flip-flop */ - TTL7474_clock_w(0, param & 0x10); + ttl7474_clock_w(target, param & 0x10); param = (param + 0x10) & 0xff; timer_adjust_oneshot(int_timer, video_screen_get_time_until_pos(machine->primary_screen, param, 0), param); - TTL7474_update(machine, 0); + ttl7474_update(target); } static void machine_reset_common(running_machine *machine, int line) { + const device_config *ttl7474_9m_1 = devtag_get_device(machine, "7474_9m_1"); + const device_config *ttl7474_9m_2 = devtag_get_device(machine, "7474_9m_2"); irq_line = line; /* initalize main CPU interrupt generator flip-flops */ - TTL7474_config(machine, 0, &galaxold_7474_9M_2_intf); - TTL7474_preset_w(0, 1); - TTL7474_clear_w (0, 1); + ttl7474_preset_w(ttl7474_9m_2, 1); + ttl7474_clear_w (ttl7474_9m_2, 1); - TTL7474_config(machine, 1, &galaxold_7474_9M_1_intf); - TTL7474_clear_w (1, 1); - TTL7474_d_w (1, 0); - TTL7474_preset_w(1, 0); + ttl7474_clear_w (ttl7474_9m_1, 1); + ttl7474_d_w (ttl7474_9m_1, 0); + ttl7474_preset_w(ttl7474_9m_1, 0); /* start a timer to generate interrupts */ int_timer = timer_alloc(machine, interrupt_timer, NULL); diff --git a/src/mame/machine/vertigo.c b/src/mame/machine/vertigo.c index 26f3d2f846f..45af5f5e281 100644 --- a/src/mame/machine/vertigo.c +++ b/src/mame/machine/vertigo.c @@ -11,6 +11,9 @@ #include "machine/pit8253.h" +static const device_config *ttl74148; + + /************************************* * @@ -20,7 +23,6 @@ static PIT8253_OUTPUT_CHANGED( v_irq4_w ); static PIT8253_OUTPUT_CHANGED( v_irq3_w ); -static void update_irq(running_machine *machine); @@ -59,12 +61,6 @@ const struct pit8253_config vertigo_pit8254_config = }; -static const struct TTL74148_interface irq_encoder = -{ - update_irq -}; - - /************************************* * @@ -74,22 +70,22 @@ static const struct TTL74148_interface irq_encoder = * *************************************/ -static void update_irq(running_machine *machine) +void vertigo_update_irq(const device_config *device) { if (irq_state < 7) - cputag_set_input_line(machine, "maincpu", irq_state ^ 7, CLEAR_LINE); + cputag_set_input_line(device->machine, "maincpu", irq_state ^ 7, CLEAR_LINE); - irq_state = TTL74148_output_r(0); + irq_state = ttl74148_output_r(device); if (irq_state < 7) - cputag_set_input_line(machine, "maincpu", irq_state ^ 7, ASSERT_LINE); + cputag_set_input_line(device->machine, "maincpu", irq_state ^ 7, ASSERT_LINE); } static void update_irq_encoder(running_machine *machine, int line, int state) { - TTL74148_input_line_w(0, line, !state); - TTL74148_update(machine, 0); + ttl74148_input_line_w(ttl74148, line, !state); + ttl74148_update(ttl74148); } @@ -211,13 +207,13 @@ MACHINE_RESET( vertigo ) { int i; - TTL74148_config(machine, 0, &irq_encoder); - TTL74148_enable_input_w(0, 0); + ttl74148 = devtag_get_device(machine, "74148"); + ttl74148_enable_input_w(ttl74148, 0); for (i = 0; i < 8; i++) - TTL74148_input_line_w(0, i, 1); + ttl74148_input_line_w(ttl74148, i, 1); - TTL74148_update(machine, 0); + ttl74148_update(ttl74148); vertigo_vproc_init(machine); irq4_time = timer_get_time(machine); diff --git a/src/mame/video/artmagic.c b/src/mame/video/artmagic.c index 77a021a3057..5806f1aa163 100644 --- a/src/mame/video/artmagic.c +++ b/src/mame/video/artmagic.c @@ -61,6 +61,7 @@ VIDEO_START( artmagic ) blitter_base = (UINT16 *)memory_region(machine, "gfx1"); blitter_mask = memory_region_length(machine, "gfx1")/2 - 1; + tlc34076_state_save(machine); state_save_register_global_array(machine, artmagic_xor); state_save_register_global(machine, artmagic_is_stoneball); state_save_register_global_array(machine, blitter_data);