X-Git-Url: http://4ch.mooo.com/gitweb/?p=16.git;a=blobdiff_plain;f=src%2Flib%2F16_ca.c;h=8dd2da0af0c5d8b017a6074f74501c548111a8c3;hp=008e4e84cb54949bf0b645a18a4637db04eea567;hb=256be2f6f35912701d3e3770e49e388f462a6acc;hpb=aa074e927a76160b8a861471713931db2b5968d0 diff --git a/src/lib/16_ca.c b/src/lib/16_ca.c index 008e4e84..8dd2da0a 100755 --- a/src/lib/16_ca.c +++ b/src/lib/16_ca.c @@ -1,23 +1,19 @@ -/* Project 16 Source Code~ - * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover +/* Catacomb Apocalypse Source Code + * Copyright (C) 1993-2014 Flat Rock Software * - * This file is part of Project 16. - * - * Project 16 is free software; you can redistribute it and/or modify + * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or + * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * - * Project 16 is distributed in the hope that it will be useful, + * 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. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see , or - * write to the Free Software Foundation, Inc., 51 Franklin Street, - * Fifth Floor, Boston, MA 02110-1301 USA. - * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ // ID_CA.C @@ -40,7 +36,7 @@ loaded into the data segment #pragma warn -pro #pragma warn -use -#define THREEBYTEGRSTARTS +//#define THREEBYTEGRSTARTS //https://github.com/open-watcom/open-watcom-v2/issues/279#issuecomment-244587566 for _seg //http://www.shikadi.net/moddingwiki/GameMaps_Format for info on the code /* @@ -125,9 +121,9 @@ huffnode audiohuffman[255]; int grhandle; // handle to EGAGRAPH int maphandle; // handle to MAPTEMP / GAMEMAPS int audiohandle; // handle to AUDIOT / AUDIO -*/ -long chunkcomplen,chunkexplen; -/* + +long c hunkcomplen,c hunkexplen; + SDMode oldsoundmode; @@ -142,14 +138,14 @@ void CAL_CarmackExpand (unsigned far *source, unsigned far *dest, #ifdef THREEBYTEGRSTARTS #define FILEPOSSIZE 3 //#define GRFILEPOS(c) (*(long far *)(((byte far *)grstarts)+(c)*3)&0xffffff) -CASVT GRFILEPOS(int c, global_game_variables_t *gvar) +long GRFILEPOS(int c, global_game_variables_t *gvar) { - CASVT value; + long value; int offset; offset = c*3; - value = *(CASVT far *)(((byte far *)gvar->ca.grstarts)+offset); + value = *(long far *)(((byte far *)gvar->ca.grstarts)+offset); value &= 0x00ffffffl; @@ -160,11 +156,7 @@ CASVT GRFILEPOS(int c, global_game_variables_t *gvar) }; #else #define FILEPOSSIZE 4 -//#define GRFILEPOS(c) (gvar->ca.grstarts[c]) -CASVT GRFILEPOS(int c, global_game_variables_t *gvar) -{ - return gvar->ca.grstarts[c]; -} +#define GRFILEPOS(c) (gvar->ca.grstarts[c]) #endif /* @@ -216,9 +208,9 @@ void CA_CloseDebug(global_game_variables_t *gvar) void CAL_GetGrChunkLength (int chunk,global_game_variables_t *gvar) { - lseek(gvar->ca.file.grhandle,GRFILEPOS(chunk,gvar),SEEK_SET); + lseek(gvar->ca.file.grhandle,GRFILEPOS(chunk),SEEK_SET); read(gvar->ca.file.grhandle,&gvar->ca.chunkexplen,sizeof(gvar->ca.chunkexplen)); - gvar->ca.chunkcomplen = GRFILEPOS(chunk+1,gvar)-GRFILEPOS(chunk,gvar)-4; + gvar->ca.chunkcomplen = GRFILEPOS(chunk+1)-GRFILEPOS(chunk)-4; } @@ -1077,7 +1069,7 @@ void CAL_SetupGrFile (global_game_variables_t *gvar) // // load the data offsets from ???head.ext // - MM_GetPtr (MEMPTRCONV gvar->ca.grstarts,(NUMCHUNKS+1)*FILEPOSSIZE, gvar); + MM_GetPtr (MEMPTR gvar->ca.grstarts,(NUMCHUNKS+1)*FILEPOSSIZE, gvar); strcpy(fname,GHEADNAME); strcat(fname,EXTENSION); @@ -1108,19 +1100,16 @@ void CAL_SetupGrFile (global_game_variables_t *gvar) // load the pic and sprite headers into the arrays in the data segment // #if NUMPICS>0 - MM_GetPtr(MEMPTRCONV gvar->video.pictable,NUMPICS*sizeof(pictabletype),gvar); + MM_GetPtr(MEMPTR gvar->video.pictable,NUMPICS*sizeof(pictabletype),gvar); CAL_GetGrChunkLength(STRUCTPIC,gvar); // position file pointer - printf("CAL_SetupGrFile:\n"); - printf(" gvar->ca.chunkcomplen size is %lu\n", gvar->ca.chunkcomplen); - MM_GetPtr(&compseg,gvar->ca.chunkcomplen,gvar); - IN_Ack(gvar); + MM_GetPtr(&compseg,gvar->ca.chunkcomplen, gvar); CA_FarRead (gvar->ca.file.grhandle,compseg,gvar->ca.chunkcomplen,gvar); CAL_HuffExpand (compseg, (byte far *)gvar->video.pictable,NUMPICS*sizeof(pictabletype),gvar->ca.grhuffman); MM_FreePtr(&compseg,gvar); #endif #if NUMPICM>0 - MM_GetPtr(MEMPTRCONV picmtable,NUMPICM*sizeof(pictabletype)); + MM_GetPtr(MEMPTR picmtable,NUMPICM*sizeof(pictabletype)); CAL_GetGrChunkLength(STRUCTPICM); // position file pointer MM_GetPtr(&compseg,gvar->ca.chunkcomplen); CA_FarRead (gvar->ca.file.grhandle,compseg,gvar->ca.chunkcomplen); @@ -1129,7 +1118,7 @@ void CAL_SetupGrFile (global_game_variables_t *gvar) #endif #if NUMSPRITES>0 - MM_GetPtr(MEMPTRCONV spritetable,NUMSPRITES*sizeof(spritetabletype)); + MM_GetPtr(MEMPTR spritetable,NUMSPRITES*sizeof(spritetabletype)); CAL_GetGrChunkLength(STRUCTSPRITE); // position file pointer MM_GetPtr(&compseg,gvar->ca.chunkcomplen); CA_FarRead (gvar->ca.file.grhandle,compseg,gvar->ca.chunkcomplen); @@ -1165,7 +1154,7 @@ void CAL_SetupMapFile (global_game_variables_t *gvar) O_RDONLY | O_BINARY, S_IREAD)) == -1) Quit (gvar, "Can't open maphead.mph"); length = filelength(handle); - MM_GetPtr (MEMPTRCONV gvar->ca.tinf,length,gvar); + MM_GetPtr (MEMPTR gvar->ca.tinf,length,gvar); CA_FarRead(handle, gvar->ca.tinf, length,gvar); close(handle); //#else @@ -1216,7 +1205,7 @@ void CAL_SetupMapFile (global_game_variables_t *gvar) O_RDONLY | O_BINARY, S_IREAD)) == -1) Quit (gvar, "Can't open AUDIOHED.16""!"); length = filelength(handle); - MM_GetPtr (MEMPTRCONV audiostarts,length); + MM_GetPtr (MEMPTR audiostarts,length); CA_FarRead(handle, (byte far *)audiostarts, length); close(handle); #else @@ -1340,7 +1329,7 @@ void CA_CacheAudioChunk (int chunk) if (audiosegs[chunk]) { - MM_SetPurge (MEMPTRCONV audiosegs[chunk],0); + MM_SetPurge (MEMPTR audiosegs[chunk],0); return; // allready in memory } @@ -1362,7 +1351,7 @@ void CA_CacheAudioChunk (int chunk) #ifndef AUDIOHEADERLINKED - MM_GetPtr (MEMPTRCONV audiosegs[chunk],compressed); + MM_GetPtr (MEMPTR audiosegs[chunk],compressed); if (mmerror) return; @@ -1387,7 +1376,7 @@ void CA_CacheAudioChunk (int chunk) expanded = *(long far *)source; source += 4; // skip over length - MM_GetPtr (MEMPTRCONV audiosegs[chunk],expanded); + MM_GetPtr (MEMPTR audiosegs[chunk],expanded); if (mmerror) goto done; CAL_HuffExpand (source,audiosegs[chunk],expanded,audiohuffman); @@ -1428,7 +1417,7 @@ void CA_LoadAllSounds (void) for (i=0;ica.file.grhandle,pos,SEEK_SET); @@ -1876,7 +1865,7 @@ void CA_CacheGrChunk (int chunk) // load the chunk into a buffer, either the miscbuffer if it fits, or allocate // a larger buffer // - pos = GRFILEPOS(chunk,gvar); + pos = GRFILEPOS(chunk); if (pos<0) // $FFFFFFFF start is a sparse tile return; @@ -1884,7 +1873,7 @@ void CA_CacheGrChunk (int chunk) while (GRFILEPOS(next) == -1) // skip past any sparse tiles next++; - compressed = GRFILEPOS(next,gvar)-pos; + compressed = GRFILEPOS(next)-pos; lseek(gvar->ca.file.grhandle,pos,SEEK_SET); @@ -1956,12 +1945,12 @@ void CA_CacheMap (global_game_variables_t *gvar) // if (pos<0) // $FFFFFFFF start is a sparse map // printf("CA_CacheMap: Tried to load a non existent map!"); -// MM_GetPtr(MEMPTRCONV gvar->ca.camapheaderseg[mapnum],sizeof(maptype)); +// MM_GetPtr(MEMPTR gvar->ca.camapheaderseg[mapnum],sizeof(maptype)); // lseek(maphandle,pos,SEEK_SET); // CA_FarRead (maphandle,(memptr)mapheaderseg[mapnum],sizeof(maptype)); // } // else -// MM_SetPurge (MEMPTRCONV mapheaderseg[mapnum], 0, &(gvar->mm)); +// MM_SetPurge (MEMPTR mapheaderseg[mapnum], 0, &(gvar->mm)); // // load the planes in @@ -1979,7 +1968,7 @@ void CA_CacheMap (global_game_variables_t *gvar) if (!compressed) continue; // the plane is not used in this game - dest = MEMPTRCONV mapsegs[plane]; + dest = MEMPTR mapsegs[plane]; MM_GetPtr(dest,size); lseek(maphandle,pos,SEEK_SET); @@ -2363,7 +2352,7 @@ void CAL_CacheMarks (char *title, global_game_variables_t *gvar) if (dialog && updatecachebox) updatecachebox (); - pos = GRFILEPOS(i,gvar); + pos = GRFILEPOS(i); if (pos<0) continue; @@ -2371,7 +2360,7 @@ void CAL_CacheMarks (char *title, global_game_variables_t *gvar) while (GRFILEPOS(next) == -1) // skip past any sparse tiles next++; - compressed = GRFILEPOS(next,gvar)-pos; + compressed = GRFILEPOS(next)-pos; endpos = pos+compressed; if (compressed<=BUFFERSIZE) @@ -2394,10 +2383,10 @@ void CAL_CacheMarks (char *title, global_game_variables_t *gvar) if (next == NUMCHUNKS) continue; - nextpos = GRFILEPOS(next,gvar); - while (GRFILEPOS(++next,gvar) == -1) // skip past any sparse tiles + nextpos = GRFILEPOS(next); + while (GRFILEPOS(++next) == -1) // skip past any sparse tiles ; - nextendpos = GRFILEPOS(next,gvar); + nextendpos = GRFILEPOS(next); if (nextpos - endpos <= MAXEMPTYREAD && nextendpos-pos <= BUFFERSIZE) endpos = nextendpos;