]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/16_ca.c
wwww yakuji wwww ca use to load maps w hmmm cachemap is hard to translate
[16.git] / src / lib / 16_ca.c
index 6511ef176ab649739d61e14ed50b1645c4c27108..725e9321e9b6ee3e1414ec9bd5bfe79358c486e6 100755 (executable)
@@ -724,7 +724,7 @@ dinorm:
 =\r
 ======================\r
 */\r
-/*++++\r
+\r
 #define NEARTAG        0xa7\r
 #define FARTAG 0xa8\r
 \r
@@ -747,13 +747,13 @@ void CAL_CarmackExpand (unsigned far *source, unsigned far *dest, unsigned lengt
                        count = ch&0xff;\r
                        if (!count)\r
                        {                               // have to insert a word containing the tag byte\r
-                               ch |= *((unsigned char far *)inptr)++;\r
+                               ch |= *(/*(unsigned char far *)*/inptr)++;\r
                                *outptr++ = ch;\r
                                length--;\r
                        }\r
                        else\r
                        {\r
-                               offset = *((unsigned char far *)inptr)++;\r
+                               offset = *(/*(unsigned char far *)*/inptr)++;\r
                                copyptr = outptr - offset;\r
                                length -= count;\r
                                while (count--)\r
@@ -765,7 +765,7 @@ void CAL_CarmackExpand (unsigned far *source, unsigned far *dest, unsigned lengt
                        count = ch&0xff;\r
                        if (!count)\r
                        {                               // have to insert a word containing the tag byte\r
-                               ch |= *((unsigned char far *)inptr)++;\r
+                               ch |= *(/*(unsigned char far *)*/inptr)++;\r
                                *outptr++ = ch;\r
                                length --;\r
                        }\r
@@ -785,7 +785,6 @@ void CAL_CarmackExpand (unsigned far *source, unsigned far *dest, unsigned lengt
                }\r
        }\r
 }\r
-*/\r
 \r
 \r
 /*\r
@@ -795,7 +794,7 @@ void CAL_CarmackExpand (unsigned far *source, unsigned far *dest, unsigned lengt
 =\r
 ======================\r
 */\r
-/*++++\r
+\r
 long CA_RLEWCompress (unsigned huge *source, long length, unsigned huge *dest,\r
   unsigned rlewtag)\r
 {\r
@@ -842,7 +841,7 @@ long CA_RLEWCompress (unsigned huge *source, long length, unsigned huge *dest,
   complength = 2*(dest-start);\r
   return complength;\r
 }\r
-*/\r
+\r
 \r
 /*\r
 ======================\r
@@ -852,7 +851,7 @@ long CA_RLEWCompress (unsigned huge *source, long length, unsigned huge *dest,
 =\r
 ======================\r
 */\r
