Privatized most of the m_machine pointers in the system to prevent

direct use.
This commit is contained in:
Aaron Giles 2011-04-19 06:02:01 +00:00
parent 3628e7eaed
commit d971ce8f36
33 changed files with 283 additions and 226 deletions

View File

@ -201,7 +201,6 @@ const debug_view_source *debug_view_source_list::match_device(device_t *device)
debug_view::debug_view(running_machine &machine, debug_view_type type, debug_view_osd_update_func osdupdate, void *osdprivate)
: m_next(NULL),
m_machine(machine),
m_type(type),
m_source(NULL),
m_source_list(machine),
@ -218,7 +217,8 @@ debug_view::debug_view(running_machine &machine, debug_view_type type, debug_vie
m_update_pending(true),
m_osd_update_pending(true),
m_viewdata(NULL),
m_viewdata_size(0)
m_viewdata_size(0),
m_machine(machine)
{
// allocate memory for the buffer
m_viewdata_size = m_visible.y * m_visible.x;

View File

@ -240,7 +240,6 @@ protected:
protected:
// core view data
debug_view * m_next; // link to the next view
running_machine & m_machine; // machine associated with this view
debug_view_type m_type; // type of view
const debug_view_source *m_source; // currently selected data source
debug_view_source_list m_source_list; // list of available data sources
@ -264,6 +263,9 @@ protected:
bool m_osd_update_pending; // true if there is a pending update
debug_view_char * m_viewdata; // current array of view data
int m_viewdata_size; // number of elements of the viewdata array
private:
running_machine & m_machine; // machine associated with this view
};

View File

@ -569,8 +569,7 @@ void device_interface::interface_debug_setup()
//-------------------------------------------------
device_t::device_t(running_machine &_machine, const device_config &config)
: m_machine(_machine),
m_state_manager(_machine.state()),
: m_state_manager(_machine.state()),
m_debug(NULL),
m_execute(NULL),
m_memory(NULL),
@ -585,7 +584,8 @@ device_t::device_t(running_machine &_machine, const device_config &config)
m_unscaled_clock(config.m_clock),
m_clock_scale(1.0),
m_attoseconds_per_clock((config.m_clock == 0) ? 0 : HZ_TO_ATTOSECONDS(config.m_clock)),
m_auto_finder_list(NULL)
m_auto_finder_list(NULL),
m_machine(_machine)
{
}

View File

@ -502,7 +502,6 @@ protected:
//------------------- end derived class overrides
running_machine & m_machine;
state_manager & m_state_manager;
device_debug * m_debug;
@ -629,6 +628,9 @@ protected:
void register_auto_finder(auto_finder_base &autodev);
auto_finder_base * m_auto_finder_list;
private:
running_machine & m_machine;
};

View File

