And some more. Converted the ds2404 to a device along the way.

This commit is contained in:
Aaron Giles 2009-12-21 16:10:00 +00:00
parent a9697769d9
commit ead42740ca
20 changed files with 267 additions and 196 deletions

View File

@ -17,7 +17,8 @@ typedef enum {
DS2404_STATE_COPY_SCRATCHPAD /* Copy Scratchpad command active */ DS2404_STATE_COPY_SCRATCHPAD /* Copy Scratchpad command active */
} DS2404_STATE; } DS2404_STATE;
typedef struct { typedef struct _ds2404_state ds2404_state;
struct _ds2404_state {
UINT16 address; UINT16 address;
UINT16 offset; UINT16 offset;
UINT16 end_offset; UINT16 end_offset;
@ -27,17 +28,25 @@ typedef struct {
UINT8 rtc[5]; /* 40-bit RTC counter */ UINT8 rtc[5]; /* 40-bit RTC counter */
DS2404_STATE state[8]; DS2404_STATE state[8];
int state_ptr; int state_ptr;
} DS2404; };
static DS2404 ds2404; INLINE ds2404_state *get_safe_token(const device_config *device)
{
assert(device != NULL);
assert(device->token != NULL);
assert(device->type == DS2404);
static void ds2404_rom_cmd(UINT8 cmd) return (ds2404_state *)device->token;
}
static void ds2404_rom_cmd(ds2404_state *state, UINT8 cmd)
{ {
switch(cmd) switch(cmd)
{ {
case 0xcc: /* Skip ROM */ case 0xcc: /* Skip ROM */
ds2404.state[0] = DS2404_STATE_COMMAND; state->state[0] = DS2404_STATE_COMMAND;
ds2404.state_ptr = 0; state->state_ptr = 0;
break; break;
default: default:
@ -46,33 +55,33 @@ static void ds2404_rom_cmd(UINT8 cmd)
} }
} }
static void ds2404_cmd(UINT8 cmd) static void ds2404_cmd(ds2404_state *state, UINT8 cmd)
{ {
switch(cmd) switch(cmd)
{ {
case 0x0f: /* Write scratchpad */ case 0x0f: /* Write scratchpad */
ds2404.state[0] = DS2404_STATE_ADDRESS1; state->state[0] = DS2404_STATE_ADDRESS1;
ds2404.state[1] = DS2404_STATE_ADDRESS2; state->state[1] = DS2404_STATE_ADDRESS2;
ds2404.state[2] = DS2404_STATE_INIT_COMMAND; state->state[2] = DS2404_STATE_INIT_COMMAND;
ds2404.state[3] = DS2404_STATE_WRITE_SCRATCHPAD; state->state[3] = DS2404_STATE_WRITE_SCRATCHPAD;
ds2404.state_ptr = 0; state->state_ptr = 0;
break; break;
case 0x55: /* Copy scratchpad */ case 0x55: /* Copy scratchpad */
ds2404.state[0] = DS2404_STATE_ADDRESS1; state->state[0] = DS2404_STATE_ADDRESS1;
ds2404.state[1] = DS2404_STATE_ADDRESS2; state->state[1] = DS2404_STATE_ADDRESS2;
ds2404.state[2] = DS2404_STATE_OFFSET; state->state[2] = DS2404_STATE_OFFSET;
ds2404.state[3] = DS2404_STATE_INIT_COMMAND; state->state[3] = DS2404_STATE_INIT_COMMAND;
ds2404.state[4] = DS2404_STATE_COPY_SCRATCHPAD; state->state[4] = DS2404_STATE_COPY_SCRATCHPAD;
ds2404.state_ptr = 0; state->state_ptr = 0;
break; break;
case 0xf0: /* Read memory */ case 0xf0: /* Read memory */
ds2404.state[0] = DS2404_STATE_ADDRESS1; state->state[0] = DS2404_STATE_ADDRESS1;
ds2404.state[1] = DS2404_STATE_ADDRESS2; state->state[1] = DS2404_STATE_ADDRESS2;
ds2404.state[2] = DS2404_STATE_INIT_COMMAND; state->state[2] = DS2404_STATE_INIT_COMMAND;
ds2404.state[3] = DS2404_STATE_READ_MEMORY; state->state[3] = DS2404_STATE_READ_MEMORY;
ds2404.state_ptr = 0; state->state_ptr = 0;
break; break;
default: default:
@ -81,47 +90,50 @@ static void ds2404_cmd(UINT8 cmd)
} }
} }
static UINT8 ds2404_readmem(void) static UINT8 ds2404_readmem(ds2404_state *state)
{ {
if( ds2404.address < 0x200 ) if( state->address < 0x200 )
{ {
return ds2404.sram[ ds2404.address ]; return state->sram[ state->address ];
} }
else if( ds2404.address >= 0x202 && ds2404.address <= 0x206 ) else if( state->address >= 0x202 && state->address <= 0x206 )
{ {
return ds2404.rtc[ ds2404.address - 0x202 ]; return state->rtc[ state->address - 0x202 ];
} }
return 0; return 0;
} }
static void ds2404_writemem(UINT8 value) static void ds2404_writemem(ds2404_state *state, UINT8 value)
{ {
if( ds2404.address < 0x200 ) if( state->address < 0x200 )
{ {
ds2404.sram[ ds2404.address ] = value; state->sram[ state->address ] = value;
} }
else if( ds2404.address >= 0x202 && ds2404.address <= 0x206 ) else if( state->address >= 0x202 && state->address <= 0x206 )
{ {
ds2404.rtc[ ds2404.address - 0x202 ] = value; state->rtc[ state->address - 0x202 ] = value;
} }
} }
WRITE8_HANDLER( DS2404_1W_reset_w ) WRITE8_DEVICE_HANDLER( ds2404_1w_reset_w )
{ {
ds2404.state[0] = DS2404_STATE_IDLE; ds2404_state *state = get_safe_token(device);
ds2404.state_ptr = 0; state->state[0] = DS2404_STATE_IDLE;
state->state_ptr = 0;
} }
WRITE8_HANDLER( DS2404_3W_reset_w ) WRITE8_DEVICE_HANDLER( ds2404_3w_reset_w )
{ {
ds2404.state[0] = DS2404_STATE_COMMAND; ds2404_state *state = get_safe_token(device);
ds2404.state_ptr = 0; state->state[0] = DS2404_STATE_COMMAND;
state->state_ptr = 0;
} }
READ8_HANDLER( DS2404_data_r ) READ8_DEVICE_HANDLER( ds2404_data_r )
{ {
ds2404_state *state = get_safe_token(device);
UINT8 value; UINT8 value;
switch( ds2404.state[ds2404.state_ptr] ) switch( state->state[state->state_ptr] )
{ {
case DS2404_STATE_IDLE: case DS2404_STATE_IDLE:
case DS2404_STATE_COMMAND: case DS2404_STATE_COMMAND:
@ -132,13 +144,13 @@ READ8_HANDLER( DS2404_data_r )
break; break;
case DS2404_STATE_READ_MEMORY: case DS2404_STATE_READ_MEMORY:
value = ds2404_readmem(); value = ds2404_readmem(state);
return value; return value;
case DS2404_STATE_READ_SCRATCHPAD: case DS2404_STATE_READ_SCRATCHPAD:
if( ds2404.offset < 0x20 ) { if( state->offset < 0x20 ) {
value = ds2404.ram[ds2404.offset]; value = state->ram[state->offset];
ds2404.offset++; state->offset++;
return value; return value;
} }
break; break;
@ -152,33 +164,34 @@ READ8_HANDLER( DS2404_data_r )
return 0; return 0;
} }
WRITE8_HANDLER( DS2404_data_w ) WRITE8_DEVICE_HANDLER( ds2404_data_w )
{ {
ds2404_state *state = get_safe_token(device);
int i; int i;
switch( ds2404.state[ds2404.state_ptr] ) switch( state->state[state->state_ptr] )
{ {
case DS2404_STATE_IDLE: case DS2404_STATE_IDLE:
ds2404_rom_cmd(data & 0xff); ds2404_rom_cmd(state, data & 0xff);
break; break;
case DS2404_STATE_COMMAND: case DS2404_STATE_COMMAND:
ds2404_cmd(data & 0xff); ds2404_cmd(state, data & 0xff);
break; break;
case DS2404_STATE_ADDRESS1: case DS2404_STATE_ADDRESS1:
ds2404.a1 = data & 0xff; state->a1 = data & 0xff;
ds2404.state_ptr++; state->state_ptr++;
break; break;
case DS2404_STATE_ADDRESS2: case DS2404_STATE_ADDRESS2:
ds2404.a2 = data & 0xff; state->a2 = data & 0xff;
ds2404.state_ptr++; state->state_ptr++;
break; break;
case DS2404_STATE_OFFSET: case DS2404_STATE_OFFSET:
ds2404.end_offset = data & 0xff; state->end_offset = data & 0xff;
ds2404.state_ptr++; state->state_ptr++;
break; break;
case DS2404_STATE_INIT_COMMAND: case DS2404_STATE_INIT_COMMAND:
@ -191,9 +204,9 @@ WRITE8_HANDLER( DS2404_data_w )
break; break;
case DS2404_STATE_WRITE_SCRATCHPAD: case DS2404_STATE_WRITE_SCRATCHPAD:
if( ds2404.offset < 0x20 ) { if( state->offset < 0x20 ) {
ds2404.ram[ds2404.offset] = data & 0xff; state->ram[state->offset] = data & 0xff;
ds2404.offset++; state->offset++;
} else { } else {
/* Set OF flag */ /* Set OF flag */
} }
@ -203,8 +216,8 @@ WRITE8_HANDLER( DS2404_data_w )
break; break;
} }
if( ds2404.state[ds2404.state_ptr] == DS2404_STATE_INIT_COMMAND ) { if( state->state[state->state_ptr] == DS2404_STATE_INIT_COMMAND ) {
switch( ds2404.state[ds2404.state_ptr+1] ) switch( state->state[state->state_ptr+1] )
{ {
case DS2404_STATE_IDLE: case DS2404_STATE_IDLE:
case DS2404_STATE_COMMAND: case DS2404_STATE_COMMAND:
@ -215,36 +228,37 @@ WRITE8_HANDLER( DS2404_data_w )
break; break;
case DS2404_STATE_READ_MEMORY: case DS2404_STATE_READ_MEMORY:
ds2404.address = (ds2404.a2 << 8) | ds2404.a1; state->address = (state->a2 << 8) | state->a1;
ds2404.address -= 1; state->address -= 1;
break; break;
case DS2404_STATE_WRITE_SCRATCHPAD: case DS2404_STATE_WRITE_SCRATCHPAD:
ds2404.address = (ds2404.a2 << 8) | ds2404.a1; state->address = (state->a2 << 8) | state->a1;
ds2404.offset = ds2404.address & 0x1f; state->offset = state->address & 0x1f;
break; break;
case DS2404_STATE_READ_SCRATCHPAD: case DS2404_STATE_READ_SCRATCHPAD:
ds2404.address = (ds2404.a2 << 8) | ds2404.a1; state->address = (state->a2 << 8) | state->a1;
ds2404.offset = ds2404.address & 0x1f; state->offset = state->address & 0x1f;
break; break;
case DS2404_STATE_COPY_SCRATCHPAD: case DS2404_STATE_COPY_SCRATCHPAD:
ds2404.address = (ds2404.a2 << 8) | ds2404.a1; state->address = (state->a2 << 8) | state->a1;
for( i=0; i <= ds2404.end_offset; i++ ) { for( i=0; i <= state->end_offset; i++ ) {
ds2404_writemem( ds2404.ram[i] ); ds2404_writemem( state, state->ram[i] );
ds2404.address++; state->address++;
} }
break; break;
} }
ds2404.state_ptr++; state->state_ptr++;
} }
} }
WRITE8_HANDLER( DS2404_clk_w ) WRITE8_DEVICE_HANDLER( ds2404_clk_w )
{ {
switch( ds2404.state[ds2404.state_ptr] ) ds2404_state *state = get_safe_token(device);
switch( state->state[state->state_ptr] )
{ {
case DS2404_STATE_IDLE: case DS2404_STATE_IDLE:
case DS2404_STATE_COMMAND: case DS2404_STATE_COMMAND:
@ -255,7 +269,7 @@ WRITE8_HANDLER( DS2404_clk_w )
break; break;
case DS2404_STATE_READ_MEMORY: case DS2404_STATE_READ_MEMORY:
ds2404.address++; state->address++;
break; break;
case DS2404_STATE_READ_SCRATCHPAD: case DS2404_STATE_READ_SCRATCHPAD:
@ -269,52 +283,74 @@ WRITE8_HANDLER( DS2404_clk_w )
} }
} }
static TIMER_CALLBACK( DS2404_tick ) static TIMER_CALLBACK( ds2404_tick )
{ {
ds2404_state *state = get_safe_token(ptr);
int i; int i;
for( i = 0; i < 5; i++ ) for( i = 0; i < 5; i++ )
{ {
ds2404.rtc[ i ]++; state->rtc[ i ]++;
if( ds2404.rtc[ i ] != 0 ) if( state->rtc[ i ] != 0 )
{ {
break; break;
} }
} }
} }
void DS2404_init(running_machine *machine, int ref_year, int ref_month, int ref_day)
static DEVICE_START( ds2404 )
{ {
ds2404_config *config = (ds2404_config *)device->inline_config;
ds2404_state *state = get_safe_token(device);
struct tm ref_tm; struct tm ref_tm;
time_t ref_time; time_t ref_time;
time_t current_time; time_t current_time;
emu_timer *timer; emu_timer *timer;
memset( &ref_tm, 0, sizeof( ref_tm ) ); memset( &ref_tm, 0, sizeof( ref_tm ) );
ref_tm.tm_year = ref_year - 1900; ref_tm.tm_year = config->ref_year - 1900;
ref_tm.tm_mon = ref_month - 1; ref_tm.tm_mon = config->ref_month - 1;
ref_tm.tm_mday = ref_day; ref_tm.tm_mday = config->ref_day;
ref_time = mktime( &ref_tm ); ref_time = mktime( &ref_tm );
time( &current_time ); time( &current_time );
current_time -= ref_time; current_time -= ref_time;
ds2404.rtc[ 0 ] = 0x0; state->rtc[ 0 ] = 0x0;
ds2404.rtc[ 1 ] = ( current_time >> 0 ) & 0xff; state->rtc[ 1 ] = ( current_time >> 0 ) & 0xff;
ds2404.rtc[ 2 ] = ( current_time >> 8 ) & 0xff; state->rtc[ 2 ] = ( current_time >> 8 ) & 0xff;
ds2404.rtc[ 3 ] = ( current_time >> 16 ) & 0xff; state->rtc[ 3 ] = ( current_time >> 16 ) & 0xff;
ds2404.rtc[ 4 ] = ( current_time >> 24 ) & 0xff; state->rtc[ 4 ] = ( current_time >> 24 ) & 0xff;
timer = timer_alloc( machine, DS2404_tick , NULL); timer = timer_alloc( device->machine, ds2404_tick , (void *)device);
timer_adjust_periodic( timer, ATTOTIME_IN_HZ( 256 ), 0, ATTOTIME_IN_HZ( 256 ) ); timer_adjust_periodic( timer, ATTOTIME_IN_HZ( 256 ), 0, ATTOTIME_IN_HZ( 256 ) );
} }
void DS2404_load(mame_file *file)
static DEVICE_RESET( ds2404 )
{ {
mame_fread(file, ds2404.sram, 512);
} }
void DS2404_save(mame_file *file)
static DEVICE_NVRAM( ds2404 )
{ {
mame_fwrite(file, ds2404.sram, 512); ds2404_state *state = get_safe_token(device);
if (read_or_write)
mame_fwrite(file, state->sram, sizeof(state->sram));
else if (file)
mame_fread(file, state->sram, sizeof(state->sram));
else
memset(state->sram, 0, sizeof(state->sram));
} }
static const char DEVTEMPLATE_SOURCE[] = __FILE__;
#define DEVTEMPLATE_ID(p,s) p##ds2404##s
#define DEVTEMPLATE_FEATURES DT_HAS_START | DT_HAS_RESET | DT_HAS_NVRAM | DT_HAS_INLINE_CONFIG
#define DEVTEMPLATE_NAME "DS2404"
#define DEVTEMPLATE_FAMILY "NVRAM"
#include "devtempl.h"

View File

@ -1,18 +1,34 @@
#ifndef DS2404_H #ifndef DS2404_H
#define DS2404_H #define DS2404_H
void DS2404_init(running_machine *machine, int ref_year, int ref_month, int ref_day); typedef struct _ds2404_config ds2404_config;
void DS2404_load(mame_file *file); struct _ds2404_config
void DS2404_save(mame_file *file); {
UINT32 ref_year;
UINT8 ref_month;
UINT8 ref_day;
};
#define MDRV_DS2404_ADD(_tag, _ref_year, _ref_month, _ref_day) \
MDRV_DEVICE_ADD(_tag, DS2404, 0) \
MDRV_DEVICE_CONFIG_DATA32(ds2404_config, ref_year, _ref_year) \
MDRV_DEVICE_CONFIG_DATA32(ds2404_config, ref_month, _ref_month) \
MDRV_DEVICE_CONFIG_DATA32(ds2404_config, ref_day, _ref_day)
/* 1-wire interface reset */ /* 1-wire interface reset */
WRITE8_HANDLER( DS2404_1W_reset_w ); WRITE8_DEVICE_HANDLER( ds2404_1w_reset_w );
/* 3-wire interface reset */ /* 3-wire interface reset */
WRITE8_HANDLER( DS2404_3W_reset_w ); WRITE8_DEVICE_HANDLER( ds2404_3w_reset_w );
READ8_HANDLER( DS2404_data_r ); READ8_DEVICE_HANDLER( ds2404_data_r );
WRITE8_HANDLER( DS2404_data_w ); WRITE8_DEVICE_HANDLER( ds2404_data_w );
WRITE8_HANDLER( DS2404_clk_w ); WRITE8_DEVICE_HANDLER( ds2404_clk_w );
/* device get info callback */
#define DS2404 DEVICE_GET_INFO_NAME(ds2404)
DEVICE_GET_INFO( ds2404 );
#endif #endif

View File

@ -106,11 +106,16 @@ static void tmp68301_update_timer( running_machine *machine, int i )
} }
} }
MACHINE_RESET( tmp68301 ) MACHINE_START( tmp68301 )
{ {
int i; int i;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
tmp68301_timer[i] = timer_alloc(machine, tmp68301_timer_callback, NULL); tmp68301_timer[i] = timer_alloc(machine, tmp68301_timer_callback, NULL);
}
MACHINE_RESET( tmp68301 )
{
int i;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
tmp68301_IE[i] = 0; tmp68301_IE[i] = 0;

View File

@ -2,6 +2,7 @@
#define TMP68301_H #define TMP68301_H
// Machine init // Machine init
MACHINE_START( tmp68301 );
MACHINE_RESET( tmp68301 ); MACHINE_RESET( tmp68301 );
// Hardware Registers // Hardware Registers

View File

@ -234,9 +234,9 @@ void state_save_register_memory(running_machine *machine, const char *module, co
/* check for invalid timing */ /* check for invalid timing */
if (!global->reg_allowed) if (!global->reg_allowed)
{ {
logerror("Attempt to register save state entry after state registration is closed! module %s tag %s name %s\n",module, tag, name); logerror("Attempt to register save state entry after state registration is closed!\nFile: %s, line %d, module %s tag %s name %s\n", file, line, module, tag, name);
if (machine->gamedrv->flags & GAME_SUPPORTS_SAVE) if (machine->gamedrv->flags & GAME_SUPPORTS_SAVE)
fatalerror("Attempt to register save state entry after state registration is closed! module %s tag %s name %s\n", module, tag, name); fatalerror("Attempt to register save state entry after state registration is closed!\nFile: %s, line %d, module %s tag %s name %s\n", file, line, module, tag, name);
global->illegal_regs++; global->illegal_regs++;
return; return;
} }

View File

@ -644,6 +644,8 @@ INLINE emu_timer *_timer_alloc_common(running_machine *machine, timer_fired_func
/* if we're not temporary, register ourselves with the save state system */ /* if we're not temporary, register ourselves with the save state system */
if (!temp) if (!temp)
{ {
if (!state_save_registration_allowed(machine))
fatalerror("timer_alloc() called after save state registration closed! (file %s, line %d)\n", file, line);
timer_register_save(timer); timer_register_save(timer);
restrack_register_object(OBJTYPE_TIMER, timer, 0, file, line); restrack_register_object(OBJTYPE_TIMER, timer, 0, file, line);
} }

View File

@ -302,7 +302,7 @@ MACHINE_DRIVER_END
* *
*************************************/ *************************************/
static TIMER_CALLBACK( increment_t1_clock ) static TIMER_DEVICE_CALLBACK( increment_t1_clock )
{ {
/* only increment if it is not being forced clear */ /* only increment if it is not being forced clear */
if (!(usb.last_p2_value & 0x80)) if (!(usb.last_p2_value & 0x80))
@ -316,7 +316,6 @@ void sega_usb_reset(running_machine *machine, UINT8 t1_clock_mask)
cpu_set_input_line(usb.cpu, INPUT_LINE_RESET, ASSERT_LINE); cpu_set_input_line(usb.cpu, INPUT_LINE_RESET, ASSERT_LINE);
/* start the clock timer */ /* start the clock timer */
timer_pulse(machine, attotime_mul(ATTOTIME_IN_HZ(USB_2MHZ_CLOCK), 256), NULL, 0, increment_t1_clock);
usb.t1_clock_mask = t1_clock_mask; usb.t1_clock_mask = t1_clock_mask;
} }
@ -923,6 +922,8 @@ MACHINE_DRIVER_START( sega_universal_sound_board )
MDRV_CPU_PROGRAM_MAP(usb_map) MDRV_CPU_PROGRAM_MAP(usb_map)
MDRV_CPU_IO_MAP(usb_portmap) MDRV_CPU_IO_MAP(usb_portmap)
MDRV_TIMER_ADD_PERIODIC("usb_timer", increment_t1_clock, HZ(USB_2MHZ_CLOCK / 256))
/* sound hardware */ /* sound hardware */
MDRV_SOUND_ADD("usbsnd", USB, 0) MDRV_SOUND_ADD("usbsnd", USB, 0)
MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0) MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)

View File

@ -143,6 +143,8 @@ static MACHINE_DRIVER_START( nitedrvr )
MDRV_MACHINE_START(nitedrvr) MDRV_MACHINE_START(nitedrvr)
MDRV_MACHINE_RESET(nitedrvr) MDRV_MACHINE_RESET(nitedrvr)
MDRV_TIMER_ADD_PERIODIC("crash_timer", nitedrvr_crash_toggle_callback, NSEC(PERIOD_OF_555_ASTABLE_NSEC(RES_K(180), 330, CAP_U(1))))
// video hardware // video hardware

View File

@ -3277,6 +3277,7 @@ static MACHINE_DRIVER_START( theglobp )
MDRV_CPU_PROGRAM_MAP(epos_map) MDRV_CPU_PROGRAM_MAP(epos_map)
MDRV_CPU_IO_MAP(theglobp_portmap) MDRV_CPU_IO_MAP(theglobp_portmap)
MDRV_MACHINE_START(theglobp)
MDRV_MACHINE_RESET(theglobp) MDRV_MACHINE_RESET(theglobp)
MACHINE_DRIVER_END MACHINE_DRIVER_END
@ -3290,6 +3291,7 @@ static MACHINE_DRIVER_START( acitya )
MDRV_CPU_PROGRAM_MAP(epos_map) MDRV_CPU_PROGRAM_MAP(epos_map)
MDRV_CPU_IO_MAP(acitya_portmap) MDRV_CPU_IO_MAP(acitya_portmap)
MDRV_MACHINE_START(acitya)
MDRV_MACHINE_RESET(acitya) MDRV_MACHINE_RESET(acitya)
MACHINE_DRIVER_END MACHINE_DRIVER_END

View File

@ -25,7 +25,7 @@ static UINT16* pkscramble_mdtilemap_ram;
static UINT16* pkscramble_bgtilemap_ram; static UINT16* pkscramble_bgtilemap_ram;
static tilemap *fg_tilemap, *md_tilemap, *bg_tilemap; static tilemap *fg_tilemap, *md_tilemap, *bg_tilemap;
static emu_timer *scanline_timer; static const device_config *scanline_timer;
static WRITE16_HANDLER( pkscramble_fgtilemap_w ) static WRITE16_HANDLER( pkscramble_fgtilemap_w )
{ {
@ -191,20 +191,20 @@ static TILE_GET_INFO( get_fg_tile_info )
SET_TILE_INFO(0,tile,color,0); SET_TILE_INFO(0,tile,color,0);
} }
static TIMER_CALLBACK( scanline_callback ) static TIMER_DEVICE_CALLBACK( scanline_callback )
{ {
if (param == interrupt_scanline) if (param == interrupt_scanline)
{ {
if (out & 0x2000) if (out & 0x2000)
cputag_set_input_line(machine, "maincpu", 1, ASSERT_LINE); cputag_set_input_line(timer->machine, "maincpu", 1, ASSERT_LINE);
timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, param + 1, 0), param+1); timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, param + 1, 0), param+1);
interrupt_line_active = 1; interrupt_line_active = 1;
} }
else else
{ {
if (interrupt_line_active) if (interrupt_line_active)
cputag_set_input_line(machine, "maincpu", 1, CLEAR_LINE); cputag_set_input_line(timer->machine, "maincpu", 1, CLEAR_LINE);
timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, interrupt_scanline, 0), interrupt_scanline); timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(timer->machine->primary_screen, interrupt_scanline, 0), interrupt_scanline);
interrupt_line_active = 0; interrupt_line_active = 0;
} }
} }
@ -259,15 +259,18 @@ static const ym2203_interface ym2203_config =
irqhandler irqhandler
}; };
static MACHINE_START( pkscramble)
{
state_save_register_global(machine, out);
state_save_register_global(machine, interrupt_line_active);
}
static MACHINE_RESET( pkscramble) static MACHINE_RESET( pkscramble)
{ {
out = 0; out = 0;
interrupt_line_active=0; interrupt_line_active=0;
scanline_timer = timer_alloc(machine, scanline_callback, NULL); scanline_timer = devtag_get_device(machine, "scan_timer");
timer_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, interrupt_scanline, 0), interrupt_scanline); timer_device_adjust_oneshot(scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, interrupt_scanline, 0), interrupt_scanline);
state_save_register_global(machine, out);
state_save_register_global(machine, interrupt_line_active);
} }
static MACHINE_DRIVER_START( pkscramble ) static MACHINE_DRIVER_START( pkscramble )
@ -278,7 +281,10 @@ static MACHINE_DRIVER_START( pkscramble )
MDRV_NVRAM_HANDLER(generic_0fill) MDRV_NVRAM_HANDLER(generic_0fill)
MDRV_MACHINE_START(pkscramble)
MDRV_MACHINE_RESET(pkscramble) MDRV_MACHINE_RESET(pkscramble)
MDRV_TIMER_ADD("scan_timer", scanline_callback)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)

