void DebugMemory (void) { VW_FixRefreshBuffer (); US_CenterWindow (16,7); US_CPrint ("Memory Usage"); US_CPrint ("------------"); US_Print ("Total :"); US_PrintUnsigned (mminfo.mainmem/1024); US_Print ("k\nFree :"); US_PrintUnsigned (MM_UnusedMemory()/1024); US_Print ("k\nWith purge:"); US_PrintUnsigned (MM_TotalFree()/1024); US_Print ("k\n"); VW_UpdateScreen(); IN_Ack (); #if GRMODE == EGAGR MM_ShowMemory (); #endif }
void DebugMemory (void) { //id0_int_t i; //id0_char_t scratch[80],str[10]; //id0_long_t mem; //spritetype id0_seg *block; VW_FixRefreshBuffer (); CenterWindow (16,7); #if 0 CA_OpenDebug (); for (i=0;i<NUMCHUNKS;i++) { if (grsegs[i]) { strcpy (scratch,"Chunk:"); itoa (i,str,10); strcat (scratch,str); strcat (scratch,"\n"); write (debughandle,scratch,strlen(scratch)); } } CA_CloseDebug (); #endif US_CPrint ("Memory Usage"); US_CPrint ("------------"); US_Print ("Total :"); US_PrintUnsigned (mminfo.mainmem/1024); US_Print ("k\nFree :"); US_PrintUnsigned (MM_UnusedMemory()/1024); US_Print ("k\nWith purge:"); US_PrintUnsigned (MM_TotalFree()/1024); US_Print ("k\n"); VW_UpdateScreen(); IN_Ack (); }
//-------------------------------------------------------------------------- // BLoad() -- THIS HAS NOT BEEN FULLY TESTED! // // NOTICE : This version of BLOAD is compatable with JAMPak V3.0 and the // new fileformat... //-------------------------------------------------------------------------- unsigned long BLoad(char *SourceFile, memptr *DstPtr) { int handle; memptr SrcPtr; unsigned long i, j, k, r, c; word flags; byte Buffer[8]; unsigned long SrcLen,DstLen; struct CMP1Header CompHeader; boolean Compressed = false; memset((void *)&CompHeader,0,sizeof(struct CMP1Header)); // // Open file to load.... // if ((handle = open(SourceFile, O_RDONLY|O_BINARY)) == -1) return(0); // // Look for JAMPAK headers // read(handle,Buffer,4); if (!strncmp(Buffer,COMP,4)) { // // Compressed under OLD file format // Compressed = true; SrcLen = Verify(SourceFile); read(handle,(void *)&CompHeader.OrginalLen,4); CompHeader.CompType = ct_LZW; MM_GetPtr(DstPtr,CompHeader.OrginalLen); if (!*DstPtr) return(0); } else if (!strncmp(Buffer,CMP1,4)) { // // Compressed under new file format... // Compressed = true; SrcLen = Verify(SourceFile); read(handle,(void *)&CompHeader,sizeof(struct CMP1Header)); MM_GetPtr(DstPtr,CompHeader.OrginalLen); if (!*DstPtr) return(0); } else DstLen = Verify(SourceFile); // // Load the file in memory... // if (Compressed) { DstLen = CompHeader.OrginalLen; if ((MM_TotalFree() < SrcLen) && (CompHeader.CompType)) { if (!InitBufferedIO(handle,&lzwBIO)) Quit("No memory for buffered I/O."); switch (CompHeader.CompType) { #if LZW_SUPPORT case ct_LZW: lzwDecompress(&lzwBIO,MK_FP(*DstPtr,0),CompHeader.OrginalLen,(SRC_BFILE|DEST_MEM)); break; #endif #if LZH_SUPPORT case ct_LZH: lzhDecompress(&lzwBIO,MK_FP(*DstPtr,0),CompHeader.OrginalLen,CompHeader.CompressLen,(SRC_BFILE|DEST_MEM)); break; #endif default: Quit("BLoad() - Unrecognized/Supported compression"); break; } FreeBufferedIO(&lzwBIO); } else { CA_LoadFile(SourceFile,&SrcPtr); switch (CompHeader.CompType) { #if LZW_SUPPORT case ct_LZW: lzwDecompress(MK_FP(SrcPtr,8),MK_FP(*DstPtr,0),CompHeader.OrginalLen,(SRC_MEM|DEST_MEM)); break; #endif #if LZH_SUPPORT case ct_LZH: lzhDecompress(MK_FP(SrcPtr,8),MK_FP(*DstPtr,0),CompHeader.OrginalLen,CompHeader.CompressLen,(SRC_MEM|DEST_MEM)); break; #endif default: Quit("BLoad() - Unrecognized/Supported compression"); break; } MM_FreePtr(&SrcPtr); } } else CA_LoadFile(SourceFile,DstPtr); close(handle); return(DstLen); }
//-------------------------------------------------------------------------- // BLoad() -- THIS HAS NOT BEEN FULLY TESTED! // // NOTICE : This version of BLOAD is compatable with JAMPak V3.0 and the // new fileformat... //-------------------------------------------------------------------------- id0_unsigned_long_t BLoad(const id0_char_t *SourceFile, memptr *DstPtr) { BE_FILE_T handle; memptr SrcPtr; //id0_unsigned_long_t i, j, k, r, c; //id0_word_t flags; id0_byte_t Buffer[8]; id0_unsigned_long_t SrcLen,DstLen; struct CMP1Header CompHeader; id0_boolean_t Compressed = false; memset((void *)&CompHeader,0,sizeof(struct CMP1Header)); // // Open file to load.... // if (!BE_Cross_IsFileValid(handle = BE_Cross_open_for_reading(SourceFile))) //if ((handle = open(SourceFile, O_RDONLY|O_BINARY)) == -1) return(0); // // Look for JAMPAK headers // BE_Cross_readInt8LEBuffer(handle,Buffer,4); //read(handle,Buffer,4); if (!strncmp((char *)Buffer,COMP,4)) { // // Compressed under OLD file format // Compressed = true; SrcLen = Verify(SourceFile); BE_Cross_readInt32LE(handle, &CompHeader.OrginalLen); //read(handle,(void *)&CompHeader.OrginalLen,4); CompHeader.CompType = ct_LZW; MM_GetPtr(DstPtr,CompHeader.OrginalLen); if (!*DstPtr) return(0); } else if (!strncmp((char *)Buffer,CMP1,4)) { // // Compressed under new file format... // Compressed = true; SrcLen = Verify(SourceFile); BE_Cross_readInt8LEBuffer(handle,(void *)&CompHeader,sizeof(struct CMP1Header)); //read(handle,(void *)&CompHeader,sizeof(struct CMP1Header)); // REFKEEN - Big Endian support #ifdef REFKEEN_ARCH_BIG_ENDIAN CompHeader.CompType = BE_Cross_Swap16LE(CompHeader.CompType); CompHeader.OrginalLen = BE_Cross_Swap32LE(CompHeader.OrginalLen); CompHeader.CompressLen = BE_Cross_Swap32LE(CompHeader.CompressLen); #endif MM_GetPtr(DstPtr,CompHeader.OrginalLen); if (!*DstPtr) return(0); } else DstLen = Verify(SourceFile); // // Load the file in memory... // if (Compressed) { DstLen = CompHeader.OrginalLen; // REFKEEN - Looks like this is an unsigned comparison in original EXE if (((id0_unsigned_long_t)MM_TotalFree() < SrcLen) && (CompHeader.CompType)) { if (!InitBufferedIO(handle,&lzwBIO)) Quit("No memory for buffered I/O."); switch (CompHeader.CompType) { #if LZW_SUPPORT case ct_LZW: //lzwDecompress(&lzwBIO,MK_FP(*DstPtr,0),CompHeader.OrginalLen,(SRC_BFILE|DEST_MEM)); lzwDecompress(&lzwBIO,*DstPtr,CompHeader.OrginalLen,(SRC_BFILE|DEST_MEM)); break; #endif #if LZH_SUPPORT case ct_LZH: //lzhDecompress(&lzwBIO,MK_FP(*DstPtr,0),CompHeader.OrginalLen,CompHeader.CompressLen,(SRC_BFILE|DEST_MEM)); lzhDecompress(&lzwBIO,*DstPtr,CompHeader.OrginalLen,CompHeader.CompressLen,(SRC_BFILE|DEST_MEM)); break; #endif default: Quit("BLoad() - Unrecognized/Supported compression"); break; } FreeBufferedIO(&lzwBIO); } else { // REFKEEN - Better close the current file handle before re-opening here BE_Cross_close(handle); // CA_LoadFile(SourceFile,&SrcPtr); switch (CompHeader.CompType) { #if LZW_SUPPORT case ct_LZW: //lzwDecompress(MK_FP(SrcPtr,8),MK_FP(*DstPtr,0),CompHeader.OrginalLen,(SRC_MEM|DEST_MEM)); lzwDecompress((id0_byte_t *)SrcPtr + 8,*DstPtr,CompHeader.OrginalLen,(SRC_MEM|DEST_MEM)); break; #endif #if LZH_SUPPORT case ct_LZH: //lzhDecompress(MK_FP(SrcPtr,8),MK_FP(*DstPtr,0),CompHeader.OrginalLen,CompHeader.CompressLen,(SRC_MEM|DEST_MEM)); lzhDecompress((id0_byte_t *)SrcPtr + 8,*DstPtr,CompHeader.OrginalLen,CompHeader.CompressLen,(SRC_MEM|DEST_MEM)); break; #endif default: Quit("BLoad() - Unrecognized/Supported compression"); break; } MM_FreePtr(&SrcPtr); // REFKEEN - File handle already closed return(DstLen); } } else { // REFKEEN - Again we close the current file handle first, then load and finally return DstLen without re-closing file handle BE_Cross_close(handle); CA_LoadFile(SourceFile,DstPtr); return(DstLen); } BE_Cross_close(handle); return(DstLen); }
int DebugKeys (void) { boolean esc; int level,i; #if DEBUG_KEYS_AVAILABLE if (Keyboard[sc_R]) { CenterWindow (12,2); if (autofire) US_PrintCentered ("Rapid-Fire OFF"); else US_PrintCentered ("Rapid-Fire ON"); VW_UpdateScreen(); IN_Ack(); autofire ^= 1; return 1; } #endif #if DEBUG_KEYS_AVAILABLE if (Keyboard[sc_A]) { char levelstr[50]; unsigned org_tile,org_mapon,msgnum; boolean newmsg=true,newlevel=false; VW_FixRefreshBuffer (); CenterWindow (16,3); US_Print("\n"); US_CPrint("Message Test"); VW_UpdateScreen(); org_mapon = mapon; msgnum = (org_tile = *(mapsegs[0]+farmapylookup[player->tiley]+player->tilex))-NAMESTART; while (1) { // Get outta' here // if (Keyboard[sc_Escape]) { while (Keyboard[sc_Escape]); break; } // Move to previous message // if (Keyboard[sc_UpArrow]) { if (msgnum) { msgnum--; newmsg = true; } } // Move to next message // if (Keyboard[sc_DownArrow]) { if (msgnum < 24) { msgnum++; newmsg = true; } } // Move to previous level // if (Keyboard[sc_LeftArrow]) { if (mapon) { MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3); mapon--; newlevel = true; } } // Move to next level // if (Keyboard[sc_RightArrow]) { if (mapon < LASTMAP-1) { MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3); mapon++; newlevel = true; } } // Load new level text // if (newlevel) { CA_CacheGrChunk(LEVEL1TEXT+mapon); ScanText(); newmsg = true; newlevel=false; } // Display new message text // if (newmsg) { *(mapsegs[0]+farmapylookup[player->tiley]+player->tilex) = msgnum+NAMESTART; DrawText(true); strcpy(levelstr,"Level: "); itoa(mapon,levelstr+strlen(levelstr),10); strcat(levelstr," Msg: "); itoa(msgnum,levelstr+strlen(levelstr),10); DisplaySMsg(levelstr,NULL); newmsg = false; if (Keyboard[sc_UpArrow] || Keyboard[sc_DownArrow] || Keyboard[sc_LeftArrow] || Keyboard[sc_RightArrow]) VW_WaitVBL(6); } } // Restore game // MM_SetPurge(&grsegs[LEVEL1TEXT+mapon],3); mapon = org_mapon; CA_CacheGrChunk(LEVEL1TEXT+mapon); ScanText(); *(mapsegs[0]+farmapylookup[player->tiley]+player->tilex) = org_tile; DrawText(true); status_flag = 0; } if (Keyboard[sc_V]) { displayofs = bufferofs = screenloc[screenpage]; CenterWindow (16,4); US_CPrint("\n"GAMENAME); US_CPrint(VERSION); US_CPrint(REVISION); VW_UpdateScreen(); IN_Ack (); } #endif if (Keyboard[sc_Q]) // Q = Insta-Quit! Quit("Insta-Quit!"); #if 0 if (Keyboard[sc_Z]) // Z = freeze Time { if (FreezeTime) FreezeTime = 1; // Allow refresh to dec to zero.. else StopTime(); IN_Ack(); return 1; } #endif // if (Keyboard[sc_E]) // FaceDoor((player->x>>16l)+1,(player->y>>16l)); // FaceAngle(90); #if 0 if (Keyboard[sc_B]) // B = border color { CenterWindow(24,3); PrintY+=6; US_Print(" Border color (0-15):"); VW_UpdateScreen(); esc = !US_LineInput (px,py,str,NULL,true,2,0); if (!esc) { level = atoi (str); if (level>=0 && level<=15) VW_ColorBorder (level); } return 1; } #endif #if 1//DEBUG_KEYS_AVAILABLE if (Keyboard[sc_O]) { extern unsigned objectcount,latchmemavail; unsigned unused,total; CenterWindow (30,13); US_Print ("Objects: "); US_PrintUnsigned (objectcount); US_Print("\n\nTics: "); US_PrintUnsigned (tics); US_Print(" Real Tics: "); US_PrintUnsigned(realtics); US_Print ("\n\n Total Available: "); US_PrintUnsigned (mminfo.mainmem/1024); US_Print ("k\n Mem In Use: "); unused=MM_UnusedMemory()/1024; US_PrintUnsigned (unused); US_Print ("k\n Mem After Purge: "); total=MM_TotalFree()/1024; US_PrintUnsigned (total); US_Print ("k ("); US_PrintUnsigned (total-unused); US_Print (")\n\nLatch Mem Free: "); US_PrintUnsigned (latchmemavail); US_Print ("\n"); VW_UpdateScreen(); IN_Ack(); } if (colordelay<1) { if (Keyboard[26]) { extern unsigned *groundcolor,debug_gnd; groundcolor = &debug_gnd; debug_gnd += 0x0101; if (debug_gnd == 0x1010) debug_gnd = 0; colordelay = 10; } if (Keyboard[27]) { extern unsigned *skycolor,debug_sky; skycolor = &debug_sky; debug_sky += 0x0101; if (debug_sky == 0x1010) debug_sky = 0; colordelay = 10; } } else colordelay -= realtics; #endif #if 0 if (Keyboard[sc_C]) // C = count objects { CountObjects(); return 1; } if (Keyboard[sc_D]) // D = start / end demo record { if (DemoMode == demo_Off) StartDemoRecord (); else if (DemoMode == demo_Record) { EndDemoRecord (); playstate = ex_completed; } return 1; } #endif #if 0 if (Keyboard[sc_E]) // E = quit level { if (tedlevel) TEDDeath(); playstate = ex_warped; gamestate.mapon++; } #endif #if 0 if (Keyboard[sc_F]) // F = facing spot { CenterWindow (12,4); US_Print ("X:"); US_PrintUnsigned (player->x); US_Print ("Y:"); US_PrintUnsigned (player->y); US_Print ("A:"); US_PrintUnsigned (player->angle); VW_UpdateScreen(); IN_Ack(); return 1; } #endif if (Keyboard[sc_G]) // G = god mode { CenterWindow (12,2); if (godmode) US_PrintCentered ("God mode OFF"); else US_PrintCentered ("God mode ON"); VW_UpdateScreen(); IN_Ack(); godmode ^= 1; return 1; } #if 0 if (Keyboard[sc_H]) // H = hurt self { TakeDamage (5); } #endif if (Keyboard[sc_I]) // I = item cheat { extern boolean redraw_gems; CenterWindow (12,3); US_PrintCentered ("Free items!"); VW_UpdateScreen(); for (i=0;i<4;i++) { GiveBolt (); GiveNuke (); GivePotion (); // if (!gamestate.keys[i]) GiveKey (i); gamestate.gems[i] = GEM_DELAY_TIME; } gamestate.gems[4] = GEM_DELAY_TIME; redraw_gems = true; ///////// for (i=0;i<8;i++) ///////// GiveScroll (i,false); IN_Ack (); return 1; } #if DEBUG_OVERHEAD if (Keyboard[sc_Z]) // O is used elsewhere... { ViewMap(); return 1; } #endif #if 0 if (Keyboard[sc_P]) // P = pause with no screen disruptioon { PicturePause (); return 1; } #endif #if 0 if (Keyboard[sc_S]) // S = slow motion { singlestep^=1; CenterWindow (18,3); if (singlestep) US_PrintCentered ("Slow motion ON"); else US_PrintCentered ("Slow motion OFF"); VW_UpdateScreen(); IN_Ack (); return 1; } #endif #if 0 if (Keyboard[sc_V]) // V = extra VBLs { CenterWindow(30,3); PrintY+=6; US_Print(" Add how many extra VBLs(0-8):"); VW_UpdateScreen(); esc = !US_LineInput (px,py,str,NULL,true,2,0); if (!esc) { level = atoi (str); if (level>=0 && level<=8) extravbls = level; } return 1; } #endif if (Keyboard[sc_W]) // W = warp to level { CenterWindow(26,3); PrintY+=6; US_Print(" Warp to which level(0-17):"); VW_UpdateScreen(); esc = !US_LineInput (px,py,str,NULL,true,2,0); if (!esc) { level = atoi (str); if (level>=0 && level<=LASTMAP-1) { gamestate.mapon = level; playstate = ex_warped; lasttext = -1; } } return 1; } #if 0 if (Keyboard[sc_X]) // X = item cheat { CenterWindow (12,3); US_PrintCentered ("Extra stuff!"); VW_UpdateScreen(); for (i=0;i<4;i++) { GiveBolt (); GiveNuke (); GivePotion (); } IN_Ack (); return 1; } #endif //////// if (LastScan >= sc_1 && LastScan <= sc_8) // free scrolls //////// { //////// GiveScroll (LastScan-sc_1,false); //////// IN_ClearKeysDown (); //////// } return 0; }