X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_ca.c;h=25463ac732dff8703683b1d0f659af0aac7345ac;hb=c48c2f1e1f84ca6eaa064e6e88884c7e9c8d303b;hp=169c4a8539691ecbc600f7d6d604417d09c6889f;hpb=e5cb235d748a442c66e6b1c556072b70dfc05c91;p=16.git diff --git a/src/lib/16_ca.c b/src/lib/16_ca.c old mode 100644 new mode 100755 index 169c4a85..25463ac7 --- a/src/lib/16_ca.c +++ b/src/lib/16_ca.c @@ -176,8 +176,14 @@ long GRFILEPOS(int c) */ void CA_OpenDebug(global_game_variables_t *gvar) { - unlink("debug.16"); - gvar->handle.debughandle = open("debug.16", O_CREAT | O_WRONLY | O_TEXT); +#ifdef __BORLANDC__ + unlink("debug.16b"); + gvar->handle.debughandle = open("debug.16b", O_CREAT | O_WRONLY | O_TEXT); +#endif +#ifdef __WATCOMC__ + unlink("debug.16w"); + gvar->handle.debughandle = open("debug.16w", O_CREAT | O_WRONLY | O_TEXT); +#endif } void CA_CloseDebug(global_game_variables_t *gvar) @@ -219,20 +225,21 @@ void CAL_GetGrChunkLength (int chunk) boolean CA_FarRead(int handle, byte huge *dest, dword length, mminfo_t *mm) { boolean flag; - /*dword fat=0; - word segm=0; + //dword fat=0; + //word segm=0; //if(mm->EMSVer<0x40) if(length>0xfffflu) { printf("File is a fat bakapee\n"); - segm=(length%0xfffflu)-1; - fat=segm*0xfffflu; - length-=fat; + //segm=(length%0xfffflu)-1; + //fat=segm*0xfffflu; + //length-=fat; // printf("CA_FarRead doesn't support 64K reads yet!\n"); + return 0;//TODO: EXPAND!!! } - if(!fat&&!segm) - {*/ + //if(!fat&&!segm) + //{ __asm { push ds mov bx,[handle] @@ -274,7 +281,6 @@ End: } #endif return flag; - //}else return 0;//todo: EXPAND!!! } @@ -291,20 +297,21 @@ End: boolean CA_FarWrite(int handle, byte huge *source, dword length, mminfo_t *mm) { boolean flag; - /*dword fat=0; - word segm=0; + //dword fat=0; + //word segm=0; //if(mm->EMSVer<0x40) if(length>0xfffflu) { printf("File is a fat bakapee\n"); - segm=(length%0xfffflu)-1; - fat=segm*0xfffflu; - length-=fat; + //segm=(length%0xfffflu)-1; + //fat=segm*0xfffflu; + //length-=fat; // printf("CA_FarRead doesn't support 64K reads yet!\n"); + return 0; } - if(!fat&&!segm) - {*/ + //if(!fat&&!segm) + //{ __asm { push ds mov bx,[handle] @@ -346,7 +353,6 @@ End: } #endif return flag; - //}else return 0; } @@ -363,7 +369,7 @@ End: boolean CA_ReadFile(char *filename, memptr *ptr, mminfo_t *mm) { int handle; - dword size; + sdword size; //long size; if((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1) @@ -371,6 +377,38 @@ boolean CA_ReadFile(char *filename, memptr *ptr, mminfo_t *mm) size = filelength(handle); if(!CA_FarRead(handle,*ptr,size, mm)) + { + close (handle); + return false; + } + close (handle); + return true; +} + + +/* +========================== += += CA_WriteFile += += Writes a file from a memory buffer += +========================== +*/ + +boolean CA_WriteFile (char *filename, void far *ptr, long length, mminfo_t *mm) +{ + int handle; + sdword size; + //long size; + + handle = open(filename,O_CREAT | O_BINARY | O_WRONLY, + S_IREAD | S_IWRITE | S_IFREG); + + if (handle == -1) + return false; + + if (!CA_FarWrite (handle,ptr,length, mm)) { close(handle); return false; @@ -394,7 +432,7 @@ boolean CA_ReadFile(char *filename, memptr *ptr, mminfo_t *mm) boolean CA_LoadFile(char *filename, memptr *ptr, mminfo_t *mm, mminfotype *mmi) { int handle; - dword size; + sdword size; //long size; if((handle = open(filename,O_RDONLY | O_BINARY, S_IREAD)) == -1) @@ -882,7 +920,7 @@ asm mov ds,ax = ====================== */ - +////++++ enable! /*void CAL_SetupGrFile (void) { int handle; @@ -1080,8 +1118,14 @@ asm mov ds,ax void CA_Startup(global_game_variables_t *gvar) { #ifdef PROFILE - unlink("profile.16"); - gvar->handle.profilehandle = open("profile.16", O_CREAT | O_WRONLY | O_TEXT); +#ifdef __BORLANDC__ + unlink("profile.16b"); + gvar->handle.profilehandle = open("profile.16b", O_CREAT | O_WRONLY | O_TEXT); +#endif +#ifdef __WATCOMC__ + unlink("profile.16w"); + gvar->handle.profilehandle = open("profile.16w", O_CREAT | O_WRONLY | O_TEXT); +#endif #endif // unlink("debug0.16"); // gvar->handle.showmemhandle = open("debug0.16", O_CREAT | O_WRONLY | O_TEXT); @@ -1933,9 +1977,14 @@ void CA_ClearAllMarks (void) ====================== */ /*++++ -void CA_FreeGraphics (void) +void CA_SetGrPurge (void) { - int i; + int i; + +// +// free graphics +// + CA_ClearMarks (); for (i=0;i