From b7fced59e1d1690842f7ac8f286eb89d4c976189 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 25 Sep 2006 18:04:29 +0000 Subject: 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 --- src/d_main.c | 25 +++++++++-- src/doomstat.h | 4 +- src/g_game.c | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/g_game.h | 3 +- src/i_system.c | 6 +-- src/m_menu.c | 8 +++- 6 files changed, 166 insertions(+), 14 deletions(-) (limited to 'src') 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 #include +#include #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; iangleturn -= 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 @@ -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 #include @@ -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) -- cgit v1.2.3