summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
author Zsolt Vasvari <zsoltvas@mamedev.org>2008-03-11 02:41:24 +0000
committer Zsolt Vasvari <zsoltvas@mamedev.org>2008-03-11 02:41:24 +0000
commit5397db06151ae8a3473449f01038cdd99ffe80d3 (patch)
treea31482bb118623d334a5f2a7e6e3d4a48b6df49e /src
parent2a8f0936fd1b3e282bac44c6e45300a01d18960d (diff)
Moves crosshair code from video.c into its own module
Simplifies crosshair logic and makes it screen device based
Diffstat (limited to 'src')
-rw-r--r--src/emu/crsshair.c317
-rw-r--r--src/emu/crsshair.h28
-rw-r--r--src/emu/emu.mak1
-rw-r--r--src/emu/mame.c2
-rw-r--r--src/emu/mame.h1
-rw-r--r--src/emu/ui.c4
-rw-r--r--src/emu/video.c315
-rw-r--r--src/emu/video.h11
8 files changed, 362 insertions, 317 deletions
diff --git a/src/emu/crsshair.c b/src/emu/crsshair.c
new file mode 100644
index 00000000000..95ae21a02a3
--- /dev/null
+++ b/src/emu/crsshair.c
@@ -0,0 +1,317 @@
+/***************************************************************************
+
+ crsshair.h
+
+ Crosshair handling.
+
+ Copyright Nicola Salmoria and the MAME Team.
+ Visit http://mamedev.org for licensing and usage restrictions.
+
+***************************************************************************/
+
+#include "driver.h"
+#include "rendutil.h"
+
+
+
+/***************************************************************************
+ CONSTANTS
+***************************************************************************/
+
+#define CROSSHAIR_RAW_SIZE 100
+#define CROSSHAIR_RAW_ROWBYTES ((CROSSHAIR_RAW_SIZE + 7) / 8)
+
+
+/***************************************************************************
+ TYPE DEFINITIONS
+***************************************************************************/
+
+typedef struct _crosshair_global crosshair_global;
+struct _crosshair_global
+{
+ UINT8 visible; /* global visibility */
+ bitmap_t * bitmap[MAX_PLAYERS]; /* bitmap per player */
+ render_texture * texture[MAX_PLAYERS]; /* texture per player */
+ const device_config *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 */
+ UINT8 fade; /* color fading factor */
+ UINT8 animation_counter; /* animation frame index */
+};
+
+
+/***************************************************************************
+ GLOBAL VARIABLES
+***************************************************************************/
+
+/* global state */
+static crosshair_global global;
+
+/* raw bitmap */
+static const UINT8 crosshair_raw_top[] =
+{
+ 0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,
+ 0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,
+ 0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf0,0x00,
+ 0x01,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf8,0x00,
+ 0x03,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xfc,0x00,
+ 0x07,0xfe,0x00,0x00,0x00,0x0f,0xfe,0x00,0x00,0x00,0x07,0xfe,0x00,
+ 0x0f,0xff,0x00,0x00,0x01,0xff,0xff,0xf0,0x00,0x00,0x0f,0xff,0x00,
+ 0x1f,0xff,0x80,0x00,0x1f,0xff,0xff,0xff,0x00,0x00,0x1f,0xff,0x80,
+ 0x3f,0xff,0x80,0x00,0xff,0xff,0xff,0xff,0xe0,0x00,0x1f,0xff,0xc0,
+ 0x7f,0xff,0xc0,0x03,0xff,0xff,0xff,0xff,0xf8,0x00,0x3f,0xff,0xe0,
+ 0xff,0xff,0xe0,0x07,0xff,0xff,0xff,0xff,0xfc,0x00,0x7f,0xff,0xf0,
+ 0x7f,0xff,0xf0,0x1f,0xff,0xff,0xff,0xff,0xff,0x00,0xff,0xff,0xe0,
+ 0x3f,0xff,0xf8,0x7f,0xff,0xff,0xff,0xff,0xff,0xc1,0xff,0xff,0xc0,
+ 0x0f,0xff,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xe1,0xff,0xff,0x00,
+ 0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0xff,0xfe,0x00,
+ 0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,
+ 0x01,0xff,0xff,0xff,0xff,0xf0,0x01,0xff,0xff,0xff,0xff,0xf8,0x00,
+ 0x00,0x7f,0xff,0xff,0xff,0x00,0x00,0x1f,0xff,0xff,0xff,0xe0,0x00,
+ 0x00,0x3f,0xff,0xff,0xf8,0x00,0x00,0x03,0xff,0xff,0xff,0xc0,0x00,
+ 0x00,0x1f,0xff,0xff,0xe0,0x00,0x00,0x00,0xff,0xff,0xff,0x80,0x00,
+ 0x00,0x0f,0xff,0xff,0x80,0x00,0x00,0x00,0x3f,0xff,0xff,0x00,0x00,
+ 0x00,0x03,0xff,0xfe,0x00,0x00,0x00,0x00,0x0f,0xff,0xfc,0x00,0x00,
+ 0x00,0x01,0xff,0xfc,0x00,0x00,0x00,0x00,0x07,0xff,0xf8,0x00,0x00,
+ 0x00,0x03,0xff,0xf8,0x00,0x00,0x00,0x00,0x01,0xff,0xf8,0x00,0x00,
+ 0x00,0x07,0xff,0xfc,0x00,0x00,0x00,0x00,0x03,0xff,0xfc,0x00,0x00,
+ 0x00,0x0f,0xff,0xfe,0x00,0x00,0x00,0x00,0x07,0xff,0xfe,0x00,0x00,
+ 0x00,0x0f,0xff,0xff,0x00,0x00,0x00,0x00,0x0f,0xff,0xfe,0x00,0x00,
+ 0x00,0x1f,0xff,0xff,0x80,0x00,0x00,0x00,0x1f,0xff,0xff,0x00,0x00,
+ 0x00,0x1f,0xff,0xff,0x80,0x00,0x00,0x00,0x1f,0xff,0xff,0x00,0x00,
+ 0x00,0x3f,0xfe,0xff,0xc0,0x00,0x00,0x00,0x3f,0xff,0xff,0x80,0x00,
+ 0x00,0x7f,0xfc,0x7f,0xe0,0x00,0x00,0x00,0x7f,0xe7,0xff,0xc0,0x00,
+ 0x00,0x7f,0xf8,0x3f,0xf0,0x00,0x00,0x00,0xff,0xc3,0xff,0xc0,0x00,
+ 0x00,0xff,0xf8,0x1f,0xf8,0x00,0x00,0x01,0xff,0x83,0xff,0xe0,0x00,
+ 0x00,0xff,0xf0,0x07,0xf8,0x00,0x00,0x01,0xfe,0x01,0xff,0xe0,0x00,
+ 0x00,0xff,0xf0,0x03,0xfc,0x00,0x00,0x03,0xfc,0x01,0xff,0xe0,0x00,
+ 0x01,0xff,0xe0,0x01,0xfe,0x00,0x00,0x07,0xf8,0x00,0xff,0xf0,0x00,
+ 0x01,0xff,0xe0,0x00,0xff,0x00,0x00,0x0f,0xf0,0x00,0xff,0xf0,0x00,
+ 0x01,0xff,0xc0,0x00,0x3f,0x80,0x00,0x1f,0xc0,0x00,0x7f,0xf0,0x00,
+ 0x01,0xff,0xc0,0x00,0x1f,0x80,0x00,0x1f,0x80,0x00,0x7f,0xf0,0x00,
+ 0x03,0xff,0xc0,0x00,0x0f,0xc0,0x00,0x3f,0x00,0x00,0x7f,0xf8,0x00,
+ 0x03,0xff,0x80,0x00,0x07,0xe0,0x00,0x7e,0x00,0x00,0x3f,0xf8,0x00,
+ 0x03,0xff,0x80,0x00,0x01,0xf0,0x00,0xf8,0x00,0x00,0x3f,0xf8,0x00,
+ 0x03,0xff,0x80,0x00,0x00,0xf8,0x01,0xf0,0x00,0x00,0x3f,0xf8,0x00,
+ 0x03,0xff,0x80,0x00,0x00,0x78,0x01,0xe0,0x00,0x00,0x3f,0xf8,0x00,
+ 0x07,0xff,0x00,0x00,0x00,0x3c,0x03,0xc0,0x00,0x00,0x3f,0xfc,0x00,
+ 0x07,0xff,0x00,0x00,0x00,0x0e,0x07,0x00,0x00,0x00,0x1f,0xfc,0x00,
+ 0x07,0xff,0x00,0x00,0x00,0x07,0x0e,0x00,0x00,0x00,0x1f,0xfc,0x00,
+ 0x07,0xff,0x00,0x00,0x00,0x03,0x9c,0x00,0x00,0x00,0x1f,0xfc,0x00,
+ 0x07,0xff,0x00,0x00,0x00,0x01,0x98,0x00,0x00,0x00,0x1f,0xfc,0x00,
+ 0x07,0xff,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x1f,0xfc,0x00
+};
+
+/* per-player colors */
+static const rgb_t crosshair_colors[] =
+{
+ MAKE_RGB(0x40,0x40,0xff),
+ MAKE_RGB(0xff,0x40,0x40),
+ MAKE_RGB(0x40,0xff,0x40),
+ MAKE_RGB(0xff,0xff,0x40),
+ MAKE_RGB(0xff,0x40,0xff),
+ MAKE_RGB(0x40,0xff,0xff),
+ MAKE_RGB(0xff,0xff,0xff)
+};
+
+
+/***************************************************************************
+ FUNCTION PROTOTYPES
+***************************************************************************/
+
+static void crosshair_exit(running_machine *machine);
+static void animate(const device_config *device, int vblank_state);
+
+
+/***************************************************************************
+ CORE IMPLEMENTATION
+***************************************************************************/
+
+
+/*-------------------------------------------------
+ create_bitmap - create the rendering
+ structures for the given player
+-------------------------------------------------*/
+
+static void create_bitmap(int player)
+{
+ char filename[20];
+
+ /* first try to load a bitmap for the crosshair */
+ sprintf(filename, "cross%d.png", player);
+ global.bitmap[player] = render_load_png(NULL, filename, NULL, NULL);
+
+ /* if that didn't work, use the built-in one */
+ if (global.bitmap[player] == NULL)
+ {
+ rgb_t color = crosshair_colors[player];
+ int x, y;
+
+ /* allocate a blank bitmap to start with */
+ global.bitmap[player] = bitmap_alloc(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE, BITMAP_FORMAT_ARGB32);
+ fillbitmap(global.bitmap[player], MAKE_ARGB(0x00,0xff,0xff,0xff), NULL);
+
+ /* extract the raw source data to it */
+ for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
+ {
+ /* assume it is mirrored vertically */
+ UINT32 *dest0 = BITMAP_ADDR32(global.bitmap[player], y, 0);
+ UINT32 *dest1 = BITMAP_ADDR32(global.bitmap[player], CROSSHAIR_RAW_SIZE - 1 - y, 0);
+
+ /* 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] = MAKE_ARGB(0xff,0x00,0x00,0x00) | color;
+ }
+ }
+
+ /* create a texture to reference the bitmap */
+ global.texture[player] = render_texture_alloc(render_texture_hq_scale, NULL);
+ render_texture_set_bitmap(global.texture[player], global.bitmap[player], NULL, 0, TEXFORMAT_ARGB32);
+}
+
+
+/*-------------------------------------------------
+ crosshair_init - initialize the crosshair
+ bitmaps and such
+-------------------------------------------------*/
+
+void crosshair_init(running_machine *machine)
+{
+ input_port_entry *ipt;
+
+ /* request a callback upon exiting */
+ add_exit_callback(machine, crosshair_exit);
+
+ /* visible by default */
+ global.visible = TRUE;
+
+ /* determine who needs crosshairs */
+ for (ipt = machine->input_ports; ipt->type != IPT_END; ipt++)
+ if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE)
+ {
+ int player = ipt->player;
+
+ /* for now, use the main screen */
+ global.screen[player] = machine->primary_screen;
+
+ create_bitmap(player);
+ }
+
+ /* register the animation callback */
+ if (machine->primary_screen != NULL)
+ video_screen_register_vbl_cb(machine->primary_screen, animate);
+}
+
+
+/*-------------------------------------------------
+ crosshair_exit - free memory allocated for
+ the crosshairs
+-------------------------------------------------*/
+
+static void crosshair_exit(running_machine *machine)
+{
+ int player;
+
+ /* free bitmaps and textures for each player */
+ for (player = 0; player < MAX_PLAYERS; player++)
+ {
+ if (global.texture[player] != NULL)
+ render_texture_free(global.texture[player]);
+ global.texture[player] = NULL;
+
+ if (global.bitmap[player] != NULL)
+ bitmap_free(global.bitmap[player]);
+ global.bitmap[player] = NULL;
+ }
+}
+
+
+/*-------------------------------------------------
+ crosshair_toggle - toggle crosshair
+ visibility
+-------------------------------------------------*/
+
+void crosshair_toggle(running_machine *machine)
+{
+ global.visible = !global.visible;
+}
+
+
+/*-------------------------------------------------
+ animate - animates the crosshair once a frame
+-------------------------------------------------*/
+
+static void animate(const device_config *device, int vblank_state)
+{
+ input_port_entry *ipt;
+ int portnum = -1;
+
+ /* increment animation counter */
+ global.animation_counter += 0x04;
+
+ /* compute a fade factor from the current animation value */
+ if (global.animation_counter < 0x80)
+ global.fade = 0xa0 + (0x60 * ( global.animation_counter & 0x7f) / 0x80);
+ else
+ global.fade = 0xa0 + (0x60 * (~global.animation_counter & 0x7f) / 0x80);
+
+ /* read all the lightgun values */
+ for (ipt = device->machine->input_ports; ipt->type != IPT_END; ipt++)
+ {
+ /* keep track of the port number */
+ if (ipt->type == IPT_PORT)
+ portnum++;
+
+ /* compute the values */
+ if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE)
+ {
+ float value = (float)(get_crosshair_pos(portnum, ipt->player, ipt->analog.crossaxis) - ipt->analog.min) / (float)(ipt->analog.max - ipt->analog.min);
+ if (ipt->analog.crossscale < 0)
+ value = -(1.0 - value) * ipt->analog.crossscale;
+ else
+ value *= ipt->analog.crossscale;
+ value += ipt->analog.crossoffset;
+
+ /* switch off the axis */
+ switch (ipt->analog.crossaxis)
+ {
+ case CROSSHAIR_AXIS_X:
+ global.x[ipt->player] = value;
+ if (ipt->analog.crossaltaxis != 0)
+ global.y[ipt->player] = ipt->analog.crossaltaxis;
+ break;
+
+ case CROSSHAIR_AXIS_Y:
+ global.y[ipt->player] = value;
+ if (ipt->analog.crossaltaxis != 0)
+ global.x[ipt->player] = ipt->analog.crossaltaxis;
+ break;
+ }
+ }
+ }
+}
+
+
+/*-------------------------------------------------
+ crosshair_render - render the crosshairs
+ for the given screen
+-------------------------------------------------*/
+
+void crosshair_render(const device_config *screen)
+{
+ int player;
+
+ /* skip if not visible */
+ if (global.visible)
+ for (player = 0; player < MAX_PLAYERS; player++)
+ if (global.screen[player] == screen)
+ {
+ /* add a quad assuming a 4:3 screen (this is not perfect) */
+ render_screen_add_quad(screen,
+ global.x[player] - 0.03f, global.y[player] - 0.04f,
+ global.x[player] + 0.03f, global.y[player] + 0.04f,
+ MAKE_ARGB(0xc0, global.fade, global.fade, global.fade),
+ global.texture[player], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
+ }
+}
diff --git a/src/emu/crsshair.h b/src/emu/crsshair.h
new file mode 100644
index 00000000000..48418ef2e2f
--- /dev/null
+++ b/src/emu/crsshair.h
@@ -0,0 +1,28 @@
+/***************************************************************************
+
+ crsshair.h
+
+ Crosshair handling.
+
+ Copyright Nicola Salmoria and the MAME Team.
+ Visit http://mamedev.org for licensing and usage restrictions.
+
+***************************************************************************/
+
+#pragma once
+
+#ifndef __CRSSHAIR_H__
+#define __CRSSHAIR_H__
+
+
+/* initializes the crosshair system */
+void crosshair_init(running_machine *machine);
+
+/* draws crosshair(s) in a given screen, if neccessary */
+void crosshair_render(const device_config *screen);
+
+/* toggles crosshair visibility */
+void crosshair_toggle(running_machine *machine);
+
+
+#endif /* __CRSSHAIR_H__ */
diff --git a/src/emu/emu.mak b/src/emu/emu.mak
index 094059bbbda..72abf481aef 100644
--- a/src/emu/emu.mak
+++ b/src/emu/emu.mak
@@ -44,6 +44,7 @@ EMUOBJS = \
$(EMUOBJ)/cpuexec.o \
$(EMUOBJ)/cpuint.o \
$(EMUOBJ)/cpuintrf.o \
+ $(EMUOBJ)/crsshair.o \
$(EMUOBJ)/devintrf.o \
$(EMUOBJ)/drawgfx.o \
$(EMUOBJ)/driver.o \
diff --git a/src/emu/mame.c b/src/emu/mame.c
index 5742ece9c57..aa811ba4bd1 100644
--- a/src/emu/mame.c
+++ b/src/emu/mame.c
@@ -51,6 +51,7 @@
- calls the driver's DRIVER_INIT callback
- calls device_list_start() [devintrf.c] to start any devices
- calls video_init() [video.c] to start the video system
+ - calls crosshair_init() [crsshair.c] to configure the crosshairs
- calls sound_init() [sound.c] to start the audio system
- calls mame_debug_init() [debugcpu.c] to set up the debugger
- calls the driver's MACHINE_START, SOUND_START, and VIDEO_START callbacks
@@ -1579,6 +1580,7 @@ static void init_machine(running_machine *machine)
/* start the video and audio hardware */
video_init(machine);
+ crosshair_init(machine);
sound_init(machine);
input_port_post_init(machine);
diff --git a/src/emu/mame.h b/src/emu/mame.h
index 46550f8aa57..3a333e99bd2 100644
--- a/src/emu/mame.h
+++ b/src/emu/mame.h
@@ -14,6 +14,7 @@
#include "mamecore.h"
#include "video.h"
+#include "crsshair.h"
#include "restrack.h"
#include "options.h"
#include <stdarg.h>
diff --git a/src/emu/ui.c b/src/emu/ui.c
index 0c94c82f231..d20ca508d08 100644
--- a/src/emu/ui.c
+++ b/src/emu/ui.c
@@ -1220,7 +1220,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
/* first draw the FPS counter */
if (showfps || osd_ticks() < showfps_end)
{
- ui_draw_text_full(video_get_speed_text(), 0.0f, 0.0f, 1.0f,
+ ui_draw_text_full(video_get_speed_text(machine), 0.0f, 0.0f, 1.0f,
JUSTIFY_RIGHT, WRAP_WORD, DRAW_OPAQUE, ARGB_WHITE, ARGB_BLACK, NULL, NULL);
}
else
@@ -1334,7 +1334,7 @@ static UINT32 handler_ingame(running_machine *machine, UINT32 state)
/* toggle crosshair display */
if (input_ui_pressed(IPT_UI_TOGGLE_CROSSHAIR))
- video_crosshair_toggle();
+ crosshair_toggle(machine);
/* increment frameskip? */
if (input_ui_pressed(IPT_UI_FRAMESKIP_INC))
diff --git a/src/emu/video.c b/src/emu/video.c
index dc26bc70b10..231aca3b838 100644
--- a/src/emu/video.c
+++ b/src/emu/video.c
@@ -10,7 +10,6 @@
***************************************************************************/
#include "driver.h"
-#include "deprecat.h"
#include "profiler.h"
#include "png.h"
#include "debugger.h"
@@ -126,13 +125,6 @@ struct _video_global
render_target * snap_target; /* screen shapshot target */
bitmap_t * snap_bitmap; /* screen snapshot bitmap */
- /* crosshair bits */
- bitmap_t * crosshair_bitmap[MAX_PLAYERS]; /* crosshair bitmap per player */
- render_texture * crosshair_texture[MAX_PLAYERS]; /* crosshair texture per player */
- UINT8 crosshair_animate; /* animation frame index */
- UINT8 crosshair_visible; /* crosshair visible mask */
- UINT8 crosshair_needed; /* crosshair needed mask */
-
/* global VBLANK callbacks */
vblank_state_changed_global_func vbl_cbs[MAX_VBL_CB]; /* the array of callbacks */
};
@@ -143,7 +135,7 @@ struct _video_global
GLOBAL VARIABLES
***************************************************************************/
-/* global video state */
+/* global state */
static video_global global;
/* frameskipping tables */
@@ -197,11 +189,6 @@ static file_error mame_fopen_next(running_machine *machine, const char *pathopti
/* movie recording */
static void movie_record_frame(const device_config *screen);
-/* crosshair rendering */
-static void crosshair_init(running_machine *machine);
-static void crosshair_render(running_machine *machine);
-static void crosshair_free(void);
-
/* software rendering */
static void rgb888_draw_primitives(const render_primitive *primlist, void *dstdata, UINT32 width, UINT32 height, UINT32 pitch);
@@ -295,6 +282,9 @@ void video_init(running_machine *machine)
const device_config *screen;
const char *filename;
+ /* request a callback upon exiting */
+ add_exit_callback(machine, video_exit);
+
/* reset our global state */
memset(&global, 0, sizeof(global));
global.speed_percent = 1.0;
@@ -309,9 +299,6 @@ void video_init(running_machine *machine)
global.refresh_speed = options_get_bool(mame_options(), OPTION_REFRESHSPEED);
global.update_in_pause = options_get_bool(mame_options(), OPTION_UPDATEINPAUSE);
- /* request a callback upon exiting */
- add_exit_callback(machine, video_exit);
-
/* set the first screen device as the primary - this will set NULL if screenless */
machine->primary_screen = video_screen_first(machine->config);
@@ -403,9 +390,6 @@ void video_init(running_machine *machine)
render_target_set_layer_config(global.snap_target, 0);
}
- /* create crosshairs */
- crosshair_init(machine);
-
/* start recording movie if specified */
filename = options_get_string(mame_options(), OPTION_MNGWRITE);
if ((filename[0] != 0) && (machine->primary_screen != NULL))
@@ -422,9 +406,6 @@ static void video_exit(running_machine *machine)
const device_config *screen;
int i;
- /* free crosshairs */
- crosshair_free();
-
/* stop recording any movie */
if (machine->primary_screen != NULL)
video_movie_end_recording(machine->primary_screen);
@@ -1527,7 +1508,9 @@ static int finish_screen_updates(running_machine *machine)
}
/* draw any crosshairs */
- crosshair_render(machine);
+ for (screen = video_screen_first(machine->config); screen != NULL; screen = video_screen_next(screen))
+ crosshair_render(screen);
+
return anything_changed;
}
@@ -1575,9 +1558,9 @@ void video_set_speed_factor(int speed)
be displayed in the upper-right corner
-------------------------------------------------*/
-const char *video_get_speed_text(void)
+const char *video_get_speed_text(running_machine *machine)
{
- int paused = mame_is_paused(Machine);
+ int paused = mame_is_paused(machine);
static char buffer[1024];
char *dest = buffer;
@@ -1590,7 +1573,7 @@ const char *video_get_speed_text(void)
dest += sprintf(dest, "fast ");
/* if we're auto frameskipping, display that plus the level */
- else if (effective_autoframeskip(Machine))
+ else if (effective_autoframeskip(machine))
dest += sprintf(dest, "auto%2d/%d", effective_frameskip(), MAX_FRAMESKIP);
/* otherwise, just display the frameskip plus the level */
@@ -2297,284 +2280,6 @@ static void movie_record_frame(const device_config *screen)
/***************************************************************************
- CROSSHAIR RENDERING
-***************************************************************************/
-
-/* decripton of the bitmap data */
-#define CROSSHAIR_RAW_SIZE 100
-#define CROSSHAIR_RAW_ROWBYTES ((CROSSHAIR_RAW_SIZE + 7) / 8)
-
-/* raw bitmap */
-static const UINT8 crosshair_raw_top[] =
-{
- 0x00,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,
- 0x00,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xe0,0x00,
- 0x00,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf0,0x00,
- 0x01,0xf8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xf8,0x00,
- 0x03,0xfc,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x03,0xfc,0x00,
- 0x07,0xfe,0x00,0x00,0x00,0x0f,0xfe,0x00,0x00,0x00,0x07,0xfe,0x00,
- 0x0f,0xff,0x00,0x00,0x01,0xff,0xff,0xf0,0x00,0x00,0x0f,0xff,0x00,
- 0x1f,0xff,0x80,0x00,0x1f,0xff,0xff,0xff,0x00,0x00,0x1f,0xff,0x80,
- 0x3f,0xff,0x80,0x00,0xff,0xff,0xff,0xff,0xe0,0x00,0x1f,0xff,0xc0,
- 0x7f,0xff,0xc0,0x03,0xff,0xff,0xff,0xff,0xf8,0x00,0x3f,0xff,0xe0,
- 0xff,0xff,0xe0,0x07,0xff,0xff,0xff,0xff,0xfc,0x00,0x7f,0xff,0xf0,
- 0x7f,0xff,0xf0,0x1f,0xff,0xff,0xff,0xff,0xff,0x00,0xff,0xff,0xe0,
- 0x3f,0xff,0xf8,0x7f,0xff,0xff,0xff,0xff,0xff,0xc1,0xff,0xff,0xc0,
- 0x0f,0xff,0xf8,0xff,0xff,0xff,0xff,0xff,0xff,0xe1,0xff,0xff,0x00,
- 0x07,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfb,0xff,0xfe,0x00,
- 0x03,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0x00,
- 0x01,0xff,0xff,0xff,0xff,0xf0,0x01,0xff,0xff,0xff,0xff,0xf8,0x00,
- 0x00,0x7f,0xff,0xff,0xff,0x00,0x00,0x1f,0xff,0xff,0xff,0xe0,0x00,
- 0x00,0x3f,0xff,0xff,0xf8,0x00,0x00,0x03,0xff,0xff,0xff,0xc0,0x00,
- 0x00,0x1f,0xff,0xff,0xe0,0x00,0x00,0x00,0xff,0xff,0xff,0x80,0x00,
- 0x00,0x0f,0xff,0xff,0x80,0x00,0x00,0x00,0x3f,0xff,0xff,0x00,0x00,
- 0x00,0x03,0xff,0xfe,0x00,0x00,0x00,0x00,0x0f,0xff,0xfc,0x00,0x00,
- 0x00,0x01,0xff,0xfc,0x00,0x00,0x00,0x00,0x07,0xff,0xf8,0x00,0x00,
- 0x00,0x03,0xff,0xf8,0x00,0x00,0x00,0x00,0x01,0xff,0xf8,0x00,0x00,
- 0x00,0x07,0xff,0xfc,0x00,0x00,0x00,0x00,0x03,0xff,0xfc,0x00,0x00,
- 0x00,0x0f,0xff,0xfe,0x00,0x00,0x00,0x00,0x07,0xff,0xfe,0x00,0x00,
- 0x00,0x0f,0xff,0xff,0x00,0x00,0x00,0x00,0x0f,0xff,0xfe,0x00,0x00,
- 0x00,0x1f,0xff,0xff,0x80,0x00,0x00,0x00,0x1f,0xff,0xff,0x00,0x00,
- 0x00,0x1f,0xff,0xff,0x80,0x00,0x00,0x00,0x1f,0xff,0xff,0x00,0x00,
- 0x00,0x3f,0xfe,0xff,0xc0,0x00,0x00,0x00,0x3f,0xff,0xff,0x80,0x00,
- 0x00,0x7f,0xfc,0x7f,0xe0,0x00,0x00,0x00,0x7f,0xe7,0xff,0xc0,0x00,
- 0x00,0x7f,0xf8,0x3f,0xf0,0x00,0x00,0x00,0xff,0xc3,0xff,0xc0,0x00,
- 0x00,0xff,0xf8,0x1f,0xf8,0x00,0x00,0x01,0xff,0x83,0xff,0xe0,0x00,
- 0x00,0xff,0xf0,0x07,0xf8,0x00,0x00,0x01,0xfe,0x01,0xff,0xe0,0x00,
- 0x00,0xff,0xf0,0x03,0xfc,0x00,0x00,0x03,0xfc,0x01,0xff,0xe0,0x00,
- 0x01,0xff,0xe0,0x01,0xfe,0x00,0x00,0x07,0xf8,0x00,0xff,0xf0,0x00,
- 0x01,0xff,0xe0,0x00,0xff,0x00,0x00,0x0f,0xf0,0x00,0xff,0xf0,0x00,
- 0x01,0xff,0xc0,0x00,0x3f,0x80,0x00,0x1f,0xc0,0x00,0x7f,0xf0,0x00,
- 0x01,0xff,0xc0,0x00,0x1f,0x80,0x00,0x1f,0x80,0x00,0x7f,0xf0,0x00,
- 0x03,0xff,0xc0,0x00,0x0f,0xc0,0x00,0x3f,0x00,0x00,0x7f,0xf8,0x00,
- 0x03,0xff,0x80,0x00,0x07,0xe0,0x00,0x7e,0x00,0x00,0x3f,0xf8,0x00,
- 0x03,0xff,0x80,0x00,0x01,0xf0,0x00,0xf8,0x00,0x00,0x3f,0xf8,0x00,
- 0x03,0xff,0x80,0x00,0x00,0xf8,0x01,0xf0,0x00,0x00,0x3f,0xf8,0x00,
- 0x03,0xff,0x80,0x00,0x00,0x78,0x01,0xe0,0x00,0x00,0x3f,0xf8,0x00,
- 0x07,0xff,0x00,0x00,0x00,0x3c,0x03,0xc0,0x00,0x00,0x3f,0xfc,0x00,
- 0x07,0xff,0x00,0x00,0x00,0x0e,0x07,0x00,0x00,0x00,0x1f,0xfc,0x00,
- 0x07,0xff,0x00,0x00,0x00,0x07,0x0e,0x00,0x00,0x00,0x1f,0xfc,0x00,
- 0x07,0xff,0x00,0x00,0x00,0x03,0x9c,0x00,0x00,0x00,0x1f,0xfc,0x00,
- 0x07,0xff,0x00,0x00,0x00,0x01,0x98,0x00,0x00,0x00,0x1f,0xfc,0x00,
- 0x07,0xff,0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,0x1f,0xfc,0x00
-};
-
-/* per-player colors */
-static const rgb_t crosshair_colors[] =
-{
- MAKE_RGB(0x40,0x40,0xff),
- MAKE_RGB(0xff,0x40,0x40),
- MAKE_RGB(0x40,0xff,0x40),
- MAKE_RGB(0xff,0xff,0x40),
- MAKE_RGB(0xff,0x40,0xff),
- MAKE_RGB(0x40,0xff,0xff),
- MAKE_RGB(0xff,0xff,0xff)
-};
-
-
-/*-------------------------------------------------
- crosshair_init - initialize the crosshair
- bitmaps and such
--------------------------------------------------*/
-
-static void crosshair_init(running_machine *machine)
-{
- input_port_entry *ipt;
- int player;
-
- /* determine who needs crosshairs */
- global.crosshair_needed = 0x00;
- for (ipt = machine->input_ports; ipt->type != IPT_END; ipt++)
- if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE)
- global.crosshair_needed |= 1 << ipt->player;
-
- /* all visible by default */
- global.crosshair_visible = global.crosshair_needed;
-
- /* loop over each player and load or create a bitmap */
- for (player = 0; player < MAX_PLAYERS; player++)
- if (global.crosshair_needed & (1 << player))
- {
- char filename[20];
-
- /* first try to load a bitmap for the crosshair */
- sprintf(filename, "cross%d.png", player);
- global.crosshair_bitmap[player] = render_load_png(NULL, filename, NULL, NULL);
-
- /* if that didn't work, make one up */
- if (global.crosshair_bitmap[player] == NULL)
- {
- rgb_t color = crosshair_colors[player];
- int x, y;
-
- /* allocate a blank bitmap to start with */
- global.crosshair_bitmap[player] = bitmap_alloc(CROSSHAIR_RAW_SIZE, CROSSHAIR_RAW_SIZE, BITMAP_FORMAT_ARGB32);
- fillbitmap(global.crosshair_bitmap[player], MAKE_ARGB(0x00,0xff,0xff,0xff), NULL);
-
- /* extract the raw source data to it */
- for (y = 0; y < CROSSHAIR_RAW_SIZE / 2; y++)
- {
- /* assume it is mirrored vertically */
- UINT32 *dest0 = BITMAP_ADDR32(global.crosshair_bitmap[player], y, 0);
- UINT32 *dest1 = BITMAP_ADDR32(global.crosshair_bitmap[player], CROSSHAIR_RAW_SIZE - 1 - y, 0);
-
- /* 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] = MAKE_ARGB(0xff,0x00,0x00,0x00) | color;
- }
- }
-
- /* create a texture to reference the bitmap */
- global.crosshair_texture[player] = render_texture_alloc(render_texture_hq_scale, NULL);
- render_texture_set_bitmap(global.crosshair_texture[player], global.crosshair_bitmap[player], NULL, 0, TEXFORMAT_ARGB32);
- }
-}
-
-
-/*-------------------------------------------------
- video_crosshair_toggle - toggle crosshair
- visibility
--------------------------------------------------*/
-
-void video_crosshair_toggle(void)
-{
- int player;
-
- /* if we're all visible, turn all off */
- if (global.crosshair_visible == global.crosshair_needed)
- global.crosshair_visible = 0;
-
- /* otherwise, turn on the first bit that isn't currently on and stop there */
- else
- for (player = 0; player < MAX_PLAYERS; player++)
- if ((global.crosshair_needed & (1 << player)) && !(global.crosshair_visible & (1 << player)))
- {
- global.crosshair_visible |= 1 << player;
- break;
- }
-}
-
-
-/*-------------------------------------------------
- get_crosshair_screen_mask - returns a bitmask
- indicating on which screens the crosshair for
- a player's should be displayed
--------------------------------------------------*/
-
-static UINT32 get_crosshair_screen_mask(int player)
-{
- return (global.crosshair_visible & (1 << player)) ? 1 : 0;
-}
-
-
-/*-------------------------------------------------
- crosshair_render - render the crosshairs
--------------------------------------------------*/
-
-static void crosshair_render(running_machine *machine)
-{
- float x[MAX_PLAYERS], y[MAX_PLAYERS];
- input_port_entry *ipt;
- int portnum = -1;
- int player;
- UINT8 tscale;
-
- /* skip if not needed */
- if (global.crosshair_visible == 0)
- return;
-
- /* animate via crosshair_animate */
- global.crosshair_animate += 0x04;
-
- /* compute a color scaling factor from the current animation value */
- if (global.crosshair_animate < 0x80)
- tscale = 0xa0 + (0x60 * ( global.crosshair_animate & 0x7f) / 0x80);
- else
- tscale = 0xa0 + (0x60 * (~global.crosshair_animate & 0x7f) / 0x80);
-
- /* read all the lightgun values */
- for (ipt = machine->input_ports; ipt->type != IPT_END; ipt++)
- {
- /* keep track of the port number */
- if (ipt->type == IPT_PORT)
- portnum++;
-
- /* compute the values */
- if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE)
- {
- float value = (float)(get_crosshair_pos(portnum, ipt->player, ipt->analog.crossaxis) - ipt->analog.min) / (float)(ipt->analog.max - ipt->analog.min);
- if (ipt->analog.crossscale < 0)
- value = -(1.0 - value) * ipt->analog.crossscale;
- else
- value *= ipt->analog.crossscale;
- value += ipt->analog.crossoffset;
-
- /* switch off the axis */
- switch (ipt->analog.crossaxis)
- {
- case CROSSHAIR_AXIS_X:
- x[ipt->player] = value;
- if (ipt->analog.crossaltaxis != 0)
- y[ipt->player] = ipt->analog.crossaltaxis;
- break;
-
- case CROSSHAIR_AXIS_Y:
- y[ipt->player] = value;
- if (ipt->analog.crossaltaxis != 0)
- x[ipt->player] = ipt->analog.crossaltaxis;
- break;
- }
- }
- }
-
- /* draw all crosshairs */
- for (player = 0; player < MAX_PLAYERS; player++)
- {
- const device_config *screen;
- int scrnum;
-
- UINT32 scrmask = get_crosshair_screen_mask(player);
-
- for (screen = video_screen_first(machine->config), scrnum = 0; screen != NULL; screen = video_screen_next(screen), scrnum++)
- if (scrmask & (1 << scrnum))
- {
- /* add a quad assuming a 4:3 screen (this is not perfect) */
- render_screen_add_quad(screen,
- x[player] - 0.03f, y[player] - 0.04f,
- x[player] + 0.03f, y[player] + 0.04f,
- MAKE_ARGB(0xc0, tscale, tscale, tscale),
- global.crosshair_texture[player], PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA));
- }
- }
-}
-
-
-/*-------------------------------------------------
- crosshair_free - free memory allocated for
- the crosshairs
--------------------------------------------------*/
-
-static void crosshair_free(void)
-{
- int player;
-
- /* free bitmaps and textures for each player */
- for (player = 0; player < MAX_PLAYERS; player++)
- {
- if (global.crosshair_texture[player] != NULL)
- render_texture_free(global.crosshair_texture[player]);
- global.crosshair_texture[player] = NULL;
-
- if (global.crosshair_bitmap[player] != NULL)
- bitmap_free(global.crosshair_bitmap[player]);
- global.crosshair_bitmap[player] = NULL;
- }
-}
-
-
-
-/***************************************************************************
SOFTWARE RENDERING
***************************************************************************/
diff --git a/src/emu/video.h b/src/emu/video.h
index ff28fca4367..211f8a8414a 100644
--- a/src/emu/video.h
+++ b/src/emu/video.h
@@ -14,10 +14,6 @@
#ifndef __VIDEO_H__
#define __VIDEO_H__
-#include "mamecore.h"
-#include "devintrf.h"
-#include "timer.h"
-
/***************************************************************************
CONSTANTS
@@ -195,7 +191,7 @@ int video_get_speed_factor(void);
void video_set_speed_factor(int speed);
/* return text to display about the current speed */
-const char *video_get_speed_text(void);
+const char *video_get_speed_text(running_machine *machine);
/* get/set the current frameskip (-1 means auto) */
int video_get_frameskip(void);
@@ -226,9 +222,4 @@ void video_movie_begin_recording(const device_config *screen, const char *name);
void video_movie_end_recording(const device_config *screen);
-/* ----- crosshair rendering ----- */
-
-void video_crosshair_toggle(void);
-
-
#endif /* __VIDEO_H__ */