From 39494b5a451472db3b613446a5b1c8c2b0d92cf6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 14 May 2010 18:42:32 +0000 Subject: Don't grab the mouse when the demo sequence advances. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1935 --- src/i_video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 6936532d..bc3f17cf 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -85,6 +85,7 @@ static screen_mode_t *screen_modes_corrected[] = { }; extern void M_QuitDOOM(); +extern boolean advancedemo; // SDL video driver name @@ -228,7 +229,7 @@ static boolean MouseShouldBeGrabbed() // only grab mouse when playing levels (but not demos) - return (gamestate == GS_LEVEL) && !demoplayback; + return (gamestate == GS_LEVEL) && !demoplayback && !advancedemo; #endif /* #ifndef _WIN32_WCE */ } -- cgit v1.2.3 From bb3f64f28173bba0b243957c63679d2ec63dce5c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 10 Jul 2010 15:27:52 +0000 Subject: Add key binding to change demo recording quit key. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1939 --- src/g_game.c | 3 ++- src/m_config.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/g_game.c b/src/g_game.c index b0532f42..a9ee2641 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -184,6 +184,7 @@ int key_weapon7 = '7'; int key_weapon8 = '8'; int key_pause = KEY_PAUSE; +int key_demo_quit = 'q'; int mousebfire = 0; int mousebstrafe = 1; @@ -1846,7 +1847,7 @@ void G_WriteDemoTiccmd (ticcmd_t* cmd) { byte *demo_start; - if (gamekeydown['q']) // press q to end demo recording + if (gamekeydown[key_demo_quit]) // press q to end demo recording G_CheckDemoStatus (); demo_start = demo_p; diff --git a/src/m_config.c b/src/m_config.c index a2f3ac58..d0fe6808 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -149,6 +149,7 @@ extern int key_weapon7; extern int key_weapon8; extern int key_message_refresh; +extern int key_demo_quit; extern int mousebfire; extern int mousebstrafe; @@ -1041,6 +1042,12 @@ static default_t extra_defaults_list[] = // CONFIG_VARIABLE_KEY(key_message_refresh, key_message_refresh), + + //! + // Key to quit the game when recording a demo. + // + + CONFIG_VARIABLE_KEY(key_demo_quit, key_demo_quit), }; static default_collection_t extra_defaults = -- cgit v1.2.3 From 79300a83cb91395d97b33824dcbe39c06ff371da Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 10 Jul 2010 15:56:18 +0000 Subject: Add key bindings for multiplayer messaging. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1940 --- src/hu_stuff.c | 22 ++++++++++++---------- src/m_config.c | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 1381532d..afe3974c 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -88,6 +88,16 @@ char* player_names[] = HUSTR_PLRRED }; +int key_multi_msg = HU_INPUTTOGGLE; + +int key_multi_msgplayer[MAXPLAYERS] = +{ + HUSTR_KEYGREEN, + HUSTR_KEYINDIGO, + HUSTR_KEYBROWN, + HUSTR_KEYRED +}; + int key_message_refresh = KEY_ENTER; char chat_char; // remove later. @@ -572,14 +582,6 @@ boolean HU_Responder(event_t *ev) int i; int numplayers; - static char destination_keys[MAXPLAYERS] = - { - HUSTR_KEYGREEN, - HUSTR_KEYINDIGO, - HUSTR_KEYBROWN, - HUSTR_KEYRED - }; - static int num_nobrainers = 0; numplayers = 0; @@ -608,7 +610,7 @@ boolean HU_Responder(event_t *ev) message_counter = HU_MSGTIMEOUT; eatkey = true; } - else if (netgame && ev->data2 == HU_INPUTTOGGLE) + else if (netgame && ev->data2 == key_multi_msg) { eatkey = chat_on = true; HUlib_resetIText(&w_chat); @@ -618,7 +620,7 @@ boolean HU_Responder(event_t *ev) { for (i=0; idata2 == destination_keys[i]) + if (ev->data2 == key_multi_msgplayer[i]) { if (playeringame[i] && i!=consoleplayer) { diff --git a/src/m_config.c b/src/m_config.c index d0fe6808..ef9c97e8 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -150,7 +150,10 @@ extern int key_weapon8; extern int key_message_refresh; extern int key_demo_quit; - + +extern int key_multi_msg; +extern int key_multi_msgplayer[]; + extern int mousebfire; extern int mousebstrafe; extern int mousebforward; @@ -1048,6 +1051,36 @@ static default_t extra_defaults_list[] = // CONFIG_VARIABLE_KEY(key_demo_quit, key_demo_quit), + + //! + // Key to send a message during multiplayer games. + // + + CONFIG_VARIABLE_KEY(key_multi_msg, key_multi_msg), + + //! + // Key to send a message to the green player during multiplayer games. + // + + CONFIG_VARIABLE_KEY(key_multi_msgplayer1, key_multi_msgplayer[0]), + + //! + // Key to send a message to the indigo player during multiplayer games. + // + + CONFIG_VARIABLE_KEY(key_multi_msgplayer2, key_multi_msgplayer[1]), + + //! + // Key to send a message to the brown player during multiplayer games. + // + + CONFIG_VARIABLE_KEY(key_multi_msgplayer3, key_multi_msgplayer[2]), + + //! + // Key to send a message to the red player during multiplayer games. + // + + CONFIG_VARIABLE_KEY(key_multi_msgplayer4, key_multi_msgplayer[3]), }; static default_collection_t extra_defaults = -- cgit v1.2.3 From 232fba47e0a42af8c3ec0f934eaa855163c4ee35 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 28 Jul 2010 20:39:07 +0000 Subject: Add config file parameter to set OPL I/O port. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1947 --- src/m_config.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/m_config.c b/src/m_config.c index ef9c97e8..8744e98a 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -191,6 +191,7 @@ extern int vanilla_demo_limit; extern int snd_musicdevice; extern int snd_sfxdevice; extern int snd_samplerate; +extern int opl_io_port; // controls whether to use libsamplerate for sample rate conversions @@ -208,6 +209,7 @@ static int snd_mport = 0; typedef enum { DEFAULT_INT, + DEFAULT_INT_HEX, DEFAULT_STRING, DEFAULT_FLOAT, DEFAULT_KEY, @@ -243,14 +245,19 @@ typedef struct char *filename; } default_collection_t; +#define CONFIG_VARIABLE_GENERIC(name, variable, type) \ + { #name, &variable, type, 0, 0 } + #define CONFIG_VARIABLE_KEY(name, variable) \ - { #name, &variable, DEFAULT_KEY, 0, 0 } + CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_KEY) #define CONFIG_VARIABLE_INT(name, variable) \ - { #name, &variable, DEFAULT_INT, 0, 0 } + CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_INT) +#define CONFIG_VARIABLE_INT_HEX(name, variable) \ + CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_INT_HEX) #define CONFIG_VARIABLE_FLOAT(name, variable) \ - { #name, &variable, DEFAULT_FLOAT, 0, 0 } + CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_FLOAT) #define CONFIG_VARIABLE_STRING(name, variable) \ - { #name, &variable, DEFAULT_STRING, 0, 0 } + CONFIG_VARIABLE_GENERIC(name, variable, DEFAULT_STRING) //! @begin_config_file default.cfg @@ -625,19 +632,26 @@ static default_t extra_defaults_list[] = //! // Mouse acceleration threshold. When the speed of mouse movement - // exceeds this threshold value, the speed is multiplied by an + // exceeds this threshold value, the speed is multiplied by an // acceleration factor (mouse_acceleration). // CONFIG_VARIABLE_INT(mouse_threshold, mouse_threshold), //! - // Sound output sample rate, in Hz. Typical values to use are + // Sound output sample rate, in Hz. Typical values to use are // 11025, 22050, 44100 and 48000. // CONFIG_VARIABLE_INT(snd_samplerate, snd_samplerate), + //! + // The I/O port to use to access the OPL chip. Only relevant when + // using native OPL music playback. + // + + CONFIG_VARIABLE_INT_HEX(opl_io_port, opl_io_port), + //! // If non-zero, the ENDOOM screen is displayed when exiting the // game. If zero, the ENDOOM screen is not displayed. @@ -1178,6 +1192,10 @@ static void SaveDefaultCollection(default_collection_t *collection) fprintf(f, "%i", * (int *) defaults[i].location); break; + case DEFAULT_INT_HEX: + fprintf(f, "0x%x", * (int *) defaults[i].location); + break; + case DEFAULT_FLOAT: fprintf(f, "%f", * (float *) defaults[i].location); break; @@ -1267,6 +1285,7 @@ static void LoadDefaultCollection(default_collection_t *collection) break; case DEFAULT_INT: + case DEFAULT_INT_HEX: * (int *) def->location = ParseIntParameter(strparm); break; -- cgit v1.2.3 From 4319d9cda4caab4a9c4d5f98a780ea8d9e3531f6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 31 Jul 2010 19:25:17 +0000 Subject: Add multiplayer spy key binding. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1948 --- src/g_game.c | 3 ++- src/m_config.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/g_game.c b/src/g_game.c index a9ee2641..701b98d5 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -185,6 +185,7 @@ int key_weapon8 = '8'; int key_pause = KEY_PAUSE; int key_demo_quit = 'q'; +int key_spy = KEY_F12; int mousebfire = 0; int mousebstrafe = 1; @@ -740,7 +741,7 @@ boolean G_Responder (event_t* ev) { // allow spy mode changes even during the demo if (gamestate == GS_LEVEL && ev->type == ev_keydown - && ev->data1 == KEY_F12 && (singledemo || !deathmatch) ) + && ev->data1 == key_spy && (singledemo || !deathmatch) ) { // spy mode do diff --git a/src/m_config.c b/src/m_config.c index 8744e98a..b2e52e7f 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -122,6 +122,7 @@ extern int key_menu_messages; extern int key_menu_qload; extern int key_menu_quit; extern int key_menu_gamma; +extern int key_spy; extern int key_menu_incscreen; extern int key_menu_decscreen; @@ -922,6 +923,12 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_KEY(key_menu_gamma, key_menu_gamma), + //! + // Keyboard shortcut to switch view in multiplayer. + // + + CONFIG_VARIABLE_KEY(key_spy, key_spy), + //! // Keyboard shortcut to increase the screen size. // -- cgit v1.2.3 From ad8d7a1efb8c61bb39568f76ab814919895cc501 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 3 Aug 2010 20:12:36 +0000 Subject: When in windowed mode, allow the screen size to be dynamically resized by dragging the window borders. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1949 --- src/i_scale.c | 14 +++- src/i_video.c | 208 ++++++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 150 insertions(+), 72 deletions(-) (limited to 'src') diff --git a/src/i_scale.c b/src/i_scale.c index a022ab15..3f7b3a7d 100644 --- a/src/i_scale.c +++ b/src/i_scale.c @@ -53,11 +53,11 @@ static int dest_pitch; // stretch_tables[1] : 40% / 60% // All other combinations can be reached from these two tables. -static byte *stretch_tables[2]; +static byte *stretch_tables[2] = { NULL, NULL }; // 50%/50% stretch table, for 800x600 squash mode -static byte *half_stretch_table; +static byte *half_stretch_table = NULL; // Called to set the source and destination buffers before doing the // scale. @@ -364,6 +364,11 @@ static byte *GenerateStretchTable(byte *palette, int pct) static void I_InitStretchTables(byte *palette) { + if (stretch_tables[0] != NULL) + { + return; + } + // We only actually need two lookup tables: // // mix 0% = just write line 1 @@ -385,6 +390,11 @@ static void I_InitStretchTables(byte *palette) static void I_InitSquashTable(byte *palette) { + if (half_stretch_table != NULL) + { + return; + } + printf("I_InitSquashTable: Generating lookup table.."); fflush(stdout); half_stretch_table = GenerateStretchTable(palette, 50); diff --git a/src/i_video.c b/src/i_video.c index bc3f17cf..91b670b8 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -98,8 +98,6 @@ static SDL_Surface *screen; static SDL_Color palette[256]; static boolean palette_to_set; -static int windowwidth, windowheight; - // display has been set up? static boolean initialized = false; @@ -160,6 +158,12 @@ static SDL_Cursor *cursors[2]; static screen_mode_t *screen_mode; +// Window resize state. + +static boolean need_resize = false; +static unsigned int resize_w, resize_h; +static unsigned int last_resize_time; + // If true, keyboard mapping is ignored, like in Vanilla Doom. // The sensible thing to do is to disable this if you have a non-US // keyboard. @@ -178,6 +182,8 @@ int vanilla_keyboard_mapping = true; float mouse_acceleration = 2.0; int mouse_threshold = 10; +static void ApplyWindowResize(unsigned int w, unsigned int h); + static boolean MouseShouldBeGrabbed() { // never grab the mouse when in screensaver mode @@ -580,6 +586,13 @@ void I_GetEvent(void) palette_to_set = true; break; + case SDL_RESIZABLE: + need_resize = true; + resize_w = sdlevent.resize.w; + resize_h = sdlevent.resize.h; + last_resize_time = SDL_GetTicks(); + break; + default: break; } @@ -815,14 +828,20 @@ void I_FinishUpdate (void) static int lasttic; int tics; int i; - // UNUSED static unsigned char *bigscreen=0; if (!initialized) return; if (noblit) return; - + + if (need_resize && SDL_GetTicks() > last_resize_time + 500) + { + ApplyWindowResize(resize_w, resize_h); + need_resize = false; + palette_to_set = true; + } + UpdateGrab(); // Don't update the screen if the window isn't visible. @@ -1492,11 +1511,96 @@ static char *WindowBoxType(screen_mode_t *mode, int w, int h) } } +static void SetVideoMode(screen_mode_t *mode, int w, int h) +{ + byte *doompal; + int flags = 0; + + doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE); + + // Generate lookup tables before setting the video mode. + + if (mode != NULL && mode->InitMode != NULL) + { + mode->InitMode(doompal); + } + + // Set the video mode. + + flags |= SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF; + + if (fullscreen) + { + flags |= SDL_FULLSCREEN; + } + else + { + flags |= SDL_RESIZABLE; + } + + screen = SDL_SetVideoMode(w, h, 8, flags); + + if (screen == NULL) + { + I_Error("Error setting video mode: %s\n", SDL_GetError()); + } + + // If mode was not set, it must be set now that we know the + // screen size. + + if (mode == NULL) + { + mode = I_FindScreenMode(screen->w, screen->h); + + if (mode == NULL) + { + I_Error("I_InitGraphics: Unable to find a screen mode small " + "enough for %ix%i", screen->w, screen->h); + } + + // Generate lookup tables before setting the video mode. + + if (mode->InitMode != NULL) + { + mode->InitMode(doompal); + } + } + + // Save screen mode. + + screen_mode = mode; +} + +static void ApplyWindowResize(unsigned int w, unsigned int h) +{ + screen_mode_t *mode; + + // Find the biggest screen mode that will fall within these + // dimensions, falling back to the smallest mode possible if + // none is found. + + mode = I_FindScreenMode(w, h); + + if (mode == NULL) + { + mode = I_FindScreenMode(SCREENWIDTH, SCREENHEIGHT); + } + + // Reset mode to resize window. + + printf("Resize to %ix%i\n", mode->width, mode->height); + SetVideoMode(mode, mode->width, mode->height); + + // Save settings. + + screen_width = mode->width; + screen_height = mode->height; +} + void I_InitGraphics(void) { SDL_Event dummy; byte *doompal; - int flags = 0; char *env; // Pass through the XSCREENSAVER_WINDOW environment variable to @@ -1527,70 +1631,53 @@ void I_InitGraphics(void) CheckCommandLine(); - doompal = W_CacheLumpName (DEH_String("PLAYPAL"),PU_CACHE); + // Set up title and icon. Windows cares about the ordering; this + // has to be done before the call to SDL_SetVideoMode. + + I_SetWindowCaption(); +#if !SDL_VERSION_ATLEAST(1, 3, 0) + I_SetWindowIcon(); +#endif + + // + // Enter into graphics mode. + // + // When in screensaver mode, run full screen and auto detect + // screen dimensions (don't change video mode) + // if (screensaver_mode) { - windowwidth = 0; - windowheight = 0; + SetVideoMode(NULL, 0, 0); } else { + int w, h; + if (autoadjust_video_settings) { I_AutoAdjustSettings(); } - windowwidth = screen_width; - windowheight = screen_height; + w = screen_width; + h = screen_height; - screen_mode = I_FindScreenMode(windowwidth, windowheight); + screen_mode = I_FindScreenMode(w, h); if (screen_mode == NULL) { I_Error("I_InitGraphics: Unable to find a screen mode small " - "enough for %ix%i", windowwidth, windowheight); + "enough for %ix%i", w, h); } - if (windowwidth != screen_mode->width - || windowheight != screen_mode->height) + if (w != screen_mode->width || h != screen_mode->height) { printf("I_InitGraphics: %s (%ix%i within %ix%i)\n", - WindowBoxType(screen_mode, windowwidth, windowheight), - screen_mode->width, screen_mode->height, - windowwidth, windowheight); - } - - // Generate lookup tables before setting the video mode. - - if (screen_mode->InitMode != NULL) - { - screen_mode->InitMode(doompal); + WindowBoxType(screen_mode, w, h), + screen_mode->width, screen_mode->height, w, h); } - } - - // Set up title and icon. Windows cares about the ordering; this - // has to be done before the call to SDL_SetVideoMode. - - I_SetWindowCaption(); -#if !SDL_VERSION_ATLEAST(1, 3, 0) - I_SetWindowIcon(); -#endif - - // Set the video mode. - - flags |= SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF; - - if (fullscreen) - { - flags |= SDL_FULLSCREEN; - } - - screen = SDL_SetVideoMode(windowwidth, windowheight, 8, flags); - if (screen == NULL) - { - I_Error("Error setting video mode: %s\n", SDL_GetError()); + SetVideoMode(screen_mode, w, h); } // Start with a clear black screen @@ -1611,6 +1698,7 @@ void I_InitGraphics(void) // Set the palette + doompal = W_CacheLumpName(DEH_String("PLAYPAL"), PU_CACHE); I_SetPalette(doompal); SDL_SetColors(screen, palette, 0, 256); @@ -1619,26 +1707,6 @@ void I_InitGraphics(void) UpdateFocus(); UpdateGrab(); - // In screensaver mode, now find a screen_mode to use. - - if (screensaver_mode) - { - screen_mode = I_FindScreenMode(screen->w, screen->h); - - if (screen_mode == NULL) - { - I_Error("I_InitGraphics: Unable to find a screen mode small " - "enough for %ix%i", screen->w, screen->h); - } - - // Generate lookup tables before setting the video mode. - - if (screen_mode->InitMode != NULL) - { - screen_mode->InitMode(doompal); - } - } - // On some systems, it takes a second or so for the screen to settle // after changing modes. We include the option to add a delay when // setting the screen mode, so that the game doesn't start immediately @@ -1654,12 +1722,12 @@ void I_InitGraphics(void) // Likewise if the screen pitch is not the same as the width // If we have to multiply, drawing is done to a separate 320x200 buf - native_surface = !SDL_MUSTLOCK(screen) + native_surface = !SDL_MUSTLOCK(screen) && screen_mode == &mode_scale_1x && screen->pitch == SCREENWIDTH && aspect_ratio_correct; - // If not, allocate a buffer and copy from that buffer to the + // If not, allocate a buffer and copy from that buffer to the // screen when we do an update if (native_surface) @@ -1670,7 +1738,7 @@ void I_InitGraphics(void) } else { - screens[0] = (unsigned char *) Z_Malloc (SCREENWIDTH * SCREENHEIGHT, + screens[0] = (unsigned char *) Z_Malloc (SCREENWIDTH * SCREENHEIGHT, PU_STATIC, NULL); } -- cgit v1.2.3 From 05cafe91729446ebd28f3fdab2302277c53530d1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 4 Aug 2010 18:25:04 +0000 Subject: Initial code for previous/next weapon switching keys. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1950 --- src/g_game.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 115 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/g_game.c b/src/g_game.c index 701b98d5..1e163716 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -182,6 +182,8 @@ int key_weapon5 = '5'; int key_weapon6 = '6'; int key_weapon7 = '7'; int key_weapon8 = '8'; +int key_prevweapon = 0; +int key_nextweapon = 0; int key_pause = KEY_PAUSE; int key_demo_quit = 'q'; @@ -235,6 +237,28 @@ static int *weapon_keys[] = { &key_weapon8 }; +// Set to -1 or +1 to switch to the previous or next weapon. + +static int next_weapon = 0; + +// Used for prev/next weapon keys. + +static const struct +{ + weapontype_t weapon; + weapontype_t weapon_num; +} weapon_order_table[] = { + { wp_fist, wp_fist }, + { wp_chainsaw, wp_fist }, + { wp_pistol, wp_pistol }, + { wp_shotgun, wp_shotgun }, + { wp_supershotgun, wp_shotgun }, + { wp_chaingun, wp_chaingun }, + { wp_missile, wp_missile }, + { wp_plasma, wp_plasma }, + { wp_bfg, wp_bfg } +}; + #define SLOWTURNTICS 6 #define NUMKEYS 256 @@ -396,7 +420,63 @@ int G_CmdChecksum (ticcmd_t* cmd) return sum; } - + +static boolean WeaponSelectable(weapontype_t weapon) +{ + // Can't select a weapon if we don't own it. + + if (!players[consoleplayer].weaponowned[weapon]) + { + return false; + } + + // Can't select the fist if we have the chainsaw, unless + // we also have the berserk pack. + + if (weapon == wp_fist + && players[consoleplayer].weaponowned[wp_chainsaw] + && !players[consoleplayer].powers[pw_strength]) + { + return false; + } + + return true; +} + +static int G_NextWeapon(int direction) +{ + weapontype_t weapon; + int i; + + // Find index in the table. + + if (players[consoleplayer].pendingweapon == wp_nochange) + { + weapon = players[consoleplayer].readyweapon; + } + else + { + weapon = players[consoleplayer].pendingweapon; + } + + for (i=0; ibuttons |= BT_CHANGE; + cmd->buttons |= i << BT_WEAPONSHIFT; + next_weapon = 0; + } + else { - int key = *weapon_keys[i]; + // Check weapon keys. - if (gamekeydown[key]) + for (i=0; ibuttons |= BT_CHANGE; - cmd->buttons |= i<buttons |= BT_CHANGE; + cmd->buttons |= i<data2); } + // If the next/previous weapon keys are pressed, set the next_weapon + // variable to change weapons when the next ticcmd is generated. + + if (ev->type == ev_keydown && ev->data1 == key_prevweapon) + { + next_weapon = -1; + } + else if (ev->type == ev_keydown && ev->data1 == key_nextweapon) + { + next_weapon = 1; + } + switch (ev->type) { case ev_keydown: -- cgit v1.2.3 From 5e9a9a52dbebabda79f221caf318dd8fba4b0781 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 7 Aug 2010 16:07:00 +0000 Subject: Fix sound resampling low pass filter. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1951 --- src/i_sdlsound.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index d51345c7..ff191202 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -244,12 +244,15 @@ static void ExpandSoundData_SDL(byte *data, // (maximum frequency, by nyquist) dt = 1.0f / mixer_freq; - rc = 1.0f / (3.14f * samplerate); + rc = 1.0f / (2 * 3.14f * samplerate); alpha = dt / (rc + dt); - for (i=1; i @@ -41,6 +40,7 @@ #include "deh_main.h" #include "i_system.h" +#include "i_swap.h" #include "s_sound.h" #include "m_argv.h" #include "w_wad.h" @@ -49,6 +49,7 @@ #include "doomdef.h" #define LOW_PASS_FILTER +//#define DEBUG_DUMP_WAVS #define MAX_SOUND_SLICE_TIME 70 /* ms */ #define NUM_CHANNELS 16 @@ -159,12 +160,62 @@ static boolean ConvertibleRatio(int freq1, int freq2) } } +#ifdef DEBUG_DUMP_WAVS + +// Debug code to dump resampled sound effects to WAV files for analysis. + +static void WriteWAV(char *filename, byte *data, + uint32_t length, int samplerate) +{ + FILE *wav; + unsigned int i; + unsigned short s; + + wav = fopen(filename, "wb"); + + // Header + + fwrite("RIFF", 1, 4, wav); + i = LONG(36 + samplerate); + fwrite(&i, 4, 1, wav); + fwrite("WAVE", 1, 4, wav); + + // Subchunk 1 + + fwrite("fmt ", 1, 4, wav); + i = LONG(16); + fwrite(&i, 4, 1, wav); // Length + s = SHORT(1); + fwrite(&s, 2, 1, wav); // Format (PCM) + s = SHORT(2); + fwrite(&s, 2, 1, wav); // Channels (2=stereo) + i = LONG(samplerate); + fwrite(&i, 4, 1, wav); // Sample rate + i = LONG(samplerate * 2 * 2); + fwrite(&i, 4, 1, wav); // Byte rate (samplerate * stereo * 16 bit) + s = SHORT(2 * 2); + fwrite(&s, 2, 1, wav); // Block align (stereo * 16 bit) + s = SHORT(16); + fwrite(&s, 2, 1, wav); // Bits per sample (16 bit) + + // Data subchunk + + fwrite("data", 1, 4, wav); + i = LONG(length); + fwrite(&i, 4, 1, wav); // Data length + fwrite(data, 1, length, wav); // Data + + fclose(wav); +} + +#endif + // Generic sound expansion function for any sample rate. static void ExpandSoundData_SDL(byte *data, - int samplerate, - uint32_t length, - Mix_Chunk *destination) + int samplerate, + uint32_t length, + Mix_Chunk *destination) { SDL_AudioCVT convertor; uint32_t expanded_length; @@ -181,7 +232,7 @@ static void ExpandSoundData_SDL(byte *data, = Z_Malloc(expanded_length, PU_STATIC, &destination->abuf); // If we can, use the standard / optimized SDL conversion routines. - + if (samplerate <= mixer_freq && ConvertibleRatio(samplerate, mixer_freq) && SDL_BuildAudioCVT(&convertor, @@ -244,7 +295,7 @@ static void ExpandSoundData_SDL(byte *data, // (maximum frequency, by nyquist) dt = 1.0f / mixer_freq; - rc = 1.0f / (2 * 3.14f * samplerate); + rc = 1.0f / (3.14f * samplerate); alpha = dt / (rc + dt); // Both channels are processed in parallel, hence [i-2]: @@ -347,6 +398,16 @@ static boolean CacheSFX_SDL(int sound) length, &sound_chunks[sound]); +#ifdef DEBUG_DUMP_WAVS + { + char filename[16]; + + sprintf(filename, "%s.wav", DEH_String(S_sfx[sound].name)); + WriteWAV(filename, sound_chunks[sound].abuf, + sound_chunks[sound].alen, mixer_freq); + } +#endif + // don't need the original lump any more W_ReleaseLumpNum(lumpnum); -- cgit v1.2.3 From f3d3b03870a6842e104c67ce6fc7edfde89d77ec Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 9 Aug 2010 17:53:10 +0000 Subject: Add weapon cycling bindings for mouse and joystick buttons. Add weapon cycling bindings to configuration file and setup tool. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1953 --- src/g_game.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++-------- src/m_config.c | 44 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/g_game.c b/src/g_game.c index 1e163716..bf9560db 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -198,6 +198,9 @@ int mousebstraferight = -1; int mousebbackward = -1; int mousebuse = -1; +int mousebprevweapon = -1; +int mousebnextweapon = -1; + // Control whether if a mouse button is double clicked, it acts like // "use" has been pressed @@ -210,6 +213,9 @@ int joybspeed = 2; int joybstrafeleft = -1; int joybstraferight = -1; +int joybprevweapon = -1; +int joybnextweapon = -1; + // fraggle: Disallow mouse and joystick movement to cause forward/backward // motion. Specified with the '-novert' command line parameter. // This is an int to allow saving to config file @@ -262,11 +268,13 @@ static const struct #define SLOWTURNTICS 6 #define NUMKEYS 256 +#define MAX_JOY_BUTTONS 20 +#define MAX_MOUSE_BUTTONS 3 static boolean gamekeydown[NUMKEYS]; static int turnheld; // for accelerative turning -static boolean mousearray[4]; +static boolean mousearray[MAX_MOUSE_BUTTONS + 1]; static boolean *mousebuttons = &mousearray[1]; // allow [-1] // mouse values are used once @@ -280,8 +288,6 @@ static int dclicktime2; static boolean dclickstate2; static int dclicks2; -#define MAX_JOY_BUTTONS 20 - // joystick values are repeated static int joyxmove; static int joyymove; @@ -815,7 +821,6 @@ void G_DoLoadLevel (void) players[consoleplayer].message = "Press escape to quit."; } } - static void SetJoyButtons(unsigned int buttons_mask) { @@ -823,10 +828,54 @@ static void SetJoyButtons(unsigned int buttons_mask) for (i=0; idata1 & 1; - mousebuttons[1] = ev->data1 & 2; - mousebuttons[2] = ev->data1 & 4; + SetMouseButtons(ev->data1); mousex = ev->data2*(mouseSensitivity+5)/10; mousey = ev->data3*(mouseSensitivity+5)/10; return true; // eat events diff --git a/src/m_config.c b/src/m_config.c index b2e52e7f..2065700e 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -148,6 +148,8 @@ extern int key_weapon5; extern int key_weapon6; extern int key_weapon7; extern int key_weapon8; +extern int key_prevweapon; +extern int key_nextweapon; extern int key_message_refresh; extern int key_demo_quit; @@ -164,6 +166,9 @@ extern int mousebstraferight; extern int mousebbackward; extern int mousebuse; +extern int mousebprevweapon; +extern int mousebnextweapon; + extern int dclick_use; extern int joybfire; @@ -173,6 +178,9 @@ extern int joybspeed; extern int joybstrafeleft; extern int joybstraferight; +extern int joybprevweapon; +extern int joybnextweapon; + extern int viewwidth; extern int viewheight; @@ -747,6 +755,18 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_INT(joyb_straferight, joybstraferight), + //! + // Joystick button to cycle to the previous weapon. + // + + CONFIG_VARIABLE_INT(joyb_prevweapon, joybprevweapon), + + //! + // Joystick button to cycle to the next weapon. + // + + CONFIG_VARIABLE_INT(joyb_nextweapon, joybnextweapon), + //! // Mouse button to strafe left. // @@ -771,6 +791,18 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_INT(mouseb_backward, mousebbackward), + //! + // Mouse button to cycle to the previous weapon. + // + + CONFIG_VARIABLE_INT(mouseb_prevweapon, mousebprevweapon), + + //! + // Mouse button to cycle to the next weapon. + // + + CONFIG_VARIABLE_INT(mouseb_nextweapon, mousebnextweapon), + //! // If non-zero, double-clicking a mouse button acts like pressing // the "use" key to use an object in-game, eg. a door or switch. @@ -1061,6 +1093,18 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_KEY(key_weapon8, key_weapon8), + //! + // Key to cycle to the previous weapon. + // + + CONFIG_VARIABLE_KEY(key_prevweapon, key_prevweapon), + + //! + // Key to cycle to the next weapon. + // + + CONFIG_VARIABLE_KEY(key_nextweapon, key_nextweapon), + //! // Key to re-display last message. // -- cgit v1.2.3 From aa5b8eba10fb1122c64c42122bfd48d7a7c7d745 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 20 Aug 2010 11:30:30 +0000 Subject: Extend mouse code to support up to 8 buttons (allows mouse wheel to be used). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1958 --- src/g_game.c | 1 - src/i_video.c | 77 ++++++++++++++++++++++++++++++++++++++++------------------- src/i_video.h | 5 ++-- 3 files changed, 55 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/g_game.c b/src/g_game.c index bf9560db..95cd77a6 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -269,7 +269,6 @@ static const struct #define NUMKEYS 256 #define MAX_JOY_BUTTONS 20 -#define MAX_MOUSE_BUTTONS 3 static boolean gamekeydown[NUMKEYS]; static int turnheld; // for accelerative turning diff --git a/src/i_video.c b/src/i_video.c index 91b670b8..d2d0d169 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -107,6 +107,10 @@ static boolean initialized = false; static boolean nomouse = false; extern int usemouse; +// Bit mask of mouse button state. + +static unsigned int mouse_button_state = 0; + // if true, screens[0] is screen->pixel static boolean native_surface; @@ -430,29 +434,58 @@ void I_StartFrame (void) } -static int MouseButtonState(void) +static void UpdateMouseButtonState(unsigned int button, boolean on) { - Uint8 state; - int result = 0; + event_t event; -#if SDL_VERSION_ATLEAST(1, 3, 0) - state = SDL_GetMouseState(0, NULL, NULL); -#else - state = SDL_GetMouseState(NULL, NULL); -#endif + if (button < SDL_BUTTON_LEFT || button > MAX_MOUSE_BUTTONS) + { + return; + } // Note: button "0" is left, button "1" is right, // button "2" is middle for Doom. This is different // to how SDL sees things. - if (state & SDL_BUTTON(1)) - result |= 1; - if (state & SDL_BUTTON(3)) - result |= 2; - if (state & SDL_BUTTON(2)) - result |= 4; + switch (button) + { + case SDL_BUTTON_LEFT: + button = 0; + break; - return result; + case SDL_BUTTON_RIGHT: + button = 1; + break; + + case SDL_BUTTON_MIDDLE: + button = 2; + break; + + default: + // SDL buttons are indexed from 1. + --button; + break; + } + + printf("button %i -> %s\n", button, on ? "on" : "off"); + + // Turn bit representing this button on or off. + + if (on) + { + mouse_button_state |= (1 << button); + } + else + { + mouse_button_state &= ~(1 << button); + } + + // Post an event with the new button state. + + event.type = ev_mouse; + event.data1 = mouse_button_state; + event.data2 = event.data3 = 0; + D_PostEvent(&event); } static int AccelerateMouse(int val) @@ -544,7 +577,7 @@ void I_GetEvent(void) /* case SDL_MOUSEMOTION: event.type = ev_mouse; - event.data1 = MouseButtonState(); + event.data1 = mouse_button_state; event.data2 = AccelerateMouse(sdlevent.motion.xrel); event.data3 = -AccelerateMouse(sdlevent.motion.yrel); D_PostEvent(&event); @@ -554,20 +587,14 @@ void I_GetEvent(void) case SDL_MOUSEBUTTONDOWN: if (usemouse && !nomouse) { - event.type = ev_mouse; - event.data1 = MouseButtonState(); - event.data2 = event.data3 = 0; - D_PostEvent(&event); + UpdateMouseButtonState(sdlevent.button.button, true); } break; case SDL_MOUSEBUTTONUP: if (usemouse && !nomouse) { - event.type = ev_mouse; - event.data1 = MouseButtonState(); - event.data2 = event.data3 = 0; - D_PostEvent(&event); + UpdateMouseButtonState(sdlevent.button.button, false); } break; @@ -637,7 +664,7 @@ static void I_ReadMouse(void) if (x != 0 || y != 0) { ev.type = ev_mouse; - ev.data1 = MouseButtonState(); + ev.data1 = mouse_button_state; ev.data2 = AccelerateMouse(x); ev.data3 = -AccelerateMouse(y); diff --git a/src/i_video.h b/src/i_video.h index bd5de24a..94ffcc29 100644 --- a/src/i_video.h +++ b/src/i_video.h @@ -28,10 +28,11 @@ #ifndef __I_VIDEO__ #define __I_VIDEO__ - #include "doomtype.h" -typedef struct +#define MAX_MOUSE_BUTTONS 8 + +typedef struct { // Screen width and height -- cgit v1.2.3 From d6a516833146d29d5e7b0d4f8ed6b80ecb193b88 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 20 Aug 2010 12:20:58 +0000 Subject: Align memory allocated by zone memory system to 8 byte boundaries on 64-bit machines. Possibly fixes problems on sparc64? Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1959 --- src/z_zone.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/z_zone.c b/src/z_zone.c index 975f41e5..2877fe6e 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -41,6 +41,7 @@ // because it will get overwritten automatically if needed. // +#define MEM_ALIGN sizeof(void *) #define ZONEID 0x1d4a11 typedef struct memblock_s @@ -201,7 +202,7 @@ Z_Malloc memblock_t* base; void *result; - size = (size + 3) & ~3; + size = (size + MEM_ALIGN - 1) & ~(MEM_ALIGN - 1); // scan through the block list, // looking for the first free block -- cgit v1.2.3 From 1d8283647fe152be88fad6b675c601ff8c423487 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 20 Aug 2010 13:01:29 +0000 Subject: Remove debug printf(). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1960 --- src/i_video.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index d2d0d169..ee10a12e 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -467,8 +467,6 @@ static void UpdateMouseButtonState(unsigned int button, boolean on) break; } - printf("button %i -> %s\n", button, on ? "on" : "off"); - // Turn bit representing this button on or off. if (on) -- cgit v1.2.3 From 14cf34bc65d7584984d26eea4154d58770125e60 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 22 Aug 2010 01:21:27 +0000 Subject: Change span drawing functions to work the same as Vanilla, so that in screenshots, floors and ceilings are pixel-perfect identical to Vanilla Doom (thanks Porsche Monty). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1963 --- src/r_draw.c | 111 ++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/r_draw.c b/src/r_draw.c index 6813ea59..b7d847d9 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -594,48 +594,54 @@ int dscount; // Draws the actual span. void R_DrawSpan (void) { - fixed_t xfrac; - fixed_t yfrac; - byte* dest; - int count; - int spot; - -#ifdef RANGECHECK + unsigned int position, step; + byte *dest; + int count; + int spot; + unsigned int xtemp, ytemp; + +#ifdef RANGECHECK if (ds_x2 < ds_x1 || ds_x1<0 - || ds_x2>=SCREENWIDTH + || ds_x2>=SCREENWIDTH || (unsigned)ds_y>SCREENHEIGHT) { I_Error( "R_DrawSpan: %i to %i at %i", ds_x1,ds_x2,ds_y); } -// dscount++; -#endif +// dscount++; +#endif + + // Pack position and step variables into a single 32-bit integer, + // with x in the top 16 bits and y in the bottom 16 bits. For + // each 16-bit part, the top 6 bits are the integer part and the + // bottom 10 bits are the fractional part of the pixel position. + + position = ((ds_xfrac << 10) & 0xffff0000) + | ((ds_yfrac >> 6) & 0x0000ffff); + step = ((ds_xstep << 10) & 0xffff0000) + | ((ds_ystep >> 6) & 0x0000ffff); - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - dest = ylookup[ds_y] + columnofs[ds_x1]; // We do not check for zero spans here? - count = ds_x2 - ds_x1; + count = ds_x2 - ds_x1; - do + do { - // Current texture index in u,v. - spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); + // Calculate current texture index in u,v. + ytemp = (position >> 4) & 0x0fc0; + xtemp = (position >> 26); + spot = xtemp | ytemp; // Lookup pixel from flat texture tile, // re-index using light/colormap. *dest++ = ds_colormap[ds_source[spot]]; - // Next step in u,v. - xfrac += ds_xstep; - yfrac += ds_ystep; - - } while (count--); -} + position += step; + + } while (count--); +} @@ -715,49 +721,54 @@ void R_DrawSpan (void) // // Again.. // -void R_DrawSpanLow (void) -{ - fixed_t xfrac; - fixed_t yfrac; - byte* dest; - int count; - int spot; - -#ifdef RANGECHECK +void R_DrawSpanLow (void) +{ + unsigned int position, step; + unsigned int xtemp, ytemp; + byte *dest; + int count; + int spot; + +#ifdef RANGECHECK if (ds_x2 < ds_x1 || ds_x1<0 - || ds_x2>=SCREENWIDTH + || ds_x2>=SCREENWIDTH || (unsigned)ds_y>SCREENHEIGHT) { I_Error( "R_DrawSpan: %i to %i at %i", ds_x1,ds_x2,ds_y); } // dscount++; -#endif - - xfrac = ds_xfrac; - yfrac = ds_yfrac; - - count = (ds_x2 - ds_x1); +#endif + + position = ((ds_xfrac << 10) & 0xffff0000) + | ((ds_yfrac >> 6) & 0x0000ffff); + step = ((ds_xstep << 10) & 0xffff0000) + | ((ds_ystep >> 6) & 0x0000ffff); + + count = (ds_x2 - ds_x1); // Blocky mode, need to multiply by 2. ds_x1 <<= 1; ds_x2 <<= 1; - + dest = ylookup[ds_y] + columnofs[ds_x1]; - - do - { - spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63); + + do + { + // Calculate current texture index in u,v. + ytemp = (position >> 4) & 0x0fc0; + xtemp = (position >> 26); + spot = xtemp | ytemp; + // Lowres/blocky mode does it twice, // while scale is adjusted appropriately. - *dest++ = ds_colormap[ds_source[spot]]; *dest++ = ds_colormap[ds_source[spot]]; - - xfrac += ds_xstep; - yfrac += ds_ystep; + *dest++ = ds_colormap[ds_source[spot]]; - } while (count--); + position += step; + + } while (count--); } // -- cgit v1.2.3