From 535c64b336ce59b4e18819544cd2a1129ae97c61 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 12 Mar 2009 18:55:27 +0000 Subject: Define INVALID_SET_FILE_POINTER if it is not defined, to fix compilation under MSVC6 (thanks Quasar) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1466 --- src/w_file_win32.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/w_file_win32.c b/src/w_file_win32.c index 05d3c445..d5e60579 100644 --- a/src/w_file_win32.c +++ b/src/w_file_win32.c @@ -35,6 +35,12 @@ #include "w_file.h" #include "z_zone.h" +// This constant doesn't exist in VC6: + +#ifndef INVALID_SET_FILE_POINTER +#define INVALID_SET_FILE_POINTER 0xffffffff +#endif + typedef struct { wad_file_t wad; -- cgit v1.2.3 From e2e1069332289a714ebebc71db225510c6d8ebff Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 14 Mar 2009 15:28:41 +0000 Subject: Add check to allow sched_setaffinity code to work on older versions of libc. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1470 --- src/i_main.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/i_main.c b/src/i_main.c index 7c5b16e7..3a9ec696 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -29,18 +29,6 @@ #include "SDL.h" -#include - -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include -#endif - -#ifdef HAVE_SCHED_SETAFFINITY -#include -#include -#endif - #include "doomdef.h" #include "i_system.h" #include "m_argv.h" @@ -48,6 +36,9 @@ #if defined(_WIN32) +#define WIN32_LEAN_AND_MEAN +#include + typedef BOOL WINAPI (*SetAffinityFunc)(HANDLE hProcess, DWORD_PTR mask); // This is a bit more complicated than it really needs to be. We really @@ -93,16 +84,24 @@ static void LockCPUAffinity(void) #elif defined(HAVE_SCHED_SETAFFINITY) +#include +#include + // Unix (Linux) version: static void LockCPUAffinity(void) { +#ifdef CPU_SET cpu_set_t set; CPU_ZERO(&set); CPU_SET(0, &set); sched_setaffinity(getpid(), sizeof(set), &set); +#else + unsigned long mask = 1; + sched_setaffinity(getpid(), sizeof(mask), &mask); +#endif } #else -- cgit v1.2.3 From 578fd9aafdee97bc95cb81811fdc63ca17dd2850 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 15 Mar 2009 14:44:23 +0000 Subject: Fix clipped sounds when using libsamplerate (thanks David Flater) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1479 --- src/i_sdlsound.c | 378 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 214 insertions(+), 164 deletions(-) (limited to 'src') diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index b6fc9787..f3af667e 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "SDL.h" #include "SDL_mixer.h" @@ -58,11 +59,12 @@ static int channels_playing[NUM_CHANNELS]; static int mixer_freq; static Uint16 mixer_format; static int mixer_channels; -static uint32_t (*ExpandSoundData)(byte *data, int samplerate, int length, - Mix_Chunk *destination) = NULL; int use_libsamplerate = 0; +extern int mb_used; + + // When a sound stops, check if it is still playing. If it is not, // we can mark the sound data as CACHE to be freed back for other // means. @@ -79,6 +81,12 @@ static void ReleaseSoundOnChannel(int channel) channels_playing[channel] = sfx_None; +#ifdef HAVE_LIBSAMPLERATE + // Don't allow precached sounds to be swapped out. + if (use_libsamplerate) + return; +#endif + for (i=0; i signed 16 bits -// mono --> stereo -// samplerate --> mixer_freq -// Returns number of clipped samples. -// DWF 2008-02-10 with cleanups by Simon Howard. - -static uint32_t ExpandSoundData_SRC(byte *data, - int samplerate, - int length, - Mix_Chunk *destination) -{ - SRC_DATA src_data; - uint32_t i, abuf_index=0, clipped=0; - int retn; - int16_t *expanded; - - src_data.input_frames = length; - src_data.data_in = malloc(length * sizeof(float)); - src_data.src_ratio = (double)mixer_freq / samplerate; - - // We include some extra space here in case of rounding-up. - src_data.output_frames = src_data.src_ratio * length + (mixer_freq / 4); - src_data.data_out = malloc(src_data.output_frames * sizeof(float)); - - assert(src_data.data_in != NULL && src_data.data_out != NULL); - - // Convert input data to floats - - for (i=0; ialen = src_data.output_frames_gen * 4; - destination->abuf = Z_Malloc(destination->alen, PU_STATIC, - &destination->abuf); - expanded = (int16_t *) destination->abuf; - - for (i=0; i INT16_MAX) { - cvtval_i = INT16_MAX; - ++clipped; - } - - // Left and right channels - - expanded[abuf_index++] = cvtval_i; - expanded[abuf_index++] = cvtval_i; - } - - free(src_data.data_in); - free(src_data.data_out); - return clipped; -} - #endif static boolean ConvertibleRatio(int freq1, int freq2) @@ -248,12 +162,11 @@ static boolean ConvertibleRatio(int freq1, int freq2) } // Generic sound expansion function for any sample rate. -// Returns number of clipped samples (always 0). -static uint32_t ExpandSoundData_SDL(byte *data, - int samplerate, - int length, - Mix_Chunk *destination) +static void ExpandSoundData_SDL(byte *data, + int samplerate, + uint32_t length, + Mix_Chunk *destination) { SDL_AudioCVT convertor; uint32_t expanded_length; @@ -265,7 +178,6 @@ static uint32_t ExpandSoundData_SDL(byte *data, // Double up twice: 8 -> 16 bit and mono -> stereo expanded_length *= 4; - destination->alen = expanded_length; destination->abuf = Z_Malloc(expanded_length, PU_STATIC, &destination->abuf); @@ -344,69 +256,92 @@ static uint32_t ExpandSoundData_SDL(byte *data, } #endif /* #ifdef LOW_PASS_FILTER */ } - - return 0; } -// Load and convert a sound effect -// Returns true if successful -static boolean CacheSFX(int sound) +// Load and validate a sound effect lump. +// Preconditions: +// S_sfx[sound].lumpnum has been set +// Postconditions if sound is valid: +// returns true +// starred parameters are set, with data_ref pointing to start of sound +// caller is responsible for releasing the identified lump +// Postconditions if sound is invalid: +// returns false +// starred parameters are garbage +// lump already released + +static boolean LoadSoundLump(int sound, + int *lumpnum, + int *samplerate, + uint32_t *length, + byte **data_ref) { - int lumpnum; - unsigned int lumplen; - int samplerate; - int clipped; - unsigned int length; - byte *data; - - // need to load the sound + // Load the sound - lumpnum = S_sfx[sound].lumpnum; - data = W_CacheLumpNum(lumpnum, PU_STATIC); - lumplen = W_LumpLength(lumpnum); + *lumpnum = S_sfx[sound].lumpnum; + *data_ref = W_CacheLumpNum(*lumpnum, PU_STATIC); + int lumplen = W_LumpLength(*lumpnum); + byte *data = *data_ref; - // Check the header, and ensure this is a valid sound + // Ensure this is a valid sound - if (lumplen < 8 - || data[0] != 0x03 || data[1] != 0x00) + if (lumplen < 8 || data[0] != 0x03 || data[1] != 0x00) { - // Invalid sound - - return false; + // Invalid sound + W_ReleaseLumpNum(*lumpnum); + return false; } // 16 bit sample rate field, 32 bit length field - samplerate = (data[3] << 8) | data[2]; - length = (data[7] << 24) | (data[6] << 16) | (data[5] << 8) | data[4]; + *samplerate = (data[3] << 8) | data[2]; + *length = (data[7] << 24) | (data[6] << 16) | (data[5] << 8) | data[4]; - // If the header specifies that the length of the sound is greater than - // the length of the lump itself, this is an invalid sound lump + // If the header specifies that the length of the sound is + // greater than the length of the lump itself, this is an invalid + // sound lump. - if (length > lumplen - 8) + if (*length > lumplen - 8) { - return false; + W_ReleaseLumpNum(*lumpnum); + return false; } + // Prune header + *data_ref += 8; + + return true; +} + + +// Load and convert a sound effect +// Returns true if successful + +static boolean CacheSFX_SDL(int sound) +{ + int lumpnum; + int samplerate; + uint32_t length; + byte *data; + +#ifdef HAVE_LIBSAMPLERATE + assert(!use_libsamplerate); // Should be using I_PrecacheSounds_SRC instead +#endif + + if (!LoadSoundLump(sound, &lumpnum, &samplerate, &length, &data)) + return false; + // Sample rate conversion - // DWF 2008-02-10: sound_chunks[sound].alen and abuf are determined - // by ExpandSoundData. + // sound_chunks[sound].alen and abuf are determined by ExpandSoundData. sound_chunks[sound].allocated = 1; sound_chunks[sound].volume = MIX_MAX_VOLUME; - clipped = ExpandSoundData(data + 8, - samplerate, - length, - &sound_chunks[sound]); - - if (clipped) - { - fprintf(stderr, "Sound %d: clipped %u samples (%0.2f %%)\n", - sound, clipped, - 400.0 * clipped / sound_chunks[sound].alen); - } + ExpandSoundData_SDL(data, + samplerate, + length, + &sound_chunks[sound]); // don't need the original lump any more @@ -415,50 +350,169 @@ static boolean CacheSFX(int sound) return true; } + #ifdef HAVE_LIBSAMPLERATE -// Preload all the sound effects - stops nasty ingame freezes +// Preload and resample all sound effects with libsamplerate. -static void I_PrecacheSounds(void) +static void I_PrecacheSounds_SRC(void) { char namebuf[9]; - int i; + uint32_t sound_i, sample_i; + boolean good_sound[NUMSFX]; + float *resampled_sound[NUMSFX]; + uint32_t resampled_sound_length[NUMSFX]; + float norm_factor; + float max_amp = 0; - printf("I_PrecacheSounds: Precaching all sound effects.."); + assert(use_libsamplerate); - for (i=sfx_pistol; i 0); + resampled_sound[sound_i] = src_data.data_out; + resampled_sound_length[sound_i] = src_data.output_frames_gen; + free(src_data.data_in); + good_sound[sound_i] = true; + + // Track maximum amplitude for later normalization + + rsound = resampled_sound[sound_i]; + rlen = resampled_sound_length[sound_i]; + for (sample_i=0; sample_i max_amp) + max_amp = fabs_amp; + } + } + } + + // Pass 2: normalize and convert to signed 16-bit stereo. - S_sfx[i].lumpnum = W_CheckNumForName(namebuf); + if (max_amp <= 0) + max_amp = 1; + norm_factor = INT16_MAX / max_amp; - if (S_sfx[i].lumpnum != -1) + for (sound_i=sfx_pistol; sound_i limit) + { + return (1 << n); + } + } + + // Should never happen? + + return 1024; +} + static boolean I_SDL_InitSound(void) { int i; - int slicesize; // No sounds yet @@ -690,9 +715,7 @@ static boolean I_SDL_InitSound(void) return false; } - slicesize = (snd_samplerate * SOUND_SLICE_TIME) / 1000; - - if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, slicesize) < 0) + if (Mix_OpenAudio(snd_samplerate, AUDIO_S16SYS, 2, GetSliceSize()) < 0) { fprintf(stderr, "Error initialising SDL_mixer: %s\n", Mix_GetError()); return false; -- cgit v1.2.3 From 1c78ab7f5f69f49114a150d28c0c7506b14198f1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 18 May 2009 18:30:49 +0000 Subject: Fix A_BossDeath behavior in v1.9 emulation mode (thanks entryway) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1525 --- src/p_enemy.c | 122 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 55 insertions(+), 67 deletions(-) (limited to 'src') diff --git a/src/p_enemy.c b/src/p_enemy.c index 4729dbc5..760bbbc8 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1612,6 +1612,57 @@ void A_Explode (mobj_t* thingy) P_RadiusAttack(thingy, thingy->target, 128); } +// Check whether the death of the specified monster type is allowed +// to trigger the end of episode special action. +// +// This behavior changed in v1.9, the most notable effect of which +// was to break uac_dead.wad + +static boolean CheckBossEnd(mobjtype_t motype) +{ + if (gameversion < exe_ultimate) + { + if (gamemap != 8) + { + return false; + } + + // Baron death on later episodes is nothing special. + + if (motype == MT_BRUISER && gameepisode != 1) + { + return false; + } + + return true; + } + else + { + // New logic that appeared in Ultimate Doom. + // Looks like the logic was overhauled while adding in the + // episode 4 support. Now bosses only trigger on their + // specific episode. + + switch(gameepisode) + { + case 1: + return gamemap == 8 && motype == MT_BRUISER; + + case 2: + return gamemap == 8 && motype == MT_CYBORG; + + case 3: + return gamemap == 8 && motype == MT_SPIDER; + + case 4: + return (gamemap == 6 && motype == MT_CYBORG) + || (gamemap == 8 && motype == MT_SPIDER); + + default: + return gamemap == 8; + } + } +} // // A_BossDeath @@ -1636,75 +1687,12 @@ void A_BossDeath (mobj_t* mo) } else { - switch(gameepisode) - { - case 1: - if (gamemap != 8) - return; - - // fraggle: disable this as it breaks uac_dead.wad. - // There is at least one version of Doom 1.9 which it is - // possible to play uac_dead through on. I think this was - // added here for Ultimate Doom. - // - // See lmps/doom/ultimate/uac_dead.zip in idgames for - // an example of a demo which goes out of sync if this - // is left in here. - // - // For the time being, I'm making the assumption that - // doing this is not going to break anything else. - // - // 2005/10/24: Modify this to test the gameversion setting - - if (gameversion >= exe_ultimate && mo->type != MT_BRUISER) - return; - break; - - case 2: - if (gamemap != 8) - return; - - if (mo->type != MT_CYBORG) - return; - break; - - case 3: - if (gamemap != 8) - return; - - if (mo->type != MT_SPIDER) - return; - - break; - - case 4: - switch(gamemap) - { - case 6: - if (mo->type != MT_CYBORG) - return; - break; - - case 8: - if (mo->type != MT_SPIDER) - return; - break; - - default: - return; - break; - } - break; - - default: - if (gamemap != 8) - return; - break; - } - + if (!CheckBossEnd(mo->type)) + { + return; + } } - // make sure there is a player alive for victory for (i=0 ; i 0) -- cgit v1.2.3 From 0794d30b63dbdb3eeb8c2cbed67316a1b4e7c885 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 3 Jun 2009 19:37:19 +0000 Subject: Add key_ variables for the keys used to control the menu. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1542 --- src/m_menu.c | 232 ++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 152 insertions(+), 80 deletions(-) (limited to 'src') diff --git a/src/m_menu.c b/src/m_menu.c index aab2afce..dc182569 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -71,6 +71,35 @@ extern boolean message_dontfuckwithme; extern boolean chat_on; // in heads-up code +// +// menu keys: +// + +int key_menu_activate = KEY_ESCAPE; +int key_menu_up = KEY_UPARROW; +int key_menu_down = KEY_DOWNARROW; +int key_menu_left = KEY_LEFTARROW; +int key_menu_right = KEY_RIGHTARROW; +int key_menu_back = KEY_BACKSPACE; +int key_menu_forward = KEY_ENTER; +int key_menu_confirm = 'y'; +int key_menu_abort = 'n'; + +int key_menu_help = KEY_F1; +int key_menu_save = KEY_F2; +int key_menu_load = KEY_F3; +int key_menu_volume = KEY_F4; +int key_menu_detail = KEY_F5; +int key_menu_qsave = KEY_F6; +int key_menu_endgame = KEY_F7; +int key_menu_messages = KEY_F8; +int key_menu_qload = KEY_F9; +int key_menu_quit = KEY_F10; +int key_menu_gamma = KEY_F11; + +int key_menu_incscreen = KEY_EQUALS; +int key_menu_decscreen = KEY_MINUS; + // // defaulted values // @@ -672,9 +701,9 @@ void M_SaveGame (int choice) // char tempstring[80]; -void M_QuickSaveResponse(int ch) +void M_QuickSaveResponse(int key) { - if (ch == 'y') + if (key == key_menu_confirm) { M_DoSave(quickSaveSlot); S_StartSound(NULL,sfx_swtchx); @@ -709,9 +738,9 @@ void M_QuickSave(void) // // M_QuickLoad // -void M_QuickLoadResponse(int ch) +void M_QuickLoadResponse(int key) { - if (ch == 'y') + if (key == key_menu_confirm) { M_LoadSelect(quickSaveSlot); S_StartSound(NULL,sfx_swtchx); @@ -924,9 +953,9 @@ void M_DrawEpisode(void) V_DrawPatchDirect (54,38,0,W_CacheLumpName(DEH_String("M_EPISOD"),PU_CACHE)); } -void M_VerifyNightmare(int ch) +void M_VerifyNightmare(int key) { - if (ch != 'y') + if (key != key_menu_confirm) return; G_DeferedInitNew(nightmare,epi+1,1); @@ -1024,9 +1053,9 @@ void M_ChangeMessages(int choice) // // M_EndGame // -void M_EndGameResponse(int ch) +void M_EndGameResponse(int key) { - if (ch != 'y') + if (key != key_menu_confirm) return; currentMenu->lastOn = itemOn; @@ -1120,9 +1149,9 @@ int quitsounds2[8] = -void M_QuitResponse(int ch) +void M_QuitResponse(int key) { - if (ch != 'y') + if (key != key_menu_confirm) return; if (!netgame) { @@ -1421,34 +1450,34 @@ boolean M_Responder (event_t* ev) { if (ev->data3 == -1) { - key = KEY_UPARROW; + key = key_menu_up; joywait = I_GetTime() + 5; } else if (ev->data3 == 1) { - key = KEY_DOWNARROW; + key = key_menu_down; joywait = I_GetTime() + 5; } if (ev->data2 == -1) { - key = KEY_LEFTARROW; + key = key_menu_left; joywait = I_GetTime() + 2; } else if (ev->data2 == 1) { - key = KEY_RIGHTARROW; + key = key_menu_right; joywait = I_GetTime() + 2; } if (ev->data1&1) { - key = KEY_ENTER; + key = key_menu_forward; joywait = I_GetTime() + 5; } if (ev->data1&2) { - key = KEY_BACKSPACE; + key = key_menu_back; joywait = I_GetTime() + 5; } } @@ -1459,13 +1488,13 @@ boolean M_Responder (event_t* ev) mousey += ev->data3; if (mousey < lasty-30) { - key = KEY_DOWNARROW; + key = key_menu_down; mousewait = I_GetTime() + 5; mousey = lasty -= 30; } else if (mousey > lasty+30) { - key = KEY_UPARROW; + key = key_menu_up; mousewait = I_GetTime() + 5; mousey = lasty += 30; } @@ -1473,26 +1502,26 @@ boolean M_Responder (event_t* ev) mousex += ev->data2; if (mousex < lastx-30) { - key = KEY_LEFTARROW; + key = key_menu_left; mousewait = I_GetTime() + 5; mousex = lastx -= 30; } else if (mousex > lastx+30) { - key = KEY_RIGHTARROW; + key = key_menu_right; mousewait = I_GetTime() + 5; mousex = lastx += 30; } if (ev->data1&1) { - key = KEY_ENTER; + key = key_menu_forward; mousewait = I_GetTime() + 15; } if (ev->data1&2) { - key = KEY_BACKSPACE; + key = key_menu_back; mousewait = I_GetTime() + 15; } } @@ -1514,7 +1543,7 @@ boolean M_Responder (event_t* ev) if (testcontrols) { - if (key == KEY_ESCAPE || key == KEY_F10) + if (key == key_menu_activate || key == key_menu_quit) { I_Quit(); return true; @@ -1574,121 +1603,136 @@ boolean M_Responder (event_t* ev) // Take care of any messages that need input if (messageToPrint) { - if (messageNeedsInput == true && - !(ch == ' ' || ch == 'n' || ch == 'y' || key == KEY_ESCAPE)) - return false; - + if (messageNeedsInput) + { + if (ch != ' ' && ch != KEY_ESCAPE + && ch != key_menu_confirm && ch != key_menu_abort) + { + return false; + } + } + menuactive = messageLastMenuActive; messageToPrint = 0; if (messageRoutine) messageRoutine(ch); - + menuactive = false; S_StartSound(NULL,sfx_swtchx); return true; } - - if (devparm && key == KEY_F1) + + if (devparm && key == key_menu_help) { G_ScreenShot (); return true; } - - + // F-Keys if (!menuactive) - switch(key) - { - case KEY_MINUS: // Screen size down + { + if (key == key_menu_decscreen) // Screen size down + { if (automapactive || chat_on) return false; M_SizeDisplay(0); S_StartSound(NULL,sfx_stnmov); return true; - - case KEY_EQUALS: // Screen size up + } + else if (key == key_menu_incscreen) // Screen size up + { if (automapactive || chat_on) return false; M_SizeDisplay(1); S_StartSound(NULL,sfx_stnmov); return true; - - case KEY_F1: // Help key + } + else if (key == key_menu_help) // Help key + { M_StartControlPanel (); if ( gamemode == retail ) currentMenu = &ReadDef2; else currentMenu = &ReadDef1; - + itemOn = 0; S_StartSound(NULL,sfx_swtchn); return true; - - case KEY_F2: // Save + } + else if (key == key_menu_save) // Save + { M_StartControlPanel(); S_StartSound(NULL,sfx_swtchn); M_SaveGame(0); return true; - - case KEY_F3: // Load + } + else if (key == key_menu_load) // Load + { M_StartControlPanel(); S_StartSound(NULL,sfx_swtchn); M_LoadGame(0); return true; - - case KEY_F4: // Sound Volume + } + else if (key == key_menu_volume) // Sound Volume + { M_StartControlPanel (); currentMenu = &SoundDef; itemOn = sfx_vol; S_StartSound(NULL,sfx_swtchn); return true; - - case KEY_F5: // Detail toggle + } + else if (key == key_menu_detail) // Detail toggle + { M_ChangeDetail(0); S_StartSound(NULL,sfx_swtchn); return true; - - case KEY_F6: // Quicksave + } + else if (key == key_menu_qsave) // Quicksave + { S_StartSound(NULL,sfx_swtchn); M_QuickSave(); return true; - - case KEY_F7: // End game + } + else if (key == key_menu_endgame) // End game + { S_StartSound(NULL,sfx_swtchn); M_EndGame(0); return true; - - case KEY_F8: // Toggle messages + } + else if (key == key_menu_messages) // Toggle messages + { M_ChangeMessages(0); S_StartSound(NULL,sfx_swtchn); return true; - - case KEY_F9: // Quickload + } + else if (key == key_menu_qload) // Quickload + { S_StartSound(NULL,sfx_swtchn); M_QuickLoad(); return true; - - case KEY_F10: // Quit DOOM + } + else if (key == key_menu_quit) // Quit DOOM + { S_StartSound(NULL,sfx_swtchn); M_QuitDOOM(0); return true; - - case KEY_F11: // gamma toggle + } + else if (key == key_menu_gamma) // gamma toggle + { usegamma++; if (usegamma > 4) usegamma = 0; players[consoleplayer].message = DEH_String(gammamsg[usegamma]); I_SetPalette (W_CacheLumpName (DEH_String("PLAYPAL"),PU_CACHE)); return true; - } + } - // Pop-up menu? if (!menuactive) { - if (key == KEY_ESCAPE) + if (key == key_menu_activate) { M_StartControlPanel (); S_StartSound(NULL,sfx_swtchn); @@ -1699,19 +1743,25 @@ boolean M_Responder (event_t* ev) // Keys usable within menu - switch (key) + + if (key == key_menu_down) { - case KEY_DOWNARROW: - do + // Move down to next item + + do { if (itemOn+1 > currentMenu->numitems-1) itemOn = 0; else itemOn++; S_StartSound(NULL,sfx_pstop); } while(currentMenu->menuitems[itemOn].status==-1); + return true; - - case KEY_UPARROW: + } + else if (key == key_menu_up) + { + // Move back up to previous item + do { if (!itemOn) @@ -1719,9 +1769,13 @@ boolean M_Responder (event_t* ev) else itemOn--; S_StartSound(NULL,sfx_pstop); } while(currentMenu->menuitems[itemOn].status==-1); + return true; + } + else if (key == key_menu_left) + { + // Slide slider left - case KEY_LEFTARROW: if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2) { @@ -1729,8 +1783,11 @@ boolean M_Responder (event_t* ev) currentMenu->menuitems[itemOn].routine(0); } return true; - - case KEY_RIGHTARROW: + } + else if (key == key_menu_right) + { + // Slide slider right + if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status == 2) { @@ -1738,8 +1795,11 @@ boolean M_Responder (event_t* ev) currentMenu->menuitems[itemOn].routine(1); } return true; + } + else if (key == key_menu_forward) + { + // Activate menu item - case KEY_ENTER: if (currentMenu->menuitems[itemOn].routine && currentMenu->menuitems[itemOn].status) { @@ -1756,14 +1816,20 @@ boolean M_Responder (event_t* ev) } } return true; - - case KEY_ESCAPE: + } + else if (key == key_menu_activate) + { + // Deactivate menu + currentMenu->lastOn = itemOn; M_ClearMenus (); S_StartSound(NULL,sfx_swtchx); return true; - - case KEY_BACKSPACE: + } + else if (key == key_menu_back) + { + // Go back to previous menu + currentMenu->lastOn = itemOn; if (currentMenu->prevMenu) { @@ -1772,24 +1838,30 @@ boolean M_Responder (event_t* ev) S_StartSound(NULL,sfx_swtchn); } return true; - - default: + } + else + { + // Keyboard shortcut? + for (i = itemOn+1;i < currentMenu->numitems;i++) + { if (currentMenu->menuitems[i].alphaKey == ch) { itemOn = i; S_StartSound(NULL,sfx_pstop); return true; } + } + for (i = 0;i <= itemOn;i++) + { if (currentMenu->menuitems[i].alphaKey == ch) { itemOn = i; S_StartSound(NULL,sfx_pstop); return true; } - break; - + } } return false; -- cgit v1.2.3 From 5a19f1d85430f2cb3a4812842c834f2d6e41e0f4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 3 Jun 2009 19:55:50 +0000 Subject: Add configuration file entries for menu key bindings. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1543 --- src/m_config.c | 148 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) (limited to 'src') diff --git a/src/m_config.c b/src/m_config.c index 4066cb3c..8acdf415 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -87,6 +87,33 @@ extern int key_use; extern int key_strafe; extern int key_speed; +// Menu control keys: + +extern int key_menu_activate; +extern int key_menu_up; +extern int key_menu_down; +extern int key_menu_left; +extern int key_menu_right; +extern int key_menu_back; +extern int key_menu_forward; +extern int key_menu_confirm; +extern int key_menu_abort; + +extern int key_menu_help; +extern int key_menu_save; +extern int key_menu_load; +extern int key_menu_volume; +extern int key_menu_detail; +extern int key_menu_qsave; +extern int key_menu_endgame; +extern int key_menu_messages; +extern int key_menu_qload; +extern int key_menu_quit; +extern int key_menu_gamma; + +extern int key_menu_incscreen; +extern int key_menu_decscreen; + extern int mousebfire; extern int mousebstrafe; extern int mousebforward; @@ -710,6 +737,127 @@ static default_t extra_defaults_list[] = // CONFIG_VARIABLE_INT(use_libsamplerate, use_libsamplerate), + + //! + // Key that activates the menu when pressed. + // + + CONFIG_VARIABLE_KEY(key_menu_activate, key_menu_activate), + + //! + // Key that moves the cursor up on the menu. + // + + CONFIG_VARIABLE_KEY(key_menu_up, key_menu_up), + + //! + // Key that moves the cursor down on the menu. + // + + CONFIG_VARIABLE_KEY(key_menu_down, key_menu_down), + + //! + // Key that moves the currently selected slider on the menu left. + // + + CONFIG_VARIABLE_KEY(key_menu_left, key_menu_left), + + //! + // Key that moves the currently selected slider on the menu right. + // + + CONFIG_VARIABLE_KEY(key_menu_right, key_menu_right), + + //! + // Key to go back to the previous menu. + // + + CONFIG_VARIABLE_KEY(key_menu_back, key_menu_back), + + //! + // Key to activate the currently selected menu item. + // + + CONFIG_VARIABLE_KEY(key_menu_forward, key_menu_forward), + + //! + // Key to answer 'yes' to a question in the menu. + // + + CONFIG_VARIABLE_KEY(key_menu_confirm, key_menu_confirm), + + //! + // Key to answer 'no' to a question in the menu. + // + + CONFIG_VARIABLE_KEY(key_menu_abort, key_menu_abort), + + //! + // Keyboard shortcut to bring up the help screen. + // + + CONFIG_VARIABLE_KEY(key_menu_help, key_menu_help), + + //! + // Keyboard shortcut to bring up the save game menu. + // + + CONFIG_VARIABLE_KEY(key_menu_save, key_menu_save), + + //! + // Keyboard shortcut to bring up the load game menu. + // + + CONFIG_VARIABLE_KEY(key_menu_load, key_menu_load), + + //! + // Keyboard shortcut to bring up the sound volume menu. + // + + CONFIG_VARIABLE_KEY(key_menu_volume, key_menu_volume), + + //! + // Keyboard shortcut to toggle the detail level. + // + + CONFIG_VARIABLE_KEY(key_menu_detail, key_menu_detail), + + //! + // Keyboard shortcut to quicksave the current game. + // + + CONFIG_VARIABLE_KEY(key_menu_qsave, key_menu_qsave), + + //! + // Keyboard shortcut to end the game. + // + + CONFIG_VARIABLE_KEY(key_menu_endgame, key_menu_endgame), + + //! + // Keyboard shortcut to toggle heads-up messages. + // + + CONFIG_VARIABLE_KEY(key_menu_messages, key_menu_messages), + + //! + // Keyboard shortcut to load the last quicksave. + // + + CONFIG_VARIABLE_KEY(key_menu_qload, key_menu_qload), + + //! + // Keyboard shortcut to quit the game. + // + + CONFIG_VARIABLE_KEY(key_menu_quit, key_menu_quit), + + //! + // Keyboard shortcut to toggle the gamma correction level. + // + + CONFIG_VARIABLE_KEY(key_menu_gamma, key_menu_gamma), + }; static default_collection_t extra_defaults = -- cgit v1.2.3 From b3a03a40660e7bc4cbc2720aeb5c9c35c5de030a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 3 Jun 2009 19:59:26 +0000 Subject: Fix shortcut keys for menu items. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1544 --- src/m_menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/m_menu.c b/src/m_menu.c index dc182569..6809e6c0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1839,7 +1839,7 @@ boolean M_Responder (event_t* ev) } return true; } - else + else if (ch != 0) { // Keyboard shortcut? -- cgit v1.2.3 From 334af5fd565c261f070a42d17a1429cfca1b6651 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 3 Jun 2009 20:18:04 +0000 Subject: Add config file variables to increase/decrease screen size. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1545 --- src/m_config.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/m_config.c b/src/m_config.c index 8acdf415..251588a1 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -858,6 +858,18 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_KEY(key_menu_gamma, key_menu_gamma), + //! + // Keyboard shortcut to increase the screen size. + // + + CONFIG_VARIABLE_KEY(key_menu_incscreen, key_menu_incscreen), + + //! + // Keyboard shortcut to decrease the screen size. + // + + CONFIG_VARIABLE_KEY(key_menu_decscreen, key_menu_decscreen), + }; static default_collection_t extra_defaults = -- cgit v1.2.3 From 500bcb6919887185f4f98763a36c5c243e11bae5 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 3 Jun 2009 23:20:06 +0000 Subject: Use key for confirming menu messages, not typed char. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1547 --- src/m_menu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/m_menu.c b/src/m_menu.c index 6809e6c0..1ced1d16 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -1605,8 +1605,8 @@ boolean M_Responder (event_t* ev) { if (messageNeedsInput) { - if (ch != ' ' && ch != KEY_ESCAPE - && ch != key_menu_confirm && ch != key_menu_abort) + if (key != ' ' && key != KEY_ESCAPE + && key != key_menu_confirm && key != key_menu_abort) { return false; } @@ -1615,7 +1615,7 @@ boolean M_Responder (event_t* ev) menuactive = messageLastMenuActive; messageToPrint = 0; if (messageRoutine) - messageRoutine(ch); + messageRoutine(key); menuactive = false; S_StartSound(NULL,sfx_swtchx); -- cgit v1.2.3 From e3e71290f86c785a29ec6b9eeb609c7625776255 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 5 Jun 2009 16:58:48 +0000 Subject: Add key binding variables for automap and weapon keys. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1551 --- src/am_map.c | 210 ++++++++++++++++++++++++++++++--------------------------- src/g_game.c | 33 +++++++-- src/m_config.c | 143 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 284 insertions(+), 102 deletions(-) (limited to 'src') diff --git a/src/am_map.c b/src/am_map.c index 5fbe748a..9a81d62c 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -90,19 +90,18 @@ // drawing stuff #define FB 0 -#define AM_PANDOWNKEY KEY_DOWNARROW -#define AM_PANUPKEY KEY_UPARROW -#define AM_PANRIGHTKEY KEY_RIGHTARROW -#define AM_PANLEFTKEY KEY_LEFTARROW -#define AM_ZOOMINKEY '=' -#define AM_ZOOMOUTKEY '-' -#define AM_STARTKEY KEY_TAB -#define AM_ENDKEY KEY_TAB -#define AM_GOBIGKEY '0' -#define AM_FOLLOWKEY 'f' -#define AM_GRIDKEY 'g' -#define AM_MARKKEY 'm' -#define AM_CLEARMARKKEY 'c' +int key_map_north = KEY_UPARROW; +int key_map_south = KEY_DOWNARROW; +int key_map_east = KEY_RIGHTARROW; +int key_map_west = KEY_LEFTARROW; +int key_map_zoomin = '='; +int key_map_zoomout = '-'; +int key_map_toggle = KEY_TAB; +int key_map_maxzoom = '0'; +int key_map_follow = 'f'; +int key_map_grid = 'g'; +int key_map_mark = 'm'; +int key_map_clearmark = 'c'; #define AM_NUMMARKPOINTS 10 @@ -632,121 +631,136 @@ AM_Responder static int cheatstate=0; static int bigstate=0; static char buffer[20]; + int key; rc = false; if (!automapactive) { - if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY) + if (ev->type == ev_keydown && ev->data1 == key_map_toggle) { AM_Start (); viewactive = false; rc = true; } } - else if (ev->type == ev_keydown) { - rc = true; - switch(ev->data1) - { - case AM_PANRIGHTKEY: // pan right - if (!followplayer) m_paninc.x = FTOM(F_PANINC); - else rc = false; - break; - case AM_PANLEFTKEY: // pan left - if (!followplayer) m_paninc.x = -FTOM(F_PANINC); - else rc = false; - break; - case AM_PANUPKEY: // pan up - if (!followplayer) m_paninc.y = FTOM(F_PANINC); - else rc = false; - break; - case AM_PANDOWNKEY: // pan down - if (!followplayer) m_paninc.y = -FTOM(F_PANINC); - else rc = false; - break; - case AM_ZOOMOUTKEY: // zoom out - mtof_zoommul = M_ZOOMOUT; - ftom_zoommul = M_ZOOMIN; - break; - case AM_ZOOMINKEY: // zoom in - mtof_zoommul = M_ZOOMIN; - ftom_zoommul = M_ZOOMOUT; - break; - case AM_ENDKEY: - bigstate = 0; - viewactive = true; - AM_Stop (); - break; - case AM_GOBIGKEY: - bigstate = !bigstate; - if (bigstate) - { - AM_saveScaleAndLoc(); - AM_minOutWindowScale(); - } - else AM_restoreScaleAndLoc(); - break; - case AM_FOLLOWKEY: - followplayer = !followplayer; - f_oldloc.x = INT_MAX; + key = ev->data1; + + if (key == key_map_east) // pan right + { + if (!followplayer) m_paninc.x = FTOM(F_PANINC); + else rc = false; + } + else if (key == key_map_west) // pan left + { + if (!followplayer) m_paninc.x = -FTOM(F_PANINC); + else rc = false; + } + else if (key == key_map_north) // pan up + { + if (!followplayer) m_paninc.y = FTOM(F_PANINC); + else rc = false; + } + else if (key == key_map_south) // pan down + { + if (!followplayer) m_paninc.y = -FTOM(F_PANINC); + else rc = false; + } + else if (key == key_map_zoomout) // zoom out + { + mtof_zoommul = M_ZOOMOUT; + ftom_zoommul = M_ZOOMIN; + } + else if (key == key_map_zoomin) // zoom in + { + mtof_zoommul = M_ZOOMIN; + ftom_zoommul = M_ZOOMOUT; + } + else if (key == key_map_toggle) + { + bigstate = 0; + viewactive = true; + AM_Stop (); + } + else if (key == key_map_maxzoom) + { + bigstate = !bigstate; + if (bigstate) + { + AM_saveScaleAndLoc(); + AM_minOutWindowScale(); + } + else AM_restoreScaleAndLoc(); + } + else if (key == key_map_follow) + { + followplayer = !followplayer; + f_oldloc.x = INT_MAX; if (followplayer) plr->message = DEH_String(AMSTR_FOLLOWON); else plr->message = DEH_String(AMSTR_FOLLOWOFF); - break; - case AM_GRIDKEY: - grid = !grid; + } + else if (key == key_map_grid) + { + grid = !grid; if (grid) plr->message = DEH_String(AMSTR_GRIDON); else plr->message = DEH_String(AMSTR_GRIDOFF); - break; - case AM_MARKKEY: - sprintf(buffer, "%s %d", DEH_String(AMSTR_MARKEDSPOT), markpointnum); - plr->message = buffer; - AM_addMark(); - break; - case AM_CLEARMARKKEY: - AM_clearMarks(); - plr->message = DEH_String(AMSTR_MARKSCLEARED); - break; - default: - cheatstate=0; - rc = false; - } + } + else if (key == key_map_mark) + { + sprintf(buffer, "%s %d", DEH_String(AMSTR_MARKEDSPOT), markpointnum); + plr->message = buffer; + AM_addMark(); + } + else if (key == key_map_clearmark) + { + AM_clearMarks(); + plr->message = DEH_String(AMSTR_MARKSCLEARED); + } + else + { + cheatstate=0; + rc = false; + } + if (!deathmatch && cht_CheckCheat(&cheat_amap, ev->data2)) { rc = false; cheating = (cheating+1) % 3; } } - else if (ev->type == ev_keyup) { - rc = false; - switch (ev->data1) - { - case AM_PANRIGHTKEY: - if (!followplayer) m_paninc.x = 0; - break; - case AM_PANLEFTKEY: - if (!followplayer) m_paninc.x = 0; - break; - case AM_PANUPKEY: - if (!followplayer) m_paninc.y = 0; - break; - case AM_PANDOWNKEY: - if (!followplayer) m_paninc.y = 0; - break; - case AM_ZOOMOUTKEY: - case AM_ZOOMINKEY: - mtof_zoommul = FRACUNIT; - ftom_zoommul = FRACUNIT; - break; - } + rc = false; + key = ev->data1; + + if (key == key_map_east) + { + if (!followplayer) m_paninc.x = 0; + } + else if (key == key_map_west) + { + if (!followplayer) m_paninc.x = 0; + } + else if (key == key_map_north) + { + if (!followplayer) m_paninc.y = 0; + } + else if (key == key_map_south) + { + if (!followplayer) m_paninc.y = 0; + } + else if (key == key_map_zoomout || key == key_map_zoomin) + { + mtof_zoommul = FRACUNIT; + ftom_zoommul = FRACUNIT; + } } return rc; diff --git a/src/g_game.c b/src/g_game.c index 44e77a74..cd070884 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -173,6 +173,15 @@ int key_fire = KEY_RCTRL; int key_use = ' '; int key_strafe = KEY_RALT; int key_speed = KEY_RSHIFT; + +int key_weapon1 = '1'; +int key_weapon2 = '2'; +int key_weapon3 = '3'; +int key_weapon4 = '4'; +int key_weapon5 = '5'; +int key_weapon6 = '6'; +int key_weapon7 = '7'; +int key_weapon8 = '8'; int mousebfire = 0; int mousebstrafe = 1; @@ -211,6 +220,17 @@ fixed_t forwardmove[2] = {0x19, 0x32}; fixed_t sidemove[2] = {0x18, 0x28}; fixed_t angleturn[3] = {640, 1280, 320}; // + slow turn +static int *weapon_keys[] = { + &key_weapon1, + &key_weapon2, + &key_weapon3, + &key_weapon4, + &key_weapon5, + &key_weapon6, + &key_weapon7, + &key_weapon8 +}; + #define SLOWTURNTICS 6 #define NUMKEYS 256 @@ -501,13 +521,18 @@ void G_BuildTiccmd (ticcmd_t* cmd) } // chainsaw overrides - for (i=0 ; ibuttons |= BT_CHANGE; cmd->buttons |= i< @@ -487,7 +487,7 @@ static void BuildIWADDirList(void) AddDoomWadPath(); -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_WIN32_WCE) // Search the registry and find where IWADs have been installed. -- cgit v1.2.3 From 8a262fb95d8f335cf7930a8ae667fe5e01552cf4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 01:24:40 +0000 Subject: Fix compile with FEATURE_SOUND disabled. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1554 --- src/m_config.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/m_config.c b/src/m_config.c index cca4bec1..be329cba 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -747,6 +747,8 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_INT(dclick_use, dclick_use), +#ifdef FEATURE_SOUND + //! // Controls whether libsamplerate support is used for performing // sample rate conversions of sound effects. Support for this @@ -762,6 +764,8 @@ static default_t extra_defaults_list[] = CONFIG_VARIABLE_INT(use_libsamplerate, use_libsamplerate), +#endif + //! // Key that activates the menu when pressed. // -- cgit v1.2.3 From 2df46868ae68060f3eb681a5dd1943ee522a88b4 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 01:26:45 +0000 Subject: Fix compile with FEATURE_MULTIPLAYER disabled. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1555 --- src/d_net.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/d_net.c b/src/d_net.c index 4e87a813..f5890769 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -429,6 +429,7 @@ static int GetLowTic(void) int i; int lowtic; +#ifdef FEATURE_MULTIPLAYER if (net_client_connected) { lowtic = INT_MAX; @@ -443,6 +444,7 @@ static int GetLowTic(void) } } else +#endif { lowtic = maketic; } -- cgit v1.2.3 From 7f9b5d41173c7db6465a5f7666fe7913106a8c1c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 01:32:15 +0000 Subject: Add CPU affinity function for Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1558 --- src/i_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/i_main.c b/src/i_main.c index 3a9ec696..e1de5881 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -34,7 +34,15 @@ #include "m_argv.h" #include "d_main.h" -#if defined(_WIN32) +#if defined(_WIN32_WCE) + +// Windows CE? I doubt it even supports SMP.. + +static void LockCPUAffinity(void) +{ +} + +#elif defined(_WIN32) #define WIN32_LEAN_AND_MEAN #include -- cgit v1.2.3 From 3831ece14e28284302cc1a49f568b5c0b6858f90 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 01:33:58 +0000 Subject: Include libc_wince.h when on Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1559 --- src/doomtype.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/doomtype.h b/src/doomtype.h index 2c9680b3..0a5b5e38 100644 --- a/src/doomtype.h +++ b/src/doomtype.h @@ -29,6 +29,13 @@ #ifndef __DOOMTYPE__ #define __DOOMTYPE__ +// Windows CE is missing some vital ANSI C functions. We have to +// use our own replacements. + +#ifdef _WIN32_WCE +#include "libc_wince.h" +#endif + // C99 integer types; with gcc we just use this. Other compilers // should add conditional statements that define the C99 types. -- cgit v1.2.3 From 61d40373640c0cabdaef4d4381ac5ae636fab642 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 01:56:21 +0000 Subject: Detect Windows CE target and build/include libc_wince files as necessary. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1561 --- src/Makefile.am | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 63ddc98f..64e23b79 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -170,6 +170,7 @@ chocolate_doom_SOURCES=$(SOURCE_FILES) endif chocolate_doom_LDADD = \ + ../wince/libc_wince.a \ ../textscreen/libtextscreen.a \ ../pcsound/libpcsound.a \ @LDFLAGS@ \ -- cgit v1.2.3 From 45359954fe5054f27637962a272177d9c8115b90 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 02:10:21 +0000 Subject: Use MessageBoxW instead of MessageBox (doesn't exist on Windows CE) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1563 --- src/i_system.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/i_system.c b/src/i_system.c index fe596a60..07218142 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -246,13 +246,18 @@ void I_Error (char *error, ...) // On Windows, pop up a dialog box with the error message. { char msgbuf[512]; + wchar_t wmsgbuf[512]; va_start(argptr, error); memset(msgbuf, 0, sizeof(msgbuf)); vsnprintf(msgbuf, sizeof(msgbuf) - 1, error, argptr); va_end(argptr); - MessageBox(NULL, msgbuf, "Error", MB_OK); + MultiByteToWideChar(CP_ACP, 0, + msgbuf, strlen(msgbuf) + 1, + wmsgbuf, sizeof(wmsgbuf)); + + MessageBoxW(NULL, wmsgbuf, L"Error", MB_OK); } #endif -- cgit v1.2.3 From 5a1443a3685eb02b3b97b0be74ebf5936546d02b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 14:20:46 +0000 Subject: Exit with an error on failure to allocate zone memory. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1564 --- src/i_system.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/i_system.c b/src/i_system.c index 07218142..714f63cc 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -95,6 +95,11 @@ byte *I_ZoneBase (int *size) *size = I_GetHeapSize(); zonemem = malloc(*size); + + if (zonemem == NULL) + { + I_Error("Failed to allocate %i bytes for zone memory", *size); + } printf("zone memory: %p, %x allocated for zone\n", zonemem, *size); -- cgit v1.2.3 From 7b7076a20c7042b2f71c82317bfbc48e8854dd32 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 14:35:27 +0000 Subject: Add IWAD search dirs for Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1565 --- src/d_iwad.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/d_iwad.c b/src/d_iwad.c index 8794e9be..d1c2f0bf 100644 --- a/src/d_iwad.c +++ b/src/d_iwad.c @@ -487,7 +487,14 @@ static void BuildIWADDirList(void) AddDoomWadPath(); -#if defined(_WIN32) && !defined(_WIN32_WCE) +#if defined(_WIN32_WCE) + + // Windows CE locations: + + AddIWADDir("\\Storage Card"); + AddIWADDir(getenv("HOME")); + +#elif defined(_WIN32) // Search the registry and find where IWADs have been installed. -- cgit v1.2.3 From fdfff2b9e72c8a1d3975277cad80b9d3afec032f Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 15:15:40 +0000 Subject: Remove call to setbuf. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1566 --- src/d_main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/d_main.c b/src/d_main.c index 849897fe..29a366a1 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -878,8 +878,7 @@ void D_DoomMain (void) I_Error("Game mode indeterminate. No IWAD file was found. Try\n" "specifying one with the '-iwad' command line parameter.\n"); } - - setbuf (stdout, NULL); + modifiedgame = false; //! -- cgit v1.2.3 From ad9f8107f4d9d4ea636eb238205f31270cc1514a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 16:35:43 +0000 Subject: Don't try to use the SDL DirectX driver under Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1568 --- src/i_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index 0ed4d716..fa7dfff9 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -1353,7 +1353,7 @@ static void SetSDLVideoDriver(void) free(env_string); } -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_WIN32_WCE) // Allow -gdi as a shortcut for using the windib driver. -- cgit v1.2.3 From 5d99eee5a4509f42d635156bfb1d6c495d8de221 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 17:10:05 +0000 Subject: Make auto-adjust code switch to windowed mode if no fullscreen modes are available. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1571 --- src/i_video.c | 196 +++++++++++++++++++++++++++++++++------------------------- 1 file changed, 113 insertions(+), 83 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index fa7dfff9..c3055b5d 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -964,125 +964,155 @@ static screen_mode_t *I_FindScreenMode(int w, int h) return best_mode; } -// If the video mode set in the configuration file is not available, -// try to choose a different mode. +// Adjust to an appropriate fullscreen mode. +// Returns true if successful. -static void I_AutoAdjustSettings(void) +static boolean AutoAdjustFullscreen(void) { - if (fullscreen) - { - SDL_Rect **modes; - SDL_Rect *best_mode; - screen_mode_t *screen_mode; - int target_pixels, diff, best_diff; - int i; - - modes = SDL_ListModes(NULL, SDL_FULLSCREEN); - - // Find the best mode that matches the mode specified in the - // configuration file - - best_mode = NULL; - best_diff = INT_MAX; - target_pixels = screen_width * screen_height; + SDL_Rect **modes; + SDL_Rect *best_mode; + screen_mode_t *screen_mode; + int target_pixels, diff, best_diff; + int i; - for (i=0; modes[i] != NULL; ++i) - { - //printf("%ix%i?\n", modes[i]->w, modes[i]->h); + modes = SDL_ListModes(NULL, SDL_FULLSCREEN); - // What screen_mode_t would be used for this video mode? + // No fullscreen modes available at all? - screen_mode = I_FindScreenMode(modes[i]->w, modes[i]->h); + if (modes == NULL || modes == (SDL_Rect **) -1 || *modes == NULL) + { + return false; + } - // Never choose a screen mode that we cannot run in, or - // is poor quality for fullscreen + // Find the best mode that matches the mode specified in the + // configuration file - if (screen_mode == NULL || screen_mode->poor_quality) - { - // printf("\tUnsupported / poor quality\n"); - continue; - } + best_mode = NULL; + best_diff = INT_MAX; + target_pixels = screen_width * screen_height; - // Do we have the exact mode? - // If so, no autoadjust needed + for (i=0; modes[i] != NULL; ++i) + { + //printf("%ix%i?\n", modes[i]->w, modes[i]->h); - if (screen_width == modes[i]->w && screen_height == modes[i]->h) - { - // printf("\tExact mode!\n"); - return; - } + // What screen_mode_t would be used for this video mode? - // Is this mode better than the current mode? + screen_mode = I_FindScreenMode(modes[i]->w, modes[i]->h); - diff = (screen_width - modes[i]->w) - * (screen_width - modes[i]->w) - + (screen_height - modes[i]->h) - * (screen_height - modes[i]->h); + // Never choose a screen mode that we cannot run in, or + // is poor quality for fullscreen - if (diff < best_diff) - { - // printf("\tA valid mode\n"); - best_mode = modes[i]; - best_diff = diff; - } + if (screen_mode == NULL || screen_mode->poor_quality) + { + // printf("\tUnsupported / poor quality\n"); + continue; } - if (best_mode == NULL) - { - // Unable to find a valid mode! + // Do we have the exact mode? + // If so, no autoadjust needed - I_Error("Unable to find any valid video mode at all!"); + if (screen_width == modes[i]->w && screen_height == modes[i]->h) + { + // printf("\tExact mode!\n"); + return true; } - printf("I_InitGraphics: %ix%i mode not supported on this machine.\n", - screen_width, screen_height); + // Is this mode better than the current mode? - screen_width = best_mode->w; - screen_height = best_mode->h; + diff = (screen_width - modes[i]->w) * (screen_width - modes[i]->w) + + (screen_height - modes[i]->h) * (screen_height - modes[i]->h); + if (diff < best_diff) + { + // printf("\tA valid mode\n"); + best_mode = modes[i]; + best_diff = diff; + } } - else + + if (best_mode == NULL) { - screen_mode_t *best_mode; + // Unable to find a valid mode! - // - // Windowed mode. - // - // Find a screen_mode_t to fit within the current settings - // + return false; + } - best_mode = I_FindScreenMode(screen_width, screen_height); + printf("I_InitGraphics: %ix%i mode not supported on this machine.\n", + screen_width, screen_height); - if (best_mode == NULL) - { - // Nothing fits within the current settings. - // Pick the closest to 320x200 possible. + screen_width = best_mode->w; + screen_height = best_mode->h; - best_mode = I_FindScreenMode(SCREENWIDTH, SCREENHEIGHT_4_3); - } + return true; +} - // Do we have the exact mode already? +// Auto-adjust to a valid windowed mode. - if (best_mode->width == screen_width - && best_mode->height == screen_height) - { - return; - } +static void AutoAdjustWindowed(void) +{ + screen_mode_t *best_mode; + // Find a screen_mode_t to fit within the current settings + + best_mode = I_FindScreenMode(screen_width, screen_height); + + if (best_mode == NULL) + { + // Nothing fits within the current settings. + // Pick the closest to 320x200 possible. + + best_mode = I_FindScreenMode(SCREENWIDTH, SCREENHEIGHT_4_3); + } + + // Switch to the best mode if necessary. + + if (best_mode->width != screen_width || best_mode->height != screen_height) + { printf("I_InitGraphics: Cannot run at specified mode: %ix%i\n", screen_width, screen_height); screen_width = best_mode->width; screen_height = best_mode->height; } +} - printf("I_InitGraphics: Auto-adjusted to %ix%i.\n", - screen_width, screen_height); +// If the video mode set in the configuration file is not available, +// try to choose a different mode. + +static void I_AutoAdjustSettings(void) +{ + int old_screen_w, old_screen_h; + + old_screen_w = screen_width; + old_screen_h = screen_height; + + // If we are running fullscreen, try to autoadjust to a valid fullscreen + // mode. If this is impossible, switch to windowed. + + if (fullscreen && !AutoAdjustFullscreen()) + { + fullscreen = 0; + } - printf("NOTE: Your video settings have been adjusted. " - "To disable this behavior,\n" - "set autoadjust_video_settings to 0 in your " - "configuration file.\n"); + // If we are running windowed, pick a valid window size. + + if (!fullscreen) + { + AutoAdjustWindowed(); + } + + // Have the settings changed? Show a message. + + if (screen_width != old_screen_w || screen_height != old_screen_h) + { + printf("I_InitGraphics: Auto-adjusted to %ix%i.\n", + screen_width, screen_height); + + printf("NOTE: Your video settings have been adjusted. " + "To disable this behavior,\n" + "set autoadjust_video_settings to 0 in your " + "configuration file.\n"); + } } // Set video size to a particular scale factor (1x, 2x, 3x, etc.) -- cgit v1.2.3 From 0e3e4653f8df775fdd41e18e956f465fd334f275 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 17:53:25 +0000 Subject: Use home dir to store configuration and savegames under Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1573 --- src/m_config.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/m_config.c b/src/m_config.c index be329cba..5bc46ca3 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -1313,9 +1313,11 @@ void M_LoadDefaults (void) void M_SetConfigDir(void) { -#ifndef _WIN32 - // Ignore the HOME environment variable on Windows - just behave - // like Vanilla Doom. +#if !defined(_WIN32) || defined(_WIN32_WCE) + + // Configuration settings are stored in ~/.chocolate-doom/, + // except on Windows, where we behave like Vanilla Doom and + // save in the current directory. char *homedir; @@ -1338,7 +1340,7 @@ void M_SetConfigDir(void) else #endif /* #ifndef _WIN32 */ { -#ifdef _WIN32 +#if defined(_WIN32) && !defined(_WIN32_WCE) //! // @platform windows // @vanilla -- cgit v1.2.3 From bdeaec12d0f79c5cd15b49105a11988ac5ec545c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 7 Jun 2009 23:41:10 +0000 Subject: Use CreateFileW instead of OpenFile (doesn't exist on Windows CE) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1576 --- src/w_file_win32.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/w_file_win32.c b/src/w_file_win32.c index d5e60579..ec17cf6c 100644 --- a/src/w_file_win32.c +++ b/src/w_file_win32.c @@ -94,12 +94,24 @@ unsigned int GetFileLength(HANDLE handle) static wad_file_t *W_Win32_OpenFile(char *path) { win32_wad_file_t *result; + wchar_t wpath[MAX_PATH + 1]; HANDLE handle; - OFSTRUCT fileinfo; - handle = (HANDLE) OpenFile(path, &fileinfo, OF_READ); + // Open the file: - if (handle == (HANDLE) HFILE_ERROR) + MultiByteToWideChar(CP_OEMCP, 0, + path, strlen(path) + 1, + wpath, sizeof(wpath)); + + handle = CreateFileW(wpath, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if (handle == INVALID_HANDLE_VALUE) { return NULL; } -- cgit v1.2.3 From a91a1c60f544d26195c2df9dd9cd1ef042deacf9 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 8 Jun 2009 18:15:57 +0000 Subject: Use SDL's getenv/putenv implementation, and populate at startup. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1577 --- src/i_main.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/i_main.c b/src/i_main.c index e1de5881..03f8a5ac 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -133,6 +133,15 @@ int main(int argc, char **argv) myargc = argc; myargv = argv; +#ifdef _WIN32_WCE + + // Windows CE has no environment, but SDL provides an implementation. + // Populate the environment with the values we normally find. + + PopulateEnvironment(); + +#endif + // Only schedule on a single core, if we have multiple // cores. This is to work around a bug in SDL_mixer. -- cgit v1.2.3 From ac28eb407daaee8a92fb9efb28ac2426c4edb97b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 10 Jun 2009 19:03:08 +0000 Subject: Add key bindings for pause, message refresh. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1586 --- src/g_game.c | 12 ++++++++---- src/hu_stuff.c | 3 ++- src/hu_stuff.h | 1 - src/i_system.c | 15 ++++++++++++++- src/m_config.c | 16 ++++++++++++++++ 5 files changed, 40 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/g_game.c b/src/g_game.c index cd070884..8255fdd0 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_pause = KEY_PAUSE; int mousebfire = 0; int mousebstrafe = 1; @@ -790,13 +792,15 @@ boolean G_Responder (event_t* ev) switch (ev->type) { case ev_keydown: - if (ev->data1 == KEY_PAUSE) + if (ev->data1 == key_pause) { sendpause = true; - return true; - } - if (ev->data1 data1 data1] = true; + } + return true; // eat key down events case ev_keyup: diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 886236ba..0ab750fb 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -88,6 +88,7 @@ char* player_names[] = HUSTR_PLRRED }; +int key_message_refresh = KEY_ENTER; char chat_char; // remove later. static player_t* plr; @@ -597,7 +598,7 @@ boolean HU_Responder(event_t *ev) if (!chat_on) { - if (ev->data1 == HU_MSGREFRESH) + if (ev->data1 == key_message_refresh) { message_on = true; message_counter = HU_MSGTIMEOUT; diff --git a/src/hu_stuff.h b/src/hu_stuff.h index 310201f6..9b1618c1 100644 --- a/src/hu_stuff.h +++ b/src/hu_stuff.h @@ -40,7 +40,6 @@ #define HU_BROADCAST 5 -#define HU_MSGREFRESH KEY_ENTER #define HU_MSGX 0 #define HU_MSGY 0 #define HU_MSGWIDTH 64 // in characters diff --git a/src/i_system.c b/src/i_system.c index 714f63cc..5f90fd7d 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -133,6 +133,9 @@ void I_Init (void) I_InitJoystick(); } +#define ENDOOM_W 80 +#define ENDOOM_H 25 + // // Displays the text mode ending screen after the game quits // @@ -141,6 +144,8 @@ void I_Endoom(void) { unsigned char *endoom_data; unsigned char *screendata; + int y; + int indent; endoom_data = W_CacheLumpName(DEH_String("ENDOOM"), PU_STATIC); @@ -156,7 +161,15 @@ void I_Endoom(void) // Write the data to the screen memory screendata = TXT_GetScreenData(); - memcpy(screendata, endoom_data, 4000); + + indent = (ENDOOM_W - TXT_SCREEN_W) / 2; + + for (y=0; ysym); } -- cgit v1.2.3 From 43748a366a4bc5494c15995273bfe158530e03de Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 11 Jun 2009 21:34:36 +0000 Subject: Include libc_wince.a in chocolate-server build. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1595 --- src/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 64e23b79..208039a5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,7 @@ net_structrw.c net_structrw.h \ z_native.c z_zone.h chocolate_server_SOURCES=$(DEDSERV_FILES) -chocolate_server_LDADD = @LDFLAGS@ @SDLNET_LIBS@ +chocolate_server_LDADD = ../wince/libc_wince.a @LDFLAGS@ @SDLNET_LIBS@ MAIN_SOURCE_FILES=\ am_map.c am_map.h \ -- cgit v1.2.3 From c80600ef2c0ded9c51ebd0f169972149956d939b Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 12 Jun 2009 17:34:27 +0000 Subject: Always grab input on Windows CE. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1597 --- src/i_video.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index e0db6145..aaefd922 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -182,7 +182,7 @@ static boolean MouseShouldBeGrabbed() if (screensaver_mode) return false; - // if the window doesnt have focus, never grab it + // if the window doesn't have focus, never grab it if (!window_focused) return false; @@ -193,6 +193,17 @@ static boolean MouseShouldBeGrabbed() if (fullscreen) return true; +#ifdef _WIN32_WCE + + // On Windows CE, always grab input. This is because hardware + // button events are only acquired by SDL when the input is grabbed. + // Almost all Windows CE devices should have touch screens anyway, + // so this shouldn't affect mouse grabbing behavior. + + return true; + +#else + // Don't grab the mouse if mouse input is disabled if (!usemouse || nomouse) @@ -204,18 +215,20 @@ static boolean MouseShouldBeGrabbed() return false; // if we specify not to grab the mouse, never grab - + if (!grabmouse) return false; // when menu is active or game is paused, release the mouse - + if (menuactive || paused) return false; // only grab mouse when playing levels (but not demos) return (gamestate == GS_LEVEL) && !demoplayback; + +#endif /* #ifndef _WIN32_WCE */ } // Update the value of window_focused when we get a focus event -- cgit v1.2.3 From d4863b4c4ac47766b5fd3b8b0949be7af792e3d0 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 12 Jun 2009 19:07:55 +0000 Subject: On Windows CE systems without a keyboard, patch the default settings to use hardware keys. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1600 --- src/d_main.c | 1 + src/m_config.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/m_config.h | 1 + 3 files changed, 80 insertions(+) (limited to 'src') diff --git a/src/d_main.c b/src/d_main.c index 29a366a1..c59a8fb7 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -974,6 +974,7 @@ void D_DoomMain (void) V_Init (); printf (DEH_String("M_LoadDefaults: Load system defaults.\n")); + M_ApplyPlatformDefaults(); M_LoadDefaults (); // load before initing other systems printf (DEH_String("W_Init: Init WADfiles.\n")); diff --git a/src/m_config.c b/src/m_config.c index 9e770e48..4f789845 100644 --- a/src/m_config.c +++ b/src/m_config.c @@ -31,6 +31,11 @@ #include #include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#endif + #include "config.h" #include "deh_main.h" #include "doomdef.h" @@ -1380,3 +1385,76 @@ void M_SetConfigDir(void) } } +#ifdef _WIN32_WCE + +static int SystemHasKeyboard(void) +{ + HKEY key; + DWORD valtype; + DWORD valsize; + DWORD result; + + if (RegOpenKeyExW(HKEY_CURRENT_USER, + L"\\Software\\Microsoft\\Shell", 0, + KEY_READ, &key) != ERROR_SUCCESS) + { + return 0; + } + + valtype = REG_SZ; + valsize = sizeof(DWORD); + + if (RegQueryValueExW(key, L"HasKeyboard", NULL, &valtype, + (LPBYTE) &result, &valsize) != ERROR_SUCCESS) + { + result = 0; + } + + // Close the key + + RegCloseKey(key); + + return result; +} + +// +// Apply custom defaults for Windows CE. +// + +static void M_ApplyWindowsCEDefaults(void) +{ + // If the system doesn't have a keyboard, patch the default + // configuration to use the hardware keys. + + if (!SystemHasKeyboard()) + { + key_use = KEY_F1; + key_fire = KEY_F2; + key_menu_activate = KEY_F3; + key_map_toggle = KEY_F4; + + key_menu_help = 0; + key_menu_save = 0; + key_menu_load = 0; + key_menu_volume = 0; + + key_menu_confirm = KEY_ENTER; + key_menu_back = KEY_F2; + key_menu_abort = KEY_F2; + } +} + +#endif + +// +// Apply custom patches to the default values depending on the +// platform we are running on. +// + +void M_ApplyPlatformDefaults(void) +{ +#ifdef _WIN32_WCE + M_ApplyWindowsCEDefaults(); +#endif +} + diff --git a/src/m_config.h b/src/m_config.h index 747569cd..ff11e6d6 100644 --- a/src/m_config.h +++ b/src/m_config.h @@ -31,6 +31,7 @@ void M_LoadDefaults(void); void M_SaveDefaults(void); void M_SetConfigDir(void); +void M_ApplyPlatformDefaults(void); extern char *configdir; -- cgit v1.2.3 From 356cc402cac65af3b617c6fb025cccc335a17251 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 13 Jun 2009 17:10:18 +0000 Subject: Don't post zero key events. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1602 --- src/i_video.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/i_video.c b/src/i_video.c index aaefd922..3412051b 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -502,13 +502,20 @@ void I_GetEvent(void) event.data2 = sdlevent.key.keysym.unicode; } - D_PostEvent(&event); + if (event.data1 != 0) + { + D_PostEvent(&event); + } break; case SDL_KEYUP: event.type = ev_keyup; event.data1 = TranslateKey(&sdlevent.key.keysym); - D_PostEvent(&event); + + if (event.data1 != 0) + { + D_PostEvent(&event); + } break; /* -- cgit v1.2.3 From 9d9d55a9d8d56c1044e89d93e85f21ff2348237a Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Tue, 16 Jun 2009 19:47:13 +0000 Subject: Automatically allocate a smaller zone size if it was not possible to allocate the default 16 MiB. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1603 --- src/i_system.c | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/i_system.c b/src/i_system.c index 5f90fd7d..5e19d407 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -59,6 +59,8 @@ #include "w_wad.h" #include "z_zone.h" +#define MIN_RAM 4 /* MiB */ + int mb_used = 16; int show_endoom = 1; @@ -68,8 +70,10 @@ void I_Tactile(int on, int off, int total) { } -int I_GetHeapSize (void) +byte *I_ZoneBase (int *size) { + byte *zonemem; + int min_ram = MIN_RAM; int p; //! @@ -79,28 +83,46 @@ int I_GetHeapSize (void) // p = M_CheckParm("-mb"); - + if (p > 0) { mb_used = atoi(myargv[p+1]); + min_ram = mb_used; } - - return mb_used*1024*1024; -} - -byte *I_ZoneBase (int *size) -{ - byte *zonemem; - *size = I_GetHeapSize(); + // Allocate the zone memory. This loop tries progressively smaller + // zone sizes until a size is found that can be allocated. + // If we used the -mb command line parameter, only the parameter + // provided is accepted. - zonemem = malloc(*size); + zonemem = NULL; - if (zonemem == NULL) + while (zonemem == NULL) { - I_Error("Failed to allocate %i bytes for zone memory", *size); + // We need a reasonable minimum amount of RAM to start. + + if (mb_used < min_ram) + { + I_Error("Unable to allocate %i MiB of RAM for zone", mb_used); + } + + // Try to allocate the zone memory. + + *size = mb_used * 1024 * 1024; + + zonemem = malloc(*size); + + // Failed to allocate? Reduce zone size until we reach a size + // that is acceptable. We decrease by 2 MiB at a time to ensure + // that there is 1-2 MiB still free on the system (my Windows + // Mobile PDA becomes unstable if very low on memory) + + if (zonemem == NULL) + { + mb_used -= 2; + } } - + printf("zone memory: %p, %x allocated for zone\n", zonemem, *size); -- cgit v1.2.3 From 1dbed3064b9392de6deef18c47df8ee41708563e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 12 Jul 2009 14:00:50 +0000 Subject: On Windows CE, use the Windows API to find the amount of available memory, so that at least two megabytes are always left available to the OS. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1619 --- src/i_system.c | 107 +++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 85 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/i_system.c b/src/i_system.c index 5e19d407..f37b5bec 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -59,9 +59,9 @@ #include "w_wad.h" #include "z_zone.h" -#define MIN_RAM 4 /* MiB */ +#define DEFAULT_RAM 16 /* MiB */ +#define MIN_RAM 4 /* MiB */ -int mb_used = 16; int show_endoom = 1; // Tactile feedback function, probably used for the Logitech Cyberman @@ -70,26 +70,59 @@ void I_Tactile(int on, int off, int total) { } -byte *I_ZoneBase (int *size) +#ifdef _WIN32_WCE + +// Windows CE-specific auto-allocation function that allocates the zone +// size based on the amount of memory reported free by the OS. + +static byte *AutoAllocMemory(int *size, int default_ram, int min_ram) { + MEMORYSTATUS memory_status; byte *zonemem; - int min_ram = MIN_RAM; - int p; + size_t available; - //! - // @arg - // - // Specify the heap size, in MiB (default 16). - // + // Get available physical RAM. We leave one megabyte extra free + // for the OS to keep running (my PDA becomes unstable if too + // much RAM is allocated) - p = M_CheckParm("-mb"); + GlobalMemoryStatus(&memory_status); + available = memory_status.dwAvailPhys - 2 * 1024 * 1024; - if (p > 0) + // Limit to default_ram if we have more than that available: + + if (available > default_ram * 1024 * 1024) + { + available = default_ram * 1024 * 1024; + } + + if (available < min_ram * 1024 * 1024) { - mb_used = atoi(myargv[p+1]); - min_ram = mb_used; + I_Error("Unable to allocate %i MiB of RAM for zone", min_ram); } + // Allocate zone: + + *size = available; + zonemem = malloc(*size); + + if (zonemem == NULL) + { + I_Error("Failed when allocating %i bytes", *size); + } + + return zonemem; +} + +#else + +// Zone memory auto-allocation function that allocates the zone size +// by trying progressively smaller zone sizes until one is found that +// works. + +static byte *AutoAllocMemory(int *size, int default_ram, int min_ram) +{ + byte *zonemem; + // Allocate the zone memory. This loop tries progressively smaller // zone sizes until a size is found that can be allocated. // If we used the -mb command line parameter, only the parameter @@ -101,35 +134,65 @@ byte *I_ZoneBase (int *size) { // We need a reasonable minimum amount of RAM to start. - if (mb_used < min_ram) + if (default_ram < min_ram) { - I_Error("Unable to allocate %i MiB of RAM for zone", mb_used); + I_Error("Unable to allocate %i MiB of RAM for zone", default_ram); } // Try to allocate the zone memory. - *size = mb_used * 1024 * 1024; + *size = default_ram * 1024 * 1024; zonemem = malloc(*size); // Failed to allocate? Reduce zone size until we reach a size - // that is acceptable. We decrease by 2 MiB at a time to ensure - // that there is 1-2 MiB still free on the system (my Windows - // Mobile PDA becomes unstable if very low on memory) + // that is acceptable. if (zonemem == NULL) { - mb_used -= 2; + default_ram -= 1; } } + return zonemem; +} + +#endif + +byte *I_ZoneBase (int *size) +{ + byte *zonemem; + int min_ram, default_ram; + int p; + + //! + // @arg + // + // Specify the heap size, in MiB (default 16). + // + + p = M_CheckParm("-mb"); + + if (p > 0) + { + default_ram = atoi(myargv[p+1]); + min_ram = default_ram; + } + else + { + default_ram = DEFAULT_RAM; + min_ram = MIN_RAM; + } + + zonemem = AutoAllocMemory(size, default_ram, min_ram); + printf("zone memory: %p, %x allocated for zone\n", zonemem, *size); return zonemem; } -// +// // I_ConsoleStdout // // Returns true if stdout is a real console, false if it is a file -- cgit v1.2.3 From e66653a8a67f3613344ae4ea30b37403d6ff17cf Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 12 Jul 2009 16:47:12 +0000 Subject: Fix compile with libsamplerate. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1620 --- src/i_sdlsound.c | 9 +++++---- src/z_native.c | 5 +++++ src/z_zone.c | 5 +++++ src/z_zone.h | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index cdb771e9..bb8229e4 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -63,8 +63,6 @@ static int mixer_channels; int use_libsamplerate = 0; -extern int mb_used; - // When a sound stops, check if it is still playing. If it is not, // we can mark the sound data as CACHE to be freed back for other // means. @@ -364,17 +362,20 @@ static void I_PrecacheSounds_SRC(void) uint32_t resampled_sound_length[NUMSFX]; float norm_factor; float max_amp = 0; + unsigned int zone_size; assert(use_libsamplerate); - if (mb_used < 32) + zone_size = Z_ZoneSize(); + + if (zone_size < 32 * 1024 * 1024) { fprintf(stderr, "WARNING: low memory. Heap size is only %d MiB.\n" "WARNING: use_libsamplerate needs more heap!\n" "WARNING: put -mb 64 on the command line to avoid " "\"Error: Z_Malloc: failed on allocation of X bytes\" !\n", - mb_used); + zone_size / (1024 * 1024)); } printf("I_PrecacheSounds_SRC: Precaching all sound effects.."); diff --git a/src/z_native.c b/src/z_native.c index 199c9426..37bdc02a 100644 --- a/src/z_native.c +++ b/src/z_native.c @@ -483,3 +483,8 @@ int Z_FreeMemory(void) return -1; } +unsigned int Z_ZoneSize(void) +{ + return 0; +} + diff --git a/src/z_zone.c b/src/z_zone.c index f0b8ad53..975f41e5 100644 --- a/src/z_zone.c +++ b/src/z_zone.c @@ -473,3 +473,8 @@ int Z_FreeMemory (void) return free; } +unsigned int Z_ZoneSize(void) +{ + return mainzone->size; +} + diff --git a/src/z_zone.h b/src/z_zone.h index 44eb365b..a00630cf 100644 --- a/src/z_zone.h +++ b/src/z_zone.h @@ -67,7 +67,7 @@ void Z_FileDumpHeap (FILE *f); void Z_CheckHeap (void); void Z_ChangeTag2 (void *ptr, int tag, char *file, int line); int Z_FreeMemory (void); - +unsigned int Z_ZoneSize(void); // // This is used to get the local FILE:LINE info from CPP -- cgit v1.2.3