summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2006-09-25 18:04:29 +0000
committerSimon Howard2006-09-25 18:04:29 +0000
commitb7fced59e1d1690842f7ac8f286eb89d4c976189 (patch)
tree3ea6f0401c5f5c56be86c8c3ebf3554b9ad06c00 /src
parent9a5c207939ed554e8ac00587cce3ec83798cfbc1 (diff)
downloadchocolate-doom-b7fced59e1d1690842f7ac8f286eb89d4c976189.tar.gz
chocolate-doom-b7fced59e1d1690842f7ac8f286eb89d4c976189.tar.bz2
chocolate-doom-b7fced59e1d1690842f7ac8f286eb89d4c976189.zip
Add "test controls" mode - for setup.exe in the future. Start straight
into the game with no melt effect and display a box showing mouse speed to allow the threshold to be set easily. When escape is pressed, quit straight away. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 662
Diffstat (limited to 'src')
-rw-r--r--src/d_main.c25
-rw-r--r--src/doomstat.h4
-rw-r--r--src/g_game.c134
-rw-r--r--src/g_game.h3
-rw-r--r--src/i_system.c6
-rw-r--r--src/m_menu.c8
6 files changed, 166 insertions, 14 deletions
diff --git a/src/d_main.c b/src/d_main.c
index 6d1675c4..a23be747 100644
--- a/src/d_main.c
+++ b/src/d_main.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: d_main.c 653 2006-09-22 20:32:00Z fraggle $
+// $Id: d_main.c 662 2006-09-25 18:04:29Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -184,7 +184,7 @@
//-----------------------------------------------------------------------------
-static const char rcsid[] = "$Id: d_main.c 653 2006-09-22 20:32:00Z fraggle $";
+static const char rcsid[] = "$Id: d_main.c 662 2006-09-25 18:04:29Z fraggle $";
#define BGCOLOR 7
#define FGCOLOR 8
@@ -500,6 +500,13 @@ void D_Display (void)
}
+ if (testcontrols)
+ {
+ // Box showing current mouse speed
+
+ G_DrawMouseSpeedBox();
+ }
+
menuactivestate = menuactive;
viewactivestate = viewactive;
inhelpscreensstate = inhelpscreens;
@@ -523,7 +530,7 @@ void D_Display (void)
// normal update
- if (!wipe)
+ if (!wipe || testcontrols)
{
I_FinishUpdate (); // page flip or blit buffer
return;
@@ -1839,6 +1846,18 @@ void D_DoomMain (void)
autostart = true;
}
+ // Invoked by setup to test the controls.
+
+ p = M_CheckParm("-testcontrols");
+
+ if (p > 0)
+ {
+ startepisode = 1;
+ startmap = 1;
+ autostart = true;
+ testcontrols = true;
+ }
+
// Check for load game parameter
// We do this here and save the slot number, so that the network code
// can override it or send the load slot to other players.
diff --git a/src/doomstat.h b/src/doomstat.h
index 2b41b36e..9953f697 100644
--- a/src/doomstat.h
+++ b/src/doomstat.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: doomstat.h 593 2006-09-01 20:45:45Z fraggle $
+// $Id: doomstat.h 662 2006-09-25 18:04:29Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -156,7 +156,7 @@ extern int viewheight;
extern int viewwidth;
extern int scaledviewwidth;
-
+extern boolean testcontrols;
diff --git a/src/g_game.c b/src/g_game.c
index 94a56ff8..4b6ec2f2 100644
--- a/src/g_game.c
+++ b/src/g_game.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: g_game.c 641 2006-09-21 11:13:28Z rtc_marine $
+// $Id: g_game.c 662 2006-09-25 18:04:29Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -134,10 +134,11 @@
static const char
-rcsid[] = "$Id: g_game.c 641 2006-09-21 11:13:28Z rtc_marine $";
+rcsid[] = "$Id: g_game.c 662 2006-09-25 18:04:29Z fraggle $";
#include <string.h>
#include <stdlib.h>
+#include <math.h>
#include "doomdef.h"
#include "doomstat.h"
@@ -153,6 +154,7 @@ rcsid[] = "$Id: g_game.c 641 2006-09-21 11:13:28Z rtc_marine $";
#include "m_random.h"
#include "i_system.h"
#include "i_timer.h"
+#include "i_video.h"
#include "p_setup.h"
#include "p_saveg.h"
@@ -260,6 +262,8 @@ byte* demoend;
boolean singledemo; // quit after playing a demo from cmdline
boolean precache = true; // if true, load all graphics at start
+
+boolean testcontrols = false; // Invoked by setup to test controls
wbstartstruct_t wminfo; // parms for world map / intermission
@@ -336,6 +340,7 @@ boolean* joybuttons = &joyarray[1]; // allow [-1]
int savegameslot;
char savedescription[32];
+int testcontrols_mousespeed;
#define BODYQUESIZE 32
@@ -345,6 +350,106 @@ int bodyqueslot;
int vanilla_savegame_limit = 1;
int vanilla_demo_limit = 1;
+
+#define MOUSE_SPEED_BOX_WIDTH 16
+#define COLOR_RED 0xb0
+#define COLOR_BLACK 0x00
+#define COLOR_WHITE 0xff
+
+void G_DrawMouseSpeedBox(void)
+{
+ extern int usemouse;
+ int i;
+ int box_x, box_y;
+ int original_speed;
+ int x, y;
+ int redline_x;
+ int linelen;
+ char *lumpname;
+ int color;
+
+ // If the mouse is turned off or acceleration is turned off, don't
+ // draw the box at all.
+
+ if (!usemouse || fabs(mouse_acceleration - 1) < 0.01)
+ {
+ return;
+ }
+
+ // Calculate box position
+
+ box_x = SCREENWIDTH - MOUSE_SPEED_BOX_WIDTH * 8;
+ box_y = SCREENHEIGHT - 9;
+
+ // Draw the box.
+
+ x = box_x;
+
+ for (i=0; i<MOUSE_SPEED_BOX_WIDTH; ++i)
+ {
+ if (i == 0)
+ {
+ lumpname = "M_LSLEFT";
+ }
+ else if (i == MOUSE_SPEED_BOX_WIDTH - 1)
+ {
+ lumpname = "M_LSRGHT";
+ }
+ else
+ {
+ lumpname = "M_LSCNTR";
+ }
+
+ V_DrawPatchDirect(x, box_y, 0, W_CacheLumpName(DEH_String(lumpname),
+ PU_CACHE));
+ x += 8;
+ }
+
+ // Calculate the position of the red line. This is 1/3 of the way
+ // along the box.
+
+ redline_x = (MOUSE_SPEED_BOX_WIDTH / 3) * 8;
+
+ // Undo acceleration and get back the original mouse speed
+
+ if (testcontrols_mousespeed < mouse_threshold)
+ {
+ original_speed = testcontrols_mousespeed;
+ }
+ else
+ {
+ original_speed = testcontrols_mousespeed - mouse_threshold;
+ original_speed = (int) (original_speed / mouse_acceleration);
+ original_speed += mouse_threshold;
+ }
+
+ // Calculate line length
+
+ linelen = (original_speed * redline_x) / mouse_threshold;
+
+ // Draw horizontal "thermometer"
+
+ for (x=0; x<(MOUSE_SPEED_BOX_WIDTH - 1) * 8; ++x)
+ {
+ if (x < linelen)
+ {
+ color = COLOR_WHITE;
+ }
+ else
+ {
+ color = COLOR_BLACK;
+ }
+
+ screens[0][(box_y - 4) * SCREENWIDTH + box_x + x + 1] = color;
+ }
+
+ // Draw red line
+
+ for (y=box_y - 8; y<box_y; ++y)
+ {
+ screens[0][y * SCREENWIDTH + box_x + redline_x] = COLOR_RED;
+ }
+}
int G_CmdChecksum (ticcmd_t* cmd)
{
@@ -556,6 +661,13 @@ void G_BuildTiccmd (ticcmd_t* cmd)
else
cmd->angleturn -= mousex*0x8;
+ if (mousex == 0)
+ {
+ // No movement in the previous frame
+
+ testcontrols_mousespeed = 0;
+ }
+
mousex = mousey = 0;
if (forward > MAXPLMOVE)
@@ -640,6 +752,11 @@ void G_DoLoadLevel (void)
sendpause = sendsave = paused = false;
memset (mousebuttons, 0, sizeof(mousebuttons));
memset (joybuttons, 0, sizeof(joybuttons));
+
+ if (testcontrols)
+ {
+ players[consoleplayer].message = "Press escape to quit.";
+ }
}
@@ -700,7 +817,18 @@ boolean G_Responder (event_t* ev)
if (F_Responder (ev))
return true; // finale ate the event
}
-
+
+ if (testcontrols && ev->type == ev_mouse)
+ {
+ // If we are invoked by setup to test the controls, save the
+ // mouse speed so that we can display it on-screen.
+ // Perform a low pass filter on this so that the thermometer
+ // appears to move smoothly.
+
+ testcontrols_mousespeed = ((testcontrols_mousespeed * 2)
+ + abs(ev->data2)) / 3;
+ }
+
switch (ev->type)
{
case ev_keydown:
diff --git a/src/g_game.h b/src/g_game.h
index 11a8582d..4d226d2a 100644
--- a/src/g_game.h
+++ b/src/g_game.h
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: g_game.h 8 2005-07-23 16:44:57Z fraggle $
+// $Id: g_game.h 662 2006-09-25 18:04:29Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -77,6 +77,7 @@ boolean G_Responder (event_t* ev);
void G_ScreenShot (void);
+void G_DrawMouseSpeedBox(void);
#endif
//-----------------------------------------------------------------------------
diff --git a/src/i_system.c b/src/i_system.c
index 1ad1bf20..a70f7d62 100644
--- a/src/i_system.c
+++ b/src/i_system.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: i_system.c 653 2006-09-22 20:32:00Z fraggle $
+// $Id: i_system.c 662 2006-09-25 18:04:29Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -81,7 +81,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: i_system.c 653 2006-09-22 20:32:00Z fraggle $";
+rcsid[] = "$Id: i_system.c 662 2006-09-25 18:04:29Z fraggle $";
#include <stdlib.h>
@@ -226,7 +226,7 @@ void I_Quit (void)
M_SaveDefaults ();
I_ShutdownGraphics();
- if (show_endoom)
+ if (show_endoom && !testcontrols)
{
I_Endoom();
}
diff --git a/src/m_menu.c b/src/m_menu.c
index a4d8cbdf..b4e73d64 100644
--- a/src/m_menu.c
+++ b/src/m_menu.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: m_menu.c 653 2006-09-22 20:32:00Z fraggle $
+// $Id: m_menu.c 662 2006-09-25 18:04:29Z fraggle $
//
// Copyright(C) 1993-1996 Id Software, Inc.
// Copyright(C) 2005 Simon Howard
@@ -78,7 +78,7 @@
//-----------------------------------------------------------------------------
static const char
-rcsid[] = "$Id: m_menu.c 653 2006-09-22 20:32:00Z fraggle $";
+rcsid[] = "$Id: m_menu.c 662 2006-09-25 18:04:29Z fraggle $";
#include <stdlib.h>
#include <ctype.h>
@@ -1550,6 +1550,10 @@ boolean M_Responder (event_t* ev)
if (ch == -1)
return false;
+ if (testcontrols && ch == KEY_ESCAPE)
+ {
+ I_Quit();
+ }
// Save Game string input
if (saveStringEnter)