From 2186d5f3f95cd74a070a490d899291648d58667a Mon Sep 17 00:00:00 2001 From: Steven Fuller Date: Sun, 1 Jul 2001 00:55:22 +0000 Subject: Initial revision --- src/mslhand.c | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 src/mslhand.c (limited to 'src/mslhand.c') diff --git a/src/mslhand.c b/src/mslhand.c new file mode 100644 index 0000000..fe1e8ca --- /dev/null +++ b/src/mslhand.c @@ -0,0 +1,187 @@ +#include "3dc.h" + +#include "mslhand.h" + +#if PSX +#include "psx_inc.h" +#endif + +#define UseLocalAssert 1 +#include "ourasert.h" + +extern SHAPEHEADER * mainshapelist[]; + +static int begins[ MSLS_MAXSECTIONS ]; +static int ends[ MSLS_MAXSECTIONS ]; + +static int autodelete[ maxobjects ]; + +#define MSS_FREE (-1) + +static void EnsureInitialized(void) +{ + static int initialized = 0; + + if (!initialized) + { + int i; + + initialized = 1; + + for (i=0; i=0 ? ends[i] : 0; + } + + blockstart = ends[sect]; + /* can use a local assert here to fail on a mainshapelist overflow, otherwise return error code */ + LOCALASSERT(ends[sect] + num_shapes <= maxend); + if (ends[sect] + num_shapes > maxend ) return MSL_OVERFLOW; + ends[sect] += num_shapes; + + for (i=blockstart; ipoints) + { + if (*shp->points) free(*shp->points); + free(shp->points); + } + if (shp->sh_normals) + { + if (*shp->sh_normals) free(*shp->sh_normals); + free(shp->sh_normals); + } + if (shp->sh_vnormals) + { + if (*shp->sh_vnormals) free(*shp->sh_vnormals); + free(shp->sh_vnormals); + } + if (shp->sh_extraitemdata) + free(shp->sh_extraitemdata); + /* the items are allocated in one big bunch + // 9 int's per item (to make bsp simple) + // this should be changed if it is to be done + // a different way + */ + if (shp->items) + { + for (i=0; inumitems; i++) + { + if (shp->items[i][0] == 5 || shp->items[i][0] == 6) + { + int UVIndex = (shp->items[i][3] &0xffff0000) >> 16; + max_num_texs = max (max_num_texs, shp->items[i][3] &0x7fff); + if(shp->items[i][2]& iflag_txanim) + { + int j; + TXANIMHEADER** thlist=(TXANIMHEADER**)shp->sh_textures[UVIndex]; + for(j=1;thlist[j]!=0;j++) + { + int k; + TXANIMHEADER* th=thlist[j]; + for(k=0;ktxa_numframes;k++) + { + free(th->txa_framedata[k].txf_uvdata); + } + free (th->txa_framedata); + free (th); + } + free (thlist); + shp->sh_textures[UVIndex]=0; + } + else + { + free(shp->sh_textures[UVIndex]); + } + } + } + + free (*shp->items); + free (shp->items); + } + + if (shp->sh_textures) + { + free (shp->sh_textures); + } + + if (shp->sh_localtextures) + { + for (i=0; i<(max_num_texs+1); i++) + { + free (shp->sh_localtextures[i]); + } + free (shp->sh_localtextures); + } + + if (shp->sh_instruction) + free(shp->sh_instruction); + + free(shp); + } + mainshapelist[i]=0; + autodelete[i]=0; + } + + begins[sect]=MSS_FREE; + ends[sect]=MSS_FREE; + +#else + +printf("\nDo NOT call this function!\n"); +//GLOBALASSERT(1==0); + +#endif + +} -- cgit v1.3