@ -227,7 +227,7 @@ gfx_element *gfx_element_alloc(running_machine &machine, const gfx_layout *gl, c
gfx_element *gfx;
/* allocate memory for the gfx_element structure */
gfx = auto_alloc_clear(machine, gfx_element);
gfx = auto_alloc_clear(machine, gfx_element(machine));
/* fill in the data */
gfx->width = width;
@ -243,7 +243,6 @@ gfx_element *gfx_element_alloc(running_machine &machine, const gfx_layout *gl, c
gfx->total_colors = total_colors;
gfx->srcdata = srcdata;
gfx->m_machine = &machine;
/* copy the layout */
gfx->layout = *gl;
@ -379,8 +378,6 @@ void gfx_element_build_temporary(gfx_element *gfx, running_machine &machine, UIN
gfx->srcdata = base;
gfx->dirty = &not_dirty;
gfx->dirtyseq = 0;
gfx->m_machine = &machine;
}

View File

@ -120,7 +120,10 @@ struct _gfx_layout
class gfx_element
{
public:
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
gfx_element(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
UINT16 width; /* current pixel width of each element (changeble with source clipping) */
UINT16 height; /* current pixel height of each element (changeble with source clipping) */
@ -146,8 +149,10 @@ public:
UINT8 * dirty; /* dirty array for detecting tiles that need decoding */
UINT32 dirtyseq; /* sequence number; incremented each time a tile is dirtied */
running_machine *m_machine; /* pointer to the owning machine */
gfx_layout layout; /* copy of the original layout */
private:
running_machine &m_machine; /* pointer to the owning machine */
};

View File

@ -62,13 +62,18 @@ struct _palette_private
class colortable_t
{
public:
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
colortable_t(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine * m_machine; /* associated machine */
UINT32 entries; /* number of entries */
UINT32 palentries; /* number of palette entries */
UINT16 * raw; /* raw data about each entry */
rgb_t * palette; /* palette entries */
private:
running_machine & m_machine; /* associated machine */
};
@ -323,10 +328,9 @@ colortable_t *colortable_alloc(running_machine &machine, UINT32 palettesize)
assert(palettesize > 0);
/* allocate the colortable */
ctable = auto_alloc_clear(machine, colortable_t);
ctable = auto_alloc_clear(machine, colortable_t(machine));
/* fill in the basics */
ctable->m_machine = &machine;
ctable->entries = machine.total_colors();
ctable->palentries = palettesize;

View File

@ -2099,7 +2099,7 @@ static void init_port_state(running_machine &machine)
/* allocate a new input_port_info structure */
portstate = auto_alloc_clear(machine, input_port_state);
((input_port_config *)port)->state = portstate;
((input_port_config *)port)->m_machine = &machine;
((input_port_config *)port)->set_machine(machine);
/* start with tail pointers to all the data */
analogstatetail = &portstate->analoglist;
@ -3646,9 +3646,9 @@ input_port_config::input_port_config(const char *_tag)
tag(_tag),
fieldlist(NULL),
state(NULL),
m_machine(NULL),
owner(NULL),
active(0)
active(0),
m_machine(NULL)
{
}

View File

@ -742,6 +742,7 @@ public:
input_port_config *next() const { return m_next; }
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
void set_machine(running_machine &machine) { m_machine = &machine; }
input_port_config * m_next; /* pointer to next port */
const char * tag; /* pointer to this port's tag */
@ -749,9 +750,11 @@ public:
/* these fields are only valid if the port is live */
input_port_state * state; /* live state of port (NULL if not live) */
running_machine * m_machine; /* machine if port is live */
device_config * owner; /* associated device, when appropriate */
input_port_value active; /* mask of active bits in the port */
private:
running_machine * m_machine; /* machine if port is live */
};

View File

@ -78,11 +78,14 @@ struct _joystick_map
/* a single input device */
struct _input_device
class input_device
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
input_device(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine * m_machine; /* machine we are attached to */
astring name; /* string name of device */
input_device_class devclass; /* class of this device */
int devindex; /* device index of this device */
@ -93,6 +96,9 @@ struct _input_device
/* joystick information */
joystick_map joymap; /* joystick map for this device */
UINT8 lastmap; /* last joystick map value for this device */
private:
running_machine & m_machine; /* machine we are attached to */
};
@ -759,7 +765,7 @@ input_device *input_device_add(running_machine &machine, input_device_class devc
assert(devclass != DEVICE_CLASS_INVALID && devclass < DEVICE_CLASS_MAXIMUM);
/* allocate a new device */
input_device *device = auto_alloc_clear(machine, input_device);
input_device *device = auto_alloc_clear(machine, input_device(machine));
input_device **newlist = auto_alloc_array(machine, input_device *, devlist->count + 1);
for (int devnum = 0; devnum < devlist->count; devnum++)
newlist[devnum] = devlist->list[devnum];
@ -768,7 +774,6 @@ input_device *input_device_add(running_machine &machine, input_device_class devc
devlist->list[devlist->count++] = device;
/* fill in the data */
device->m_machine = &machine;
device->name.cpy(name);
device->devclass = devclass;
device->devindex = devlist->count - 1;

View File

@ -559,7 +559,7 @@ typedef UINT32 input_code;
typedef INT32 (*item_get_state_func)(void *device_internal, void *item_internal);
/* (opaque) input device object */
typedef struct _input_device input_device;
class input_device;

View File

@ -1795,7 +1795,6 @@ address_space::address_space(device_memory_interface &memory, address_spacenum s
: m_next(NULL),
m_config(*memory.space_config(spacenum)),
m_device(memory.device()),
m_machine(memory.device().machine()),
m_map(NULL),
m_addrmask(0xffffffffUL >> (32 - m_config.m_addrbus_width)),
m_bytemask(address_to_byte_end(m_addrmask)),
@ -1808,7 +1807,8 @@ address_space::address_space(device_memory_interface &memory, address_spacenum s
m_direct(*auto_alloc(memory.device().machine(), direct_read_data(*this))),
m_name(memory.space_config(spacenum)->name()),
m_addrchars((m_config.m_databus_width + 3) / 4),
m_logaddrchars((m_config.m_logaddr_width + 3) / 4)
m_logaddrchars((m_config.m_logaddr_width + 3) / 4),
m_machine(memory.device().machine())
{
// notify the device
memory.set_address_space(spacenum, *this);

View File

@ -540,7 +540,6 @@ protected:
address_space * m_next; // next address space in the global list
const address_space_config &m_config; // configuration of this space
device_t & m_device; // reference to the owning device
running_machine & m_machine; // reference to the owning machine
address_map * m_map; // original memory map
offs_t m_addrmask; // physical address mask
offs_t m_bytemask; // byte-converted physical address mask
@ -554,6 +553,9 @@ protected:
const char * m_name; // friendly name of the address space
UINT8 m_addrchars; // number of characters to use for physical addresses
UINT8 m_logaddrchars; // number of characters to use for logical addresses
private:
running_machine & m_machine; // reference to the owning machine
};

View File

@ -65,12 +65,15 @@ struct _blit_parameters
/* core tilemap structure */
struct _tilemap_t
class tilemap_t
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
tilemap_t(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
tilemap_t * next; /* pointer to next tilemap */
running_machine * m_machine; /* pointer back to the owning machine */
/* basic tilemap metrics */
UINT32 rows; /* number of tile rows */
@ -120,6 +123,9 @@ struct _tilemap_t
bitmap_t * flagsmap; /* per-pixel flags */
UINT8 * tileflags; /* per-tile flags */
UINT8 * pen_to_flags; /* mapping of pens to flags */
private:
running_machine & m_machine; /* pointer back to the owning machine */
};
@ -350,10 +356,9 @@ static tilemap_t *tilemap_create_common(running_machine &machine, void *get_info
tilemap_instance = machine.tilemap_data->instance;
/* allocate the tilemap itself */
tmap = auto_alloc_clear(machine, tilemap_t);
tmap = auto_alloc_clear(machine, tilemap_t(machine));
/* fill in the basic metrics */
tmap->m_machine = &machine;
tmap->rows = rows;
tmap->cols = cols;
tmap->tilewidth = tilewidth;

View File

@ -380,7 +380,7 @@
typedef UINT32 tilemap_memory_index;
/* opaque tilemap definition */
typedef struct _tilemap_t tilemap_t;
class tilemap_t;
/* tile_data is filled in by the get_tile_info callback */

View File

@ -116,11 +116,14 @@ struct _ui_menu_item
};
struct _ui_menu
class ui_menu
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
ui_menu(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine * m_machine; /* machine we are attached to */
render_container * container; /* render_container we render to */
ui_menu_handler_func handler; /* handler callback */
void * parameter; /* parameter */
@ -140,6 +143,9 @@ struct _ui_menu
float customtop; /* amount of extra height to add at the top */
float custombottom; /* amount of extra height to add at the bottom */
ui_menu_pool * pool; /* list of memory pools */
private:
running_machine & m_machine; /* machine we are attached to */
};
@ -441,10 +447,9 @@ ui_menu *ui_menu_alloc(running_machine &machine, render_container *container, ui
ui_menu *menu;
/* allocate and clear memory for the menu and the state */
menu = auto_alloc_clear(machine, ui_menu);
menu = auto_alloc_clear(machine, ui_menu(machine));
/* initialize the state */
menu->m_machine = &machine;
menu->container = container;
menu->handler = handler;
menu->parameter = parameter;

View File

@ -53,7 +53,7 @@ typedef enum _ui_menu_reset_options ui_menu_reset_options;
***************************************************************************/
/* forward declarations */
typedef struct _ui_menu ui_menu;
class ui_menu;
/* menu-related callback functions */

View File

@ -249,7 +249,7 @@ static void draw_sprite(running_machine &machine, bitmap_t *bitmap,const rectang
{
igs017_state *state = machine.driver_data<igs017_state>();
// prepare GfxElement on the fly
gfx_element gfx;
gfx_element gfx(machine);
// Bounds checking
if ( addr + dimx * dimy >= state->m_sprites_gfx_size )

View File

@ -368,7 +368,7 @@ static void draw_sprites(running_machine &machine, UINT32 *sprites, const rectan
UINT8 *gfx_max = base_gfx + machine.region("gfx1")->bytes();
UINT8 *gfxdata;
gfx_element gfx;
gfx_element gfx(machine);
for(i = 0; i <= count*2; i += 2)
{

View File

@ -21,11 +21,14 @@ typedef struct _am2901
UINT32 y; /* Y output */
} am2901;
typedef struct _vector_generator
class vector_generator
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
vector_generator(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine *m_machine;
UINT32 sreg; /* shift register */
UINT32 l1; /* latch 1 adder operand only */
UINT32 l2; /* latch 2 adder operand only */
@ -44,7 +47,10 @@ typedef struct _vector_generator
UINT32 vud2; /* v-counter up or down (stored in L2) */
UINT32 hc1; /* use h- or v-counter in L1 mode */
UINT32 ven; /* vector intensity enable */
} vector_generator;
private:
running_machine &m_machine;
};
typedef struct _microcode
{
@ -81,7 +87,8 @@ class vertigo_state : public driver_device
{
public:
vertigo_state(running_machine &machine, const driver_device_config_base &config)
: driver_device(machine, config) { }
: driver_device(machine, config),
m_vgen(machine) { }
UINT16 *m_vectorram;
device_t *m_ttl74148;

View File

@ -26,12 +26,12 @@ TODO: Add CDDA support
#define CD_SECTOR_TIME (1000/((150*1024)/2048)) /* 1X CDROM sector time in msec (300KBps) */
typedef struct _akiko_state akiko_state;
struct _akiko_state
class akiko_state
{
public:
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
void set_machine(running_machine &machine) { m_machine = &machine; }
running_machine *m_machine;
address_space *m_space;
/* chunky to planar converter */
@ -68,6 +68,9 @@ struct _akiko_state
device_t *m_i2cmem;
int m_cdrom_is_device;
private:
running_machine *m_machine;
};
static TIMER_CALLBACK(akiko_dma_proc);
@ -172,7 +175,7 @@ static DEVICE_START( akiko )
running_machine &machine = device->machine();
akiko_state *state = get_safe_token(device);
state->m_machine = &machine;
state->set_machine(machine);
state->m_space = machine.device("maincpu")->memory().space(AS_PROGRAM);
state->m_c2p_input_index = 0;
state->m_c2p_output_index = 0;

View File

@ -88,16 +88,17 @@ struct effects_control
/* C1CA-C1CB */ UINT16 timer_duration;
};
static struct
struct nmk004_state
{
public:
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
void set_machine(running_machine &machine) { m_machine = &machine; }
const UINT8 *rom; // NMK004 data ROM
UINT8 from_main; // command from main CPU
UINT8 to_main; // answer to main CPU
int protection_check;
running_machine *m_machine;
device_t *ymdevice;
okim6295_device *oki1device;
okim6295_device *oki2device;
@ -107,7 +108,12 @@ static struct
/* C020-C19F */ struct fm_control fm_control[FM_CHANNELS];
/* C220-C2DF */ struct psg_control psg_control[PSG_CHANNELS];
/* C1A0-C21F */ struct effects_control effects_control[EFFECTS_CHANNELS];
} NMK004_state;
private:
running_machine *m_machine;
};
static nmk004_state NMK004_state;
#define SAMPLE_TABLE_0 0xefe0
@ -1022,7 +1028,7 @@ static TIMER_CALLBACK( real_nmk004_init )
memset(&NMK004_state, 0, sizeof(NMK004_state));
NMK004_state.m_machine = &machine;
NMK004_state.set_machine(machine);
NMK004_state.ymdevice = machine.device("ymsnd");
NMK004_state.oki1device = machine.device<okim6295_device>("oki1");
NMK004_state.oki2device = machine.device<okim6295_device>("oki2");

View File

@ -10,21 +10,20 @@
static UINT8 sdd1_read(running_machine& machine, UINT32 addr);
typedef struct //Input Manager
class SDD1_IM //Input Manager
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
SDD1_IM(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine* m_machine;
UINT32 byte_ptr;
UINT8 bit_count;
} SDD1_IM;
static SDD1_IM* SDD1_IM_ctor(running_machine& machine)
{
SDD1_IM* newclass = (SDD1_IM*)auto_alloc_array(machine, UINT8, sizeof(SDD1_IM));
newclass->m_machine = &machine;
return newclass;
}
private:
running_machine& m_machine;
};
static void SDD1_IM_prepareDecomp(SDD1_IM* thisptr, UINT32 in_buf)
{
@ -55,21 +54,20 @@ static UINT8 SDD1_IM_getCodeword(SDD1_IM* thisptr, const UINT8 code_len)
return codeword;
}
typedef struct //Golomb-Code Decoder
class SDD1_GCD //Golomb-Code Decoder
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
SDD1_GCD(running_machine &machine, SDD1_IM* associatedIM)
: IM(associatedIM),
m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine* m_machine;
SDD1_IM* IM;
} SDD1_GCD;
static SDD1_GCD* SDD1_GCD_ctor(running_machine& machine, SDD1_IM* associatedIM)
{
SDD1_GCD* newclass = (SDD1_GCD*)auto_alloc_array(machine, UINT8, sizeof(SDD1_GCD));
newclass->m_machine = &machine;
newclass->IM = associatedIM;
return newclass;
}
private:
running_machine& m_machine;
};
static void SDD1_GCD_getRunCount(SDD1_GCD* thisptr, UINT8 code_num, UINT8* MPScount, UINT8* LPSind)
{
@ -122,25 +120,24 @@ static void SDD1_GCD_getRunCount(SDD1_GCD* thisptr, UINT8 code_num, UINT8* MPSco
}
}
typedef struct // Bits Generator
class SDD1_BG // Bits Generator
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
SDD1_BG(running_machine &machine, SDD1_GCD* associatedGCD, UINT8 code)
: code_num(code),
GCD(associatedGCD),
m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine* m_machine;
UINT8 code_num;
UINT8 MPScount;
UINT8 LPSind;
SDD1_GCD* GCD;
} SDD1_BG;
static SDD1_BG* SDD1_BG_ctor(running_machine& machine, SDD1_GCD* associatedGCD, UINT8 code)
{
SDD1_BG* newclass = (SDD1_BG*)auto_alloc_array(machine, UINT8, sizeof(SDD1_BG));
newclass->m_machine = &machine;
newclass->code_num = code;
newclass->GCD = associatedGCD;
return newclass;
}
public:
running_machine& m_machine;
} ;
static void SDD1_BG_prepareDecomp(SDD1_BG* thisptr)
{
@ -231,33 +228,34 @@ typedef struct
UINT8 MPS;
} SDD1_PEM_ContextInfo;
typedef struct //Probability Estimation Module
class SDD1_PEM //Probability Estimation Module
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
running_machine* m_machine;
SDD1_PEM_ContextInfo contextInfo[32];
SDD1_BG* BG[8];
} SDD1_PEM;
static SDD1_PEM* SDD1_PEM_ctor(running_machine& machine,
public:
SDD1_PEM(running_machine& machine,
SDD1_BG* associatedBG0, SDD1_BG* associatedBG1,
SDD1_BG* associatedBG2, SDD1_BG* associatedBG3,
SDD1_BG* associatedBG4, SDD1_BG* associatedBG5,
SDD1_BG* associatedBG6, SDD1_BG* associatedBG7)
{
SDD1_PEM* newclass = (SDD1_PEM*)auto_alloc_array(machine, UINT8, sizeof(SDD1_PEM));
newclass->m_machine = &machine;
newclass->BG[0] = associatedBG0;
newclass->BG[1] = associatedBG1;
newclass->BG[2] = associatedBG2;
newclass->BG[3] = associatedBG3;
newclass->BG[4] = associatedBG4;
newclass->BG[5] = associatedBG5;
newclass->BG[6] = associatedBG6;
newclass->BG[7] = associatedBG7;
return newclass;
}
: m_machine(machine)
{
BG[0] = associatedBG0;
BG[1] = associatedBG1;
BG[2] = associatedBG2;
BG[3] = associatedBG3;
BG[4] = associatedBG4;
BG[5] = associatedBG5;
BG[6] = associatedBG6;
BG[7] = associatedBG7;
}
running_machine &machine() const { return m_machine; }
SDD1_PEM_ContextInfo contextInfo[32];
SDD1_BG* BG[8];
private:
running_machine& m_machine;
} ;
static void SDD1_PEM_prepareDecomp(SDD1_PEM* thisptr)
{
@ -300,26 +298,25 @@ static UINT8 SDD1_PEM_getBit(SDD1_PEM* thisptr, UINT8 context)
return bit ^ currentMPS;
}
typedef struct
class SDD1_CM
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
SDD1_CM(running_machine& machine, SDD1_PEM* associatedPEM)
: PEM(associatedPEM),
m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine* m_machine;
UINT8 bitplanesInfo;
UINT8 contextBitsInfo;
UINT8 bit_number;
UINT8 currBitplane;
UINT16 prevBitplaneBits[8];
SDD1_PEM* PEM;
} SDD1_CM;
static SDD1_CM* SDD1_CM_ctor(running_machine& machine, SDD1_PEM* associatedPEM)
{
SDD1_CM* newclass = (SDD1_CM*)auto_alloc_array(machine, UINT8, sizeof(SDD1_CM));
newclass->m_machine = &machine;
newclass->PEM = associatedPEM;
return newclass;
}
private:
running_machine& m_machine;
} ;
static void SDD1_CM_prepareDecomp(SDD1_CM* thisptr, UINT32 first_byte)
{
@ -404,24 +401,23 @@ static UINT8 SDD1_CM_getBit(SDD1_CM* thisptr)
return bit;
}
typedef struct
class SDD1_OL
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
SDD1_OL(running_machine& machine, SDD1_CM* associatedCM)
: CM(associatedCM),
m_machine(machine) { }
running_machine &machine() const { return m_machine; }
running_machine* m_machine;
UINT8 bitplanesInfo;
UINT16 length;
UINT8* buffer;
SDD1_CM* CM;
} SDD1_OL;
static SDD1_OL* SDD1_OL_ctor(running_machine& machine, SDD1_CM* associatedCM)
{
SDD1_OL* newclass = (SDD1_OL*)auto_alloc_array(machine, UINT8, sizeof(SDD1_OL));
newclass->m_machine = &machine;
newclass->CM = associatedCM;
return newclass;
}
private:
running_machine& m_machine;
} ;
static void SDD1_OL_prepareDecomp(SDD1_OL* thisptr, UINT32 first_byte, UINT16 out_len, UINT8 *out_buf)
{
@ -481,11 +477,13 @@ static void SDD1_OL_launch(SDD1_OL* thisptr)
}
}
typedef struct
class SDD1emu
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
SDD1emu(running_machine &machine);
running_machine &machine() const { return m_machine; }
running_machine* m_machine;
SDD1_IM* IM;
SDD1_GCD* GCD;
SDD1_BG* BG0; SDD1_BG* BG1; SDD1_BG* BG2; SDD1_BG* BG3;
@ -493,28 +491,28 @@ typedef struct
SDD1_PEM* PEM;
SDD1_CM* CM;
SDD1_OL* OL;
} SDD1emu;
static SDD1emu* SDD1emu_ctor(running_machine &machine)
private:
running_machine& m_machine;
};
SDD1emu::SDD1emu(running_machine &machine)
: m_machine(machine)
{
SDD1emu* newclass = (SDD1emu*)auto_alloc_array(machine, UINT8, sizeof(SDD1emu));
newclass->m_machine = &machine;
newclass->IM = SDD1_IM_ctor(machine);
newclass->GCD = SDD1_GCD_ctor(machine, newclass->IM);
newclass->BG0 = SDD1_BG_ctor(machine, newclass->GCD, 0);
newclass->BG1 = SDD1_BG_ctor(machine, newclass->GCD, 1);
newclass->BG2 = SDD1_BG_ctor(machine, newclass->GCD, 2);
newclass->BG3 = SDD1_BG_ctor(machine, newclass->GCD, 3);
newclass->BG4 = SDD1_BG_ctor(machine, newclass->GCD, 4);
newclass->BG5 = SDD1_BG_ctor(machine, newclass->GCD, 5);
newclass->BG6 = SDD1_BG_ctor(machine, newclass->GCD, 6);
newclass->BG7 = SDD1_BG_ctor(machine, newclass->GCD, 7);
newclass->PEM = SDD1_PEM_ctor(machine, newclass->BG0, newclass->BG1, newclass->BG2, newclass->BG3,
newclass->BG4, newclass->BG5, newclass->BG6, newclass->BG7);
newclass->CM = SDD1_CM_ctor(machine, newclass->PEM);
newclass->OL = SDD1_OL_ctor(machine, newclass->CM);
return newclass;
IM = auto_alloc(machine, SDD1_IM(machine));
GCD = auto_alloc(machine, SDD1_GCD(machine, IM));
BG0 = auto_alloc(machine, SDD1_BG(machine, GCD, 0));
BG1 = auto_alloc(machine, SDD1_BG(machine, GCD, 1));
BG2 = auto_alloc(machine, SDD1_BG(machine, GCD, 2));
BG3 = auto_alloc(machine, SDD1_BG(machine, GCD, 3));
BG4 = auto_alloc(machine, SDD1_BG(machine, GCD, 4));
BG5 = auto_alloc(machine, SDD1_BG(machine, GCD, 5));
BG6 = auto_alloc(machine, SDD1_BG(machine, GCD, 6));
BG7 = auto_alloc(machine, SDD1_BG(machine, GCD, 7));
PEM = auto_alloc(machine, SDD1_PEM(machine, BG0, BG1, BG2, BG3,
BG4, BG5, BG6, BG7));
CM = auto_alloc(machine, SDD1_CM(machine, PEM));
OL = auto_alloc(machine, SDD1_OL(machine, CM));
}
static void SDD1emu_decompress(SDD1emu* thisptr, UINT32 in_buf, UINT16 out_len, UINT8 *out_buf)
@ -577,7 +575,7 @@ static void sdd1_init(running_machine& machine)
snes_sdd1.dma[i].size = 0;
}
snes_sdd1.sdd1emu = SDD1emu_ctor(machine);
snes_sdd1.sdd1emu = auto_alloc(machine, SDD1emu(machine));
snes_sdd1.buffer.data = (UINT8*)auto_alloc_array(machine, UINT8, 0x10000);
snes_sdd1.buffer.ready = 0;