View File

@ -96,8 +96,8 @@ static int channel2_active;
static int channel2_const; static int channel2_const;
/* timer handling */ /* timer handling */
static TIMER_CALLBACK( polyplay_timer_callback ); static TIMER_DEVICE_CALLBACK( polyplay_timer_callback );
static emu_timer* polyplay_timer; static const device_config* polyplay_timer;
static WRITE8_HANDLER( polyplay_start_timer2 ); static WRITE8_HANDLER( polyplay_start_timer2 );
static WRITE8_HANDLER( polyplay_sound_channel ); static WRITE8_HANDLER( polyplay_sound_channel );
@ -123,7 +123,7 @@ static MACHINE_RESET( polyplay )
polyplay_set_channel2(0); polyplay_set_channel2(0);
polyplay_play_channel2(machine, 0); polyplay_play_channel2(machine, 0);
polyplay_timer = timer_alloc(machine, polyplay_timer_callback, NULL); polyplay_timer = devtag_get_device(machine, "timer");
} }
@ -234,10 +234,10 @@ static WRITE8_HANDLER( polyplay_sound_channel )
static WRITE8_HANDLER( polyplay_start_timer2 ) static WRITE8_HANDLER( polyplay_start_timer2 )
{ {
if (data == 0x03) if (data == 0x03)
timer_adjust_oneshot(polyplay_timer, attotime_never, 0); timer_device_adjust_oneshot(polyplay_timer, attotime_never, 0);
if (data == 0xb5) if (data == 0xb5)
timer_adjust_periodic(polyplay_timer, ATTOTIME_IN_HZ(40), 0, ATTOTIME_IN_HZ(40)); timer_device_adjust_periodic(polyplay_timer, ATTOTIME_IN_HZ(40), 0, ATTOTIME_IN_HZ(40));
} }
static READ8_HANDLER( polyplay_random_read ) static READ8_HANDLER( polyplay_random_read )
@ -286,6 +286,9 @@ static MACHINE_DRIVER_START( polyplay )
MDRV_CPU_VBLANK_INT("screen", coin_interrupt) MDRV_CPU_VBLANK_INT("screen", coin_interrupt)
MDRV_MACHINE_RESET(polyplay) MDRV_MACHINE_RESET(polyplay)
MDRV_TIMER_ADD("timer", polyplay_timer_callback)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
@ -354,9 +357,9 @@ ROM_START( polyplay )
ROM_END ROM_END
static TIMER_CALLBACK( polyplay_timer_callback ) static TIMER_DEVICE_CALLBACK( polyplay_timer_callback )
{ {
cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, 0x4c); cputag_set_input_line_and_vector(timer->machine, "maincpu", 0, HOLD_LINE, 0x4c);
} }
/* game driver */ /* game driver */

