/* ======================================================================================================================= ======================================================================================================================= */ BOOL ReadZippedRomData(char *rompath) { /*~~~~~~~~~~~~~~~~~~~~~~~*/ unzFile fp; unsigned long gROMLength; /* size in bytes of the ROM */ /*~~~~~~~~~~~~~~~~~~~~~~~*/ if(fp = unzOpen(rompath)) { /*~~~~~~~~~~~~~~~~~~~~*/ char szFileName[256]; /*~~~~~~~~~~~~~~~~~~~~*/ if(unzGoToFirstFile(fp) == UNZ_OK) { do { /*~~~~~~~~~~~~~~~~~~~~~~*/ unz_file_info file_info; /*~~~~~~~~~~~~~~~~~~~~~~*/ if(unzGetCurrentFileInfo(fp, &file_info, szFileName, 256, NULL, 0, NULL, 0) == UNZ_OK) { if ( stricmp(&szFileName[strlen(szFileName) - 4], ".bin") == 0 || stricmp(&szFileName[strlen(szFileName) - 4], ".v64") == 0 || stricmp(&szFileName[strlen(szFileName) - 4], ".rom") == 0 || stricmp(&szFileName[strlen(szFileName) - 4], ".usa") == 0 || stricmp(&szFileName[strlen(szFileName) - 4], ".z64") == 0 || stricmp(&szFileName[strlen(szFileName) - 4], ".j64") == 0 || stricmp(&szFileName[strlen(szFileName) - 4], ".pal") == 0 || stricmp(&szFileName[strlen(szFileName) - 4], ".n64") == 0 ) { gROMLength = file_info.uncompressed_size; /* get size of ROM */ /* pad with zeros to fill the displacement */ if(((gROMLength & 0xFFFF)) == 0) gAllocationLength = gROMLength; else gAllocationLength = gROMLength + (0x10000 - (gROMLength & 0xFFFF)); if(unzOpenCurrentFile(fp) == UNZ_OK) { uint64 i; InitVirtualRomMemory(gAllocationLength); InitMemoryLookupTables(); InitTLB(); Is_Reading_Rom_File = TRUE; To_Stop_Reading_Rom_File = FALSE; sprintf(generalmessage, "%s [%s] ", TranslateStringByString("Loading"), szFileName); SetStatusBarText(0, generalmessage); for(i = 0; i < gROMLength && To_Stop_Reading_Rom_File == FALSE; i += 65536) /* for( i=0; i<gROMLength; i+=65536) */ { WindowMsgLoop(); if(To_Stop_Reading_Rom_File == TRUE) { CloseROM(); To_Stop_Reading_Rom_File = FALSE; Is_Reading_Rom_File = FALSE; unzClose(fp); return FALSE; } /* fread(gMS_ROM_Image+i, sizeof(uint8), 65536, fp); */ if(unzReadCurrentFile(fp, gMS_ROM_Image + i, sizeof(uint8) * 65536) == 65536) { sprintf(generalmessage, "%s [%s] %d%%", TranslateStringByString("Loading"), szFileName, i * 100 / gROMLength); SetStatusBarText(0, generalmessage); } else if(unzReadCurrentFile(fp, gMS_ROM_Image + i, 1) == 0) { sprintf(generalmessage, "%s [%s] %d%%", TranslateStringByString("Loading"), szFileName, i * 100 / gROMLength); SetStatusBarText(0, generalmessage); } else { DisplayError("File could not be read. gROMLength = %08X\n", gROMLength); CloseROM(); unzCloseCurrentFile(fp); unzClose(fp); Set_Ready_Message(); Is_Reading_Rom_File = FALSE; return FALSE; } } ByteSwap(gAllocationLength, gMS_ROM_Image); memcpy((uint8 *) &rominfo.validation, gMS_ROM_Image, 0x40); SwapRomHeader((uint8 *) &rominfo.validation); /* Copy boot code to SP_DMEM */ memcpy((uint8 *) &SP_DMEM, gMS_ROM_Image, 0x1000); memcpy(rominfo.name, gMS_ROM_Image + 0x20, 20); SwapRomName(rominfo.name); Set_Ready_Message(); unzCloseCurrentFile(fp); unzClose(fp); Is_Reading_Rom_File = FALSE; return TRUE; } else { DisplayError("File could not be read: CRC Error in zip."); unzClose(fp); return FALSE; } } } else { DisplayError("File could not unzipped."); unzClose(fp); return FALSE; } } while(unzGoToNextFile(fp) == UNZ_OK); } unzClose(fp); } return FALSE; }
void format_profiler_result_msg(char *msg) { uint64 totaltimer = 0; int i; for(i = 0; i < MAX_PROF; i++) { totaltimer += profiler_timer_count[i]; } if(totaltimer == 0) totaltimer = 1; if( Kaillera_Is_Running ) { sprintf ( msg, "%s:%2.1f%% %s:%2.1f%% %s:%2.1f%% %s:%2.1f%% %s:%2.1f%% %s:%2.1f%% %s: %2.1f%%", TranslateStringByString("core"), (profiler_timer_count[R4300I_PROF] * 100.0f / totaltimer), TranslateStringByString("video"), (profiler_timer_count[VIDEO_PROF] * 100.0f / totaltimer), TranslateStringByString("audio"), (profiler_timer_count[AUDIO_PROF] * 100.0f / totaltimer), TranslateStringByString("compiler"), (profiler_timer_count[COMPILER_PROF] * 100.0f / totaltimer), TranslateStringByString("idle"), (profiler_timer_count[CPU_IDLE_PROF] * 100.0f / totaltimer), TranslateStringByString("netplay"), (profiler_timer_count[NETPLAY_PROF] * 100.0f / totaltimer), TranslateStringByString("kaillera"), (profiler_timer_count[KAILLERA_PROF] * 100.0f / totaltimer) ); } else { sprintf ( msg, "%s:%2.1f%% %s:%2.1f%% %s:%2.1f%% %s:%2.1f%% %s:%2.1f%%", TranslateStringByString("core"), (profiler_timer_count[R4300I_PROF] * 100.0f / totaltimer), TranslateStringByString("video"), (profiler_timer_count[VIDEO_PROF] * 100.0f / totaltimer), TranslateStringByString("audio"), (profiler_timer_count[AUDIO_PROF] * 100.0f / totaltimer), TranslateStringByString("compiler"), (profiler_timer_count[COMPILER_PROF] * 100.0f / totaltimer), TranslateStringByString("idle"), (profiler_timer_count[CPU_IDLE_PROF] * 100.0f / totaltimer) ); } cpuIdlePercentageIdx++; cpuIdlePercentageIdx %= 4; cpuIdlePercentages[cpuIdlePercentageIdx] = (uint32)(((double)(__int64)profiler_timer_count[CPU_IDLE_PROF] * 100.0 / (double)(__int64)totaltimer)+0.5); }
BOOL ReadRomData(char *rompath) { /*~~~~~~~~~~~~~~~~~~~~~~~*/ FILE *fp; unsigned long gROMLength; /* size in bytes of the ROM */ /*~~~~~~~~~~~~~~~~~~~~~~~*/ if(stricmp(&rompath[strlen(rompath) - 4], ".zip") == 0) { return ReadZippedRomData(rompath); } fp = fopen(rompath, "rb"); if(fp == NULL) { MessageBox ( gui.hwnd1964main, TranslateStringByString("Error opening this file. Please refresh the ROM list."), TranslateStringByString("Error"), MB_ICONINFORMATION ); return FALSE; } rewind(fp); fseek(fp, 0, SEEK_END); gROMLength = ftell(fp); /* pad with zeros to fill the displacement */ if(((gROMLength & 0xFFFF)) == 0) gAllocationLength = gROMLength; else gAllocationLength = gROMLength + (0x10000 - (gROMLength & 0xFFFF)); fseek(fp, 0, SEEK_SET); /* set pointer to beginning of file */ if(fp != NULL) { uint64 i; InitVirtualRomMemory(gAllocationLength); InitMemoryLookupTables(); InitTLB(); Is_Reading_Rom_File = TRUE; To_Stop_Reading_Rom_File = FALSE; for(i = 0; i < gROMLength && To_Stop_Reading_Rom_File == FALSE; i += 65536) { WindowMsgLoop(); if(To_Stop_Reading_Rom_File == TRUE) { CloseROM(); To_Stop_Reading_Rom_File = FALSE; Is_Reading_Rom_File = FALSE; fclose(fp); return FALSE; } fread(gMS_ROM_Image + i, sizeof(uint8), 65536, fp); { /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ char drive[_MAX_DRIVE], dir[_MAX_DIR]; char fname[_MAX_FNAME], ext[_MAX_EXT]; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ _splitpath(rompath, drive, dir, fname, ext); strcat(fname, ext); sprintf(generalmessage, "%s [%s] %d%%", TranslateStringByString("Loading"), fname, i * 100 / gROMLength); } SetStatusBarText(0, generalmessage); } Set_Ready_Message(); Is_Reading_Rom_File = FALSE; ByteSwap(gAllocationLength, gMS_ROM_Image); memcpy((uint8 *) &rominfo.validation, gMS_ROM_Image, 0x40); SwapRomHeader((uint8 *) &rominfo.validation); /* Copy boot code to SP_DMEM */ memcpy((uint8 *) &SP_DMEM, gMS_ROM_Image, 0x1000); memcpy(rominfo.name, gMS_ROM_Image + 0x20, 20); SwapRomName(rominfo.name); } else { MessageBox(0, TranslateStringByString("File could not be opened."), TranslateStringByString("Error"), 0); return FALSE; } fclose(fp); return TRUE; }
void ProcessToolTips(LPARAM lParam) { LPTOOLTIPTEXT lpttt; char str[256]; lpttt = (LPTOOLTIPTEXT) lParam; lpttt->hinst = gui.hInst; // Specify the resource identifier of the descriptive // text for the given button. switch (lpttt->hdr.idFrom) { case ID_BUTTON_OPEN_ROM: LoadString(gui.hInst, ID_BUTTON_OPEN_ROM, str, 256); break; case ID_BUTTON_PLAY: LoadString(gui.hInst, ID_BUTTON_PLAY, str, 256); break; case ID_BUTTON_PAUSE: LoadString(gui.hInst, ID_BUTTON_PAUSE, str, 256); break; case ID_BUTTON_STOP: LoadString(gui.hInst, ID_BUTTON_STOP, str, 256); break; case ID_BUTTON_RESET: LoadString(gui.hInst, ID_BUTTON_RESET, str, 256); break; case ID_BUTTON_SETUP_PLUGINS: LoadString(gui.hInst, ID_BUTTON_SETUP_PLUGINS, str, 256); break; case ID_BUTTON_ROM_PROPERTIES: LoadString(gui.hInst, ID_BUTTON_ROM_PROPERTIES, str, 256); break; case ID_BUTTON_HELP: LoadString(gui.hInst, ID_BUTTON_HELP, str, 256); break; case ID_BUTTON_HOME_PAGE: LoadString(gui.hInst, ID_BUTTON_HOME_PAGE, str, 256); break; case ID_BUTTON_FULL_SCREEN: LoadString(gui.hInst, ID_BUTTON_FULL_SCREEN, str, 256); break; case ID_BUTTON_FRAMESKIP: LoadString(gui.hInst, ID_BUTTON_FRAMESKIP, str, 256); break; case ID_BUTTON_SYNC_SPEED: LoadString(gui.hInst, ID_BUTTON_SYNC_SPEED, str, 256); break; case ID_BUTTON_AUTO_CF: LoadString(gui.hInst, ID_BUTTON_AUTO_CF, str, 256); break; default: return; } memset(lpttt->szText,0,80); strncpy(lpttt->szText, TranslateStringByString(str), 79); }