static std::string GenerateMPSString(uint32 mps, bool ctlr_string = false) { char tmpbuf[256]; tmpbuf[0] = 0; if(!mps) { if(!ctlr_string) trio_snprintf(tmpbuf, sizeof(tmpbuf), _("a lurker")); } else trio_snprintf(tmpbuf, sizeof(tmpbuf), ("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s"), ctlr_string ? ((mps == round_up_pow2(mps)) ? _("controller") : _("controllers")) : ((mps == round_up_pow2(mps)) ? _("player") : _("players")), (mps & 0x0001) ? " 1" : "", (mps & 0x0002) ? " 2" : "", (mps & 0x0004) ? " 3" : "", (mps & 0x0008) ? " 4" : "", (mps & 0x0010) ? " 5" : "", (mps & 0x0020) ? " 6" : "", (mps & 0x0040) ? " 7" : "", (mps & 0x0080) ? " 8" : "", (mps & 0x0100) ? " 9" : "", (mps & 0x0200) ? " 10" : "", (mps & 0x0400) ? " 11" : "", (mps & 0x0800) ? " 12" : "", (mps & 0x1000) ? " 13" : "", (mps & 0x2000) ? " 14" : "", (mps & 0x4000) ? " 15" : "", (mps & 0x8000) ? " 16" : ""); return(std::string(tmpbuf)); }
std::vector<BranchTraceResult> VBDBG_GetBranchTrace(void) { BranchTraceResult tmp; std::vector<BranchTraceResult> ret; for(int x = 0; x < NUMBT; x++) { const BTEntry *bt = &BTEntries[(x + BTIndex) % NUMBT]; if(!bt->valid) continue; tmp.count = bt->branch_count; trio_snprintf(tmp.from, sizeof(tmp.from), "%08x", bt->from); trio_snprintf(tmp.to, sizeof(tmp.to), "%08x", bt->to); tmp.code[0] = 0; if(bt->ecode >= 0xFFA0 && bt->ecode <= 0xFFBF) // TRAP { trio_snprintf(tmp.code, sizeof(tmp.code), "TRAP"); } else if(bt->ecode >= 0xFE00 && bt->ecode <= 0xFEFF) { trio_snprintf(tmp.code, sizeof(tmp.code), "INT%d", (bt->ecode >> 4) & 0xF); } else switch(bt->ecode)
int benchmark (void) { char output[50]; trio_snprintf(output, 50, "%d", 123); trio_snprintf(output, 50, "%ld", 123); trio_snprintf(output, 50, "%5d", 123); trio_snprintf(output, 50, "%05x", 123); trio_snprintf(output, 50, "%*d", 5, 10); return 0; }
// Call this function from the game thread void LogDebugger_Draw(MDFN_Surface *surface, const MDFN_Rect *rect, const MDFN_Rect *screen_rect) { if(!IsActive) return; // // // const MDFN_PixelFormat pf_cache = surface->format; const uint32 lifecolors[4] = { pf_cache.MakeColor(0xe0, 0xd0, 0xd0, 0xFF), pf_cache.MakeColor(0xd0, 0xe0, 0xd0, 0xFF), pf_cache.MakeColor(0xd0, 0xd0, 0xEF, 0xFF), pf_cache.MakeColor(0xd4, 0xd4, 0xd4, 0xFF) }; int32 y = 0; char logmessage[256]; trio_snprintf(logmessage, sizeof(logmessage), "%s (%d messages)", LoggingActive ? "Logging Enabled" : "Logging Disabled", (int)WhichLog->entries.size()); DrawText(surface, 0, y, logmessage, pf_cache.MakeColor(0x20, 0xFF, 0x20, 0xFF), MDFN_FONT_6x13_12x13, rect->w); y += 13; std::map<std::string, LogInstance>::iterator dl_iter; int32 groups_x = 0; for(dl_iter = NeoDeathLog.begin(); dl_iter != NeoDeathLog.end(); dl_iter++) { uint32 group_color = pf_cache.MakeColor(0x80, 0x80, 0x80, 0xFF); char group_string[256]; trio_snprintf(group_string, 256, "%s(%d)", dl_iter->first.c_str(), (int)dl_iter->second.entries.size()); if(&dl_iter->second == WhichLog) group_color = pf_cache.MakeColor(0xFF, 0x80, 0x80, 0xFF); groups_x += 6 + DrawText(surface, groups_x, y, group_string, group_color, MDFN_FONT_6x13_12x13); } y += 13; for(uint32 i = WhichLog->LogScroll; i < (WhichLog->LogScroll + 32) && i < WhichLog->entries.size(); i++) { int32 type_x = 0; char tmpbuf[64]; trio_snprintf(tmpbuf, 64, "%d", i); type_x = DrawText(surface, type_x, y, tmpbuf, pf_cache.MakeColor(0x80, 0x80, 0xD0, 0xFF), MDFN_FONT_5x7); type_x += 1; type_x += DrawText(surface, type_x, y, WhichLog->entries[i].type, pf_cache.MakeColor(0xFF, 0x40, 0x40, 0xFF), MDFN_FONT_6x13_12x13); type_x += 5; DrawText(surface, type_x, y, WhichLog->entries[i].text, lifecolors[i & 3], MDFN_FONT_6x13_12x13); y += 13; } }
void InputDevice_Gamepad::StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix) { SFORMAT StateRegs[] = { SFVAR(dtr), SFARRAY(buttons, sizeof(buttons)), SFVAR(command_phase), SFVAR(bitpos), SFVAR(receive_buffer), SFVAR(command), SFARRAY(transmit_buffer, sizeof(transmit_buffer)), SFVAR(transmit_pos), SFVAR(transmit_count), SFEND }; char section_name[32]; trio_snprintf(section_name, sizeof(section_name), "%s_Gamepad", sname_prefix); if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, section_name, true) && load) Power(); else if(load) { if((transmit_pos + transmit_count) > sizeof(transmit_buffer)) { transmit_pos = 0; transmit_count = 0; } } }
void BitDump(const char* tag, int level, const BYTE* buffer, UINT32 length, UINT32 flags) { DWORD i; int nbits; const char* str; const char** strs; char pbuffer[64 * 8 + 1]; size_t pos = 0; strs = (flags & BITDUMP_MSB_FIRST) ? BYTE_BIT_STRINGS_MSB : BYTE_BIT_STRINGS_LSB; for (i = 0; i < length; i += 8) { str = strs[buffer[i / 8]]; nbits = (length - i) > 8 ? 8 : (length - i); pos += trio_snprintf(&pbuffer[pos], length - pos, "%.*s ", nbits, str); if ((i % 64) == 0) { pos = 0; WLog_LVL(tag, level, "%s", pbuffer); } } if (i) WLog_LVL(tag, level, "%s ", pbuffer); }
bool MDFNI_SetSettingUI(const char *name, uint64 value) { char tmpstr[32]; trio_snprintf(tmpstr, 32, "%llu", value); return(MDFNI_SetSetting(name, tmpstr, FALSE)); }
uint32 TIMER_GetRegister(const unsigned int id, char *special, const uint32 special_len) { uint32 ret = 0xDEADBEEF; switch(id) { case TIMER_GSREG_TCR: ret = TimerControl; if(special) trio_snprintf(special, special_len, "TEnable: %d, TimZInt: %d, TClkSel: %d(%.3f KHz)", (int)(bool)(ret & TC_TENABLE), (int)(bool)(ret & TC_TIMZINT), (int)(bool)(ret & TC_TCLKSEL), (double)VB_MASTER_CLOCK / ((ret & TC_TCLKSEL) ? 500 : 2000) / 1000 ); break; case TIMER_GSREG_DIVCOUNTER: ret = TimerDivider; break; case TIMER_GSREG_RELOAD_VALUE: ret = TimerReloadValue; break; case TIMER_GSREG_COUNTER: ret = TimerCounter; break; } return(ret); }
static int clistcallb(char *name, uint32 a, uint64 v, uint64 compare, int s, char type, unsigned int length, bool bigendian, void *data) { char tmp[512]; int ret; if(type == 'C') trio_snprintf(tmp, 512, "%s $%08x:%03lld:%03lld - %s",s?"*":" ",a,v,compare,name); else trio_snprintf(tmp, 512, "%s $%08x:%03lld - %s",s?"*":" ",a,v,name); if(type != 'R') tmp[2]='S'; ret = AddToList(tmp,lid); lid++; return(ret); }
char *msg_href(struct emailinfo *to_email, struct emailinfo *from_email, bool generate_markup) /* note: you probably have to make a copy of * the buffer returned before the next call to this function. */ { static char buffer[MAXFILELEN + 11]; char *ptr; ptr = msg_relpath(to_email, from_email); if (generate_markup) trio_snprintf(buffer, MAXFILELEN + 11, "<a href=\"%s\">", ptr); else trio_snprintf(buffer, MAXFILELEN + 11, "%s", ptr); return buffer; }
static std::vector<BranchTraceResult> GetBranchTrace(void) { BranchTraceResult tmp; std::vector<BranchTraceResult> ret; for(int x = 0; x < NUMBT; x++) { const BTEntry *bt = &BTEntries[(x + BTIndex) % NUMBT]; if(!bt->valid) continue; tmp.count = bt->branch_count; trio_snprintf(tmp.from, sizeof(tmp.from), "%04X", bt->from); trio_snprintf(tmp.to, sizeof(tmp.to), "%04X", bt->to); tmp.code[1] = 0; switch(bt->vector) { default: tmp.code[0] = 0; break; case 0xFFFE: tmp.code[0] = 'R'; // RESET break; case 0xFFFA: tmp.code[0] = 'T'; // TIMER break; case 0xFFF8: tmp.code[0] = '1'; // IRQ1 break; case 0xFFF6: tmp.code[0] = '2'; // IRQ2 break; } ret.push_back(tmp); } return(ret); }
char *msg_relpath(struct emailinfo *to_email, struct emailinfo *from_email) /* called by msg_href() : note: you probably have to make a copy of * the buffer returned before the next call to this function. */ { static char buffer[MAXFILELEN]; char *name; name = message_name(to_email); if (!from_email && to_email->subdir) trio_snprintf(buffer, MAXFILELEN, "%s%s.%s", to_email->subdir->subdir, name, set_htmlsuffix); else if (!to_email->subdir || to_email->subdir == from_email->subdir) trio_snprintf(buffer, MAXFILELEN, "%s.%s", name, set_htmlsuffix); else trio_snprintf(buffer, MAXFILELEN, "%s%s%s.%s", to_email->subdir->rel_path_to_top, to_email->subdir->subdir, name, set_htmlsuffix); return buffer; }
static uint32 SBoxDBG_GetRegister(const unsigned int id, char *special, const uint32 special_len) { uint32 value = 0xDEADBEEF; switch(id) { case GSREG_ADPCM_CTRL: value = sbox.ADPCMControl; if(special) { int tmp_freq = 32 / (1 << (value & 0x3)); trio_snprintf(special, special_len, "Frequency: ~%dKHz, Ch0 Interpolation: %s, Ch1 Interpolation: %s, Ch0 Reset: %d, Ch1 Reset: %d", tmp_freq, (value & 0x4) ? "On" : "Off", (value & 0x8) ? "On":"Off", (int)(bool)(value & 0x10), (int)(bool)(value & 0x20)); } break; case GSREG_ADPCM0_LVOL: value = sbox.ADPCMVolume[0][0]; break; case GSREG_ADPCM0_RVOL: value = sbox.ADPCMVolume[0][1]; break; case GSREG_ADPCM1_LVOL: value = sbox.ADPCMVolume[1][0]; break; case GSREG_ADPCM1_RVOL: value = sbox.ADPCMVolume[1][1]; break; case GSREG_CDDA_LVOL: value = sbox.CDDAVolume[0]; break; case GSREG_CDDA_RVOL: value = sbox.CDDAVolume[1]; break; case GSREG_ADPCM0_CUR: value = sbox.ADPCMPredictor[0] + 0x4000; break; case GSREG_ADPCM1_CUR: value = sbox.ADPCMPredictor[1] + 0x4000; break; default: value = pce_psg->GetRegister(id, special, special_len); break; } return(value); }
bool FXTIMER_GetRegister(const std::string &name, uint32 &value, std::string *special) { if(name == "TCTRL") { value = control; if(special) { char buf[256]; trio_snprintf(buf, 256, "Counting Enabled: %d, IRQ Enabled: %d, IRQ Asserted: %d", (int)(bool)(control & 2), (int)(bool)(control & 1), (int)(bool)(control & 4)); *special = std::string(buf); } return(TRUE); } else if(name == "TPRD") { value = period; if(special) { char buf[256]; trio_snprintf(buf, 256, "Effective Period: %d; 21477272 / %d = %fHz", EFF_PERIOD, EFF_PERIOD, (double)21477272 / (EFF_PERIOD)); *special = std::string(buf); } return(TRUE); } else if(name == "TCNTR") { value = counter; if(special) { //char buf[256]; //trio_snprintf(buf, 256, "Pad: %d, ??: %d, Timer: %d, Reset: %d", //*special = std::string(buf); } return(TRUE); } else return(FALSE); }
static int clistcallb(const MemoryPatch& patch, void *data) { char tmp[512]; int ret; if(!lid) { CHEAT_printf(" /---------------------------------------\\"); CHEAT_printf(" | Type | Affected Addr Range | Name \\"); CHEAT_printf(" |-----------------------------------------\\"); } if(patch.type == 'C' || patch.type == 'S') { trio_snprintf(tmp, 512, "%c %c | $%08x | %s", patch.status ? '*' : ' ', patch.type, patch.addr, patch.name.c_str()); //trio_snprintf(tmp, 512, "%s %c $%08x:%lld:%lld - %s", patch.status ? "*" : " ", patch.type, patch.addr, patch.val, patch.compare, patch.name.c_str()); } else { uint32 sa = patch.addr; uint32 ea = patch.addr + ((patch.mltpl_count - 1) * patch.mltpl_addr_inc) + (patch.length - 1); if(patch.mltpl_count == 0 || patch.length == 0) trio_snprintf(tmp, 512, "%c %c%s | | %s", patch.status ? '*' : ' ', patch.type, patch.conditions.size() ? "+CC" : " ", patch.name.c_str()); else { if(sa == ea) trio_snprintf(tmp, 512, "%c %c%s | $%08x | %s", patch.status ? '*' : ' ', patch.type, patch.conditions.size() ? "+CC" : " ", sa, patch.name.c_str()); else trio_snprintf(tmp, 512, "%c %c%s | $%08x-$%08x | %s", patch.status ? '*' : ' ', patch.type, patch.conditions.size() ? "+CC" : " ", sa, ea, patch.name.c_str()); } } ret = AddToList(tmp, lid); lid++; return(ret); }
void InputDevice_DualShock::StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix) { SFORMAT StateRegs[] = { SFVAR(cur_ana_button_state), SFVAR(prev_ana_button_state), SFVAR(combo_anatoggle_counter), SFVAR(da_rumble_compat), SFVAR(analog_mode), SFVAR(analog_mode_locked), SFVAR(mad_munchkins), SFARRAY(rumble_magic, sizeof(rumble_magic)), SFARRAY(rumble_param, sizeof(rumble_param)), SFVAR(dtr), SFARRAY(buttons, sizeof(buttons)), SFARRAY(&axes[0][0], sizeof(axes)), SFVAR(command_phase), SFVAR(bitpos), SFVAR(receive_buffer), SFVAR(command), SFARRAY(transmit_buffer, sizeof(transmit_buffer)), SFVAR(transmit_pos), SFVAR(transmit_count), SFEND }; char section_name[32]; trio_snprintf(section_name, sizeof(section_name), "%s_DualShock", sname_prefix); if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, section_name, true) && load) Power(); else if(load) { if(((uint64)transmit_pos + transmit_count) > sizeof(transmit_buffer)) { transmit_pos = 0; transmit_count = 0; } } }
void MDFNI_SaveState(const char *fname, const char *suffix, const MDFN_Surface *surface, const MDFN_Rect *DisplayRect, const MDFN_Rect *LineWidths) { if(!MDFNGameInfo->StateAction) return; if(MDFNnetplay && (MDFNGameInfo->SaveStateAltersState == true)) { char sb[256]; trio_snprintf(sb, sizeof(sb), _("Module %s is not compatible with manual state saving during netplay."), MDFNGameInfo->shortname); MDFND_NetplayText((const uint8*)sb, false); return; } MDFND_SetStateStatus(NULL); MDFNSS_Save(fname, suffix, surface, DisplayRect, LineWidths); }
void HuC_Close(void) { if(mcg) { for(unsigned i = 0; i < mcg->GetNVPDC(); i++) { uint32 nvs = mcg->GetNVSize(i); if(nvs) { char buf[32]; std::vector<uint8> tmp_buf; tmp_buf.resize(nvs); mcg->ReadNV(i, &tmp_buf[0], 0, tmp_buf.size()); trio_snprintf(buf, sizeof(buf), "mg%d", i); MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, buf).c_str(), 6, &tmp_buf[0], tmp_buf.size()); } } } if(IsPopulous) { if(PopRAM) { MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 6, PopRAM, 32768); } } else if(IsTsushin) { if(TsushinRAM) { MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 6, TsushinRAM, 32768); MDFN_free(TsushinRAM); TsushinRAM = NULL; } } else if(!BRAM_Disabled && IsBRAMUsed()) { MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav").c_str(), 0, SaveRAM, 2048); } Cleanup(); }
static uint32 GetRegister_CPU(const unsigned int id, char *special, const uint32 special_len) { uint32 value = 0xDEADBEEF; switch(id) { case CPU_GSREG_PC: value = X.PC; break; case CPU_GSREG_A: value = X.A; break; case CPU_GSREG_X: value = X.X; break; case CPU_GSREG_Y: value = X.Y; break; case CPU_GSREG_SP: value = X.S; break; case CPU_GSREG_P: value = X.P; if(special) { trio_snprintf(special, special_len, "N: %d, V: %d, D: %d, I: %d, Z: %d, C: %d", (int)(bool)(value & N_FLAG), (int)(bool)(value & V_FLAG), (int)(bool)(value & D_FLAG), (int)(bool)(value & I_FLAG), (int)(bool)(value & Z_FLAG), (int)(bool)(value & C_FLAG)); } break; case CPU_GSREG_TIMESTAMP: value = timestamp; break; } return(value); }
void MDFNI_SaveMovie(char *fname, const MDFN_Surface *surface, const MDFN_Rect *DisplayRect, const int32 *LineWidths) { gzFile fp; if(!MDFNGameInfo->StateAction) return; if(MDFNnetplay && (MDFNGameInfo->SaveStateAltersState == true)) { char sb[256]; trio_snprintf(sb, sizeof(sb), _("Module %s is not compatible with manual movie save starting/stopping during netplay."), MDFNGameInfo->shortname); MDFND_NetplayText((const uint8*)sb, false); return; } if(current < 0) /* Can't interrupt playback.*/ return; if(current > 0) /* Stop saving. */ { StopRecording(); return; } memset(&RewindBuffer, 0, sizeof(StateMem)); RewindBuffer.initial_malloc = 16; current = CurrentMovie; if(fname) fp = gzopen(fname, "wb3"); else { fp=gzopen(MDFN_MakeFName(MDFNMKF_MOVIE,CurrentMovie,0).c_str(),"wb3"); } if(!fp) return; MDFNSS_SaveFP(fp, surface, DisplayRect, LineWidths); gzseek(fp, 0, SEEK_END); gzflush(fp, Z_SYNC_FLUSH); // Flush output so that previews will still work right while // the movie is being recorded. Purely cosmetic. :) slots[current] = fp; current++; MDFN_DispMessage(_("Movie recording started.")); }
static int srescallb(uint32 a, uint64 last, uint64 current, void *data) { char tmp[256]; if(searchbytelen == 8) trio_snprintf(tmp, 256, "$%08x:%020llu:%020llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current); if(searchbytelen == 7) trio_snprintf(tmp, 256, "$%08x:%017llu:%017llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current); if(searchbytelen == 6) trio_snprintf(tmp, 256, "$%08x:%015llu:%015llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current); if(searchbytelen == 5) trio_snprintf(tmp, 256, "$%08x:%013llu:%013llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current); if(searchbytelen == 4) trio_snprintf(tmp, 256, "$%08x:%10u:%10u",(unsigned int)a,(unsigned int)last,(unsigned int)current); else if(searchbytelen == 3) trio_snprintf(tmp, 256, "$%08x:%08u:%08u",(unsigned int)a,(unsigned int)last,(unsigned int)current); else if(searchbytelen == 2) trio_snprintf(tmp, 256, "$%08x:%05u:%05u",(unsigned int)a,(unsigned int)last,(unsigned int)current); else if(searchbytelen == 1) trio_snprintf(tmp, 256, "$%08x:%03u:%03u",(unsigned int)a,(unsigned int)last,(unsigned int)current); else // > 4 trio_snprintf(tmp, 256, "$%08x:%020llu:%020llu",(unsigned int)a,(unsigned long long)last,(unsigned long long)current); return(AddToList(tmp,a)); }
static void BuildDynamicSetting(MDFNSetting *setting, const char *system_name, const char *name, uint32 flags, const char *description, MDFNSettingType type, const char *default_value, const char *minimum = NULL, const char *maximum = NULL, bool (*validate_func)(const char *name, const char *value) = NULL, void (*ChangeNotification)(const char *name) = NULL) { char setting_name[256]; memset(setting, 0, sizeof(MDFNSetting)); trio_snprintf(setting_name, 256, "%s.%s", system_name, name); setting->name = strdup(setting_name); setting->description = description; setting->type = type; setting->flags = flags; setting->default_value = default_value; setting->minimum = minimum; setting->maximum = maximum; setting->validate_func = validate_func; setting->ChangeNotification = ChangeNotification; }
void CalcFramerates(char *virtfps, char *drawnfps, char *blitfps, size_t maxlen) { uint32 curtime = SDL_GetTicks(); uint32 vt_frames_drawn = 0, dt_frames_drawn = 0, bt_frames_drawn = 0; uint32 vt_mintime, dt_mintime, bt_mintime; vt_mintime = dt_mintime = bt_mintime = curtime; for(int x = 0; x < 128; x++) { uint32 vt = VirtualTime[x]; uint32 dt = DrawnTime[x]; uint32 bt = BlittedTime[x]; if(vt >= (curtime - 1000)) { if(vt < vt_mintime) vt_mintime = vt; vt_frames_drawn++; } if(dt >= (curtime - 1000)) { if(dt < dt_mintime) dt_mintime = dt; dt_frames_drawn++; } if(bt >= (curtime - 1000)) { if(bt < bt_mintime) bt_mintime = bt; bt_frames_drawn++; } } if(curtime - vt_mintime) trio_snprintf(virtfps, maxlen, "%0.2f", (double)vt_frames_drawn * 1000 / (curtime - vt_mintime)); else trio_snprintf(virtfps, maxlen, "?"); if(curtime - dt_mintime) trio_snprintf(drawnfps, maxlen, "%0.2f", (double)dt_frames_drawn * 1000 / (curtime - dt_mintime)); else trio_snprintf(drawnfps, maxlen, "?"); if(curtime - bt_mintime) trio_snprintf(blitfps, maxlen, "%0.2f", (double)bt_frames_drawn * 1000 / (curtime - bt_mintime)); else trio_snprintf(blitfps, maxlen, "?"); }
void WSwanDBG_Disassemble(uint32 &a, uint32 SpecialA, char *text_buffer) { uint32 mis = MDFNGameInfo->Debugger->MaxInstructionSize; mis = 256; uint8 instr_buffer[mis]; uint32 ps = v30mz_get_reg(NEC_PS); int consumed; for(unsigned int i = 0; i < mis; i++) { instr_buffer[i] = WSwan_readmem20(((ps << 4) + a + i) & 0xFFFFF); } consumed = zedis.disasm(0x0000, a, instr_buffer, text_buffer); int x; for(x = strlen(text_buffer); x < 40; x++) text_buffer[x] = ' '; text_buffer[x] = 0; for(int i = 0; i < consumed; i++) { char tmp[16]; trio_snprintf(tmp, 16, " %02x", instr_buffer[i]); strcat(text_buffer, tmp); } for(int i = 1; i < consumed; i++) if(((a + i) & 0xFFFF) == SpecialA) { a = SpecialA; strcpy(text_buffer, "BORKBORK"); return; } a = (a + consumed) & 0xFFFF; }
int CheatLoop(void *arg) { std::vector<MENU> NewCheatsMenu; std::vector<MENU> MainMenu; NewCheatsMenu.push_back( MENU(_("Add Cheat"), AddCheat, NULL) ); NewCheatsMenu.push_back( MENU(_("Reset Search"), ResetSearch, NULL) ); NewCheatsMenu.push_back( MENU(_("Do Search"), DoSearch, NULL) ); NewCheatsMenu.push_back( MENU(_("Set Original to Current"), SetOC, NULL) ); NewCheatsMenu.push_back( MENU(_("Unhide Excluded"), UnhideEx, NULL) ); NewCheatsMenu.push_back( MENU(_("Show Results"), ShowRes, NULL) ); MainMenu.push_back( MENU(_("List Cheats"), ListCheats, NULL) ); MainMenu.push_back( MENU(_("Cheat Search..."), NULL, &NewCheatsMenu) ); if(CurGame->CheatFormatInfo != NULL) { for(unsigned i = 0; i < CurGame->CheatFormatInfo->NumFormats; i++) { char buf[256]; trio_snprintf(buf, 256, _("Add %s Code"), CurGame->CheatFormatInfo->Formats[i].FullName); MainMenu.push_back( MENU(buf, AddCodeCheat, NULL, (void*)&CurGame->CheatFormatInfo->Formats[i]) ); } } try { DoMenu(MainMenu, 1); } catch(...) { } return(1); }
struct emailsubdir *msg_subdir(int msgnum, time_t date) { static struct emailsubdir *last_subdir; static struct emailsubdir *subdir; char s[DATESTRLEN]; char desc_buf[DATESTRLEN]; char *desc = NULL; char *fmt = set_describe_folder; if (set_msgsperfolder > 0) { int subdir_no = msgnum / set_msgsperfolder; trio_snprintf(s, DATESTRLEN, "%d/", subdir_no); if (!fmt) fmt = "%d"; desc = msgsperfolder_label(fmt, subdir_no); } else if (set_folder_by_date) { strftime(s, DATESTRLEN - 1, set_folder_by_date, localtime(&date)); if (!fmt) fmt = set_folder_by_date; strftime(desc_buf, DATESTRLEN, fmt, localtime(&date)); desc = strsav(desc_buf); if (s[0] && s[strlen(s) - 1] != '/') strcat(s, "/"); } else return NULL; subdir = last_subdir; if (!last_subdir || strcmp(s, last_subdir->subdir)) { subdir = new_subdir(s, last_subdir, desc, date); if (set_increment != -1) last_subdir = subdir; } if (desc) free(desc); return subdir; }
void HuC_SaveNV(void) { if(mcg) { for(unsigned i = 0; i < mcg->GetNVPDC(); i++) { uint32 nvs = mcg->GetNVSize(i); if(nvs) { char buf[32]; trio_snprintf(buf, sizeof(buf), "mg%d", i); MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, buf), mcg->ReadNV(i), nvs); } } } if(IsPopulous) { if(PopRAM) { MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), PopRAM, 32768); } } else if(IsTsushin) { if(TsushinRAM) { MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), TsushinRAM, 32768); } } else if(!BRAM_Disabled && IsBRAMUsed()) { MDFN_DumpToFile(MDFN_MakeFName(MDFNMKF_SAV, 0, "sav"), SaveRAM, 2048); } }
std::vector<BranchTraceResult> PCFXDBG_GetBranchTrace(void) { BranchTraceResult tmp; std::vector<BranchTraceResult> ret; for(int x = 0; x < NUMBT; x++) { const BTEntry *bt = &BTEntries[(x + BTIndex) % NUMBT]; tmp.count = bt->branch_count; trio_snprintf(tmp.from, sizeof(tmp.from), "%08x", bt->from); trio_snprintf(tmp.to, sizeof(tmp.to), "%08x", bt->to); tmp.code[0] = 0; switch(bt->ecode) { case 0: break; default: trio_snprintf(tmp.code, sizeof(tmp.code), "e"); break; case 0xFFF0: // Reset trio_snprintf(tmp.code, sizeof(tmp.code), "R"); break; case 0xFFD0: // NMI trio_snprintf(tmp.code, sizeof(tmp.code), "NMI"); break; case 0xFFC0: // Address trap trio_snprintf(tmp.code, sizeof(tmp.code), "ADTR"); break; case 0xFFA0 ... 0xFFBF: // TRAP trio_snprintf(tmp.code, sizeof(tmp.code), "TRAP"); break; case 0xFF90: // Illegal/invalid instruction code trio_snprintf(tmp.code, sizeof(tmp.code), "ILL"); break; case 0xFF80: // Zero division trio_snprintf(tmp.code, sizeof(tmp.code), "ZD"); break; case 0xFF70: trio_snprintf(tmp.code, sizeof(tmp.code), "FIV"); // FIV break; case 0xFF68: trio_snprintf(tmp.code, sizeof(tmp.code), "FZD"); // FZD break; case 0xFF64: trio_snprintf(tmp.code, sizeof(tmp.code), "FOV"); // FOV break; case 0xFF62: trio_snprintf(tmp.code, sizeof(tmp.code), "FUD"); // FUD break; case 0xFF61: trio_snprintf(tmp.code, sizeof(tmp.code), "FPR"); // FPR break; case 0xFF60: trio_snprintf(tmp.code, sizeof(tmp.code), "FRO"); // FRO break; case 0xFE00 ... 0xFEFF: trio_snprintf(tmp.code, sizeof(tmp.code), "INT%d", (bt->ecode >> 4) & 0xF); break; } ret.push_back(tmp); } return(ret); }
static INLINE bool MDFN_DumpToFileReal(const char *filename, int compress, const std::vector<PtrLengthPair> &pearpairs) { if(MDFN_GetSettingB("filesys.disablesavegz")) compress = 0; if(compress) { char mode[64]; gzFile gp; trio_snprintf(mode, 64, "wb%d", compress); gp = gzopen(filename, mode); if(!gp) { ErrnoHolder ene(errno); MDFN_PrintError(_("Error opening \"%s\": %s"), filename, ene.StrError()); return(0); } for(unsigned int i = 0; i < pearpairs.size(); i++) { const void *data = pearpairs[i].GetData(); const int64 length = pearpairs[i].GetLength(); if(gzwrite(gp, data, length) != length) { int errnum; MDFN_PrintError(_("Error writing to \"%s\": %s"), filename, gzerror(gp, &errnum)); gzclose(gp); return(0); } } if(gzclose(gp) != Z_OK) // FIXME: Huhm, how should we handle this? { MDFN_PrintError(_("Error closing \"%s\""), filename); return(0); } } else { FILE *fp = fopen(filename, "wb"); if(!fp) { ErrnoHolder ene(errno); MDFN_PrintError(_("Error opening \"%s\": %s"), filename, ene.StrError()); return(0); } for(unsigned int i = 0; i < pearpairs.size(); i++) { const void *data = pearpairs[i].GetData(); const uint64 length = pearpairs[i].GetLength(); if(fwrite(data, 1, length, fp) != length) { ErrnoHolder ene(errno); MDFN_PrintError(_("Error writing to \"%s\": %s"), filename, ene.StrError()); fclose(fp); return(0); } } if(fclose(fp) == EOF) { ErrnoHolder ene(errno); MDFN_PrintError(_("Error closing \"%s\": %s"), filename, ene.StrError()); return(0); } } return(1); }
MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name) { MDFNFILE GameFile; struct stat stat_buf; std::vector<FileExtensionSpecStruct> valid_iae; if(strlen(name) > 4 && (!strcasecmp(name + strlen(name) - 4, ".cue") || !strcasecmp(name + strlen(name) - 4, ".toc") || !strcasecmp(name + strlen(name) - 4, ".m3u"))) { return(MDFNI_LoadCD(force_module, name)); } if(!stat(name, &stat_buf) && !S_ISREG(stat_buf.st_mode)) { return(MDFNI_LoadCD(force_module, name)); } MDFNI_CloseGame(); LastSoundMultiplier = 1; MDFNGameInfo = NULL; MDFN_printf(_("Loading %s...\n"),name); MDFN_indent(1); GetFileBase(name); // Construct a NULL-delimited list of known file extensions for MDFN_fopen() for(unsigned int i = 0; i < MDFNSystems.size(); i++) { const FileExtensionSpecStruct *curexts = MDFNSystems[i]->FileExtensions; // If we're forcing a module, only look for extensions corresponding to that module if(force_module && strcmp(MDFNSystems[i]->shortname, force_module)) continue; if(curexts) while(curexts->extension && curexts->description) { valid_iae.push_back(*curexts); curexts++; } } { FileExtensionSpecStruct tmpext = { NULL, NULL }; valid_iae.push_back(tmpext); } if(!GameFile.Open(name, &valid_iae[0], _("game"))) { MDFNGameInfo = NULL; return 0; } if(!LoadIPS(GameFile, MDFN_MakeFName(MDFNMKF_IPS, 0, 0).c_str())) { MDFNGameInfo = NULL; GameFile.Close(); return(0); } MDFNGameInfo = NULL; for(std::list<MDFNGI *>::iterator it = MDFNSystemsPrio.begin(); it != MDFNSystemsPrio.end(); it++) //_unsigned int x = 0; x < MDFNSystems.size(); x++) { char tmpstr[256]; trio_snprintf(tmpstr, 256, "%s.enable", (*it)->shortname); if(force_module) { if(!strcmp(force_module, (*it)->shortname)) { if(!(*it)->Load) { GameFile.Close(); if((*it)->LoadCD) MDFN_PrintError(_("Specified system only supports CD(physical, or image files, such as *.cue and *.toc) loading.")); else MDFN_PrintError(_("Specified system does not support normal file loading.")); MDFN_indent(-1); MDFNGameInfo = NULL; return 0; } MDFNGameInfo = *it; break; } } else { // Is module enabled? if(!MDFN_GetSettingB(tmpstr)) continue; if(!(*it)->Load || !(*it)->TestMagic) continue; if((*it)->TestMagic(name, &GameFile)) { MDFNGameInfo = *it; break; } } } if(!MDFNGameInfo) { GameFile.Close(); if(force_module) MDFN_PrintError(_("Unrecognized system \"%s\"!"), force_module); else MDFN_PrintError(_("Unrecognized file format. Sorry.")); MDFN_indent(-1); MDFNGameInfo = NULL; return 0; } MDFN_printf(_("Using module: %s(%s)\n\n"), MDFNGameInfo->shortname, MDFNGameInfo->fullname); MDFN_indent(1); assert(MDFNGameInfo->soundchan != 0); MDFNGameInfo->soundrate = 0; MDFNGameInfo->name = NULL; MDFNGameInfo->rotated = 0; if(MDFNGameInfo->Load(name, &GameFile) <= 0) { GameFile.Close(); MDFN_indent(-2); MDFNGameInfo = NULL; return(0); } if(MDFNGameInfo->GameType != GMT_PLAYER) { MDFN_LoadGameCheats(NULL); MDFNMP_InstallReadPatches(); } MDFNI_SetLayerEnableMask(~0ULL); #ifdef WANT_DEBUGGER MDFNDBG_PostGameLoad(); #endif MDFNSS_CheckStates(); MDFNMOV_CheckMovies(); MDFN_ResetMessages(); // Save state, status messages, etc. MDFN_indent(-2); if(!MDFNGameInfo->name) { unsigned int x; char *tmp; MDFNGameInfo->name = (UTF8 *)strdup(GetFNComponent(name)); for(x=0; x<strlen((char *)MDFNGameInfo->name); x++) { if(MDFNGameInfo->name[x] == '_') MDFNGameInfo->name[x] = ' '; } if((tmp = strrchr((char *)MDFNGameInfo->name, '.'))) *tmp = 0; } PrevInterlaced = false; deint.ClearState(); TBlur_Init(); MDFN_StateEvilBegin(); last_sound_rate = -1; memset(&last_pixel_format, 0, sizeof(MDFN_PixelFormat)); return(MDFNGameInfo); }