]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_ca.c
16_ca needs huge amounts of work and I should remember what needs to be done soon...
[16.git] / src / lib / 16_ca.c
index 008e4e84cb54949bf0b645a18a4637db04eea567..64c6674a9be661d57e6ca73a14fa5b8b116c13d9 100755 (executable)
@@ -1,23 +1,19 @@
-/* Project 16 Source Code~\r
- * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
+/* Catacomb Apocalypse Source Code\r
+ * Copyright (C) 1993-2014 Flat Rock Software\r
  *\r
- * This file is part of Project 16.\r
- *\r
- * Project 16 is free software; you can redistribute it and/or modify\r
+ * This program is free software; you can redistribute it and/or modify\r
  * it under the terms of the GNU General Public License as published by\r
- * the Free Software Foundation; either version 3 of the License, or\r
+ * the Free Software Foundation; either version 2 of the License, or\r
  * (at your option) any later version.\r
  *\r
- * Project 16 is distributed in the hope that it will be useful,\r
+ * This program is distributed in the hope that it will be useful,\r
  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
  * GNU General Public License for more details.\r
  *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
- * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
- * Fifth Floor, Boston, MA 02110-1301 USA.\r
- *\r
+ * You should have received a copy of the GNU General Public License along\r
+ * with this program; if not, write to the Free Software Foundation, Inc.,\r
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
  */\r
 \r
 // ID_CA.C\r
@@ -40,7 +36,7 @@ loaded into the data segment
 #pragma warn -pro\r
 #pragma warn -use\r
 \r
