diff options
author | 2008-12-19 19:40:22 +0000 | |
---|---|---|
committer | 2008-12-19 19:40:22 +0000 | |
commit | f36fc8641eb9e45c79bc3051d06c2887e82a562f (patch) | |
tree | 52f420821fac5adf6df506b8baa9764fab6a6648 /src/emu/sound | |
parent | 42c9aeff3943f2e6779d3d125fc014cd96d16d71 (diff) |
This update is the below two patches, plus the remaining changes
necessary to remove 12 of the final 14 references to the global
Machine. The remaining 2 are in fatalerror() and logerror(), which
are both local to mame.c, so Machine is now fully static.
--
From: Atari Ace [mailto:atari_ace@verizon.net]
Sent: Thursday, December 18, 2008 5:47 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Make Machine static followup
Hi mamedev,
This incremental patch to my last patch undoes the change that caches
the ppu2c0x videorom. I changed the code back to how it behaved
originally, using an existing machine on the chip struct to eliminate
the one troublesome Machine reference.
~aa
--
From: Atari Ace [mailto:atari_ace@verizon.net]
Sent: Thursday, December 18, 2008 2:54 PM
To: submit@mamedev.org
Cc: atariace@hotmail.com
Subject: [patch] Make Machine static!
Hi mamedev,
This large patch completes the removal of the use of Machine
throughout MAME. It does so primarily by adding machine, device or
space to various apis and modifying the callers, but for some
remaining cases it adds a new api, mame_get_running_machine(), which
will be called instead. There are only 14 uses of this api currently,
and that number should drop over time.
There are a few changes of note:
1. 6821pia.c. I attached machine to the 'device' structure. I'm
working on converting this to a proper device, but that change isn't
ready.
2. fddebug.c. I added a proper header so that the apis won't get
accidentally converted to static again.
3. scsi.c. I added a machine to SCSIInstance.
4. system16.c. I modified sys16_patch_code to take an array of
patches.
4. custom.h. I added the owning sound device to the reset/stop
routines as well as the token. Note that passing only the device
would require exposing the internals of custom_sound, as the token
passed is not the device token, but the token returned from the
CUSTOM_START routine. Better ideas here are welcome.
4. ppc2c0x.c. To avoid changing more interfaces, the init routine
saves the videorom location rather than looks it up each time.
I tried to choose what I felt was the natural parameter for an api,
rather than always pass machine, but in some cases I used machine to
limit the number of additional changes. Some additional cleanup here
is probably warranted, I'll look into that later once I'm recovered
from this two-week project.
~aa
Diffstat (limited to 'src/emu/sound')
-rw-r--r-- | src/emu/sound/5110intf.c | 2 | ||||
-rw-r--r-- | src/emu/sound/5110intf.h | 2 | ||||
-rw-r--r-- | src/emu/sound/custom.c | 4 | ||||
-rw-r--r-- | src/emu/sound/custom.h | 8 | ||||
-rw-r--r-- | src/emu/sound/psx.c | 6 | ||||
-rw-r--r-- | src/emu/sound/psx.h | 2 | ||||
-rw-r--r-- | src/emu/sound/sp0256.c | 18 | ||||
-rw-r--r-- | src/emu/sound/sp0256.h | 4 | ||||
-rw-r--r-- | src/emu/sound/tms5110.c | 10 | ||||
-rw-r--r-- | src/emu/sound/tms5110.h | 2 | ||||
-rw-r--r-- | src/emu/sound/upd7759.c | 7 | ||||
-rw-r--r-- | src/emu/sound/upd7759.h | 2 |
12 files changed, 36 insertions, 31 deletions
diff --git a/src/emu/sound/5110intf.c b/src/emu/sound/5110intf.c index e02149b71a4..53f4065abf3 100644 --- a/src/emu/sound/5110intf.c +++ b/src/emu/sound/5110intf.c @@ -35,7 +35,7 @@ struct tms5110_info /* static function prototypes */ static STREAM_UPDATE( tms5110_update ); -static int speech_rom_read_bit(void) +static int speech_rom_read_bit(const device_config *device) { struct tms5110_info *info = sndti_token(SOUND_TMS5110, 0); diff --git a/src/emu/sound/5110intf.h b/src/emu/sound/5110intf.h index a92ff347c5a..dc5d6501e9d 100644 --- a/src/emu/sound/5110intf.h +++ b/src/emu/sound/5110intf.h @@ -10,7 +10,7 @@ typedef struct _tms5110_interface tms5110_interface; struct _tms5110_interface { - int (*M0_callback)(void); /* function to be called when chip requests another bit */ + int (*M0_callback)(const device_config *device); /* function to be called when chip requests another bit */ void (*load_address)(int addr); /* speech ROM load address callback */ }; diff --git a/src/emu/sound/custom.c b/src/emu/sound/custom.c index 3cbe58283b0..cdb563bbd64 100644 --- a/src/emu/sound/custom.c +++ b/src/emu/sound/custom.c @@ -34,7 +34,7 @@ static SND_STOP( custom ) { struct custom_info *info = device->token; if (info->intf->stop) - (*info->intf->stop)(info->token); + (*info->intf->stop)(device, info->token); } @@ -42,7 +42,7 @@ static SND_RESET( custom ) { struct custom_info *info = device->token; if (info->intf->reset) - (*info->intf->reset)(info->token); + (*info->intf->reset)(device, info->token); } diff --git a/src/emu/sound/custom.h b/src/emu/sound/custom.h index 40c82b85350..16d7abf847b 100644 --- a/src/emu/sound/custom.h +++ b/src/emu/sound/custom.h @@ -7,15 +7,15 @@ typedef struct _custom_sound_interface custom_sound_interface; struct _custom_sound_interface { void *(*start)(const device_config *device, int clock, const custom_sound_interface *config); - void (*stop)(void *token); - void (*reset)(void *token); + void (*stop)(const device_config *device, void *token); + void (*reset)(const device_config *device, void *token); void *extra_data; }; void *custom_get_token(int index); #define CUSTOM_START(name) void *name(const device_config *device, int clock, const custom_sound_interface *config) -#define CUSTOM_STOP(name) void name(void *token) -#define CUSTOM_RESET(name) void name(void *token) +#define CUSTOM_STOP(name) void name(const device_config *device, void *token) +#define CUSTOM_RESET(name) void name(const device_config *device, void *token) #endif /* __CUSTOM_H__ */ diff --git a/src/emu/sound/psx.c b/src/emu/sound/psx.c index 7c965529fb3..6a2792d9913 100644 --- a/src/emu/sound/psx.c +++ b/src/emu/sound/psx.c @@ -213,10 +213,9 @@ static STREAM_UPDATE( PSXSPU_update ) } } -static void spu_read( UINT32 n_address, INT32 n_size ) +static void spu_read( running_machine *machine, UINT32 n_address, INT32 n_size ) { struct psxinfo *chip = sndti_token(SOUND_PSXSPU, 0); - running_machine *machine = chip->device->machine; verboselog( machine, 1, "spu_read( %08x, %08x )\n", n_address, n_size ); while( n_size > 0 ) @@ -233,10 +232,9 @@ static void spu_read( UINT32 n_address, INT32 n_size ) } } -static void spu_write( UINT32 n_address, INT32 n_size ) +static void spu_write( running_machine *machine, UINT32 n_address, INT32 n_size ) { struct psxinfo *chip = sndti_token(SOUND_PSXSPU, 0); - running_machine *machine = chip->device->machine; verboselog( machine, 1, "spu_write( %08x, %08x )\n", n_address, n_size ); while( n_size > 0 ) diff --git a/src/emu/sound/psx.h b/src/emu/sound/psx.h index f7fd8afad9f..6aca4bd34a6 100644 --- a/src/emu/sound/psx.h +++ b/src/emu/sound/psx.h @@ -16,7 +16,7 @@ READ32_HANDLER( psx_spu_r ); WRITE32_HANDLER( psx_spu_delay_w ); READ32_HANDLER( psx_spu_delay_r ); -typedef void ( *spu_handler )( UINT32, INT32 ); +typedef void ( *spu_handler )( running_machine *, UINT32, INT32 ); typedef struct _psx_spu_interface psx_spu_interface; struct _psx_spu_interface diff --git a/src/emu/sound/sp0256.c b/src/emu/sound/sp0256.c index deedd736bd3..1ce005c2419 100644 --- a/src/emu/sound/sp0256.c +++ b/src/emu/sound/sp0256.c @@ -58,7 +58,7 @@ if( sp->sby_line != line_state ) \ { \ sp->sby_line = line_state; \ - if( sp->sby ) sp->sby(sp->sby_line); \ + if( sp->sby ) sp->sby(sp->device, sp->sby_line); \ } \ } @@ -77,9 +77,10 @@ struct lpc12_t struct sp0256 { + const device_config *device; sound_stream *stream; /* MAME core sound stream */ - void (*drq)(int state); /* Data request callback */ - void (*sby)(int state); /* Standby callback */ + void (*drq)(const device_config *device, int state); /* Data request callback */ + void (*sby)(const device_config *device, int state); /* Standby callback */ int sby_line; /* Standby line state */ INT16 *cur_buf; /* Current sound buffer. */ int cur_len; /* Fullness of current sound buffer. */ @@ -766,7 +767,7 @@ static void sp0256_micro(struct sp0256 *sp) sp->ald = 0; for (i = 0; i < 16; i++) sp->filt.r[i] = 0; - if( sp->drq) sp->drq(ASSERT_LINE); + if( sp->drq) sp->drq(sp->device, ASSERT_LINE); } /* ---------------------------------------------------------------- */ @@ -1175,10 +1176,11 @@ static SND_START( sp0256 ) sp = auto_malloc(sizeof(*sp)); memset(sp, 0, sizeof(*sp)); + sp->device = device; sp->drq = intf->lrq_callback; sp->sby = intf->sby_callback; - if( sp->drq ) sp->drq(ASSERT_LINE); - if( sp->sby ) sp->sby(sp->sby_line = ASSERT_LINE); + if( sp->drq ) sp->drq(device, ASSERT_LINE); + if( sp->sby ) sp->sby(device, sp->sby_line = ASSERT_LINE); sp->stream = stream_create(device, 0, 1, clock / CLOCK_DIVIDER, sp, sp0256_update); @@ -1236,7 +1238,7 @@ static void sp0256_reset(struct sp0256 *sp) sp->mode = 0; sp->page = 0x1000 << 3; sp->silent = 1; - if( sp->drq ) sp->drq(ASSERT_LINE); + if( sp->drq ) sp->drq(sp->device, ASSERT_LINE); SET_SBY(ASSERT_LINE) } @@ -1265,7 +1267,7 @@ WRITE8_HANDLER( sp0256_ALD_w ) /* ---------------------------------------------------------------- */ sp->lrq = 0; sp->ald = (0xFF & data) << 4; - if( sp->drq ) sp->drq(CLEAR_LINE); + if( sp->drq ) sp->drq(sp->device, CLEAR_LINE); SET_SBY(CLEAR_LINE) return; diff --git a/src/emu/sound/sp0256.h b/src/emu/sound/sp0256.h index 312408b8fda..edcfd6d0701 100644 --- a/src/emu/sound/sp0256.h +++ b/src/emu/sound/sp0256.h @@ -25,8 +25,8 @@ typedef struct _sp0256_interface sp0256_interface; struct _sp0256_interface { - void (*lrq_callback)(int state); - void (*sby_callback)(int state); + void (*lrq_callback)(const device_config *device, int state); + void (*sby_callback)(const device_config *device, int state); }; void sp0256_bitrevbuff(UINT8 *buffer, unsigned int start, unsigned int length); diff --git a/src/emu/sound/tms5110.c b/src/emu/sound/tms5110.c index af198b010dc..fc7315c41a7 100644 --- a/src/emu/sound/tms5110.c +++ b/src/emu/sound/tms5110.c @@ -111,8 +111,9 @@ struct tms5110 UINT8 addr_bit; /* external callback */ - int (*M0_callback)(void); + int (*M0_callback)(const device_config *); void (*set_load_address)(int); + const device_config *device; /* these contain data describing the current and previous voice frames */ UINT16 old_energy; @@ -183,6 +184,7 @@ void *tms5110_create(const device_config *device, int variant) tms = malloc_or_die(sizeof(*tms)); memset(tms, 0, sizeof(*tms)); + tms->device = device; tms5110_set_variant(tms, variant); state_save_register_device_item_array(device, 0, tms->fifo); @@ -280,7 +282,7 @@ void tms5110_reset_chip(void *chip) ******************************************************************************************/ -void tms5110_set_M0_callback(void *chip, int (*func)(void)) +void tms5110_set_M0_callback(void *chip, int (*func)(const device_config *)) { struct tms5110 *tms = chip; tms->M0_callback = func; @@ -347,7 +349,7 @@ int i; { if (tms->M0_callback) { - int data = (*tms->M0_callback)(); + int data = (*tms->M0_callback)(tms->device); FIFO_data_write(tms, data); } else @@ -361,7 +363,7 @@ static void perform_dummy_read(struct tms5110 *tms) { if (tms->M0_callback) { - int data = (*tms->M0_callback)(); + int data = (*tms->M0_callback)(tms->device); if (DEBUG_5110) logerror("TMS5110 performing dummy read; value read = %1i\n", data&1); } else diff --git a/src/emu/sound/tms5110.h b/src/emu/sound/tms5110.h index b9c157ee61a..c6a739f2945 100644 --- a/src/emu/sound/tms5110.h +++ b/src/emu/sound/tms5110.h @@ -33,7 +33,7 @@ void tms5110_destroy(void *chip); void tms5110_set_variant(void *chip, int variant); void tms5110_reset_chip(void *chip); -void tms5110_set_M0_callback(void *chip, int (*func)(void)); +void tms5110_set_M0_callback(void *chip, int (*func)(const device_config *)); void tms5110_set_load_address(void *chip, void (*func)(int)); void tms5110_CTL_set(void *chip, int data); diff --git a/src/emu/sound/upd7759.c b/src/emu/sound/upd7759.c index 7b3b285d863..7fdb0297020 100644 --- a/src/emu/sound/upd7759.c +++ b/src/emu/sound/upd7759.c @@ -148,6 +148,7 @@ enum struct upd7759_chip { + const device_config *device; sound_stream *channel; /* stream channel for playback */ /* internal clock to output sample rate mapping */ @@ -161,7 +162,7 @@ struct upd7759_chip UINT8 reset; /* current state of the RESET line */ UINT8 start; /* current state of the START line */ UINT8 drq; /* current state of the DRQ line */ - void (*drqcallback)(int param); /* drq callback */ + void (*drqcallback)(const device_config *device, int param); /* drq callback */ /* internal state machine */ INT8 state; /* current overall chip state */ @@ -536,7 +537,7 @@ static TIMER_CALLBACK( upd7759_slave_update ) /* if the DRQ changed, update it */ logerror("slave_update: DRQ %d->%d\n", olddrq, chip->drq); if (olddrq != chip->drq && chip->drqcallback) - (*chip->drqcallback)(chip->drq); + (*chip->drqcallback)(chip->device, chip->drq); /* set a timer to go off when that is done */ if (chip->state != STATE_IDLE) @@ -634,6 +635,8 @@ static SND_START( upd7759 ) chip = auto_malloc(sizeof(*chip)); memset(chip, 0, sizeof(*chip)); + chip->device = device; + /* allocate a stream channel */ chip->channel = stream_create(device, 0, 1, clock/4, chip, upd7759_update); diff --git a/src/emu/sound/upd7759.h b/src/emu/sound/upd7759.h index 92808ed5d5d..95b966ada1a 100644 --- a/src/emu/sound/upd7759.h +++ b/src/emu/sound/upd7759.h @@ -13,7 +13,7 @@ typedef struct _upd7759_interface upd7759_interface; struct _upd7759_interface { - void (*drqcallback)(int param); /* drq callback (per chip, slave mode only) */ + void (*drqcallback)(const device_config *device, int param); /* drq callback (per chip, slave mode only) */ }; void upd7759_set_bank_base(int which, offs_t base); |