From f36fc8641eb9e45c79bc3051d06c2887e82a562f Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Fri, 19 Dec 2008 19:40:22 +0000 Subject: 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 --- src/emu/mame.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/emu/mame.c') diff --git a/src/emu/mame.c b/src/emu/mame.c index 02cccdaec90..0e63bd326ad 100644 --- a/src/emu/mame.c +++ b/src/emu/mame.c @@ -181,7 +181,7 @@ struct _mame_private ***************************************************************************/ /* the active machine */ -running_machine *Machine; +static running_machine *Machine; /* the current options */ static core_options *mame_opts; @@ -1144,6 +1144,7 @@ static void fatalerror_common(running_machine *machine, int exitcode, const char void CLIB_DECL fatalerror(const char *text, ...) { + extern running_machine *Machine; running_machine *machine = Machine; va_list arg; @@ -1202,6 +1203,7 @@ void CLIB_DECL popmessage(const char *format, ...) void CLIB_DECL logerror(const char *format, ...) { + extern running_machine *Machine; running_machine *machine = Machine; /* currently, we need a machine to do this */ -- cgit v1.2.3-70-g09d2