View File

@ -680,6 +680,7 @@ static MACHINE_DRIVER_START( realbrk )
MDRV_CPU_PROGRAM_MAP(realbrk_mem) MDRV_CPU_PROGRAM_MAP(realbrk_mem)
MDRV_CPU_VBLANK_INT("screen", realbrk_interrupt) MDRV_CPU_VBLANK_INT("screen", realbrk_interrupt)
MDRV_MACHINE_START( tmp68301 )
MDRV_MACHINE_RESET( tmp68301 ) MDRV_MACHINE_RESET( tmp68301 )
/* video hardware */ /* video hardware */

View File

@ -867,6 +867,11 @@ static MACHINE_DRIVER_START( type1 )
MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf ) MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf )
MDRV_PPI8255_ADD( "ppi8255_1", scramble_ppi_1_intf ) MDRV_PPI8255_ADD( "ppi8255_1", scramble_ppi_1_intf )
MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback)
MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback)
MDRV_TIMER_ADD("int_timer", galaxold_interrupt_timer)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(16000.0/132/2) MDRV_SCREEN_REFRESH_RATE(16000.0/132/2)
@ -990,6 +995,11 @@ static MACHINE_DRIVER_START( hustler )
MDRV_MACHINE_RESET(scramble) MDRV_MACHINE_RESET(scramble)
MDRV_7474_ADD("7474_9m_1", galaxold_7474_9m_1_callback)
MDRV_7474_ADD("7474_9m_2", galaxold_7474_9m_2_callback)
MDRV_TIMER_ADD("int_timer", galaxold_interrupt_timer)
/* device config overrides */ /* device config overrides */
MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf ) MDRV_PPI8255_ADD( "ppi8255_0", scramble_ppi_0_intf )
MDRV_PPI8255_ADD( "ppi8255_1", scramble_ppi_1_intf ) MDRV_PPI8255_ADD( "ppi8255_1", scramble_ppi_1_intf )

