From 3fe3086cc8c1b967f31b8717140caf1d4875d5b0 Mon Sep 17 00:00:00 2001 From: Steam Deck User Date: Fri, 31 Mar 2023 11:34:55 -0400 Subject: [PATCH] Misc. Additional Memory optimizations for PSP 1000 --- source/cl_input.c | 3 + source/cl_parse.c | 4 +- source/cl_tent.c | 12 + source/libpspmath/libpspmath.a | Bin 53804 -> 66154 bytes source/mathlib.h | 2 + source/menu.c | 3 +- source/pr_cmds.c | 47 ++++ source/psp/module.h | 2 +- source/psp/video_hardware_model.cpp | 5 + source/psp/video_hardware_warp.cpp | 7 + source/snd_sdl.c | 2 +- source/sv_main.c | 4 +- source/zone.c | 412 +++++++++++++++------------- source/zone.h | 20 +- 14 files changed, 323 insertions(+), 200 deletions(-) diff --git a/source/cl_input.c b/source/cl_input.c index 2fdea60..0c13bdf 100644 --- a/source/cl_input.c +++ b/source/cl_input.c @@ -320,12 +320,15 @@ Send the intended movement message to the server */ extern cvar_t waypoint_mode; +qboolean in_game; float crosshair_opacity; void CL_BaseMove (usercmd_t *cmd) { if (cls.signon != SIGNONS)//BLUBS CHANGED HERE return; + in_game = true; + CL_AdjustAngles (); Q_memset (cmd, 0, sizeof(*cmd)); diff --git a/source/cl_parse.c b/source/cl_parse.c index 3ee3f27..5218110 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -912,7 +912,7 @@ void CL_ParseClientdata (int bits) if (bits & SU_WEAPON) - i = MSG_ReadByte (); + i = MSG_ReadShort (); else i = 0; @@ -995,7 +995,7 @@ void CL_ParseClientdata (int bits) if (cl.progress_bar != i) cl.progress_bar = i; - i = MSG_ReadByte (); + i = MSG_ReadShort (); if (cl.stats[STAT_WEAPON2] != i) cl.stats[STAT_WEAPON2] = i; diff --git a/source/cl_tent.c b/source/cl_tent.c index 662fb17..d4bad1b 100644 --- a/source/cl_tent.c +++ b/source/cl_tent.c @@ -41,9 +41,21 @@ void CL_InitTEnts (void) { cl_sfx_r_exp3 = S_PrecacheSound ("sounds/weapons/r_exp3.wav"); cl_sfx_step[0] = S_PrecacheSound ("sounds/player/footstep1.wav"); + +#ifdef SLIM + cl_sfx_step[1] = S_PrecacheSound ("sounds/player/footstep2.wav"); cl_sfx_step[2] = S_PrecacheSound ("sounds/player/footstep3.wav"); cl_sfx_step[3] = S_PrecacheSound ("sounds/player/footstep4.wav"); + +#else + + cl_sfx_step[1] = S_PrecacheSound ("sounds/player/footstep1.wav"); + cl_sfx_step[2] = S_PrecacheSound ("sounds/player/footstep1.wav"); + cl_sfx_step[3] = S_PrecacheSound ("sounds/player/footstep1.wav"); + +#endif // SLIM + } /* diff --git a/source/libpspmath/libpspmath.a b/source/libpspmath/libpspmath.a index 5f165f7e349858fb794597de432273a9607422d3..d928edb60cc716401a50672d334fa1fb2ac8da0b 100644 GIT binary patch literal 66154 zcmeHw4{%&ZndhgGEDKu@1q`^3?CngjE?#iSqd#_R&IRK{aTLm7%@MX-x4G4fG$Tv5 z`ZJNnS%+emCs`z3E)c_|sN5d6rz8#-2-qQk%>uay@ZPbtsjaC1cfQ45T){x@mbwZX zcJ11AmGAd^ufI`G>pji0VS89Fz=lA+`_v`+>ulx0TliHD+92|c4n$5{->D;<4 zo!+u-+xG3rWZF-%|0k2%w{JBEWY>sDTBP~gB5(Sb$oj8~{L6nK^7cOw+4%oNI(|>2 z=la0C>)j&n`K-t-ZxDI!-6FsJg2)Ho7r1}-uS5oL>@YB6&{G{E2R<$GM+uRG?-e=p zDUpu@{~vD>c?jqEFVBlS3hYr}z6Af1*NZ$oB=QU}-$D9!|EI`bqa5EG7diRYB7ckX zokf}c?;8X6(%*>uBl4uX@Q=mGk@3>)xzgmwfnB2$xsu#HRNUV`HJKaF2VVMy7QFr2 zAVF{>Ul=cql(t1&DZ}8zl<}2v8kbv0&Ml=)^wb z8_Er65vJ~%EScEi#2;w-*n~FN&{(D1Lu0uE22jXN75YcU`zQ9B)*eT7bE6|4Dpb|^ zLxstSs)(t<+-NllzBsU&Z?XLZ}NR#6u z6XX4QAr~bKP89E16gjq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hG(Gh%h3z|XZ8{7_{+ekXn7h}ZKuy?&CBnt?b3>&>8;&a7hf$o zD^Bl?|COcCR>`7|hOy|pTn|fp+{CHEcD_V!ZlUWf{BNtpro$7Zv4P_L(PAU2oy(N+ zNa;Xv0KjkE0d(Fmw_pdefG!i{t3-&E6b+Ck?>j=7(z)c!&@Yn7Y<2zmY_+d1TYV6-oSNj=x$EW0b7^@hoT=R{Up?2QUL|&=POdVq zvTPlk@=6+MJO%1i9h*au!fjXg_$0QbG=I9 z8u8;G(rteHZ-|H2Ei^@s*YzrYf;=CuvI`A#0$7e3T&OpD2DmQ)qoVa{T(zA(pC6ar ztE`wEqb)6^SBaUEWBJO&$iW69b+tS&)n@bT(AS&nG0!F!ell=^r@~??j@RMd7L4#{hx>WsxvbmD&BwpZx$bT;J1qpJ~&dGnQ6(*%(P-zW%|Q2 z=gi4al@ZCzMv;KS6bNTBQJiZ{3$=*{uWJ5z9h$H&2WDOp3tqYhx)|esfgUupGNJ2v zu5F2!fmbq5J#l2f^(L-NIE#1&i;6a%>v`6w#Q^on?n2yVOybsRVbH9XSl9CmzxZU~ zv^>}IjKitt$@(e8HDb(RS&+1@IR#{cdynE|xzL1qxYp7+yB^cdr=57$#P{cg-d9~-F@8_;My zKnxIj39k?r0d2n(deasi>+|H;uC3nlIYMKyI9C6Vsbhmlj15jt1-a?zq zv^2h#iE-zIyX7O~BHA%{A(URMQ&BKnlM^UuEW{}n-Ni&pm`8EFw>X^Zy%E=li(Kz* zG^}NArS)c!q+#a9;au;HxJF#$dT&?qpE7*9t70FcrcvAJ^SNm0y*GW!IE8&%O7G2Z S$pC)1yB9Op8<3BKkpB-zbeSjs diff --git a/source/mathlib.h b/source/mathlib.h index 73e87ce..2d8ee41 100644 --- a/source/mathlib.h +++ b/source/mathlib.h @@ -68,6 +68,8 @@ extern int nanmask; //#endif #define CLAMP(min, x, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x)) //johnfitz +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) #define lhrandom(MIN,MAX) ((rand() & 32767) * (((MAX)-(MIN)) * (1.0f / 32767.0f)) + (MIN)) diff --git a/source/menu.c b/source/menu.c index f1c6322..70b3cc1 100644 --- a/source/menu.c +++ b/source/menu.c @@ -773,13 +773,14 @@ char *exitMessage [] = " X :Yes O : No " }; - +extern qboolean in_game; void M_Menu_Exit_f (void) { wasInMenus = (key_dest == key_menu_pause); key_dest = key_menu_pause; m_state = m_exit; m_entersound = true; + in_game = false; } diff --git a/source/pr_cmds.c b/source/pr_cmds.c index ec28795..d17afdc 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -615,6 +615,29 @@ void PF_sound (void) volume = G_FLOAT(OFS_PARM3) * 255; attenuation = G_FLOAT(OFS_PARM4); + // AWFUL AWFUL HACK for limiting zombie sound variations +#ifndef SLIM + char* s = sample; + + if (s[strlen(s) - 6] == 'r' || s[strlen(s) - 6] == 'd' || s[strlen(s) - 6] == 'a' || + s[strlen(s) - 6] == 't' || s[strlen(s) - 6] == 'w') { + if (s[strlen(s) - 5] == '1' || s[strlen(s) - 5] == '2' || + s[strlen(s) - 5] == '3' || s[strlen(s) - 5] == '4' || + s[strlen(s) - 5] == '5' || s[strlen(s) - 5] == '6' || + s[strlen(s) - 5] == '7' || s[strlen(s) - 5] == '8' || + s[strlen(s) - 5] == '9') { + + if (s[strlen(s) - 6] == 'r') { + sample[strlen(sample) - 6] = 'w'; + sample[strlen(sample) - 5] = '1'; + } else { + sample[strlen(sample) - 5] = '0'; + } + } + } + +#endif // SLIM + if (volume < 0 || volume > 255) Sys_Error ("SV_StartSound: volume = %i", volume); @@ -2416,6 +2439,30 @@ void PF_precache_sound (void) G_INT(OFS_RETURN) = G_INT(OFS_PARM0); PR_CheckEmptyString (s); + // AWFUL AWFUL HACK for limiting zombie sound variations +#ifndef SLIM + + if (s[strlen(s) - 6] == 'r' || s[strlen(s) - 6] == 'd' || s[strlen(s) - 6] == 'a' || + s[strlen(s) - 6] == 't' || s[strlen(s) - 6] == 'w') { + if (s[strlen(s) - 5] == '1' || s[strlen(s) - 5] == '2' || + s[strlen(s) - 5] == '3' || s[strlen(s) - 5] == '4' || + s[strlen(s) - 5] == '5' || s[strlen(s) - 5] == '6' || + s[strlen(s) - 5] == '7' || s[strlen(s) - 5] == '8' || + s[strlen(s) - 5] == '9') { + + if (s[strlen(s) - 6] == 'r') { + s[strlen(s) - 6] = 'w'; + s[strlen(s) - 5] = '1'; + } else + s[strlen(s) - 5] = '0'; + } + } + + + +#endif // SLIM + + for (i=0 ; igl_texturenum[i][0] = pheader->gl_texturenum[i][1] = pheader->gl_texturenum[i][2] = pheader->gl_texturenum[i][3] = loadtextureimage (model2, 0, 0, qtrue, GU_LINEAR); if (pheader->gl_texturenum[i][0] == 0)// did not find a matching TGA... + +#endif // SLIM + { sprintf (name, "%s_%i", loadmodel->name, i); if(mod_h2) diff --git a/source/psp/video_hardware_warp.cpp b/source/psp/video_hardware_warp.cpp index 5214ce7..d0ba6ce 100644 --- a/source/psp/video_hardware_warp.cpp +++ b/source/psp/video_hardware_warp.cpp @@ -876,6 +876,9 @@ R_LoadSkys extern int nonetexture; void Sky_LoadSkyBox (char *name) { + +#ifdef SLIM + if (strcmp(skybox_name, name) == 0) return; //no change @@ -899,6 +902,7 @@ void Sky_LoadSkyBox (char *name) for (int i = 0; i < 6; i++) { int mark = Hunk_LowMark (); + if(!(skyimage[i] = loadtextureimage (va("gfx/env/%s%s", name, suf[i]), 0, 0, qfalse, GU_LINEAR)) && !(skyimage[i] = loadtextureimage (va("gfx/env/%s_%s", name, suf[i]), 0, 0, qfalse, GU_LINEAR))) { @@ -912,6 +916,9 @@ void Sky_LoadSkyBox (char *name) Hunk_FreeToLowMark (mark); } strcpy(skybox_name, name); + +#endif // SLIM + } /* diff --git a/source/snd_sdl.c b/source/snd_sdl.c index 0788538..f7b7e57 100644 --- a/source/snd_sdl.c +++ b/source/snd_sdl.c @@ -40,7 +40,7 @@ qboolean SNDDMA_Init(void) return 0; } desired.channels = 2; - desired.samples = 512; + desired.samples = 48; desired.callback = paint_audio; /* Open the audio device */ diff --git a/source/sv_main.c b/source/sv_main.c index 3661791..f84e728 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -749,7 +749,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) if (bits & SU_WEAPONSKIN) MSG_WriteByte (msg, ent->v.weaponskin); if (bits & SU_WEAPON) - MSG_WriteByte (msg, SV_ModelIndex(pr_strings+ent->v.weaponmodel)); + MSG_WriteShort (msg, SV_ModelIndex(pr_strings+ent->v.weaponmodel)); if (bits & SU_GRENADES) MSG_WriteLong (msg, ent->v.grenades); @@ -767,7 +767,7 @@ void SV_WriteClientdataToMessage (edict_t *ent, sizebuf_t *msg) MSG_WriteByte (msg, ent->v.x2_icon); MSG_WriteByte (msg, ent->v.insta_icon); MSG_WriteByte (msg, ent->v.progress_bar); - MSG_WriteByte (msg, SV_ModelIndex(pr_strings+ent->v.weapon2model)); + MSG_WriteShort (msg, SV_ModelIndex(pr_strings+ent->v.weapon2model)); MSG_WriteByte (msg, ent->v.weapon2skin); MSG_WriteByte (msg, ent->v.weapon2frame); MSG_WriteByte (msg, ent->v.currentmag2); diff --git a/source/zone.c b/source/zone.c index 5794b6c..fef31d0 100644 --- a/source/zone.c +++ b/source/zone.c @@ -1,5 +1,7 @@ /* -Copyright (C) 1996-1997 Id Software, Inc. +Copyright (C) 1996-2001 Id Software, Inc. +Copyright (C) 2002-2009 John Fitzgibbons and others +Copyright (C) 2010-2014 QuakeSpasm developers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -17,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// Z_zone.c +// zone.c #include "quakedef.h" @@ -29,17 +31,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef struct memblock_s { - int size; // including the header and possibly tiny fragments - int tag; // a tag of 0 is a free block - int id; // should be ZONEID - struct memblock_s *next, *prev; - int pad; // pad to 64 bit boundary + int size; // including the header and possibly tiny fragments + int tag; // a tag of 0 is a free block + int id; // should be ZONEID + int pad; // pad to 64 bit boundary + struct memblock_s *next, *prev; } memblock_t; typedef struct { int size; // total bytes malloced, including header - memblock_t blocklist; // start / end cap for linked list + memblock_t blocklist; // start / end cap for linked list memblock_t *rover; } memzone_t; @@ -443,6 +445,7 @@ void *Q_strdup (const char *str) return p; } + /* ============================================================================== @@ -458,34 +461,7 @@ all big things are allocated on the hunk. ============================================================================== */ -memzone_t *mainzone; - -void Z_ClearZone (memzone_t *zone, int size); - - -/* -======================== -Z_ClearZone -======================== -*/ -void Z_ClearZone (memzone_t *zone, int size) -{ - memblock_t *block; - -// set the entire zone to one free block - - zone->blocklist.next = zone->blocklist.prev = block = - (memblock_t *)( (byte *)zone + sizeof(memzone_t) ); - zone->blocklist.tag = 1; // in use block - zone->blocklist.id = 0; - zone->blocklist.size = 0; - zone->rover = block; - - block->prev = block->next = &zone->blocklist; - block->tag = 0; // free block - block->id = ZONEID; - block->size = size - sizeof(memzone_t); -} +static memzone_t *mainzone; /* @@ -501,12 +477,8 @@ void Z_Free (void *ptr) Sys_Error ("Z_Free: NULL pointer"); block = (memblock_t *) ( (byte *)ptr - sizeof(memblock_t)); - if (block->id != ZONEID) - { - Con_DPrintf("Z_Free: freed a pointer without ZONEID\n"); - return; - } + Sys_Error ("Z_Free: freed a pointer without ZONEID"); if (block->tag == 0) Sys_Error ("Z_Free: freed a freed pointer"); @@ -535,28 +507,10 @@ void Z_Free (void *ptr) } -/* -======================== -Z_Malloc -======================== -*/ -void *Z_Malloc (int size) -{ - void *buf; - -Z_CheckHeap (); // DEBUG - buf = Z_TagMalloc (size, 1); - if (!buf) - Sys_Error ("Z_Malloc: failed on allocation of %i bytes",size); - Q_memset (buf, 0, size); - - return buf; -} - void *Z_TagMalloc (int size, int tag) { int extra; - memblock_t *start, *rover, *new, *base; + memblock_t *start, *rover, *newblock, *base; if (!tag) Sys_Error ("Z_TagMalloc: tried to use a 0 tag"); @@ -588,14 +542,14 @@ void *Z_TagMalloc (int size, int tag) extra = base->size - size; if (extra > MINFRAGMENT) { // there will be a free fragment after the allocated block - new = (memblock_t *) ((byte *)base + size ); - new->size = extra; - new->tag = 0; // free block - new->prev = base; - new->id = ZONEID; - new->next = base->next; - new->next->prev = new; - base->next = new; + newblock = (memblock_t *) ((byte *)base + size ); + newblock->size = extra; + newblock->tag = 0; // free block + newblock->prev = base; + newblock->id = ZONEID; + newblock->next = base->next; + newblock->next->prev = newblock; + base->next = newblock; base->size = size; } @@ -611,6 +565,92 @@ void *Z_TagMalloc (int size, int tag) return (void *) ((byte *)base + sizeof(memblock_t)); } +/* +======================== +Z_CheckHeap +======================== +*/ +void Z_CheckHeap (void) +{ + memblock_t *block; + + for (block = mainzone->blocklist.next ; ; block = block->next) + { + if (block->next == &mainzone->blocklist) + break; // all blocks have been hit + if ( (byte *)block + block->size != (byte *)block->next) + Sys_Error ("Z_CheckHeap: block size does not touch the next block"); + if ( block->next->prev != block) + Sys_Error ("Z_CheckHeap: next block doesn't have proper back link"); + if (!block->tag && !block->next->tag) + Sys_Error ("Z_CheckHeap: two consecutive free blocks"); + } +} + + +/* +======================== +Z_Malloc +======================== +*/ +void *Z_Malloc (int size) +{ + void *buf; + + Z_CheckHeap (); // DEBUG + buf = Z_TagMalloc (size, 1); + if (!buf) + Sys_Error ("Z_Malloc: failed on allocation of %i bytes",size); + Q_memset (buf, 0, size); + + return buf; +} + +/* +======================== +Z_Realloc +======================== +*/ +void *Z_Realloc(void *ptr, int size) +{ + int old_size; + void *old_ptr; + memblock_t *block; + + if (!ptr) + return Z_Malloc (size); + + block = (memblock_t *) ((byte *) ptr - sizeof (memblock_t)); + if (block->id != ZONEID) + Sys_Error ("Z_Realloc: realloced a pointer without ZONEID"); + if (block->tag == 0) + Sys_Error ("Z_Realloc: realloced a freed pointer"); + + old_size = block->size; + old_size -= (4 + (int)sizeof(memblock_t)); /* see Z_TagMalloc() */ + old_ptr = ptr; + + Z_Free (ptr); + ptr = Z_TagMalloc (size, 1); + if (!ptr) + Sys_Error ("Z_Realloc: failed on allocation of %i bytes", size); + + if (ptr != old_ptr) + memmove (ptr, old_ptr, MIN(old_size, size)); + if (old_size < size) + memset ((byte *)ptr + old_size, 0, size - old_size); + + return ptr; +} + +char *Z_Strdup (char *s) +{ + size_t sz = strlen(s) + 1; + char *ptr = (char *) Z_Malloc (sz); + memcpy (ptr, s, sz); + return ptr; +} + /* ======================== @@ -640,37 +680,16 @@ void Z_Print (memzone_t *zone) } -/* -======================== -Z_CheckHeap -======================== -*/ -void Z_CheckHeap (void) -{ - memblock_t *block; - - for (block = mainzone->blocklist.next ; ; block = block->next) - { - if (block->next == &mainzone->blocklist) - break; // all blocks have been hit - if ( (byte *)block + block->size != (byte *)block->next) - Sys_Error ("Z_CheckHeap: block size does not touch the next block\n"); - if ( block->next->prev != block) - Sys_Error ("Z_CheckHeap: next block doesn't have proper back link\n"); - if (!block->tag && !block->next->tag) - Sys_Error ("Z_CheckHeap: two consecutive free blocks\n"); - } -} - //============================================================================ -#define HUNK_SENTINAL 0x1df001ed +#define HUNK_SENTINEL 0x1df001ed +#define HUNKNAME_LEN 24 typedef struct { - int sentinal; + int sentinel; int size; // including sizeof(hunk_t), -1 = not allocated - char name[8]; + char name[HUNKNAME_LEN]; } hunk_t; byte *hunk_base; @@ -682,13 +701,11 @@ int hunk_high_used; qboolean hunk_tempactive; int hunk_tempmark; -void R_FreeTextures (void); - /* ============== Hunk_Check -Run consistancy and sentinal trahing checks +Run consistancy and sentinel trahing checks ============== */ void Hunk_Check (void) @@ -697,9 +714,9 @@ void Hunk_Check (void) for (h = (hunk_t *)hunk_base ; (byte *)h != hunk_base + hunk_low_used ; ) { - if (h->sentinal != HUNK_SENTINAL) - Sys_Error ("Hunk_Check: trahsed sentinal"); - if (h->size < 16 || h->size + (byte *)h - hunk_base > hunk_size) + if (h->sentinel != HUNK_SENTINEL) + Sys_Error ("Hunk_Check: trashed sentinel"); + if (h->size < (int) sizeof(hunk_t) || h->size + (byte *)h - hunk_base > hunk_size) Sys_Error ("Hunk_Check: bad size"); h = (hunk_t *)((byte *)h+h->size); } @@ -715,13 +732,11 @@ Otherwise, allocations with the same name will be totaled up before printing. */ void Hunk_Print (qboolean all) { - hunk_t *h, *next, *endlow, *starthigh, *endhigh; int count, sum; int totalblocks; - char name[9]; + char name[HUNKNAME_LEN]; - name[8] = 0; count = 0; sum = 0; totalblocks = 0; @@ -756,9 +771,9 @@ void Hunk_Print (qboolean all) // // run consistancy checks // - if (h->sentinal != HUNK_SENTINAL) - Sys_Error ("Hunk_Check: trahsed sentinal"); - if (h->size < 16 || h->size + (byte *)h - hunk_base > hunk_size) + if (h->sentinel != HUNK_SENTINEL) + Sys_Error ("Hunk_Check: trashed sentinel"); + if (h->size < (int) sizeof(hunk_t) || h->size + (byte *)h - hunk_base > hunk_size) Sys_Error ("Hunk_Check: bad size"); next = (hunk_t *)((byte *)h+h->size); @@ -769,7 +784,7 @@ void Hunk_Print (qboolean all) // // print the single block // - memcpy_vfpu(name, h->name, 8); + memcpy (name, h->name, HUNKNAME_LEN); if (all) Con_Printf ("%8p :%8i %8s\n",h, h->size, name); @@ -777,7 +792,7 @@ void Hunk_Print (qboolean all) // print the total // if (next == endlow || next == endhigh || - strncmp (h->name, next->name, 8) ) + strncmp (h->name, next->name, HUNKNAME_LEN - 1)) { if (!all) Con_Printf (" :%8i %8s (TOTAL)\n",sum, name); @@ -790,6 +805,17 @@ void Hunk_Print (qboolean all) Con_Printf ("-------------------------\n"); Con_Printf ("%8i total blocks\n", totalblocks); + +} + +/* +=================== +Hunk_Print_f -- johnfitz -- console command to call hunk_print +=================== +*/ +void Hunk_Print_f (void) +{ + Hunk_Print (false); } /* @@ -801,21 +827,17 @@ void *Hunk_AllocName (int size, char *name) { hunk_t *h; +#ifdef PARANOID + Hunk_Check (); +#endif + if (size < 0) - { Sys_Error ("Hunk_Alloc: bad size: %i", size); - //Con_Printf ("Hunk_Alloc: bad size: %i", size); - return NULL; - } size = sizeof(hunk_t) + ((size+15)&~15); if (hunk_size - hunk_low_used - hunk_high_used < size) - { - Sys_Error ("Hunk_Alloc: failed on %i bytes, %s", size, name); - //Con_Printf ("Hunk_Alloc: failed on %i bytes",size); - return NULL; - } + Sys_Error ("Hunk_Alloc: failed on %i bytes",size); h = (hunk_t *)(hunk_base + hunk_low_used); hunk_low_used += size; @@ -825,8 +847,8 @@ void *Hunk_AllocName (int size, char *name) memset (h, 0, size); h->size = size; - h->sentinal = HUNK_SENTINAL; - Q_strncpy (h->name, name, 8); + h->sentinel = HUNK_SENTINEL; + strlcpy(h->name, name, HUNKNAME_LEN); return (void *)(h+1); } @@ -897,11 +919,15 @@ void *Hunk_HighAllocName (int size, char *name) hunk_tempactive = false; } +#ifdef PARANOID + Hunk_Check (); +#endif + size = sizeof(hunk_t) + ((size+15)&~15); if (hunk_size - hunk_low_used - hunk_high_used < size) { - Con_Printf ("Hunk_HighAlloc: failed on %i bytes, %s\n", size, name); + Con_Printf ("Hunk_HighAlloc: failed on %i bytes\n",size); return NULL; } @@ -912,8 +938,8 @@ void *Hunk_HighAllocName (int size, char *name) memset (h, 0, size); h->size = size; - h->sentinal = HUNK_SENTINAL; - Q_strncpy (h->name, name, 8); + h->sentinel = HUNK_SENTINEL; + strlcpy (h->name, name, HUNKNAME_LEN); return (void *)(h+1); } @@ -947,6 +973,14 @@ void *Hunk_TempAlloc (int size) return buf; } +char *Hunk_Strdup (char *s, char *name) +{ + size_t sz = strlen(s) + 1; + char *ptr = (char *) Hunk_AllocName (sz, name); + memcpy (ptr, s, sz); + return ptr; +} + /* =============================================================================== @@ -955,11 +989,12 @@ CACHE MEMORY =============================================================================== */ +#define CACHENAME_LEN 32 typedef struct cache_system_s { - int size; // including this header - cache_user_t *user; - char name[16]; + int size; // including this header + cache_user_t *user; + char name[CACHENAME_LEN]; struct cache_system_s *prev, *next; struct cache_system_s *lru_prev, *lru_next; // for LRU flushing } cache_system_t; @@ -975,25 +1010,25 @@ Cache_Move */ void Cache_Move ( cache_system_t *c) { - cache_system_t *new; + cache_system_t *new_cs; // we are clearing up space at the bottom, so only allocate it late - new = Cache_TryAlloc (c->size, true); - if (new) + new_cs = Cache_TryAlloc (c->size, true); + if (new_cs) { // Con_Printf ("cache_move ok\n"); - Q_memcpy ( new+1, c+1, c->size - sizeof(cache_system_t) ); - new->user = c->user; - Q_memcpy (new->name, c->name, sizeof(new->name)); + Q_memcpy ( new_cs+1, c+1, c->size - sizeof(cache_system_t) ); + new_cs->user = c->user; + Q_memcpy (new_cs->name, c->name, sizeof(new_cs->name)); Cache_Free (c->user); - new->user->data = (void *)(new+1); + new_cs->user->data = (void *)(new_cs+1); } else { // Con_Printf ("cache_move failed\n"); - Cache_Free (c->user); // tough luck... + Cache_Free (c->user); // tough luck... } } @@ -1080,7 +1115,7 @@ Size should already include the header and padding */ cache_system_t *Cache_TryAlloc (int size, qboolean nobottom) { - cache_system_t *cs, *new; + cache_system_t *cs, *new_cs; // is the cache completely empty? @@ -1089,62 +1124,62 @@ cache_system_t *Cache_TryAlloc (int size, qboolean nobottom) if (hunk_size - hunk_high_used - hunk_low_used < size) Sys_Error ("Cache_TryAlloc: %i is greater then free hunk", size); - new = (cache_system_t *) (hunk_base + hunk_low_used); - memset (new, 0, sizeof(*new)); - new->size = size; + new_cs = (cache_system_t *) (hunk_base + hunk_low_used); + memset (new_cs, 0, sizeof(*new_cs)); + new_cs->size = size; - cache_head.prev = cache_head.next = new; - new->prev = new->next = &cache_head; + cache_head.prev = cache_head.next = new_cs; + new_cs->prev = new_cs->next = &cache_head; - Cache_MakeLRU (new); - return new; + Cache_MakeLRU (new_cs); + return new_cs; } // search from the bottom up for space - new = (cache_system_t *) (hunk_base + hunk_low_used); + new_cs = (cache_system_t *) (hunk_base + hunk_low_used); cs = cache_head.next; do { if (!nobottom || cs != cache_head.next) { - if ( (byte *)cs - (byte *)new >= size) + if ( (byte *)cs - (byte *)new_cs >= size) { // found space - memset (new, 0, sizeof(*new)); - new->size = size; + memset (new_cs, 0, sizeof(*new_cs)); + new_cs->size = size; - new->next = cs; - new->prev = cs->prev; - cs->prev->next = new; - cs->prev = new; + new_cs->next = cs; + new_cs->prev = cs->prev; + cs->prev->next = new_cs; + cs->prev = new_cs; - Cache_MakeLRU (new); + Cache_MakeLRU (new_cs); - return new; + return new_cs; } } // continue looking - new = (cache_system_t *)((byte *)cs + cs->size); + new_cs = (cache_system_t *)((byte *)cs + cs->size); cs = cs->next; } while (cs != &cache_head); // try to allocate one at the very end - if ( hunk_base + hunk_size - hunk_high_used - (byte *)new >= size) + if ( hunk_base + hunk_size - hunk_high_used - (byte *)new_cs >= size) { - memset (new, 0, sizeof(*new)); - new->size = size; + memset (new_cs, 0, sizeof(*new_cs)); + new_cs->size = size; - new->next = &cache_head; - new->prev = cache_head.prev; - cache_head.prev->next = new; - cache_head.prev = new; + new_cs->next = &cache_head; + new_cs->prev = cache_head.prev; + cache_head.prev->next = new_cs; + cache_head.prev = new_cs; - Cache_MakeLRU (new); + Cache_MakeLRU (new_cs); - return new; + return new_cs; } return NULL; // couldn't allocate @@ -1160,10 +1195,9 @@ Throw everything out, so new data will be demand cached void Cache_Flush (void) { while (cache_head.next != &cache_head) - Cache_Free ( cache_head.next->user ); // reclaim the space + Cache_Free ( cache_head.next->user); // reclaim the space } - /* ============ Cache_Print @@ -1174,10 +1208,9 @@ void Cache_Print (void) { cache_system_t *cd; - Con_Printf("\n===\nCache System Dump\n===\n"); for (cd = cache_head.next ; cd != &cache_head ; cd = cd->next) { - Con_Printf("* NAME: %s | SIZE: %.2fkB", cd->name, (float)(cd->size/1024)); + Con_Printf ("%8i : %s\n", cd->size, cd->name); } } @@ -1192,16 +1225,6 @@ void Cache_Report (void) Con_DPrintf ("%4.1f megabyte data cache\n", (hunk_size - hunk_high_used - hunk_low_used) / (float)(1024*1024) ); } -/* -============ -Cache_Compact - -============ -*/ -void Cache_Compact (void) -{ -} - /* ============ Cache_Init @@ -1275,7 +1298,7 @@ void *Cache_Alloc (cache_user_t *c, int size, char *name) cache_system_t *cs; if (c->data) - Sys_Error ("Cache_Alloc: allready allocated"); + Sys_Error ("Cache_Alloc: already allocated"); if (size <= 0) Sys_Error ("Cache_Alloc: size %i", size); @@ -1288,19 +1311,17 @@ void *Cache_Alloc (cache_user_t *c, int size, char *name) cs = Cache_TryAlloc (size, false); if (cs) { - strncpy (cs->name, name, sizeof(cs->name)-1); + strlcpy (cs->name, name, CACHENAME_LEN); c->data = (void *)(cs+1); cs->user = c; break; } // free the least recently used cahedat - if (cache_head.lru_prev == &cache_head) { - Cache_Print(); - Sys_Error ("Cache_Alloc: out of memory"); - } - // not enough memory at all - Cache_Free ( cache_head.lru_prev->user ); + if (cache_head.lru_prev == &cache_head) + Sys_Error ("Cache_Alloc: out of memory"); // not enough memory at all + + Cache_Free (cache_head.lru_prev->user); } return Cache_Check (c); @@ -1309,6 +1330,25 @@ void *Cache_Alloc (cache_user_t *c, int size, char *name) //============================================================================ +void Memory_InitZone (memzone_t *zone, int size) +{ + memblock_t *block; + +// set the entire zone to one free block + + zone->blocklist.next = zone->blocklist.prev = block = + (memblock_t *)( (byte *)zone + sizeof(memzone_t) ); + zone->blocklist.tag = 1; // in use block + zone->blocklist.id = 0; + zone->blocklist.size = 0; + zone->rover = block; + + block->prev = block->next = &zone->blocklist; + block->tag = 0; // free block + block->id = ZONEID; + block->size = size - sizeof(memzone_t); +} + /* ======================== Memory_Init @@ -1319,7 +1359,7 @@ void Memory_Init (void *buf, int size) int p; int zonesize = DYNAMIC_SIZE; - hunk_base = buf; + hunk_base = (byte *) buf; hunk_size = size; hunk_low_used = 0; hunk_high_used = 0; @@ -1333,7 +1373,9 @@ void Memory_Init (void *buf, int size) else Sys_Error ("Memory_Init: you must specify a size in KB after -zone"); } - mainzone = Hunk_AllocName (zonesize, "zone" ); - Z_ClearZone (mainzone, zonesize); + mainzone = (memzone_t *) Hunk_AllocName (zonesize, "zone" ); + Memory_InitZone (mainzone, zonesize); + + Cmd_AddCommand ("hunk_print", Hunk_Print_f); //johnfitz } diff --git a/source/zone.h b/source/zone.h index 7808ce5..be7e126 100644 --- a/source/zone.h +++ b/source/zone.h @@ -1,5 +1,7 @@ /* -Copyright (C) 1996-1997 Id Software, Inc. +Copyright (C) 1996-2001 Id Software, Inc. +Copyright (C) 2002-2009 John Fitzgibbons and others +Copyright (C) 2010-2014 QuakeSpasm developers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -8,7 +10,7 @@ of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -17,6 +19,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef __ZZONE_H +#define __ZZONE_H + /* memory allocation @@ -92,16 +98,13 @@ void *Q_strdup (const char *str); // void Z_Free (void *ptr); void *Z_Malloc (int size); // returns 0 filled memory -void *Z_TagMalloc (int size, int tag); - -void Z_DumpHeap (void); -void Z_CheckHeap (void); -int Z_FreeMemory (void); +void *Z_Realloc (void *ptr, int size); +char *Z_Strdup (char *s); void *Hunk_Alloc (int size); // returns 0 filled memory void *Hunk_AllocName (int size, char *name); - void *Hunk_HighAllocName (int size, char *name); +char *Hunk_Strdup (char *s, char *name); int Hunk_LowMark (void); void Hunk_FreeToLowMark (int mark); @@ -134,3 +137,4 @@ void Cache_Report (void); void* memcpy_vfpu(void* dst, void* src, unsigned int size); +#endif /* __ZZONE_H */ \ No newline at end of file