X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_ca.c;h=64c6674a9be661d57e6ca73a14fa5b8b116c13d9;hb=ce3c236194323bcbc331bad4a059ea95fb6c7947;hp=008e4e84cb54949bf0b645a18a4637db04eea567;hpb=181c6beee3d42da41fc53f44f0aa3e9315016ad2;p=16.git diff --git a/src/lib/16_ca.c b/src/lib/16_ca.c index 008e4e84..64c6674a 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; } @@ -1049,7 +1041,9 @@ void CAL_SetupGrFile (global_game_variables_t *gvar) { char fname[13]; int handle; +#if NUMPICS>0 memptr compseg; +#endif #ifdef GRHEADERLINKED @@ -1110,10 +1104,7 @@ void CAL_SetupGrFile (global_game_variables_t *gvar) #if NUMPICS>0 MM_GetPtr(MEMPTRCONV 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); @@ -1808,15 +1799,15 @@ void CAL_ReadGrChunk (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; next = chunk +1; - while (GRFILEPOS(next,gvar) == -1) // skip past any sparse tiles + 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); @@ -1876,7 +1867,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 +1875,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); @@ -2363,7 +2354,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 +2362,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 +2385,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;