View File

@ -909,7 +909,8 @@ CPU - 317-0092 |--------------------------------------------------------------
static UINT16 *workram; static UINT16 *workram;
static UINT8 rom_board; static UINT8 rom_board;
static int atomicp_sound_rate; static UINT8 atomicp_sound_divisor;
static UINT8 atomicp_sound_count;
static UINT8 has_sound_cpu; static UINT8 has_sound_cpu;
@ -1112,16 +1113,13 @@ static MACHINE_RESET( system16b )
} }
static TIMER_CALLBACK( atomicp_sound_irq ) static TIMER_DEVICE_CALLBACK( atomicp_sound_irq )
{ {
cputag_set_input_line(machine, "maincpu", 2, HOLD_LINE); if (++atomicp_sound_count >= atomicp_sound_divisor)
} {
cputag_set_input_line(timer->machine, "maincpu", 2, HOLD_LINE);
atomicp_sound_count = 0;
static MACHINE_RESET( atomicp ) }
{
MACHINE_RESET_CALL(system16b);
timer_pulse(machine, ATTOTIME_IN_HZ(atomicp_sound_rate), NULL, 0, atomicp_sound_irq);
} }
@ -1556,6 +1554,12 @@ static void wrestwar_i8751_sim(running_machine *machine)
* *
*************************************/ *************************************/
static MACHINE_START( atomicp )
{
state_save_register_global(machine, atomicp_sound_count);
}
static WRITE16_HANDLER( atomicp_sound_w ) static WRITE16_HANDLER( atomicp_sound_w )
{ {
ym2413_w(devtag_get_device(space->machine, "ymsnd"), offset, data >> 8); ym2413_w(devtag_get_device(space->machine, "ymsnd"), offset, data >> 8);
@ -3296,7 +3300,9 @@ static MACHINE_DRIVER_START( atomicp ) /* 10MHz CPU Clock verified */
/* basic machine hardware */ /* basic machine hardware */
MDRV_DEVICE_REMOVE("soundcpu") MDRV_DEVICE_REMOVE("soundcpu")
MDRV_MACHINE_RESET(atomicp)
MDRV_MACHINE_START(atomicp)
MDRV_TIMER_ADD_PERIODIC("atomicp_timer", atomicp_sound_irq, HZ(10000))
/* sound hardware */ /* sound hardware */
MDRV_SOUND_REPLACE("ymsnd", YM2413, XTAL_20MHz/4) /* 20MHz OSC divided by 4 (verified) */ MDRV_SOUND_REPLACE("ymsnd", YM2413, XTAL_20MHz/4) /* 20MHz OSC divided by 4 (verified) */
@ -6356,7 +6362,7 @@ static DRIVER_INIT( atomicp )
system16b_generic_init(machine, ROM_BOARD_ATOMICP); system16b_generic_init(machine, ROM_BOARD_ATOMICP);
disable_screen_blanking = 1; disable_screen_blanking = 1;
segaic16_display_enable = 1; segaic16_display_enable = 1;
atomicp_sound_rate = 10000; atomicp_sound_divisor = 1;
} }
@ -6365,7 +6371,7 @@ static DRIVER_INIT( snapper )
system16b_generic_init(machine, ROM_BOARD_ATOMICP); system16b_generic_init(machine, ROM_BOARD_ATOMICP);
disable_screen_blanking = 1; disable_screen_blanking = 1;
segaic16_display_enable = 1; segaic16_display_enable = 1;
atomicp_sound_rate = 2500; atomicp_sound_divisor = 4;
} }

