\r
=============================================================================\r
*/\r
-\r
-#include "src/lib/16_head.h"\r
+
+#include "src/lib/16_ca.h"\r
//#include "ID_STRS.H"\r
\r
//#define THREEBYTEGRSTARTS\r
void CAL_DialogDraw (char *title,unsigned numcache);\r
void CAL_DialogUpdate (void);\r
void CAL_DialogFinish (void);*/\r
-void CAL_CarmackExpand (unsigned far *source, unsigned far *dest,\r
- unsigned length);\r
+//void CAL_CarmackExpand (unsigned far *source, unsigned far *dest,unsigned length);\r
\r
\r
-/*#ifdef THREEBYTEGRSTARTS\r
-#define FILEPOSSIZE 3*/\r
+/*++++#ifdef THREEBYTEGRSTARTS\r
+#define FILEPOSSIZE 3\r
//#define GRFILEPOS(c) (*(long far *)(((byte far *)grstarts)+(c)*3)&0xffffff)\r
long GRFILEPOS(int c)\r
{\r
#else\r
#define FILEPOSSIZE 4\r
#define GRFILEPOS(c) (grstarts[c])\r
-#endif\r
+#endif*/\r
\r
/*\r
=============================================================================\r
=\r
============================\r
*/\r
-\r
-void CA_OpenDebug (void)\r
+/*++++\r
+void CA_OpenDebug(void)\r
{\r
- unlink ("DEBUG.TXT");\r
+ unlink("DEBUG.TXT");\r
debughandle = open("DEBUG.TXT", O_CREAT | O_WRONLY | O_TEXT);\r
}\r
\r
-void CA_CloseDebug (void)\r
+void CA_CloseDebug(void)\r
{\r
- close (debughandle);\r
-}\r
+ close debughandle);\r
+}*/\r
\r
\r
\r
=\r
============================\r
*/\r
-\r
+/*++++\r
void CAL_GetGrChunkLength (int chunk)\r
{\r
lseek(grhandle,GRFILEPOS(chunk),SEEK_SET);\r
read(grhandle,&chunkexplen,sizeof(chunkexplen));\r
chunkcomplen = GRFILEPOS(chunk+1)-GRFILEPOS(chunk)-4;\r
-}\r
+}*/\r
\r
\r
/*\r
==========================\r
*/\r
\r
-boolean CA_FarRead (int handle, byte far *dest, long length)\r
+boolean CA_FarRead (int handle, byte far *dest, dword length)\r
{
- union REGS CPURegs;\r
+ boolean flag;\r
if (length>0xffffl)\r
printf("CA_FarRead doesn't support 64K reads yet!\n");\r
int 21h\r
pop ds\r
jnc good
- }\r
- errno = CPURegs.x.ax;\r
- return false;
- __asm
- {\r
+ mov errno,ax
+ mov flag,0
+ jmp End
good:\r
cmp ax,[WORD PTR length]\r
je done\r
- errno = EINVFMT; // user manager knows this is bad read\r
- return false;\r
-done:\r
- return true;\r
+// errno = EINVFMT; // user manager knows this is bad read\r
+ mov flag,0
+ jmp End
+done:
+ mov flag,1
+End:
+ }\r
+ return flag;\r
}\r
\r
\r
==========================\r
*/\r
\r
-boolean CA_FarWrite (int handle, byte far *source, long length)\r
-{\r
+boolean CA_FarWrite (int handle, byte far *source, dword length)\r
+{
+ boolean flag;\r
if (length>0xffffl)\r
- Quit ("CA_FarWrite doesn't support 64K reads yet!");\r
-\r
-asm push ds\r
-asm mov bx,[handle]\r
-asm mov cx,[WORD PTR length]\r
-asm mov dx,[WORD PTR source]\r
-asm mov ds,[WORD PTR source+2]\r
-asm mov ah,0x40 // WRITE w/handle\r
-asm int 21h\r
-asm pop ds\r
-asm jnc good\r
- errno = _AX;\r
- return false;\r
-good:\r
-asm cmp ax,[WORD PTR length]\r
-asm je done\r
- errno = ENOMEM; // user manager knows this is bad write\r
- return false;\r
+ printf("CA_FarWrite doesn't support 64K reads yet!\n");
\r
-done:\r
- return true;\r
+ __asm
+ {\r
+ push ds\r
+ mov bx,[handle]\r
+ mov cx,[WORD PTR length]\r
+ mov dx,[WORD PTR source]\r
+ mov ds,[WORD PTR source+2]\r
+ mov ah,0x40 // WRITE w/handle\r
+ int 21h\r
+ pop ds\r
+ jnc good
+ mov errno,ax\r
+ mov flag,0
+ jmp End\r
+good:\r
+ cmp ax,[WORD PTR length]\r
+ je done\r
+ //errno = ENOMEM; // user manager knows this is bad write
+ mov flag,0
+ jmp End\r
+done:
+ mov flag,1
+End:\r
+ }
+ return flag;\r
}\r
\r
\r
==========================\r
*/\r
\r
-boolean CA_ReadFile (char *filename, memptr *ptr)\r
+boolean CA_ReadFile(char *filename, memptr *ptr)\r
{\r
int handle;\r
- long size;\r
+ dword size;\r
\r
- if ((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1)\r
+ if((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1)\r
return false;\r
\r
- size = filelength (handle);\r
- if (!CA_FarRead (handle,*ptr,size))\r
+ size = filelength(handle);\r
+ if(!CA_FarRead(handle,*ptr,size))\r
{\r
- close (handle);\r
+ close(handle);\r
return false;\r
}\r
- close (handle);\r
+ close(handle);\r
return true;\r
}\r
\r
==========================\r
*/\r
\r
-boolean CA_LoadFile (char *filename, memptr *ptr)\r
+boolean CA_LoadFile(char *filename, memptr *ptr)\r
{\r
int handle;\r
long size;\r
\r
- if ((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1)\r
+ if((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1)\r
return false;\r
\r
size = filelength (handle);\r
MM_GetPtr (ptr,size);\r
- if (!CA_FarRead (handle,*ptr,size))\r
+ if(!CA_FarRead (handle,*ptr,size))\r
{\r
close (handle);\r
return false;\r
}\r
- close (handle);\r
+ close(handle);\r
return true;\r
}\r
\r
======================\r
*/\r
\r
-void CAL_HuffExpand (byte huge *source, byte huge *dest,\r
+/*++++void CAL_HuffExpand (byte huge *source, byte huge *dest,\r
long length,huffnode *hufftable)\r
{\r
// unsigned bit,byte,node,code;\r
//--------------------------\r
// expand less than 64k of data\r
//--------------------------\r
+
+ __asm
+ {\r
+ mov bx,[headptr]\r
\r
-asm mov bx,[headptr]\r
-\r
-asm mov si,[sourceoff]\r
-asm mov di,[destoff]\r
-asm mov es,[destseg]\r
-asm mov ds,[sourceseg]\r
-asm mov ax,[endoff]\r
+ mov si,[sourceoff]\r
+ mov di,[destoff]\r
+ mov es,[destseg]\r
+ mov ds,[sourceseg]\r
+ mov ax,[endoff]\r
\r
-asm mov ch,[si] // load first byte\r
-asm inc si\r
-asm mov cl,1\r
+ mov ch,[si] // load first byte\r
+ inc si\r
+ mov cl,1\r
\r
expandshort:\r
-asm test ch,cl // bit set?\r
-asm jnz bit1short\r
-asm mov dx,[ss:bx] // take bit0 path from node\r
-asm shl cl,1 // advance to next bit position\r
-asm jc newbyteshort\r
-asm jnc sourceupshort\r
+ test ch,cl // bit set?\r
+ jnz bit1short\r
+ mov dx,[ss:bx] // take bit0 path from node\r
+ shl cl,1 // advance to next bit position\r
+ jc newbyteshort\r
+ jnc sourceupshort\r
\r
bit1short:\r
asm mov dx,[ss:bx+2] // take bit1 path\r
asm mov bx,[headptr] // back to the head node for next bit\r
\r
asm cmp di,ax // done?\r
-asm jne expandshort\r
+asm jne expandshort
+ }\r
}\r
else\r
{\r
//--------------------------\r
\r
length--;\r
-\r
+
+ __asm
+ {\r
asm mov bx,[headptr]\r
asm mov cl,1\r
\r
asm jnc expand\r
asm dec [WORD PTR ss:length+2]\r
asm jns expand // when length = ffff ffff, done\r
-\r
+ }\r
+ }\r
+
+ __asm
+ {\r
+ mov ax,ss\r
+ mov ds,ax
}\r
\r
-asm mov ax,ss\r
-asm mov ds,ax\r
-\r
-}\r
+}*/\r
\r
\r
/*\r
=\r
======================\r
*/\r
-\r
+/*++++\r
#define NEARTAG 0xa7\r
#define FARTAG 0xa8\r
\r
}\r
}\r
}\r
-\r
+*/\r
\r
\r
/*\r
=\r
======================\r
*/\r
-\r
+/*++++\r
long CA_RLEWCompress (unsigned huge *source, long length, unsigned huge *dest,\r
unsigned rlewtag)\r
{\r
complength = 2*(dest-start);\r
return complength;\r
}\r
-\r
+*/\r
\r
/*\r
======================\r
=\r
======================\r
*/\r
-\r
+/*++++\r
void CA_RLEWexpand (unsigned huge *source, unsigned huge *dest,long length,\r
unsigned rlewtag)\r
{\r
asm mov ds,ax\r
\r
}\r
-\r
+*/\r
\r
\r
/*\r
======================\r
*/\r
\r
-void CAL_SetupGrFile (void)\r
+/*void CAL_SetupGrFile (void)\r
{\r
int handle;\r
memptr compseg;\r
MM_FreePtr(&compseg);\r
#endif\r
\r
-}\r
+}*/\r
\r
//==========================================================================\r
\r
======================\r
*/\r
\r
-void CAL_SetupMapFile (void)\r
+/*void CAL_SetupMapFile (void)\r
{\r
int handle;\r
long length;\r
O_RDONLY | O_BINARY, S_IREAD)) == -1)\r
Quit ("Can't open MAPTEMP."EXT"!");\r
#endif\r
-}\r
+}*/\r
\r
//==========================================================================\r
\r
======================\r
*/\r
\r
-void CAL_SetupAudioFile (void)\r
+/*void CAL_SetupAudioFile (void)\r
{\r
int handle;\r
long length;\r
O_RDONLY | O_BINARY, S_IREAD)) == -1)\r
Quit ("Can't open AUDIO."EXT"!");\r
#endif\r
-}\r
+}*/\r
\r
//==========================================================================\r
\r
======================\r
*/\r
\r
-void CA_Startup (void)\r
+void CA_Startup(void)\r
{\r
#ifdef PROFILE\r
- unlink ("PROFILE.TXT");\r
+ unlink("PROFILE.TXT");\r
profilehandle = open("PROFILE.TXT", O_CREAT | O_WRONLY | O_TEXT);\r
#endif\r
-\r
+/*++++\r
// MDM begin - (GAMERS EDGE)\r
//\r
- if (!FindFile("AUDIO."EXT,NULL,2))\r
+ if(!FindFile("AUDIO."EXT,NULL,2))\r
Quit("CA_Startup(): Can't find audio files.");\r
//\r
// MDM end\r
\r
#ifndef NOAUDIO\r
- CAL_SetupAudioFile ();\r
+ CAL_SetupAudioFile();\r
#endif\r
\r
// MDM begin - (GAMERS EDGE)\r
\r
drawcachebox = CAL_DialogDraw;\r
updatecachebox = CAL_DialogUpdate;\r
- finishcachebox = CAL_DialogFinish;\r
+ finishcachebox = CAL_DialogFinish;*/\r
}\r
\r
//==========================================================================\r
======================\r
*/\r
\r
-void CA_Shutdown (void)\r
+void CA_Shutdown(void)\r
{\r
#ifdef PROFILE\r
- close (profilehandle);\r
+ close(profilehandle);\r
#endif\r
-\r
- close (maphandle);\r
- close (grhandle);\r
- close (audiohandle);\r
+/*++++\r
+ close(maphandle);\r
+ close(grhandle);\r
+ close(audiohandle);*/\r
}\r
\r
//===========================================================================\r
=\r
======================\r
*/\r
-\r
+/*++++
void CA_CacheAudioChunk (int chunk)\r
{\r
long pos,compressed;\r
if (compressed>BUFFERSIZE)\r
MM_FreePtr(&bigbufferseg);\r
#endif\r
-}\r
+}*/\r
\r
//===========================================================================\r
\r
=\r
======================\r
*/\r
-\r
+/*++++
void CA_LoadAllSounds (void)\r
{\r
unsigned start,i;\r
CA_CacheAudioChunk (start);\r
\r
oldsoundmode = SoundMode;\r
-}\r
+}*/\r
\r
//===========================================================================\r
\r
-#if GRMODE == EGAGR\r
+//++++#if GRMODE == EGAGR\r
\r
/*\r
======================\r
=\r
======================\r
*/\r
-\r
+/*++++\r
unsigned static sheight,swidth;\r
boolean static dothemask;\r
\r
}\r
\r
#endif\r
-\r
+*/\r
//===========================================================================\r
\r
/*\r
=\r
======================\r
*/\r
-\r
+/*++++\r
void CAL_CacheSprite (int chunk, byte far *compressed)\r
{\r
int i;\r
}\r
\r
#endif\r
-}\r
+}*/\r
\r
//===========================================================================\r
\r
=\r
======================\r
*/\r
-\r
+/*++++\r
void CAL_ExpandGrChunk (int chunk, byte far *source)\r
{\r
long expanded;\r
CAL_HuffExpand (source,grsegs[chunk],expanded,grhuffman);\r
}\r
}\r
-\r
+*/\r
\r
/*\r
======================\r
=\r
======================\r
*/\r
-\r
+/*++++\r
void CAL_ReadGrChunk (int chunk)\r
{\r
long pos,compressed;\r
if (compressed>BUFFERSIZE)\r
MM_FreePtr(&bigbufferseg);\r
}\r
-\r
+*/\r
/*\r
======================\r
=\r
=\r
======================\r
*/\r
-\r
+/*++++\r
void CA_CacheGrChunk (int chunk)\r
{\r
long pos,compressed;\r
if (compressed>BUFFERSIZE)\r
MM_FreePtr(&bigbufferseg);\r
}\r
-\r
+*/\r
\r
\r
//==========================================================================\r
=\r
======================\r
*/\r
-\r
+/*++++\r
void CA_CacheMap (int mapnum)\r
{\r
long pos,compressed;\r
if (compressed>BUFFERSIZE)\r
MM_FreePtr(&bigbufferseg);\r
}\r
-}\r
+}*/\r
\r
//===========================================================================\r
\r
=\r
======================\r
*/\r
-\r
+/*++++\r
void CA_UpLevel (void)\r
{\r
if (ca_levelnum==7)\r
\r
ca_levelbit<<=1;\r
ca_levelnum++;\r
-}\r
+}*/\r
\r
//===========================================================================\r
\r
=\r
======================\r
*/\r
-\r
+/*++\r
void CA_DownLevel (void)\r
{\r
if (!ca_levelnum)\r
ca_levelbit>>=1;\r
ca_levelnum--;\r
CA_CacheMarks(NULL);\r
-}\r
+}*/\r
\r
//===========================================================================\r
\r
=\r
======================\r
*/\r
-\r
+/*\r
void CA_ClearMarks (void)\r
{\r
int i;\r
for (i=0;i<NUMCHUNKS;i++)\r
grneeded[i]&=~ca_levelbit;\r
}\r
-\r
+*/\r
\r
//===========================================================================\r
\r
=\r
======================\r
*/\r
-\r
+/*\r
void CA_ClearAllMarks (void)\r
{\r
_fmemset (grneeded,0,sizeof(grneeded));\r
ca_levelbit = 1;\r
ca_levelnum = 0;\r
}\r
-\r
+*/\r
\r
//===========================================================================\r
\r
=\r
======================\r
*/\r
-\r
+/*++++\r
void CA_FreeGraphics (void)\r
{\r
int i;\r
if (grsegs[i])\r
MM_SetPurge (&(memptr)grsegs[i],3);\r
}\r
-\r
+*/\r
\r
/*\r
======================\r
=\r
======================\r
*/\r
-\r
+/*++++++++\r
void CA_SetAllPurge (void)\r
{\r
int i;\r
for (i=0;i<NUMCHUNKS;i++)\r
if (grsegs[i])\r
MM_SetPurge (&(memptr)grsegs[i],3);\r
-}\r
+}*/\r
\r
\r
//===========================================================================\r
=\r
======================\r
*/\r
-\r
+/*\r
#define NUMBARS (17l*8)\r
#define BARSTEP 8\r
\r
\r
VW_UpdateScreen();\r
}\r
-\r
+*/\r
\r
/*\r
======================\r
=\r
======================\r
*/\r
-\r
+/*\r
void CAL_DialogUpdate (void)\r
{\r
unsigned x,xh;\r
lastx = xh;\r
VW_UpdateScreen();\r
}\r
-}\r
+}*/\r
\r
/*\r
======================\r
=\r
======================\r
*/\r
-\r
+/*\r
void CAL_DialogFinish (void)\r
{\r
unsigned x,xh;\r
#endif\r
VW_UpdateScreen();\r
\r
-}\r
+}*/\r
\r
//===========================================================================\r
\r
= CA_CacheMarks\r
=\r
======================\r
-*/\r
+*//*\r
#define MAXEMPTYREAD 1024\r
\r
void CA_CacheMarks (char *title)\r
//\r
if (dialog && finishcachebox)\r
finishcachebox();\r
-}\r
+}*/\r