summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2010-06-08 06:09:57 +0000
committer Aaron Giles <aaron@aarongiles.com>2010-06-08 06:09:57 +0000
commit100564d41225bfd2fa163c0174557ed979285b4e (patch)
tree0be83fbde1ddb95633293c9faee60d0f2bc6ace1 /src/osd
parent962dca9f57d61cdea65ee32c6362bf3d0d1e2dae (diff)
WARNING: There are likely to be regressions in both functionality and
performance as a result of this change. Do not panic; report issues to the list in the short term and I will look into them. There are probably also some details I forgot to mention. Please ask questions if anything is not clear. NOTE: This is a major internal change to the way devices are handled in MAME. There is a small impact on drivers, but the bulk of the changes are to the devices themselves. Full documentation on the new device handling is in progress at http://mamedev.org/devwiki/index.php/MAME_Device_Basics Defined two new casting helpers: [Aaron Giles] downcast<type>(value) should be used for safe and efficient downcasting from a base class to a derived class. It wraps static_cast<> by adding an assert that a matching dynamic_cast<> returns the same result in debug builds. crosscast<type>(value) should be used for safe casting from one type to another in multiple inheritance scenarios. It compiles to a dynamic_cast<> plus an assert on the result. Since it does not optimize down to static_cast<>, you should prefer downcast<> over crosscast<> when you can. Redefined running_device to be a proper C++ class (now called device_t). Same for device_config (still called device_config). All devices and device_configs must now be derived from these base classes. This means each device type now has a pair of its own unique classes that describe the device. Drivers are encouraged to use the specific device types instead of the generic running_device or device_t classes. Drivers that have a state class defined in their header file are encouraged to use initializers off the constructor to locate devices. [Aaron Giles] Removed the following fields from the device and device configuration classes as they never were necessary or provided any use: device class, device family, source file, version, credits. [Aaron Giles] Added templatized variant of machine->device() which performs a downcast as part of the device fetch. Thus machine->device<timer_device>("timer") will locate a device named "timer", downcast it to a timer_device, and assert if the downcast fails. [Aaron Giles] Removed most publically accessible members of running_device/device_t in favor of inline accessor functions. The only remaining public member is machine. Thus all references to device->type are now device->type(), etc. [Aaron Giles] Created a number of device interface classes which are designed to be mix- ins for the device classes, providing specific extended functionality and information. There are standard interface classes for sound, execution, state, nvram, memory, and disassembly. Devices can opt into 0 or more of these classes. [Aaron Giles] Converted the classic CPU device to a standard device that uses the execution, state, memory, and disassembly interfaces. Used this new class (cpu_device) to implement the existing CPU device interface. In the future it will be possible to convert each CPU core to its own device type, but for now they are still all CPU devices with a cpu_type() that specifies exactly which kind of CPU. [Aaron Giles] Created a new header devlegcy.h which wraps the old device interface using some special template classes. To use these with an existing device, simply remove from the device header the DEVICE_GET_INFO() declaration and the #define mapping the ALL_CAPS name to the DEVICE_GET_INFO. In their place #include "devlegcy.h" and use the DECLARE_LEGACY_DEVICE() macro. In addition, there is a DECLARE_LEGACY_SOUND_DEVICE() macro for wrapping existing sound devices into new-style devices, and a DECLARE_LEGACY_NVRAM_DEVICE() for wrapping NVRAM devices. Also moved the token and inline_config members to the legacy device class, as these are not used in modern devices. [Aaron Giles] Converted the standard base devices (VIDEO_SCREEN, SPEAKER, and TIMER) from legacy devices to the new C++ style. Also renamed VIDEO_SCREEN to simply SCREEN. The various global functions that were previously used to access information or modify the state of these devices are now replaced by methods on the device classes. Specifically: video_screen_configure() == screen->configure() video_screen_set_visarea() == screen->set_visible_area() video_screen_update_partial() == screen->update_partial() video_screen_update_now() == screen->update_now() video_screen_get_vpos() == screen->vpos() video_screen_get_hpos() == screen->hpos() video_screen_get_vblank() == screen->vblank() video_screen_get_hblank() == screen->hblank() video_screen_get_width() == screen->width() video_screen_get_height() == screen->height() video_screen_get_visible_area() == screen->visible_area() video_screen_get_time_until_pos() == screen->time_until_pos() video_screen_get_time_until_vblank_start() == screen->time_until_vblank_start() video_screen_get_time_until_vblank_end() == screen->time_until_vblank_end() video_screen_get_time_until_update() == screen->time_until_update() video_screen_get_scan_period() == screen->scan_period() video_screen_get_frame_period() == screen->frame_period() video_screen_get_frame_number() == screen->frame_number() timer_device_adjust_oneshot() == timer->adjust() timer_device_adjust_periodic() == timer->adjust() timer_device_reset() == timer->reset() timer_device_enable() == timer->enable() timer_device_enabled() == timer->enabled() timer_device_get_param() == timer->param() timer_device_set_param() == timer->set_param() timer_device_get_ptr() == timer->get_ptr() timer_device_set_ptr() == timer->set_ptr() timer_device_timeelapsed() == timer->time_elapsed() timer_device_timeleft() == timer->time_left() timer_device_starttime() == timer->start_time() timer_device_firetime() == timer->fire_time() Updated all drivers that use the above functions to fetch the specific device type (timer_device or screen_device) and call the appropriate method. [Aaron Giles] Changed machine->primary_screen and the 'screen' parameter to VIDEO_UPDATE to specifically pass in a screen_device object. [Aaron Giles] Defined a new custom interface for the Z80 daisy chain. This interface behaves like the standard interfaces, and can be added to any device that implements the Z80 daisy chain behavior. Converted all existing Z80 daisy chain devices to new-style devices that inherit this interface. [Aaron Giles] Changed the way CPU state tables are built up. Previously, these were data structures defined by a CPU core which described all the registers and how to output them. This functionality is now part of the state interface and is implemented via the device_state_entry class. Updated all CPU cores which were using the old data structure to use the new form. The syntax is currently awkward, but will be cleaner for CPUs that are native new devices. [Aaron Giles] Converted the okim6295 and eeprom devices to the new model. These were necessary because they both require multiple interfaces to operate and it didn't make sense to create legacy device templates for these single cases. (okim6295 needs the sound interface and the memory interface, while eeprom requires both the nvram and memory interfaces). [Aaron Giles] Changed parameters in a few callback functions from pointers to references in situations where they are guaranteed to never be NULL. [Aaron Giles] Removed MDRV_CPU_FLAGS() which was only used for disabling a CPU. Changed it to MDRV_DEVICE_DISABLE() instead. Updated drivers. [Aaron Giles] Reorganized the token parsing for machine configurations. The core parsing code knows how to create/replace/remove devices, but all device token parsing is now handled in the device_config class, which in turn will make use of any interface classes or device-specific token handling for custom token processing. [Aaron Giles] Moved many validity checks out of validity.c and into the device interface classes. For example, address space validation is now part of the memory interface class. [Aaron Giles] Consolidated address space parameters (bus width, endianness, etc.) into a single address_space_config class. Updated all code that queried for address space parameters to use the new mechanism. [Aaron Giles]
Diffstat (limited to 'src/osd')
-rw-r--r--src/osd/osdepend.h4
-rw-r--r--src/osd/sdl/debugwin.c2
-rw-r--r--src/osd/sdl/drawogl.c8
-rw-r--r--src/osd/sdl/video.c3
-rw-r--r--src/osd/windows/d3d8intf.c1
-rw-r--r--src/osd/windows/d3d9intf.c1
-rw-r--r--src/osd/windows/debugwin.c5
-rw-r--r--src/osd/windows/drawd3d.c8
-rw-r--r--src/osd/windows/drawdd.c8
-rw-r--r--src/osd/windows/input.c1
-rw-r--r--src/osd/windows/sound.c1
-rw-r--r--src/osd/windows/video.c3
-rw-r--r--src/osd/windows/windows.mak4
-rw-r--r--src/osd/windows/winmain.c9
14 files changed, 29 insertions, 29 deletions
diff --git a/src/osd/osdepend.h b/src/osd/osdepend.h
index a45152ff916..ae08f732c3c 100644
--- a/src/osd/osdepend.h
+++ b/src/osd/osdepend.h
@@ -71,7 +71,7 @@
class input_type_desc;
-class running_device;
+class device_t;
/*-----------------------------------------------------------------------------
@@ -126,7 +126,7 @@ class running_device;
-----------------------------------------------------------------------------*/
void osd_init(running_machine *machine);
-void osd_wait_for_debugger(running_device *device, int firststop);
+void osd_wait_for_debugger(device_t *device, int firststop);
diff --git a/src/osd/sdl/debugwin.c b/src/osd/sdl/debugwin.c
index 4608d95ebd3..ebdcc416b1c 100644
--- a/src/osd/sdl/debugwin.c
+++ b/src/osd/sdl/debugwin.c
@@ -440,7 +440,7 @@ static void debugmain_set_cpu(running_device *cpu)
dv = get_view(dmain, DVT_REGISTERS);
for (regsubitem = registers_view_get_subview_list(dv->view); regsubitem != NULL; regsubitem = regsubitem->next)
- if (regsubitem->device == cpu)
+ if (regsubitem->cpudevice == cpu)
{
registers_view_set_subview(dv->view, regsubitem->index);
break;
diff --git a/src/osd/sdl/drawogl.c b/src/osd/sdl/drawogl.c
index a652cba2c66..aee6a1f7826 100644
--- a/src/osd/sdl/drawogl.c
+++ b/src/osd/sdl/drawogl.c
@@ -1208,12 +1208,11 @@ 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 = video_screen_first(window->machine->config); screen != NULL; screen = video_screen_next(screen))
+ for (screen = screen_first(*window->machine->config); screen != NULL; screen = screen_next(screen))
{
if (scrnum == window->index)
{
- scrconfig = (const screen_config *) screen->inline_config;
- is_vector = (scrconfig->type == SCREEN_TYPE_VECTOR) ? 1 : 0;
+ is_vector = (screen->screen_type() == SCREEN_TYPE_VECTOR) ? 1 : 0;
break;
}
else
@@ -2938,13 +2937,12 @@ static void texture_shader_update(sdl_window_info *window, texture_info *texture
int uniform_location, scrnum;
render_container *container;
GLfloat vid_attributes[4]; // gamma, contrast, brightness, effect
- const device_config *screen;
assert ( sdl->glsl_vid_attributes && texture->format!=SDL_TEXFORMAT_PALETTE16 );
scrnum = 0;
container = (render_container *)NULL;
- for (screen = video_screen_first(window->machine->config); screen != NULL; screen = video_screen_next(screen))
+ for (screen_device *screen = screen_first(*window->machine); screen != NULL; screen = screen_next(screen))
{
if (scrnum == window->start_viewscreen)
{
diff --git a/src/osd/sdl/video.c b/src/osd/sdl/video.c
index a45babe2f7e..641dc460203 100644
--- a/src/osd/sdl/video.c
+++ b/src/osd/sdl/video.c
@@ -818,7 +818,6 @@ static void extract_video_config(running_machine *machine)
static void load_effect_overlay(running_machine *machine, const char *filename)
{
- const device_config *screen;
char *tempstr = global_alloc_array(char, strlen(filename) + 5);
char *dest;
@@ -839,7 +838,7 @@ static void load_effect_overlay(running_machine *machine, const char *filename)
}
// set the overlay on all screens
- for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen))
+ for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen))
render_container_set_overlay(render_container_get_screen(screen), effect_bitmap);
global_free(tempstr);
diff --git a/src/osd/windows/d3d8intf.c b/src/osd/windows/d3d8intf.c
index d91bb7c0864..af07c5f4d23 100644
--- a/src/osd/windows/d3d8intf.c
+++ b/src/osd/windows/d3d8intf.c
@@ -43,6 +43,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d8.h>
+#undef interface
// MAME headers
#include "emu.h"
diff --git a/src/osd/windows/d3d9intf.c b/src/osd/windows/d3d9intf.c
index 6d22435e21d..26f039ab200 100644
--- a/src/osd/windows/d3d9intf.c
+++ b/src/osd/windows/d3d9intf.c
@@ -43,6 +43,7 @@
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <d3d9.h>
+#undef interface
// MAME headers
#include "emu.h"
diff --git a/src/osd/windows/debugwin.c b/src/osd/windows/debugwin.c
index 3c1be5e8781..9447b9b87ee 100644
--- a/src/osd/windows/debugwin.c
+++ b/src/osd/windows/debugwin.c
@@ -2577,12 +2577,15 @@ static void console_set_cpu(running_device *device)
break;
}
if (main_console->view[1].view != NULL)
+ {
+ device_state_interface *stateintf = device_state(device);
for (regsubitem = registers_view_get_subview_list(main_console->view[1].view); regsubitem != NULL; regsubitem = regsubitem->next)
- if (regsubitem->device == device)
+ if (regsubitem->stateintf == stateintf)
{
registers_view_set_subview(main_console->view[1].view, regsubitem->index);
break;
}
+ }
// then update the caption
if (regsubitem != NULL)
diff --git a/src/osd/windows/drawd3d.c b/src/osd/windows/drawd3d.c
index 5d48cf9d3e0..b78bdb4c9ab 100644
--- a/src/osd/windows/drawd3d.c
+++ b/src/osd/windows/drawd3d.c
@@ -53,6 +53,7 @@
#include <tchar.h>
#include <mmsystem.h>
#include <d3d9.h>
+#undef interface
// MAME headers
#include "emu.h"
@@ -1271,7 +1272,6 @@ static int get_adapter_for_monitor(d3d_info *d3d, win_monitor_info *monitor)
static void pick_best_mode(win_window_info *window)
{
- const device_config *primary_screen = video_screen_first(window->machine->config);
double target_refresh = 60.0;
INT32 target_width, target_height;
d3d_info *d3d = (d3d_info *)window->drawdata;
@@ -1281,11 +1281,9 @@ 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 = screen_first(*window->machine->config);
if (primary_screen != NULL)
- {
- const screen_config *config = (const screen_config *)primary_screen->inline_config;
- target_refresh = ATTOSECONDS_TO_HZ(config->refresh);
- }
+ target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh());
// determine the minimum width/height for the selected target
// note: technically we should not be calling this from an alternate window
diff --git a/src/osd/windows/drawdd.c b/src/osd/windows/drawdd.c
index afb7e7728f2..7320471c27b 100644
--- a/src/osd/windows/drawdd.c
+++ b/src/osd/windows/drawdd.c
@@ -44,6 +44,7 @@
#include <windows.h>
#include <mmsystem.h>
#include <ddraw.h>
+#undef interface
// MAME headers
#include "emu.h"
@@ -1316,7 +1317,6 @@ static HRESULT WINAPI enum_modes_callback(LPDDSURFACEDESC2 desc, LPVOID context)
static void pick_best_mode(win_window_info *window)
{
- const device_config *primary_screen = video_screen_first(window->machine->config);
dd_info *dd = (dd_info *)window->drawdata;
mode_enum_info einfo;
HRESULT result;
@@ -1333,11 +1333,9 @@ 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 = screen_first(*window->machine->config);
if (primary_screen != NULL)
- {
- const screen_config *config = (const screen_config *)primary_screen->inline_config;
- einfo.target_refresh = ATTOSECONDS_TO_HZ(config->refresh);
- }
+ einfo.target_refresh = ATTOSECONDS_TO_HZ(primary_screen->refresh());
printf("Target refresh = %f\n", einfo.target_refresh);
// if we're not stretching, allow some slop on the minimum since we can handle it
diff --git a/src/osd/windows/input.c b/src/osd/windows/input.c
index 47a4e229b90..5448395ac8b 100644
--- a/src/osd/windows/input.c
+++ b/src/osd/windows/input.c
@@ -51,6 +51,7 @@
// undef WINNT for dinput.h to prevent duplicate definition
#undef WINNT
#include <dinput.h>
+#undef interface
// standard C headers
#include <conio.h>
diff --git a/src/osd/windows/sound.c b/src/osd/windows/sound.c
index 87a72fbd2d0..2116f1ddc0e 100644
--- a/src/osd/windows/sound.c
+++ b/src/osd/windows/sound.c
@@ -47,6 +47,7 @@
// undef WINNT for dsound.h to prevent duplicate definition
#undef WINNT
#include <dsound.h>
+#undef interface
// MAME headers
#include "emu.h"
diff --git a/src/osd/windows/video.c b/src/osd/windows/video.c
index 6d034add22f..49c6780c73e 100644
--- a/src/osd/windows/video.c
+++ b/src/osd/windows/video.c
@@ -470,7 +470,6 @@ static void extract_video_config(running_machine *machine)
static void load_effect_overlay(running_machine *machine, const char *filename)
{
- const device_config *screen;
char *tempstr = global_alloc_array(char, strlen(filename) + 5);
char *dest;
@@ -491,7 +490,7 @@ static void load_effect_overlay(running_machine *machine, const char *filename)
}
// set the overlay on all screens
- for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen))
+ for (screen_device *screen = screen_first(*machine); screen != NULL; screen = screen_next(screen))
render_container_set_overlay(render_container_get_screen(screen), effect_bitmap);
global_free(tempstr);
diff --git a/src/osd/windows/windows.mak b/src/osd/windows/windows.mak
index 568527163c4..8d342b73834 100644
--- a/src/osd/windows/windows.mak
+++ b/src/osd/windows/windows.mak
@@ -147,8 +147,8 @@ CPPONLYFLAGS += /EHsc
# disable function pointer warnings in C++ which are evil to work around
CPPONLYFLAGS += /wd4191 /wd4060 /wd4065 /wd4640
-# disable warning about exception specifications
-CPPONLYFLAGS += /wd4290
+# disable warning about exception specifications and using this in constructors
+CPPONLYFLAGS += /wd4290 /wd4355
# explicitly set the entry point for UNICODE builds
LDFLAGS += /ENTRY:wmainCRTStartup
diff --git a/src/osd/windows/winmain.c b/src/osd/windows/winmain.c
index 68ff2b04838..a92b8b6a132 100644
--- a/src/osd/windows/winmain.c
+++ b/src/osd/windows/winmain.c
@@ -712,10 +712,11 @@ static const char *line_to_symbol(const char *line, FPTR &address)
// find a matching start
if (strncmp(line, " 0x", 18) == 0)
if (sscanf(line, " 0x%p %s", &temp, symbol) == 2)
- {
- address = reinterpret_cast<FPTR>(temp);
- return strstr(line, symbol);
- }
+ if (symbol[0] != '0' && symbol[1] != 'x')
+ {
+ address = reinterpret_cast<FPTR>(temp);
+ return strstr(line, symbol);
+ }
#endif
#ifdef _MSC_VER