ref: b7fced59e1d1690842f7ac8f286eb89d4c976189
parent: 9a5c207939ed554e8ac00587cce3ec83798cfbc1
author: Simon Howard <[email protected]>
date: Mon Sep 25 14:04:29 EDT 2006
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
--- 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 @@
}
+ if (testcontrols)
+ {
+ // Box showing current mouse speed
+
+ G_DrawMouseSpeedBox();
+ }
+
menuactivestate = menuactive;
viewactivestate = viewactive;
inhelpscreensstate = inhelpscreens;
@@ -523,7 +530,7 @@
// normal update
- if (!wipe)
+ if (!wipe || testcontrols)
{
I_FinishUpdate (); // page flip or blit buffer
return;
@@ -1837,6 +1844,18 @@
startmap = myargv[p+2][0]-'0';
}
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
--- 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 viewwidth;
extern int scaledviewwidth;
-
+extern boolean testcontrols;
--- 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 @@
#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 @@
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 @@
int savegameslot;
char savedescription[32];
+int testcontrols_mousespeed;
#define BODYQUESIZE 32
@@ -345,6 +350,106 @@
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 @@
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 @@
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 @@
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:
--- 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 @@
void G_ScreenShot (void);
+void G_DrawMouseSpeedBox(void);
#endif
//-----------------------------------------------------------------------------
--- 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 @@
M_SaveDefaults ();
I_ShutdownGraphics();
- if (show_endoom)
+ if (show_endoom && !testcontrols)
{
I_Endoom();
}
--- 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 @@
if (ch == -1)
return false;
+ if (testcontrols && ch == KEY_ESCAPE)
+ {
+ I_Quit();
+ }
// Save Game string input
if (saveStringEnter)