-#define THREEBYTEGRSTARTS\r
+//#define THREEBYTEGRSTARTS\r
 //https://github.com/open-watcom/open-watcom-v2/issues/279#issuecomment-244587566 for _seg\r
 //http://www.shikadi.net/moddingwiki/GameMaps_Format for info on the code\r
 /*\r
@@ -125,9 +121,9 @@ huffnode    audiohuffman[255];
 int                    grhandle;               // handle to EGAGRAPH\r
 int                    maphandle;              // handle to MAPTEMP / GAMEMAPS\r
 int                    audiohandle;    // handle to AUDIOT / AUDIO\r
-*/\r
-long           chunkcomplen,chunkexplen;\r
-/*\r
+\r
+long           c hunkcomplen,c hunkexplen;\r
+\r
 SDMode         oldsoundmode;\r
 \r
 \r
@@ -142,14 +138,14 @@ void      CAL_CarmackExpand (unsigned far *source, unsigned far *dest,
 #ifdef THREEBYTEGRSTARTS\r
 #define FILEPOSSIZE    3\r
 //#define      GRFILEPOS(c) (*(long far *)(((byte far *)grstarts)+(c)*3)&0xffffff)\r
-CASVT GRFILEPOS(int c, global_game_variables_t *gvar)\r
+long GRFILEPOS(int c, global_game_variables_t *gvar)\r
 {\r
-       CASVT value;\r
+       long value;\r
        int     offset;\r
 \r
        offset = c*3;\r
 \r
-       value = *(CASVT far *)(((byte far *)gvar->ca.grstarts)+offset);\r
+       value = *(long far *)(((byte far *)gvar->ca.grstarts)+offset);\r
 \r
        value &= 0x00ffffffl;\r
 \r
@@ -160,11 +156,7 @@ CASVT GRFILEPOS(int c, global_game_variables_t *gvar)
 };\r
 #else\r
 #define FILEPOSSIZE    4\r
-//#define      GRFILEPOS(c) (gvar->ca.grstarts[c])\r
-CASVT GRFILEPOS(int c, global_game_variables_t *gvar)\r
-{\r
-       return gvar->ca.grstarts[c];\r
-}\r
+#define        GRFILEPOS(c) (gvar->ca.grstarts[c])\r
 #endif\r
 \r
 /*\r
@@ -216,9 +208,9 @@ void CA_CloseDebug(global_game_variables_t *gvar)
 \r
 void CAL_GetGrChunkLength (int chunk,global_game_variables_t *gvar)\r
 {\r
-       lseek(gvar->ca.file.grhandle,GRFILEPOS(chunk,gvar),SEEK_SET);\r
+       lseek(gvar->ca.file.grhandle,GRFILEPOS(chunk),SEEK_SET);\r
        read(gvar->ca.file.grhandle,&gvar->ca.chunkexplen,sizeof(gvar->ca.chunkexplen));\r
-       gvar->ca.chunkcomplen = GRFILEPOS(chunk+1,gvar)-GRFILEPOS(chunk,gvar)-4;\r
+       gvar->ca.chunkcomplen = GRFILEPOS(chunk+1)-GRFILEPOS(chunk)-4;\r
 }\r
 \r
 \r
@@ -1049,7 +1041,9 @@ void CAL_SetupGrFile (global_game_variables_t *gvar)
 {\r
        char fname[13];\r
        int handle;\r
+#if NUMPICS>0\r
        memptr compseg;\r
+#endif\r
 \r
 #ifdef GRHEADERLINKED\r
 \r
@@ -1110,10 +1104,7 @@ void CAL_SetupGrFile (global_game_variables_t *gvar)
 #if NUMPICS>0\r
        MM_GetPtr(MEMPTRCONV gvar->video.pictable,NUMPICS*sizeof(pictabletype),gvar);\r
        CAL_GetGrChunkLength(STRUCTPIC,gvar);           // position file pointer\r
-       printf("CAL_SetupGrFile:\n");\r
-       printf("        gvar->ca.chunkcomplen size is %lu\n", gvar->ca.chunkcomplen);\r
-       MM_GetPtr(&compseg,gvar->ca.chunkcomplen,gvar);\r
-       IN_Ack(gvar);\r
+       MM_GetPtr(&compseg,gvar->ca.chunkcomplen, gvar);\r
        CA_FarRead (gvar->ca.file.grhandle,compseg,gvar->ca.chunkcomplen,gvar);\r
        CAL_HuffExpand (compseg, (byte far *)gvar->video.pictable,NUMPICS*sizeof(pictabletype),gvar->ca.grhuffman);\r
        MM_FreePtr(&compseg,gvar);\r
@@ -1808,15 +1799,15 @@ void CAL_ReadGrChunk (int chunk)
 // load the chunk into a buffer, either the miscbuffer if it fits, or allocate\r
 // a larger buffer\r
 //\r
-       pos = GRFILEPOS(chunk,gvar);\r
+       pos = GRFILEPOS(chunk);\r
        if (pos<0)                                                      // $FFFFFFFF start is a sparse tile\r
          return;\r
 \r
        next = chunk +1;\r
-       while (GRFILEPOS(next,gvar) == -1)              // skip past any sparse tiles\r
+       while (GRFILEPOS(next) == -1)           // skip past any sparse tiles\r
                next++;\r
 \r
-       compressed = GRFILEPOS(next,gvar)-pos;\r
+       compressed = GRFILEPOS(next)-pos;\r
 \r
        lseek(gvar->ca.file.grhandle,pos,SEEK_SET);\r
 \r
@@ -1876,7 +1867,7 @@ void CA_CacheGrChunk (int chunk)
 // load the chunk into a buffer, either the miscbuffer if it fits, or allocate\r
 // a larger buffer\r
 //\r
-       pos = GRFILEPOS(chunk,gvar);\r
+       pos = GRFILEPOS(chunk);\r
        if (pos<0)                                                      // $FFFFFFFF start is a sparse tile\r
          return;\r
 \r
@@ -1884,7 +1875,7 @@ void CA_CacheGrChunk (int chunk)
        while (GRFILEPOS(next) == -1)           // skip past any sparse tiles\r
                next++;\r
 \r
-       compressed = GRFILEPOS(next,gvar)-pos;\r
+       compressed = GRFILEPOS(next)-pos;\r
 \r
        lseek(gvar->ca.file.grhandle,pos,SEEK_SET);\r
 \r
@@ -2363,7 +2354,7 @@ void CAL_CacheMarks (char *title, global_game_variables_t *gvar)
                        if (dialog && updatecachebox)\r
                                updatecachebox ();\r
 \r
-                       pos = GRFILEPOS(i,gvar);\r
+                       pos = GRFILEPOS(i);\r
                        if (pos<0)\r
                                continue;\r
 \r
@@ -2371,7 +2362,7 @@ void CAL_CacheMarks (char *title, global_game_variables_t *gvar)
                        while (GRFILEPOS(next) == -1)           // skip past any sparse tiles\r
                                next++;\r
 \r
-                       compressed = GRFILEPOS(next,gvar)-pos;\r
+                       compressed = GRFILEPOS(next)-pos;\r
                        endpos = pos+compressed;\r
 \r
                        if (compressed<=BUFFERSIZE)\r
@@ -2394,10 +2385,10 @@ void CAL_CacheMarks (char *title, global_game_variables_t *gvar)
                                                if (next == NUMCHUNKS)\r
                                                        continue;\r
 \r
-                                               nextpos = GRFILEPOS(next,gvar);\r
-                                               while (GRFILEPOS(++next,gvar) == -1)    // skip past any sparse tiles\r
+                                               nextpos = GRFILEPOS(next);\r
+                                               while (GRFILEPOS(++next) == -1) // skip past any sparse tiles\r
                                                        ;\r
-                                               nextendpos = GRFILEPOS(next,gvar);\r
+                                               nextendpos = GRFILEPOS(next);\r
                                                if (nextpos - endpos <= MAXEMPTYREAD\r
                                                && nextendpos-pos <= BUFFERSIZE)\r
                                                        endpos = nextendpos;\r