-/*++++\r
+\r
 void CA_RLEWexpand (unsigned huge *source, unsigned huge *dest,long length,\r
   unsigned rlewtag)\r
 {\r
@@ -903,64 +902,88 @@ void CA_RLEWexpand (unsigned huge *source, unsigned huge *dest,long length,
 //\r
 // NOTE: A repeat count that produces 0xfff0 bytes can blow this!\r
 //\r
-\r
-asm    mov     bx,rlewtag\r
-asm    mov     si,sourceoff\r
-asm    mov     di,destoff\r
-asm    mov     es,destseg\r
-asm    mov     ds,sourceseg\r
-\r
+       __asm{\r
+               mov     bx,rlewtag\r
+               mov     si,sourceoff\r
+               mov     di,destoff\r
+               mov     es,destseg\r
+               mov     ds,sourceseg\r
+#ifdef __BORLANDC__\r
+       }\r
+#endif\r
 expand:\r
-asm    lodsw\r
-asm    cmp     ax,bx\r
-asm    je      repeat\r
-asm    stosw\r
-asm    jmp     next\r
-\r
+#ifdef __BORLANDC__\r
+       __asm {\r
+#endif\r
+               lodsw\r
+               cmp     ax,bx\r
+               je      repeat\r
+               stosw\r
+               jmp     next\r
+#ifdef __BORLANDC__\r
+       }\r
+#endif\r
 repeat:\r
-asm    lodsw\r
-asm    mov     cx,ax           // repeat count\r
-asm    lodsw                   // repeat value\r
-asm    rep stosw\r
-\r
+#ifdef __BORLANDC__\r
+       __asm {\r
+#endif\r
+               lodsw\r
+               mov     cx,ax           // repeat count\r
+               lodsw                   // repeat value\r
+               rep stosw\r
+#ifdef __BORLANDC__\r
+       }\r
+#endif\r
 next:\r
-\r
-asm    cmp     si,0x10         // normalize ds:si\r
-asm    jb      sinorm\r
-asm    mov     ax,si\r
-asm    shr     ax,1\r
-asm    shr     ax,1\r
-asm    shr     ax,1\r
-asm    shr     ax,1\r
-asm    mov     dx,ds\r
-asm    add     dx,ax\r
-asm    mov     ds,dx\r
-asm    and     si,0xf\r
+#ifdef __BORLANDC__\r
+       __asm {\r
+#endif\r
+               cmp     si,0x10         // normalize ds:si\r
+               jb      sinorm\r
+               mov     ax,si\r
+               shr     ax,1\r
+               shr     ax,1\r
+               shr     ax,1\r
+               shr     ax,1\r
+               mov     dx,ds\r
+               add     dx,ax\r
+               mov     ds,dx\r
+               and     si,0xf\r
+#ifdef __BORLANDC__\r
+       }\r
+#endif\r
 sinorm:\r
-asm    cmp     di,0x10         // normalize es:di\r
-asm    jb      dinorm\r
-asm    mov     ax,di\r
-asm    shr     ax,1\r
-asm    shr     ax,1\r
-asm    shr     ax,1\r
-asm    shr     ax,1\r
-asm    mov     dx,es\r
-asm    add     dx,ax\r
-asm    mov     es,dx\r
-asm    and     di,0xf\r
+#ifdef __BORLANDC__\r
+       __asm {\r
+#endif\r
+               cmp     di,0x10         // normalize es:di\r
+               jb      dinorm\r
+               mov     ax,di\r
+               shr     ax,1\r
+               shr     ax,1\r
+               shr     ax,1\r
+               shr     ax,1\r
+               mov     dx,es\r
+               add     dx,ax\r
+               mov     es,dx\r
+               and     di,0xf\r
+#ifdef __BORLANDC__\r
+       }\r
+#endif\r
 dinorm:\r
+#ifdef __BORLANDC__\r
+       __asm {\r
+#endif\r
+               cmp     di,ss:endoff\r
+               jne     expand\r
+               mov     ax,es\r
+               cmp     ax,ss:endseg\r
+               jb      expand\r
 \r
-asm    cmp     di,ss:endoff\r
-asm    jne     expand\r
-asm    mov     ax,es\r
-asm    cmp     ax,ss:endseg\r
-asm    jb      expand\r
-\r
-asm    mov     ax,ss\r
-asm    mov     ds,ax\r
-\r
+               mov     ax,ss\r
+               mov     ds,ax\r
+       }\r
 }\r
-*/\r
 \r
 \r
 /*\r
@@ -1206,7 +1229,7 @@ void CA_Startup(global_game_variables_t *gvar)
 \r
        CAL_SetupMapFile (gvar);\r
 \r
-       gvar->ca.mapon = -1;\r
+       gvar->ca.map.mapon = -1;\r
        gvar->ca.ca_levelbit = 1;\r
        gvar->ca.ca_levelnum = 0;\r
 \r
@@ -1834,11 +1857,14 @@ void CA_CacheMap (global_game_variables_t *gvar)
 //\r
 // free up memory from last map\r
 //\r
-//     if (gvar->ca.map.mapon>-1 && gvar->ca.map.mapheaderseg[gvar->ca.map.mapon])\r
-//             MM_SetPurge (&(memptr)gvar->ca.map.mapheaderseg[gvar-ca.map.mapon],3);\r
+       if (gvar->ca.map.mapon>-1 && gvar->ca.map.mapheaderseg[gvar->ca.map.mapon])\r
+               MM_SetPurge (&((memptr)gvar->ca.map.mapheaderseg\r
+                                                                                       [(gvar->ca.map.mapon)]),\r
+\r
+ 3, &(gvar->mm));\r
        for (plane=0;plane<MAPPLANES;plane++)\r
                if (gvar->ca.map.mapsegs[plane])\r
-                       MM_FreePtr (&(memptr)gvar->ca.map.mapsegs[plane]);\r
+                       MM_FreePtr (&(memptr)gvar->ca.map.mapsegs[plane], &(gvar->mm));\r
 \r
        gvar->ca.map.mapon = gvar->ca.map.mapnum;\r
 \r
@@ -1849,7 +1875,8 @@ void CA_CacheMap (global_game_variables_t *gvar)
 //\r
        if (!gvar->ca.map.mapheaderseg[gvar->ca.map.mapnum])\r
        {\r
-               pos = ((__segmement *)tinf)->headeroffsets[gvar->ca.mapnum];\r
+               //pos = ((mapfiletype   _seg *)tinf)->headeroffsets[mapnum];\r
+               pos = ((_seg *)gvar->ca.map.tinf)->headeroffsets[gvar->ca.map.mapnum];\r
                if (pos<0)                                              // $FFFFFFFF start is a sparse map\r
                  printf("CA_CacheMap: Tried to load a non existent map!");\r
 \r
@@ -1858,7 +1885,7 @@ void CA_CacheMap (global_game_variables_t *gvar)
                CA_FarRead (maphandle,(memptr)mapheaderseg[mapnum],sizeof(maptype));\r
        }\r
        else\r
-               MM_SetPurge (&(memptr)mapheaderseg[mapnum],0);\r
+               MM_SetPurge (&(memptr)mapheaderseg[mapnum], 0, &(gvar->mm));\r
 \r
 //\r
 // load the planes in\r
@@ -1916,7 +1943,7 @@ void CA_CacheMap (global_game_variables_t *gvar)
                if (compressed>BUFFERSIZE)\r
                        MM_FreePtr(&bigbufferseg);\r
        }\r
-}*/\r
+}//*/\r
 \r
 //===========================================================================\r
 \r