View File

@ -15,8 +15,7 @@
***************************************************************************/
/* internal structure containing a word index, shift and mask */
typedef struct _atarimo_mask atarimo_mask;
struct _atarimo_mask
struct atarimo_mask
{
int word; /* word index */
int shift; /* shift amount */
@ -24,15 +23,18 @@ struct _atarimo_mask
};
/* internal structure containing the state of the motion objects */
typedef struct _atarimo_data atarimo_data;
struct _atarimo_data
class atarimo_data
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
atarimo_data(running_machine &machine)
: m_machine(machine)
{
}
running_machine * m_machine; /* pointer back to the machine */
running_machine &machine() const { return m_machine; }
UINT32 gfxchanged; /* true if the gfx info has changed */
gfx_element gfxelement[MAX_GFX_ELEMENTS]; /* local copy of graphics elements */
gfx_element * gfxelement[MAX_GFX_ELEMENTS]; /* local copy of graphics elements */
int gfxgranularity[MAX_GFX_ELEMENTS];
bitmap_t *bitmap; /* temporary bitmap to render to */
@ -112,6 +114,9 @@ struct _atarimo_data
UINT32 last_xpos; /* (during processing) the previous X position */
UINT32 next_xpos; /* (during processing) the next X position */
private:
running_machine & m_machine; /* pointer back to the machine */
};
@ -129,7 +134,7 @@ struct _atarimo_data
STATIC VARIABLES
***************************************************************************/
static atarimo_data atarimo[ATARIMO_MAX];
static atarimo_data *atarimo[ATARIMO_MAX];
static emu_timer *force_update_timer;
@ -230,11 +235,12 @@ INLINE int convert_mask(const atarimo_entry *input, atarimo_mask *result)
INLINE void init_gfxelement(atarimo_data *mo, int idx)
{
mo->gfxelement[idx] = *mo->machine().gfx[idx];
mo->gfxgranularity[idx] = mo->gfxelement[idx].color_granularity;
mo->gfxelement[idx].color_granularity = 1;
mo->gfxelement[idx].color_base = 0;
mo->gfxelement[idx].total_colors = 65536;
mo->gfxelement[idx] = auto_alloc(mo->machine(), gfx_element(mo->machine()));
memcpy(mo->gfxelement[idx], mo->machine().gfx[idx], sizeof(*mo->gfxelement[idx]));
mo->gfxgranularity[idx] = mo->gfxelement[idx]->color_granularity;
mo->gfxelement[idx]->color_granularity = 1;
mo->gfxelement[idx]->color_base = 0;
mo->gfxelement[idx]->total_colors = 65536;
}
@ -326,10 +332,10 @@ static TIMER_CALLBACK( force_update )
void atarimo_init(running_machine &machine, int map, const atarimo_desc *desc)
{
gfx_element *gfx = machine.gfx[desc->gfxindex];
atarimo_data *mo = &atarimo[map];
int i;
assert_always(map >= 0 && map < ATARIMO_MAX, "atarimo_init: map out of range");
atarimo_data *mo = atarimo[map] = auto_alloc(machine, atarimo_data(machine));
/* determine the masks first */
convert_mask(&desc->linkmask, &mo->linkmask);
@ -348,7 +354,6 @@ void atarimo_init(running_machine &machine, int map, const atarimo_desc *desc)
convert_mask(&desc->absolutemask, &mo->absolutemask);
/* copy in the basic data */
mo->m_machine = &machine;
mo->gfxchanged = FALSE;
mo->linked = desc->linked;
@ -452,7 +457,7 @@ void atarimo_init(running_machine &machine, int map, const atarimo_desc *desc)
UINT16 *atarimo_get_code_lookup(int map, int *size)
{
atarimo_data *mo = &atarimo[map];
atarimo_data *mo = atarimo[map];
if (size)
*size = round_to_powerof2(mo->codemask.mask);
@ -467,7 +472,7 @@ UINT16 *atarimo_get_code_lookup(int map, int *size)
UINT8 *atarimo_get_color_lookup(int map, int *size)
{
atarimo_data *mo = &atarimo[map];
atarimo_data *mo = atarimo[map];
if (size)
*size = round_to_powerof2(mo->colormask.mask);
@ -482,7 +487,7 @@ UINT8 *atarimo_get_color_lookup(int map, int *size)
UINT8 *atarimo_get_gfx_lookup(int map, int *size)
{
atarimo_data *mo = &atarimo[map];
atarimo_data *mo = atarimo[map];
mo->gfxchanged = TRUE;
if (size)
@ -633,7 +638,7 @@ static void convert_dirty_grid_to_rects(atarimo_data *mo, const rectangle *clipr
bitmap_t *atarimo_render(int map, const rectangle *cliprect, atarimo_rect_list *rectlist)
{
atarimo_data *mo = &atarimo[map];
atarimo_data *mo = atarimo[map];
int startband, stopband, band, i;
rectangle *rect;
@ -737,7 +742,7 @@ bitmap_t *atarimo_render(int map, const rectangle *cliprect, atarimo_rect_list *
static int mo_render_object(atarimo_data *mo, const atarimo_entry *entry, const rectangle *cliprect)
{
int gfxindex = mo->gfxlookup[EXTRACT_DATA(entry, mo->gfxmask)];
const gfx_element *gfx = &mo->gfxelement[gfxindex];
const gfx_element *gfx = mo->gfxelement[gfxindex];
bitmap_t *bitmap = mo->bitmap;
int x, y, sx, sy;
@ -910,7 +915,7 @@ if ((temp & 0xff00) == 0xc800)
void atarimo_set_bank(int map, int bank)
{
atarimo_data *mo = &atarimo[map];
atarimo_data *mo = atarimo[map];
mo->bank = bank;
}
@ -922,7 +927,7 @@ void atarimo_set_bank(int map, int bank)
void atarimo_set_xscroll(int map, int xscroll)
{
atarimo_data *mo = &atarimo[map];
atarimo_data *mo = atarimo[map];
mo->xscroll = xscroll;
}
@ -934,7 +939,7 @@ void atarimo_set_xscroll(int map, int xscroll)
void atarimo_set_yscroll(int map, int yscroll)
{
atarimo_data *mo = &atarimo[map];
atarimo_data *mo = atarimo[map];
mo->yscroll = yscroll;
}
@ -946,7 +951,7 @@ void atarimo_set_yscroll(int map, int yscroll)
int atarimo_get_bank(int map)
{
return atarimo[map].bank;
return atarimo[map]->bank;
}
@ -957,7 +962,7 @@ int atarimo_get_bank(int map)
int atarimo_get_xscroll(int map)
{
return atarimo[map].xscroll;
return atarimo[map]->xscroll;
}
@ -968,7 +973,7 @@ int atarimo_get_xscroll(int map)
int atarimo_get_yscroll(int map)
{
return atarimo[map].yscroll;
return atarimo[map]->yscroll;
}
@ -978,7 +983,7 @@ int atarimo_get_yscroll(int map)
READ16_HANDLER( atarimo_0_spriteram_r )
{
atarimo_data *mo = &atarimo[0];
atarimo_data *mo = atarimo[0];
return mo->sprite_ram[offset] & mem_mask;
}
@ -990,7 +995,7 @@ READ16_HANDLER( atarimo_0_spriteram_r )
WRITE16_HANDLER( atarimo_0_spriteram_w )
{
int entry, idx, bank;
atarimo_data *mo = &atarimo[0];
atarimo_data *mo = atarimo[0];
COMBINE_DATA(&mo->sprite_ram[offset]);
if (mo->split)
@ -1014,7 +1019,7 @@ WRITE16_HANDLER( atarimo_0_spriteram_w )
READ16_HANDLER( atarimo_1_spriteram_r )
{
atarimo_data *mo = &atarimo[1];
atarimo_data *mo = atarimo[1];
return mo->sprite_ram[offset] & mem_mask;
}
@ -1026,7 +1031,7 @@ READ16_HANDLER( atarimo_1_spriteram_r )
WRITE16_HANDLER( atarimo_1_spriteram_w )
{
int entry, idx, bank;
atarimo_data *mo = &atarimo[1];
atarimo_data *mo = atarimo[1];
COMBINE_DATA(&mo->sprite_ram[offset]);
if (mo->split)
@ -1052,7 +1057,7 @@ WRITE16_HANDLER( atarimo_1_spriteram_w )
WRITE16_HANDLER( atarimo_0_spriteram_expanded_w )
{
int entry, idx, bank;
atarimo_data *mo = &atarimo[0];
atarimo_data *mo = atarimo[0];
COMBINE_DATA(&mo->sprite_ram[offset]);
if (!(offset & 1))
@ -1080,7 +1085,7 @@ WRITE16_HANDLER( atarimo_0_spriteram_expanded_w )
void atarimo_set_slipram(int map, UINT16 *ram)
{
atarimo_data *mo = &atarimo[map];
atarimo_data *mo = atarimo[map];
mo->slip_ram = ram;
}
@ -1091,7 +1096,7 @@ void atarimo_set_slipram(int map, UINT16 *ram)
READ16_HANDLER( atarimo_0_slipram_r )
{
atarimo_data *mo = &atarimo[0];
atarimo_data *mo = atarimo[0];
logerror("READ: %04x:%04x\n", offset, mo->slip_ram[offset] & mem_mask);
return mo->slip_ram[offset] & mem_mask;
}
@ -1103,7 +1108,7 @@ READ16_HANDLER( atarimo_0_slipram_r )
WRITE16_HANDLER( atarimo_0_slipram_w )
{
atarimo_data *mo = &atarimo[0];
atarimo_data *mo = atarimo[0];
logerror("WRITE: %04x:%04x:%04x:%04x\n", offset, mo->slip_ram[offset], data, mem_mask);
COMBINE_DATA(&mo->slip_ram[offset]);
}
@ -1115,7 +1120,7 @@ WRITE16_HANDLER( atarimo_0_slipram_w )
READ16_HANDLER( atarimo_1_slipram_r )
{
atarimo_data *mo = &atarimo[1];
atarimo_data *mo = atarimo[1];
return mo->slip_ram[offset] & mem_mask;
}
@ -1126,7 +1131,7 @@ READ16_HANDLER( atarimo_1_slipram_r )
WRITE16_HANDLER( atarimo_1_slipram_w )
{
atarimo_data *mo = &atarimo[1];
atarimo_data *mo = atarimo[1];
COMBINE_DATA(&mo->slip_ram[offset]);
}

View File

@ -56,8 +56,7 @@ UINT8 *avgdvg_colorram;
*
*************************************/
typedef struct _vgvector vgvector;
struct _vgvector
struct vgvector
{
int x; int y;
rgb_t color;
@ -66,12 +65,10 @@ struct _vgvector
int status;
};
typedef struct _vgdata vgdata;
struct _vgdata
struct vgdata
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
running_machine *m_machine;
void set_machine(running_machine &machine) { m_machine = &machine; }
UINT16 pc;
UINT8 sp;
@ -110,6 +107,9 @@ struct _vgdata
INT32 clipy_min;
INT32 clipx_max;
INT32 clipy_max;
private:
running_machine *m_machine;
};
typedef struct _vgconf vgconf;
@ -1494,7 +1494,7 @@ static VIDEO_START( avg_common )
const rectangle &visarea = machine.primary_screen->visible_area();
vg = &vgd;
vg->m_machine = &machine;
vg->set_machine(machine);
xmin = visarea.min_x;
ymin = visarea.min_y;
@ -1527,7 +1527,7 @@ VIDEO_START( dvg )
vgc = &dvg_default;
vg = &vgd;
vg->m_machine = &machine;
vg->set_machine(machine);
xmin = visarea.min_x;
ymin = visarea.min_y;

View File

@ -24,8 +24,7 @@
#define IS_POLYEND(x) (((x) ^ ((x) >> 1)) & 0x4000)
typedef struct _poly_extra_data poly_extra_data;
struct _poly_extra_data
struct poly_extra_data
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }

View File

@ -484,7 +484,7 @@ static void draw_sprites( running_machine &machine, bitmap_t *bitmap, const rect
for (i = 0; i < 0x20; i++)
{
gfx_element gfx;
gfx_element gfx(machine);
if (!(state->m_videoregs[0x02 / 2] & 0x8000))
{

View File

@ -464,7 +464,7 @@ void metro_draw_sprites( running_machine &machine, bitmap_t *bitmap, const recta
for (i = 0; i < 0x20; i++)
{
gfx_element gfx;
gfx_element gfx(machine);
if (!(state->m_videoregs[0x02/2] & 0x8000))
{

View File

@ -187,7 +187,6 @@ void vertigo_vproc_reset(running_machine &machine)
memset(&state->m_vs, 0, sizeof(state->m_vs));
memset(&state->m_bsp, 0, sizeof(state->m_bsp));
memset(&state->m_vgen, 0, sizeof(state->m_vgen));
state->m_vgen.m_machine = &machine;
}

View File

@ -148,7 +148,7 @@ enum
//============================================================
typedef struct _debugview_info debugview_info;
typedef struct _debugwin_info debugwin_info;
class debugwin_info;
struct _debugview_info
@ -161,9 +161,13 @@ struct _debugview_info
};
struct _debugwin_info
class debugwin_info
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
debugwin_info(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
debugwin_info * next;
HWND wnd;
@ -191,7 +195,8 @@ struct _debugwin_info
HWND otherwnd[MAX_OTHER_WND];
running_machine * m_machine;
private:
running_machine & m_machine;
};
@ -542,7 +547,7 @@ static debugwin_info *debugwin_window_create(running_machine &machine, LPCSTR ti
RECT work_bounds;
// allocate memory
info = global_alloc_clear(debugwin_info);
info = global_alloc_clear(debugwin_info(machine));
// create the window
info->handler = handler;
@ -563,8 +568,6 @@ static debugwin_info *debugwin_window_create(running_machine &machine, LPCSTR ti
info->handle_key = global_handle_key;
strcpy(info->edit_defstr, "");
info->m_machine = &machine;
// hook us in
info->next = window_list;
window_list = info;

View File

@ -160,10 +160,13 @@ struct _rawinput_device_info
// generic device information
typedef struct _device_info device_info;
struct _device_info
class device_info
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
device_info(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
// device information
device_info ** head;
@ -172,7 +175,6 @@ struct _device_info
void (*poll)(device_info *info);
// MAME information
running_machine * m_machine;
input_device * device;
// device state
@ -186,6 +188,9 @@ struct _device_info
// DirectInput/RawInput-specific state
dinput_device_info dinput;
rawinput_device_info rawinput;
private:
running_machine & m_machine;
};
@ -817,9 +822,8 @@ static device_info *generic_device_alloc(running_machine &machine, device_info *
device_info *devinfo;
// allocate memory for the device object
devinfo = global_alloc_clear(device_info);
devinfo = global_alloc_clear(device_info(machine));
devinfo->head = devlist_head_ptr;
devinfo->m_machine = &machine;
// allocate a UTF8 copy of the name
devinfo->name = utf8_from_tstring(name);

View File

@ -609,13 +609,12 @@ void winwindow_video_window_create(running_machine &machine, int index, win_moni
assert(GetCurrentThreadId() == main_threadid);
// allocate a new window object
window = global_alloc_clear(win_window_info);
window = global_alloc_clear(win_window_info(machine));
window->maxwidth = config->width;
window->maxheight = config->height;
window->refresh = config->refresh;
window->monitor = monitor;
window->fullscreen = !video_config.windowed;
window->m_machine = &machine;
// see if we are safe for fullscreen
window->fullscreen_safe = TRUE;

View File

@ -65,10 +65,13 @@
// TYPE DEFINITIONS
//============================================================
typedef struct _win_window_info win_window_info;
struct _win_window_info
struct win_window_info
{
running_machine &machine() const { assert(m_machine != NULL); return *m_machine; }
public:
win_window_info(running_machine &machine)
: m_machine(machine) { }
running_machine &machine() const { return m_machine; }
win_window_info * next;
volatile int init_state;
@ -106,7 +109,8 @@ struct _win_window_info
// drawing data
void * drawdata;
running_machine * m_machine;
private:
running_machine & m_machine;
};