diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/attotime.c | 26 | ||||
-rw-r--r-- | src/emu/attotime.h | 6 | ||||
-rw-r--r-- | src/emu/cpu/sh2/sh2drc.c | 2 | ||||
-rw-r--r-- | src/emu/machine/6532riot.c | 699 | ||||
-rw-r--r-- | src/emu/machine/6532riot.h | 136 | ||||
-rw-r--r-- | src/mame/audio/exidy.c | 234 | ||||
-rw-r--r-- | src/mame/audio/gottlieb.c | 86 | ||||
-rw-r--r-- | src/mame/audio/starwars.c | 192 | ||||
-rw-r--r-- | src/mame/drivers/gameplan.c | 44 | ||||
-rw-r--r-- | src/mame/drivers/gottlieb.c | 865 | ||||
-rw-r--r-- | src/mame/drivers/starwars.c | 5 | ||||
-rw-r--r-- | src/mame/drivers/tourtabl.c | 113 | ||||
-rw-r--r-- | src/mame/includes/gameplan.h | 1 | ||||
-rw-r--r-- | src/mame/includes/starwars.h | 7 | ||||
-rw-r--r-- | src/mame/video/gottlieb.c | 83 |
15 files changed, 1328 insertions, 1171 deletions
diff --git a/src/emu/attotime.c b/src/emu/attotime.c index 6116c9fbd0e..9783dfe2ba0 100644 --- a/src/emu/attotime.c +++ b/src/emu/attotime.c @@ -53,6 +53,32 @@ attoseconds_t attotime_to_attoseconds(attotime _time) } +/*------------------------------------------------- + attotime_to_ticks - convert an attotime to + clock ticks at the given frequency +-------------------------------------------------*/ + +INT64 attotime_to_ticks(attotime _time, INT32 frequency) +{ + INT32 fracticks = attotime_mul(attotime_make(0, _time.attoseconds), frequency).seconds; + return (INT64)_time.seconds * (INT64)frequency + fracticks; +} + + +/*------------------------------------------------- + ticks_to_attotime - convert clock ticks at + the given frequency to an attotime +-------------------------------------------------*/ + +attotime ticks_to_attotime(INT64 ticks, INT32 frequency) +{ + attotime result; + result.seconds = ticks / frequency; + result.attoseconds = HZ_TO_ATTOSECONDS(frequency) * (ticks - (INT64)result.seconds * (INT64)frequency); + return result; +} + + /*************************************************************************** CORE MATH FUNCTIONS diff --git a/src/emu/attotime.h b/src/emu/attotime.h index 6d94e7cc13d..2ca17ff6cc6 100644 --- a/src/emu/attotime.h +++ b/src/emu/attotime.h @@ -137,6 +137,12 @@ extern const attotime attotime_never; /* convert an attotime to attoseconds, clamping to maximum positive/negative values */ attoseconds_t attotime_to_attoseconds(attotime _time); +/* convert an attotime to clock ticks at the given frequency */ +INT64 attotime_to_ticks(attotime _time, INT32 frequency); + +/* convert clock ticks at the given frequency to an attotime */ +attotime ticks_to_attotime(INT64 ticks, INT32 frequency); + /* ----- core math functions ----- */ diff --git a/src/emu/cpu/sh2/sh2drc.c b/src/emu/cpu/sh2/sh2drc.c index 37c121a11c4..fee4981138d 100644 --- a/src/emu/cpu/sh2/sh2drc.c +++ b/src/emu/cpu/sh2/sh2drc.c @@ -27,7 +27,7 @@ ***************************************************************************/ #define FORCE_C_BACKEND (0) // use the C backend even when a native one is available -#define LOG_UML (1) // log UML assembly +#define LOG_UML (0) // log UML assembly #define LOG_NATIVE (0) // log native assembly #define SET_EA (0) // makes slower but "shows work" in the EA fake register like the interpreter diff --git a/src/emu/machine/6532riot.c b/src/emu/machine/6532riot.c index 24a193486e2..37b2286ec59 100644 --- a/src/emu/machine/6532riot.c +++ b/src/emu/machine/6532riot.c @@ -12,362 +12,519 @@ The timer seems to follow these rules: ***************************************************************************/ #include "driver.h" -#include "machine/6532riot.h" +#include "6532riot.h" -struct riot6532 + +/*************************************************************************** + CONSTANTS +***************************************************************************/ + +enum +{ + TIMER_IDLE, + TIMER_COUNTING, + TIMER_FINISHING +}; + +#define TIMER_FLAG 0x80 +#define PA7_FLAG 0x40 + + + +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +typedef struct _riot6532_port riot6532_port; +struct _riot6532_port { - const struct riot6532_interface *intf; + UINT8 in; + UINT8 out; + UINT8 ddr; + riot_read_func in_func; + riot_write_func out_func; +}; - UINT8 in_a; - UINT8 out_a; - UINT8 in_b; - UINT8 out_b; - UINT8 ddr_a; - UINT8 ddr_b; - int shift; +typedef struct _riot6532_state riot6532_state; +struct _riot6532_state +{ + const riot6532_interface *intf; + int index; + + riot6532_port port[2]; + + UINT8 irqstate; + UINT8 irqenable; - int pa7_enable; - int pa7_direction; /* 0x80 = high-to-low, 0x00 = low-to-high */ - int pa7_flag; - UINT8 pa7; + UINT8 pa7dir; /* 0x80 = high-to-low, 0x00 = low-to-high */ + UINT8 pa7prev; - int timer_irq_enable; - int timer_irq; - emu_timer *counter_timer; + UINT8 timershift; + UINT8 timerstate; + emu_timer * timer; - int clock; + UINT32 clock; }; -static struct riot6532 r6532[MAX_R6532]; +/*************************************************************************** + INLINE FUNCTIONS +***************************************************************************/ -INLINE void r6532_set_timer(int which, UINT8 count) +/*------------------------------------------------- + get_safe_token - convert a device's token + into a riot6532_state +-------------------------------------------------*/ + +INLINE riot6532_state *get_safe_token(const device_config *device) { - timer_adjust_oneshot( r6532[which].counter_timer, attotime_mul(ATTOTIME_IN_HZ(r6532[which].clock), (count << r6532[which].shift) + 1), which ); + assert(device != NULL); + assert(device->token != NULL); + assert(device->type == RIOT6532); + return (riot6532_state *)device->token; } -static TIMER_CALLBACK( r6532_irq_timer_callback ) +/*------------------------------------------------- + update_irqstate - update the IRQ state + based on interrupt enables +-------------------------------------------------*/ + +INLINE void update_irqstate(const device_config *device) { - int which = param; + riot6532_state *riot = get_safe_token(device); + int state = (riot->irqstate & riot->irqenable); - if ( r6532[which].timer_irq_enable ) - { - r6532[which].timer_irq = 1; - if (r6532[which].intf->irq_func) - (*r6532[which].intf->irq_func)(machine, ASSERT_LINE); - else - logerror("6532RIOT chip #%d: Interrupt is asserted but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); - } + if (riot->intf->irq_func != NULL) + (*riot->intf->irq_func)(device, (state != 0) ? ASSERT_LINE : CLEAR_LINE); + else + logerror("6532RIOT chip #%d: no irq callback function. PC: %08X\n", riot->index, safe_activecpu_get_pc()); } -static void r6532_pa7_check(running_machine *machine, int which){ - UINT8 data = ( ( r6532[which].ddr_a & r6532[which].out_a ) | ( ~r6532[which].ddr_a & r6532[which].in_a ) ) & 0x80; - if ((r6532[which].pa7 ^ data) && (r6532[which].pa7_direction ^ data)) +/*------------------------------------------------- + apply_ddr - combine inputs and outputs + according to the DDR +-------------------------------------------------*/ + +INLINE UINT8 apply_ddr(const riot6532_port *port) +{ + return (port->out & port->ddr) | (port->in & ~port->ddr); +} + + +/*------------------------------------------------- + update_pa7_state - see if PA7 has changed + and signal appropriately +-------------------------------------------------*/ + +INLINE void update_pa7_state(const device_config *device) +{ + riot6532_state *riot = get_safe_token(device); + UINT8 data = apply_ddr(&riot->port[0]) & 0x80; + + /* if the state changed in the correct direction, set the PA7 flag and update IRQs */ + if ((riot->pa7prev ^ data) && (riot->pa7dir ^ data) == 0) { - r6532[which].pa7_flag = 1; - if (r6532[which].pa7_enable) - { - if (r6532[which].intf->irq_func) - (*r6532[which].intf->irq_func)(machine, ASSERT_LINE); - else - logerror("6532RIOT chip #%d: Interrupt is asserted but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); - } + riot->irqstate |= PA7_FLAG; + update_irqstate(device); } - r6532[which].pa7 = data; + riot->pa7prev = data; +} + + +/*------------------------------------------------- + get_timer - return the current timer value +-------------------------------------------------*/ + +INLINE UINT8 get_timer(riot6532_state *riot) +{ + /* if idle, return 0 */ + if (riot->timerstate == TIMER_IDLE) + return 0; + + /* if counting, return the number of ticks remaining */ + else if (riot->timerstate == TIMER_COUNTING) + return attotime_to_ticks(timer_timeleft(riot->timer), riot->clock) >> riot->timershift; + + /* if finishing, return the number of ticks without the shift */ + else + return attotime_to_ticks(timer_timeleft(riot->timer), riot->clock); } -void r6532_write(running_machine *machine, int which, offs_t offset, UINT8 data) + +/*************************************************************************** + INTERNAL FUNCTIONS +***************************************************************************/ + +/*------------------------------------------------- + timer_end_callback - callback to process the + timer +-------------------------------------------------*/ + +static TIMER_CALLBACK( timer_end_callback ) { - if (offset & 4) + const device_config *device = ptr; + riot6532_state *riot = get_safe_token(device); + + assert(riot->timerstate != TIMER_IDLE); + + /* if we finished counting, switch to the finishing state */ + if (riot->timerstate == TIMER_COUNTING) { - if (offset & 0x10) - { - switch (offset & 3) - { - case 0: - r6532[which].shift = 0; - break; - case 1: - r6532[which].shift = 3; - break; - case 2: - r6532[which].shift = 6; - break; - case 3: - r6532[which].shift = 10; - break; - } - r6532[which].timer_irq_enable = (offset & 8); - r6532_set_timer( which, data ); - } - else - { - r6532[which].pa7_enable = (offset & 2) >> 1; - r6532[which].pa7_direction = ( offset & 1 ) << 7; - } + riot->timerstate = TIMER_FINISHING; + timer_adjust_oneshot(riot->timer, ticks_to_attotime(255, riot->clock), 0); + + /* signal timer IRQ as well */ + riot->irqstate |= TIMER_FLAG; + update_irqstate(device); } - else + + /* if we finished finishing, switch to the idle state */ + else if (riot->timerstate == TIMER_FINISHING) { - offset &= 3; - - switch (offset) - { - case 0: - r6532[which].out_a = data; - if (r6532[which].ddr_a) - { - UINT8 write_data = ( r6532[which].ddr_a & r6532[which].out_a ) | ( ~r6532[which].ddr_a & 0xFF ); - if (r6532[which].intf->out_a_func) - r6532[which].intf->out_a_func(machine, 0, write_data); - else - logerror("6532RIOT chip #%d: Port A is being written to but has no handler. PC: %08X - %02X\n", which, safe_activecpu_get_pc(), write_data); - /* Check for PA7 change */ - r6532_pa7_check(machine, which); - } - break; - case 1: - r6532[which].ddr_a = data; - r6532_pa7_check(machine, which); - break; - case 2: - r6532[which].out_b = data; - if (r6532[which].ddr_b) - { - UINT8 write_data = ( r6532[which].ddr_b & r6532[which].out_b ) | ( ~r6532[which].ddr_b & 0xFF ); - if (r6532[which].intf->out_b_func) - r6532[which].intf->out_b_func(machine, 0, write_data); - else - logerror("6532RIOT chip #%d: Port B is being written to but has no handler. PC: %08X - %02X\n", which, safe_activecpu_get_pc(), write_data); - } - break; - case 3: - r6532[which].ddr_b = data; - break; - } + riot->timerstate = TIMER_IDLE; + timer_adjust_oneshot(riot->timer, attotime_never, 0); } } -INLINE UINT8 r6532_read_timer(running_machine *machine, int which) + +/*************************************************************************** + I/O ACCESS +***************************************************************************/ + +/*------------------------------------------------- + riot6532_w - master I/O write access +-------------------------------------------------*/ + +WRITE8_DEVICE_HANDLER( riot6532_w ) { - int timer_cycles_left = ( attotime_to_double(timer_timeleft( r6532[which].counter_timer )) * r6532[which].clock ) - 1; - if ( timer_cycles_left >= 0) + riot6532_state *riot = get_safe_token(device); + + /* if A4 == 1 and A2 == 1, we are writing to the timer */ + if ((offset & 0x14) == 0x14) { - timer_cycles_left = timer_cycles_left >> r6532[which].shift; + static const UINT8 timershift[4] = { 0, 3, 6, 10 }; + attotime curtime = timer_get_time(); + INT64 target; + + /* A0-A1 contain the timer divisor */ + riot->timershift = timershift[offset & 3]; + + /* A3 contains the timer IRQ enable */ + if (offset & 8) + riot->irqenable |= TIMER_FLAG; + else + riot->irqenable &= ~TIMER_FLAG; + + /* writes here clear the timer flag */ + if (riot->timerstate != TIMER_FINISHING || get_timer(riot) != 0xff) + riot->irqstate &= ~TIMER_FLAG; + update_irqstate(device); + + /* update the timer */ + riot->timerstate = TIMER_COUNTING; + target = attotime_to_ticks(curtime, riot->clock) + 1 + (data << riot->timershift); + timer_adjust_oneshot(riot->timer, attotime_sub(ticks_to_attotime(target, riot->clock), curtime), 0); + } + + /* if A4 == 0 and A2 == 1, we are writing to the edge detect control */ + else if ((offset & 0x14) == 0x04) + { + /* A1 contains the A7 IRQ enable */ + if (offset & 2) + riot->irqenable |= PA7_FLAG; + else + riot->irqenable &= ~PA7_FLAG; + + /* A0 specifies the edge detect direction: 0=negative, 1=positive */ + riot->pa7dir = (offset & 1) << 7; } + + /* if A4 == anything and A2 == 0, we are writing to the I/O section */ else { - if (timer_cycles_left != -1) + /* A1 selects the port */ + riot6532_port *port = &riot->port[(offset >> 1) & 1]; + + /* if A0 == 1, we are writing to the port's DDR */ + if (offset & 1) + port->ddr = data; + + /* if A0 == 0, we are writing to the port's output */ + else { - if (r6532[which].intf->irq_func && r6532[which].timer_irq) - (*r6532[which].intf->irq_func)(machine, CLEAR_LINE); + UINT8 olddata = port->out; + port->out = data; + if (port->out_func != NULL) + (*port->out_func)(device, data, olddata); else - logerror("6532RIOT chip #%d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); - - /* Timer flag is cleared, so adjust the target */ - timer_cycles_left = ( timer_cycles_left > -256 ) ? timer_cycles_left & 0xFF : 0; - r6532_set_timer( which, timer_cycles_left ); + logerror("6532RIOT chip %s: Port %c is being written to but has no handler. PC: %08X - %02X\n", device->tag, 'A' + (offset & 1), safe_activecpu_get_pc(), data); } + + /* writes to port A need to update the PA7 state */ + if (port == &riot->port[0]) + update_pa7_state(device); } - return timer_cycles_left; } -void r6532_set_input_a(running_machine *machine, int which, UINT8 data) -{ - r6532[which].in_a = data; - /* Check for PA7 change */ - r6532_pa7_check(machine, which); -} - +/*------------------------------------------------- + riot6532_r - master I/O read access +-------------------------------------------------*/ -void r6532_set_input_b(int which, UINT8 data) +READ8_DEVICE_HANDLER( riot6532_r ) { - r6532[which].in_b = data; -} - + riot6532_state *riot = get_safe_token(device); + UINT8 val = 0; + + /* if A2 == 1 and A0 == 1, we are reading interrupt flags */ + if ((offset & 0x05) == 0x05) + { + val = riot->irqstate; -INLINE UINT8 r6532_read_irq_flags(running_machine *machine, int which) -{ - int timer_cycles_left = ( attotime_to_double(timer_timeleft( r6532[which].counter_timer )) * r6532[which].clock ) - 1; - int res = 0; + /* implicitly clears the PA7 flag */ + riot->irqstate &= ~PA7_FLAG; + update_irqstate(device); + } + + /* if A2 == 1 and A0 == 0, we are reading the timer */ + else if ((offset & 0x05) == 0x04) + { + val = get_timer(riot); - if ( timer_cycles_left < 0 ) + /* A3 contains the timer IRQ enable */ + if (offset & 8) + riot->irqenable |= TIMER_FLAG; + else + riot->irqenable &= ~TIMER_FLAG; + + /* implicitly clears the timer flag */ + if (riot->timerstate != TIMER_FINISHING || val != 0xff) + riot->irqstate &= ~TIMER_FLAG; + update_irqstate(device); + } + + /* if A2 == 0 and A0 == anything, we are reading from ports */ + else { - res |= 0x80; - if ( timer_cycles_left < -1 ) + /* A1 selects the port */ + riot6532_port *port = &riot->port[(offset >> 1) & 1]; + + /* if A0 == 1, we are reading the port's DDR */ + if (offset & 1) + val = port->ddr; + + /* if A0 == 0, we are reading the port as an input */ + else { - if ( r6532[which].intf->irq_func) - (*r6532[which].intf->irq_func)(machine, CLEAR_LINE); + /* call the input callback if it exists */ + if (port->in_func != NULL) + { + port->in = (*port->in_func)(device, port->in); + + /* changes to port A need to update the PA7 state */ + if (port == &riot->port[0]) + update_pa7_state(device); + } else - logerror("6532RIOT chip #%d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); + logerror("6532RIOT chip %s: Port %c is being read but has no handler. PC: %08X\n", device->tag, 'A' + (offset & 1), safe_activecpu_get_pc()); - /* Timer flag is cleared, so adjust the target */ - r6532_set_timer( which, timer_cycles_left > -256 ? timer_cycles_left & 0xFF : 0 ); + /* apply the DDR to the result */ + val = apply_ddr(port); } } + return val; +} - if (r6532[which].pa7_flag) - { - res |= 0x40; - r6532[which].pa7_flag = 0; - if (r6532[which].intf->irq_func && timer_cycles_left != -1) - (*r6532[which].intf->irq_func)(machine, CLEAR_LINE); - else - logerror("6532RIOT chip #%d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); - } +/*------------------------------------------------- + riot6532_porta_in_set - set port A input + value +-------------------------------------------------*/ - return res; +void riot6532_porta_in_set(const device_config *device, UINT8 data, UINT8 mask) +{ + riot6532_state *riot = get_safe_token(device); + riot->port[0].in = (riot->port[0].in & ~mask) | (data & mask); + update_pa7_state(device); } -UINT8 r6532_read(running_machine *machine, int which, offs_t offset) +/*------------------------------------------------- + riot6532_portb_in_set - set port B input + value +-------------------------------------------------*/ + +void riot6532_portb_in_set(const device_config *device, UINT8 data, UINT8 mask) { - UINT8 val = 0; + riot6532_state *riot = get_safe_token(device); + riot->port[1].in = (riot->port[1].in & ~mask) | (data & mask); +} - switch (offset & 7) - { - case 0: - if (r6532[which].intf->in_a_func) - r6532[which].in_a = r6532[which].intf->in_a_func(machine, 0); - else - logerror("6532RIOT chip #%d: Port A is being read but has no handler. PC: %08X\n", which, safe_activecpu_get_pc()); - val = ( r6532[which].ddr_a & r6532[which].out_a ) | ( ~r6532[which].ddr_a & r6532[which].in_a ); - /* Check for PA7 change */ - r6532_pa7_check(machine, which); - break; - case 1: - val = r6532[which].ddr_a; - break; - case 2: - if (r6532[which].intf->in_b_func) - r6532[which].in_b = r6532[which].intf->in_b_func(machine, 0); - else - logerror("6532RIOT chip #%d: Port B is being read but has no handler. PC: %08X\n", which, safe_activecpu_get_pc()); - - val = ( r6532[which].ddr_b & r6532[which].out_b ) | ( ~r6532[which].ddr_b & r6532[which].in_b ); - break; - case 3: - val = r6532[which].ddr_b; - break; - case 4: - case 6: - r6532[which].timer_irq_enable = offset & 8; - val = r6532_read_timer(machine, which); - break; - case 5: - case 7: - val = r6532_read_irq_flags(machine, which); - break; - } - return val; +/*------------------------------------------------- + riot6532_porta_in_get - return port A input + value +-------------------------------------------------*/ + +UINT8 riot6532_porta_in_get(const device_config *device) +{ + riot6532_state *riot = get_safe_token(device); + return riot->port[0].in; } -void r6532_set_clock(int which, int clock) +/*------------------------------------------------- + riot6532_portb_in_get - return port B input + value +-------------------------------------------------*/ + +UINT8 riot6532_portb_in_get(const device_config *device) { - r6532[which].clock = clock; + riot6532_state *riot = get_safe_token(device); + return riot->port[1].in; } -void r6532_reset(running_machine *machine, int which) +/*------------------------------------------------- + riot6532_porta_in_get - return port A output + value +-------------------------------------------------*/ + +UINT8 riot6532_porta_out_get(const device_config *device) { - r6532[which].out_a = 0; - r6532[which].out_b = 0; - r6532[which].ddr_a = 0; - r6532[which].ddr_b = 0; + riot6532_state *riot = get_safe_token(device); + return riot->port[0].out; +} - r6532[which].shift = 10; - r6532[which].counter_timer = timer_alloc(r6532_irq_timer_callback, NULL); +/*------------------------------------------------- + riot6532_portb_in_get - return port B output + value +-------------------------------------------------*/ - r6532_set_timer( which, 0xFF ); +UINT8 riot6532_portb_out_get(const device_config *device) +{ + riot6532_state *riot = get_safe_token(device); + return riot->port[1].out; +} - r6532[which].pa7_enable = 0; - r6532[which].pa7_direction = 0x80; - r6532[which].pa7_flag = 0; - r6532[which].pa7 = 0; - r6532[which].timer_irq_enable = 0; - r6532[which].timer_irq = 0; +/*************************************************************************** + DEVICE INTERFACE +***************************************************************************/ - if (r6532[which].intf->irq_func) - (*r6532[which].intf->irq_func)(machine, CLEAR_LINE); - else - logerror("6532RIOT chip #%d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); +/*------------------------------------------------- + riot6532_portb_r - return port B output + value +-------------------------------------------------*/ + +static DEVICE_START( riot6532 ) +{ + const riot6532_config *config = device->inline_config; + riot6532_state *riot = get_safe_token(device); + char unique_tag[30]; + + /* validate arguments */ + assert(device != NULL); + assert(device->tag != NULL); + assert(strlen(device->tag) < 20); + + /* set static values */ + riot->intf = device->static_config; + riot->index = device_list_index(device->machine->config->devicelist, RIOT6532, device->tag); + riot->clock = config->clock; + + /* configure the ports */ + riot->port[0].in_func = riot->intf->in_a_func; + riot->port[0].out_func = riot->intf->out_a_func; + riot->port[1].in_func = riot->intf->in_b_func; + riot->port[1].out_func = riot->intf->out_b_func; + + /* allocate timers */ + riot->timer = timer_alloc(timer_end_callback, (void *)device); + + /* register for save states */ + state_save_combine_module_and_tag(unique_tag, "riot6532", device->tag); + + state_save_register_item(unique_tag, 0, riot->port[0].in); + state_save_register_item(unique_tag, 0, riot->port[0].out); + state_save_register_item(unique_tag, 0, riot->port[0].ddr); + state_save_register_item(unique_tag, 0, riot->port[1].in); + state_save_register_item(unique_tag, 0, riot->port[1].out); + state_save_register_item(unique_tag, 0, riot->port[1].ddr); + + state_save_register_item(unique_tag, 0, riot->irqstate); + state_save_register_item(unique_tag, 0, riot->irqenable); + + state_save_register_item(unique_tag, 0, riot->pa7dir); + state_save_register_item(unique_tag, 0, riot->pa7prev); + + state_save_register_item(unique_tag, 0, riot->timershift); + state_save_register_item(unique_tag, 0, riot->timerstate); } -void r6532_config(running_machine *machine, int which, const struct riot6532_interface* intf) +static DEVICE_RESET( riot6532 ) { - assert_always(mame_get_phase(machine) == MAME_PHASE_INIT, "Can only call r6532_init at init time!"); - assert_always( which < MAX_R6532, "which exceeds maximum number of configured r6532s!" ); + riot6532_state *riot = get_safe_token(device); + + /* reset I/O states */ + riot->port[0].out = 0; + riot->port[0].ddr = 0; + riot->port[1].out = 0; + riot->port[1].ddr = 0; + + /* reset IRQ states */ + riot->irqenable = 0; + riot->irqstate = 0; + update_irqstate(device); + + /* reset PA7 states */ + riot->pa7dir = 0; + riot->pa7prev = 0; + + /* reset timer states */ + riot->timershift = 0; + riot->timerstate = TIMER_IDLE; + timer_adjust_oneshot(riot->timer, attotime_never, 0); +} - r6532[which].intf = intf; - /* Default clock is CPU #0 clock */ - r6532_set_clock( which, cpunum_get_clock(0) ); +static DEVICE_SET_INFO( riot6532 ) +{ + switch (state) + { + /* no parameters to set */ + } } -WRITE8_HANDLER( r6532_0_w ) { r6532_write(machine, 0, offset, data); } -WRITE8_HANDLER( r6532_1_w ) { r6532_write(machine, 1, offset, data); } -WRITE8_HANDLER( r6532_2_w ) { r6532_write(machine, 2, offset, data); } -WRITE8_HANDLER( r6532_3_w ) { r6532_write(machine, 3, offset, data); } -WRITE8_HANDLER( r6532_4_w ) { r6532_write(machine, 4, offset, data); } -WRITE8_HANDLER( r6532_5_w ) { r6532_write(machine, 5, offset, data); } -WRITE8_HANDLER( r6532_6_w ) { r6532_write(machine, 6, offset, data); } -WRITE8_HANDLER( r6532_7_w ) { r6532_write(machine, 7, offset, data); } - -READ8_HANDLER( r6532_0_r ) { return r6532_read(machine, 0, offset); } -READ8_HANDLER( r6532_1_r ) { return r6532_read(machine, 1, offset); } -READ8_HANDLER( r6532_2_r ) { return r6532_read(machine, 2, offset); } -READ8_HANDLER( r6532_3_r ) { return r6532_read(machine, 3, offset); } -READ8_HANDLER( r6532_4_r ) { return r6532_read(machine, 4, offset); } -READ8_HANDLER( r6532_5_r ) { return r6532_read(machine, 5, offset); } -READ8_HANDLER( r6532_6_r ) { return r6532_read(machine, 6, offset); } -READ8_HANDLER( r6532_7_r ) { return r6532_read(machine, 7, offset); } - -WRITE8_HANDLER( r6532_0_porta_w) { r6532_set_input_a(machine, 0, data); } -WRITE8_HANDLER( r6532_1_porta_w) { r6532_set_input_a(machine, 1, data); } -WRITE8_HANDLER( r6532_2_porta_w) { r6532_set_input_a(machine, 2, data); } -WRITE8_HANDLER( r6532_3_porta_w) { r6532_set_input_a(machine, 3, data); } -WRITE8_HANDLER( r6532_4_porta_w) { r6532_set_input_a(machine, 4, data); } -WRITE8_HANDLER( r6532_5_porta_w) { r6532_set_input_a(machine, 5, data); } -WRITE8_HANDLER( r6532_6_porta_w) { r6532_set_input_a(machine, 6, data); } -WRITE8_HANDLER( r6532_7_porta_w) { r6532_set_input_a(machine, 7, data); } - -WRITE8_HANDLER( r6532_0_portb_w) { r6532_set_input_b(0, data); } -WRITE8_HANDLER( r6532_1_portb_w) { r6532_set_input_b(1, data); } -WRITE8_HANDLER( r6532_2_portb_w) { r6532_set_input_b(2, data); } -WRITE8_HANDLER( r6532_3_portb_w) { r6532_set_input_b(3, data); } -WRITE8_HANDLER( r6532_4_portb_w) { r6532_set_input_b(4, data); } -WRITE8_HANDLER( r6532_5_portb_w) { r6532_set_input_b(5, data); } -WRITE8_HANDLER( r6532_6_portb_w) { r6532_set_input_b(6, data); } -WRITE8_HANDLER( r6532_7_portb_w) { r6532_set_input_b(7, data); } - -READ8_HANDLER( r6532_0_porta_r) { return r6532[0].in_a; } -READ8_HANDLER( r6532_1_porta_r) { return r6532[1].in_a; } -READ8_HANDLER( r6532_2_porta_r) { return r6532[2].in_a; } -READ8_HANDLER( r6532_3_porta_r) { return r6532[3].in_a; } -READ8_HANDLER( r6532_4_porta_r) { return r6532[4].in_a; } -READ8_HANDLER( r6532_5_porta_r) { return r6532[5].in_a; } -READ8_HANDLER( r6532_6_porta_r) { return r6532[6].in_a; } -READ8_HANDLER( r6532_7_porta_r) { return r6532[7].in_a; } - -READ8_HANDLER( r6532_0_portb_r) { return r6532[0].in_b; } -READ8_HANDLER( r6532_1_portb_r) { return r6532[1].in_b; } -READ8_HANDLER( r6532_2_portb_r) { return r6532[2].in_b; } -READ8_HANDLER( r6532_3_portb_r) { return r6532[3].in_b; } -READ8_HANDLER( r6532_4_portb_r) { return r6532[4].in_b; } -READ8_HANDLER( r6532_5_portb_r) { return r6532[5].in_b; } -READ8_HANDLER( r6532_6_portb_r) { return r6532[6].in_b; } -READ8_HANDLER( r6532_7_portb_r) { return r6532[7].in_b; } - +DEVICE_GET_INFO( riot6532 ) +{ + switch (state) + { + /* --- the following bits of info are returned as 64-bit signed integers --- */ + case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(riot6532_state); break; + case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(riot6532_config); break; + case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; + + /* --- the following bits of info are returned as pointers to data or functions --- */ + case DEVINFO_FCT_SET_INFO: info->set_info = DEVICE_SET_INFO_NAME(riot6532); break; + case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(riot6532);break; + case DEVINFO_FCT_STOP: /* Nothing */ break; + case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(riot6532);break; + + /* --- the following bits of info are returned as NULL-terminated strings --- */ + case DEVINFO_STR_NAME: info->s = "6532 (RIOT)"; break; + case DEVINFO_STR_FAMILY: info->s = "I/O devices"; break; + case DEVINFO_STR_VERSION: info->s = "1.0"; break; + case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; + case DEVINFO_STR_CREDITS: info->s = "Copyright Nicola Salmoria and the MAME Team"; break; + } +} diff --git a/src/emu/machine/6532riot.h b/src/emu/machine/6532riot.h index e757e97c141..5adaf26e497 100644 --- a/src/emu/machine/6532riot.h +++ b/src/emu/machine/6532riot.h @@ -4,84 +4,72 @@ ***************************************************************************/ -#ifndef RIOT_6532 -#define RIOT_6532 +#ifndef __RIOT6532_H__ +#define __RIOT6532_H__ -#define MAX_R6532 8 -struct riot6532_interface +/*************************************************************************** + TYPE DEFINITIONS +***************************************************************************/ + +typedef struct _riot6532_config riot6532_config; +struct _riot6532_config +{ + UINT32 clock; +}; + + +typedef UINT8 (*riot_read_func)(const device_config *device, UINT8 olddata); +typedef void (*riot_write_func)(const device_config *device, UINT8 newdata, UINT8 olddata); +typedef void (*riot_irq_func)(const device_config *device, int state); + + +typedef struct _riot6532_interface riot6532_interface; +struct _riot6532_interface { - read8_machine_func in_a_func; - read8_machine_func in_b_func; - write8_machine_func out_a_func; - write8_machine_func out_b_func; - void (*irq_func)(running_machine *machine, int state); + riot_read_func in_a_func; + riot_read_func in_b_func; + riot_write_func out_a_func; + riot_write_func out_b_func; + riot_irq_func irq_func; }; -void r6532_set_clock(int which, int clock); -void r6532_reset(running_machine *machine, int which); -void r6532_config(running_machine *machine, int which, const struct riot6532_interface* intf); -UINT8 r6532_read(running_machine *machine, int which, offs_t offset); -void r6532_write(running_machine *machine, int which, offs_t offset, UINT8 data); -void r6532_set_input_a(running_machine *machine, int which, UINT8 data); -void r6532_set_input_b(int which, UINT8 data); - -/******************* Standard 8-bit CPU interfaces, D0-D7 *******************/ - -READ8_HANDLER( r6532_0_r ); -READ8_HANDLER( r6532_1_r ); -READ8_HANDLER( r6532_2_r ); -READ8_HANDLER( r6532_3_r ); -READ8_HANDLER( r6532_4_r ); -READ8_HANDLER( r6532_5_r ); -READ8_HANDLER( r6532_6_r ); -READ8_HANDLER( r6532_7_r ); - -WRITE8_HANDLER( r6532_0_w ); -WRITE8_HANDLER( r6532_1_w ); -WRITE8_HANDLER( r6532_2_w ); -WRITE8_HANDLER( r6532_3_w ); -WRITE8_HANDLER( r6532_4_w ); -WRITE8_HANDLER( r6532_5_w ); -WRITE8_HANDLER( r6532_6_w ); -WRITE8_HANDLER( r6532_7_w ); - -/******************* 8-bit A/B port interfaces *******************/ - -WRITE8_HANDLER( r6532_0_porta_w ); -WRITE8_HANDLER( r6532_1_porta_w ); -WRITE8_HANDLER( r6532_2_porta_w ); -WRITE8_HANDLER( r6532_3_porta_w ); -WRITE8_HANDLER( r6532_4_porta_w ); -WRITE8_HANDLER( r6532_5_porta_w ); -WRITE8_HANDLER( r6532_6_porta_w ); -WRITE8_HANDLER( r6532_7_porta_w ); - -WRITE8_HANDLER( r6532_0_portb_w ); -WRITE8_HANDLER( r6532_1_portb_w ); -WRITE8_HANDLER( r6532_2_portb_w ); -WRITE8_HANDLER( r6532_3_portb_w ); -WRITE8_HANDLER( r6532_4_portb_w ); -WRITE8_HANDLER( r6532_5_portb_w ); -WRITE8_HANDLER( r6532_6_portb_w ); -WRITE8_HANDLER( r6532_7_portb_w ); - -READ8_HANDLER( r6532_0_porta_r ); -READ8_HANDLER( r6532_1_porta_r ); -READ8_HANDLER( r6532_2_porta_r ); -READ8_HANDLER( r6532_3_porta_r ); -READ8_HANDLER( r6532_4_porta_r ); -READ8_HANDLER( r6532_5_porta_r ); -READ8_HANDLER( r6532_6_porta_r ); -READ8_HANDLER( r6532_7_porta_r ); - -READ8_HANDLER( r6532_0_portb_r ); -READ8_HANDLER( r6532_1_portb_r ); -READ8_HANDLER( r6532_2_portb_r ); -READ8_HANDLER( r6532_3_portb_r ); -READ8_HANDLER( r6532_4_portb_r ); -READ8_HANDLER( r6532_5_portb_r ); -READ8_HANDLER( r6532_6_portb_r ); -READ8_HANDLER( r6532_7_portb_r ); + + +/*************************************************************************** + DEVICE CONFIGURATION MACROS +***************************************************************************/ + +#define MDRV_RIOT6532_ADD(_tag, _clock, _intrf) \ + MDRV_DEVICE_ADD(_tag, RIOT6532) \ + MDRV_DEVICE_CONFIG_DATA32(riot6532_config, clock, _clock) \ + MDRV_DEVICE_CONFIG(_intrf) + +#define MDRV_RIOT6532_REMOVE(_tag) \ + MDRV_DEVICE_REMOVE(_tag, RIOT6532) + + + +/*************************************************************************** + FUNCTION PROTOTYPES +***************************************************************************/ + +READ8_DEVICE_HANDLER( riot6532_r ); +WRITE8_DEVICE_HANDLER( riot6532_w ); + +void riot6532_porta_in_set(const device_config *device, UINT8 data, UINT8 mask); +void riot6532_portb_in_set(const device_config *device, UINT8 data, UINT8 mask); + +UINT8 riot6532_porta_in_get(const device_config *device); +UINT8 riot6532_portb_in_get(const device_config *device); + +UINT8 riot6532_porta_out_get(const device_config *device); +UINT8 riot6532_portb_out_get(const device_config *device); + + +/* ----- device interface ----- */ + +#define RIOT6532 DEVICE_GET_INFO_NAME(riot6532) +DEVICE_GET_INFO( riot6532 ); #endif diff --git a/src/mame/audio/exidy.c b/src/mame/audio/exidy.c index dbe09a6ff9f..25824cad390 100644 --- a/src/mame/audio/exidy.c +++ b/src/mame/audio/exidy.c @@ -10,6 +10,7 @@ #include "deprecat.h" #include "cpu/m6502/m6502.h" #include "machine/6821pia.h" +#include "machine/6532riot.h" #include "sound/hc55516.h" #include "sound/5220intf.h" #include "sound/custom.h" @@ -50,16 +51,7 @@ enum static UINT8 riot_irq_state; /* 6532 variables */ -static emu_timer *riot_timer; -static UINT8 riot_irq_flag; -static UINT8 riot_timer_irq_enable; -static UINT8 riot_PA7_irq_enable; -static UINT8 riot_porta_data; -static UINT8 riot_porta_ddr; -static UINT8 riot_portb_data; -static UINT8 riot_portb_ddr; -static int riot_clock_divisor; -static UINT8 riot_state; +static const device_config *riot; /* 6840 variables */ struct sh6840_timer_channel @@ -116,16 +108,6 @@ static double freq_to_step; /************************************* * - * Prototypes - * - *************************************/ - -static TIMER_CALLBACK( riot_interrupt ); - - - -/************************************* - * * Interrupt generation helper * *************************************/ @@ -403,176 +385,64 @@ void exidy_sh6840_sh_reset(void *token) /************************************* * - * 6532 RIOT timer callback + * 6532 interface * *************************************/ -static TIMER_CALLBACK( riot_interrupt ) +static void r6532_irq(const device_config *device, int state) { - /* if we're doing the initial interval counting... */ - if (riot_state == RIOT_COUNT) - { - /* generate the IRQ */ - riot_irq_flag |= 0x80; - riot_irq_state = riot_timer_irq_enable; - update_irq_state(machine, 0); - - /* now start counting clock cycles down */ - riot_state = RIOT_POST_COUNT; - timer_adjust_oneshot(riot_timer, attotime_mul(ATTOTIME_IN_HZ(SH6532_CLOCK), 0xff), 0); - } - - /* if not, we are done counting down */ - else - { - riot_state = RIOT_IDLE; - timer_adjust_oneshot(riot_timer, attotime_never, 0); - } + riot_irq_state = (state == ASSERT_LINE) ? 1 : 0; + update_irq_state(device->machine, 0); } +static void r6532_porta_w(const device_config *device, UINT8 newdata, UINT8 olddata) +{ + if (has_mc3417) + cpunum_set_input_line(device->machine, 2, INPUT_LINE_RESET, (newdata & 0x10) ? CLEAR_LINE : ASSERT_LINE); +} -/************************************* - * - * 6532 RIOT write handler - * - *************************************/ -static WRITE8_HANDLER( exidy_shriot_w ) +static void r6532_portb_w(const device_config *device, UINT8 newdata, UINT8 olddata) { - /* I/O is done if A2 == 0 */ - if ((offset & 0x04) == 0) + if (has_tms5220) { - switch (offset & 0x03) + if ((olddata & 0x01) && !(newdata & 0x01)) { - case 0: /* port A */ - if (has_mc3417) - cpunum_set_input_line(machine, 2, INPUT_LINE_RESET, (data & 0x10) ? CLEAR_LINE : ASSERT_LINE); - riot_porta_data = (riot_porta_data & ~riot_porta_ddr) | (data & riot_porta_ddr); - break; - - case 1: /* port A DDR */ - riot_porta_ddr = data; - break; - - case 2: /* port B */ - if (has_tms5220) - { - if (!(data & 0x01) && (riot_portb_data & 0x01)) - { - riot_porta_data = tms5220_status_r(machine, 0); - logerror("(%f)%04X:TMS5220 status read = %02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), riot_porta_data); - } - if (!(data & 0x02) && (riot_portb_data & 0x02)) - { - logerror("(%f)%04X:TMS5220 data write = %02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), riot_porta_data); - tms5220_data_w(machine, 0, riot_porta_data); - } - } - riot_portb_data = (riot_portb_data & ~riot_portb_ddr) | (data & riot_portb_ddr); - break; - - case 3: /* port B DDR */ - riot_portb_ddr = data; - break; + riot6532_porta_in_set(riot, tms5220_status_r(device->machine, 0), 0xff); + logerror("(%f)%04X:TMS5220 status read = %02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), tms5220_status_r(device->machine, 0)); + } + if ((olddata & 0x02) && !(newdata & 0x02)) + { + logerror("(%f)%04X:TMS5220 data write = %02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), riot6532_porta_out_get(riot)); + tms5220_data_w(device->machine, 0, riot6532_porta_out_get(riot)); } - } - - /* PA7 edge detect control if A2 == 1 and A4 == 0 */ - else if ((offset & 0x10) == 0) - { - riot_PA7_irq_enable = offset & 0x03; - } - - /* timer enable if A2 == 1 and A4 == 1 */ - else - { - static const int divisors[4] = { 1, 8, 64, 1024 }; - - /* make sure the IRQ state is clear */ - if (riot_state != RIOT_COUNT) - riot_irq_flag &= ~0x80; - riot_irq_state = 0; - update_irq_state(machine, 0); - - /* set the enable from the offset */ - riot_timer_irq_enable = (offset & 0x08) ? 1 : 0; - - /* set a new timer */ - riot_clock_divisor = divisors[offset & 0x03]; - timer_adjust_oneshot(riot_timer, attotime_mul(ATTOTIME_IN_HZ(SH6532_CLOCK), data * riot_clock_divisor), 0); - riot_state = RIOT_COUNT; } } - -/************************************* - * - * 6532 RIOT read handler - * - *************************************/ - -static READ8_HANDLER( exidy_shriot_r ) +static UINT8 r6532_portb_r(const device_config *device, UINT8 olddata) { - /* I/O is done if A2 == 0 */ - if ((offset & 0x04) == 0) - { - switch (offset & 0x03) - { - case 0x00: /* port A */ - return riot_porta_data; - - case 0x01: /* port A DDR */ - return riot_porta_ddr; - - case 0x02: /* port B */ - if (has_tms5220) - { - riot_portb_data &= ~0x0c; - if (!tms5220_ready_r()) riot_portb_data |= 0x04; - if (!tms5220_int_r()) riot_portb_data |= 0x08; - } - return riot_portb_data; - - case 0x03: /* port B DDR */ - return riot_portb_ddr; - } - } - - /* interrupt flags are read if A2 == 1 and A0 == 1 */ - else if (offset & 0x01) + UINT8 newdata = olddata; + if (has_tms5220) { - int temp = riot_irq_flag; - riot_irq_flag = 0; - riot_irq_state = 0; - update_irq_state(machine, 0); - return temp; + newdata &= ~0x0c; + if (!tms5220_ready_r()) newdata |= 0x04; + if (!tms5220_int_r()) newdata |= 0x08; } + return newdata; +} - /* timer count is read if A2 == 1 and A0 == 0 */ - else - { - /* set the enable from the offset */ - riot_timer_irq_enable = offset & 0x08; - - /* compute the timer based on the current state */ - switch (riot_state) - { - case RIOT_IDLE: - return 0x00; - - case RIOT_COUNT: - return attotime_to_double(timer_timeleft(riot_timer)) * SH6532_CLOCK / riot_clock_divisor; - case RIOT_POST_COUNT: - return attotime_to_double(timer_timeleft(riot_timer)) * SH6532_CLOCK; - } - } +static const riot6532_interface r6532_interface = +{ + NULL, /* port A read handler */ + r6532_portb_r, /* port B read handler */ + r6532_porta_w, /* port A write handler */ + r6532_portb_w, /* port B write handler */ + r6532_irq /* IRQ callback */ +}; - logerror("Undeclared RIOT read: %x PC:%x\n",offset,activecpu_get_pc()); - return 0xff; -} @@ -762,6 +632,8 @@ static void *venture_common_sh_start(int clock, const struct CustomSound_interfa void *ret = exidy_sh6840_sh_start(clock, config); + riot = device_list_find_by_tag(Machine->config->devicelist, RIOT6532, "riot"); + has_sh8253 = TRUE; has_tms5220 = _has_tms5220; @@ -773,9 +645,6 @@ static void *venture_common_sh_start(int clock, const struct CustomSound_interfa has_mc3417 = TRUE; } - /* 6532 */ - riot_timer = timer_alloc(riot_interrupt, NULL); - /* 8253 */ freq_to_step = (double)(1 << 24) / (double)SH8253_CLOCK; @@ -800,12 +669,7 @@ static void venture_sh_reset(void *token) pia_reset(); /* 6532 */ - riot_irq_flag = 0; - riot_timer_irq_enable = 0; - riot_porta_data = 0xff; - riot_portb_data = 0xff; - riot_clock_divisor = 1; - riot_state = RIOT_IDLE; + device_reset(riot); /* 8253 */ memset(sh8253_timer, 0, sizeof(sh8253_timer)); @@ -823,7 +687,7 @@ static const struct CustomSound_interface venture_custom_interface = static ADDRESS_MAP_START( venture_audio_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_GLOBAL_MASK(0x7fff) AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0780) AM_RAM - AM_RANGE(0x0800, 0x087f) AM_MIRROR(0x0780) AM_READWRITE(exidy_shriot_r, exidy_shriot_w) + AM_RANGE(0x0800, 0x087f) AM_MIRROR(0x0780) AM_DEVREADWRITE(RIOT6532, "riot", riot6532_r, riot6532_w) AM_RANGE(0x1000, 0x1003) AM_MIRROR(0x07fc) AM_READWRITE(pia_1_r, pia_1_w) AM_RANGE(0x1800, 0x1803) AM_MIRROR(0x07fc) AM_READWRITE(exidy_sh8253_r, exidy_sh8253_w) AM_RANGE(0x2000, 0x27ff) AM_WRITE(exidy_sound_filter_w) @@ -838,6 +702,8 @@ MACHINE_DRIVER_START( venture_audio ) MDRV_CPU_ADD("audio", M6502, 3579545/4) MDRV_CPU_PROGRAM_MAP(venture_audio_map,0) + MDRV_RIOT6532_ADD("riot", SH6532_CLOCK, r6532_interface) + MDRV_SPEAKER_STANDARD_MONO("mono") MDRV_SOUND_ADD("custom", CUSTOM, 0) @@ -859,7 +725,7 @@ static WRITE8_HANDLER( mtrap_voiceio_w ) hc55516_digit_w(0, data & 1); if (!(offset & 0x20)) - riot_portb_data = data & 1; + riot6532_portb_in_set(riot, data & 1, 0xff); } @@ -867,10 +733,10 @@ static READ8_HANDLER( mtrap_voiceio_r ) { if (!(offset & 0x80)) { - int data = (riot_porta_data & 0x06) >> 1; - data |= (riot_porta_data & 0x01) << 2; - data |= (riot_porta_data & 0x08); - + UINT8 porta = riot6532_porta_out_get(riot); + UINT8 data = (porta & 0x06) >> 1; + data |= (porta & 0x01) << 2; + data |= (porta & 0x08); return data; } @@ -1017,7 +883,7 @@ static const struct CustomSound_interface victory_custom_interface = static ADDRESS_MAP_START( victory_audio_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x00ff) AM_MIRROR(0x0f00) AM_RAM - AM_RANGE(0x1000, 0x107f) AM_MIRROR(0x0f80) AM_READWRITE(exidy_shriot_r, exidy_shriot_w) + AM_RANGE(0x1000, 0x107f) AM_MIRROR(0x0f80) AM_DEVREADWRITE(RIOT6532, "riot", riot6532_r, riot6532_w) AM_RANGE(0x2000, 0x2003) AM_MIRROR(0x0ffc) AM_READWRITE(pia_1_r, pia_1_w) AM_RANGE(0x3000, 0x3003) AM_MIRROR(0x0ffc) AM_READWRITE(exidy_sh8253_r, exidy_sh8253_w) AM_RANGE(0x4000, 0x4fff) AM_NOP @@ -1033,6 +899,8 @@ MACHINE_DRIVER_START( victory_audio ) MDRV_CPU_ADD("audio", M6502, VICTORY_AUDIO_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(victory_audio_map,0) + MDRV_RIOT6532_ADD("riot", SH6532_CLOCK, r6532_interface) + MDRV_SPEAKER_STANDARD_MONO("mono") MDRV_SOUND_ADD("custom", CUSTOM, 0) diff --git a/src/mame/audio/gottlieb.c b/src/mame/audio/gottlieb.c index 13fb07432c8..1a2e6e9dfa8 100644 --- a/src/mame/audio/gottlieb.c +++ b/src/mame/audio/gottlieb.c @@ -1,12 +1,53 @@ #include "driver.h" #include "deprecat.h" #include "cpu/m6502/m6502.h" +#include "machine/6532riot.h" #include "sound/samples.h" #include "sound/dac.h" #include "sound/ay8910.h" #include "sound/sp0250.h" +static const device_config *riot; + + +/************************************* + * + * RIOT interfaces + * + *************************************/ + +SOUND_START( gottlieb1 ) +{ + riot = device_list_find_by_tag(machine->config->devicelist, RIOT6532, "riot"); +} + +static UINT8 r6532_portb_r(const device_config *device, UINT8 olddata) +{ + return input_port_read(device->machine, "SB1"); +} + +static void r6532_portb_w(const device_config *device, UINT8 newdata, UINT8 olddata) +{ + cpunum_set_input_line(device->machine, 1, INPUT_LINE_NMI, (newdata & 0x80) ? CLEAR_LINE : ASSERT_LINE); +} + + +static void snd_interrupt(const device_config *device, int state) +{ + cpunum_set_input_line(device->machine, 1, M6502_IRQ_LINE, state); +} + + +const riot6532_interface gottlieb_riot6532_intf = +{ + NULL, + r6532_portb_r, + NULL, + r6532_portb_w, + snd_interrupt +}; + static void play_sample(const char *phonemes) { @@ -75,22 +116,24 @@ WRITE8_HANDLER( gottlieb_sh_w ) } } } + } - soundlatch_w(machine,offset,data); - - switch (cpu_gettotalcpu()) + switch (cpu_gettotalcpu()) + { + case 2: + /* Revision 1 sound board */ + riot6532_porta_in_set(riot, (~data & 0x3f) | (((data & 0x0f) != 0x0f) << 7), 0xbf); + break; + case 3: + case 4: + /* Revision 2 & 3 sound board */ + if ((data&0x0f) != 0xf) { - case 2: - /* Revision 1 sound board */ - cpunum_set_input_line(machine, 1,M6502_IRQ_LINE,HOLD_LINE); - break; - case 3: - case 4: - /* Revision 2 & 3 sound board */ + soundlatch_w(machine,offset,data); cpunum_set_input_line(machine, cpu_gettotalcpu()-1,M6502_IRQ_LINE,HOLD_LINE); cpunum_set_input_line(machine, cpu_gettotalcpu()-2,M6502_IRQ_LINE,HOLD_LINE); - break; } + break; } } @@ -168,24 +211,6 @@ WRITE8_HANDLER( gottlieb_speech_clock_DAC_w ) -UINT8 *gottlieb_riot_regs; - /* lazy handling of the 6532's I/O, and no handling of timers at all */ - -READ8_HANDLER( gottlieb_riot_r ) -{ - switch (offset) { - case 0: /* port A */ - return soundlatch_r(machine,0) ^ 0xff; /* invert command */ - case 2: /* port B */ - return 0x40; /* say that PB6 is 1 (test SW1 not pressed) */ - case 5: /* interrupt register */ - return 0x40; /* say that edge detected on PA7 */ - default: - return gottlieb_riot_regs[offset]; - } -} - - static UINT8 psg_latch; @@ -195,7 +220,8 @@ static int sp0250_drq; static UINT8 sp0250_latch; static TIMER_CALLBACK( nmi_callback ); -void gottlieb_sound_init(void) + +SOUND_START( gottlieb2 ) { nmi_timer = timer_alloc(nmi_callback, NULL); } diff --git a/src/mame/audio/starwars.c b/src/mame/audio/starwars.c index 7a36ecc5468..0cbf0b51add 100644 --- a/src/mame/audio/starwars.c +++ b/src/mame/audio/starwars.c @@ -12,159 +12,70 @@ #include "sound/5220intf.h" #include "includes/starwars.h" -/* Sound commands from the main CPU are stored in a single byte */ -/* register. The main CPU then interrupts the Sound CPU. */ -static int port_A = 0; /* 6532 port A data register */ +static UINT8 sound_data; /* data for the sound cpu */ +static UINT8 main_data; /* data for the main cpu */ - /* Configured as follows: */ - /* d7 (in) Main Ready Flag */ - /* d6 (in) Sound Ready Flag */ - /* d5 (out) Mute Speech */ - /* d4 (in) Not Sound Self Test */ - /* d3 (out) Hold Main CPU in Reset? */ - /* + enable delay circuit? */ - /* d2 (in) TMS5220 Not Ready */ - /* d1 (out) TMS5220 Not Read */ - /* d0 (out) TMS5220 Not Write */ +static const device_config *riot; -static int port_B = 0; /* 6532 port B data register */ - /* (interfaces to TMS5220 data bus) */ -static int irq_flag = 0; /* 6532 interrupt flag register */ - -static int port_A_ddr = 0; /* 6532 Data Direction Register A */ -static int port_B_ddr = 0; /* 6532 Data Direction Register B */ - /* for each bit, 0 = input, 1 = output */ - -static int PA7_irq = 0; /* IRQ-on-write flag (sound CPU) */ - -static int sound_data; /* data for the sound cpu */ -static int main_data; /* data for the main cpu */ - - - -/************************************* - * - * Sound interrupt generation - * - *************************************/ - -static TIMER_CALLBACK( snd_interrupt ) +SOUND_START( starwars ) { - irq_flag |= 0x80; /* set timer interrupt flag */ - cpunum_set_input_line(machine, 1, M6809_IRQ_LINE, ASSERT_LINE); + riot = device_list_find_by_tag(machine->config->devicelist, RIOT6532, "riot"); } - /************************************* * - * M6532 I/O read + * RIOT interfaces * *************************************/ -READ8_HANDLER( starwars_m6532_r ) +static UINT8 r6532_porta_r(const device_config *device, UINT8 olddata) { - static int temp; - - switch (offset) - { - case 0: /* 0x80 - Read Port A */ - - /* Note: bit 4 is always set to avoid sound self test */ - - return port_A|0x10|(!tms5220_ready_r()<<2); - - case 1: /* 0x81 - Read Port A DDR */ - return port_A_ddr; - - case 2: /* 0x82 - Read Port B */ - return port_B; /* speech data read? */ - - case 3: /* 0x83 - Read Port B DDR */ - return port_B_ddr; - - case 5: /* 0x85 - Read Interrupt Flag Register */ - if (irq_flag) - cpunum_set_input_line(machine, 1, M6809_IRQ_LINE, CLEAR_LINE); - temp = irq_flag; - irq_flag = 0; /* Clear int flags */ - return temp; - - default: - return 0; - } - + /* Configured as follows: */ + /* d7 (in) Main Ready Flag */ + /* d6 (in) Sound Ready Flag */ + /* d5 (out) Mute Speech */ + /* d4 (in) Not Sound Self Test */ + /* d3 (out) Hold Main CPU in Reset? */ + /* + enable delay circuit? */ + /* d2 (in) TMS5220 Not Ready */ + /* d1 (out) TMS5220 Not Read */ + /* d0 (out) TMS5220 Not Write */ + /* Note: bit 4 is always set to avoid sound self test */ + + return (olddata & 0xc0) | 0x10 | (!tms5220_ready_r() << 2); } - -/************************************* - * - * M6532 I/O write - * - *************************************/ - -WRITE8_HANDLER( starwars_m6532_w ) +static void r6532_porta_w(const device_config *device, UINT8 newdata, UINT8 olddata) { - switch (offset) - { - case 0: /* 0x80 - Port A Write */ - - /* Write to speech chip on PA0 falling edge */ - - if((port_A&0x01)==1) - { - port_A = (port_A&(~port_A_ddr))|(data&port_A_ddr); - if ((port_A&0x01)==0) - tms5220_data_w(machine,0,port_B); - } - else - port_A = (port_A&(~port_A_ddr))|(data&port_A_ddr); - - return; - - case 1: /* 0x81 - Port A DDR Write */ - port_A_ddr = data; - return; - - case 2: /* 0x82 - Port B Write */ - /* TMS5220 Speech Data on port B */ - - /* ignore DDR for now */ - port_B = data; - - return; - - case 3: /* 0x83 - Port B DDR Write */ - port_B_ddr = data; - return; - - case 7: /* 0x87 - Enable Interrupt on PA7 Transitions */ - - /* This feature is emulated now. When the Main CPU */ - /* writes to mainwrite, it may send an IRQ to the */ - /* sound CPU, depending on the state of this flag. */ - - PA7_irq = data; - return; + /* handle 5220 read */ + if ((olddata & 2) != 0 && (newdata & 2) == 0) + riot6532_portb_in_set(riot, tms5220_status_r(device->machine, 0), 0xff); + /* handle 5220 write */ + if ((olddata & 1) != 0 && (newdata & 1) == 0) + tms5220_data_w(device->machine, 0, riot6532_portb_out_get(riot)); +} - case 0x1f: /* 0x9f - Set Timer to decrement every n*1024 clocks, */ - /* With IRQ enabled on countdown */ - /* Should be decrementing every data*1024 6532 clock cycles */ - /* 6532 runs at 1.5 MHz */ +static void snd_interrupt(const device_config *device, int state) +{ + cpunum_set_input_line(device->machine, 1, M6809_IRQ_LINE, state); +} - timer_set(attotime_mul(ATTOTIME_IN_HZ(1500000), data * 1024), NULL, 0, snd_interrupt); - return; - default: - return; - } +const riot6532_interface starwars_riot6532_intf = +{ + r6532_porta_r, + NULL, + r6532_porta_w, + NULL, + snd_interrupt +}; -} @@ -176,16 +87,15 @@ WRITE8_HANDLER( starwars_m6532_w ) static TIMER_CALLBACK( sound_callback ) { - port_A |= 0x40; /* result from sound cpu pending */ + riot6532_porta_in_set(riot, 0x40, 0x40); main_data = param; cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100)); } + READ8_HANDLER( starwars_sin_r ) { - port_A &= 0x7f; /* ready to receive new commands from main */ - if (PA7_irq) - cpunum_set_input_line(machine, 1, M6809_IRQ_LINE, CLEAR_LINE); + riot6532_porta_in_set(riot, 0x00, 0x80); return sound_data; } @@ -205,27 +115,24 @@ WRITE8_HANDLER( starwars_sout_w ) READ8_HANDLER( starwars_main_read_r ) { - port_A &= 0xbf; /* ready to receive new commands from sound cpu */ + riot6532_porta_in_set(riot, 0x00, 0x40); return main_data; } READ8_HANDLER( starwars_main_ready_flag_r ) { - return (port_A & 0xc0); /* only upper two flag bits mapped */ + return riot6532_porta_in_get(riot) & 0xc0; /* only upper two flag bits mapped */ } static TIMER_CALLBACK( main_callback ) { - if (port_A & 0x80) - logerror ("Sound data not read %x\n",sound_data); + if (riot6532_porta_in_get(riot) & 0x80) + logerror("Sound data not read %x\n",sound_data); - port_A |= 0x80; /* command from main cpu pending */ + riot6532_porta_in_set(riot, 0x80, 0x80); sound_data = param; cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100)); - - if (PA7_irq) - cpunum_set_input_line(machine, 1, M6809_IRQ_LINE, ASSERT_LINE); } WRITE8_HANDLER( starwars_main_wr_w ) @@ -236,9 +143,8 @@ WRITE8_HANDLER( starwars_main_wr_w ) WRITE8_HANDLER( starwars_soundrst_w ) { - port_A &= 0x3f; + riot6532_porta_in_set(riot, 0x00, 0xc0); /* reset sound CPU here */ cpunum_set_input_line(machine, 1, INPUT_LINE_RESET, PULSE_LINE); } - diff --git a/src/mame/drivers/gameplan.c b/src/mame/drivers/gameplan.c index 53da22edce4..745196ad416 100644 --- a/src/mame/drivers/gameplan.c +++ b/src/mame/drivers/gameplan.c @@ -146,7 +146,7 @@ static WRITE8_HANDLER( audio_trigger_w ) UINT8 cmd = (data << 7) | (state->audio_cmd & 0x7f); soundlatch_w(machine, 0, cmd); - r6532_0_porta_w(machine, 0, cmd); + riot6532_porta_in_set(state->riot, cmd, 0xff); } @@ -167,19 +167,31 @@ static const struct via6522_interface via_2_interface = * *************************************/ -static void r6532_irq(running_machine *machine, int state) +static void r6532_irq(const device_config *device, int state) { - cpunum_set_input_line(machine, 1, 0, state); + cpunum_set_input_line(device->machine, 1, 0, state); } -static const struct riot6532_interface r6532_interface = +static UINT8 r6532_soundlatch_r(const device_config *device, UINT8 olddata) { - soundlatch_r, /* port A read handler */ - 0, /* port B read handler */ - 0, /* port A write handler */ - soundlatch2_w, /* port B write handler */ - r6532_irq /* IRQ callback */ + return soundlatch_r(device->machine, 0); +} + + +static void r6532_soundlatch2_w(const device_config *device, UINT8 newdata, UINT8 olddata) +{ + soundlatch2_w(device->machine, 0, newdata); +} + + +static const riot6532_interface r6532_interface = +{ + r6532_soundlatch_r, /* port A read handler */ + NULL, /* port B read handler */ + NULL, /* port A write handler */ + r6532_soundlatch2_w, /* port B write handler */ + r6532_irq /* IRQ callback */ }; @@ -193,14 +205,12 @@ static const struct riot6532_interface r6532_interface = static MACHINE_START( gameplan ) { gameplan_state *state = machine->driver_data; + + state->riot = device_list_find_by_tag(machine->config->devicelist, RIOT6532, "riot"); via_config(1, &via_1_interface); via_config(2, &via_2_interface); - r6532_config(machine, 0, &r6532_interface); - r6532_set_clock(0, GAMEPLAN_AUDIO_CPU_CLOCK); - r6532_reset(machine, 0); - /* register for save states */ state_save_register_global(state->current_port); state_save_register_global(state->audio_cmd); @@ -247,7 +257,7 @@ ADDRESS_MAP_END static ADDRESS_MAP_START( gameplan_audio_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x1780) AM_RAM /* 6532 internal RAM */ - AM_RANGE(0x0800, 0x081f) AM_MIRROR(0x17e0) AM_READWRITE(r6532_0_r, r6532_0_w) + AM_RANGE(0x0800, 0x081f) AM_MIRROR(0x17e0) AM_DEVREADWRITE(RIOT6532, "riot", riot6532_r, riot6532_w) AM_RANGE(0x2000, 0x9fff) AM_NOP AM_RANGE(0xa000, 0xa000) AM_MIRROR(0x1ffc) AM_WRITE(AY8910_control_port_0_w) AM_RANGE(0xa001, 0xa001) AM_MIRROR(0x1ffc) AM_READ(AY8910_read_port_0_r) @@ -261,7 +271,7 @@ ADDRESS_MAP_END /* same as Gameplan, but larger ROM */ static ADDRESS_MAP_START( leprechn_audio_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x1780) AM_RAM /* 6532 internal RAM */ - AM_RANGE(0x0800, 0x081f) AM_MIRROR(0x17e0) AM_READWRITE(r6532_0_r, r6532_0_w) + AM_RANGE(0x0800, 0x081f) AM_MIRROR(0x17e0) AM_DEVREADWRITE(RIOT6532, "riot", riot6532_r, riot6532_w) AM_RANGE(0x2000, 0x9fff) AM_NOP AM_RANGE(0xa000, 0xa000) AM_MIRROR(0x1ffc) AM_WRITE(AY8910_control_port_0_w) AM_RANGE(0xa001, 0xa001) AM_MIRROR(0x1ffc) AM_READ(AY8910_read_port_0_r) @@ -1163,7 +1173,7 @@ static const struct AY8910interface ay8910_interface = AY8910_LEGACY_OUTPUT, AY8910_DEFAULT_LOADS, input_port_6_r, - input_port_7_r, + input_port_7_r }; @@ -1178,6 +1188,8 @@ static MACHINE_DRIVER_START( gameplan ) MDRV_CPU_ADD("audio", M6502, GAMEPLAN_AUDIO_CPU_CLOCK) MDRV_CPU_PROGRAM_MAP(gameplan_audio_map,0) + MDRV_RIOT6532_ADD("riot", GAMEPLAN_AUDIO_CPU_CLOCK, r6532_interface) + MDRV_MACHINE_START(gameplan) MDRV_MACHINE_RESET(gameplan) diff --git a/src/mame/drivers/gottlieb.c b/src/mame/drivers/gottlieb.c index c1fc559f655..81b97902df5 100644 --- a/src/mame/drivers/gottlieb.c +++ b/src/mame/drivers/gottlieb.c @@ -1,23 +1,36 @@ /*************************************************************************** -Gottlieb driver : dedicated to Warren Davis, Jeff Lee, Tim Skelly & David Thiel - -driver by Fabrice Frances & Nicola Salmoria -thanks to Frans van Egmond for locating and dumping Tylz - -Notes: -There was a bug in the hardware of the GG1 and GG2 boards, which is not -emulated. The bug seems to have disappeared with the later revision of the -board, e.g the board used by 3Stooges and Mach3 don't seem to have it). -The bug was affecting the first character column (on horizontal games): -screen memory could be used, but whatever was stored in this column, always -the same character was displayed. -This led to two consequences: -- the image on the monitor had to be stretched so that the column was not - visible -- game designers were not using the first column. In fact, when the first - column was ejected from the screen, the last one was usually out too, - so it wasn't used either... + Gottlieb hardware + dedicated to Warren Davis, Jeff Lee, Tim Skelly & David Thiel + + driver by Fabrice Frances & Nicola Salmoria + + Games supported: + * Cloud 9 + * Firebeast + + Known issues: + * none at this time + +**************************************************************************** + + Thanks to Frans van Egmond for locating and dumping Tylz + + Notes: + + There was a bug in the hardware of the GG1 and GG2 boards, which is not + emulated. The bug seems to have disappeared with the later revision of + the board, e.g the board used by 3Stooges and Mach3 don't seem to have + it). The bug was affecting the first character column (on horizontal + games): screen memory could be used, but whatever was stored in this + column, always the same character was displayed. + + This led to two consequences: + - the image on the monitor had to be stretched so that the column was + not visible + - game designers were not using the first column. In fact, when the + first column was ejected from the screen, the last one was usually + out too, so it wasn't used either... **************************************************************************** @@ -148,44 +161,49 @@ VBlank duration: 1/VSYNC * (16/256) = 1017.6 us ***************************************************************************/ #include "driver.h" +#include "machine/6532riot.h" #include "sound/ay8910.h" #include "sound/dac.h" #include "sound/samples.h" #include "sound/sp0250.h" +#include "gottlieb.h" -extern UINT8 *gottlieb_charram; -extern UINT8 *gottlieb_riot_regs; - -extern WRITE8_HANDLER( gottlieb_videoram_w ); -extern WRITE8_HANDLER( gottlieb_charram_w ); -extern WRITE8_HANDLER( gottlieb_video_outputs_w ); -extern WRITE8_HANDLER( usvsthem_video_outputs_w ); -extern WRITE8_HANDLER( gottlieb_paletteram_w ); -VIDEO_START( gottlieb ); -VIDEO_UPDATE( gottlieb ); -VIDEO_START( vidvince ); +#define SYSTEM_CLOCK XTAL_20MHz +#define CPU_CLOCK XTAL_15MHz +#define SOUND1_CLOCK XTAL_3_579545MHz -WRITE8_HANDLER( gottlieb_sh_w ); -READ8_HANDLER( riot_ram_r ); -READ8_HANDLER( gottlieb_riot_r ); -WRITE8_HANDLER( riot_ram_w ); -WRITE8_HANDLER( gottlieb_riot_w ); -WRITE8_HANDLER( gottlieb_speech_w ); -WRITE8_HANDLER( gottlieb_speech_clock_DAC_w ); -void gottlieb_sound_init(void); -void stooges_sp0250_drq(int level); -READ8_HANDLER( stooges_sound_input_r ); -WRITE8_HANDLER( stooges_8910_latch_w ); -WRITE8_HANDLER( stooges_sp0250_latch_w ); -WRITE8_HANDLER( stooges_sound_control_w ); -WRITE8_HANDLER( gottlieb_nmi_rate_w ); -WRITE8_HANDLER( gottlieb_cause_dac_nmi_w ); +/************************************* + * + * Globals + * + *************************************/ static UINT8 *audiobuffer_region; +static int track[2]; +static int joympx; + +static int current_frame = 1; +static int laserdisc_playing; +static int lasermpx; +static int audioptr; +static int audioready=1; +static int skipfirstbyte; +static int discready; +static int lastcmd; +static int odd_field; +static int access_time; + + + +/************************************* + * + * Initialization + * + *************************************/ static MACHINE_RESET( gottlieb ) { @@ -193,47 +211,43 @@ static MACHINE_RESET( gottlieb ) } -static int track[2]; -static READ8_HANDLER( gottlieb_track_0_r ) +/************************************* + * + * Input ports + * + *************************************/ + +static CUSTOM_INPUT( analog_delta_r ) { - return input_port_read(machine, "IN2") - track[0]; + const char *string = param; + int which = string[0] - '0'; + + return input_port_read(field->port->machine, &string[1]) - track[which]; } -static READ8_HANDLER( gottlieb_track_1_r ) -{ - return input_port_read(machine, "IN3") - track[1]; -} -static WRITE8_HANDLER( gottlieb_track_reset_w ) +static WRITE8_HANDLER( gottlieb_analog_reset_w ) { /* reset the trackball counters */ - track[0] = input_port_read(machine, "IN2"); - track[1] = input_port_read(machine, "IN3"); + track[0] = input_port_read_safe(machine, "TRACKX", 0); + track[1] = input_port_read_safe(machine, "TRACKY", 0); } -static int joympx; -static READ8_HANDLER( stooges_IN4_r ) +static CUSTOM_INPUT( stooges_joystick_r ) { - int joy; + static const char *joyport[] = { "P1JOY", "P2JOY", "P3JOY", NULL }; + return (joyport[joympx & 3] != NULL) ? input_port_read(field->port->machine, joyport[joympx & 3]) : 0xff; +} - switch (joympx) - { - case 0: - default: - joy = ((input_port_read(machine, "IN4") >> 0) & 0x0f); /* joystick 1 */ - break; - case 1: - joy = ((input_port_read(machine, "IN5") >> 0) & 0x0f); /* joystick 2 */ - break; - case 2: - joy = ((input_port_read(machine, "IN5") >> 4) & 0x0f); /* joystick 3 */ - break; - } - return joy | (input_port_read(machine, "IN4") & 0xf0); -} + +/************************************* + * + * Output ports + * + *************************************/ static WRITE8_HANDLER( reactor_output_w ) { @@ -243,6 +257,7 @@ static WRITE8_HANDLER( reactor_output_w ) gottlieb_video_outputs_w(machine,offset,data); } + static WRITE8_HANDLER( stooges_output_w ) { joympx = (data >> 5) & 0x03; @@ -250,17 +265,12 @@ static WRITE8_HANDLER( stooges_output_w ) } -static int current_frame = 1; -static int laserdisc_playing; -static int lasermpx; -static int audioptr; -static int audioready=1; -static int skipfirstbyte; -static int discready; -static int lastcmd; -static int odd_field; -static int access_time; +/************************************* + * + * Laserdisc interface + * + *************************************/ /* The only sure thing I know about the Philips 24-bit frame number code is that the * 4 most significant bits are 1's and these four 1's are used to detect a valid frame @@ -285,14 +295,15 @@ static READ8_HANDLER( gottlieb_laserdisc_status_r ) tmp = current_frame % 100; logerror("LSB frame read: %d\n",tmp); return ((tmp / 10) << 4) | (tmp % 10); - break; + case 1: tmp = (current_frame / 100) % 100; logerror("MSB frame read: %d\n",tmp); return ((tmp / 10) << 4) | (tmp % 10); - break; + case 2: - if (lasermpx == 1) { + if (lasermpx == 1) + { /* bits 0-2 frame number MSN */ /* bit 3 audio buffer ready */ /* bit 4 ready to send new laserdisc command? */ @@ -300,13 +311,18 @@ static READ8_HANDLER( gottlieb_laserdisc_status_r ) /* bit 6 break in audio trasmission */ /* bit 7 missing audio clock */ return ((current_frame / 10000) & 0x7) | (audioready << 3) | 0x10 | (discready << 5); - } else { /* read audio buffer */ + } + else + { /* read audio buffer */ if (skipfirstbyte) audioptr++; skipfirstbyte = 0; - if (audiobuffer_region) { + if (audiobuffer_region) + { logerror("audio bufread: %02x\n",audiobuffer_region[audioptr]); return audiobuffer_region[audioptr++]; - } else { + } + else + { logerror("audiobuffer is null !!"); return 0xFF; /* don't know what to do in this case ;-) */ } @@ -381,8 +397,26 @@ logerror("laserdisc command %02x -> %02x\n",data,cmd); } } + + +/************************************* + * + * Interrupt generation + * + *************************************/ + +static TIMER_CALLBACK( nmi_clear ) +{ + cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, CLEAR_LINE); +} + + static INTERRUPT_GEN( gottlieb_interrupt ) { + /* assert the NMI and set a timer to clear it at the first visible line */ + cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, ASSERT_LINE); + timer_set(video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, nmi_clear); + if (access_time > 0) { access_time--; if (access_time == 0) @@ -405,53 +439,75 @@ logerror("current frame : %d\n",current_frame); else audioready = 0; } } - cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); } + +/************************************* + * + * Main CPU memory handlers + * + *************************************/ + static ADDRESS_MAP_START( reactor_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_GLOBAL_MASK(0xffff) - AM_RANGE(0x00000, 0x01fff) AM_RAM - AM_RANGE(0x02000, 0x020ff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram) AM_SIZE(&spriteram_size) - AM_RANGE(0x03000, 0x033ff) AM_MIRROR(0x0400) AM_RAM_WRITE(gottlieb_videoram_w) AM_BASE(&videoram) - AM_RANGE(0x04000, 0x04fff) AM_RAM_WRITE(gottlieb_charram_w) AM_BASE(&gottlieb_charram) - AM_RANGE(0x06000, 0x0601f) AM_WRITE(gottlieb_paletteram_w) AM_BASE(&paletteram) - AM_RANGE(0x07000, 0x07000) AM_READWRITE(input_port_0_r, watchdog_reset_w) /* DSW */ - AM_RANGE(0x07001, 0x07001) AM_READWRITE(input_port_1_r, gottlieb_track_reset_w) /* buttons */ - AM_RANGE(0x07002, 0x07002) AM_READWRITE(gottlieb_track_0_r, gottlieb_sh_w) /* trackball H */ - AM_RANGE(0x07003, 0x07003) AM_READWRITE(gottlieb_track_1_r, reactor_output_w) /* trackball V */ - AM_RANGE(0x07004, 0x07004) AM_READ(input_port_4_r) /* joystick */ - AM_RANGE(0x08000, 0x0ffff) AM_ROM + AM_RANGE(0x0000, 0x1fff) AM_RAM + AM_RANGE(0x2000, 0x20ff) AM_MIRROR(0x0f00) AM_WRITEONLY AM_BASE(&spriteram) /* FRSEL */ + AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM_WRITE(gottlieb_videoram_w) AM_BASE(&videoram) /* BRSEL */ + AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(gottlieb_charram_w) AM_BASE(&gottlieb_charram) /* BOJRSEL1 */ +/* AM_RANGE(0x5000, 0x5fff) AM_WRITE() */ /* BOJRSEL2 */ + AM_RANGE(0x6000, 0x601f) AM_MIRROR(0x0fe0) AM_WRITE(gottlieb_paletteram_w) AM_BASE(&paletteram) /* COLSEL */ + AM_RANGE(0x7000, 0x7000) AM_MIRROR(0x0ff8) AM_WRITE(watchdog_reset_w) + AM_RANGE(0x7001, 0x7001) AM_MIRROR(0x0ff8) AM_WRITE(gottlieb_analog_reset_w) /* A1J2 interface */ + AM_RANGE(0x7002, 0x7002) AM_MIRROR(0x0ff8) AM_WRITE(gottlieb_sh_w) /* trackball H */ + AM_RANGE(0x7003, 0x7003) AM_MIRROR(0x0ff8) AM_WRITE(reactor_output_w) /* trackball V */ + AM_RANGE(0x7000, 0x7000) AM_MIRROR(0x0ff8) AM_READ_PORT("DSW") + AM_RANGE(0x7001, 0x7001) AM_MIRROR(0x0ff8) AM_READ_PORT("IN1") /* buttons */ + AM_RANGE(0x7002, 0x7002) AM_MIRROR(0x0ff8) AM_READ_PORT("IN2") /* trackball H */ + AM_RANGE(0x7003, 0x7003) AM_MIRROR(0x0ff8) AM_READ_PORT("IN3") /* trackball V */ + AM_RANGE(0x7004, 0x7004) AM_MIRROR(0x0ff8) AM_READ_PORT("IN4") + AM_RANGE(0x8000, 0xffff) AM_ROM ADDRESS_MAP_END static ADDRESS_MAP_START( gottlieb_map, ADDRESS_SPACE_PROGRAM, 8 ) ADDRESS_MAP_GLOBAL_MASK(0xffff) - AM_RANGE(0x00000, 0x00fff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) - AM_RANGE(0x01000, 0x01fff) AM_RAM AM_REGION(REGION_CPU1, 0x1000) /* or ROM */ - AM_RANGE(0x02000, 0x02fff) AM_RAM AM_REGION(REGION_CPU1, 0x2000) /* or ROM */ - AM_RANGE(0x03000, 0x037ff) AM_RAM AM_BASE(&spriteram) AM_SIZE(&spriteram_size) // argusg wants to check this - AM_RANGE(0x03800, 0x03bff) AM_MIRROR(0x0400) AM_RAM_WRITE(gottlieb_videoram_w) AM_BASE(&videoram) - AM_RANGE(0x04000, 0x04fff) AM_RAM_WRITE(gottlieb_charram_w) AM_BASE(&gottlieb_charram) - AM_RANGE(0x05000, 0x0501f) AM_WRITE(gottlieb_paletteram_w) AM_BASE(&paletteram) - AM_RANGE(0x05800, 0x05800) AM_READWRITE(input_port_0_r, watchdog_reset_w) /* DSW */ - AM_RANGE(0x05801, 0x05801) AM_READWRITE(input_port_1_r, gottlieb_track_reset_w) /* buttons */ - AM_RANGE(0x05802, 0x05802) AM_READWRITE(gottlieb_track_0_r, gottlieb_sh_w) /* trackball H */ - AM_RANGE(0x05803, 0x05803) AM_READWRITE(gottlieb_track_1_r, gottlieb_video_outputs_w) /* trackball V */ - AM_RANGE(0x05804, 0x05804) AM_READ(input_port_4_r) /* joystick */ - AM_RANGE(0x05805, 0x05807) AM_READ(gottlieb_laserdisc_status_r) - AM_RANGE(0x06000, 0x0ffff) AM_ROM + AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE(&generic_nvram) AM_SIZE(&generic_nvram_size) + AM_RANGE(0x1000, 0x1fff) AM_RAM AM_REGION(REGION_CPU1, 0x1000) /* or ROM */ + AM_RANGE(0x2000, 0x2fff) AM_RAM AM_REGION(REGION_CPU1, 0x2000) /* or ROM */ + AM_RANGE(0x3000, 0x30ff) AM_MIRROR(0x0700) AM_WRITEONLY AM_BASE(&spriteram) /* FRSEL */ + AM_RANGE(0x3800, 0x3bff) AM_MIRROR(0x0400) AM_RAM_WRITE(gottlieb_videoram_w) AM_BASE(&videoram) /* BRSEL */ + AM_RANGE(0x4000, 0x4fff) AM_RAM_WRITE(gottlieb_charram_w) AM_BASE(&gottlieb_charram) /* BOJRSEL1 */ + AM_RANGE(0x5000, 0x501f) AM_MIRROR(0x07e0) AM_WRITE(gottlieb_paletteram_w) AM_BASE(&paletteram) /* COLSEL */ + AM_RANGE(0x5800, 0x5800) AM_MIRROR(0x07f8) AM_WRITE(watchdog_reset_w) + AM_RANGE(0x5801, 0x5801) AM_MIRROR(0x07f8) AM_WRITE(gottlieb_analog_reset_w) /* A1J2 interface */ + AM_RANGE(0x5802, 0x5802) AM_MIRROR(0x07f8) AM_WRITE(gottlieb_sh_w) /* OP20-27 */ + AM_RANGE(0x5803, 0x5803) AM_MIRROR(0x07f8) AM_WRITE(gottlieb_video_outputs_w) /* OP30-37 */ +/* AM_RANGE(0x5804, 0x5804) AM_MIRROR(0x07f8) AM_WRITE()*/ /* OP40-47 */ + AM_RANGE(0x5800, 0x5800) AM_MIRROR(0x07f8) AM_READ_PORT("DSW") + AM_RANGE(0x5801, 0x5801) AM_MIRROR(0x07f8) AM_READ_PORT("IN1") /* IP10-17 */ + AM_RANGE(0x5802, 0x5802) AM_MIRROR(0x07f8) AM_READ_PORT("IN2") /* trackball H */ + AM_RANGE(0x5803, 0x5803) AM_MIRROR(0x07f8) AM_READ_PORT("IN3") /* trackball V */ + AM_RANGE(0x5804, 0x5804) AM_MIRROR(0x07f8) AM_READ_PORT("IN4") /* IP40-47 */ + AM_RANGE(0x6000, 0xffff) AM_ROM ADDRESS_MAP_END -static ADDRESS_MAP_START( gottlieb_sound_map, ADDRESS_SPACE_PROGRAM, 8 ) + +/************************************* + * + * Sound CPU memory handlers + * + *************************************/ + +static ADDRESS_MAP_START( sound1_map, ADDRESS_SPACE_PROGRAM, 8 ) /* A15 not decoded except in expansion socket */ ADDRESS_MAP_GLOBAL_MASK(0x7fff) - AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0180) AM_RAM - AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x01e0) AM_READWRITE(gottlieb_riot_r, SMH_RAM) AM_BASE(&gottlieb_riot_regs) - AM_RANGE(0x1000, 0x1000) AM_WRITE(DAC_0_data_w) - AM_RANGE(0x2000, 0x2000) AM_WRITE(gottlieb_speech_w) - AM_RANGE(0x3000, 0x3000) AM_WRITE(gottlieb_speech_clock_DAC_w) + AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0d80) AM_RAM + AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0de0) AM_DEVREADWRITE(RIOT6532, "riot", riot6532_r, riot6532_w) + AM_RANGE(0x1000, 0x1000) AM_MIRROR(0x0fff) AM_WRITE(DAC_0_data_w) + AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x0fff) AM_WRITE(gottlieb_speech_w) + AM_RANGE(0x3000, 0x3000) AM_MIRROR(0x0fff) AM_WRITE(gottlieb_speech_clock_DAC_w) AM_RANGE(0x6000, 0x7fff) AM_ROM ADDRESS_MAP_END @@ -480,6 +536,12 @@ ADDRESS_MAP_END +/************************************* + * + * Port definitions + * + *************************************/ + static INPUT_PORTS_START( reactor ) PORT_START_TAG("DSW") PORT_DIPNAME( 0x01, 0x01, "Sound with Logos" ) @@ -507,8 +569,8 @@ static INPUT_PORTS_START( reactor ) PORT_DIPSETTING( 0x80, "20000" ) PORT_START_TAG("IN1") - PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_NAME("Select in Service Mode") PORT_CODE(KEYCODE_F1) - PORT_SERVICE( 0x02, IP_ACTIVE_LOW ) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE ) PORT_NAME("Select in Service Mode") PORT_CODE(KEYCODE_F1) + PORT_SERVICE_DIPLOC( 0x02, IP_ACTIVE_LOW, "SB1:8" ) PORT_BIT ( 0xfc, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START_TAG("IN2") /* trackball H */ @@ -525,6 +587,18 @@ static INPUT_PORTS_START( reactor ) PORT_BIT ( 0x10, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_BIT ( 0x20, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_BIT ( 0xc0, IP_ACTIVE_HIGH, IPT_UNKNOWN ) + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ INPUT_PORTS_END static INPUT_PORTS_START( mplanets ) @@ -563,7 +637,7 @@ static INPUT_PORTS_START( mplanets ) PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) PORT_START_TAG("IN3") /* trackball V (dial) */ - PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(5) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_Z) PORT_CODE_INC(KEYCODE_X) + PORT_BIT( 0xff, 0, IPT_SPECIAL ) PORT_CUSTOM(analog_delta_r, "1TRACKY") PORT_START_TAG("IN4") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY @@ -574,6 +648,21 @@ static INPUT_PORTS_START( mplanets ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON2 ) + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ + + PORT_START_TAG("TRACKY") + PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(5) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_Z) PORT_CODE_INC(KEYCODE_X) INPUT_PORTS_END static INPUT_PORTS_START( tylz ) @@ -636,6 +725,18 @@ static INPUT_PORTS_START( tylz ) PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ INPUT_PORTS_END static INPUT_PORTS_START( qbert ) @@ -691,6 +792,18 @@ static INPUT_PORTS_START( qbert ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_4WAY PORT_COCKTAIL PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_COCKTAIL PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_4WAY PORT_COCKTAIL + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ INPUT_PORTS_END static INPUT_PORTS_START( qbertqub ) @@ -750,6 +863,18 @@ static INPUT_PORTS_START( qbertqub ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ INPUT_PORTS_END static INPUT_PORTS_START( krull ) @@ -802,6 +927,18 @@ static INPUT_PORTS_START( krull ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_8WAY PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_8WAY PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_8WAY + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ INPUT_PORTS_END static INPUT_PORTS_START( mach3 ) @@ -953,27 +1090,30 @@ static INPUT_PORTS_START( 3stooges ) PORT_START_TAG("IN3") /* trackball V not used */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START_TAG("IN4") /* joystick 2 (Moe) */ - PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) - PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) - PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) - PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) + PORT_START_TAG("IN4") /* joystick inputs */ + PORT_BIT( 0x0f, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(stooges_joystick_r, NULL) PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(3) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - /* the bottom four bits of the previous port are multiplexed among */ - /* three joysticks - the following port contains settings for the other two */ - PORT_START_TAG("IN5") + PORT_START_TAG("P1JOY") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) + + PORT_START_TAG("P2JOY") + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) + + PORT_START_TAG("P3JOY") PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(3) PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3) PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3) PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3) - PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1) - PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) - PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) - PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) INPUT_PORTS_END static INPUT_PORTS_START( curvebal ) @@ -1037,6 +1177,18 @@ PORT_DIPSETTING( 0xc2, DEF_STR( Free_Play ) ) */ PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_BIT(0x40, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("Bunt") PORT_PLAYER(1) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ INPUT_PORTS_END static INPUT_PORTS_START( screwloo ) @@ -1143,6 +1295,18 @@ static INPUT_PORTS_START( insector ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ INPUT_PORTS_END static INPUT_PORTS_START( vidvince ) @@ -1238,8 +1402,8 @@ static INPUT_PORTS_START( wizwarz ) PORT_START_TAG("IN2") /* trackball H not used */ PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_UNUSED ) - PORT_START_TAG("IN3") /* trackball V not used */ - PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(15) PORT_KEYDELTA(15) PORT_CODE_DEC(KEYCODE_Z) PORT_CODE_INC(KEYCODE_X) + PORT_START_TAG("IN3") /* trackball V is a dial input */ + PORT_BIT( 0xff, 0, IPT_SPECIAL ) PORT_CUSTOM(analog_delta_r, "1TRACKY") PORT_START_TAG("IN4") /* ? */ PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY @@ -1250,6 +1414,9 @@ static INPUT_PORTS_START( wizwarz ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START2 ) + + PORT_START_TAG("TRACKY") + PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(15) PORT_KEYDELTA(15) PORT_CODE_DEC(KEYCODE_Z) PORT_CODE_INC(KEYCODE_X) INPUT_PORTS_END static INPUT_PORTS_START( argusg ) @@ -1288,21 +1455,36 @@ static INPUT_PORTS_START( argusg ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) PORT_START_TAG("IN2") /* trackball H */ - PORT_BIT( 0xff, 0, IPT_TRACKBALL_X ) PORT_SENSITIVITY(15) PORT_KEYDELTA(20) + PORT_BIT( 0xff, 0, IPT_SPECIAL ) PORT_CUSTOM(analog_delta_r, "0TRACKX") PORT_START_TAG("IN3") /* trackball V */ - PORT_BIT( 0xff, 0, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(15) PORT_KEYDELTA(20) + PORT_BIT( 0xff, 0, IPT_SPECIAL ) PORT_CUSTOM(analog_delta_r, "1TRACKY") /* NOTE: Buttons are shared for both players; are mirrored to each side of the controller */ PORT_START_TAG("IN4") - PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) - PORT_BIT ( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) - PORT_BIT ( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) - PORT_BIT ( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) - PORT_BIT ( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_BIT ( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_BIT ( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN ) - PORT_BIT ( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) + PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON2 ) + PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON1 ) + PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) + PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2) + PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN ) + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ + + PORT_START_TAG("TRACKX") + PORT_BIT( 0xff, 0, IPT_TRACKBALL_X ) PORT_SENSITIVITY(15) PORT_KEYDELTA(20) + + PORT_START_TAG("TRACKY") + PORT_BIT( 0xff, 0, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(15) PORT_KEYDELTA(20) INPUT_PORTS_END static INPUT_PORTS_START( kngtmare ) @@ -1356,55 +1538,77 @@ static INPUT_PORTS_START( kngtmare ) PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START1 ) PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START2 ) + + PORT_START_TAG("SB1") + PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SB1:7" ) + PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SB1:6" ) + PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SB1:5" ) + PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SB1:1" ) + PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SB1:4" ) + PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SB1:3" ) + PORT_DIPNAME( 0x40, 0x40, "Sound Test" ) + PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) + PORT_DIPSETTING( 0x00, DEF_STR( On ) ) + PORT_BIT( 0x80, 0x80, IPT_UNKNOWN ) /* To U3-6 on QBert */ INPUT_PORTS_END + + +/************************************* + * + * Graphics definitions + * + *************************************/ + /* the games can store char gfx data in either a 4k RAM area (128 chars), or */ /* a 8k ROM area (256 chars). */ -static const gfx_layout charRAMlayout = +static const gfx_layout bg_ram_layout = { - 8,8, /* 8*8 characters */ - 128, /* 128 characters */ - 4, /* 4 bits per pixel */ - { 0, 1, 2, 3 }, - { 0, 4, 8, 12, 16, 20, 24, 28}, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, - 32*8 /* every char takes 32 consecutive bytes */ + 8,8, + 128, + 4, + { STEP4(0,1) }, + { STEP8(0,4) }, + { STEP8(0,32) }, + 32*8 }; -static const gfx_layout charROMlayout = +static const gfx_layout bg_rom_layout = { - 8,8, /* 8*8 characters */ - 256, /* 256 characters */ - 4, /* 4 bits per pixel */ - { 0, 1, 2, 3 }, - { 0, 4, 8, 12, 16, 20, 24, 28}, - { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 }, - 32*8 /* every char takes 32 consecutive bytes */ + 8,8, + 256, + 4, + { STEP4(0,1) }, + { STEP8(0,4) }, + { STEP8(0,32) }, + 32*8 }; -static const gfx_layout spritelayout = +static const gfx_layout fg_layout = { 16,16, RGN_FRAC(1,4), - 4, /* 4 bits per pixel */ + 4, { RGN_FRAC(0,4), RGN_FRAC(1,4), RGN_FRAC(2,4), RGN_FRAC(3,4) }, - { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }, - { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, - 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, + { STEP16(0,1) }, + { STEP16(0,16) }, 32*8 }; -static GFXDECODE_START( charRAM ) - GFXDECODE_ENTRY( 0, 0x4000, charRAMlayout, 0, 1 ) /* the game dynamically modifies this */ - GFXDECODE_ENTRY( REGION_GFX2, 0x0000, spritelayout, 0, 1 ) +static GFXDECODE_START( gfxdecode ) + GFXDECODE_ENTRY( 0, 0x4000, bg_ram_layout, 0, 1 ) /* the game dynamically modifies this */ + GFXDECODE_ENTRY( REGION_GFX1, 0x0000, bg_rom_layout, 0, 1 ) + GFXDECODE_ENTRY( REGION_GFX2, 0x0000, fg_layout, 0, 1 ) GFXDECODE_END -static GFXDECODE_START( charROM ) - GFXDECODE_ENTRY( REGION_GFX1, 0x0000, charROMlayout, 0, 1 ) - GFXDECODE_ENTRY( REGION_GFX2, 0x0000, spritelayout, 0, 1 ) -GFXDECODE_END +/************************************* + * + * Sound interfaces + * + *************************************/ + static const char *const reactor_sample_names[] = { "*reactor", @@ -1504,43 +1708,29 @@ static const struct sp0250_interface sp0250_interface = -/******************************************************************** -* -* Machine Driver macro -* ==================== -* -* There are two versions of the machine driver, -* one for revision 1 sound board (1x6502 + DAC + Votrax), -* one for revision 2 (2x6502 + DAC + GI SP-0250 speech chip + 2x8910). -* They are identical apart form the sound CPU subsections. -* -********************************************************************/ +/************************************* + * + * Core machine drivers + * + *************************************/ -/* games using the revision 1 sound board */ -static MACHINE_DRIVER_START( gottlieb ) +static MACHINE_DRIVER_START( gottlieb_core ) /* basic machine hardware */ - MDRV_CPU_ADD("main", I8088, 5000000) /* 5 MHz */ + MDRV_CPU_ADD("main", I8088, CPU_CLOCK/3) MDRV_CPU_PROGRAM_MAP(gottlieb_map,0) MDRV_CPU_VBLANK_INT("main", gottlieb_interrupt) - /* audio CPU */ - MDRV_CPU_ADD("sound", M6502, 3579545/4) /* the board can be set to /2 as well */ - MDRV_CPU_PROGRAM_MAP(gottlieb_sound_map,0) - /* NMIs are triggered by the Votrax SC-01 */ - MDRV_MACHINE_RESET(gottlieb) MDRV_NVRAM_HANDLER(generic_1fill) + MDRV_WATCHDOG_VBLANK_INIT(16) /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) - MDRV_SCREEN_REFRESH_RATE(61) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1018) /* frames per second, vblank duration */) MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(32*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 30*8-1) + MDRV_SCREEN_RAW_PARAMS(SYSTEM_CLOCK/4, 318, 0, 256, 256, 0, 240) - MDRV_GFXDECODE(charROM) + MDRV_GFXDECODE(gfxdecode) MDRV_PALETTE_LENGTH(16) MDRV_VIDEO_START(gottlieb) @@ -1548,88 +1738,35 @@ static MACHINE_DRIVER_START( gottlieb ) /* sound hardware */ MDRV_SPEAKER_STANDARD_MONO("mono") - - MDRV_SOUND_ADD("dac", DAC, 0) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) -MACHINE_DRIVER_END - - -static MACHINE_DRIVER_START( reactor ) - - /* basic machine hardware */ - MDRV_IMPORT_FROM(gottlieb) - MDRV_CPU_MODIFY("main") - MDRV_CPU_PROGRAM_MAP(reactor_map,0) - - MDRV_NVRAM_HANDLER(NULL) - - /* video hardware */ - MDRV_GFXDECODE(charRAM) - - MDRV_SOUND_ADD("samples", SAMPLES, 0) - MDRV_SOUND_CONFIG(reactor_samples_interface) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) -MACHINE_DRIVER_END - - -static MACHINE_DRIVER_START( qbert ) - - /* basic machine hardware */ - MDRV_IMPORT_FROM(gottlieb) - - /* video hardware */ - MDRV_SOUND_ADD("samples", SAMPLES, 0) - MDRV_SOUND_CONFIG(qbert_samples_interface) - MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END -static MACHINE_DRIVER_START( krull ) +static MACHINE_DRIVER_START( gottlieb_soundrev1 ) + MDRV_SOUND_START( gottlieb1 ) + + MDRV_RIOT6532_ADD("riot", SOUND1_CLOCK/4, gottlieb_riot6532_intf) - /* basic machine hardware */ - MDRV_IMPORT_FROM(gottlieb) + /* audio CPU */ + MDRV_CPU_ADD("audio", M6502, SOUND1_CLOCK/4) /* the board can be set to /2 as well */ + MDRV_CPU_PROGRAM_MAP(sound1_map,0) - /* video hardware */ - MDRV_GFXDECODE(charRAM) + /* sound hardware */ + MDRV_SOUND_ADD("dac", DAC, 0) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) MACHINE_DRIVER_END -/* games using the revision 2 sound board */ -static MACHINE_DRIVER_START( gottlieb2 ) - - /* basic machine hardware */ - MDRV_CPU_ADD("main", I8088, 5000000) /* 5 MHz */ - MDRV_CPU_PROGRAM_MAP(gottlieb_map,0) - MDRV_CPU_VBLANK_INT("main", gottlieb_interrupt) - - MDRV_CPU_ADD("sound", M6502, 1000000) /* 1 MHz */ - /* audio CPU */ +static MACHINE_DRIVER_START( gottlieb_soundrev2 ) + /* audio CPUs */ + MDRV_CPU_ADD("audio", M6502, 1000000) /* 1 MHz */ MDRV_CPU_PROGRAM_MAP(stooges_sound_map,0) - MDRV_CPU_ADD("sound2", M6502, 1000000) /* 1 MHz */ - /* audio CPU */ + MDRV_CPU_ADD("audio2", M6502, 1000000) /* 1 MHz */ MDRV_CPU_PROGRAM_MAP(stooges_sound2_map,0) - MDRV_MACHINE_RESET(gottlieb) - MDRV_NVRAM_HANDLER(generic_1fill) - - /* video hardware */ - MDRV_SCREEN_ADD("main", RASTER) - MDRV_SCREEN_REFRESH_RATE(61) - MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1018) /* frames per second, vblank duration */) - MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) - MDRV_SCREEN_SIZE(32*8, 32*8) - MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 0*8, 30*8-1) - - MDRV_GFXDECODE(charROM) - MDRV_PALETTE_LENGTH(16) - - MDRV_VIDEO_START(gottlieb) - MDRV_VIDEO_UPDATE(gottlieb) - /* sound hardware */ - MDRV_SPEAKER_STANDARD_MONO("mono") - + MDRV_SOUND_START( gottlieb2 ) + MDRV_SOUND_ADD("dac1", DAC, 0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.15) @@ -1648,27 +1785,57 @@ static MACHINE_DRIVER_START( gottlieb2 ) MACHINE_DRIVER_END -static MACHINE_DRIVER_START( stooges ) +static MACHINE_DRIVER_START( gottlieb1 ) + MDRV_IMPORT_FROM(gottlieb_core) + MDRV_IMPORT_FROM(gottlieb_soundrev1) +MACHINE_DRIVER_END - /* basic machine hardware */ - MDRV_IMPORT_FROM(gottlieb2) - MDRV_GFXDECODE(charRAM) + +static MACHINE_DRIVER_START( gottlieb2 ) + MDRV_IMPORT_FROM(gottlieb_core) + MDRV_IMPORT_FROM(gottlieb_soundrev2) MACHINE_DRIVER_END -static MACHINE_DRIVER_START( vidvince ) + + +/************************************* + * + * Specific machine drivers + * + *************************************/ + +static MACHINE_DRIVER_START( reactor ) + MDRV_IMPORT_FROM(gottlieb1) /* basic machine hardware */ - MDRV_IMPORT_FROM(gottlieb2) - MDRV_VIDEO_START(vidvince) + MDRV_CPU_MODIFY("main") + MDRV_CPU_PROGRAM_MAP(reactor_map,0) + + MDRV_NVRAM_HANDLER(NULL) + /* sound hardware */ + MDRV_SOUND_ADD("samples", SAMPLES, 0) + MDRV_SOUND_CONFIG(reactor_samples_interface) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MACHINE_DRIVER_END -/*************************************************************************** +static MACHINE_DRIVER_START( qbert ) + MDRV_IMPORT_FROM(gottlieb1) + + /* video hardware */ + MDRV_SOUND_ADD("samples", SAMPLES, 0) + MDRV_SOUND_CONFIG(qbert_samples_interface) + MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) +MACHINE_DRIVER_END - Game driver(s) -***************************************************************************/ + +/************************************* + * + * ROM definitions + * + *************************************/ ROM_START( reactor ) ROM_REGION( 0x10000, REGION_CPU1, 0 ) @@ -1685,42 +1852,39 @@ ROM_START( reactor ) ROM_LOAD( "snd1", 0x7000, 0x800, CRC(d958a0fd) SHA1(3c383076c68a929f96d844e89b09f3075f331906) ) ROM_LOAD( "snd2", 0x7800, 0x800, CRC(5dc86942) SHA1(a449fcfb25521a0e7523184518b5204dac56e5f8) ) - /* no gfx1 (RAM is used) */ + ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) + /* no ROMs; RAM is used instead */ ROM_REGION( 0x8000, REGION_GFX2, ROMREGION_DISPOSE ) - /* 0000-0fff empty */ ROM_LOAD( "fg3", 0x1000, 0x1000, CRC(8416ad53) SHA1(f868259b97675e58b6a7f1dc3c2a4ecf6aa0570e) ) /* sprites */ - /* 2000-2fff empty */ ROM_LOAD( "fg2", 0x3000, 0x1000, CRC(5489605a) SHA1(f4bbaaa8cd881dc164b118d1e516edeeea54c1d8) ) - /* 4000-4fff empty */ ROM_LOAD( "fg1", 0x5000, 0x1000, CRC(18396c57) SHA1(39d90a842a03091414ed58d4128b524ecc20c9f1) ) - /* 6000-6fff empty */ ROM_LOAD( "fg0", 0x7000, 0x1000, CRC(d1f20e15) SHA1(dba9aa0fec8b720a33d78b3dd1d7f74040048f7e) ) ROM_END ROM_START( mplanets ) ROM_REGION( 0x10000, REGION_CPU1, 0 ) - ROM_LOAD( "rom4.c16", 0x6000, 0x2000, CRC(5402077f) SHA1(f4e8699ab3c6dfc0f86b6df86d2a5b35caf2ca73) ) - ROM_LOAD( "rom3.c14-15", 0x8000, 0x2000, CRC(5d18d740) SHA1(30307d98704c49dec5aecd0a1ec2f06f1869a5d2) ) - ROM_LOAD( "rom2.c13-14", 0xa000, 0x2000, CRC(960c3bb1) SHA1(305a7904fa8c0b9823ad186d1c5c7460c0900bad) ) - ROM_LOAD( "rom1.c12-13", 0xc000, 0x2000, CRC(eb515f10) SHA1(31c3519328eba7adc4a3b0adcc0384f606d81a57) ) - ROM_LOAD( "rom0.c11-12", 0xe000, 0x2000, CRC(74de78aa) SHA1(7ebd02e660c1413eff284a7ca77feeff41c1e2b7) ) + ROM_LOAD( "rom4.c16", 0x6000, 0x2000, CRC(5402077f) SHA1(f4e8699ab3c6dfc0f86b6df86d2a5b35caf2ca73) ) + ROM_LOAD( "rom3.c14-15", 0x8000, 0x2000, CRC(5d18d740) SHA1(30307d98704c49dec5aecd0a1ec2f06f1869a5d2) ) + ROM_LOAD( "rom2.c13-14", 0xa000, 0x2000, CRC(960c3bb1) SHA1(305a7904fa8c0b9823ad186d1c5c7460c0900bad) ) + ROM_LOAD( "rom1.c12-13", 0xc000, 0x2000, CRC(eb515f10) SHA1(31c3519328eba7adc4a3b0adcc0384f606d81a57) ) + ROM_LOAD( "rom0.c11-12", 0xe000, 0x2000, CRC(74de78aa) SHA1(7ebd02e660c1413eff284a7ca77feeff41c1e2b7) ) /* note from f205v: my original Gottlieb PCB only sports one 2732 sound EPROM labeled "snd.3h" It contains the two joint roms you can find herefollowing, therefore the sound is identical */ ROM_REGION( 0x10000, REGION_CPU2, 0 ) - ROM_LOAD( "snd1", 0x7000, 0x800, CRC(453193a1) SHA1(317ec81f71661eaa92624c0304a52b635dcd5613) ) - ROM_LOAD( "snd2", 0x7800, 0x800, CRC(f5ffc98f) SHA1(516e895df94942fc51f1b51eb9316d4296df82e7) ) + ROM_LOAD( "snd1", 0x7000, 0x0800, CRC(453193a1) SHA1(317ec81f71661eaa92624c0304a52b635dcd5613) ) + ROM_LOAD( "snd2", 0x7800, 0x0800, CRC(f5ffc98f) SHA1(516e895df94942fc51f1b51eb9316d4296df82e7) ) ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) - ROM_LOAD( "bg0.e11-12", 0x0000, 0x1000, CRC(709aa24c) SHA1(95be072bf63320f4b44feaf88003ba011754e20f) ) /* chars */ - ROM_LOAD( "bg1.e13", 0x1000, 0x1000, CRC(4921e345) SHA1(7b6e03458222be501ed150ffbd489433027fc6cb) ) + ROM_LOAD( "bg0.e11-12", 0x0000, 0x1000, CRC(709aa24c) SHA1(95be072bf63320f4b44feaf88003ba011754e20f) ) /* chars */ + ROM_LOAD( "bg1.e13", 0x1000, 0x1000, CRC(4921e345) SHA1(7b6e03458222be501ed150ffbd489433027fc6cb) ) ROM_REGION( 0x8000, REGION_GFX2, ROMREGION_DISPOSE ) - ROM_LOAD( "fg3.k7-8", 0x0000, 0x2000, CRC(c990b39f) SHA1(d1b6060744b78df430e914504b20e8693829bbd5) ) /* sprites */ - ROM_LOAD( "fg2.k6", 0x2000, 0x2000, CRC(735e2522) SHA1(9fac59e9b1d81695d3da32107d640726cf96e31a) ) - ROM_LOAD( "fg1.k5", 0x4000, 0x2000, CRC(6456cc1c) SHA1(12c20f0ce49a7d3579049e8ba95e542c4aaee241) ) - ROM_LOAD( "fg0.k4", 0x6000, 0x2000, CRC(a920e325) SHA1(60f15d5014a55d9c18b06c17c7587d45716619e4) ) + ROM_LOAD( "fg3.k7-8", 0x0000, 0x2000, CRC(c990b39f) SHA1(d1b6060744b78df430e914504b20e8693829bbd5) ) /* sprites */ + ROM_LOAD( "fg2.k6", 0x2000, 0x2000, CRC(735e2522) SHA1(9fac59e9b1d81695d3da32107d640726cf96e31a) ) + ROM_LOAD( "fg1.k5", 0x4000, 0x2000, CRC(6456cc1c) SHA1(12c20f0ce49a7d3579049e8ba95e542c4aaee241) ) + ROM_LOAD( "fg0.k4", 0x6000, 0x2000, CRC(a920e325) SHA1(60f15d5014a55d9c18b06c17c7587d45716619e4) ) ROM_END ROM_START( mplanuk ) @@ -1852,7 +2016,7 @@ ROM_START( qberttst ) ROM_END /* test rom, not a game */ -ROM_START( qbtrktst) +ROM_START( qbtrktst ) ROM_REGION( 0x10000, REGION_CPU1, 0 ) ROM_LOAD( "qb-rom2.bin", 0xa000, 0x2000, CRC(fe434526) SHA1(4cfc5d52dd6c82163e035af82d6112c0c93a3797) ) ROM_LOAD( "qb-rom1.bin", 0xc000, 0x2000, CRC(55635447) SHA1(ca6acdef1c9e06b33efe1f0a2df2dfb03723cfbe) ) @@ -1997,7 +2161,8 @@ ROM_START( krull ) ROM_LOAD( "snd1.bin", 0x6000, 0x1000, CRC(dd2b30b4) SHA1(f01cb64932493bf69d4fc75a7fa809ff6f6e4263) ) ROM_LOAD( "snd2.bin", 0x7000, 0x1000, CRC(8cab901b) SHA1(b886532828efc8cf442e2ee4ebbfe37acd489f62) ) - /* no gfx1 (RAM is used) */ + ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) + /* no ROMs; RAM is used instead */ ROM_REGION( 0x8000, REGION_GFX2, ROMREGION_DISPOSE ) ROM_LOAD( "fg3.bin", 0x0000, 0x2000, CRC(82d77a45) SHA1(753476609c4bf4f0f0cd28d61fd8aef6967bda57) ) /* sprites */ @@ -2096,7 +2261,8 @@ ROM_START( 3stooges ) ROM_LOAD( "yrom2", 0xc000, 0x2000, CRC(90f9c940) SHA1(646dacc902cf235948ac9c064c92390e2764370b) ) ROM_LOAD( "yrom1", 0xe000, 0x2000, CRC(55f8ab30) SHA1(a6b6318f12fd4a1fab61b82cde33759da615d5b2) ) - /* no gfx1 (RAM is used) */ + ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) + /* no ROMs; RAM is used instead */ ROM_REGION( 0x8000, REGION_GFX2, ROMREGION_DISPOSE ) ROM_LOAD( "gv113fg3", 0x0000, 0x2000, CRC(28071212) SHA1(33ce5cfae3491658f8b4cb977dc2da0a75dffee4) ) /* sprites */ @@ -2144,7 +2310,8 @@ ROM_START( vidvince ) ROM_LOAD( "gv132_yrom1_snd_2764.n3", 0xe000, 0x2000, CRC(befa4b97) SHA1(424b40844629631a3f31cc12c61ac7000b5f3eb9) ) ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) - ROM_LOAD( "gv132_bg0_2732.e11e12", 0x1000, 0x1000, CRC(1521bb4a) SHA1(a3a1209c74f1ca18f0be2d2c7b1fa2af625dfa5f) ) /* chars */ + ROM_LOAD( "gv132_bg0_2732.e11e12", 0x0000, 0x1000, CRC(1521bb4a) SHA1(a3a1209c74f1ca18f0be2d2c7b1fa2af625dfa5f) ) /* chars */ + /* RAM is used for the other half */ ROM_REGION( 0x8000, REGION_GFX2, ROMREGION_DISPOSE ) ROM_LOAD( "gv132_fg3_2764.k7k8", 0x0000, 0x2000, CRC(42a78a52) SHA1(7d24006d6746d21939dd0c6241a8d67c42073163) ) /* sprites */ @@ -2192,7 +2359,8 @@ ROM_START( argusg ) ROM_LOAD( "arg_snd1_2716.u5", 0x7000, 0x800, CRC(3a6cf455) SHA1(0c701aa4d956947a101212b494b030cd2df5a2d6) ) ROM_LOAD( "arg_snd2_2716.u6", 0x7800, 0x800, CRC(ddf32040) SHA1(61ae22faa013b29a5fbd9520073f172a98ca38ec) ) - /* no gfx1 (RAM is used) */ + ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) + /* no ROMs; RAM is used instead */ ROM_REGION( 0x8000, REGION_GFX2, ROMREGION_DISPOSE ) ROM_LOAD( "arg_fg3_2764.k7k8", 0x0000, 0x2000, CRC(cdb6e25c) SHA1(d439a4c777c585d1ee89410816c9f7580f7e0ae8) ) /* sprites */ @@ -2211,60 +2379,89 @@ ROM_START( kngtmare ) ROM_REGION( 0x10000, REGION_CPU2, 0 ) ROM_LOAD( "gv112_snd", 0x7000, 0x1000, NO_DUMP ) + ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) + ROM_LOAD( "gv112_bg0_2732.e11e12", 0x0000, 0x1000, CRC(a74591fd) SHA1(e6916cfa44cbe4c0d58fb0307c70580a6fabfcf1) ) + ROM_LOAD( "gv112_bg1_2732.e13", 0x1000, 0x1000, CRC(5a226e6a) SHA1(faf119a8db823f2fc57c0e789b5f3486bca1feb1) ) + ROM_REGION( 0x8000, REGION_GFX2, ROMREGION_DISPOSE ) ROM_LOAD( "gv112_fg3_2764.k7k8", 0x0000, 0x2000, CRC(d1886658) SHA1(2ba452acfb3548c02137c8732e1f7cf8f4c31275) ) ROM_LOAD( "gv112_fg2_2764.k6", 0x2000, 0x2000, CRC(e1c73f0c) SHA1(3e91d6184f94b06ab0342504da387ac41d1a83b3) ) ROM_LOAD( "gv112_fg1_2764.k5", 0x4000, 0x2000, CRC(724bc3ea) SHA1(305945e7224c3463083c7579a826ec7eba846067) ) ROM_LOAD( "gv112_fg0_2764.k4", 0x6000, 0x2000, CRC(0311bbd9) SHA1(0a4f8268dab696bcb25738a482add24fb1f5f09d) ) - - ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) - ROM_LOAD( "gv112_bg0_2732.e11e12", 0x0000, 0x1000, CRC(a74591fd) SHA1(e6916cfa44cbe4c0d58fb0307c70580a6fabfcf1) ) - ROM_LOAD( "gv112_bg1_2732.e13", 0x1000, 0x1000, CRC(5a226e6a) SHA1(faf119a8db823f2fc57c0e789b5f3486bca1feb1) ) ROM_END -static DRIVER_INIT( gottlieb ) + +/************************************* + * + * Driver initialization + * + *************************************/ + +static DRIVER_INIT( ramtiles ) +{ + gottlieb_gfxcharlo = gottlieb_gfxcharhi = 0; +} + + +static DRIVER_INIT( romtiles ) { - gottlieb_sound_init(); + gottlieb_gfxcharlo = gottlieb_gfxcharhi = 1; } + +static DRIVER_INIT( vidvince ) +{ + gottlieb_gfxcharlo = 1; + gottlieb_gfxcharhi = 0; +} + + static DRIVER_INIT( stooges ) { - gottlieb_sound_init(); - memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x05804, 0x05804, 0, 0, stooges_IN4_r); + DRIVER_INIT_CALL(ramtiles); memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x05803, 0x05803, 0, 0, stooges_output_w); } + static DRIVER_INIT( laserdsc ) { - gottlieb_sound_init(); + DRIVER_INIT_CALL(romtiles); + memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x05805, 0x05807, 0, 0x007f8, gottlieb_laserdisc_status_r); memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x05803, 0x05803, 0, 0, usvsthem_video_outputs_w); /* OUT1 */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x05805, 0x05805, 0, 0, gottlieb_laserdisc_command_w); /* command for the player */ memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x05806, 0x05806, 0, 0, gottlieb_laserdisc_mpx_w); } -GAME( 1982, reactor, 0, reactor, reactor, 0, ROT0, "Gottlieb", "Reactor", 0 ) -GAME( 1982, qbert, 0, qbert, qbert, 0, ROT270, "Gottlieb", "Q*bert (US set 1)", 0 ) -GAME( 1982, qberta, qbert, qbert, qbert, 0, ROT270, "Gottlieb", "Q*bert (US set 2)", 0 ) -GAME( 1982, qbertjp, qbert, qbert, qbert, 0, ROT270, "Gottlieb (Konami license)", "Q*bert (Japan)", 0 ) -GAME( 1982, myqbert, qbert, qbert, qbert, 0, ROT270, "Gottlieb", "Mello Yello Q*bert", 0 ) -GAME( 1982, qberttst, qbert, qbert, qbert, 0, ROT270, "Gottlieb", "Q*bert (early test version)", 0 ) -GAME( 1982, qbtrktst, qbert, qbert, qbert, 0, ROT270, "Gottlieb", "Q*bert Board Input Test Rom", 0 ) -GAME( 1982, insector, 0, gottlieb, insector, 0, ROT0, "Gottlieb", "Insector (prototype)", 0 ) -GAME( 1982, tylz, 0, qbert, tylz, 0, ROT0, "Mylstar", "Tylz (prototype)", GAME_IMPERFECT_SOUND ) // modified sound hw? -GAME( 1984, argusg, 0, krull, argusg, 0, ROT0, "Gottlieb", "Argus (Gottlieb, prototype)" , 0) // aka Guardian / Protector? -GAME( 1983, mplanets, 0, gottlieb, mplanets, 0, ROT270, "Gottlieb", "Mad Planets", 0 ) -GAME( 1983, mplanuk, mplanets, gottlieb, mplanets, 0, ROT270, "Gottlieb (Taitel license)", "Mad Planets (UK)", 0 ) -GAME( 1983, krull, 0, krull, krull, 0, ROT270, "Gottlieb", "Krull", 0 ) -GAME( 1983, kngtmare, 0, gottlieb, kngtmare, 0, ROT0, "Gottlieb", "Knightmare (prototype)", GAME_NO_SOUND ) -GAME( 1983, sqbert, 0, qbert, qbert, 0, ROT270, "Mylstar", "Faster, Harder, More Challenging Q*bert (prototype)", 0 ) -GAME( 1983, qbertqub, 0, qbert, qbertqub, 0, ROT270, "Mylstar", "Q*bert's Qubes", 0 ) -GAME( 1983, mach3, 0, gottlieb2,mach3, laserdsc, ROT0, "Mylstar", "M.A.C.H. 3", GAME_NOT_WORKING ) -GAME( 1983, screwloo, 0, gottlieb2,screwloo, gottlieb, ROT0, "Mylstar", "Screw Loose (prototype)", 0 ) -GAME( 1984, cobram3, 0, gottlieb2,mach3, laserdsc, ROT0, "Data East","Cobra Command", GAME_NOT_WORKING ) -GAME( 1984, curvebal, 0, gottlieb, curvebal, 0, ROT270, "Mylstar", "Curve Ball", 0 ) -GAME( 1984, usvsthem, 0, gottlieb2,usvsthem, laserdsc, ROT0, "Mylstar", "Us vs. Them", GAME_NOT_WORKING ) -GAME( 1984, 3stooges, 0, stooges, 3stooges, stooges, ROT0, "Mylstar", "The Three Stooges In Brides Is Brides", 0 ) -GAME( 1984, vidvince, 0, vidvince, vidvince, gottlieb, ROT0, "Mylstar", "Video Vince and the Game Factory (prototype)", GAME_IMPERFECT_GRAPHICS ) // sprite wrapping issues -GAME( 1984, wizwarz, 0, gottlieb2,wizwarz, gottlieb, ROT0, "Mylstar", "Wiz Warz (prototype)", 0 ) + +/************************************* + * + * Game drivers + * + *************************************/ + +GAME( 1982, reactor, 0, reactor, reactor, ramtiles, ROT0, "Gottlieb", "Reactor", 0 ) +GAME( 1982, qbert, 0, qbert, qbert, romtiles, ROT270, "Gottlieb", "Q*bert (US set 1)", 0 ) +GAME( 1982, qberta, qbert, qbert, qbert, romtiles, ROT270, "Gottlieb", "Q*bert (US set 2)", 0 ) +GAME( 1982, qbertjp, qbert, qbert, qbert, romtiles, ROT270, "Gottlieb (Konami license)", "Q*bert (Japan)", 0 ) +GAME( 1982, myqbert, qbert, qbert, qbert, romtiles, ROT270, "Gottlieb", "Mello Yello Q*bert", 0 ) +GAME( 1982, qberttst, qbert, qbert, qbert, romtiles, ROT270, "Gottlieb", "Q*bert (early test version)", 0 ) +GAME( 1982, qbtrktst, qbert, qbert, qbert, romtiles, ROT270, "Gottlieb", "Q*bert Board Input Test Rom", 0 ) +GAME( 1982, insector, 0, gottlieb1, insector, romtiles, ROT0, "Gottlieb", "Insector (prototype)", 0 ) +GAME( 1982, tylz, 0, qbert, tylz, romtiles, ROT0, "Mylstar", "Tylz (prototype)", GAME_IMPERFECT_SOUND ) // modified sound hw? +GAME( 1984, argusg, 0, gottlieb1, argusg, ramtiles, ROT0, "Gottlieb", "Argus (Gottlieb, prototype)" , 0) // aka Guardian / Protector? +GAME( 1983, mplanets, 0, gottlieb1, mplanets, romtiles, ROT270, "Gottlieb", "Mad Planets", 0 ) +GAME( 1983, mplanuk, mplanets, gottlieb1, mplanets, romtiles, ROT270, "Gottlieb (Taitel license)", "Mad Planets (UK)", 0 ) +GAME( 1983, krull, 0, gottlieb1, krull, ramtiles, ROT270, "Gottlieb", "Krull", 0 ) +GAME( 1983, kngtmare, 0, gottlieb1, kngtmare, romtiles, ROT0, "Gottlieb", "Knightmare (prototype)", GAME_NO_SOUND ) +GAME( 1983, sqbert, 0, qbert, qbert, romtiles, ROT270, "Mylstar", "Faster, Harder, More Challenging Q*bert (prototype)", 0 ) +GAME( 1983, qbertqub, 0, qbert, qbertqub, romtiles, ROT270, "Mylstar", "Q*bert's Qubes", 0 ) +GAME( 1983, mach3, 0, gottlieb2, mach3, laserdsc, ROT0, "Mylstar", "M.A.C.H. 3", GAME_NOT_WORKING ) +GAME( 1983, screwloo, 0, gottlieb2, screwloo, romtiles, ROT0, "Mylstar", "Screw Loose (prototype)", 0 ) +GAME( 1984, cobram3, 0, gottlieb2, mach3, laserdsc, ROT0, "Data East","Cobra Command", GAME_NOT_WORKING ) +GAME( 1984, curvebal, 0, gottlieb1, curvebal, romtiles, ROT270, "Mylstar", "Curve Ball", 0 ) +GAME( 1984, usvsthem, 0, gottlieb2, usvsthem, laserdsc, ROT0, "Mylstar", "Us vs. Them", GAME_NOT_WORKING ) +GAME( 1984, 3stooges, 0, gottlieb2, 3stooges, stooges, ROT0, "Mylstar", "The Three Stooges In Brides Is Brides", 0 ) +GAME( 1984, vidvince, 0, gottlieb2, vidvince, vidvince, ROT0, "Mylstar", "Video Vince and the Game Factory (prototype)", GAME_IMPERFECT_GRAPHICS ) // sprite wrapping issues +GAME( 1984, wizwarz, 0, gottlieb2, wizwarz, romtiles, ROT0, "Mylstar", "Wiz Warz (prototype)", 0 ) diff --git a/src/mame/drivers/starwars.c b/src/mame/drivers/starwars.c index 5f992c913b0..6a0c6bb5dd2 100644 --- a/src/mame/drivers/starwars.c +++ b/src/mame/drivers/starwars.c @@ -196,7 +196,7 @@ static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 ) AM_RANGE(0x0000, 0x07ff) AM_WRITE(starwars_sout_w) AM_RANGE(0x0800, 0x0fff) AM_READ(starwars_sin_r) /* SIN Read */ AM_RANGE(0x1000, 0x107f) AM_RAM /* 6532 ram */ - AM_RANGE(0x1080, 0x109f) AM_READWRITE(starwars_m6532_r, starwars_m6532_w) + AM_RANGE(0x1080, 0x109f) AM_DEVREADWRITE(RIOT6532, "riot", riot6532_r, riot6532_w) AM_RANGE(0x1800, 0x183f) AM_WRITE(quad_pokey_w) AM_RANGE(0x2000, 0x27ff) AM_RAM /* program RAM */ AM_RANGE(0x4000, 0x7fff) AM_ROM /* sound roms */ @@ -385,6 +385,8 @@ static MACHINE_DRIVER_START( starwars ) MDRV_MACHINE_RESET(starwars) MDRV_NVRAM_HANDLER(generic_0fill) + + MDRV_RIOT6532_ADD("riot", MASTER_CLOCK / 8, starwars_riot6532_intf) /* video hardware */ MDRV_SCREEN_ADD("main", VECTOR) @@ -396,6 +398,7 @@ static MACHINE_DRIVER_START( starwars ) MDRV_VIDEO_UPDATE(vector) /* sound hardware */ + MDRV_SOUND_START(starwars) MDRV_SPEAKER_STANDARD_MONO("mono") MDRV_SOUND_ADD("pokey1", POKEY, 1500000) diff --git a/src/mame/drivers/tourtabl.c b/src/mame/drivers/tourtabl.c index 96c33c25e57..44943ad3adb 100644 --- a/src/mame/drivers/tourtabl.c +++ b/src/mame/drivers/tourtabl.c @@ -16,39 +16,14 @@ #define MASTER_CLOCK 3579575 -static UINT8* r6532_0_ram; -static UINT8* r6532_1_ram; - - - -static WRITE8_HANDLER( tourtabl_led_w ) +static void tourtabl_led_w(const device_config *device, UINT8 newdata, UINT8 olddata) { - set_led_status(0, data & 0x40); /* start 1 */ - set_led_status(1, data & 0x20); /* start 2 */ - set_led_status(2, data & 0x10); /* start 4 */ - set_led_status(3, data & 0x80); /* select game */ - - coin_lockout_global_w(!(data & 0x80)); -} - + set_led_status(0, newdata & 0x40); /* start 1 */ + set_led_status(1, newdata & 0x20); /* start 2 */ + set_led_status(2, newdata & 0x10); /* start 4 */ + set_led_status(3, newdata & 0x80); /* select game */ -static WRITE8_HANDLER( r6532_0_ram_w ) -{ - r6532_0_ram[offset] = data; -} -static WRITE8_HANDLER( r6532_1_ram_w ) -{ - r6532_1_ram[offset] = data; -} - - -static READ8_HANDLER( r6532_0_ram_r ) -{ - return r6532_0_ram[offset]; -} -static READ8_HANDLER( r6532_1_ram_r ) -{ - return r6532_1_ram[offset]; + coin_lockout_global_w(!(newdata & 0x80)); } @@ -65,46 +40,56 @@ static READ8_HANDLER( tourtabl_get_databus_contents ) } -static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x007F) AM_READ(tia_r) - AM_RANGE(0x0080, 0x00FF) AM_READ(r6532_0_ram_r) - AM_RANGE(0x0100, 0x017F) AM_READ(tia_r) - AM_RANGE(0x0180, 0x01FF) AM_READ(r6532_0_ram_r) - AM_RANGE(0x0280, 0x029F) AM_READ(r6532_0_r) - AM_RANGE(0x0400, 0x047F) AM_READ(r6532_1_ram_r) - AM_RANGE(0x0500, 0x051F) AM_READ(r6532_1_r) - AM_RANGE(0x0800, 0x1FFF) AM_READ(SMH_ROM) - AM_RANGE(0xE800, 0xFFFF) AM_READ(SMH_ROM) +static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 ) + AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_READWRITE(tia_r, tia_w) + AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM + AM_RANGE(0x0280, 0x029f) AM_DEVREADWRITE(RIOT6532, "riot1", riot6532_r, riot6532_w) + AM_RANGE(0x0400, 0x047f) AM_RAM + AM_RANGE(0x0500, 0x051f) AM_DEVREADWRITE(RIOT6532, "riot2", riot6532_r, riot6532_w) + AM_RANGE(0x0800, 0x1fff) AM_ROM + AM_RANGE(0xe800, 0xffff) AM_ROM ADDRESS_MAP_END -static ADDRESS_MAP_START( writemem, ADDRESS_SPACE_PROGRAM, 8 ) - AM_RANGE(0x0000, 0x007F) AM_WRITE(tia_w) - AM_RANGE(0x0080, 0x00FF) AM_WRITE(r6532_0_ram_w) AM_BASE(&r6532_0_ram) - AM_RANGE(0x0100, 0x017F) AM_WRITE(tia_w) - AM_RANGE(0x0180, 0x01FF) AM_WRITE(r6532_0_ram_w) - AM_RANGE(0x0280, 0x029F) AM_WRITE(r6532_0_w) - AM_RANGE(0x0400, 0x047F) AM_WRITE(r6532_1_ram_w) AM_BASE(&r6532_1_ram) - AM_RANGE(0x0500, 0x051F) AM_WRITE(r6532_1_w) - AM_RANGE(0x0800, 0x1FFF) AM_WRITE(SMH_ROM) - AM_RANGE(0xE800, 0xFFFF) AM_WRITE(SMH_ROM) -ADDRESS_MAP_END +static UINT8 port6_r(const device_config *device, UINT8 olddata) +{ + return input_port_read_indexed(device->machine, 6); +} + +static UINT8 port7_r(const device_config *device, UINT8 olddata) +{ + return input_port_read_indexed(device->machine, 7); +} +static UINT8 port8_r(const device_config *device, UINT8 olddata) +{ + return input_port_read_indexed(device->machine, 8); +} -static const struct riot6532_interface r6532_interface_0 = +static UINT8 port9_r(const device_config *device, UINT8 olddata) { - input_port_6_r, - input_port_7_r, + return input_port_read_indexed(device->machine, 9); +} + +static void watchdog_w(const device_config *device, UINT8 newdata, UINT8 olddata) +{ + watchdog_reset(device->machine); +} + +static const riot6532_interface r6532_interface_0 = +{ + port6_r, + port7_r, NULL, - watchdog_reset_w, + watchdog_w, NULL }; -static const struct riot6532_interface r6532_interface_1 = +static const riot6532_interface r6532_interface_1 = { - input_port_8_r, - input_port_9_r, + port8_r, + port9_r, NULL, tourtabl_led_w, NULL @@ -121,11 +106,6 @@ static const struct tia_interface tourtabl_tia_interface = static MACHINE_START( tourtabl ) { - r6532_config(machine, 0, &r6532_interface_0); - r6532_config(machine, 1, &r6532_interface_1); - r6532_reset(machine, 0); - r6532_reset(machine, 1); - tia_init( machine, &tourtabl_tia_interface ); } @@ -208,9 +188,12 @@ INPUT_PORTS_END static MACHINE_DRIVER_START( tourtabl ) /* basic machine hardware */ MDRV_CPU_ADD("main", M6502, MASTER_CLOCK / 3) /* actually M6507 */ - MDRV_CPU_PROGRAM_MAP(readmem, writemem) + MDRV_CPU_PROGRAM_MAP(main_map,0) MDRV_MACHINE_START(tourtabl) + + MDRV_RIOT6532_ADD("riot1", MASTER_CLOCK / 3, r6532_interface_0) + MDRV_RIOT6532_ADD("riot2", MASTER_CLOCK / 3, r6532_interface_1) /* video hardware */ MDRV_SCREEN_ADD("main", RASTER) diff --git a/src/mame/includes/gameplan.h b/src/mame/includes/gameplan.h index f3c1bd0d378..d42fcc0c670 100644 --- a/src/mame/includes/gameplan.h +++ b/src/mame/includes/gameplan.h @@ -22,6 +22,7 @@ struct _gameplan_state UINT8 current_port; UINT8 audio_cmd; UINT8 *trvquest_question; + const device_config *riot; /* video state */ UINT8 *videoram; diff --git a/src/mame/includes/starwars.h b/src/mame/includes/starwars.h index f44a99c7c2d..f90e61e2d7a 100644 --- a/src/mame/includes/starwars.h +++ b/src/mame/includes/starwars.h @@ -4,6 +4,9 @@ ***************************************************************************/ +#include "machine/6532riot.h" + + /*----------- defined in drivers/starwars.c -----------*/ extern UINT8 starwars_is_esb; @@ -34,6 +37,10 @@ WRITE8_HANDLER( starwars_math_w ); /*----------- defined in audio/starwars.c -----------*/ +extern const riot6532_interface starwars_riot6532_intf; + +SOUND_START( starwars ); + READ8_HANDLER( starwars_main_read_r ); READ8_HANDLER( starwars_main_ready_flag_r ); WRITE8_HANDLER( starwars_main_wr_w ); diff --git a/src/mame/video/gottlieb.c b/src/mame/video/gottlieb.c index 9f5e008234c..40c4e8bbdfb 100644 --- a/src/mame/video/gottlieb.c +++ b/src/mame/video/gottlieb.c @@ -7,17 +7,23 @@ ***************************************************************************/ #include "driver.h" +#include "video/resnet.h" UINT8 *gottlieb_charram; +UINT8 gottlieb_gfxcharlo; +UINT8 gottlieb_gfxcharhi; + static int background_priority = 0; static int spritebank; static tilemap *bg_tilemap; -static int swap_bg_ramrom; static UINT8 last_video_outputs; +static double weights[4]; + + /*************************************************************************** Gottlieb games dosn't have a color PROM. They use 32 bytes of RAM to @@ -47,43 +53,16 @@ static UINT8 last_video_outputs; ***************************************************************************/ WRITE8_HANDLER( gottlieb_paletteram_w ) { - int bit0, bit1, bit2, bit3; int r, g, b, val; paletteram[offset] = data; - - /* red component */ - + val = paletteram[offset | 1]; - - bit0 = (val >> 0) & 0x01; - bit1 = (val >> 1) & 0x01; - bit2 = (val >> 2) & 0x01; - bit3 = (val >> 3) & 0x01; - - r = 0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3; - - /* green component */ + r = combine_4_weights(weights, (val >> 0) & 1, (val >> 1) & 1, (val >> 2) & 1, (val >> 3) & 1); val = paletteram[offset & ~1]; - - bit0 = (val >> 4) & 0x01; - bit1 = (val >> 5) & 0x01; - bit2 = (val >> 6) & 0x01; - bit3 = (val >> 7) & 0x01; - - g = 0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3; - - /* blue component */ - - val = paletteram[offset & ~1]; - - bit0 = (val >> 0) & 0x01; - bit1 = (val >> 1) & 0x01; - bit2 = (val >> 2) & 0x01; - bit3 = (val >> 3) & 0x01; - - b = 0x10 * bit0 + 0x21 * bit1 + 0x46 * bit2 + 0x88 * bit3; + g = combine_4_weights(weights, (val >> 4) & 1, (val >> 5) & 1, (val >> 6) & 1, (val >> 7) & 1); + b = combine_4_weights(weights, (val >> 0) & 1, (val >> 1) & 1, (val >> 2) & 1, (val >> 3) & 1); palette_set_color(machine, offset / 2, MAKE_RGB(r, g, b)); } @@ -140,9 +119,7 @@ WRITE8_HANDLER( gottlieb_charram_w ) if (gottlieb_charram[offset] != data) { gottlieb_charram[offset] = data; - decodechar(machine->gfx[0], offset / 32, gottlieb_charram); - tilemap_mark_all_tiles_dirty(bg_tilemap); } } @@ -150,35 +127,35 @@ WRITE8_HANDLER( gottlieb_charram_w ) static TILE_GET_INFO( get_bg_tile_info ) { int code = videoram[tile_index]; - - SET_TILE_INFO(0, code^swap_bg_ramrom, 0, 0); -} - -static void gottlieb_video_start_common(void) -{ - bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, - 8, 8, 32, 32); - - tilemap_set_transparent_pen(bg_tilemap, 0); + if ((code & 0x80) == 0) + SET_TILE_INFO(gottlieb_gfxcharlo, code, 0, 0); + else + SET_TILE_INFO(gottlieb_gfxcharhi, code, 0, 0); } VIDEO_START( gottlieb ) { - swap_bg_ramrom = 0x00; - gottlieb_video_start_common(); -} + static const int resistances[4] = { 2000, 1000, 470, 240 }; + + /* compute palette information */ + /* note that there really are pullup/pulldown resistors, but this situation is complicated */ + /* by the use of transistors, so we ignore that and just use the realtive resistor weights */ + compute_resistor_weights(0, 255, -1.0, + 4, resistances, weights, 180, 0, + 4, resistances, weights, 180, 0, + 4, resistances, weights, 180, 0); + + bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32); + tilemap_set_transparent_pen(bg_tilemap, 0); + tilemap_set_scrolldx(bg_tilemap, 0, 318 - 256); -VIDEO_START( vidvince ) -{ - swap_bg_ramrom = 0x80; - gottlieb_video_start_common(); } static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) { int offs; - for (offs = 0; offs < spriteram_size - 8; offs += 4) /* it seems there's something strange with sprites #62 and #63 */ + for (offs = 0; offs < 256; offs += 4) /* it seems there's something strange with sprites #62 and #63 */ { /* coordinates hand tuned to make the position correct in Q*Bert Qubes start */ /* of level animation. */ @@ -190,7 +167,7 @@ static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const recta if (flip_screen_y_get()) sy = 244 - sy; if (spriteram[offs] || spriteram[offs + 1]) /* needed to avoid garbage on screen */ - drawgfx(bitmap, machine->gfx[1], + drawgfx(bitmap, machine->gfx[2], code, 0, flip_screen_x_get(), flip_screen_y_get(), sx,sy, |