modernized crosshair_manager (nw)

This commit is contained in:
Miodrag Milanovic 2016-01-11 11:59:41 +01:00
parent 3c1ea41741
commit 3b922ba118
7 changed files with 190 additions and 228 deletions

View File

@ -24,38 +24,10 @@
#define CROSSHAIR_RAW_ROWBYTES ((CROSSHAIR_RAW_SIZE + 7) / 8)
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
struct crosshair_global
{
UINT8 usage; /* true if any crosshairs are used */
UINT8 used[MAX_PLAYERS]; /* usage per player */
UINT8 mode[MAX_PLAYERS]; /* visibility mode per player */
UINT8 visible[MAX_PLAYERS]; /* visibility per player */
bitmap_argb32 * bitmap[MAX_PLAYERS]; /* bitmap per player */
render_texture * texture[MAX_PLAYERS]; /* texture per player */
screen_device * screen[MAX_PLAYERS]; /* the screen on which this player's crosshair is drawn */
float x[MAX_PLAYERS]; /* current X position */
float y[MAX_PLAYERS]; /* current Y position */
float last_x[MAX_PLAYERS]; /* last X position */
float last_y[MAX_PLAYERS]; /* last Y position */
UINT8 fade; /* color fading factor */
UINT8 animation_counter; /* animation frame index */
UINT16 auto_time; /* time in seconds to turn invisible */
UINT16 time[MAX_PLAYERS]; /* time since last movement */
char name[MAX_PLAYERS][CROSSHAIR_PIC_NAME_LENGTH + 1]; /* name of crosshair png file */
};
/***************************************************************************
GLOBAL VARIABLES
***************************************************************************/
/* global state */
static crosshair_global global;
/* raw bitmap */
static const UINT8 crosshair_raw_top[] =
{
@ -123,99 +95,22 @@ static const rgb_t crosshair_colors[] =
rgb_t(0xff,0xff,0xff)
};
//**************************************************************************
// CROSSHAIR MANAGER
//**************************************************************************
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
//-------------------------------------------------
// crosshair_manager - constructor
//-------------------------------------------------
static void crosshair_exit(running_machine &machine);
static void crosshair_load(running_machine &machine, config_type cfg_type, xml_data_node *parentnode);
static void crosshair_save(running_machine &machine, config_type cfg_type, xml_data_node *parentnode);
static void animate(running_machine &machine, screen_device &device, bool vblank_state);
/***************************************************************************
CORE IMPLEMENTATION
***************************************************************************/
/*-------------------------------------------------
create_bitmap - create the rendering
structures for the given player
-------------------------------------------------*/
static void create_bitmap(running_machine &machine, int player)
{
int x, y;
char filename[20];
rgb_t color = crosshair_colors[player];
/* if we have a bitmap and texture for this player, kill it */
if (global.bitmap[player] == nullptr) {
global.bitmap[player] = global_alloc(bitmap_argb32);
global.texture[player] = machine.render().texture_alloc(render_texture::hq_scale);
}
emu_file crossfile(machine.options().crosshair_path(), OPEN_FLAG_READ);
if (global.name[player][0] != 0)
{
/* look for user specified file */
sprintf(filename, "%s.png", global.name[player]);
render_load_png(*global.bitmap[player], crossfile, nullptr, filename);
}
else
{
/* look for default cross?.png in crsshair\game dir */
sprintf(filename, "cross%d.png", player + 1);
render_load_png(*global.bitmap[player], crossfile, machine.system().name, filename);
/* look for default cross?.png in crsshair dir */
if (!global.bitmap[player]->valid())
render_load_png(*global.bitmap[player], crossfile, nullptr, filename);
}
/* if that didn't work, use the built-in one */
if (!global.bitmap[player]->valid())
{
/* allocate a blank bitmap to start with */
global.bitmap[player]->allocate(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE);
global.bitmap[player]->fill(rgb_t(0x00,0xff,0xff,0xff));
/* extract the raw source data to it */
for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
{
/* assume it is mirrored vertically */
UINT32 *dest0 = &global.bitmap[player]->pix32(y);
UINT32 *dest1 = &global.bitmap[player]->pix32(CROSSHAIR_RAW_SIZE - 1 - y);
/* extract to two rows simultaneously */
for (x = 0; x < CROSSHAIR_RAW_SIZE; x++)
if ((crosshair_raw_top[y * CROSSHAIR_RAW_ROWBYTES + x / 8] << (x % 8)) & 0x80)
dest0[x] = dest1[x] = rgb_t(0xff,0x00,0x00,0x00) | color;
}
}
/* reference the new bitmap */
global.texture[player]->set_bitmap(*global.bitmap[player], global.bitmap[player]->cliprect(), TEXFORMAT_ARGB32);
}
/*-------------------------------------------------
crosshair_init - initialize the crosshair
bitmaps and such
-------------------------------------------------*/
void crosshair_init(running_machine &machine)
crosshair_manager::crosshair_manager(running_machine &machine)
: m_machine(machine)
{
/* request a callback upon exiting */
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(crosshair_exit), &machine));
/* clear all the globals */
memset(&global, 0, sizeof(global));
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(crosshair_manager::exit), this));
/* setup the default auto visibility time */
global.auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT;
m_auto_time = CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT;
/* determine who needs crosshairs */
for (ioport_port *port = machine.ioport().first_port(); port != nullptr; port = port->next())
@ -227,93 +122,140 @@ void crosshair_init(running_machine &machine)
assert(player < MAX_PLAYERS);
/* mark as used and set the default visibility and mode */
global.usage = TRUE;
global.used[player] = TRUE;
global.mode[player] = CROSSHAIR_VISIBILITY_DEFAULT;
global.visible[player] = (CROSSHAIR_VISIBILITY_DEFAULT == CROSSHAIR_VISIBILITY_OFF) ? FALSE : TRUE;
m_usage = TRUE;
m_used[player] = TRUE;
m_mode[player] = CROSSHAIR_VISIBILITY_DEFAULT;
m_visible[player] = (CROSSHAIR_VISIBILITY_DEFAULT == CROSSHAIR_VISIBILITY_OFF) ? FALSE : TRUE;
/* for now, use the main screen */
global.screen[player] = machine.first_screen();
m_screen[player] = machine.first_screen();
create_bitmap(machine, player);
create_bitmap(player);
}
/* register callbacks for when we load/save configurations */
if (global.usage)
machine.configuration().config_register("crosshairs", config_saveload_delegate(FUNC(crosshair_load), &machine), config_saveload_delegate(FUNC(crosshair_save), &machine));
if (m_usage)
machine.configuration().config_register("crosshairs", config_saveload_delegate(FUNC(crosshair_manager::config_load), this), config_saveload_delegate(FUNC(crosshair_manager::config_save), this));
/* register the animation callback */
if (machine.first_screen() != nullptr)
machine.first_screen()->register_vblank_callback(vblank_state_delegate(FUNC(animate), &machine));
machine.first_screen()->register_vblank_callback(vblank_state_delegate(FUNC(crosshair_manager::animate), this));
}
/*-------------------------------------------------
crosshair_exit - free memory allocated for
the crosshairs
exit - free memory allocated for
the crosshairs
-------------------------------------------------*/
static void crosshair_exit(running_machine &machine)
void crosshair_manager::exit()
{
/* free bitmaps and textures for each player */
for (int player = 0; player < MAX_PLAYERS; player++)
{
machine.render().texture_free(global.texture[player]);
global.texture[player] = nullptr;
machine().render().texture_free(m_texture[player]);
m_texture[player] = nullptr;
global_free(global.bitmap[player]);
global.bitmap[player] = nullptr;
global_free(m_bitmap[player]);
m_bitmap[player] = nullptr;
}
}
/*-------------------------------------------------
crosshair_get_usage - return TRUE
if any crosshairs are used
create_bitmap - create the rendering
structures for the given player
-------------------------------------------------*/
int crosshair_get_usage(running_machine &machine)
void crosshair_manager::create_bitmap(int player)
{
return global.usage;
int x, y;
char filename[20];
rgb_t color = crosshair_colors[player];
/* if we have a bitmap and texture for this player, kill it */
if (m_bitmap[player] == nullptr) {
m_bitmap[player] = global_alloc(bitmap_argb32);
m_texture[player] = machine().render().texture_alloc(render_texture::hq_scale);
}
emu_file crossfile(machine().options().crosshair_path(), OPEN_FLAG_READ);
if (m_name[player][0] != 0)
{
/* look for user specified file */
sprintf(filename, "%s.png", m_name[player]);
render_load_png(*m_bitmap[player], crossfile, nullptr, filename);
}
else
{
/* look for default cross?.png in crsshair\game dir */
sprintf(filename, "cross%d.png", player + 1);
render_load_png(*m_bitmap[player], crossfile, machine().system().name, filename);
/* look for default cross?.png in crsshair dir */
if (!m_bitmap[player]->valid())
render_load_png(*m_bitmap[player], crossfile, nullptr, filename);
}
/* if that didn't work, use the built-in one */
if (!m_bitmap[player]->valid())
{
/* allocate a blank bitmap to start with */
m_bitmap[player]->allocate(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE);
m_bitmap[player]->fill(rgb_t(0x00,0xff,0xff,0xff));
/* extract the raw source data to it */
for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
{
/* assume it is mirrored vertically */
UINT32 *dest0 = &m_bitmap[player]->pix32(y);
UINT32 *dest1 = &m_bitmap[player]->pix32(CROSSHAIR_RAW_SIZE - 1 - y);
/* extract to two rows simultaneously */
for (x = 0; x < CROSSHAIR_RAW_SIZE; x++)
if ((crosshair_raw_top[y * CROSSHAIR_RAW_ROWBYTES + x / 8] << (x % 8)) & 0x80)
dest0[x] = dest1[x] = rgb_t(0xff,0x00,0x00,0x00) | color;
}
}
/* reference the new bitmap */
m_texture[player]->set_bitmap(*m_bitmap[player], m_bitmap[player]->cliprect(), TEXFORMAT_ARGB32);
}
/*-------------------------------------------------
crosshair_get_user_settings - return the
get_user_settings - return the
current crosshair settings for a player
Note: auto_time is common for all players
-------------------------------------------------*/
void crosshair_get_user_settings(running_machine &machine, UINT8 player, crosshair_user_settings *settings)
void crosshair_manager::get_user_settings(UINT8 player, crosshair_user_settings *settings)
{
settings->auto_time = global.auto_time;
settings->used = global.used[player];
settings->mode = global.mode[player];
strcpy(settings->name, global.name[player]);
settings->auto_time = m_auto_time;
settings->used = m_used[player];
settings->mode = m_mode[player];
strcpy(settings->name, m_name[player]);
}
/*-------------------------------------------------
crosshair_set_user_settings - modify the
set_user_settings - modify the
current crosshair settings for a player
Note: auto_time is common for all players
-------------------------------------------------*/
void crosshair_set_user_settings(running_machine &machine, UINT8 player, crosshair_user_settings *settings)
void crosshair_manager::set_user_settings(UINT8 player, crosshair_user_settings *settings)
{
global.auto_time = settings->auto_time;
global.used[player] = settings->used;
global.mode[player] = settings->mode;
m_auto_time = settings->auto_time;
m_used[player] = settings->used;
m_mode[player] = settings->mode;
/* set visibility as specified by mode */
/* auto mode starts with visibility off */
global.visible[player] = (settings->mode == CROSSHAIR_VISIBILITY_ON) ? TRUE : FALSE;
m_visible[player] = (settings->mode == CROSSHAIR_VISIBILITY_ON) ? TRUE : FALSE;
/* update bitmap if name has changed */
int changed = strcmp(settings->name, global.name[player]);
strcpy(global.name[player], settings->name);
int changed = strcmp(settings->name, m_name[player]);
strcpy(m_name[player], settings->name);
if (changed != 0)
create_bitmap(machine, player);
create_bitmap(player);
}
@ -321,7 +263,7 @@ void crosshair_set_user_settings(running_machine &machine, UINT8 player, crossha
animate - animates the crosshair once a frame
-------------------------------------------------*/
static void animate(running_machine &machine, screen_device &device, bool vblank_state)
void crosshair_manager::animate(screen_device &device, bool vblank_state)
{
int player;
@ -330,30 +272,30 @@ static void animate(running_machine &machine, screen_device &device, bool vblank
return;
/* increment animation counter */
global.animation_counter += 0x08;
m_animation_counter += 0x08;
/* compute a fade factor from the current animation value */
if (global.animation_counter < 0x80)
global.fade = 0xa0 + (0x60 * ( global.animation_counter & 0x7f) / 0x80);
if (m_animation_counter < 0x80)
m_fade = 0xa0 + (0x60 * ( m_animation_counter & 0x7f) / 0x80);
else
global.fade = 0xa0 + (0x60 * (~global.animation_counter & 0x7f) / 0x80);
m_fade = 0xa0 + (0x60 * (~m_animation_counter & 0x7f) / 0x80);
for (player = 0; player < MAX_PLAYERS; player++)
{
/* read all the lightgun values */
if (global.used[player])
device.machine().ioport().crosshair_position(player, global.x[player], global.y[player]);
if (m_used[player])
device.machine().ioport().crosshair_position(player, m_x[player], m_y[player]);
/* auto visibility */
if (global.mode[player] == CROSSHAIR_VISIBILITY_AUTO)
if (m_mode[player] == CROSSHAIR_VISIBILITY_AUTO)
{
if ((global.x[player] != global.last_x[player]) || (global.y[player] != global.last_y[player]))
if ((m_x[player] != m_last_x[player]) || (m_y[player] != m_last_y[player]))
{
/* crosshair has moved, keep crosshair visible */
global.visible[player] = TRUE;
global.last_x[player] = global.x[player];
global.last_y[player] = global.y[player];
global.time[player] = 0;
m_visible[player] = TRUE;
m_last_x[player] = m_x[player];
m_last_y[player] = m_y[player];
m_time[player] = 0;
}
else
{
@ -361,12 +303,12 @@ static void animate(running_machine &machine, screen_device &device, bool vblank
/* slightly confusing formula, but the effect is: */
/* auto_time = 0 makes the crosshair barely visible while moved */
/* every increment in auto_time is about .2s at 60Hz */
if (global.time[player] > global.auto_time * 12 + 2)
if (m_time[player] > m_auto_time * 12 + 2)
/* time exceeded so turn crosshair invisible */
global.visible[player] = FALSE;
m_visible[player] = FALSE;
/* increment player visibility time */
global.time[player]++;
m_time[player]++;
}
}
}
@ -374,45 +316,33 @@ static void animate(running_machine &machine, screen_device &device, bool vblank
/*-------------------------------------------------
crosshair_render - render the crosshairs
render - render the crosshairs
for the given screen
-------------------------------------------------*/
void crosshair_render(screen_device &screen)
void crosshair_manager::render(screen_device &screen)
{
int player;
for (player = 0; player < MAX_PLAYERS; player++)
/* draw if visible and the right screen */
if (global.visible[player] &&
((global.screen[player] == &screen) || (global.screen[player] == CROSSHAIR_SCREEN_ALL)))
if (m_visible[player] &&
((m_screen[player] == &screen) || (m_screen[player] == CROSSHAIR_SCREEN_ALL)))
{
/* add a quad assuming a 4:3 screen (this is not perfect) */
screen.container().add_quad(global.x[player] - 0.03f, global.y[player] - 0.04f,
global.x[player] + 0.03f, global.y[player] + 0.04f,
rgb_t(0xc0, global.fade, global.fade, global.fade),
global.texture[player], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
screen.container().add_quad(m_x[player] - 0.03f, m_y[player] - 0.04f,
m_x[player] + 0.03f, m_y[player] + 0.04f,
rgb_t(0xc0, m_fade, m_fade, m_fade),
m_texture[player], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
}
}
/*-------------------------------------------------
crosshair_set_screen - sets the screen(s) for a
given player's crosshair
-------------------------------------------------*/
void crosshair_set_screen(running_machine &machine, int player, screen_device *screen)
{
global.screen[player] = screen;
}
/*-------------------------------------------------
crosshair_load - read and apply data from the
config_load - read and apply data from the
configuration file
-------------------------------------------------*/
static void crosshair_load(running_machine &machine, config_type cfg_type, xml_data_node *parentnode)
void crosshair_manager::config_load(config_type cfg_type, xml_data_node *parentnode)
{
/* Note: crosshair_load() is only registered if croshairs are used */
@ -436,22 +366,22 @@ static void crosshair_load(running_machine &machine, config_type cfg_type, xml_d
/* check to make sure we have a valid player */
/* also check if the player really uses a crosshair */
if (player >=0 && player < MAX_PLAYERS && global.used[player])
if (player >=0 && player < MAX_PLAYERS && m_used[player])
{
/* get, check, and store visibility mode */
mode = xml_get_attribute_int(crosshairnode, "mode", CROSSHAIR_VISIBILITY_DEFAULT);
if (mode >= CROSSHAIR_VISIBILITY_OFF && mode <= CROSSHAIR_VISIBILITY_AUTO)
{
global.mode[player] = (UINT8)mode;
m_mode[player] = (UINT8)mode;
/* set visibility as specified by mode */
/* auto mode starts with visibility off */
global.visible[player] = (mode == CROSSHAIR_VISIBILITY_ON) ? TRUE : FALSE;
m_visible[player] = (mode == CROSSHAIR_VISIBILITY_ON) ? TRUE : FALSE;
}
/* get and store crosshair pic name, truncate name to max length */
strncpy(global.name[player], xml_get_attribute_string(crosshairnode, "pic", ""), CROSSHAIR_PIC_NAME_LENGTH);
strncpy(m_name[player], xml_get_attribute_string(crosshairnode, "pic", ""), CROSSHAIR_PIC_NAME_LENGTH);
/* update bitmap */
create_bitmap(machine, player);
create_bitmap(player);
}
}
@ -461,17 +391,17 @@ static void crosshair_load(running_machine &machine, config_type cfg_type, xml_d
{
auto_time = xml_get_attribute_int(crosshairnode, "val", CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT);
if ((auto_time >= CROSSHAIR_VISIBILITY_AUTOTIME_MIN) && (auto_time <= CROSSHAIR_VISIBILITY_AUTOTIME_MAX))
global.auto_time = (UINT8)auto_time;
m_auto_time = (UINT8)auto_time;
}
}
/*-------------------------------------------------
crosshair_save - save data to the
config_save - save data to the
configuration file
-------------------------------------------------*/
static void crosshair_save(running_machine &machine, config_type cfg_type, xml_data_node *parentnode)
void crosshair_manager::config_save(config_type cfg_type, xml_data_node *parentnode)
{
/* Note: crosshair_save() is only registered if crosshairs are used */
@ -484,7 +414,7 @@ static void crosshair_save(running_machine &machine, config_type cfg_type, xml_d
for (player = 0; player < MAX_PLAYERS; player++)
{
if (global.used[player])
if (m_used[player])
{
/* create a node */
crosshairnode = xml_add_child(parentnode, "crosshair", nullptr);
@ -495,16 +425,16 @@ static void crosshair_save(running_machine &machine, config_type cfg_type, xml_d
xml_set_attribute_int(crosshairnode, "player", player);
if (global.visible[player] != CROSSHAIR_VISIBILITY_DEFAULT)
if (m_visible[player] != CROSSHAIR_VISIBILITY_DEFAULT)
{
xml_set_attribute_int(crosshairnode, "mode", global.mode[player]);
xml_set_attribute_int(crosshairnode, "mode", m_mode[player]);
changed = TRUE;
}
/* the default graphic name is "", so only save if not */
if (*(global.name[player]) != 0)
if (*(m_name[player]) != 0)
{
xml_set_attribute(crosshairnode, "pic", global.name[player]);
xml_set_attribute(crosshairnode, "pic", m_name[player]);
changed = TRUE;
}
@ -516,13 +446,13 @@ static void crosshair_save(running_machine &machine, config_type cfg_type, xml_d
}
/* always store autotime so that it stays at the user value if it is needed */
if (global.auto_time != CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT)
if (m_auto_time != CROSSHAIR_VISIBILITY_AUTOTIME_DEFAULT)
{
/* create a node */
crosshairnode = xml_add_child(parentnode, "autotime", nullptr);
if (crosshairnode != nullptr)
xml_set_attribute_int(crosshairnode, "val", global.auto_time);
xml_set_attribute_int(crosshairnode, "val", m_auto_time);
}
}

View File

@ -50,28 +50,57 @@ struct crosshair_user_settings
};
// ======================> crosshair_manager
/***************************************************************************
FUNCTION PROTOTYPES
***************************************************************************/
class crosshair_manager
{
public:
// construction/destruction
crosshair_manager(running_machine &machine);
/* initializes the crosshair system */
void crosshair_init(running_machine &machine);
/* draws crosshair(s) in a given screen, if necessary */
void render(screen_device &screen);
/* draws crosshair(s) in a given screen, if necessary */
void crosshair_render(screen_device &screen);
/* sets the screen(s) for a given player's crosshair */
void set_screen(int player, screen_device *screen) { m_screen[player] = screen; }
/* sets the screen(s) for a given player's crosshair */
void crosshair_set_screen(running_machine &machine, int player, screen_device *screen);
/* return TRUE if any crosshairs are used */
int get_usage() { return m_usage; }
/* return TRUE if any crosshairs are used */
int crosshair_get_usage(running_machine &machine);
/* return the current crosshair settings for the given player */
void get_user_settings(UINT8 player, crosshair_user_settings *settings);
/* return the current crosshair settings for the given player */
void crosshair_get_user_settings(running_machine &machine, UINT8 player, crosshair_user_settings *settings);
/* modify the current crosshair settings for the given player */
void set_user_settings(UINT8 player, crosshair_user_settings *settings);
// getters
running_machine &machine() const { return m_machine; }
private:
void create_bitmap(int player);
void exit();
void animate(screen_device &device, bool vblank_state);
/* modify the current crosshair settings for the given player */
void crosshair_set_user_settings(running_machine &machine, UINT8 player, crosshair_user_settings *settings);
void config_load(config_type cfg_type, xml_data_node *parentnode);
void config_save(config_type cfg_type, xml_data_node *parentnode);
// internal state
running_machine & m_machine; // reference to our machine
UINT8 m_usage; /* true if any crosshairs are used */
UINT8 m_used[MAX_PLAYERS]; /* usage per player */
UINT8 m_mode[MAX_PLAYERS]; /* visibility mode per player */
UINT8 m_visible[MAX_PLAYERS]; /* visibility per player */
bitmap_argb32 * m_bitmap[MAX_PLAYERS]; /* bitmap per player */
render_texture * m_texture[MAX_PLAYERS]; /* texture per player */
screen_device * m_screen[MAX_PLAYERS]; /* the screen on which this player's crosshair is drawn */
float m_x[MAX_PLAYERS]; /* current X position */
float m_y[MAX_PLAYERS]; /* current Y position */
float m_last_x[MAX_PLAYERS]; /* last X position */
float m_last_y[MAX_PLAYERS]; /* last Y position */
UINT8 m_fade; /* color fading factor */
UINT8 m_animation_counter; /* animation frame index */
UINT16 m_auto_time; /* time in seconds to turn invisible */
UINT16 m_time[MAX_PLAYERS]; /* time since last movement */
char m_name[MAX_PLAYERS][CROSSHAIR_PIC_NAME_LENGTH + 1]; /* name of crosshair png file */
};
#endif /* __CRSSHAIR_H__ */

View File

@ -266,7 +266,7 @@ void running_machine::start()
// initialize image devices
image_init(*this);
m_tilemap = std::make_unique<tilemap_manager>(*this);
crosshair_init(*this);
m_crosshair = make_unique_clear<crosshair_manager>(*this);
m_network = std::make_unique<network_manager>(*this);
// initialize the debugger

View File

@ -90,6 +90,7 @@ class bookkeeping_manager;
class configuration_manager;
class output_manager;
class ui_input_manager;
class crosshair_manager;
class osd_interface;
enum class config_type;
@ -173,6 +174,7 @@ public:
output_manager &output() const { assert(m_output != nullptr); return *m_output; }
ui_manager &ui() const { assert(m_ui != nullptr); return *m_ui; }
ui_input_manager &ui_input() const { assert(m_ui_input != nullptr); return *m_ui_input; }
crosshair_manager &crosshair() const { assert(m_crosshair != nullptr); return *m_crosshair; }
tilemap_manager &tilemap() const { assert(m_tilemap != nullptr); return *m_tilemap; }
debug_view_manager &debug_view() const { assert(m_debug_view != nullptr); return *m_debug_view; }
driver_device *driver_data() const { return &downcast<driver_device &>(root_device()); }
@ -290,6 +292,7 @@ private:
std::unique_ptr<bookkeeping_manager> m_bookkeeping;// internal data from bookkeeping.c
std::unique_ptr<configuration_manager> m_configuration; // internal data from config.c
std::unique_ptr<output_manager> m_output; // internal data from output.c
std::unique_ptr<crosshair_manager> m_crosshair; // internal data from crsshair.c
// system state
machine_phase m_current_phase; // current execution phase

View File

@ -125,7 +125,7 @@ void ui_menu_main::populate()
item_append("Video Options", nullptr, 0, (machine().render().target_by_index(1) != nullptr) ? (void *)VIDEO_TARGETS : (void *)VIDEO_OPTIONS);
/* add crosshair options menu */
if (crosshair_get_usage(machine()))
if (machine().crosshair().get_usage())
item_append("Crosshair Options", nullptr, 0, (void *)CROSSHAIR);
/* add cheat menu */

View File

@ -288,7 +288,7 @@ void ui_menu_crosshair::handle()
int newval = data->cur;
/* retreive the user settings */
crosshair_get_user_settings(machine(), data->player, &settings);
machine().crosshair().get_user_settings(data->player, &settings);
switch (menu_event->iptkey)
{
@ -360,7 +360,7 @@ void ui_menu_crosshair::handle()
if (changed)
{
/* save the user settings */
crosshair_set_user_settings(machine(), data->player, &settings);
machine().crosshair().set_user_settings(data->player, &settings);
/* rebuild the menu */
reset(UI_MENU_RESET_REMEMBER_POSITION);
@ -391,7 +391,7 @@ void ui_menu_crosshair::populate()
for (player = 0; player < MAX_PLAYERS; player++)
{
/* get the user settings */
crosshair_get_user_settings(machine(), player, &settings);
machine().crosshair().get_user_settings(player, &settings);
/* add menu items for usable crosshairs */
if (settings.used)
@ -502,7 +502,7 @@ void ui_menu_crosshair::populate()
if (use_auto)
{
/* any player can be used to get the autotime */
crosshair_get_user_settings(machine(), 0, &settings);
machine().crosshair().get_user_settings(0, &settings);
/* CROSSHAIR_ITEM_AUTO_TIME - allocate a data item and fill it */
data = (crosshair_item_data *)m_pool_alloc(sizeof(*data));

View File

@ -676,7 +676,7 @@ bool video_manager::finish_screen_updates()
// draw any crosshairs
for (screen_device *screen = iter.first(); screen != nullptr; screen = iter.next())
crosshair_render(*screen);
machine().crosshair().render(*screen);
return anything_changed;
}