View File

@ -888,35 +888,6 @@ static READ32_HANDLER( spi_unknown_r )
return 0xffffffff; return 0xffffffff;
} }
static WRITE32_HANDLER( ds2404_reset_w )
{
if( ACCESSING_BITS_0_7 ) {
DS2404_1W_reset_w(space, offset, data);
}
}
static READ32_HANDLER( ds2404_data_r )
{
if( ACCESSING_BITS_0_7 ) {
return DS2404_data_r(space, offset);
}
return 0;
}
static WRITE32_HANDLER( ds2404_data_w )
{
if( ACCESSING_BITS_0_7 ) {
DS2404_data_w(space, offset, data);
}
}
static WRITE32_HANDLER( ds2404_clk_w )
{
if( ACCESSING_BITS_0_7 ) {
DS2404_clk_w(space, offset, data);
}
}
static WRITE32_HANDLER( eeprom_w ) static WRITE32_HANDLER( eeprom_w )
{ {
const device_config *oki2 = devtag_get_device(space->machine, "oki2"); const device_config *oki2 = devtag_get_device(space->machine, "oki2");
@ -1090,10 +1061,10 @@ static ADDRESS_MAP_START( spi_map, ADDRESS_SPACE_PROGRAM, 32 )
AM_RANGE(0x00000680, 0x00000683) AM_WRITE(sound_fifo_w) AM_RANGE(0x00000680, 0x00000683) AM_WRITE(sound_fifo_w)
AM_RANGE(0x00000684, 0x00000687) AM_READ(sound_fifo_status_r) AM_RANGE(0x00000684, 0x00000687) AM_READ(sound_fifo_status_r)
AM_RANGE(0x00000684, 0x00000687) AM_WRITENOP /* Unknown */ AM_RANGE(0x00000684, 0x00000687) AM_WRITENOP /* Unknown */
AM_RANGE(0x000006d0, 0x000006d3) AM_WRITE(ds2404_reset_w) AM_RANGE(0x000006d0, 0x000006d3) AM_DEVWRITE8("ds2404", ds2404_1w_reset_w, 0x000000ff)
AM_RANGE(0x000006d4, 0x000006d7) AM_WRITE(ds2404_data_w) AM_RANGE(0x000006d4, 0x000006d7) AM_DEVWRITE8("ds2404", ds2404_data_w, 0x000000ff)
AM_RANGE(0x000006d8, 0x000006db) AM_WRITE(ds2404_clk_w) AM_RANGE(0x000006d8, 0x000006db) AM_DEVWRITE8("ds2404", ds2404_clk_w, 0x000000ff)
AM_RANGE(0x000006dc, 0x000006df) AM_READ(ds2404_data_r) AM_RANGE(0x000006dc, 0x000006df) AM_DEVREAD8("ds2404", ds2404_data_r, 0x000000ff)
AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE(&spimainram) AM_RANGE(0x00000800, 0x0003ffff) AM_RAM AM_BASE(&spimainram)
AM_RANGE(0x00200000, 0x003fffff) AM_ROM AM_SHARE("share2") AM_RANGE(0x00200000, 0x003fffff) AM_ROM AM_SHARE("share2")
AM_RANGE(0x00a00000, 0x013fffff) AM_READ(soundrom_r) AM_RANGE(0x00a00000, 0x013fffff) AM_READ(soundrom_r)
@ -1822,16 +1793,6 @@ GFXDECODE_END
static NVRAM_HANDLER( spi ) static NVRAM_HANDLER( spi )
{ {
if( read_or_write ) {
DS2404_save(file);
} else {
DS2404_init(machine, 1995, 1, 1);
if(file) {
DS2404_load(file);
}
}
nvram_handler_intelflash(machine, 0, file, read_or_write); nvram_handler_intelflash(machine, 0, file, read_or_write);
nvram_handler_intelflash(machine, 1, file, read_or_write); nvram_handler_intelflash(machine, 1, file, read_or_write);
} }
@ -1874,6 +1835,11 @@ static IRQ_CALLBACK(spi_irq_callback)
/* SPI */ /* SPI */
static MACHINE_START( spi )
{
z80_rom = auto_alloc_array(machine, UINT8, 0x40000);
}
static MACHINE_RESET( spi ) static MACHINE_RESET( spi )
{ {
int i; int i;
@ -1889,7 +1855,6 @@ static MACHINE_RESET( spi )
memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00000688, 0x0000068b, 0, 0, z80_prg_fifo_w); memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x00000688, 0x0000068b, 0, 0, z80_prg_fifo_w);
memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000068c, 0x0000068f, 0, 0, z80_enable_w); memory_install_write32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0000068c, 0x0000068f, 0, 0, z80_enable_w);
z80_rom = auto_alloc_array(machine, UINT8, 0x40000);
memory_set_bankptr(machine, "bank4", z80_rom); memory_set_bankptr(machine, "bank4", z80_rom);
memory_set_bankptr(machine, "bank5", z80_rom); memory_set_bankptr(machine, "bank5", z80_rom);
@ -1923,9 +1888,12 @@ static MACHINE_DRIVER_START( spi )
MDRV_QUANTUM_TIME(HZ(12000)) MDRV_QUANTUM_TIME(HZ(12000))
MDRV_MACHINE_START(spi)
MDRV_MACHINE_RESET(spi) MDRV_MACHINE_RESET(spi)
MDRV_NVRAM_HANDLER(spi) MDRV_NVRAM_HANDLER(spi)
MDRV_DS2404_ADD("ds2404", 1995, 1, 1)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(54) MDRV_SCREEN_REFRESH_RATE(54)
@ -2238,7 +2206,7 @@ static MACHINE_DRIVER_START( seibu386 )
MDRV_NVRAM_HANDLER(sxx2f) MDRV_NVRAM_HANDLER(sxx2f)
MDRV_MACHINE_RESET(seibu386) MDRV_MACHINE_RESET(seibu386)
/* video hardware */ /* video hardware */
MDRV_SCREEN_ADD("screen", RASTER) MDRV_SCREEN_ADD("screen", RASTER)
MDRV_SCREEN_REFRESH_RATE(54) MDRV_SCREEN_REFRESH_RATE(54)

