From 24db815f28c9edca12464b5165d0e3e0bc1a2aff Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 11 Jul 2009 11:15:32 +0000 Subject: Add missing item to NEWS. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1614 --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 42071458..2d6db773 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,8 @@ devices (eg. PDAs/embedded devices) * The textscreen library now has a scrollable pane widget. * Doxygen documentation was added for the textscreen library. + * The "join game" window in the setup tool now has an option + to automatically join a game on the local network. Compatibility: * The A_BossDeath behavior in v1.9 emulation mode was fixed -- 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(-) 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(-) 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 From 63b550c068ccdbe23b269cc20593db868fcac8a7 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 13 Jul 2009 22:43:06 +0000 Subject: Add stdio.h include to fix MSVC build (thanks Kaiser) Subversion-branch: /trunk/chocolate-doom Subversion-revision: 1625 --- src/w_file_win32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/w_file_win32.c b/src/w_file_win32.c index ec17cf6c..9e5d963f 100644 --- a/src/w_file_win32.c +++ b/src/w_file_win32.c @@ -28,6 +28,8 @@ #ifdef _WIN32 +#include + #define WIN32_LEAN_AND_MEAN #include -- cgit v1.2.3 From 4c0dc104d7582d709d8cc665a1c46ed1d49cdd65 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 13 Jul 2009 23:38:18 +0000 Subject: Add stdio.h include to fix MSVC build (thanks Kaiser) Subversion-branch: /branches/raven-branch Subversion-revision: 1627 --- src/i_endoom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/i_endoom.c b/src/i_endoom.c index a05d1662..021a3604 100644 --- a/src/i_endoom.c +++ b/src/i_endoom.c @@ -23,6 +23,7 @@ // //----------------------------------------------------------------------------- +#include #include #include "doomtype.h" -- cgit v1.2.3