@@ -1930,15 +1957,15 @@ void CA_CacheMap (global_game_variables_t *gvar)
 =\r
 ======================\r
 */\r
-/*++++\r
-void CA_UpLevel (void)\r
+\r
+void CA_UpLevel (global_game_variables_t *gvar)\r
 {\r
-       if (ca_levelnum==7)\r
-               Quit ("CA_UpLevel: Up past level 7!");\r
+       if (gvar->ca.ca_levelnum==7)\r
+               printf("CA_UpLevel: Up past level 7!");\r
 \r
-       ca_levelbit<<=1;\r
-       ca_levelnum++;\r
-}*/\r
+       gvar->ca.ca_levelbit<<=1;\r
+       gvar->ca.ca_levelnum++;\r
+}\r
 \r
 //===========================================================================\r
 \r
@@ -1952,15 +1979,15 @@ void CA_UpLevel (void)
 =\r
 ======================\r
 */\r
-/*++\r
-void CA_DownLevel (void)\r
+\r
+void CA_DownLevel (global_game_variables_t *gvar)\r
 {\r
-       if (!ca_levelnum)\r
-               Quit ("CA_DownLevel: Down past level 0!");\r
-       ca_levelbit>>=1;\r
-       ca_levelnum--;\r
-       CA_CacheMarks(NULL);\r
-}*/\r
+       if (!gvar->ca.ca_levelnum)\r
+               printf("CA_DownLevel: Down past level 0!");\r
+       gvar->ca.ca_levelbit>>=1;\r
+       gvar->ca.ca_levelnum--;\r
+       ////++++++++++++++++++++++++++++++++++++++++++CA_CacheMarks(NULL);\r
+}\r
 \r
 //===========================================================================\r
 \r
@@ -2045,7 +2072,7 @@ void CA_SetAllPurge (void)
 //\r
 // free cursor sprite and background save\r
 //\r
-       VW_FreeCursor ();\r
+       //VW_FreeCursor ();\r
 \r
 //\r
 // free map headers and map planes\r