View File

@ -24,6 +24,8 @@ WRITE8_HANDLER( nitedrvr_steering_reset_w );
WRITE8_HANDLER( nitedrvr_out0_w ); WRITE8_HANDLER( nitedrvr_out0_w );
WRITE8_HANDLER( nitedrvr_out1_w ); WRITE8_HANDLER( nitedrvr_out1_w );
TIMER_DEVICE_CALLBACK( nitedrvr_crash_toggle_callback );
MACHINE_RESET( nitedrvr ); MACHINE_RESET( nitedrvr );
MACHINE_START( nitedrvr ); MACHINE_START( nitedrvr );

View File

@ -58,11 +58,13 @@ void jumpshot_decode(running_machine *machine);
/*----------- defined in machine/theglobp.c -----------*/ /*----------- defined in machine/theglobp.c -----------*/
MACHINE_START( theglobp );
MACHINE_RESET( theglobp ); MACHINE_RESET( theglobp );
READ8_HANDLER( theglobp_decrypt_rom ); READ8_HANDLER( theglobp_decrypt_rom );
/*----------- defined in machine/acitya.c -------------*/ /*----------- defined in machine/acitya.c -------------*/
MACHINE_START( acitya );
MACHINE_RESET( acitya ); MACHINE_RESET( acitya );
READ8_HANDLER( acitya_decrypt_rom ); READ8_HANDLER( acitya_decrypt_rom );

