summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/mame.h
diff options
context:
space:
mode:
author Aaron Giles <aaron@aarongiles.com>2010-01-10 00:29:26 +0000
committer Aaron Giles <aaron@aarongiles.com>2010-01-10 00:29:26 +0000
commit4498faacd93cbb7f204d1b47e5d12bd417cf43b3 (patch)
treeeebf7c70b83ce57ba2707407872a01fe3ef7bb3c /src/emu/mame.h
parent43d93150b5bc214537d5198cd9e7f01f2020eff8 (diff)
First round of an attempted cleanup of header files in the system.
- Created new central header "emu.h"; this should be included by pretty much any driver or device as the first include. This file in turn includes pretty much everything a driver or device will need, minus any other devices it references. Note that emu.h should *never* be included by another header file. - Updated all files in the core (src/emu) to use emu.h. - Removed a ton of redundant and poorly-tracked header includes from within other header files. - Temporarily changed driver.h to map to emu.h until we update files outside of the core. Added class wrapper around tagmap so it can be directly included and accessed within objects that need it. Updated all users to embed tagmap objects and changed them to call through the class. Added nicer functions for finding devices, ports, and regions in a machine: machine->device("tag") -- return the named device, or NULL machine->port("tag") -- return the named port, or NULL machine->region("tag"[, &length[, &flags]]) -- return the named region and optionally its length and flags Made the device tag an astring. This required touching a lot of code that printed the device to explicitly fetch the C-string from it. (Thank you gcc for flagging that issue!)
Diffstat (limited to 'src/emu/mame.h')
-rw-r--r--src/emu/mame.h80
1 files changed, 46 insertions, 34 deletions
diff --git a/src/emu/mame.h b/src/emu/mame.h
index d1a3bfe2299..1a3a1e3e32f 100644
--- a/src/emu/mame.h
+++ b/src/emu/mame.h
@@ -9,21 +9,14 @@
***************************************************************************/
-#ifndef __MAME_H__
-#define __MAME_H__
+#pragma once
-#include "emucore.h"
-#include "video.h"
-#include "crsshair.h"
-#include "options.h"
-#include "inptport.h"
-#include "cpuintrf.h"
-#include <stdarg.h>
+#ifndef __EMU_H__
+#error Dont include this file directly; include emu.h instead.
+#endif
-#ifdef MESS
-#include "image.h"
-#include "uimess.h"
-#endif /* MESS */
+#ifndef __MAME_H__
+#define __MAME_H__
@@ -31,6 +24,8 @@
CONSTANTS
***************************************************************************/
+const int MAX_GFX_ELEMENTS = 32;
+
/* return values from run_game */
enum
{
@@ -69,10 +64,6 @@ enum
#define DEBUG_FLAG_WPW_IO 0x00000400 /* watchpoints are enabled for IO memory writes */
-/* maxima */
-#define MAX_GFX_ELEMENTS 32
-
-
/* MESS vs. MAME abstractions */
#ifndef MESS
#define APPNAME "MAME"
@@ -134,11 +125,10 @@ typedef enum _output_channel output_channel;
TYPE DEFINITIONS
***************************************************************************/
-/* output channel callback */
-typedef void (*output_callback_func)(void *param, const char *format, va_list argptr);
-
+// forward declarations
+class gfx_element;
+class colortable_t;
-/* forward type declarations */
typedef struct _mame_private mame_private;
typedef struct _cpuexec_private cpuexec_private;
typedef struct _timer_private timer_private;
@@ -161,18 +151,13 @@ typedef struct _generic_video_private generic_video_private;
typedef struct _generic_audio_private generic_audio_private;
-/* structure to hold a pointer/size pair for generic pointers */
-typedef union _generic_ptr generic_ptr;
-union _generic_ptr
-{
- void * v;
- UINT8 * u8;
- UINT16 * u16;
- UINT32 * u32;
- UINT64 * u64;
-};
+/* output channel callback */
+typedef void (*output_callback_func)(void *param, const char *format, va_list argptr);
+/* return a pointer to a specified memory region */
+UINT8 *memory_region(running_machine *machine, const char *name, UINT32 *length = NULL, UINT32 *flags = NULL);
+
/* this structure holds generic pointers that are commonly used */
typedef struct _generic_pointers generic_pointers;
struct _generic_pointers
@@ -202,6 +187,10 @@ public:
running_machine(const game_driver *driver);
~running_machine();
+ inline const device_config *device(const char *tag);
+ inline const input_port_config *port(const char *tag);
+ template<class T> T *region(const char *tag, UINT32 *length = NULL, UINT32 *flags = NULL);
+
resource_pool respool; /* pool of resources for this machine */
/* configuration data */
@@ -222,7 +211,7 @@ public:
/* palette-related information */
const pen_t * pens; /* remapped palette pen numbers */
- struct _colortable_t * colortable; /* global colortable for remapping */
+ colortable_t * colortable; /* global colortable for remapping */
pen_t * shadow_table; /* table for looking up a shadowed pen */
bitmap_t * priority_bitmap; /* priority bitmap */
@@ -266,6 +255,8 @@ public:
};
+
+
typedef struct _mame_system_tm mame_system_tm;
struct _mame_system_tm
{
@@ -296,7 +287,6 @@ struct _mame_system_time
***************************************************************************/
extern const char mame_disclaimer[];
-extern char giant_string_buffer[];
extern const char build_version[];
@@ -381,7 +371,7 @@ UINT8 *memory_region_alloc(running_machine *machine, const char *name, UINT32 le
void memory_region_free(running_machine *machine, const char *name);
/* return a pointer to a specified memory region */
-UINT8 *memory_region(running_machine *machine, const char *name);
+//UINT8 *memory_region(running_machine *machine, const char *name, UINT32 *length = NULL, UINT32 *flags = NULL);
/* return the size (in bytes) of a specified memory region */
UINT32 memory_region_length(running_machine *machine, const char *name);
@@ -447,4 +437,26 @@ void mame_get_current_datetime(running_machine *machine, mame_system_time *systi
#include "mess.h"
#endif /* MESS */
+
+
+/***************************************************************************
+ INLINE FUNCTIONS
+***************************************************************************/
+
+inline const device_config *running_machine::device(const char *tag)
+{
+ return device_list_find_by_tag(&config->devicelist, tag);
+}
+
+inline const input_port_config *running_machine::port(const char *tag)
+{
+ return input_port_by_tag(&portlist, tag);
+}
+
+template<class T> T *running_machine::region(const char *tag, UINT32 *length, UINT32 *flags)
+{
+ return reinterpret_cast<T *>(memory_region(this, tag, length, flags));
+}
+
+
#endif /* __MAME_H__ */