Esempio n. 1
0
void CFlashram::DmaFromFlashram(uint8_t * dest, int32_t StartOffset, int32_t len)
{
    uint8_t FlipBuffer[0x10000];

    switch (m_FlashFlag)
    {
    case FLASHRAM_MODE_READ:
        if (!m_File.IsOpen() && !LoadFlashram())
        {
            return;
        }
        if (len > sizeof(FlipBuffer))
        {
            if (bHaveDebugger())
            {
                g_Notify->DisplayError(stdstr_f("%s: DmaFromFlashram FlipBuffer to small (len: %d)", __FUNCTION__, len).c_str());
            }
            len = sizeof(FlipBuffer);
        }
        if ((len & 3) != 0)
        {
            if (bHaveDebugger())
            {
                g_Notify->DisplayError(stdstr_f("%s: Unaligned flash ram read ???", __FUNCTION__).c_str());
            }
            return;
        }
        memset(FlipBuffer, 0, sizeof(FlipBuffer));
        StartOffset = StartOffset << 1;
        m_File.Seek(StartOffset, CFile::begin);
        m_File.Read(FlipBuffer, len);

        for (int32_t count = m_File.GetLength(); count < len; count++)
        {
            FlipBuffer[count] = 0xFF;
        }

        for (int32_t count = 0; count < len; count += 4)
        {
            *(uint32_t *)(dest + count) = *(uint32_t *)&FlipBuffer[count];
        }
        break;
    case FLASHRAM_MODE_STATUS:
        if (StartOffset != 0 && len != 8)
        {
            if (bHaveDebugger())
            {
                g_Notify->DisplayError(stdstr_f("%s: Reading m_FlashStatus not being handled correctly\nStart: %X len: %X", __FUNCTION__, StartOffset, len).c_str());
            }
        }
        *((uint32_t *)(dest)+0) = (uint32_t)((m_FlashStatus >> 32) & 0xFFFFFFFF);
        *((uint32_t *)(dest)+1) = (uint32_t)(m_FlashStatus & 0xFFFFFFFF);
        break;
    default:
        if (bHaveDebugger())
        {
            g_Notify->DisplayError(stdstr_f("%s: Start: %X, Offset: %X len: %X", __FUNCTION__, dest - g_MMU->Rdram(), StartOffset, len).c_str());
        }
    }
}
Esempio n. 2
0
void UpdateScreenResolution(int ScreenWidth, int ScreenHeight)
{
    WriteTrace(TraceResolution, TraceError, "aspectmode: %d", g_settings->aspectmode());
    g_resolutions.clear();
    switch (g_settings->aspectmode())
    {
    case CSettings::Aspect_4x3:
        g_resolutions.push_back(ResolutionInfo(stdstr_f("%dx%d", ScreenHeight * 4 / 3, ScreenHeight).c_str(), ScreenHeight * 4 / 3, ScreenHeight, 0, true));
        g_resolutions.push_back(ResolutionInfo("960x720", 960, 720, 0, false));
        g_resolutions.push_back(ResolutionInfo("800x600", 800, 600, 0, false));
        g_resolutions.push_back(ResolutionInfo("640x480", 640, 480, 0, false));
        g_resolutions.push_back(ResolutionInfo("480x360", 480, 360, 0, false));
        g_resolutions.push_back(ResolutionInfo("320x240", 320, 240, 0, false));
        break;
    case CSettings::Aspect_16x9:
        g_resolutions.push_back(ResolutionInfo(stdstr_f("%dx%d", ScreenHeight * 16 / 9, ScreenHeight).c_str(), ScreenHeight * 16 / 9, ScreenHeight, 0, true));
        g_resolutions.push_back(ResolutionInfo("1280x720", 1280, 720, 0, false));
        g_resolutions.push_back(ResolutionInfo("1067x600", 1067, 600, 0, false));
        g_resolutions.push_back(ResolutionInfo("854x480", 854, 480, 0, false));
        g_resolutions.push_back(ResolutionInfo("640x360", 640, 360, 0, false));
        g_resolutions.push_back(ResolutionInfo("426x240", 426, 240, 0, false));
        break;
    case CSettings::Aspect_Original:
        g_resolutions.push_back(ResolutionInfo("Original", ScreenWidth, ScreenHeight, 0, true));
        break;
    case CSettings::Aspect_Stretch:
    default: //stretch
        g_resolutions.push_back(ResolutionInfo(stdstr_f("%dx%d", ScreenWidth, ScreenHeight).c_str(), ScreenWidth, ScreenHeight, 0, true));
        break;
    }
}
Esempio n. 3
0
bool CPlugins::CopyPlugins(const stdstr & DstDir) const
{
    //Copy GFX Plugin
    CPath srcGfxPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
    CPath dstGfxPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Gfx).c_str());
    dstGfxPlugin.SetName(stdstr_f("%s-copy", dstGfxPlugin.GetName().c_str()).c_str());

    if (!dstGfxPlugin.DirectoryExists())
    {
        dstGfxPlugin.DirectoryCreate();
    }
    if (!srcGfxPlugin.CopyTo(dstGfxPlugin))
    {
        WriteTrace(TracePlugins, TraceError, "failed to copy %s to %s", (const char *)srcGfxPlugin, (const char *)dstGfxPlugin);
        return false;
    }

    //Copy m_Audio Plugin
    CPath srcAudioPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
    CPath dstAudioPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Audio).c_str());
    dstAudioPlugin.SetName(stdstr_f("%s-copy", dstAudioPlugin.GetName().c_str()).c_str());
    if (!dstAudioPlugin.DirectoryExists())
    {
        dstAudioPlugin.DirectoryCreate();
    }
    if (!srcAudioPlugin.CopyTo(dstAudioPlugin))
    {
        return false;
    }
    //Copy RSP Plugin
    CPath srcRSPPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
    CPath dstRSPPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_RSP).c_str());
    dstRSPPlugin.SetName(stdstr_f("%s-copy", dstRSPPlugin.GetName().c_str()).c_str());
    if (!dstRSPPlugin.DirectoryExists())
    {
        dstRSPPlugin.DirectoryCreate();
    }
    if (!srcRSPPlugin.CopyTo(dstRSPPlugin))
    {
        return false;
    }

    //Copy Controller Plugin
    CPath srcContPlugin(m_PluginDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
    CPath dstContPlugin(DstDir.c_str(), g_Settings->LoadStringVal(Game_Plugin_Controller).c_str());
    dstContPlugin.SetName(stdstr_f("%s-copy", dstContPlugin.GetName().c_str()).c_str());
    if (!dstContPlugin.DirectoryExists())
    {
        dstContPlugin.DirectoryCreate();
    }
    if (!srcContPlugin.CopyTo(dstContPlugin))
    {
        return false;
    }
    return true;
}
Esempio n. 4
0
bool pjutil::TerminatedExistingExe()
{
    bool bTerminated = false;
    bool AskedUser = false;
    DWORD pid = GetCurrentProcessId();

    HANDLE nSearch = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    if (nSearch != INVALID_HANDLE_VALUE)
    {
        PROCESSENTRY32 lppe;

        memset(&lppe, 0, sizeof(PROCESSENTRY32));
        lppe.dwSize = sizeof(PROCESSENTRY32);
        stdstr ModuleName = CPath(CPath::MODULE_FILE).GetNameExtension();

        if (Process32First(nSearch, &lppe))
        {
            do
            {
                if (_stricmp(lppe.szExeFile, ModuleName.c_str()) != 0 ||
                    lppe.th32ProcessID == pid)
                {
                    continue;
                }
                if (!AskedUser)
                {
                    AskedUser = true;
                    int res = MessageBox(NULL, stdstr_f("%s currently running\n\nTerminate pid %d now?", ModuleName.c_str(), lppe.th32ProcessID).c_str(), stdstr_f("Terminate %s",ModuleName.c_str()).c_str(), MB_YESNO | MB_ICONEXCLAMATION);
                    if (res != IDYES)
                    {
                        break;
                    }
                }
                HANDLE hHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, lppe.th32ProcessID);
                if (hHandle != NULL)
                {
                    if (TerminateProcess(hHandle, 0))
                    {
                        bTerminated = true;
                    }
                    else
                    {
                        MessageBox(NULL, stdstr_f("Failed to terminate pid %d", lppe.th32ProcessID).c_str(), stdstr_f("Terminate %s failed!",ModuleName.c_str()).c_str(), MB_YESNO | MB_ICONEXCLAMATION);
                    }
                    CloseHandle(hHandle);
                }
            } while (Process32Next(nSearch, &lppe));
        }
        CloseHandle(nSearch);
    }
    return bTerminated;
}
Esempio n. 5
0
static void LoadPlugin(SettingID PluginSettingID, SettingID PluginVerSettingID, plugin_type * & plugin, const char * PluginDir, stdstr & FileName, TraceModuleProject64 TraceLevel, const char * type, bool IsCopy)
{
    if (plugin != NULL)
    {
        return;
    }
    FileName = g_Settings->LoadStringVal(PluginSettingID);
    CPath PluginFileName(PluginDir, FileName.c_str());
    if (IsCopy)
    {
        PluginFileName.SetName(stdstr_f("%s-copy", PluginFileName.GetName().c_str()).c_str());
    }
    plugin = new plugin_type();
    if (plugin)
    {
        WriteTrace(TraceLevel, TraceDebug, "%s Loading (%s): Starting", type, (const char *)PluginFileName);
        if (plugin->Load(PluginFileName))
        {
            WriteTrace(TraceLevel, TraceDebug, "%s Current Ver: %s", type, plugin->PluginName());
            g_Settings->SaveString(PluginVerSettingID, plugin->PluginName());
        }
        else
        {
            WriteTrace(TraceLevel, TraceError, "Failed to load %s", (const char *)PluginFileName);
            delete plugin;
            plugin = NULL;
        }
        WriteTrace(TraceLevel, TraceDebug, "%s Loading Done", type);
    }
    else
    {
        WriteTrace(TraceLevel, TraceError, "Failed to allocate %s plugin", type);
    }
}
Esempio n. 6
0
void CMainGui::GameCpuRunning(CMainGui * Gui)
{
    if (g_Settings->LoadBool(GameRunning_CPU_Running))
    {
        Gui->MakeWindowOnTop(g_Settings->LoadBool(UserInterface_AlwaysOnTop));
        if (g_Settings->LoadBool(Setting_AutoFullscreen))
        {
            WriteTrace(TraceDebug, __FUNCTION__ " 15");
            CIniFile RomIniFile(g_Settings->LoadStringVal(SupportFile_RomDatabase).c_str());
            stdstr Status = g_Settings->LoadStringVal(Rdb_Status);

            char String[100];
            RomIniFile.GetString("Rom Status", stdstr_f("%s.AutoFullScreen", Status.c_str()).c_str(), "true", String, sizeof(String));
            if (_stricmp(String, "true") == 0)
            {
                g_Notify->ChangeFullScreen();
            }
        }
        Gui->RefreshMenu();
        Gui->BringToTop();
    }
    else
    {
        PostMessage(Gui->m_hMainWindow, WM_GAME_CLOSED, 0, 0);
    }
}
void CProfiling::ShowCPU_Usage() {
    int64_t TotalTime, CPU = 0, Alist = 0, Dlist = 0, Idle = 0;
    PROFILE_ENRTY Entry;

    if (m_CurrentDisplayCount > 0) { m_CurrentDisplayCount -= 1; return; }
    m_CurrentDisplayCount = MAX_FRAMES;

    Entry = m_Entries.find(Timer_R4300);
    if (Entry != m_Entries.end()) { CPU = Entry->second; }

    Entry = m_Entries.find(Timer_RefreshScreen);
    if (Entry != m_Entries.end()) { CPU += Entry->second; }

    Entry = m_Entries.find(Timer_RSP_Dlist);
    if (Entry != m_Entries.end()) { Dlist = Entry->second; }

    Entry = m_Entries.find(Timer_UpdateScreen);
    if (Entry != m_Entries.end()) { Dlist += Entry->second; }

    Entry = m_Entries.find(Timer_RSP_Alist);
    if (Entry != m_Entries.end()) { Alist = Entry->second; }

    Entry = m_Entries.find(Timer_Idel);
    if (Entry != m_Entries.end()) { Idle = Entry->second; }

    TotalTime = CPU + Alist + Dlist + Idle;

    g_Notify->DisplayMessage(0, stdstr_f("r4300i: %0.1f%c    GFX: %0.1f%c    Alist: %0.1f%c    Idle: %0.1f%c",
        (float)(((double)CPU / (double)TotalTime) * 100), '%',
        (float)(((double)Dlist / (double)TotalTime) * 100), '%',
        (float)(((double)Alist / (double)TotalTime) * 100), '%',
        (float)(((double)Idle / (double)TotalTime) * 100), '%').c_str());

    ResetCounters();
}
Esempio n. 8
0
void CMempak::LoadMempak(int32_t Control)
{
    stdstr MempakName;
    MempakName.Format("%s_Cont_%d", g_Settings->LoadStringVal(Game_GameName).c_str(), Control + 1);

    CPath MempakPath(g_Settings->LoadStringVal(Directory_NativeSave).c_str(), stdstr_f("%s.mpk", MempakName.c_str()).c_str());
    if (g_Settings->LoadBool(Setting_UniqueSaveDir))
    {
        MempakPath.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str());
    }
    if (!MempakPath.DirectoryExists())
    {
        MempakPath.DirectoryCreate();
    }

    bool formatMempak = !MempakPath.Exists();

    m_MempakHandle[Control].Open(MempakPath, CFileBase::modeReadWrite | CFileBase::modeNoTruncate | CFileBase::modeCreate);
    m_MempakHandle[Control].SeekToBegin();

    if (formatMempak)
    {
        CMempak::Format(Control);
        m_MempakHandle[Control].Write(m_Mempaks[Control], 0x8000);
    }
    else
    {
        m_MempakHandle[Control].Read(m_Mempaks[Control], 0x8000);
    }
}
void CNotificationImp::BreakPoint(const char * FileName, int LineNumber)
{
    if (g_Settings->LoadBool(Debugger_Enabled))
    {
        DisplayError(stdstr_f("Break point found at\n%s\n%d", FileName, LineNumber).c_str());
        if (IsDebuggerPresent() != 0)
        {
            DebugBreak();
        }
        else
        {
            if (g_BaseSystem) 
			{
				g_BaseSystem->CloseCpu();
			}
        }
    }
    else
    {
        DisplayError("Fatal Error: Stopping emulation");
		if (g_BaseSystem) 
		{
			g_BaseSystem->CloseCpu();
		}
    }
}
Esempio n. 10
0
//------------------------------------------------------------------------
// Task    : Add a backslash to the beginning of Directory if there
//           is not already one there
//------------------------------------------------------------------------
void CPath::EnsureLeadingBackslash(std::string & Directory) const
{
    if(Directory.empty() || (Directory[0] != DIRECTORY_DELIMITER))
    {
        Directory = stdstr_f("%c%s", DIRECTORY_DELIMITER, Directory.c_str());
    }
}
Esempio n. 11
0
void R4300iOp32::LW()
{
    DWORD Address =  _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
    if ((Address & 3) != 0)
    {
        ADDRESS_ERROR_EXCEPTION(Address, true);
    }

    if (LogOptions.GenerateLog)
    {
        Log_LW((*_PROGRAM_COUNTER),Address);
    }

    if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
    {
        if (bShowTLBMisses())
        {
            g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str());
        }
        TLB_READ_EXCEPTION(Address);
    }
    else
    {
        _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0];
    }
}
Esempio n. 12
0
bool CDumpMemory::DumpMemory(LPCSTR FileName, DumpFormat Format, DWORD StartPC, DWORD EndPC, DWORD /*DumpPC*/)
{
    switch (Format)
    {
    case DisassemblyWithPC:
    {
        CLog LogFile;
        if (!LogFile.Open(FileName))
        {
            g_Notify->DisplayError(stdstr_f("Failed to open\n%s", FileName).c_str());
            return false;
        }
        LogFile.SetFlush(false);
        LogFile.SetTruncateFile(false);
        g_Notify->BreakPoint(__FILE__, __LINE__);
#ifdef legacycode
        char Command[200];
        for (COpcode OpCode(StartPC);  OpCode.PC() < EndPC; OpCode.Next())
        {
            const char * szOpName = OpCode.OpcodeName();
            OpCode.OpcodeParam(Command);
            LogFile.LogF("%X: %-15s%s\r\n",OpCode.PC(),szOpName,Command);
        }
#endif
        m_StartAddress.SetValue(StartPC, true, true);
        m_EndAddress.SetValue(EndPC, true, true);
        return true;
    }
    break;
    }
    return false;
}
Esempio n. 13
0
void CDebugScripts::RefreshStatus()
{
    INSTANCE_STATE state = m_Debugger->ScriptSystem()->GetInstanceState(m_SelectedScriptName);

    char* szState = "";
    switch (state)
    {
    case STATE_RUNNING:	szState = "Running"; break;
    case STATE_STARTED: szState = "Started"; break;
    case STATE_STOPPED: szState = "Stopped"; break;
    case STATE_INVALID: szState = "Not running"; break;
    }

    stdstr instanceInfo = stdstr_f("%s (%s)", m_SelectedScriptName, szState);

    m_InstanceInfoEdit.SetWindowTextA(instanceInfo.c_str());

    if (state == STATE_RUNNING)
    {
        m_EvalEdit.EnableWindow(TRUE);
    }
    else
    {
        m_EvalEdit.EnableWindow(FALSE);
    }
}
Esempio n. 14
0
bool AppInit(CNotification * Notify, const char * BaseDirectory, int argc, char **argv)
{
    try
    {
        g_Notify = Notify;
        InitializeLog();
        WriteTrace(TraceAppInit, TraceDebug, "Starting (BaseDirectory: %s)", BaseDirectory ? BaseDirectory : "null");
        if (Notify == NULL)
        {
            WriteTrace(TraceAppInit, TraceError, "No Notification class passed");
            return false;
        }
        WriteTrace(TraceAppInit, TraceDebug, "Settings up settings");
        g_Settings = new CSettings;
        g_Settings->Initialize(BaseDirectory, AppName());

        WriteTrace(TraceAppInit, TraceDebug, "Parse Commands");
        if (!ParseCommand(argc, argv))
        {
            WriteTrace(TraceAppInit, TraceError, "Failed to Parse Commands, exiting now");
            return false;
        }

#ifdef _WIN32
        if (g_Settings->LoadBool(Setting_CheckEmuRunning) &&
            pjutil::TerminatedExistingExe())
        {
            delete g_Settings;
            g_Settings = new CSettings;
            g_Settings->Initialize(BaseDirectory, AppName());
        }
#endif

        SetupTrace();
        FixDirectories();
#ifdef _WIN32
        CMipsMemoryVM::ReserveMemory();
        IncreaseThreadPriority();
#endif

        //Create the plugin container
        WriteTrace(TraceAppInit, TraceInfo, "Create Plugins");
        g_Plugins = new CPlugins(Directory_Plugin);

        g_Lang = new CLanguage();
        g_Lang->LoadCurrentStrings();
        g_Notify->AppInitDone();
        WriteTrace(TraceAppInit, TraceDebug, "Initialized Successfully");
        return true;
    }
    catch (...)
    {
        g_Notify->DisplayError(stdstr_f("Exception caught\nFile: %s\nLine: %d", __FILE__, __LINE__).c_str());
        WriteTrace(TraceAppInit, TraceError, "Exception caught, Init was not successfull");
        return false;
    }
}
Esempio n. 15
0
void CDMA::SP_DMA_READ()
{
    g_Reg->SP_DRAM_ADDR_REG &= 0x1FFFFFFF;

    if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
    {
        if (bHaveDebugger())
        {
            g_Notify->DisplayError(stdstr_f("%s\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", __FUNCTION__, g_Reg->SP_DRAM_ADDR_REG).c_str());
        }
        g_Reg->SP_DMA_BUSY_REG = 0;
        g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
        return;
    }

    if (g_Reg->SP_RD_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
    {
        if (bHaveDebugger())
        {
            g_Notify->DisplayError(stdstr_f("%s\nCould not fit copy in memory segment",__FUNCTION__).c_str());
        }
        return;
    }

    if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
    }
    if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
    }
    if (((g_Reg->SP_RD_LEN_REG + 1) & 3) != 0)
    {
        g_Notify->BreakPoint(__FILE__, __LINE__);
    }

    memcpy(g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF), g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG,
        g_Reg->SP_RD_LEN_REG + 1);

    g_Reg->SP_DMA_BUSY_REG = 0;
    g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
}
Esempio n. 16
0
void CCodeSection::DisplaySectionInformation()
{
    if (m_SectionID == 0)
    {
        return;
    }

    CPU_Message("====== Section %d ======", m_SectionID);
    CPU_Message("Start PC: %X", m_EnterPC);
    if (g_System->bLinkBlocks())
    {
        CPU_Message("End PC: %X", m_EndPC);
    }
    CPU_Message("CompiledLocation: %X", m_CompiledLocation);
    if (g_System->bLinkBlocks() && !m_ParentSection.empty())
    {
        stdstr ParentList;
        for (SECTION_LIST::iterator iter = m_ParentSection.begin(); iter != m_ParentSection.end(); iter++)
        {
            CCodeSection * Parent = *iter;
            if (!ParentList.empty())
            {
                ParentList += ", ";
            }
            ParentList += stdstr_f("%d", Parent->m_SectionID);
        }
        CPU_Message("Number of parents: %d (%s)", m_ParentSection.size(), ParentList.c_str());
    }

    if (g_System->bLinkBlocks())
    {
        CPU_Message("Jump Address: 0x%08X", m_Jump.JumpPC);
        CPU_Message("Jump Target Address: 0x%08X", m_Jump.TargetPC);
        if (m_JumpSection != NULL)
        {
            CPU_Message("Jump Section: %d", m_JumpSection->m_SectionID);
        }
        else
        {
            CPU_Message("Jump Section: None");
        }
        CPU_Message("Continue Address: 0x%08X", m_Cont.JumpPC);
        CPU_Message("Continue Target Address: 0x%08X", m_Cont.TargetPC);
        if (m_ContinueSection != NULL) {
            CPU_Message("Continue Section: %d", m_ContinueSection->m_SectionID);
        }
        else
        {
            CPU_Message("Continue Section: None");
        }
        CPU_Message("In Loop: %s", m_InLoop ? "Yes" : "No");
    }
    CPU_Message("=======================");
}
Esempio n. 17
0
void CRecompMemory::ShowMemUsed()
{
	DWORD Size = m_RecompPos - m_RecompCode;
	DWORD MB = Size / 0x100000;
	Size -= MB * 0x100000;
	DWORD KB = Size / 1024;
	Size -= KB * 1024;

	DWORD TotalAvaliable = m_RecompSize / 0x100000;

	g_Notify->DisplayMessage(0, stdstr_f("Memory used: %d mb %-3d kb %-3d bytes     Total Available: %d mb", MB, KB, Size, TotalAvaliable).ToUTF16().c_str());
}
void CRecompMemory::ShowMemUsed()
{
    uint32_t Size = m_RecompPos - m_RecompCode;
    uint32_t MB = Size / 0x100000;
    Size -= MB * 0x100000;
    uint32_t KB = Size / 1024;
    Size -= KB * 1024;

    uint32_t TotalAvaliable = m_RecompSize / 0x100000;

    g_Notify->DisplayMessage(0, stdstr_f("Memory used: %d mb %-3d kb %-3d bytes     Total Available: %d mb", MB, KB, Size, TotalAvaliable).c_str());
}
Esempio n. 19
0
uint32_t CFlashram::ReadFromFlashStatus(uint32_t PAddr)
{
    switch (PAddr)
    {
    case 0x08000000: return (uint32_t)(m_FlashStatus >> 32);
    default:
        if (bHaveDebugger())
        {
            g_Notify->DisplayError(stdstr_f("%s: PAddr (%X)", __FUNCTION__, PAddr).c_str());
        }
        break;
    }
    return (uint32_t)(m_FlashStatus >> 32);
}
Esempio n. 20
0
void CFlashram::DmaToFlashram(uint8_t * Source, int32_t StartOffset, int32_t len)
{
    switch (m_FlashFlag)
    {
    case FLASHRAM_MODE_WRITE:
        m_FlashRamPointer = Source;
        break;
    default:
        if (bHaveDebugger())
        {
            g_Notify->DisplayError(stdstr_f("%s: Start: %X, Offset: %X len: %X", __FUNCTION__, Source - g_MMU->Rdram(), StartOffset, len).c_str());
        }
    }
}
Esempio n. 21
0
void CMempak::LoadMempak(int32_t Control, bool Create)
{
    stdstr MempakName;
    MempakName.Format("%s_Cont_%d", g_Settings->LoadStringVal(Game_GameName).c_str(), Control + 1);

    CPath MempakPath(g_Settings->LoadStringVal(Directory_NativeSave).c_str(), stdstr_f("%s.mpk", MempakName.c_str()).c_str());
    if (g_Settings->LoadBool(Setting_UniqueSaveDir))
    {
        MempakPath.AppendDirectory(g_Settings->LoadStringVal(Game_UniqueSaveDir).c_str());
    }
#ifdef _WIN32
    MempakPath.NormalizePath(CPath(CPath::MODULE_DIRECTORY));
#endif

    if (!Create && !MempakPath.Exists())
    {
        if (!m_Formatted[Control])
        {
            CMempak::Format(Control);
            m_Formatted[Control] = true;
        }
        m_SaveExists[Control] = false;
        return;
    }

    if (!MempakPath.DirectoryExists())
    {
        MempakPath.DirectoryCreate();
    }

    bool formatMempak = !MempakPath.Exists();

    m_MempakHandle[Control].Open(MempakPath, CFileBase::modeReadWrite | CFileBase::modeNoTruncate | CFileBase::modeCreate);
    m_MempakHandle[Control].SeekToBegin();

    if (formatMempak)
    {
        if (!m_Formatted[Control])
        {
            CMempak::Format(Control);
            m_Formatted[Control] = true;
        }
        m_MempakHandle[Control].Write(m_Mempaks[Control], 0x8000);
    }
    else
    {
        m_MempakHandle[Control].Read(m_Mempaks[Control], 0x8000);
        m_Formatted[Control] = true;
    }
}
Esempio n. 22
0
void R4300iOp32::LBU()
{
    DWORD Address =  _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
    if (!g_MMU->LB_VAddr(Address,_GPR[m_Opcode.rt].UB[0]))
    {
        if (bShowTLBMisses())
        {
            g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str());
        }
        TLB_READ_EXCEPTION(Address);
    }
    else
    {
        _GPR[m_Opcode.rt].UW[0] = _GPR[m_Opcode.rt].UB[0];
    }
}
Esempio n. 23
0
EXPORT jboolean CALL Java_emu_project64_jni_NativeExports_appInit(JNIEnv* env, jclass cls, jstring BaseDir)
{
    if (g_Logger == NULL)
    {
        g_Logger = new AndroidLogger();
    }
    TraceAddModule(g_Logger);

    Notify().DisplayMessage(10, "    ____               _           __  _____ __ __");
    Notify().DisplayMessage(10, "   / __ \\_________    (_)__  _____/ /_/ ___// // /");
    Notify().DisplayMessage(10, "  / /_/ / ___/ __ \\  / / _ \\/ ___/ __/ __ \\/ // /_");
    Notify().DisplayMessage(10, " / ____/ /  / /_/ / / /  __/ /__/ /_/ /_/ /__  __/");
    Notify().DisplayMessage(10, "/_/   /_/   \\____/_/ /\\___/\\___/\\__/\\____/  /_/");
    Notify().DisplayMessage(10, "                /___/");
    Notify().DisplayMessage(10, "http://www.pj64-emu.com/");
    Notify().DisplayMessage(10, stdstr_f("%s Version %s", VER_FILE_DESCRIPTION_STR, VER_FILE_VERSION_STR).c_str());
    Notify().DisplayMessage(10, "");

    if (g_JavaVM == NULL)
    {
        Notify().DisplayError("No java VM");
        return false;
    }

    const char *baseDir = env->GetStringUTFChars(BaseDir, 0);
    bool res = AppInit(&Notify(), baseDir, 0, NULL);

    env->ReleaseStringUTFChars(BaseDir, baseDir);
    if (res)
    {
        g_JavaBridge = new JavaBridge(g_JavaVM);
        g_SyncBridge = new SyncBridge(g_JavaBridge);
        g_Plugins->SetRenderWindows(g_JavaBridge, g_SyncBridge);

        JniBridegSettings = new CJniBridegSettings();

        RegisterUISettings();
        g_Settings->RegisterChangeCB(GameRunning_CPU_Running, NULL, (CSettings::SettingChangedFunc)GameCpuRunning);
    }
    else
    {
        AppCleanup();
    }
    return res;
}
Esempio n. 24
0
void R4300iOp32::LWL()
{
    DWORD Offset, Address, Value;

    Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
    Offset  = Address & 3;

    if (!g_MMU->LW_VAddr((Address & ~3),Value))
    {
        if (bShowTLBMisses())
        {
            g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str());
        }
        TLB_READ_EXCEPTION(Address);
        return;
    }

    _GPR[m_Opcode.rt].W[0] = (int)(_GPR[m_Opcode.rt].W[0] & LWL_MASK[Offset]);
    _GPR[m_Opcode.rt].W[0] += (int)(Value << LWL_SHIFT[Offset]);
}
Esempio n. 25
0
void R4300iOp32::LWR()
{
    DWORD Offset, Address, Value;

    Address = _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
    Offset  = Address & 3;

    if (!g_MMU->LW_VAddr((Address & ~3),Value))
    {
        g_Notify->BreakPoint(__FILEW__,__LINE__);
        if (bShowTLBMisses())
        {
            g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str());
        }
        return;
    }

    _GPR[m_Opcode.rt].W[0] = (int)(_GPR[m_Opcode.rt].W[0] & LWR_MASK[Offset]);
    _GPR[m_Opcode.rt].W[0] += (int)(Value >> LWR_SHIFT[Offset]);
}
Esempio n. 26
0
void CDMA::OnFirstDMA()
{
    int16_t offset;
    const uint32_t base = 0x00000000;
    const uint32_t rt = g_MMU->RdramSize();

    switch (g_Rom->CicChipID())
    {
    case CIC_NUS_6101:  offset = +0x0318; break;
    case CIC_NUS_5167:  offset = +0x0318; break;
    case CIC_UNKNOWN:
    case CIC_NUS_6102:  offset = +0x0318; break;
    case CIC_NUS_6103:  offset = +0x0318; break;
    case CIC_NUS_6105:  offset = +0x03F0; break;
    case CIC_NUS_6106:  offset = +0x0318; break;
    default:
        g_Notify->DisplayError(stdstr_f("Unhandled CicChip(%d) in first DMA", g_Rom->CicChipID()).c_str());
        return;
    }
    g_MMU->SW_PAddr(base + offset, rt);
}
Esempio n. 27
0
void CDMA::SP_DMA_WRITE()
{
    if (g_Reg->SP_DRAM_ADDR_REG > g_MMU->RdramSize())
    {
        if (bHaveDebugger())
        {
            g_Notify->DisplayError(stdstr_f(__FUNCTION__ "\nSP_DRAM_ADDR_REG not in RDRam space : % 08X", g_Reg->SP_DRAM_ADDR_REG).ToUTF16().c_str());
        }
        return;
    }

    if (g_Reg->SP_WR_LEN_REG + 1 + (g_Reg->SP_MEM_ADDR_REG & 0xFFF) > 0x1000)
    {
        if (bHaveDebugger())
        {
            g_Notify->DisplayError(L"SP DMA WRITE\ncould not fit copy in memory segement");
        }
        return;
    }

    if ((g_Reg->SP_MEM_ADDR_REG & 3) != 0)
    {
        g_Notify->BreakPoint(__FILEW__, __LINE__);
    }

    if ((g_Reg->SP_DRAM_ADDR_REG & 3) != 0)
    {
        g_Notify->BreakPoint(__FILEW__, __LINE__);
    }
    if (((g_Reg->SP_WR_LEN_REG + 1) & 3) != 0)
    {
        g_Notify->BreakPoint(__FILEW__, __LINE__);
    }

    memcpy(g_MMU->Rdram() + g_Reg->SP_DRAM_ADDR_REG, g_MMU->Dmem() + (g_Reg->SP_MEM_ADDR_REG & 0x1FFF),
        g_Reg->SP_WR_LEN_REG + 1);

    g_Reg->SP_DMA_BUSY_REG = 0;
    g_Reg->SP_STATUS_REG &= ~SP_STATUS_DMA_BUSY;
}
Esempio n. 28
0
void R4300iOp32::LL()
{
    DWORD Address =  _GPR[m_Opcode.base].UW[0] + (short)m_Opcode.offset;
    if ((Address & 3) != 0)
    {
        ADDRESS_ERROR_EXCEPTION(Address, true);
    }

    if (!g_MMU->LW_VAddr(Address,_GPR[m_Opcode.rt].UW[0]))
    {
        if (bShowTLBMisses())
        {
            g_Notify->DisplayError(stdstr_f(__FUNCTION__ " TLB: %X", Address).ToUTF16().c_str());
        }
        TLB_READ_EXCEPTION(Address);
    }
    else
    {
        _GPR[m_Opcode.rt].W[0] = _GPR[m_Opcode.rt].W[0];
        (*_LLBit) = 1;
    }
}
Esempio n. 29
0
void CN64Disk::ByteSwapDisk()
{
    uint32_t count;

    switch (*((uint32_t *)&m_DiskImage[0]))
    {
    case 0x16D348E8:
        for (count = 0; count < m_DiskFileSize; count += 4)
        {
            m_DiskImage[count] ^= m_DiskImage[count + 3];
            m_DiskImage[count + 3] ^= m_DiskImage[count];
            m_DiskImage[count] ^= m_DiskImage[count + 3];
            m_DiskImage[count + 1] ^= m_DiskImage[count + 2];
            m_DiskImage[count + 2] ^= m_DiskImage[count + 1];
            m_DiskImage[count + 1] ^= m_DiskImage[count + 2];
        }
        break;
    case 0xE848D316: break;
    default:
        g_Notify->DisplayError(stdstr_f("ByteSwapDisk: %X", m_DiskImage[0]).c_str());
    }
}
Esempio n. 30
0
void CDebugSymbols::Refresh()
{
    if (m_SymbolsListView.m_hWnd == NULL)
    {
        return;
    }
    m_SymbolsListView.SetRedraw(FALSE);
    m_SymbolsListView.DeleteAllItems();

    CSymbols::EnterCriticalSection();

    int count = CSymbols::GetCount();

    for (int i = 0; i < count; i++)
    {
        CSymbolEntry* lpSymbol = CSymbols::GetEntryByIndex(i);

        stdstr addrStr = stdstr_f("%08X", lpSymbol->m_Address);

        m_SymbolsListView.AddItem(i, 0, addrStr.c_str());
        m_SymbolsListView.AddItem(i, 1, lpSymbol->TypeName());
        m_SymbolsListView.AddItem(i, 2, lpSymbol->m_Name);
        m_SymbolsListView.AddItem(i, 4, lpSymbol->m_Description);

        m_SymbolsListView.SetItemData(i, lpSymbol->m_Id);

        if (g_MMU)
        {
            char szValue[64];
            CSymbols::GetValueString(szValue, lpSymbol);
            m_SymbolsListView.AddItem(i, 3, szValue);
        }
    }

    CSymbols::LeaveCriticalSection();

    m_SymbolsListView.SetRedraw(TRUE);
}