diff options
author | 2011-03-29 15:50:04 +0000 | |
---|---|---|
committer | 2011-03-29 15:50:04 +0000 | |
commit | 2ad50720237fdd19cf5ab45b8cb6bb21119c00b8 (patch) | |
tree | db21eee69668a06abc3f310ebbd51f5dbadf2de7 /src/osd | |
parent | b72cf3c5702b749c7bf26383ff05a9ab55022d31 (diff) |
BIG update.
Remove redundant machine items from address_space and device_t.
Neither machine nor m_machine are directly accessible anymore.
Instead a new getter machine() is available which returns a
machine reference. So:
space->machine->xxx ==> space->machine().xxx
device->machine->yyy ==> device->machine().yyy
Globally changed all running_machine pointers to running_machine
references. Any function/method that takes a running_machine takes
it as a required parameter (1 or 2 exceptions). Being consistent
here gets rid of a lot of odd &machine or *machine, but it does
mean a very large bulk change across the project.
Structs which have a running_machine * now have that variable
renamed to m_machine, and now have a shiny new machine() method
that works like the space and device methods above. Since most of
these are things that should eventually be devices anyway, consider
this a step in that direction.
98% of the update was done with regex searches. The changes are
architected such that the compiler will catch the remaining
errors:
// find things that use an embedded machine directly and replace
// with a machine() getter call
S: ->machine->
R: ->machine\(\)\.
// do the same if via a reference
S: \.machine->
R: \.machine\(\)\.
// convert function parameters to running_machine &
S: running_machine \*machine([^;])
R: running_machine \&machine\1
// replace machine-> with machine.
S: machine->
R: machine\.
// replace &machine() with machine()
S: \&([()->a-z0-9_]+machine\(\))
R: \1
// sanity check: look for this used as a cast
(running_machine &)
// and change to this:
*(running_machine *)
Diffstat (limited to 'src/osd')
33 files changed, 375 insertions, 367 deletions
diff --git a/src/osd/sdl/debugosx.h b/src/osd/sdl/debugosx.h index 23d8accb807..58e0941349b 100644 --- a/src/osd/sdl/debugosx.h +++ b/src/osd/sdl/debugosx.h @@ -117,7 +117,7 @@ typedef float CGFloat; + (NSFont *)defaultFont; -- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine *)m; +- (id)initWithFrame:(NSRect)f type:(debug_view_type)t machine:(running_machine &)m; - (void)update; @@ -136,7 +136,7 @@ typedef float CGFloat; { } -- (id)initWithFrame:(NSRect)f machine:(running_machine *)m; +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; - (NSSize)maximumFrameSize; @@ -164,7 +164,7 @@ typedef float CGFloat; BOOL useConsole; } -- (id)initWithFrame:(NSRect)f machine:(running_machine *)m useConsole:(BOOL)uc; +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m useConsole:(BOOL)uc; - (NSSize)maximumFrameSize; @@ -192,7 +192,7 @@ typedef float CGFloat; { } -- (id)initWithFrame:(NSRect)f machine:(running_machine *)m; +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; - (NSSize)maximumFrameSize; @@ -208,7 +208,7 @@ typedef float CGFloat; { } -- (id)initWithFrame:(NSRect)f machine:(running_machine *)m; +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; @end @@ -217,7 +217,7 @@ typedef float CGFloat; { } -- (id)initWithFrame:(NSRect)f machine:(running_machine *)m; +- (id)initWithFrame:(NSRect)f machine:(running_machine &)m; @end @@ -231,7 +231,7 @@ typedef float CGFloat; + (void)addCommonActionItems:(NSMenu *)menu; + (NSPopUpButton *)newActionButtonWithFrame:(NSRect)frame; -- (id)initWithMachine:(running_machine *)m title:(NSString *)t; +- (id)initWithMachine:(running_machine &)m title:(NSString *)t; - (void)activate; @@ -267,7 +267,7 @@ typedef float CGFloat; NSTextField *commandField; } -- (id)initWithMachine:(running_machine *)m; +- (id)initWithMachine:(running_machine &)m; - (void)setCPU:(device_t *)device; @@ -299,7 +299,7 @@ typedef float CGFloat; + (void)cascadeWindow:(NSWindow *)window; -- (id)initWithMachine:(running_machine *)m title:(NSString *)t console:(MAMEDebugConsole *)c; +- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c; - (IBAction)debugNewMemoryWindow:(id)sender; - (IBAction)debugNewDisassemblyWindow:(id)sender; @@ -318,7 +318,7 @@ typedef float CGFloat; NSTextField *expressionField; } -- (id)initWithMachine:(running_machine *)m title:(NSString *)t console:(MAMEDebugConsole *)c; +- (id)initWithMachine:(running_machine &)m title:(NSString *)t console:(MAMEDebugConsole *)c; - (id <MAMEDebugViewExpressionSupport>)documentView; @@ -334,7 +334,7 @@ typedef float CGFloat; MAMEMemoryView *memoryView; } -- (id)initWithMachine:(running_machine *)m console:(MAMEDebugConsole *)c; +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; - (IBAction)changeSubview:(id)sender; @@ -346,7 +346,7 @@ typedef float CGFloat; MAMEDisassemblyView *dasmView; } -- (id)initWithMachine:(running_machine *)m console:(MAMEDebugConsole *)c; +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; - (IBAction)changeSubview:(id)sender; @@ -358,7 +358,7 @@ typedef float CGFloat; MAMEErrorLogView *logView; } -- (id)initWithMachine:(running_machine *)m console:(MAMEDebugConsole *)c; +- (id)initWithMachine:(running_machine &)m console:(MAMEDebugConsole *)c; @end @@ -370,7 +370,7 @@ typedef float CGFloat; // PROTOTYPES //============================================================ -void debugwin_update_during_game(running_machine *machine); +void debugwin_update_during_game(running_machine &machine); #endif // __SDL_DEBUGOSX__ diff --git a/src/osd/sdl/debugwin.c b/src/osd/sdl/debugwin.c index fc21b71de2d..0efc0843d9c 100644 --- a/src/osd/sdl/debugwin.c +++ b/src/osd/sdl/debugwin.c @@ -116,10 +116,10 @@ static win_i *win_list; // PROTOTYPES //============================================================ -static void debugmain_init(running_machine *machine); -static void memorywin_new(running_machine *machine); -static void disasmwin_new(running_machine *machine); -static void logwin_new(running_machine *machine); +static void debugmain_init(running_machine &machine); +static void memorywin_new(running_machine &machine); +static void disasmwin_new(running_machine &machine); +static void logwin_new(running_machine &machine); //============================================================ @@ -208,12 +208,12 @@ static win_i *get_first_win_i(int win_type_mask) // add_win_i //============================================================ -static win_i *add_win_i(running_machine *machine, int win_type) +static win_i *add_win_i(running_machine &machine, int win_type) { win_i *win = (win_i *) osd_malloc(sizeof(*win)); memset(win, 0, sizeof(*win)); win->cpu = NULL; - win->machine = machine; + win->machine() = machine; win->type = win_type; win->next = win_list; @@ -471,7 +471,7 @@ static void debugmain_set_cpu(device_t *device) dv->view->set_source(*dv->view->source_list().match_device(device)); // then update the caption - title.printf("Debug: %s - %s '%s'", device->machine->system().name, device->name(), device->tag()); + title.printf("Debug: %s - %s '%s'", device->machine().system().name, device->name(), device->tag()); gtk_window_set_title(GTK_WINDOW(dmain->win), title); disasmview_update_checks(dmain); } @@ -482,7 +482,7 @@ static void debugmain_set_cpu(device_t *device) // configuration_load //============================================================ -static void configuration_load(running_machine *machine, int config_type, xml_data_node *parentnode) +static void configuration_load(running_machine &machine, int config_type, xml_data_node *parentnode) { xml_data_node *wnode; @@ -508,7 +508,7 @@ static void configuration_load(running_machine *machine, int config_type, xml_da // configuration_save //============================================================ -static void configuration_save(running_machine *machine, int config_type, xml_data_node *parentnode) +static void configuration_save(running_machine &machine, int config_type, xml_data_node *parentnode) { /* we only care about game files */ if (config_type != CONFIG_TYPE_GAME) @@ -608,7 +608,7 @@ void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) // debugwin_update_during_game //============================================================ -void debugwin_update_during_game(running_machine *machine) +void debugwin_update_during_game(running_machine &machine) { win_i *dmain = get_first_win_i(WIN_TYPE_MAIN); if(dmain) @@ -625,9 +625,9 @@ void debugwin_update_during_game(running_machine *machine) static void debugmain_process_string(win_i *win, const char *str) { if(!str[0]) - debug_cpu_get_visible_cpu(win->machine)->debug()->single_step(); + debug_cpu_get_visible_cpu(win->machine())->debug()->single_step(); else - debug_console_execute_command(win->machine, str, 1); + debug_console_execute_command(win->machine(), str, 1); } @@ -640,7 +640,7 @@ static void debugmain_destroy(GtkObject *obj, gpointer user_data) { win_i *dmain = get_first_win_i(WIN_TYPE_MAIN); - dmain->machine->schedule_exit(); + dmain->machine().schedule_exit(); } @@ -649,7 +649,7 @@ static void debugmain_destroy(GtkObject *obj, gpointer user_data) // debugmain_init //============================================================ -static void debugmain_init(running_machine *machine) +static void debugmain_init(running_machine &machine) { win_i *dmain; @@ -761,7 +761,7 @@ static void memorywin_destroy(GtkObject *obj, gpointer user_data) // memorywin_new //============================================================ -static void memorywin_new(running_machine *machine) +static void memorywin_new(running_machine &machine) { win_i *mem; int item, cursel; @@ -855,7 +855,7 @@ static void disasmwin_destroy(GtkObject *obj, gpointer user_data) // disasmwin_new //============================================================ -static void disasmwin_new(running_machine *machine) +static void disasmwin_new(running_machine &machine) { win_i *dis; int item, cursel; @@ -917,7 +917,7 @@ static void logwin_destroy(GtkObject *obj, gpointer user_data) // logwin_new //============================================================ -static void logwin_new(running_machine *machine) +static void logwin_new(running_machine &machine) { win_i *log; @@ -1123,11 +1123,11 @@ void on_run_to_cursor_activate(GtkWidget *win) if (disasm->view->cursor_visible()) { - if (debug_cpu_get_visible_cpu(info->machine) == disasm->view->source()->device()) + if (debug_cpu_get_visible_cpu(info->machine()) == disasm->view->source()->device()) { offs_t address = downcast<debug_view_disasm *>(disasm->view)->selected_address(); command.printf("go 0x%X", address); - debug_console_execute_command(info->machine, command, 1); + debug_console_execute_command(info->machine(), command, 1); } } } @@ -1141,7 +1141,7 @@ on_set_breakpoint_at_cursor_activate(GtkWidget *win) if (disasm->view->cursor_visible()) { - if (debug_cpu_get_visible_cpu(info->machine) == disasm->view->source()->device()) + if (debug_cpu_get_visible_cpu(info->machine()) == disasm->view->source()->device()) { offs_t address = downcast<debug_view_disasm *>(disasm->view)->selected_address(); device_debug *cpuinfo = disasm->view->source()->device()->debug(); @@ -1161,7 +1161,7 @@ on_set_breakpoint_at_cursor_activate(GtkWidget *win) command.printf("bpset 0x%X", address); else command.printf("bpclear 0x%X", bpindex); - debug_console_execute_command(info->machine, command, 1); + debug_console_execute_command(info->machine(), command, 1); } } } @@ -1205,7 +1205,7 @@ on_memoryview_key_press_event(GtkWidget *widget, //printf("%s\n", event->string); //printf("The name of this keysym is `%s'\n", // gdk_keyval_name(event->keyval)); - //if (/*waiting_for_debugger ||*/ !debugwin_seq_pressed(info->view-> owner->machine)) + //if (/*waiting_for_debugger ||*/ !debugwin_seq_pressed(info->view-> owner->machine())) switch (event->keyval) { case GDK_Up: @@ -1291,7 +1291,7 @@ void sdl_osd_interface::wait_for_debugger(device_t &device, bool firststop) } // win32 stubs for linking -void debugwin_update_during_game(running_machine *machine) +void debugwin_update_during_game(running_machine &machine) { } diff --git a/src/osd/sdl/debugwin.h b/src/osd/sdl/debugwin.h index 24ad4723ccd..689f5eed98e 100644 --- a/src/osd/sdl/debugwin.h +++ b/src/osd/sdl/debugwin.h @@ -17,7 +17,7 @@ // PROTOTYPES //============================================================ -void debugwin_update_during_game(running_machine *machine); +void debugwin_update_during_game(running_machine &machine); #endif diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c index c2a697e2893..2070b1f62ea 100644 --- a/src/osd/sdl/drawogl.c +++ b/src/osd/sdl/drawogl.c @@ -553,7 +553,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); //Moved into init - //load_gl_lib(*window->machine); + //load_gl_lib(window->machine()); // create the SDL window @@ -602,7 +602,7 @@ static int drawogl_window_create(sdl_window_info *window, int width, int height) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, video_config.waitvsync ? 1 : 0); #endif - load_gl_lib(*window->machine); + load_gl_lib(window->machine()); // create the SDL surface (which creates the window in windowed mode) sdl->sdlsurf = SDL_SetVideoMode(width, height, @@ -1206,7 +1206,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) // figure out if we're vector scrnum = is_vector = 0; - for (screen = window->machine->config().first_screen(); screen != NULL; screen = screen->next_screen()) + for (screen = window->machine().config().first_screen(); screen != NULL; screen = screen->next_screen()) { if (scrnum == window->index) { @@ -1240,7 +1240,7 @@ static int drawogl_window_draw(sdl_window_info *window, UINT32 dc, int update) // we're doing nothing 3d, so the Z-buffer is currently not interesting glDisable(GL_DEPTH_TEST); - if (window->machine->options().antialias()) + if (window->machine().options().antialias()) { // enable antialiasing for lines glEnable(GL_LINE_SMOOTH); @@ -2956,7 +2956,7 @@ static void texture_shader_update(sdl_window_info *window, texture_info *texture scrnum = 0; container = (render_container *)NULL; - for (screen_device *screen = window->machine->first_screen(); screen != NULL; screen = screen->next_screen()) + for (screen_device *screen = window->machine().first_screen(); screen != NULL; screen = screen->next_screen()) { if (scrnum == window->start_viewscreen) { @@ -2972,9 +2972,9 @@ static void texture_shader_update(sdl_window_info *window, texture_info *texture container->get_user_settings(settings); //FIXME: Intended behaviour #if 1 - vid_attributes[0] = window->machine->options().gamma(); - vid_attributes[1] = window->machine->options().contrast(); - vid_attributes[2] = window->machine->options().brightness(); + vid_attributes[0] = window->machine().options().gamma(); + vid_attributes[1] = window->machine().options().contrast(); + vid_attributes[2] = window->machine().options().brightness(); #else vid_attributes[0] = settings.gamma; vid_attributes[1] = settings.contrast; diff --git a/src/osd/sdl/dview.c b/src/osd/sdl/dview.c index a1dbe008ccc..38c7d061347 100644 --- a/src/osd/sdl/dview.c +++ b/src/osd/sdl/dview.c @@ -421,8 +421,8 @@ GtkWidget *dview_new(const gchar *widget_name, const gchar *string1, const gchar return wdv; } -void dview_set_debug_view(DView *dv, running_machine *machine, debug_view_type type) +void dview_set_debug_view(DView *dv, running_machine &machine, debug_view_type type) { - dv->view = machine->debug_view().alloc_view(type, dview_update, dv); + dv->view = machine.debug_view().alloc_view(type, dview_update, dv); dv->dv_type = type; } diff --git a/src/osd/sdl/dview.h b/src/osd/sdl/dview.h index a39fd56cb86..b785c6590cd 100644 --- a/src/osd/sdl/dview.h +++ b/src/osd/sdl/dview.h @@ -48,6 +48,6 @@ struct _DView GtkWidget *dview_new(const gchar *widget_name, const gchar *string1, const gchar *string2, gint int1, gint int2); -void dview_set_debug_view(DView *dv, running_machine *machine, debug_view_type type); +void dview_set_debug_view(DView *dv, running_machine &machine, debug_view_type type); #endif diff --git a/src/osd/sdl/input.c b/src/osd/sdl/input.c index 194961b61ad..ad01375dae1 100644 --- a/src/osd/sdl/input.c +++ b/src/osd/sdl/input.c @@ -557,7 +557,7 @@ static int devmap_leastfree(device_map_t *devmap) return -1; } -static char *remove_spaces(running_machine *machine, const char *s) +static char *remove_spaces(running_machine &machine, const char *s) { char *r, *p; static const char *def_name[] = { "Unknown" }; @@ -618,7 +618,7 @@ static void devmap_register(device_map_t *devmap, int physical_idx, char *name) // init_joymap //============================================================ -static void devmap_init(running_machine *machine, device_map_t *devmap, const char *opt, int max_devices, const char *label) +static void devmap_init(running_machine &machine, device_map_t *devmap, const char *opt, int max_devices, const char *label) { int dev; char defname[20]; @@ -638,7 +638,7 @@ static void devmap_init(running_machine *machine, device_map_t *devmap, const ch const char *dev_name; sprintf(defname, "%s%d", opt, dev + 1); - dev_name = machine->options().value(defname); + dev_name = machine.options().value(defname); if (dev_name && *dev_name && strcmp(dev_name,SDLOPTVAL_AUTO)) { devmap->map[dev].name = remove_spaces(machine, dev_name); @@ -648,7 +648,7 @@ static void devmap_init(running_machine *machine, device_map_t *devmap, const ch } } -static device_info *devmap_class_register(running_machine *machine, device_map_t *devmap, +static device_info *devmap_class_register(running_machine &machine, device_map_t *devmap, int index, device_info **devlist, input_device_class devclass) { device_info *devinfo = NULL; @@ -678,7 +678,7 @@ static device_info *devmap_class_register(running_machine *machine, device_map_t // sdlinput_register_joysticks //============================================================ -static void sdlinput_register_joysticks(running_machine *machine) +static void sdlinput_register_joysticks(running_machine &machine) { device_info *devinfo; int physical_stick, axis, button, hat, stick; @@ -772,7 +772,7 @@ static void sdlinput_register_joysticks(running_machine *machine) // sdlinput_deregister_joysticks //============================================================ -static void sdlinput_deregister_joysticks(running_machine *machine) +static void sdlinput_deregister_joysticks(running_machine &machine) { device_info *curdev; @@ -791,11 +791,11 @@ static void sdlinput_deregister_joysticks(running_machine *machine) //============================================================ #if (!SDL13_POST_HG4464 && SDL_VERSION_ATLEAST(1,3,0)) -static void sdlinput_register_mice(running_machine *machine) +static void sdlinput_register_mice(running_machine &machine) { int index, physical_mouse; - mouse_enabled = machine->options().mouse(); + mouse_enabled = machine.options().mouse(); devmap_init(machine, &mouse_map, SDLOPTION_MOUSEINDEX, 8, "Mouse mapping"); @@ -841,7 +841,7 @@ static void sdlinput_register_mice(running_machine *machine) mame_printf_verbose("Mouse: End initialization\n"); } #else -static void sdlinput_register_mice(running_machine *machine) +static void sdlinput_register_mice(running_machine &machine) { device_info *devinfo; char defname[20]; @@ -855,7 +855,7 @@ static void sdlinput_register_mice(running_machine *machine) devinfo = generic_device_alloc(&mouse_list, "System mouse"); devinfo->device = input_device_add(machine, DEVICE_CLASS_MOUSE, devinfo->name, devinfo); - mouse_enabled = machine->options().mouse(); + mouse_enabled = machine.options().mouse(); // add the axes input_device_item_add(devinfo->device, "X", &devinfo->mouse.lX, ITEM_ID_XAXIS, generic_axis_get_state); @@ -930,7 +930,7 @@ static int lookup_mame_code(const char *scode) // sdlinput_read_keymap //============================================================ -static kt_table * sdlinput_read_keymap(running_machine *machine) +static kt_table * sdlinput_read_keymap(running_machine &machine) { char *keymap_filename; kt_table *key_trans_table; @@ -942,10 +942,10 @@ static kt_table * sdlinput_read_keymap(running_machine *machine) char sks[21]; char kns[21]; - if (!machine->options().bool_value(SDLOPTION_KEYMAP)) + if (!machine.options().bool_value(SDLOPTION_KEYMAP)) return sdl_key_trans_table; - keymap_filename = (char *)downcast<sdl_options &>(machine->options()).keymap_file(); + keymap_filename = (char *)downcast<sdl_options &>(machine.options()).keymap_file(); mame_printf_verbose("Keymap: Start reading keymap_file %s\n", keymap_filename); keymap_file = fopen(keymap_filename, "r"); @@ -1003,7 +1003,7 @@ static kt_table * sdlinput_read_keymap(running_machine *machine) //============================================================ #if ((1 ||!SDL13_POST_HG4464) && SDL_VERSION_ATLEAST(1,3,0)) -static void sdlinput_register_keyboards(running_machine *machine) +static void sdlinput_register_keyboards(running_machine &machine) { int physical_keyboard; int index; @@ -1053,7 +1053,7 @@ static void sdlinput_register_keyboards(running_machine *machine) mame_printf_verbose("Keyboard: End initialization\n"); } #else -static void sdlinput_register_keyboards(running_machine *machine) +static void sdlinput_register_keyboards(running_machine &machine) { device_info *devinfo; char defname[20]; @@ -1095,7 +1095,7 @@ static void sdlinput_register_keyboards(running_machine *machine) // sdlinput_init //============================================================ -void sdlinput_init(running_machine *machine) +void sdlinput_init(running_machine &machine) { keyboard_list = NULL; joystick_list = NULL; @@ -1105,9 +1105,9 @@ void sdlinput_init(running_machine *machine) app_has_mouse_focus = 1; // we need pause and exit callbacks - machine->add_notifier(MACHINE_NOTIFY_PAUSE, sdlinput_pause); - machine->add_notifier(MACHINE_NOTIFY_RESUME, sdlinput_resume); - machine->add_notifier(MACHINE_NOTIFY_EXIT, sdlinput_exit); + machine.add_notifier(MACHINE_NOTIFY_PAUSE, sdlinput_pause); + machine.add_notifier(MACHINE_NOTIFY_RESUME, sdlinput_resume); + machine.add_notifier(MACHINE_NOTIFY_EXIT, sdlinput_exit); // allocate a lock for input synchronizations input_lock = osd_lock_alloc(); @@ -1119,14 +1119,14 @@ void sdlinput_init(running_machine *machine) // register the mice sdlinput_register_mice(machine); - if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) + if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) { mame_printf_warning("Debug Build: Disabling input grab for -debug\n"); mouse_enabled = 0; } // get Sixaxis special mode info - sixaxis_mode = downcast<sdl_options &>(machine->options()).sixaxis(); + sixaxis_mode = downcast<sdl_options &>(machine.options()).sixaxis(); // register the joysticks sdlinput_register_joysticks(machine); @@ -1167,7 +1167,7 @@ static void sdlinput_exit(running_machine &machine) // deregister - sdlinput_deregister_joysticks(&machine); + sdlinput_deregister_joysticks(machine); // free all devices device_list_free_devices(&keyboard_list); @@ -1180,7 +1180,7 @@ static void sdlinput_exit(running_machine &machine) // sdlinput_get_focus_window //============================================================ -sdl_window_info *sdlinput_get_focus_window(running_machine *machine) +sdl_window_info *sdlinput_get_focus_window(running_machine &machine) { if (focus_window) // only be set on SDL >= 1.3 return focus_window; @@ -1231,7 +1231,7 @@ INLINE void resize_all_windows(void) #endif -void sdlinput_process_events_buf(running_machine *machine) +void sdlinput_process_events_buf(running_machine &machine) { SDL_Event event; @@ -1254,7 +1254,7 @@ void sdlinput_process_events_buf(running_machine *machine) } -void sdlinput_poll(running_machine *machine) +void sdlinput_poll(running_machine &machine) { device_info *devinfo; SDL_Event event; @@ -1466,7 +1466,7 @@ void sdlinput_poll(running_machine *machine) } break; case SDL_QUIT: - machine->schedule_exit(); + machine.schedule_exit(); break; case SDL_VIDEORESIZE: sdlwindow_resize(sdl_window_list, event.resize.w, event.resize.h); @@ -1494,7 +1494,7 @@ void sdlinput_poll(running_machine *machine) switch (event.window.event) { case SDL_WINDOWEVENT_CLOSE: - machine->schedule_exit(); + machine.schedule_exit(); break; case SDL_WINDOWEVENT_LEAVE: ui_input_push_mouse_leave_event(machine, window->target); @@ -1544,7 +1544,7 @@ void sdlinput_poll(running_machine *machine) //============================================================ -void sdlinput_release_keys(running_machine *machine) +void sdlinput_release_keys(running_machine &machine) { // FIXME: SDL >= 1.3 will nuke the window event buffer when // a window is closed. This will leave keys in a pressed @@ -1568,7 +1568,7 @@ void sdlinput_release_keys(running_machine *machine) // sdlinput_should_hide_mouse //============================================================ -int sdlinput_should_hide_mouse(running_machine *machine) +int sdlinput_should_hide_mouse(running_machine &machine) { // if we are paused, no if (input_paused) diff --git a/src/osd/sdl/input.h b/src/osd/sdl/input.h index f48e0c2acb8..c3806c8b06e 100644 --- a/src/osd/sdl/input.h +++ b/src/osd/sdl/input.h @@ -18,13 +18,13 @@ // PROTOTYPES //============================================================ -void sdlinput_init(running_machine *machine); -void sdlinput_poll(running_machine *machine); -int sdlinput_should_hide_mouse(running_machine *machine); +void sdlinput_init(running_machine &machine); +void sdlinput_poll(running_machine &machine); +int sdlinput_should_hide_mouse(running_machine &machine); -sdl_window_info *sdlinput_get_focus_window(running_machine *machine); +sdl_window_info *sdlinput_get_focus_window(running_machine &machine); -void sdlinput_process_events_buf(running_machine *machine); -void sdlinput_release_keys(running_machine *machine); +void sdlinput_process_events_buf(running_machine &machine); +void sdlinput_release_keys(running_machine &machine); #endif /* __SDLINPUT_H__ */ diff --git a/src/osd/sdl/osdsdl.h b/src/osd/sdl/osdsdl.h index 5b70b9f2e1d..fd459603d04 100644 --- a/src/osd/sdl/osdsdl.h +++ b/src/osd/sdl/osdsdl.h @@ -272,7 +272,7 @@ private: // sound.c //============================================================ -void sdlaudio_init(running_machine *machine); +void sdlaudio_init(running_machine &machine); //============================================================ // sdlwork.c diff --git a/src/osd/sdl/output.c b/src/osd/sdl/output.c index 7f2f7c585aa..0381ef16e0b 100644 --- a/src/osd/sdl/output.c +++ b/src/osd/sdl/output.c @@ -71,11 +71,11 @@ PID_CAST osd_getpid(void) // sdloutput_init //============================================================ -void sdloutput_init(running_machine *machine) +void sdloutput_init(running_machine &machine) { int fildes; - machine->add_notifier(MACHINE_NOTIFY_EXIT, sdloutput_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, sdloutput_exit); fildes = open(SDLMAME_OUTPUT, O_RDWR | O_NONBLOCK); @@ -89,7 +89,7 @@ void sdloutput_init(running_machine *machine) output = fdopen(fildes, "w"); mame_printf_verbose("ouput: opened output notifier file %s\n", SDLMAME_OUTPUT); - fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), machine->system().name); + fprintf(output, "MAME " PID_FMT " START %s\n", osd_getpid(), machine.system().name); fflush(output); } @@ -134,7 +134,7 @@ static void notifier_callback(const char *outname, INT32 value, void *param) // Stub for win32 //============================================================ -void sdloutput_init(running_machine *machine) +void sdloutput_init(running_machine &machine) { } diff --git a/src/osd/sdl/output.h b/src/osd/sdl/output.h index 196c29e02a6..507189fd8fe 100644 --- a/src/osd/sdl/output.h +++ b/src/osd/sdl/output.h @@ -14,7 +14,7 @@ // FUNCTION PROTOTYPES //============================================================ -void sdloutput_init(running_machine *machine); +void sdloutput_init(running_machine &machine); #endif /* __SDLMAME_OUTPUT_H__ */ diff --git a/src/osd/sdl/sdlmain.c b/src/osd/sdl/sdlmain.c index afddf9b71af..747b881d060 100644 --- a/src/osd/sdl/sdlmain.c +++ b/src/osd/sdl/sdlmain.c @@ -633,7 +633,7 @@ void sdl_osd_interface::init(running_machine &machine) exit(-1); } - if (sdlvideo_init(&machine)) + if (sdlvideo_init(machine)) { osd_exit(machine); mame_printf_error("sdlvideo_init: Initialization failed!\n\n\n"); @@ -642,11 +642,11 @@ void sdl_osd_interface::init(running_machine &machine) exit(-1); } - sdlinput_init(&machine); + sdlinput_init(machine); - sdlaudio_init(&machine); + sdlaudio_init(machine); - sdloutput_init(&machine); + sdloutput_init(machine); if (options.oslog()) machine.add_logerror_callback(output_oslog); @@ -659,7 +659,7 @@ void sdl_osd_interface::init(running_machine &machine) /* only enable watchdog if seconds_to_run is enabled *and* relatively short (time taken from ui.c) */ if ((watchdog_timeout != 0) && (str > 0) && (str < 60*5 )) { - m_watchdog = auto_alloc(&machine, watchdog); + m_watchdog = auto_alloc(machine, watchdog); m_watchdog->setTimeout(watchdog_timeout); } @@ -802,7 +802,7 @@ bitmap_t *sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, color_space = CGColorSpaceCreateDeviceRGB(); bits_per_component = 8; - bitmap = auto_alloc(&machine(), bitmap_t(bitmap_width, bitmap_height, BITMAP_FORMAT_ARGB32)); + bitmap = auto_alloc(machine(), bitmap_t(bitmap_width, bitmap_height, BITMAP_FORMAT_ARGB32)); context_ref = CGBitmapContextCreate( bitmap->base, bitmap_width, bitmap_height, bits_per_component, bitmap->rowpixels*4, color_space, bitmap_info ); @@ -1063,7 +1063,7 @@ bitmap_t *sdl_osd_interface::font_get_bitmap(osd_font font, unicode_char chnum, if (drawsurf) { // allocate a MAME destination bitmap - bitmap = auto_alloc(&machine(), bitmap_t(drawsurf->w, drawsurf->h, BITMAP_FORMAT_ARGB32)); + bitmap = auto_alloc(machine(), bitmap_t(drawsurf->w, drawsurf->h, BITMAP_FORMAT_ARGB32)); // copy the rendered character image into it for (int y = 0; y < bitmap->height; y++) diff --git a/src/osd/sdl/sound.c b/src/osd/sdl/sound.c index cb0da6968c7..b3eed800f98 100644 --- a/src/osd/sdl/sound.c +++ b/src/osd/sdl/sound.c @@ -69,8 +69,8 @@ static int snd_enabled; // PROTOTYPES //============================================================ -static int sdl_init(running_machine *machine); -static void sdl_kill(running_machine *machine); +static int sdl_init(running_machine &machine); +static void sdl_kill(running_machine &machine); static int sdl_create_buffers(void); static void sdl_destroy_buffers(void); static void sdl_cleanup_audio(running_machine &machine); @@ -81,21 +81,21 @@ static void sdl_callback(void *userdata, Uint8 *stream, int len); //============================================================ // osd_start_audio_stream //============================================================ -void sdlaudio_init(running_machine *machine) +void sdlaudio_init(running_machine &machine) { if (LOG_SOUND) sound_log = fopen(SDLMAME_SOUND_LOG, "w"); // skip if sound disabled - if (machine->sample_rate() != 0) + if (machine.sample_rate() != 0) { // attempt to initialize SDL if (sdl_init(machine)) return; - machine->add_notifier(MACHINE_NOTIFY_EXIT, sdl_cleanup_audio); + machine.add_notifier(MACHINE_NOTIFY_EXIT, sdl_cleanup_audio); // set the startup volume - machine->osd().set_mastervolume(attenuation); + machine.osd().set_mastervolume(attenuation); } return; } @@ -113,7 +113,7 @@ static void sdl_cleanup_audio(running_machine &machine) return; // kill the buffers and dsound - sdl_kill(&machine); + sdl_kill(machine); sdl_destroy_buffers(); // print out over/underflow stats @@ -419,7 +419,7 @@ static void sdl_callback(void *userdata, Uint8 *stream, int len) //============================================================ // sdl_init //============================================================ -static int sdl_init(running_machine *machine) +static int sdl_init(running_machine &machine) { int n_channels = 2; int audio_latency; @@ -428,7 +428,7 @@ static int sdl_init(running_machine *machine) if (initialized_audio) { - sdl_cleanup_audio(*machine); + sdl_cleanup_audio(machine); } mame_printf_verbose("Audio: Start initialization\n"); @@ -446,7 +446,7 @@ static int sdl_init(running_machine *machine) stream_loop = 0; // set up the audio specs - aspec.freq = machine->sample_rate(); + aspec.freq = machine.sample_rate(); aspec.format = AUDIO_S16SYS; // keep endian independent aspec.channels = n_channels; aspec.samples = sdl_xfer_samples; @@ -464,7 +464,7 @@ static int sdl_init(running_machine *machine) sdl_xfer_samples = obtained.samples; - audio_latency = downcast<sdl_options &>(machine->options()).audio_latency(); + audio_latency = downcast<sdl_options &>(machine.options()).audio_latency(); // pin audio latency if (audio_latency > MAX_AUDIO_LATENCY) @@ -477,7 +477,7 @@ static int sdl_init(running_machine *machine) } // compute the buffer sizes - stream_buffer_size = machine->sample_rate() * 2 * sizeof(INT16) * audio_latency / MAX_AUDIO_LATENCY; + stream_buffer_size = machine.sample_rate() * 2 * sizeof(INT16) * audio_latency / MAX_AUDIO_LATENCY; stream_buffer_size = (stream_buffer_size / 1024) * 1024; if (stream_buffer_size < 1024) stream_buffer_size = 1024; @@ -503,7 +503,7 @@ cant_start_audio: // sdl_kill //============================================================ -static void sdl_kill(running_machine *machine) +static void sdl_kill(running_machine &machine) { if (initialized_audio) { diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c index c3f2877857b..b8dea72fd17 100644 --- a/src/osd/sdl/video.c +++ b/src/osd/sdl/video.c @@ -90,10 +90,10 @@ static void video_exit(running_machine &machine); static void init_monitors(void); static sdl_monitor_info *pick_monitor(sdl_options &options, int index); -static void check_osd_inputs(running_machine *machine); +static void check_osd_inputs(running_machine &machine); -static void extract_video_config(running_machine *machine); -static void extract_window_config(running_machine *machine, int index, sdl_window_config *conf); +static void extract_video_config(running_machine &machine); +static void extract_window_config(running_machine &machine, int index, sdl_window_config *conf); static float get_aspect(const char *defdata, const char *data, int report_error); static void get_resolution(const char *defdata, const char *data, sdl_window_config *config, int report_error); @@ -102,7 +102,7 @@ static void get_resolution(const char *defdata, const char *data, sdl_window_con // sdlvideo_init //============================================================ -int sdlvideo_init(running_machine *machine) +int sdlvideo_init(running_machine &machine) { int index, tc; @@ -110,22 +110,22 @@ int sdlvideo_init(running_machine *machine) extract_video_config(machine); // ensure we get called on the way out - machine->add_notifier(MACHINE_NOTIFY_EXIT, video_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, video_exit); // set up monitors first init_monitors(); // we need the beam width in a float, contrary to what the core does. - video_config.beamwidth = machine->options().beam(); + video_config.beamwidth = machine.options().beam(); // initialize the window system so we can make windows if (sdlwindow_init(machine)) return 1; - tc = machine->total_colors(); + tc = machine.total_colors(); // create the windows - sdl_options &options = downcast<sdl_options &>(machine->options()); + sdl_options &options = downcast<sdl_options &>(machine.options()); for (index = 0; index < video_config.numscreens; index++) { sdl_window_config conf; @@ -337,16 +337,16 @@ void sdl_osd_interface::update(bool skip_redraw) { // profiler_mark(PROFILER_BLIT); for (window = sdl_window_list; window != NULL; window = window->next) - sdlwindow_video_window_update(&machine(), window); + sdlwindow_video_window_update(machine(), window); // profiler_mark(PROFILER_END); } // poll the joystick values here - sdlinput_poll(&machine()); - check_osd_inputs(&machine()); + sdlinput_poll(machine()); + check_osd_inputs(machine()); if ((machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) - debugwin_update_during_game(&machine()); + debugwin_update_during_game(machine()); } @@ -557,7 +557,7 @@ static sdl_monitor_info *pick_monitor(sdl_options &options, int index) // check_osd_inputs //============================================================ -static void check_osd_inputs(running_machine *machine) +static void check_osd_inputs(running_machine &machine) { sdl_window_info *window = sdlinput_get_focus_window(machine); @@ -600,9 +600,9 @@ static void check_osd_inputs(running_machine *machine) // extract_window_config //============================================================ -static void extract_window_config(running_machine *machine, int index, sdl_window_config *conf) +static void extract_window_config(running_machine &machine, int index, sdl_window_config *conf) { - sdl_options &options = downcast<sdl_options &>(machine->options()); + sdl_options &options = downcast<sdl_options &>(machine.options()); // per-window options: extract the data get_resolution(options.resolution(), options.resolution(index), conf, TRUE); } @@ -611,10 +611,10 @@ static void extract_window_config(running_machine *machine, int index, sdl_windo // extract_video_config //============================================================ -static void extract_video_config(running_machine *machine) +static void extract_video_config(running_machine &machine) { const char *stemp; - sdl_options &options = downcast<sdl_options &>(machine->options()); + sdl_options &options = downcast<sdl_options &>(machine.options()); video_config.perftest = options.video_fps(); @@ -628,7 +628,7 @@ static void extract_video_config(running_machine *machine) #endif - if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) + if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) video_config.windowed = TRUE; // default to working video please diff --git a/src/osd/sdl/video.h b/src/osd/sdl/video.h index 65f98a21e1e..e143abd7324 100644 --- a/src/osd/sdl/video.h +++ b/src/osd/sdl/video.h @@ -148,7 +148,7 @@ extern sdl_video_config video_config; // PROTOTYPES //============================================================ -int sdlvideo_init(running_machine *machine); +int sdlvideo_init(running_machine &machine); void sdlvideo_monitor_refresh(sdl_monitor_info *monitor); float sdlvideo_monitor_get_aspect(sdl_monitor_info *monitor); diff --git a/src/osd/sdl/window.c b/src/osd/sdl/window.c index 51797564833..ae9d6f44f97 100644 --- a/src/osd/sdl/window.c +++ b/src/osd/sdl/window.c @@ -98,9 +98,10 @@ static sdl_draw_info draw; typedef struct _worker_param worker_param; struct _worker_param { + running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } sdl_window_info *window; render_primitive_list *list; - running_machine *machine; + running_machine *m_machine; int resize_new_width; int resize_new_height; }; @@ -111,19 +112,19 @@ struct _worker_param { //============================================================ static void sdlwindow_exit(running_machine &machine); -static void sdlwindow_video_window_destroy(running_machine *machine, sdl_window_info *window); +static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window); static OSDWORK_CALLBACK( draw_video_contents_wt ); static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ); static OSDWORK_CALLBACK( sdlwindow_resize_wt ); static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ); -static void sdlwindow_update_cursor_state(running_machine *machine, sdl_window_info *window); +static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window); static void sdlwindow_sync(void); static void get_min_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain); static void get_max_bounds(sdl_window_info *window, int *window_width, int *window_height, int constrain); static void *complete_create_wt(void *param, int threadid); -static void set_starting_view(running_machine *machine, int index, sdl_window_info *window, const char *defview, const char *view); +static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view); //============================================================ // clear the worker_param structure, inline - faster than memset @@ -133,7 +134,7 @@ INLINE void clear_worker_param(worker_param *wp) { wp->window=NULL; wp->list=NULL; - wp->machine=NULL; + wp->m_machine=NULL; wp->resize_new_width=0; wp->resize_new_height=0; } @@ -202,17 +203,17 @@ static OSDWORK_CALLBACK(sdlwindow_thread_id) // (main thread) //============================================================ -int sdlwindow_init(running_machine *machine) +int sdlwindow_init(running_machine &machine) { mame_printf_verbose("Enter sdlwindow_init\n"); // determine if we are using multithreading or not - multithreading_enabled = downcast<sdl_options &>(machine->options()).multithreading(); + multithreading_enabled = downcast<sdl_options &>(machine.options()).multithreading(); // get the main thread ID before anything else main_threadid = SDL_ThreadID(); // ensure we get called on the way out - machine->add_notifier(MACHINE_NOTIFY_EXIT, sdlwindow_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, sdlwindow_exit); // if multithreading, create a thread to run the windows if (multithreading_enabled) @@ -234,14 +235,14 @@ int sdlwindow_init(running_machine *machine) #if USE_OPENGL if (video_config.mode == VIDEO_MODE_OPENGL) { - if (drawogl_init(*machine, &draw)) + if (drawogl_init(machine, &draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif #if SDL_VERSION_ATLEAST(1,3,0) if (video_config.mode == VIDEO_MODE_SDL13) { - if (draw13_init(*machine, &draw)) + if (draw13_init(machine, &draw)) video_config.mode = VIDEO_MODE_SOFT; } #endif @@ -303,7 +304,7 @@ static void sdlwindow_exit(running_machine &machine) { sdl_window_info *temp = sdl_window_list; sdl_window_list = temp->next; - sdlwindow_video_window_destroy(&machine, temp); + sdlwindow_video_window_destroy(machine, temp); } // if we're multithreaded, clean up the window thread @@ -506,7 +507,7 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ) ASSERT_WINDOW_THREAD(); // if we are in debug mode, never go full screen - if (window->machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) + if (window->machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) return NULL; // If we are going fullscreen (leaving windowed) remember our windowed size @@ -517,7 +518,7 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ) } window->destroy(window); - sdlinput_release_keys(wp->machine); + sdlinput_release_keys(wp->machine()); // toggle the window mode window->fullscreen = !window->fullscreen; @@ -527,7 +528,7 @@ static OSDWORK_CALLBACK( sdlwindow_toggle_full_screen_wt ) return NULL; } -void sdlwindow_toggle_full_screen(running_machine *machine, sdl_window_info *window) +void sdlwindow_toggle_full_screen(running_machine &machine, sdl_window_info *window) { worker_param wp; @@ -535,7 +536,7 @@ void sdlwindow_toggle_full_screen(running_machine *machine, sdl_window_info *win clear_worker_param(&wp); wp.window = window; - wp.machine = machine; + wp.m_machine = &machine; execute_async_wait(&sdlwindow_toggle_full_screen_wt, &wp); } @@ -552,7 +553,7 @@ static OSDWORK_CALLBACK( destroy_all_textures_wt ) return NULL; } -void sdlwindow_modify_prescale(running_machine *machine, sdl_window_info *window, int dir) +void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir) { worker_param wp; int new_prescale = window->prescale; @@ -560,7 +561,7 @@ void sdlwindow_modify_prescale(running_machine *machine, sdl_window_info *window clear_worker_param(&wp); wp.window = window; - wp.machine = machine; + wp.m_machine = &machine; if (dir > 0 && window->prescale < 3) new_prescale = window->prescale + 1; @@ -592,12 +593,12 @@ void sdlwindow_modify_prescale(running_machine *machine, sdl_window_info *window // (main or window thread) //============================================================ -static void sdlwindow_update_cursor_state(running_machine *machine, sdl_window_info *window) +static void sdlwindow_update_cursor_state(running_machine &machine, sdl_window_info *window) { #if (SDL_VERSION_ATLEAST(1,3,0)) // do not do mouse capture if the debugger's enabled to avoid // the possibility of losing control - if (!(machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)) + if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) { //FIXME: SDL1.3: really broken: the whole SDL code // will only work correct with relative mouse movements ... @@ -620,7 +621,7 @@ static void sdlwindow_update_cursor_state(running_machine *machine, sdl_window_i #else // do not do mouse capture if the debugger's enabled to avoid // the possibility of losing control - if (!(machine->debug_flags & DEBUG_FLAG_OSD_ENABLED)) + if (!(machine.debug_flags & DEBUG_FLAG_OSD_ENABLED)) { if ( window->fullscreen || sdlinput_should_hide_mouse(machine) ) { @@ -648,7 +649,7 @@ static void sdlwindow_update_cursor_state(running_machine *machine, sdl_window_i // (main thread) //============================================================ -int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config) +int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config) { sdl_window_info *window; worker_param *wp = (worker_param *) osd_malloc(sizeof(worker_param)); @@ -665,7 +666,7 @@ int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monit window->depth = config->depth; window->refresh = config->refresh; window->monitor = monitor; - window->machine = machine; + window->m_machine = &machine; window->index = index; //FIXME: these should be per_window in config-> or even better a bit set @@ -675,7 +676,7 @@ int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monit // set the initial maximized state // FIXME: Does not belong here - sdl_options &options = downcast<sdl_options &>(machine->options()); + sdl_options &options = downcast<sdl_options &>(machine.options()); window->startmaximized = options.maximize(); if (!window->fullscreen) @@ -695,16 +696,16 @@ int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monit window->rendered_event = osd_event_alloc(FALSE, TRUE); // load the layout - window->target = machine->render().target_alloc(); + window->target = machine.render().target_alloc(); // set the specific view set_starting_view(machine, index, window, options.view(), options.view(index)); // make the window title if (video_config.numscreens == 1) - sprintf(window->title, APPNAME ": %s [%s]", machine->system().description, machine->system().name); + sprintf(window->title, APPNAME ": %s [%s]", machine.system().description, machine.system().name); else - sprintf(window->title, APPNAME ": %s [%s] - Screen %d", machine->system().description, machine->system().name, index); + sprintf(window->title, APPNAME ": %s [%s] - Screen %d", machine.system().description, machine.system().name, index); wp->window = window; @@ -748,14 +749,14 @@ static OSDWORK_CALLBACK( sdlwindow_video_window_destroy_wt ) window->destroy(window); // release all keys ... - sdlinput_release_keys(wp->machine); + sdlinput_release_keys(wp->machine()); osd_free(wp); return NULL; } -static void sdlwindow_video_window_destroy(running_machine *machine, sdl_window_info *window) +static void sdlwindow_video_window_destroy(running_machine &machine, sdl_window_info *window) { sdl_window_info **prevptr; worker_param wp; @@ -779,11 +780,11 @@ static void sdlwindow_video_window_destroy(running_machine *machine, sdl_window_ // free the textures etc clear_worker_param(&wp); wp.window = window; - wp.machine = machine; + wp.m_machine = &machine; execute_async_wait(&sdlwindow_video_window_destroy_wt, &wp); // free the render target, after the textures! - window->machine->render().target_free(window->target); + window->machine().render().target_free(window->target); // free the event osd_event_free(window->rendered_event); @@ -945,7 +946,7 @@ static void pick_best_mode(sdl_window_info *window, int *fswidth, int *fsheight) // (main thread) //============================================================ -void sdlwindow_video_window_update(running_machine *machine, sdl_window_info *window) +void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window) { osd_ticks_t event_wait_ticks; @@ -996,7 +997,7 @@ void sdlwindow_video_window_update(running_machine *machine, sdl_window_info *wi wp.list = primlist; wp.window = window; - wp.machine = machine; + wp.m_machine = &machine; execute_async(&draw_video_contents_wt, &wp); } @@ -1009,7 +1010,7 @@ void sdlwindow_video_window_update(running_machine *machine, sdl_window_info *wi // (main thread) //============================================================ -static void set_starting_view(running_machine *machine, int index, sdl_window_info *window, const char *defview, const char *view) +static void set_starting_view(running_machine &machine, int index, sdl_window_info *window, const char *defview, const char *view) { int viewindex; @@ -1149,7 +1150,7 @@ static OSDWORK_CALLBACK( draw_video_contents_wt ) ASSERT_REDRAW_THREAD(); // Some configurations require events to be polled in the worker thread - sdlinput_process_events_buf(wp->machine); + sdlinput_process_events_buf(wp->machine()); window->primlist = wp->list; diff --git a/src/osd/sdl/window.h b/src/osd/sdl/window.h index f1c8b41a5c0..1a0a6b0a310 100644 --- a/src/osd/sdl/window.h +++ b/src/osd/sdl/window.h @@ -39,7 +39,8 @@ struct _sdl_window_info sdl_window_info * next; // Pointer to machine - running_machine * machine; + running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + running_machine * m_machine; // Draw Callbacks int (*create)(sdl_window_info *window, int width, int height); @@ -123,14 +124,14 @@ extern sdl_window_info *sdl_window_list; //============================================================ // core initialization -int sdlwindow_init(running_machine *machine); +int sdlwindow_init(running_machine &machine); // creation/deletion of windows -int sdlwindow_video_window_create(running_machine *machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config); -void sdlwindow_video_window_update(running_machine *machine, sdl_window_info *window); +int sdlwindow_video_window_create(running_machine &machine, int index, sdl_monitor_info *monitor, const sdl_window_config *config); +void sdlwindow_video_window_update(running_machine &machine, sdl_window_info *window); void sdlwindow_blit_surface_size(sdl_window_info *window, int window_width, int window_height); -void sdlwindow_toggle_full_screen(running_machine *machine, sdl_window_info *window); -void sdlwindow_modify_prescale(running_machine *machine, sdl_window_info *window, int dir); +void sdlwindow_toggle_full_screen(running_machine &machine, sdl_window_info *window); +void sdlwindow_modify_prescale(running_machine &machine, sdl_window_info *window, int dir); void sdlwindow_resize(sdl_window_info *window, INT32 width, INT32 height); void sdlwindow_clear(sdl_window_info *window); diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c index 4fcb3a367d3..6b6a6d2b3de 100644 --- a/src/osd/windows/debugwin.c +++ b/src/osd/windows/debugwin.c @@ -163,6 +163,8 @@ struct _debugview_info struct _debugwin_info { + running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + debugwin_info * next; HWND wnd; HWND focuswnd; @@ -189,7 +191,7 @@ struct _debugwin_info HWND otherwnd[MAX_OTHER_WND]; - running_machine * machine; + running_machine * m_machine; }; @@ -217,7 +219,7 @@ static UINT32 vscroll_width; // PROTOTYPES //============================================================ -static debugwin_info *debugwin_window_create(running_machine *machine, LPCSTR title, WNDPROC handler); +static debugwin_info *debugwin_window_create(running_machine &machine, LPCSTR title, WNDPROC handler); static void debugwin_window_free(debugwin_info *info); static LRESULT CALLBACK debugwin_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); @@ -231,23 +233,23 @@ static LRESULT CALLBACK debugwin_edit_proc(HWND wnd, UINT message, WPARAM wparam //static void generic_create_window(int type); static void generic_recompute_children(debugwin_info *info); -static void memory_create_window(running_machine *machine); +static void memory_create_window(running_machine &machine); static void memory_recompute_children(debugwin_info *info); static void memory_process_string(debugwin_info *info, const char *string); static void memory_update_menu(debugwin_info *info); static int memory_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lparam); static int memory_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam); -static void memory_update_caption(running_machine *machine, HWND wnd); +static void memory_update_caption(running_machine &machine, HWND wnd); -static void disasm_create_window(running_machine *machine); +static void disasm_create_window(running_machine &machine); static void disasm_recompute_children(debugwin_info *info); static void disasm_process_string(debugwin_info *info, const char *string); static void disasm_update_menu(debugwin_info *info); static int disasm_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lparam); static int disasm_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam); -static void disasm_update_caption(running_machine *machine, HWND wnd); +static void disasm_update_caption(running_machine &machine, HWND wnd); -static void console_create_window(running_machine *machine); +static void console_create_window(running_machine &machine); static void console_recompute_children(debugwin_info *info); static void console_process_string(debugwin_info *info, const char *string); static void console_set_cpu(device_t *device); @@ -271,7 +273,7 @@ void windows_osd_interface::wait_for_debugger(device_t &device, bool firststop) // create a console window if (main_console == NULL) - console_create_window(&machine()); + console_create_window(machine()); // update the views in the console to reflect the current CPU if (main_console != NULL) @@ -290,7 +292,7 @@ void windows_osd_interface::wait_for_debugger(device_t &device, bool firststop) smart_show_all(TRUE); // run input polling to ensure that our status is in sync - wininput_poll(&machine()); + wininput_poll(machine()); // get and process messages GetMessage(&message, NULL, 0, 0); @@ -308,7 +310,7 @@ void windows_osd_interface::wait_for_debugger(device_t &device, bool firststop) // process everything else default: - winwindow_dispatch_message(&machine(), &message); + winwindow_dispatch_message(machine(), &message); break; } @@ -322,7 +324,7 @@ void windows_osd_interface::wait_for_debugger(device_t &device, bool firststop) // debugwin_seq_pressed //============================================================ -static int debugwin_seq_pressed(running_machine *machine) +static int debugwin_seq_pressed(running_machine &machine) { const input_seq *seq = input_type_seq(machine, IPT_UI_DEBUG_BREAK, 0, SEQ_TYPE_STANDARD); int result = FALSE; @@ -504,10 +506,10 @@ void debugwin_show(int type) // debugwin_update_during_game //============================================================ -void debugwin_update_during_game(running_machine *machine) +void debugwin_update_during_game(running_machine &machine) { // if we're running live, do some checks - if (!winwindow_has_focus() && !debug_cpu_is_stopped(machine) && machine->phase() == MACHINE_PHASE_RUNNING) + if (!winwindow_has_focus() && !debug_cpu_is_stopped(machine) && machine.phase() == MACHINE_PHASE_RUNNING) { // see if the interrupt key is pressed and break if it is if (debugwin_seq_pressed(machine)) @@ -534,7 +536,7 @@ void debugwin_update_during_game(running_machine *machine) // debugwin_window_create //============================================================ -static debugwin_info *debugwin_window_create(running_machine *machine, LPCSTR title, WNDPROC handler) +static debugwin_info *debugwin_window_create(running_machine &machine, LPCSTR title, WNDPROC handler) { debugwin_info *info = NULL; RECT work_bounds; @@ -561,7 +563,7 @@ static debugwin_info *debugwin_window_create(running_machine *machine, LPCSTR ti info->handle_key = global_handle_key; strcpy(info->edit_defstr, ""); - info->machine = machine; + info->m_machine = &machine; // hook us in info->next = window_list; @@ -599,7 +601,7 @@ static void debugwin_window_free(debugwin_info *info) for (viewnum = 0; viewnum < ARRAY_LENGTH(info->view); viewnum++) if (info->view[viewnum].view != NULL) { - info->machine->debug_view().free_view(*info->view[viewnum].view); + info->machine().debug_view().free_view(*info->view[viewnum].view); info->view[viewnum].view = NULL; } @@ -708,7 +710,7 @@ static LRESULT CALLBACK debugwin_window_proc(HWND wnd, UINT message, WPARAM wpar case WM_CHAR: if (info->ignore_char_lparam == (lparam >> 16)) info->ignore_char_lparam = 0; - else if (waiting_for_debugger || !debugwin_seq_pressed(info->machine)) + else if (waiting_for_debugger || !debugwin_seq_pressed(info->machine())) return DefWindowProc(wnd, message, wparam, lparam); break; @@ -806,7 +808,7 @@ static LRESULT CALLBACK debugwin_window_proc(HWND wnd, UINT message, WPARAM wpar if (main_console && main_console->wnd == wnd) { smart_show_all(FALSE); - debug_cpu_get_visible_cpu(info->machine)->debug()->go(); + debug_cpu_get_visible_cpu(info->machine())->debug()->go(); } else DestroyWindow(wnd); @@ -853,7 +855,7 @@ static int debugwin_view_create(debugwin_info *info, int which, debug_view_type goto cleanup; // create the debug view - view->view = info->machine->debug_view().alloc_view(type, debugwin_view_update, view); + view->view = info->machine().debug_view().alloc_view(type, debugwin_view_update, view); if (view->view == NULL) goto cleanup; @@ -861,7 +863,7 @@ static int debugwin_view_create(debugwin_info *info, int which, debug_view_type cleanup: if (view->view) - info->machine->debug_view().free_view(*view->view); + info->machine().debug_view().free_view(*view->view); if (view->hscroll) DestroyWindow(view->hscroll); if (view->vscroll) @@ -1427,7 +1429,7 @@ static LRESULT CALLBACK debugwin_view_proc(HWND wnd, UINT message, WPARAM wparam { if (info->owner->ignore_char_lparam == (lparam >> 16)) info->owner->ignore_char_lparam = 0; - else if (waiting_for_debugger || !debugwin_seq_pressed(info->owner->machine)) + else if (waiting_for_debugger || !debugwin_seq_pressed(info->owner->machine())) { if (wparam >= 32 && wparam < 127 && info->view->cursor_supported()) info->view->process_char(wparam); @@ -1474,7 +1476,7 @@ static LRESULT CALLBACK debugwin_view_proc(HWND wnd, UINT message, WPARAM wparam debug_view_xy topleft = info->view->visible_position(); topleft.x = debugwin_view_process_scroll(info, LOWORD(wparam), (HWND)lparam); info->view->set_visible_position(topleft); - info->owner->machine->debug_view().flush_osd_updates(); + info->owner->machine().debug_view().flush_osd_updates(); break; } @@ -1484,7 +1486,7 @@ static LRESULT CALLBACK debugwin_view_proc(HWND wnd, UINT message, WPARAM wparam debug_view_xy topleft = info->view->visible_position(); topleft.y = debugwin_view_process_scroll(info, LOWORD(wparam), (HWND)lparam); info->view->set_visible_position(topleft); - info->owner->machine->debug_view().flush_osd_updates(); + info->owner->machine().debug_view().flush_osd_updates(); break; } @@ -1571,7 +1573,7 @@ static LRESULT CALLBACK debugwin_edit_proc(HWND wnd, UINT message, WPARAM wparam // ignore chars associated with keys we've handled if (info->ignore_char_lparam == (lparam >> 16)) info->ignore_char_lparam = 0; - else if (waiting_for_debugger || !debugwin_seq_pressed(info->machine)) + else if (waiting_for_debugger || !debugwin_seq_pressed(info->machine())) { switch (wparam) { @@ -1638,13 +1640,13 @@ static LRESULT CALLBACK debugwin_edit_proc(HWND wnd, UINT message, WPARAM wparam //============================================================ #ifdef UNUSED_FUNCTION -static void generic_create_window(running_machine *machine, debug_view_type type) +static void generic_create_window(running_machine &machine, debug_view_type type) { debugwin_info *info; char title[256]; // create the window - _snprintf(title, ARRAY_LENGTH(title), "Debug: %s [%s]", machine->system().description, machine->system().name); + _snprintf(title, ARRAY_LENGTH(title), "Debug: %s [%s]", machine.system().description, machine.system().name); info = debugwin_window_create(machine, title, NULL); if (info == NULL || !debugwin_view_create(info, 0, type)) return; @@ -1696,7 +1698,7 @@ static void generic_recompute_children(debugwin_info *info) // log_create_window //============================================================ -static void log_create_window(running_machine *machine) +static void log_create_window(running_machine &machine) { debug_view_xy totalsize; debugwin_info *info; @@ -1704,7 +1706,7 @@ static void log_create_window(running_machine *machine) RECT bounds; // create the window - _snprintf(title, ARRAY_LENGTH(title), "Errorlog: %s [%s]", machine->system().description, machine->system().name); + _snprintf(title, ARRAY_LENGTH(title), "Errorlog: %s [%s]", machine.system().description, machine.system().name); info = debugwin_window_create(machine, title, NULL); if (info == NULL || !debugwin_view_create(info, 0, DVT_LOG)) return; @@ -1740,7 +1742,7 @@ static void log_create_window(running_machine *machine) // memory_create_window //============================================================ -static void memory_create_window(running_machine *machine) +static void memory_create_window(running_machine &machine) { device_t *curcpu = debug_cpu_get_visible_cpu(machine); debugwin_info *info; @@ -1930,7 +1932,7 @@ static int memory_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar if (sel != CB_ERR) { memview->set_source(*memview->source_list().by_index(sel)); - memory_update_caption(info->machine, info->wnd); + memory_update_caption(info->machine(), info->wnd); // reset the focus SetFocus(info->focuswnd); @@ -2042,7 +2044,7 @@ static int memory_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam) // memory_update_caption //============================================================ -static void memory_update_caption(running_machine *machine, HWND wnd) +static void memory_update_caption(running_machine &machine, HWND wnd) { debugwin_info *info = (debugwin_info *)(FPTR)GetWindowLongPtr(wnd, GWLP_USERDATA); astring title; @@ -2057,7 +2059,7 @@ static void memory_update_caption(running_machine *machine, HWND wnd) // disasm_create_window //============================================================ -static void disasm_create_window(running_machine *machine) +static void disasm_create_window(running_machine &machine) { device_t *curcpu = debug_cpu_get_visible_cpu(machine); debugwin_info *info; @@ -2239,7 +2241,7 @@ static int disasm_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar if (sel != CB_ERR) { dasmview->set_source(*dasmview->source_list().by_index(sel)); - disasm_update_caption(info->machine, info->wnd); + disasm_update_caption(info->machine(), info->wnd); // reset the focus SetFocus(info->focuswnd); @@ -2268,16 +2270,16 @@ static int disasm_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar return 1; case ID_RUN_TO_CURSOR: - if (dasmview->cursor_visible() && debug_cpu_get_visible_cpu(info->machine) == dasmview->source()->device()) + if (dasmview->cursor_visible() && debug_cpu_get_visible_cpu(info->machine()) == dasmview->source()->device()) { offs_t address = dasmview->selected_address(); sprintf(command, "go 0x%X", address); - debug_console_execute_command(info->machine, command, 1); + debug_console_execute_command(info->machine(), command, 1); } return 1; case ID_TOGGLE_BREAKPOINT: - if (dasmview->cursor_visible() && debug_cpu_get_visible_cpu(info->machine) == dasmview->source()->device()) + if (dasmview->cursor_visible() && debug_cpu_get_visible_cpu(info->machine()) == dasmview->source()->device()) { offs_t address = dasmview->selected_address(); device_debug *debug = dasmview->source()->device()->debug(); @@ -2296,7 +2298,7 @@ static int disasm_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar sprintf(command, "bpset 0x%X", address); else sprintf(command, "bpclear 0x%X", bpindex); - debug_console_execute_command(info->machine, command, 1); + debug_console_execute_command(info->machine(), command, 1); } return 1; } @@ -2360,7 +2362,7 @@ static int disasm_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam) // disasm_update_caption //============================================================ -static void disasm_update_caption(running_machine *machine, HWND wnd) +static void disasm_update_caption(running_machine &machine, HWND wnd) { debugwin_info *info = (debugwin_info *)(FPTR)GetWindowLongPtr(wnd, GWLP_USERDATA); astring title; @@ -2375,7 +2377,7 @@ static void disasm_update_caption(running_machine *machine, HWND wnd) // console_create_window //============================================================ -void console_create_window(running_machine *machine) +void console_create_window(running_machine &machine) { debugwin_info *info; int bestwidth, bestheight; @@ -2494,11 +2496,11 @@ void console_create_window(running_machine *machine) cleanup: if (info->view[2].view) - machine->debug_view().free_view(*info->view[2].view); + machine.debug_view().free_view(*info->view[2].view); if (info->view[1].view) - machine->debug_view().free_view(*info->view[1].view); + machine.debug_view().free_view(*info->view[1].view); if (info->view[0].view) - machine->debug_view().free_view(*info->view[0].view); + machine.debug_view().free_view(*info->view[0].view); } @@ -2562,11 +2564,11 @@ static void console_process_string(debugwin_info *info, const char *string) // an empty string is a single step if (string[0] == 0) - debug_cpu_get_visible_cpu(info->machine)->debug()->single_step(); + debug_cpu_get_visible_cpu(info->machine())->debug()->single_step(); // otherwise, just process the command else - debug_console_execute_command(info->machine, string, 1); + debug_console_execute_command(info->machine(), string, 1); // clear the edit text box SendMessage(info->editwnd, WM_SETTEXT, 0, (LPARAM)&buffer); @@ -2588,7 +2590,7 @@ static void console_set_cpu(device_t *device) char curtitle[256]; astring title; - title.printf("Debug: %s - %s '%s'", device->machine->system().name, device->name(), device->tag()); + title.printf("Debug: %s - %s '%s'", device->machine().system().name, device->name(), device->tag()); win_get_window_text_utf8(main_console->wnd, curtitle, ARRAY_LENGTH(curtitle)); if (title.cmp(curtitle) != 0) win_set_window_text_utf8(main_console->wnd, title); @@ -2653,60 +2655,60 @@ static int global_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar switch (LOWORD(wparam)) { case ID_NEW_MEMORY_WND: - memory_create_window(info->machine); + memory_create_window(info->machine()); return 1; case ID_NEW_DISASM_WND: - disasm_create_window(info->machine); + disasm_create_window(info->machine()); return 1; case ID_NEW_LOG_WND: - log_create_window(info->machine); + log_create_window(info->machine()); return 1; case ID_RUN_AND_HIDE: smart_show_all(FALSE); case ID_RUN: - debug_cpu_get_visible_cpu(info->machine)->debug()->go(); + debug_cpu_get_visible_cpu(info->machine())->debug()->go(); return 1; case ID_NEXT_CPU: - debug_cpu_get_visible_cpu(info->machine)->debug()->go_next_device(); + debug_cpu_get_visible_cpu(info->machine())->debug()->go_next_device(); return 1; case ID_RUN_VBLANK: - debug_cpu_get_visible_cpu(info->machine)->debug()->go_vblank(); + debug_cpu_get_visible_cpu(info->machine())->debug()->go_vblank(); return 1; case ID_RUN_IRQ: - debug_cpu_get_visible_cpu(info->machine)->debug()->go_interrupt(); + debug_cpu_get_visible_cpu(info->machine())->debug()->go_interrupt(); return 1; case ID_STEP: - debug_cpu_get_visible_cpu(info->machine)->debug()->single_step(); + debug_cpu_get_visible_cpu(info->machine())->debug()->single_step(); return 1; case ID_STEP_OVER: - debug_cpu_get_visible_cpu(info->machine)->debug()->single_step_over(); + debug_cpu_get_visible_cpu(info->machine())->debug()->single_step_over(); return 1; case ID_STEP_OUT: - debug_cpu_get_visible_cpu(info->machine)->debug()->single_step_out(); + debug_cpu_get_visible_cpu(info->machine())->debug()->single_step_out(); return 1; case ID_HARD_RESET: - info->machine->schedule_hard_reset(); + info->machine().schedule_hard_reset(); return 1; case ID_SOFT_RESET: - info->machine->schedule_soft_reset(); - debug_cpu_get_visible_cpu(info->machine)->debug()->go(); + info->machine().schedule_soft_reset(); + debug_cpu_get_visible_cpu(info->machine())->debug()->go(); return 1; case ID_EXIT: if (info->focuswnd != NULL) SetFocus(info->focuswnd); - info->machine->schedule_exit(); + info->machine().schedule_exit(); return 1; } @@ -2722,7 +2724,7 @@ static int global_handle_command(debugwin_info *info, WPARAM wparam, LPARAM lpar static int global_handle_key(debugwin_info *info, WPARAM wparam, LPARAM lparam) { /* ignore any keys that are received while the debug key is down */ - if (!waiting_for_debugger && debugwin_seq_pressed(info->machine)) + if (!waiting_for_debugger && debugwin_seq_pressed(info->machine())) return 1; switch (wparam) diff --git a/src/osd/windows/debugwin.h b/src/osd/windows/debugwin.h index a522d56c693..e55604df7de 100644 --- a/src/osd/windows/debugwin.h +++ b/src/osd/windows/debugwin.h @@ -58,6 +58,6 @@ void debugwin_init_windows(running_machine &machine); void debugwin_destroy_windows(void); void debugwin_show(int type); -void debugwin_update_during_game(running_machine *machine); +void debugwin_update_during_game(running_machine &machine); #endif diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c index e9f4beb548c..02aa6faa72d 100644 --- a/src/osd/windows/drawd3d.c +++ b/src/osd/windows/drawd3d.c @@ -537,7 +537,7 @@ static int drawd3d_window_init(win_window_info *window) // experimental: load a PNG to use for vector rendering; it is treated // as a brightness map - emu_file file(window->machine->options().art_path(), OPEN_FLAG_READ); + emu_file file(window->machine().options().art_path(), OPEN_FLAG_READ); d3d->vector_bitmap = render_load_png(file, NULL, "vector.png", NULL, NULL); if (d3d->vector_bitmap != NULL) { @@ -807,7 +807,7 @@ try_again: if (window->fullscreen) { // only set the gamma if it's not 1.0f - windows_options &options = downcast<windows_options &>(window->machine->options()); + windows_options &options = downcast<windows_options &>(window->machine().options()); float brightness = options.full_screen_brightness(); float contrast = options.full_screen_contrast(); float gamma = options.full_screen_gamma(); @@ -1285,7 +1285,7 @@ static void pick_best_mode(win_window_info *window) int modenum; // determine the refresh rate of the primary screen - const screen_device_config *primary_screen = window->machine->config().first_screen(); + const screen_device_config *primary_screen = window->machine().config().first_screen(); if (primary_screen != NULL) target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh()); diff --git a/src/osd/windows/drawdd.c b/src/osd/windows/drawdd.c index d44f6846034..e1957094f32 100644 --- a/src/osd/windows/drawdd.c +++ b/src/osd/windows/drawdd.c @@ -457,7 +457,7 @@ static int drawdd_window_draw(win_window_info *window, HDC dc, int update) if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X unlocking blit surface\n", (int)result); // sync to VBLANK - if ((video_config.waitvsync || video_config.syncrefresh) && window->machine->video().throttled() && (!window->fullscreen || dd->back == NULL)) + if ((video_config.waitvsync || video_config.syncrefresh) && window->machine().video().throttled() && (!window->fullscreen || dd->back == NULL)) { result = IDirectDraw7_WaitForVerticalBlank(dd->ddraw, DDWAITVB_BLOCKBEGIN, NULL); if (result != DD_OK) mame_printf_verbose("DirectDraw: Error %08X waiting for VBLANK\n", (int)result); @@ -613,7 +613,7 @@ static int ddraw_create_surfaces(win_window_info *window) if (window->fullscreen) { // only set the gamma if it's not 1.0f - windows_options &options = downcast<windows_options &>(window->machine->options()); + windows_options &options = downcast<windows_options &>(window->machine().options()); float brightness = options.full_screen_brightness(); float contrast = options.full_screen_contrast(); float gamma = options.full_screen_gamma(); @@ -1328,7 +1328,7 @@ static void pick_best_mode(win_window_info *window) // determine the refresh rate of the primary screen einfo.target_refresh = 60.0; - const screen_device_config *primary_screen = window->machine->config().first_screen(); + const screen_device_config *primary_screen = window->machine().config().first_screen(); if (primary_screen != NULL) einfo.target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh()); printf("Target refresh = %f\n", einfo.target_refresh); diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c index 08dbec1baa0..35fe03f5cdb 100644 --- a/src/osd/windows/input.c +++ b/src/osd/windows/input.c @@ -163,6 +163,8 @@ struct _rawinput_device_info typedef struct _device_info device_info; struct _device_info { + running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + // device information device_info ** head; device_info * next; @@ -170,7 +172,7 @@ struct _device_info void (*poll)(device_info *info); // MAME information - running_machine * machine; + running_machine * m_machine; input_device * device; // device state @@ -253,7 +255,7 @@ static void device_list_poll_devices(device_info *devlist_head); static void device_list_reset_devices(device_info *devlist_head); // generic device management -static device_info *generic_device_alloc(running_machine *machine, device_info **devlist_head_ptr, const TCHAR *name); +static device_info *generic_device_alloc(running_machine &machine, device_info **devlist_head_ptr, const TCHAR *name); static void generic_device_free(device_info *devinfo); static int generic_device_index(device_info *devlist_head, device_info *devinfo); static void generic_device_reset(device_info *devinfo); @@ -261,16 +263,16 @@ static INT32 generic_button_get_state(void *device_internal, void *item_internal static INT32 generic_axis_get_state(void *device_internal, void *item_internal); // Win32-specific input code -static void win32_init(running_machine *machine); +static void win32_init(running_machine &machine); static void win32_exit(running_machine &machine); static void win32_keyboard_poll(device_info *devinfo); static void win32_lightgun_poll(device_info *devinfo); // DirectInput-specific code -static void dinput_init(running_machine *machine); +static void dinput_init(running_machine &machine); static void dinput_exit(running_machine &machine); static HRESULT dinput_set_dword_property(LPDIRECTINPUTDEVICE device, REFGUID property_guid, DWORD object, DWORD how, DWORD value); -static device_info *dinput_device_create(running_machine *machine, device_info **devlist_head_ptr, LPCDIDEVICEINSTANCE instance, LPCDIDATAFORMAT format1, LPCDIDATAFORMAT format2, DWORD cooperative_level); +static device_info *dinput_device_create(running_machine &machine, device_info **devlist_head_ptr, LPCDIDEVICEINSTANCE instance, LPCDIDATAFORMAT format1, LPCDIDATAFORMAT format2, DWORD cooperative_level); static void dinput_device_release(device_info *devinfo); static char *dinput_device_item_name(device_info *devinfo, int offset, const TCHAR *defstring, const TCHAR *suffix); static HRESULT dinput_device_poll(device_info *devinfo); @@ -283,14 +285,14 @@ static void dinput_joystick_poll(device_info *devinfo); static INT32 dinput_joystick_pov_get_state(void *device_internal, void *item_internal); // RawInput-specific code -static void rawinput_init(running_machine *machine); +static void rawinput_init(running_machine &machine); static void rawinput_exit(running_machine &machine); -static device_info *rawinput_device_create(running_machine *machine, device_info **devlist_head_ptr, PRAWINPUTDEVICELIST device); +static device_info *rawinput_device_create(running_machine &machine, device_info **devlist_head_ptr, PRAWINPUTDEVICELIST device); static void rawinput_device_release(device_info *info); static TCHAR *rawinput_device_improve_name(TCHAR *name); -static void rawinput_keyboard_enum(running_machine *machine, PRAWINPUTDEVICELIST device); +static void rawinput_keyboard_enum(running_machine &machine, PRAWINPUTDEVICELIST device); static void rawinput_keyboard_update(HANDLE device, RAWKEYBOARD *data); -static void rawinput_mouse_enum(running_machine *machine, PRAWINPUTDEVICELIST device); +static void rawinput_mouse_enum(running_machine &machine, PRAWINPUTDEVICELIST device); static void rawinput_mouse_update(HANDLE device, RAWMOUSE *data); static void rawinput_mouse_poll(device_info *devinfo); @@ -446,7 +448,7 @@ static const int win_key_trans_table[][4] = // INLINE FUNCTIONS //============================================================ -INLINE void poll_if_necessary(running_machine *machine) +INLINE void poll_if_necessary(running_machine &machine) { // make sure we poll at least once every 1/4 second if (GetTickCount() > last_poll + 1000 / 4) @@ -497,19 +499,19 @@ INLINE INT32 normalize_absolute_axis(INT32 raw, INT32 rawmin, INT32 rawmax) // wininput_init //============================================================ -void wininput_init(running_machine *machine) +void wininput_init(running_machine &machine) { // we need pause and exit callbacks - machine->add_notifier(MACHINE_NOTIFY_PAUSE, wininput_pause); - machine->add_notifier(MACHINE_NOTIFY_RESUME, wininput_resume); - machine->add_notifier(MACHINE_NOTIFY_EXIT, wininput_exit); + machine.add_notifier(MACHINE_NOTIFY_PAUSE, wininput_pause); + machine.add_notifier(MACHINE_NOTIFY_RESUME, wininput_resume); + machine.add_notifier(MACHINE_NOTIFY_EXIT, wininput_exit); // allocate a lock for input synchronizations, since messages sometimes come from another thread input_lock = osd_lock_alloc(); assert_always(input_lock != NULL, "Failed to allocate input_lock"); // decode the options - lightgun_shared_axis_mode = downcast<windows_options &>(machine->options()).dual_lightgun(); + lightgun_shared_axis_mode = downcast<windows_options &>(machine.options()).dual_lightgun(); // initialize RawInput and DirectInput (RawInput first so we can fall back) rawinput_init(machine); @@ -559,7 +561,7 @@ static void wininput_exit(running_machine &machine) // wininput_poll //============================================================ -void wininput_poll(running_machine *machine) +void wininput_poll(running_machine &machine) { int hasfocus = winwindow_has_focus() && input_enabled; @@ -809,7 +811,7 @@ static void device_list_reset_devices(device_info *devlist_head) // generic_device_alloc //============================================================ -static device_info *generic_device_alloc(running_machine *machine, device_info **devlist_head_ptr, const TCHAR *name) +static device_info *generic_device_alloc(running_machine &machine, device_info **devlist_head_ptr, const TCHAR *name) { device_info **curdev_ptr; device_info *devinfo; @@ -817,7 +819,7 @@ static device_info *generic_device_alloc(running_machine *machine, device_info * // allocate memory for the device object devinfo = global_alloc_clear(device_info); devinfo->head = devlist_head_ptr; - devinfo->machine = machine; + devinfo->m_machine = &machine; // allocate a UTF8 copy of the name devinfo->name = utf8_from_tstring(name); @@ -913,7 +915,7 @@ static INT32 generic_button_get_state(void *device_internal, void *item_internal BYTE *itemdata = (BYTE *)item_internal; // return the current state - poll_if_necessary(devinfo->machine); + poll_if_necessary(devinfo->machine()); return *itemdata >> 7; } @@ -928,7 +930,7 @@ static INT32 generic_axis_get_state(void *device_internal, void *item_internal) LONG *axisdata = (LONG *)item_internal; // return the current state - poll_if_necessary(devinfo->machine); + poll_if_necessary(devinfo->machine()); return *axisdata; } @@ -937,7 +939,7 @@ static INT32 generic_axis_get_state(void *device_internal, void *item_internal) // win32_init //============================================================ -static void win32_init(running_machine *machine) +static void win32_init(running_machine &machine) { int gunnum; @@ -946,7 +948,7 @@ static void win32_init(running_machine *machine) return; // we need an exit callback - machine->add_notifier(MACHINE_NOTIFY_EXIT, win32_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, win32_exit); // allocate two lightgun devices for (gunnum = 0; gunnum < 2; gunnum++) @@ -1069,7 +1071,7 @@ static void win32_lightgun_poll(device_info *devinfo) // dinput_init //============================================================ -static void dinput_init(running_machine *machine) +static void dinput_init(running_machine &machine) { HRESULT result; #if DIRECTINPUT_VERSION >= 0x800 @@ -1114,13 +1116,13 @@ static void dinput_init(running_machine *machine) mame_printf_verbose("DirectInput: Using DirectInput %d\n", dinput_version >> 8); // we need an exit callback - machine->add_notifier(MACHINE_NOTIFY_EXIT, dinput_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, dinput_exit); // initialize keyboard devices, but only if we don't have any yet if (keyboard_list == NULL) { // enumerate the ones we have - result = IDirectInput_EnumDevices(dinput, didevtype_keyboard, dinput_keyboard_enum, machine, DIEDFL_ATTACHEDONLY); + result = IDirectInput_EnumDevices(dinput, didevtype_keyboard, dinput_keyboard_enum, &machine, DIEDFL_ATTACHEDONLY); if (result != DI_OK) fatalerror("DirectInput: Unable to enumerate keyboards (result=%08X)\n", (UINT32)result); } @@ -1129,13 +1131,13 @@ static void dinput_init(running_machine *machine) if (mouse_list == NULL) { // enumerate the ones we have - result = IDirectInput_EnumDevices(dinput, didevtype_mouse, dinput_mouse_enum, machine, DIEDFL_ATTACHEDONLY); + result = IDirectInput_EnumDevices(dinput, didevtype_mouse, dinput_mouse_enum, &machine, DIEDFL_ATTACHEDONLY); if (result != DI_OK) fatalerror("DirectInput: Unable to enumerate mice (result=%08X)\n", (UINT32)result); } // initialize joystick devices - result = IDirectInput_EnumDevices(dinput, didevtype_joystick, dinput_joystick_enum, machine, DIEDFL_ATTACHEDONLY); + result = IDirectInput_EnumDevices(dinput, didevtype_joystick, dinput_joystick_enum, &machine, DIEDFL_ATTACHEDONLY); if (result != DI_OK) fatalerror("DirectInput: Unable to enumerate joysticks (result=%08X)\n", (UINT32)result); } @@ -1186,7 +1188,7 @@ static HRESULT dinput_set_dword_property(LPDIRECTINPUTDEVICE device, REFGUID pro // dinput_device_create //============================================================ -static device_info *dinput_device_create(running_machine *machine, device_info **devlist_head_ptr, LPCDIDEVICEINSTANCE instance, LPCDIDATAFORMAT format1, LPCDIDATAFORMAT format2, DWORD cooperative_level) +static device_info *dinput_device_create(running_machine &machine, device_info **devlist_head_ptr, LPCDIDEVICEINSTANCE instance, LPCDIDATAFORMAT format1, LPCDIDATAFORMAT format2, DWORD cooperative_level) { device_info *devinfo; HRESULT result; @@ -1330,7 +1332,7 @@ static HRESULT dinput_device_poll(device_info *devinfo) static BOOL CALLBACK dinput_keyboard_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref) { - running_machine *machine = (running_machine *)ref; + running_machine &machine = *(running_machine *)ref; device_info *devinfo; int keynum; @@ -1386,7 +1388,7 @@ static void dinput_keyboard_poll(device_info *devinfo) static BOOL CALLBACK dinput_mouse_enum(LPCDIDEVICEINSTANCE instance, LPVOID ref) { device_info *devinfo, *guninfo = NULL; - running_machine *machine = (running_machine *)ref; + running_machine &machine = *(running_machine *)ref; int axisnum, butnum; HRESULT result; @@ -1489,7 +1491,7 @@ static BOOL CALLBACK dinput_joystick_enum(LPCDIDEVICEINSTANCE instance, LPVOID r { DWORD cooperative_level = DISCL_FOREGROUND | DISCL_EXCLUSIVE; int axisnum, axiscount, povnum, butnum; - running_machine *machine = (running_machine *)ref; + running_machine &machine = *(running_machine *)ref; device_info *devinfo; HRESULT result; @@ -1623,7 +1625,7 @@ static INT32 dinput_joystick_pov_get_state(void *device_internal, void *item_int DWORD pov; // get the current state - poll_if_necessary(devinfo->machine); + poll_if_necessary(devinfo->machine()); pov = devinfo->joystick.state.rgdwPOV[povnum]; // if invalid, return 0 @@ -1646,7 +1648,7 @@ static INT32 dinput_joystick_pov_get_state(void *device_internal, void *item_int // rawinput_init //============================================================ -static void rawinput_init(running_machine *machine) +static void rawinput_init(running_machine &machine) { RAWINPUTDEVICELIST *devlist = NULL; int device_count, devnum, regcount; @@ -1654,7 +1656,7 @@ static void rawinput_init(running_machine *machine) HMODULE user32; // we need pause and exit callbacks - machine->add_notifier(MACHINE_NOTIFY_EXIT, rawinput_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, rawinput_exit); // look in user32 for the raw input APIs user32 = LoadLibrary(TEXT("user32.dll")); @@ -1746,7 +1748,7 @@ static void rawinput_exit(running_machine &machine) // rawinput_device_create //============================================================ -static device_info *rawinput_device_create(running_machine *machine, device_info **devlist_head_ptr, PRAWINPUTDEVICELIST device) +static device_info *rawinput_device_create(running_machine &machine, device_info **devlist_head_ptr, PRAWINPUTDEVICELIST device) { device_info *devinfo = NULL; TCHAR *tname = NULL; @@ -1950,7 +1952,7 @@ exit: // rawinput_keyboard_enum //============================================================ -static void rawinput_keyboard_enum(running_machine *machine, PRAWINPUTDEVICELIST device) +static void rawinput_keyboard_enum(running_machine &machine, PRAWINPUTDEVICELIST device) { device_info *devinfo; int keynum; @@ -2015,7 +2017,7 @@ static void rawinput_keyboard_update(HANDLE device, RAWKEYBOARD *data) // rawinput_mouse_enum //============================================================ -static void rawinput_mouse_enum(running_machine *machine, PRAWINPUTDEVICELIST device) +static void rawinput_mouse_enum(running_machine &machine, PRAWINPUTDEVICELIST device) { device_info *devinfo, *guninfo = NULL; int axisnum, butnum; @@ -2122,7 +2124,7 @@ static void rawinput_mouse_update(HANDLE device, RAWMOUSE *data) static void rawinput_mouse_poll(device_info *devinfo) { - poll_if_necessary(devinfo->machine); + poll_if_necessary(devinfo->machine()); // copy the accumulated raw state to the actual state osd_lock_acquire(input_lock); diff --git a/src/osd/windows/input.h b/src/osd/windows/input.h index 98a94768e9e..e161f4fe92a 100644 --- a/src/osd/windows/input.h +++ b/src/osd/windows/input.h @@ -47,8 +47,8 @@ // PROTOTYPES //============================================================ -void wininput_init(running_machine *machine); -void wininput_poll(running_machine *machine); +void wininput_init(running_machine &machine); +void wininput_poll(running_machine &machine); BOOL wininput_handle_mouse_button(int button, int down, int x, int y); BOOL wininput_handle_raw(HANDLE device); diff --git a/src/osd/windows/output.c b/src/osd/windows/output.c index d81643e610e..bd5278583d7 100644 --- a/src/osd/windows/output.c +++ b/src/osd/windows/output.c @@ -105,7 +105,7 @@ static int create_window_class(void); static LRESULT CALLBACK output_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam); static LRESULT register_client(HWND hwnd, LPARAM id); static LRESULT unregister_client(HWND hwnd, LPARAM id); -static LRESULT send_id_string(running_machine *machine, HWND hwnd, LPARAM id); +static LRESULT send_id_string(running_machine &machine, HWND hwnd, LPARAM id); static void notifier_callback(const char *outname, INT32 value, void *param); @@ -114,12 +114,12 @@ static void notifier_callback(const char *outname, INT32 value, void *param); // winoutput_init //============================================================ -void winoutput_init(running_machine *machine) +void winoutput_init(running_machine &machine) { int result; // ensure we get cleaned up - machine->add_notifier(MACHINE_NOTIFY_EXIT, winoutput_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, winoutput_exit); // reset globals clientlist = NULL; @@ -143,7 +143,7 @@ void winoutput_init(running_machine *machine) assert(output_hwnd != NULL); // set a pointer to the running machine - SetWindowLongPtr(output_hwnd, GWLP_USERDATA, (LONG_PTR)machine); + SetWindowLongPtr(output_hwnd, GWLP_USERDATA, (LONG_PTR)&machine); // allocate message ids om_mame_start = RegisterWindowMessage(OM_MAME_START); @@ -222,7 +222,7 @@ static int create_window_class(void) static LRESULT CALLBACK output_window_proc(HWND wnd, UINT message, WPARAM wparam, LPARAM lparam) { LONG_PTR ptr = GetWindowLongPtr(wnd, GWLP_USERDATA); - running_machine *machine = (running_machine *)ptr; + running_machine &machine = *(running_machine *)ptr; // register a new client if (message == om_mame_register_client) @@ -300,7 +300,7 @@ static LRESULT unregister_client(HWND hwnd, LPARAM id) // send_id_string //============================================================ -static LRESULT send_id_string(running_machine *machine, HWND hwnd, LPARAM id) +static LRESULT send_id_string(running_machine &machine, HWND hwnd, LPARAM id) { copydata_id_string *temp; COPYDATASTRUCT copydata; @@ -309,7 +309,7 @@ static LRESULT send_id_string(running_machine *machine, HWND hwnd, LPARAM id) // id 0 is the name of the game if (id == 0) - name = machine->system().name; + name = machine.system().name; else name = output_id_to_name(id); diff --git a/src/osd/windows/output.h b/src/osd/windows/output.h index 91e3685a34f..35da4039ac0 100644 --- a/src/osd/windows/output.h +++ b/src/osd/windows/output.h @@ -123,7 +123,7 @@ struct _copydata_id_string // FUNCTION PROTOTYPES //============================================================ -void winoutput_init(running_machine *machine); +void winoutput_init(running_machine &machine); #endif /* __WINDOWS_OUTPUT_H__ */ diff --git a/src/osd/windows/sound.c b/src/osd/windows/sound.c index 12f5f873bbc..1e7dc3e0d6d 100644 --- a/src/osd/windows/sound.c +++ b/src/osd/windows/sound.c @@ -101,7 +101,7 @@ static int buffer_overflows; //============================================================ static void sound_exit(running_machine &machine); -static HRESULT dsound_init(running_machine *machine); +static HRESULT dsound_init(running_machine &machine); static void dsound_kill(void); static HRESULT dsound_create_buffers(void); static void dsound_destroy_buffers(void); @@ -112,14 +112,14 @@ static void dsound_destroy_buffers(void); // winsound_init //============================================================ -void winsound_init(running_machine *machine) +void winsound_init(running_machine &machine) { // if no sound, don't create anything - if (!machine->options().sound()) + if (!machine.options().sound()) return; // ensure we get called on the way out - machine->add_notifier(MACHINE_NOTIFY_EXIT, sound_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, sound_exit); // attempt to initialize directsound // don't make it fatal if we can't -- we'll just run without sound @@ -267,7 +267,7 @@ void windows_osd_interface::set_mastervolume(int attenuation) // dsound_init //============================================================ -static HRESULT dsound_init(running_machine *machine) +static HRESULT dsound_init(running_machine &machine) { HRESULT result; @@ -300,12 +300,12 @@ static HRESULT dsound_init(running_machine *machine) stream_format.wBitsPerSample = 16; stream_format.wFormatTag = WAVE_FORMAT_PCM; stream_format.nChannels = 2; - stream_format.nSamplesPerSec = machine->sample_rate(); + stream_format.nSamplesPerSec = machine.sample_rate(); stream_format.nBlockAlign = stream_format.wBitsPerSample * stream_format.nChannels / 8; stream_format.nAvgBytesPerSec = stream_format.nSamplesPerSec * stream_format.nBlockAlign; // compute the buffer size based on the output sample rate - stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * downcast<windows_options &>(machine->options()).audio_latency() / 10; + stream_buffer_size = stream_format.nSamplesPerSec * stream_format.nBlockAlign * downcast<windows_options &>(machine.options()).audio_latency() / 10; stream_buffer_size = (stream_buffer_size / 1024) * 1024; if (stream_buffer_size < 1024) stream_buffer_size = 1024; diff --git a/src/osd/windows/sound.h b/src/osd/windows/sound.h index d7aaa4743cd..11625c74c65 100644 --- a/src/osd/windows/sound.h +++ b/src/osd/windows/sound.h @@ -47,6 +47,6 @@ // PROTOTYPES //============================================================ -void winsound_init(running_machine *machine); +void winsound_init(running_machine &machine); #endif diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c index 2a7f56a807f..d4fde80ed6c 100644 --- a/src/osd/windows/video.c +++ b/src/osd/windows/video.c @@ -94,9 +94,9 @@ static void init_monitors(void); static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data); static win_monitor_info *pick_monitor(windows_options &options, int index); -static void check_osd_inputs(running_machine *machine); +static void check_osd_inputs(running_machine &machine); -static void extract_video_config(running_machine *machine); +static void extract_video_config(running_machine &machine); static float get_aspect(const char *defdata, const char *data, int report_error); static void get_resolution(const char *defdata, const char *data, win_window_config *config, int report_error); @@ -106,12 +106,12 @@ static void get_resolution(const char *defdata, const char *data, win_window_con // winvideo_init //============================================================ -void winvideo_init(running_machine *machine) +void winvideo_init(running_machine &machine) { int index; // ensure we get called on the way out - machine->add_notifier(MACHINE_NOTIFY_EXIT, winvideo_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, winvideo_exit); // extract data from the options extract_video_config(machine); @@ -123,15 +123,15 @@ void winvideo_init(running_machine *machine) winwindow_init(machine); // create the windows - windows_options &options = downcast<windows_options &>(machine->options()); + windows_options &options = downcast<windows_options &>(machine.options()); for (index = 0; index < video_config.numscreens; index++) winwindow_video_window_create(machine, index, pick_monitor(options, index), &video_config.window[index]); if (video_config.mode != VIDEO_MODE_NONE) SetForegroundWindow(win_window_list->hwnd); // possibly create the debug window, but don't show it yet - if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) - debugwin_init_windows(*machine); + if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) + debugwin_init_windows(machine); } @@ -220,9 +220,9 @@ void windows_osd_interface::update(bool skip_redraw) winwindow_video_window_update(window); // poll the joystick values here - winwindow_process_events(&machine(), TRUE); - wininput_poll(&machine()); - check_osd_inputs(&machine()); + winwindow_process_events(machine(), TRUE); + wininput_poll(machine()); + check_osd_inputs(machine()); } @@ -359,7 +359,7 @@ finishit: // check_osd_inputs //============================================================ -static void check_osd_inputs(running_machine *machine) +static void check_osd_inputs(running_machine &machine) { // check for toggling fullscreen mode if (ui_input_pressed(machine, IPT_OSD_1)) @@ -372,9 +372,9 @@ static void check_osd_inputs(running_machine *machine) // extract_video_config //============================================================ -static void extract_video_config(running_machine *machine) +static void extract_video_config(running_machine &machine) { - windows_options &options = downcast<windows_options &>(machine->options()); + windows_options &options = downcast<windows_options &>(machine.options()); const char *stemp; // global options: extract the data @@ -384,7 +384,7 @@ static void extract_video_config(running_machine *machine) video_config.numscreens = options.numscreens(); // if we are in debug mode, never go full screen - if (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) + if (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) video_config.windowed = TRUE; // per-window options: extract the data diff --git a/src/osd/windows/video.h b/src/osd/windows/video.h index afb8ac65049..fb931845b1c 100644 --- a/src/osd/windows/video.h +++ b/src/osd/windows/video.h @@ -125,7 +125,7 @@ extern win_video_config video_config; // PROTOTYPES //============================================================ -void winvideo_init(running_machine *machine); +void winvideo_init(running_machine &machine); void winvideo_monitor_refresh(win_monitor_info *monitor); float winvideo_monitor_get_aspect(win_monitor_info *monitor); diff --git a/src/osd/windows/window.c b/src/osd/windows/window.c index 10130476245..0aeb039e5d7 100644 --- a/src/osd/windows/window.c +++ b/src/osd/windows/window.c @@ -219,18 +219,18 @@ static void mtlog_dump(void) { } // (main thread) //============================================================ -void winwindow_init(running_machine *machine) +void winwindow_init(running_machine &machine) { size_t temp; // determine if we are using multithreading or not - multithreading_enabled = downcast<windows_options &>(machine->options()).multithreading(); + multithreading_enabled = downcast<windows_options &>(machine.options()).multithreading(); // get the main thread ID before anything else main_threadid = GetCurrentThreadId(); // ensure we get called on the way out - machine->add_notifier(MACHINE_NOTIFY_EXIT, winwindow_exit); + machine.add_notifier(MACHINE_NOTIFY_EXIT, winwindow_exit); // set up window class and register it create_window_class(); @@ -268,18 +268,18 @@ void winwindow_init(running_machine *machine) // initialize the drawers if (video_config.mode == VIDEO_MODE_D3D) { - if (drawd3d_init(*machine, &draw)) + if (drawd3d_init(machine, &draw)) video_config.mode = VIDEO_MODE_GDI; } if (video_config.mode == VIDEO_MODE_DDRAW) { - if (drawdd_init(*machine, &draw)) + if (drawdd_init(machine, &draw)) video_config.mode = VIDEO_MODE_GDI; } if (video_config.mode == VIDEO_MODE_GDI) - drawgdi_init(*machine, &draw); + drawgdi_init(machine, &draw); if (video_config.mode == VIDEO_MODE_NONE) - drawnone_init(*machine, &draw); + drawnone_init(machine, &draw); // set up the window list last_window_ptr = &win_window_list; @@ -339,7 +339,7 @@ static void winwindow_exit(running_machine &machine) // (main thread) //============================================================ -void winwindow_process_events_periodic(running_machine *machine) +void winwindow_process_events_periodic(running_machine &machine) { DWORD currticks = GetTickCount(); @@ -375,14 +375,14 @@ static BOOL is_mame_window(HWND hwnd) // (main thread) //============================================================ -void winwindow_process_events(running_machine *machine, int ingame) +void winwindow_process_events(running_machine &machine, int ingame) { MSG message; assert(GetCurrentThreadId() == main_threadid); // if we're running, disable some parts of the debugger - if (ingame && (machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) + if (ingame && (machine.debug_flags & DEBUG_FLAG_OSD_ENABLED) != 0) debugwin_update_during_game(machine); // remember the last time we did this @@ -462,7 +462,7 @@ void winwindow_process_events(running_machine *machine, int ingame) // (main thread) //============================================================ -void winwindow_dispatch_message(running_machine *machine, MSG *message) +void winwindow_dispatch_message(running_machine &machine, MSG *message) { assert(GetCurrentThreadId() == main_threadid); @@ -471,7 +471,7 @@ void winwindow_dispatch_message(running_machine *machine, MSG *message) { // special case for quit case WM_QUIT: - machine->schedule_exit(); + machine.schedule_exit(); break; // temporary pause from the window thread @@ -511,7 +511,7 @@ void winwindow_toggle_full_screen(void) // if we are in debug mode, never go full screen for (window = win_window_list; window != NULL; window = window->next) - if (window->machine->debug_flags & DEBUG_FLAG_OSD_ENABLED) + if (window->machine().debug_flags & DEBUG_FLAG_OSD_ENABLED) return; // toggle the window mode @@ -549,7 +549,7 @@ BOOL winwindow_has_focus(void) // (main thread) //============================================================ -void winwindow_update_cursor_state(running_machine *machine) +void winwindow_update_cursor_state(running_machine &machine) { static POINT saved_cursor_pos = { -1, -1 }; @@ -561,7 +561,7 @@ void winwindow_update_cursor_state(running_machine *machine) // 2. we also hide the cursor in full screen mode and when the window doesn't have a menu // 3. we also hide the cursor in windowed mode if we're not paused and // the input system requests it - if (winwindow_has_focus() && ((!video_config.windowed && !win_has_menu(win_window_list)) || (!machine->paused() && wininput_should_hide_mouse()))) + if (winwindow_has_focus() && ((!video_config.windowed && !win_has_menu(win_window_list)) || (!machine.paused() && wininput_should_hide_mouse()))) { win_window_info *window = win_window_list; RECT bounds; @@ -602,7 +602,7 @@ void winwindow_update_cursor_state(running_machine *machine) // (main thread) //============================================================ -void winwindow_video_window_create(running_machine *machine, int index, win_monitor_info *monitor, const win_window_config *config) +void winwindow_video_window_create(running_machine &machine, int index, win_monitor_info *monitor, const win_window_config *config) { win_window_info *window, *win; @@ -615,7 +615,7 @@ void winwindow_video_window_create(running_machine *machine, int index, win_moni window->refresh = config->refresh; window->monitor = monitor; window->fullscreen = !video_config.windowed; - window->machine = machine; + window->m_machine = &machine; // see if we are safe for fullscreen window->fullscreen_safe = TRUE; @@ -631,10 +631,10 @@ void winwindow_video_window_create(running_machine *machine, int index, win_moni window->render_lock = osd_lock_alloc(); // load the layout - window->target = machine->render().target_alloc(); + window->target = machine.render().target_alloc(); // set the specific view - windows_options &options = downcast<windows_options &>(machine->options()); + windows_options &options = downcast<windows_options &>(machine.options()); set_starting_view(index, window, options.view(index)); // remember the current values in case they change @@ -644,9 +644,9 @@ void winwindow_video_window_create(running_machine *machine, int index, win_moni // make the window title if (video_config.numscreens == 1) - sprintf(window->title, APPNAME ": %s [%s]", machine->system().description, machine->system().name); + sprintf(window->title, APPNAME ": %s [%s]", machine.system().description, machine.system().name); else - sprintf(window->title, APPNAME ": %s [%s] - Screen %d", machine->system().description, machine->system().name, index); + sprintf(window->title, APPNAME ": %s [%s] - Screen %d", machine.system().description, machine.system().name, index); // set the initial maximized state window->startmaximized = options.maximize(); @@ -695,7 +695,7 @@ static void winwindow_video_window_destroy(win_window_info *window) SendMessage(window->hwnd, WM_USER_SELF_TERMINATE, 0, 0); // free the render target - window->machine->render().target_free(window->target); + window->machine().render().target_free(window->target); // free the lock osd_lock_free(window->render_lock); @@ -748,7 +748,7 @@ void winwindow_video_window_update(win_window_info *window) mtlog_add("winwindow_video_window_update: try lock"); // only block if we're throttled - if (window->machine->video().throttled() || timeGetTime() - last_update_time > 250) + if (window->machine().video().throttled() || timeGetTime() - last_update_time > 250) osd_lock_acquire(window->render_lock); else got_lock = osd_lock_try(window->render_lock); @@ -849,7 +849,7 @@ static void create_window_class(void) static void set_starting_view(int index, win_window_info *window, const char *view) { - const char *defview = downcast<windows_options &>(window->machine->options()).view(); + const char *defview = downcast<windows_options &>(window->machine().options()).view(); int viewindex; assert(GetCurrentThreadId() == main_threadid); @@ -872,7 +872,7 @@ static void set_starting_view(int index, win_window_info *window, const char *vi // (main thread) //============================================================ -void winwindow_ui_pause_from_main_thread(running_machine *machine, int pause) +void winwindow_ui_pause_from_main_thread(running_machine &machine, int pause) { int old_temp_pause = ui_temp_pause; @@ -885,9 +885,9 @@ void winwindow_ui_pause_from_main_thread(running_machine *machine, int pause) if (ui_temp_pause++ == 0) { // only call mame_pause if we weren't already paused due to some external reason - ui_temp_was_paused = machine->paused(); + ui_temp_was_paused = machine.paused(); if (!ui_temp_was_paused) - machine->pause(); + machine.pause(); SetEvent(ui_pause_event); } @@ -901,7 +901,7 @@ void winwindow_ui_pause_from_main_thread(running_machine *machine, int pause) { // but only do it if we were the ones who initiated it if (!ui_temp_was_paused) - machine->resume(); + machine.resume(); ResetEvent(ui_pause_event); } @@ -918,7 +918,7 @@ void winwindow_ui_pause_from_main_thread(running_machine *machine, int pause) // (window thread) //============================================================ -void winwindow_ui_pause_from_window_thread(running_machine *machine, int pause) +void winwindow_ui_pause_from_window_thread(running_machine &machine, int pause) { assert(GetCurrentThreadId() == window_threadid); @@ -967,9 +967,9 @@ void winwindow_ui_exec_on_main_thread(void (*func)(void *), void *param) // winwindow_ui_is_paused //============================================================ -int winwindow_ui_is_paused(running_machine *machine) +int winwindow_ui_is_paused(running_machine &machine) { - return machine->paused() && ui_temp_was_paused; + return machine.paused() && ui_temp_was_paused; } @@ -1120,9 +1120,9 @@ static int complete_create(win_window_info *window) monitorbounds = window->monitor->info.rcMonitor; // create the window menu if needed - if (downcast<windows_options &>(window->machine->options()).menu()) + if (downcast<windows_options &>(window->machine().options()).menu()) { - if (win_create_menu(window->machine, &menu)) + if (win_create_menu(window->machine(), &menu)) return 1; } @@ -1232,17 +1232,17 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar // input events case WM_MOUSEMOVE: - ui_input_push_mouse_move_event(window->machine, window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + ui_input_push_mouse_move_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); break; case WM_MOUSELEAVE: - ui_input_push_mouse_leave_event(window->machine, window->target); + ui_input_push_mouse_leave_event(window->machine(), window->target); break; case WM_LBUTTONDOWN: { DWORD ticks = GetTickCount(); - ui_input_push_mouse_down_event(window->machine, window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + ui_input_push_mouse_down_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); // check for a double-click if (ticks - window->lastclicktime < GetDoubleClickTime() && @@ -1250,7 +1250,7 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar GET_Y_LPARAM(lparam) >= window->lastclicky - 4 && GET_Y_LPARAM(lparam) <= window->lastclicky + 4) { window->lastclicktime = 0; - ui_input_push_mouse_double_click_event(window->machine, window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + ui_input_push_mouse_double_click_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); } else { @@ -1262,25 +1262,25 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar } case WM_LBUTTONUP: - ui_input_push_mouse_up_event(window->machine, window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); + ui_input_push_mouse_up_event(window->machine(), window->target, GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); break; case WM_CHAR: - ui_input_push_char_event(window->machine, window->target, (unicode_char) wparam); + ui_input_push_char_event(window->machine(), window->target, (unicode_char) wparam); break; // pause the system when we start a menu or resize case WM_ENTERSIZEMOVE: window->resize_state = RESIZE_STATE_RESIZING; case WM_ENTERMENULOOP: - winwindow_ui_pause_from_window_thread(window->machine, TRUE); + winwindow_ui_pause_from_window_thread(window->machine(), TRUE); break; // unpause the system when we stop a menu or resize and force a redraw case WM_EXITSIZEMOVE: window->resize_state = RESIZE_STATE_PENDING; case WM_EXITMENULOOP: - winwindow_ui_pause_from_window_thread(window->machine, FALSE); + winwindow_ui_pause_from_window_thread(window->machine(), FALSE); InvalidateRect(wnd, NULL, FALSE); break; @@ -1336,7 +1336,7 @@ LRESULT CALLBACK winwindow_video_window_proc(HWND wnd, UINT message, WPARAM wpar if (multithreading_enabled) PostThreadMessage(main_threadid, WM_QUIT, 0, 0); else - window->machine->schedule_exit(); + window->machine().schedule_exit(); break; // destroy: clean up all attached rendering bits and NULL out our hwnd diff --git a/src/osd/windows/window.h b/src/osd/windows/window.h index 1db97dd1e80..689708ba960 100644 --- a/src/osd/windows/window.h +++ b/src/osd/windows/window.h @@ -68,6 +68,8 @@ typedef struct _win_window_info win_window_info; struct _win_window_info { + running_machine &machine() const { assert(m_machine != NULL); return *m_machine; } + win_window_info * next; volatile int init_state; @@ -104,7 +106,7 @@ struct _win_window_info // drawing data void * drawdata; - running_machine * machine; + running_machine * m_machine; }; @@ -135,13 +137,13 @@ extern win_window_info *win_window_list; //============================================================ // core initialization -void winwindow_init(running_machine *machine); +void winwindow_init(running_machine &machine); // creation/deletion of windows -void winwindow_video_window_create(running_machine *machine, int index, win_monitor_info *monitor, const win_window_config *config); +void winwindow_video_window_create(running_machine &machine, int index, win_monitor_info *monitor, const win_window_config *config); BOOL winwindow_has_focus(void); -void winwindow_update_cursor_state(running_machine *machine); +void winwindow_update_cursor_state(running_machine &machine); void winwindow_video_window_update(win_window_info *window); win_monitor_info *winwindow_video_window_monitor(win_window_info *window, const RECT *proposed); @@ -150,17 +152,17 @@ extern LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, W void winwindow_toggle_full_screen(void); -void winwindow_process_events_periodic(running_machine *machine); -void winwindow_process_events(running_machine *machine, int ingame); +void winwindow_process_events_periodic(running_machine &machine); +void winwindow_process_events(running_machine &machine, int ingame); -void winwindow_ui_pause_from_window_thread(running_machine *machine, int pause); -void winwindow_ui_pause_from_main_thread(running_machine *machine, int pause); -int winwindow_ui_is_paused(running_machine *machine); +void winwindow_ui_pause_from_window_thread(running_machine &machine, int pause); +void winwindow_ui_pause_from_main_thread(running_machine &machine, int pause); +int winwindow_ui_is_paused(running_machine &machine); void winwindow_ui_exec_on_main_thread(void (*func)(void *), void *param); -void winwindow_dispatch_message(running_machine *machine, MSG *message); +void winwindow_dispatch_message(running_machine &machine, MSG *message); -extern int win_create_menu(running_machine *machine, HMENU *menus); +extern int win_create_menu(running_machine &machine, HMENU *menus); diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c index 8ecd7e71852..8afb524c6c6 100644 --- a/src/osd/windows/winmain.c +++ b/src/osd/windows/winmain.c @@ -574,10 +574,10 @@ void windows_osd_interface::init(running_machine &machine) } // initialize the subsystems - winvideo_init(&machine); - winsound_init(&machine); - wininput_init(&machine); - winoutput_init(&machine); + winvideo_init(machine); + winsound_init(machine); + wininput_init(machine); + winoutput_init(machine); // notify listeners of screen configuration astring tempstring; @@ -664,7 +664,7 @@ void windows_osd_interface::osd_exit(running_machine &machine) timeEndPeriod(caps.wPeriodMin); // one last pass at events - winwindow_process_events(&machine, 0); + winwindow_process_events(machine, 0); } @@ -860,7 +860,7 @@ bitmap_t *windows_osd_interface::font_get_bitmap(osd_font font, unicode_char chn bitmap_t *bitmap = NULL; if (actbounds.max_x >= actbounds.min_x && actbounds.max_y >= actbounds.min_y) { - bitmap = auto_alloc(&machine(), bitmap_t(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y, BITMAP_FORMAT_ARGB32)); + bitmap = auto_alloc(machine(), bitmap_t(actbounds.max_x + 1 - actbounds.min_x, actbounds.max_y + 1 - actbounds.min_y, BITMAP_FORMAT_ARGB32)); // copy the bits into it for (int y = 0; y < bitmap->height; y++) diff --git a/src/osd/windows/winmenu.c b/src/osd/windows/winmenu.c index 1b13a13e644..9e6b58f509b 100644 --- a/src/osd/windows/winmenu.c +++ b/src/osd/windows/winmenu.c @@ -61,7 +61,7 @@ LRESULT CALLBACK winwindow_video_window_proc_ui(HWND wnd, UINT message, WPARAM w // win_create_menu //============================================================ -int win_create_menu(running_machine *machine, HMENU *menus) +int win_create_menu(running_machine &machine, HMENU *menus) { return 0; } |