View File

@ -184,7 +184,7 @@ READ8_HANDLER( acitya_decrypt_rom )
} }
MACHINE_RESET( acitya ) MACHINE_START( acitya )
{ {
UINT8 *RAM = memory_region(machine, "maincpu"); UINT8 *RAM = memory_region(machine, "maincpu");
@ -196,10 +196,15 @@ MACHINE_RESET( acitya )
acitya_decrypt_rom_A(machine); acitya_decrypt_rom_A(machine);
acitya_decrypt_rom_B(machine); acitya_decrypt_rom_B(machine);
/* The initial state of the counter is 0x0B */
counter = 0x0B;
memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x10000], 0x4000); memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x10000], 0x4000);
memory_set_bank(machine, "bank1", 3);
state_save_register_global(machine, counter); state_save_register_global(machine, counter);
} }
MACHINE_RESET( acitya )
{
/* The initial state of the counter is 0x0B */
counter = 0x0B;
memory_set_bank(machine, "bank1", 3);
}

View File

@ -250,11 +250,11 @@ WRITE8_HANDLER( nitedrvr_out1_w )
} }
static TIMER_CALLBACK( nitedrvr_crash_toggle_callback ) TIMER_DEVICE_CALLBACK( nitedrvr_crash_toggle_callback )
{ {
if (nitedrvr_crash_en && nitedrvr_crash_data_en) if (nitedrvr_crash_en && nitedrvr_crash_data_en)
{ {
const device_config *discrete = devtag_get_device(machine, "discrete"); const device_config *discrete = devtag_get_device(timer->machine, "discrete");
nitedrvr_crash_data--; nitedrvr_crash_data--;
discrete_sound_w(discrete, NITEDRVR_BANG_DATA, nitedrvr_crash_data); // Crash Volume discrete_sound_w(discrete, NITEDRVR_BANG_DATA, nitedrvr_crash_data); // Crash Volume
@ -262,14 +262,14 @@ static TIMER_CALLBACK( nitedrvr_crash_toggle_callback )
if (nitedrvr_crash_data & 0x01) if (nitedrvr_crash_data & 0x01)
{ {
/* Invert video */ /* Invert video */
palette_set_color(machine,1,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */ palette_set_color(timer->machine,1,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
palette_set_color(machine,0,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */ palette_set_color(timer->machine,0,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
} }
else else
{ {
/* Normal video */ /* Normal video */
palette_set_color(machine,0,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */ palette_set_color(timer->machine,0,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
palette_set_color(machine,1,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */ palette_set_color(timer->machine,1,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
} }
} }
} }
@ -298,6 +298,4 @@ MACHINE_RESET( nitedrvr )
nitedrvr_crash_data_en = 0; nitedrvr_crash_data_en = 0;
ac_line = 0; ac_line = 0;
last_steering_val = 0; last_steering_val = 0;
timer_pulse(machine, PERIOD_OF_555_ASTABLE(RES_K(180), 330, CAP_U(1)), NULL, 0, nitedrvr_crash_toggle_callback);
} }

View File

@ -238,7 +238,7 @@ READ8_HANDLER( theglobp_decrypt_rom )
} }
MACHINE_RESET( theglobp ) MACHINE_START( theglobp )
{ {
UINT8 *RAM = memory_region(machine, "maincpu"); UINT8 *RAM = memory_region(machine, "maincpu");
@ -250,10 +250,15 @@ MACHINE_RESET( theglobp )
theglobp_decrypt_rom_A(machine); theglobp_decrypt_rom_A(machine);
theglobp_decrypt_rom_B(machine); theglobp_decrypt_rom_B(machine);
/* The initial state of the counter is 0x0A */
counter = 0x0A;
memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x10000], 0x4000); memory_configure_bank(machine, "bank1", 0, 4, &RAM[0x10000], 0x4000);
memory_set_bank(machine, "bank1", 2);
state_save_register_global(machine, counter); state_save_register_global(machine, counter);
} }
MACHINE_RESET( theglobp )
{
/* The initial state of the counter is 0x0A */
counter = 0x0A;
memory_set_bank(machine, "bank1", 2);
}