From f7b6298e77a93dc5ed217e2bb549adec7b5367a0 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Wed, 24 Sep 2008 21:14:23 +0000 Subject: [PATCH] Break out BIOS emulation code into its own file. Remove BOOT_BIN support (who still uses that?). assorted warning fixes. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@674 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Core/Core.vcproj | 314 ++++++++-------- Source/Core/Core/Src/Boot/Boot.cpp | 404 --------------------- Source/Core/Core/Src/Boot/Boot.h | 4 - Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp | 390 ++++++++++++++++++++ Source/Core/Core/Src/Boot/Boot_DOL.h | 1 + Source/Core/Core/Src/Boot/Boot_ELF.cpp | 50 ++- Source/Core/Core/Src/Boot/Boot_ELF.h | 17 + Source/Core/Core/Src/Boot/ElfReader.cpp | 62 ++-- Source/Core/Core/Src/Boot/ElfReader.h | 60 +-- Source/Core/Core/Src/CoreParameter.cpp | 6 - Source/Core/Core/Src/CoreParameter.h | 2 - Source/Core/Core/Src/HW/DVDInterface.cpp | 26 +- Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp | 4 +- Source/Core/Core/Src/PowerPC/SymbolDB.cpp | 2 +- Source/Core/Core/Src/SConscript | 1 + 15 files changed, 681 insertions(+), 662 deletions(-) create mode 100644 Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 038e738f35..d62803f59b 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -89,77 +89,6 @@ Name="VCPostBuildEventTool" /> - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - + + @@ -1263,14 +1267,6 @@ UsePrecompiledHeader="1" /> - - - @@ -1280,7 +1276,7 @@ /> + + + Open(_rFilename.c_str())) - { - u8* pData = pFile->Lock(0, pFile->GetSize()); - Memory::WriteBigEData(pData, 0x80000000, (u32)pFile->GetSize()); - pFile->Unlock(pData); - pFile->Close(); - } - - delete pFile; - return true; -} - -void WrapRunFunction(void*) -{ - while (PC != 0x00) - { - CCPU::SingleStep(); - } -} - -void WrapRunFunction2(void*) -{ - while (PC != 0x00) - { - PowerPC::SingleStep(); - } -} - -void CBoot::RunFunction(u32 _iAddr, bool _bUseDebugger) -{ - PC = _iAddr; - LR = 0x00; - - if (_bUseDebugger) - { - CCPU::Break(); - //EMM::Wrap(WrapRunFunction,0); - WrapRunFunction(0); - } - else - { - //EMM::Wrap(WrapRunFunction2,0); - WrapRunFunction2(0); - } -} - -// __________________________________________________________________________________________________ -// -// BIOS HLE: -// copy the apploader to 0x81200000 -// execute the apploader -// -void CBoot::EmulatedBIOS(bool _bDebug) -{ - LOG(BOOT, "Faking GC BIOS..."); - UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr); - m_MSR.FP = 1; - - Memory::Clear(); - - // ======================================================================================= - // Write necessary values - // --------------------------------------------------------------------------------------- - /* - "TODO: Game iso info to 0x80000000 according to yagcd - or does apploader do this?" - Answer, no - apparently it doesn't, at least not in some games (by Namco). In these cases we need to set these - manually. But I guess there's no reason that the Apploader couldn't do this by itself. So I guess we - could do this for only these Namco games that need this by detecting GetUniqueID, but that wouldn't - look pretty, and I think it's likely that this is actually how the GameCube works, it reads these values - by itself. So this is very unlikely to break anything. However, if somebody find a game that has an - apploader that automatically copies the first bytes of the disc to memory that could indicate that - the apploader procedure to load the first bytes fails for some reason in some games... I hope I'm not - being long-winded here :). The yagcd page for this is http://hitmen.c02.at/files/yagcd/yagcd/chap4.ht - ml#sec4.2 by the way. I'm not sure what the bytes 8-10 does (version and streaming), but I include - those to. - */ - // --------------------------------------------------------------------------------------- - DVDInterface::DVDRead(0x00000000, 0x80000000, 10); // write boot info needed for multidisc games - - Memory::Write_U32(0x4c000064, 0x80000300); // write default DFI Handler: rfi - Memory::Write_U32(0x4c000064, 0x80000800); // write default FPU Handler: rfi - Memory::Write_U32(0x4c000064, 0x80000C00); // write default Syscall Handler: rfi - // - Memory::Write_U32(0xc2339f3d, 0x8000001C); //game disc - Memory::Write_U32(0x0D15EA5E, 0x80000020); //funny magic word for normal boot - Memory::Write_U32(0x01800000, 0x80000028); // Physical Memory Size - -// Memory::Write_U32(0x00000003, 0x8000002C); // Console type - retail - Memory::Write_U32(0x10000006, 0x8000002C); // DevKit - - Memory::Write_U32(((1 & 0x3f) << 26) | 2, 0x81300000); // HLE OSReport for Apploader - // ======================================================================================= - - - // ======================================================================================= - // Load Apploader to Memory - The apploader is hardcoded to begin at 9 280 on the disc, but - // it seems like the size can be variable. - // --------------------------------------------------------------------------------------- - PowerPC::ppcState.gpr[1] = 0x816ffff0; // StackPointer - u32 iAppLoaderOffset = 0x2440; // 0x1c40 (old value perhaps?, I don't know why it's here) - // --------------------------------------------------------------------------------------- - u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10); - u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14); - if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1)) - return; - VolumeHandler::ReadToPtr(Memory::GetPointer(0x81200000), iAppLoaderOffset + 0x20, iAppLoaderSize); - // ======================================================================================= - - - //call iAppLoaderEntry - LOG(MASTER_LOG, "Call iAppLoaderEntry"); - - u32 iAppLoaderFuncAddr = 0x80003100; - PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0; - PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4; - PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; - RunFunction(iAppLoaderEntry, _bDebug); - u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0); - u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4); - u32 iAppLoaderClose = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+8); - - // iAppLoaderInit - LOG(MASTER_LOG, "Call iAppLoaderInit"); - PowerPC::ppcState.gpr[3] = 0x81300000; - RunFunction(iAppLoaderInit, _bDebug); - - - // ======================================================================================= - // iAppLoaderMain - This let's the apploader load the DOL (the exe) and the TOC (filesystem) - // and I guess anything else it wishes. To give you an idea about where the stuff is on the disc - // here's an example of the disc structure of these things from Baten Kaitos - Wings. The values - // are given as non hexadecimal (ie normal numbers with base 10 instead of base 16) and they - // are only approximately right. I don't know what's in the gaps or why there are gaps between - // the different things. - // Data From To Size - // Header 0 1 072 1 072 - // AppLoader 9 280 121 408 112 128 - // DOL (exe) 128 768 2 204 416 2 075 648 - // TOC 2 204 160 2 309 120 104 960 - // For some reason this game loaded these things in 16 rounds in the loop below. The third and - // last of these were double reads of things it had already copied to memory. But hey, we're - // all human :) - // --------------------------------------------------------------------------------------- - LOG(MASTER_LOG, "Call iAppLoaderMain"); - do - { - PowerPC::ppcState.gpr[3] = 0x81300004; - PowerPC::ppcState.gpr[4] = 0x81300008; - PowerPC::ppcState.gpr[5] = 0x8130000c; - - RunFunction(iAppLoaderMain, _bDebug); - - u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004); - u32 iLength = Memory::ReadUnchecked_U32(0x81300008); - u32 iDVDOffset = Memory::ReadUnchecked_U32(0x8130000c); - - LOG(MASTER_LOG, "DVDRead: offset: %08x memOffset: %08x length: %i", iDVDOffset, iRamAddress, iLength); - DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength); - - } while(PowerPC::ppcState.gpr[3] != 0x00); - // ======================================================================================= - - - // iAppLoaderClose - LOG(MASTER_LOG, "call iAppLoaderClose"); - RunFunction(iAppLoaderClose, _bDebug); - - // Load patches and run startup patches - std::string gameID = VolumeHandler::GetVolume()->GetUniqueID(); - PatchEngine_LoadPatches(gameID.c_str()); - PatchEngine_ApplyLoadPatches(); - PowerPC::ppcState.DebugCount = 0; - // return - PC = PowerPC::ppcState.gpr[3]; - - // --- preinit some stuff from bios --- - - // Bus Clock Speed - Memory::Write_U32(0x09a7ec80, 0x800000F8); - Memory::Write_U32(0x1cf7c580, 0x800000FC); - - // fake the VI Init of the BIOS - Memory::Write_U32(Core::g_CoreStartupParameter.bNTSC ? 0 : 1, 0x800000CC); - - // preset time - Memory::Write_U32(CEXIIPL::GetGCTime(), 0x800030D8); -} - - -// __________________________________________________________________________________________________ -// -// BIOS HLE: -// copy the apploader to 0x81200000 -// execute the apploader -// -bool CBoot::EmulatedBIOS_Wii(bool _bDebug) -{ - LOG(BOOT, "Faking Wii BIOS..."); - - FILE* pDump = fopen("WII/dump_0x0000_0x4000.bin", "rb"); - if (pDump != NULL) - { - LOG(MASTER_LOG, "Init from memory dump."); - - fread(Memory::GetMainRAMPtr(), 1, 16384, pDump); - fclose(pDump); - pDump = NULL; - } - else - { - // load settings.txt - { - std::string filename("WII/setting-eur.txt"); - if (VolumeHandler::IsValid()) - { - switch(VolumeHandler::GetVolume()->GetCountry()) - { - case DiscIO::IVolume::COUNTRY_JAP: - filename = "WII/setting-jpn.txt"; - break; - - case DiscIO::IVolume::COUNTRY_USA: - filename = "WII/setting-usa.txt"; - break; - - case DiscIO::IVolume::COUNTRY_EUROPE: - filename = "WII/setting-eur.txt"; - break; - - default: - PanicAlert("Unknown country. Wii boot process will be switched to European settings."); - filename = "WII/setting-eur.txt"; - break; - } - } - - FILE* pTmp = fopen(filename.c_str(), "rb"); - if (!pTmp) - { - LOG(MASTER_LOG, "Cant find setting file"); - return false; - } - - fread(Memory::GetPointer(0x3800), 256, 1, pTmp); - fclose(pTmp); - } - - // int global vars - { - // updated with info from wiibrew.org - Memory::Write_U32(0x5d1c9ea3, 0x00000018); // magic word it is a wii disc - Memory::Write_U32(0x0D15EA5E, 0x00000020); - Memory::Write_U32(0x00000001, 0x00000024); - Memory::Write_U32(0x01800000, 0x00000028); - Memory::Write_U32(0x00000023, 0x0000002c); - Memory::Write_U32(0x00000000, 0x00000030); // Init - Memory::Write_U32(0x817FEC60, 0x00000034); // Init - // 38, 3C should get start, size of FST through apploader - Memory::Write_U32(0x38a00040, 0x00000060); // Exception init - Memory::Write_U32(0x8008f7b8, 0x000000e4); // Thread Init - Memory::Write_U32(0x01800000, 0x000000f0); // "simulated memory size" (debug mode?) - Memory::Write_U32(0x8179b500, 0x000000f4); // __start - Memory::Write_U32(0x0e7be2c0, 0x000000f8); // Bus speed - Memory::Write_U32(0x2B73A840, 0x000000fc); // CPU speed - Memory::Write_U16(0x0000, 0x000030e6); // Console type - Memory::Write_U32(0x00000000, 0x000030c0); // EXI - Memory::Write_U32(0x00000000, 0x000030c4); // EXI - Memory::Write_U32(0x00000000, 0x000030dc); // Time - Memory::Write_U32(0x00000000, 0x000030d8); // Time - Memory::Write_U32(0x00000000, 0x000030f0); // apploader - Memory::Write_U32(0x01800000, 0x00003100); // BAT - Memory::Write_U32(0x01800000, 0x00003104); // BAT - Memory::Write_U32(0x00000000, 0x0000310c); // Init - Memory::Write_U32(0x8179d500, 0x00003110); // Init - Memory::Write_U32(0x04000000, 0x00003118); - Memory::Write_U32(0x04000000, 0x0000311c); // BAT - Memory::Write_U32(0x93400000, 0x00003120); // BAT - Memory::Write_U32(0x90000800, 0x00003124); // Init - MEM2 low - Memory::Write_U32(0x933e0000, 0x00003128); // Init - MEM2 high - Memory::Write_U32(0x933e0000, 0x00003130); // IOS MEM2 low - Memory::Write_U32(0x93400000, 0x00003134); // IOS MEM2 high - Memory::Write_U32(0x00000011, 0x00003138); // Console type - Memory::Write_U16(0x0113, 0x0000315e); // apploader - Memory::Write_U32(0x0000FF16, 0x00003158); // DDR ram vendor code - Memory::Write_U8(0x80, 0x0000315c); // OSInit - Memory::Write_U8(0x00, 0x00000006); // DVDInit - Memory::Write_U8(0x00, 0x00000007); // DVDInit - Memory::Write_U16(0x0000, 0x000030e0); // PADInit - - // fake the VI Init of the BIOS - Memory::Write_U32(Core::g_CoreStartupParameter.bNTSC ? 0 : 1, 0x000000CC); - - // clear exception handler - for (int i = 0x3000; i <= 0x3038; i += 4) - { - Memory::Write_U32(0x00000000, 0x80000000 + i); - } - - // app - VolumeHandler::ReadToPtr(Memory::GetPointer(0x3180), 0, 4); - Memory::Write_U8(0x80, 0x00003184); - } - } - - // apploader - if (VolumeHandler::IsValid() && VolumeHandler::IsWii()) - { - UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr); - m_MSR.FP = 1; - - //TODO: Game iso info to 0x80000000 according to yagcd - or does apploader do this? - - Memory::Write_U32(0x4c000064, 0x80000300); // write default DFI Handler: rfi - Memory::Write_U32(0x4c000064, 0x80000800); // write default FPU Handler: rfi - Memory::Write_U32(0x4c000064, 0x80000C00); // write default Syscall Handler: rfi - - Memory::Write_U32(((1 & 0x3f) << 26) | 2, 0x81300000); // HLE OSReport for Apploader - - PowerPC::ppcState.gpr[1] = 0x816ffff0; // StackPointer - - u32 iAppLoaderOffset = 0x2440; // 0x1c40; - - // Load Apploader to Memory - u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10); - u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14); - if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1)) - { - LOG(BOOT, "Invalid apploader. Probably your image is corrupted."); - return false; - } - VolumeHandler::ReadToPtr(Memory::GetPointer(0x81200000), iAppLoaderOffset + 0x20, iAppLoaderSize); - - //call iAppLoaderEntry - LOG(BOOT, "Call iAppLoaderEntry"); - - u32 iAppLoaderFuncAddr = 0x80004000; - PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0; - PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4; - PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; - RunFunction(iAppLoaderEntry, _bDebug); - u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0); - u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4); - u32 iAppLoaderClose = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+8); - - // iAppLoaderInit - LOG(BOOT, "Call iAppLoaderInit"); - PowerPC::ppcState.gpr[3] = 0x81300000; - RunFunction(iAppLoaderInit, _bDebug); - - // iAppLoaderMain - LOG(BOOT, "Call iAppLoaderMain"); - do - { - PowerPC::ppcState.gpr[3] = 0x81300004; - PowerPC::ppcState.gpr[4] = 0x81300008; - PowerPC::ppcState.gpr[5] = 0x8130000c; - - RunFunction(iAppLoaderMain, _bDebug); - - u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004); - u32 iLength = Memory::ReadUnchecked_U32(0x81300008); - u32 iDVDOffset = Memory::ReadUnchecked_U32(0x8130000c) << 2; - - LOG(BOOT, "DVDRead: offset: %08x memOffse: %08x length: %i", iDVDOffset, iRamAddress, iLength); - DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength); - } while(PowerPC::ppcState.gpr[3] != 0x00); - - // iAppLoaderClose - LOG(BOOT, "call iAppLoaderClose"); - RunFunction(iAppLoaderClose, _bDebug); - - // Load patches and run startup patches - std::string gameID = VolumeHandler::GetVolume()->GetUniqueID(); - PatchEngine_LoadPatches(gameID.c_str()); - - // return - PC = PowerPC::ppcState.gpr[3]; - } - - PowerPC::ppcState.DebugCount = 0; - - return true; -} - void CBoot::Load_FST(bool _bIsWii) { if(VolumeHandler::IsValid()) @@ -655,22 +267,6 @@ bool CBoot::BootUp(const SCoreStartupParameter& _StartupPara) } break; - // BIN - // =================================================================================== - case SCoreStartupParameter::BOOT_BIN: - { - if (!_StartupPara.m_strDefaultGCM.empty()) - { - VolumeHandler::SetVolumeName(_StartupPara.m_strDefaultGCM.c_str()); - EmulatedBIOS(false); - } - - Boot_BIN(_StartupPara.m_strFilename); - if (LoadMapFromFilename(_StartupPara.m_strFilename)) - HLE::PatchFunctions(); - } - break; - // BIOS // =================================================================================== case SCoreStartupParameter::BOOT_BIOS: diff --git a/Source/Core/Core/Src/Boot/Boot.h b/Source/Core/Core/Src/Boot/Boot.h index 4a2f488e4d..235ccf4024 100644 --- a/Source/Core/Core/Src/Boot/Boot.h +++ b/Source/Core/Core/Src/Boot/Boot.h @@ -32,7 +32,6 @@ public: BOOT_ERROR, BOOT_DOL, BOOT_ELF, - BOOT_BIN, BOOT_ISO, BOOT_BIOS }; @@ -50,14 +49,11 @@ private: static void UpdateDebugger_MapLoaded(const char* _gameID = NULL); static bool LoadMapFromFilename(const std::string& _rFilename, const char* _gameID = NULL); - static bool Boot_ELF(const char *filename); - static bool Boot_BIN(const std::string& _rFilename); static void EmulatedBIOS(bool _bDebug); static bool EmulatedBIOS_Wii(bool _bDebug); static bool Load_BIOS(const std::string& _rBiosFilename); - static void Load_FST(bool _bIsWii); }; diff --git a/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp b/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp new file mode 100644 index 0000000000..ef781448a8 --- /dev/null +++ b/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp @@ -0,0 +1,390 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#include "Common.h" + +#include "../PowerPC/PowerPC.h" +#include "../Core.h" +#include "../HW/EXI_DeviceIPL.h" +#include "../HW/Memmap.h" +#include "../HW/DVDInterface.h" +#include "../HW/CPU.h" + +#include "../Host.h" +#include "../VolumeHandler.h" +#include "../PatchEngine.h" +#include "../MemTools.h" + +#include "VolumeCreator.h" +#include "Boot.h" + +void CBoot::RunFunction(u32 _iAddr, bool _bUseDebugger) +{ + PC = _iAddr; + LR = 0x00; + + if (_bUseDebugger) + { + CCPU::Break(); + while (PC != 0x00) + CCPU::SingleStep(); + } + else + { + while (PC != 0x00) + PowerPC::SingleStep(); + } +} + +// __________________________________________________________________________________________________ +// +// BIOS HLE: +// copy the apploader to 0x81200000 +// execute the apploader +// +void CBoot::EmulatedBIOS(bool _bDebug) +{ + LOG(BOOT, "Faking GC BIOS..."); + UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr); + m_MSR.FP = 1; + + Memory::Clear(); + + // ======================================================================================= + // Write necessary values + // --------------------------------------------------------------------------------------- + /* + "TODO: Game iso info to 0x80000000 according to yagcd - or does apploader do this?" - Answer, no + apparently it doesn't, at least not in some games (by Namco). In these cases we need to set these + manually. But I guess there's no reason that the Apploader couldn't do this by itself. So I guess we + could do this for only these Namco games that need this by detecting GetUniqueID, but that wouldn't + look pretty, and I think it's likely that this is actually how the GameCube works, it reads these values + by itself. So this is very unlikely to break anything. However, if somebody find a game that has an + apploader that automatically copies the first bytes of the disc to memory that could indicate that + the apploader procedure to load the first bytes fails for some reason in some games... I hope I'm not + being long-winded here :). The yagcd page for this is http://hitmen.c02.at/files/yagcd/yagcd/chap4.ht + ml#sec4.2 by the way. I'm not sure what the bytes 8-10 does (version and streaming), but I include + those to. + */ + // --------------------------------------------------------------------------------------- + DVDInterface::DVDRead(0x00000000, 0x80000000, 10); // write boot info needed for multidisc games + + Memory::Write_U32(0x4c000064, 0x80000300); // write default DFI Handler: rfi + Memory::Write_U32(0x4c000064, 0x80000800); // write default FPU Handler: rfi + Memory::Write_U32(0x4c000064, 0x80000C00); // write default Syscall Handler: rfi + // + Memory::Write_U32(0xc2339f3d, 0x8000001C); //game disc + Memory::Write_U32(0x0D15EA5E, 0x80000020); //funny magic word for normal boot + Memory::Write_U32(0x01800000, 0x80000028); // Physical Memory Size + +// Memory::Write_U32(0x00000003, 0x8000002C); // Console type - retail + Memory::Write_U32(0x10000006, 0x8000002C); // DevKit + + Memory::Write_U32(((1 & 0x3f) << 26) | 2, 0x81300000); // HLE OSReport for Apploader + // ======================================================================================= + + + // ======================================================================================= + // Load Apploader to Memory - The apploader is hardcoded to begin at 9 280 on the disc, but + // it seems like the size can be variable. + // --------------------------------------------------------------------------------------- + PowerPC::ppcState.gpr[1] = 0x816ffff0; // StackPointer + u32 iAppLoaderOffset = 0x2440; // 0x1c40 (old value perhaps?, I don't know why it's here) + // --------------------------------------------------------------------------------------- + u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10); + u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14); + if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1)) + return; + VolumeHandler::ReadToPtr(Memory::GetPointer(0x81200000), iAppLoaderOffset + 0x20, iAppLoaderSize); + // ======================================================================================= + + + //call iAppLoaderEntry + LOG(MASTER_LOG, "Call iAppLoaderEntry"); + + u32 iAppLoaderFuncAddr = 0x80003100; + PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0; + PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4; + PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; + RunFunction(iAppLoaderEntry, _bDebug); + u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0); + u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4); + u32 iAppLoaderClose = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+8); + + // iAppLoaderInit + LOG(MASTER_LOG, "Call iAppLoaderInit"); + PowerPC::ppcState.gpr[3] = 0x81300000; + RunFunction(iAppLoaderInit, _bDebug); + + + // ======================================================================================= + // iAppLoaderMain - This let's the apploader load the DOL (the exe) and the TOC (filesystem) + // and I guess anything else it wishes. To give you an idea about where the stuff is on the disc + // here's an example of the disc structure of these things from Baten Kaitos - Wings. The values + // are given as non hexadecimal (ie normal numbers with base 10 instead of base 16) and they + // are only approximately right. I don't know what's in the gaps or why there are gaps between + // the different things. + // Data From To Size + // Header 0 1 072 1 072 + // AppLoader 9 280 121 408 112 128 + // DOL (exe) 128 768 2 204 416 2 075 648 + // TOC 2 204 160 2 309 120 104 960 + // For some reason this game loaded these things in 16 rounds in the loop below. The third and + // last of these were double reads of things it had already copied to memory. But hey, we're + // all human :) + // --------------------------------------------------------------------------------------- + LOG(MASTER_LOG, "Call iAppLoaderMain"); + do + { + PowerPC::ppcState.gpr[3] = 0x81300004; + PowerPC::ppcState.gpr[4] = 0x81300008; + PowerPC::ppcState.gpr[5] = 0x8130000c; + + RunFunction(iAppLoaderMain, _bDebug); + + u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004); + u32 iLength = Memory::ReadUnchecked_U32(0x81300008); + u32 iDVDOffset = Memory::ReadUnchecked_U32(0x8130000c); + + LOG(MASTER_LOG, "DVDRead: offset: %08x memOffset: %08x length: %i", iDVDOffset, iRamAddress, iLength); + DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength); + + } while(PowerPC::ppcState.gpr[3] != 0x00); + // ======================================================================================= + + + // iAppLoaderClose + LOG(MASTER_LOG, "call iAppLoaderClose"); + RunFunction(iAppLoaderClose, _bDebug); + + // Load patches and run startup patches + std::string gameID = VolumeHandler::GetVolume()->GetUniqueID(); + PatchEngine_LoadPatches(gameID.c_str()); + PatchEngine_ApplyLoadPatches(); + PowerPC::ppcState.DebugCount = 0; + // return + PC = PowerPC::ppcState.gpr[3]; + + // --- preinit some stuff from bios --- + + // Bus Clock Speed + Memory::Write_U32(0x09a7ec80, 0x800000F8); + Memory::Write_U32(0x1cf7c580, 0x800000FC); + + // fake the VI Init of the BIOS + Memory::Write_U32(Core::g_CoreStartupParameter.bNTSC ? 0 : 1, 0x800000CC); + + // preset time + Memory::Write_U32(CEXIIPL::GetGCTime(), 0x800030D8); +} + + +// __________________________________________________________________________________________________ +// +// BIOS HLE: +// copy the apploader to 0x81200000 +// execute the apploader +// +bool CBoot::EmulatedBIOS_Wii(bool _bDebug) +{ + LOG(BOOT, "Faking Wii BIOS..."); + + FILE* pDump = fopen("WII/dump_0x0000_0x4000.bin", "rb"); + if (pDump != NULL) + { + LOG(MASTER_LOG, "Init from memory dump."); + + fread(Memory::GetMainRAMPtr(), 1, 16384, pDump); + fclose(pDump); + pDump = NULL; + } + else + { + // load settings.txt + { + std::string filename("WII/setting-eur.txt"); + if (VolumeHandler::IsValid()) + { + switch(VolumeHandler::GetVolume()->GetCountry()) + { + case DiscIO::IVolume::COUNTRY_JAP: + filename = "WII/setting-jpn.txt"; + break; + + case DiscIO::IVolume::COUNTRY_USA: + filename = "WII/setting-usa.txt"; + break; + + case DiscIO::IVolume::COUNTRY_EUROPE: + filename = "WII/setting-eur.txt"; + break; + + default: + PanicAlert("Unknown country. Wii boot process will be switched to European settings."); + filename = "WII/setting-eur.txt"; + break; + } + } + + FILE* pTmp = fopen(filename.c_str(), "rb"); + if (!pTmp) + { + LOG(MASTER_LOG, "Cant find setting file"); + return false; + } + + fread(Memory::GetPointer(0x3800), 256, 1, pTmp); + fclose(pTmp); + } + + // int global vars + { + // updated with info from wiibrew.org + Memory::Write_U32(0x5d1c9ea3, 0x00000018); // magic word it is a wii disc + Memory::Write_U32(0x0D15EA5E, 0x00000020); + Memory::Write_U32(0x00000001, 0x00000024); + Memory::Write_U32(0x01800000, 0x00000028); + Memory::Write_U32(0x00000023, 0x0000002c); + Memory::Write_U32(0x00000000, 0x00000030); // Init + Memory::Write_U32(0x817FEC60, 0x00000034); // Init + // 38, 3C should get start, size of FST through apploader + Memory::Write_U32(0x38a00040, 0x00000060); // Exception init + Memory::Write_U32(0x8008f7b8, 0x000000e4); // Thread Init + Memory::Write_U32(0x01800000, 0x000000f0); // "simulated memory size" (debug mode?) + Memory::Write_U32(0x8179b500, 0x000000f4); // __start + Memory::Write_U32(0x0e7be2c0, 0x000000f8); // Bus speed + Memory::Write_U32(0x2B73A840, 0x000000fc); // CPU speed + Memory::Write_U16(0x0000, 0x000030e6); // Console type + Memory::Write_U32(0x00000000, 0x000030c0); // EXI + Memory::Write_U32(0x00000000, 0x000030c4); // EXI + Memory::Write_U32(0x00000000, 0x000030dc); // Time + Memory::Write_U32(0x00000000, 0x000030d8); // Time + Memory::Write_U32(0x00000000, 0x000030f0); // apploader + Memory::Write_U32(0x01800000, 0x00003100); // BAT + Memory::Write_U32(0x01800000, 0x00003104); // BAT + Memory::Write_U32(0x00000000, 0x0000310c); // Init + Memory::Write_U32(0x8179d500, 0x00003110); // Init + Memory::Write_U32(0x04000000, 0x00003118); + Memory::Write_U32(0x04000000, 0x0000311c); // BAT + Memory::Write_U32(0x93400000, 0x00003120); // BAT + Memory::Write_U32(0x90000800, 0x00003124); // Init - MEM2 low + Memory::Write_U32(0x933e0000, 0x00003128); // Init - MEM2 high + Memory::Write_U32(0x933e0000, 0x00003130); // IOS MEM2 low + Memory::Write_U32(0x93400000, 0x00003134); // IOS MEM2 high + Memory::Write_U32(0x00000011, 0x00003138); // Console type + Memory::Write_U16(0x0113, 0x0000315e); // apploader + Memory::Write_U32(0x0000FF16, 0x00003158); // DDR ram vendor code + Memory::Write_U8(0x80, 0x0000315c); // OSInit + Memory::Write_U8(0x00, 0x00000006); // DVDInit + Memory::Write_U8(0x00, 0x00000007); // DVDInit + Memory::Write_U16(0x0000, 0x000030e0); // PADInit + + // fake the VI Init of the BIOS + Memory::Write_U32(Core::g_CoreStartupParameter.bNTSC ? 0 : 1, 0x000000CC); + + // clear exception handler + for (int i = 0x3000; i <= 0x3038; i += 4) + { + Memory::Write_U32(0x00000000, 0x80000000 + i); + } + + // app + VolumeHandler::ReadToPtr(Memory::GetPointer(0x3180), 0, 4); + Memory::Write_U8(0x80, 0x00003184); + } + } + + // apploader + if (VolumeHandler::IsValid() && VolumeHandler::IsWii()) + { + UReg_MSR& m_MSR = ((UReg_MSR&)PowerPC::ppcState.msr); + m_MSR.FP = 1; + + //TODO: Game iso info to 0x80000000 according to yagcd - or does apploader do this? + + Memory::Write_U32(0x4c000064, 0x80000300); // write default DFI Handler: rfi + Memory::Write_U32(0x4c000064, 0x80000800); // write default FPU Handler: rfi + Memory::Write_U32(0x4c000064, 0x80000C00); // write default Syscall Handler: rfi + + Memory::Write_U32(((1 & 0x3f) << 26) | 2, 0x81300000); // HLE OSReport for Apploader + + PowerPC::ppcState.gpr[1] = 0x816ffff0; // StackPointer + + u32 iAppLoaderOffset = 0x2440; // 0x1c40; + + // Load Apploader to Memory + u32 iAppLoaderEntry = VolumeHandler::Read32(iAppLoaderOffset + 0x10); + u32 iAppLoaderSize = VolumeHandler::Read32(iAppLoaderOffset + 0x14); + if ((iAppLoaderEntry == (u32)-1) || (iAppLoaderSize == (u32)-1)) + { + LOG(BOOT, "Invalid apploader. Probably your image is corrupted."); + return false; + } + VolumeHandler::ReadToPtr(Memory::GetPointer(0x81200000), iAppLoaderOffset + 0x20, iAppLoaderSize); + + //call iAppLoaderEntry + LOG(BOOT, "Call iAppLoaderEntry"); + + u32 iAppLoaderFuncAddr = 0x80004000; + PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0; + PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4; + PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; + RunFunction(iAppLoaderEntry, _bDebug); + u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0); + u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4); + u32 iAppLoaderClose = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+8); + + // iAppLoaderInit + LOG(BOOT, "Call iAppLoaderInit"); + PowerPC::ppcState.gpr[3] = 0x81300000; + RunFunction(iAppLoaderInit, _bDebug); + + // iAppLoaderMain + LOG(BOOT, "Call iAppLoaderMain"); + do + { + PowerPC::ppcState.gpr[3] = 0x81300004; + PowerPC::ppcState.gpr[4] = 0x81300008; + PowerPC::ppcState.gpr[5] = 0x8130000c; + + RunFunction(iAppLoaderMain, _bDebug); + + u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004); + u32 iLength = Memory::ReadUnchecked_U32(0x81300008); + u32 iDVDOffset = Memory::ReadUnchecked_U32(0x8130000c) << 2; + + LOG(BOOT, "DVDRead: offset: %08x memOffse: %08x length: %i", iDVDOffset, iRamAddress, iLength); + DVDInterface::DVDRead(iDVDOffset, iRamAddress, iLength); + } while(PowerPC::ppcState.gpr[3] != 0x00); + + // iAppLoaderClose + LOG(BOOT, "call iAppLoaderClose"); + RunFunction(iAppLoaderClose, _bDebug); + + // Load patches and run startup patches + std::string gameID = VolumeHandler::GetVolume()->GetUniqueID(); + PatchEngine_LoadPatches(gameID.c_str()); + + // return + PC = PowerPC::ppcState.gpr[3]; + } + + PowerPC::ppcState.DebugCount = 0; + + return true; +} + diff --git a/Source/Core/Core/Src/Boot/Boot_DOL.h b/Source/Core/Core/Src/Boot/Boot_DOL.h index 15c55aff4b..73a6feb230 100644 --- a/Source/Core/Core/Src/Boot/Boot_DOL.h +++ b/Source/Core/Core/Src/Boot/Boot_DOL.h @@ -14,6 +14,7 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ + #ifndef _BOOT_DOL_H #define _BOOT_DOL_H diff --git a/Source/Core/Core/Src/Boot/Boot_ELF.cpp b/Source/Core/Core/Src/Boot/Boot_ELF.cpp index ce85c3ac2c..947af9037e 100644 --- a/Source/Core/Core/Src/Boot/Boot_ELF.cpp +++ b/Source/Core/Core/Src/Boot/Boot_ELF.cpp @@ -1,3 +1,20 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + #include "../PowerPC/PowerPC.h" #include "Boot.h" #include "../HLE/HLE.h" @@ -7,16 +24,13 @@ bool CBoot::IsElfWii(const char *filename) { - Common::IMappedFile *mapfile = Common::IMappedFile::CreateMappedFileDEPRECATED(); - bool ok = mapfile->Open(filename); - if (!ok) - return false; - size_t filesize = (size_t)mapfile->GetSize(); - u8 *ptr = mapfile->Lock(0, filesize); - u8 *mem = new u8[filesize]; - memcpy(mem, ptr, filesize); - mapfile->Unlock(ptr); - mapfile->Close(); + FILE *f = fopen(filename, "rb"); + fseek(f, 0, SEEK_END); + u64 filesize = ftell(f); + fseek(f, 0, SEEK_SET); + u8 *mem = new u8[(size_t)filesize]; + fread(mem, 1, filesize, f); + fclose(f); ElfReader reader(mem); @@ -29,13 +43,13 @@ bool CBoot::IsElfWii(const char *filename) bool CBoot::Boot_ELF(const char *filename) { - Common::IMappedFile *mapfile = Common::IMappedFile::CreateMappedFileDEPRECATED(); - mapfile->Open(filename); - u8 *ptr = mapfile->Lock(0, mapfile->GetSize()); - u8 *mem = new u8[(size_t)mapfile->GetSize()]; - memcpy(mem, ptr, (size_t)mapfile->GetSize()); - mapfile->Unlock(ptr); - mapfile->Close(); + FILE *f = fopen(filename, "rb"); + fseek(f, 0, SEEK_END); + u64 filesize = ftell(f); + fseek(f, 0, SEEK_SET); + u8 *mem = new u8[(size_t)filesize]; + fread(mem, 1, filesize, f); + fclose(f); ElfReader reader(mem); reader.LoadInto(0x80000000); @@ -46,9 +60,9 @@ bool CBoot::Boot_ELF(const char *filename) } else { HLE::PatchFunctions(); } - delete [] mem; PC = reader.GetEntryPoint(); + delete [] mem; return true; } diff --git a/Source/Core/Core/Src/Boot/Boot_ELF.h b/Source/Core/Core/Src/Boot/Boot_ELF.h index 50e96676b7..6ad1ff06f7 100644 --- a/Source/Core/Core/Src/Boot/Boot_ELF.h +++ b/Source/Core/Core/Src/Boot/Boot_ELF.h @@ -1 +1,18 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + #pragma once diff --git a/Source/Core/Core/Src/Boot/ElfReader.cpp b/Source/Core/Core/Src/Boot/ElfReader.cpp index a37c555ece..425ec21f42 100644 --- a/Source/Core/Core/Src/Boot/ElfReader.cpp +++ b/Source/Core/Core/Src/Boot/ElfReader.cpp @@ -1,3 +1,20 @@ +// Copyright (C) 2003-2008 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + #include #include "Common.h" @@ -12,17 +29,17 @@ void bswap(Elf32_Half &w) {w = Common::swap16(w);} void byteswapHeader(Elf32_Ehdr &ELF_H) { bswap(ELF_H.e_type); - bswap(ELF_H.e_machine);// = _byteswap_ushort(ELF_H.e_machine); - bswap(ELF_H.e_ehsize);// = _byteswap_ushort(ELF_H.e_ehsize); - bswap(ELF_H.e_phentsize);// = _byteswap_ushort(ELF_H.e_phentsize); - bswap(ELF_H.e_phnum);// = _byteswap_ushort(ELF_H.e_phnum); - bswap(ELF_H.e_shentsize);// = _byteswap_ushort(ELF_H.e_shentsize); - bswap(ELF_H.e_shnum);// = _byteswap_ushort(ELF_H.e_shnum); - bswap(ELF_H.e_shstrndx);//= _byteswap_ushort(ELF_H.e_shstrndx); - bswap(ELF_H.e_version);// = _byteswap_ulong(ELF_H.e_version ); - bswap(ELF_H.e_entry);// = _byteswap_ulong(ELF_H.e_entry ); - bswap(ELF_H.e_phoff);// = _byteswap_ulong(ELF_H.e_phoff ); - bswap(ELF_H.e_shoff);// = _byteswap_ulong(ELF_H.e_shoff ); + bswap(ELF_H.e_machine); + bswap(ELF_H.e_ehsize); + bswap(ELF_H.e_phentsize); + bswap(ELF_H.e_phnum); + bswap(ELF_H.e_shentsize); + bswap(ELF_H.e_shnum); + bswap(ELF_H.e_shstrndx); + bswap(ELF_H.e_version); + bswap(ELF_H.e_entry); + bswap(ELF_H.e_phoff); + bswap(ELF_H.e_shoff); bswap(ELF_H.e_flags); } @@ -52,7 +69,6 @@ void byteswapSection(Elf32_Shdr &sec) bswap(sec.sh_type); } - ElfReader::ElfReader(void *ptr) { base = (char*)ptr; @@ -75,8 +91,7 @@ ElfReader::ElfReader(void *ptr) entryPoint = header->e_entry; } - -const char *ElfReader::GetSectionName(int section) +const char *ElfReader::GetSectionName(int section) const { if (sections[section].sh_type == SHT_NULL) return 0; @@ -90,8 +105,6 @@ const char *ElfReader::GetSectionName(int section) return 0; } - - void addrToHiLo(u32 addr, u16 &hi, s16 &lo) { lo = (addr & 0xFFFF); @@ -143,7 +156,7 @@ bool ElfReader::LoadInto(u32 vaddr) segmentVAddr[i] = baseAddress + p->p_vaddr; u32 writeAddr = segmentVAddr[i]; - u8 *src = GetSegmentPtr(i); + const u8 *src = GetSegmentPtr(i); u8 *dst = Memory::GetPointer(writeAddr); u32 srcSize = p->p_filesz; u32 dstSize = p->p_memsz; @@ -188,17 +201,14 @@ bool ElfReader::LoadInto(u32 vaddr) return true; } - -SectionID ElfReader::GetSectionByName(const char *name, int firstSection) +SectionID ElfReader::GetSectionByName(const char *name, int firstSection) const { for (int i = firstSection; i < header->e_shnum; i++) { const char *secname = GetSectionName(i); if (secname != 0 && strcmp(name, secname) == 0) - { return i; - } } return -1; } @@ -210,15 +220,12 @@ bool ElfReader::LoadSymbols() if (sec != -1) { int stringSection = sections[sec].sh_link; - - const char *stringBase = (const char*)GetSectionDataPtr(stringSection); + const char *stringBase = (const char *)GetSectionDataPtr(stringSection); //We have a symbol table! Elf32_Sym *symtab = (Elf32_Sym *)(GetSectionDataPtr(sec)); - int numSymbols = sections[sec].sh_size / sizeof(Elf32_Sym); - - for (int sym = 0; sym>2]; - } + u32 Read32(int off) const { return base32[off>>2]; } // Quick accessors - ElfType GetType() { return (ElfType)(header->e_type); } - ElfMachine GetMachine() { return (ElfMachine)(header->e_machine); } - u32 GetEntryPoint() { return entryPoint; } - u32 GetFlags() { return (u32)(header->e_flags); } + ElfType GetType() const { return (ElfType)(header->e_type); } + ElfMachine GetMachine() const { return (ElfMachine)(header->e_machine); } + u32 GetEntryPoint() const { return entryPoint; } + u32 GetFlags() const { return (u32)(header->e_flags); } - int GetNumSegments() { return (int)(header->e_phnum); } - int GetNumSections() { return (int)(header->e_shnum); } - const char *GetSectionName(int section); - u8 *GetPtr(int offset) - { - return (u8*)base + offset; - } - u8 *GetSectionDataPtr(int section) + int GetNumSegments() const { return (int)(header->e_phnum); } + int GetNumSections() const { return (int)(header->e_shnum); } + const u8 *GetPtr(int offset) const { return (u8*)base + offset; } + const char *GetSectionName(int section) const; + const u8 *GetSectionDataPtr(int section) const { if (section < 0 || section >= header->e_shnum) return 0; @@ -62,16 +69,13 @@ public: else return 0; } - u8 *GetSegmentPtr(int segment) + const u8 *GetSegmentPtr(int segment) { return GetPtr(segments[segment].p_offset); } - u32 GetSectionAddr(SectionID section) {return sectionAddrs[section];} - int GetSectionSize(SectionID section) - { - return sections[section].sh_size; - } - SectionID GetSectionByName(const char *name, int firstSection=0); //-1 for not found + u32 GetSectionAddr(SectionID section) const { return sectionAddrs[section]; } + int GetSectionSize(SectionID section) const { return sections[section].sh_size; } + SectionID GetSectionByName(const char *name, int firstSection = 0) const; //-1 for not found bool DidRelocate() { return bRelocate; diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index 73718ab962..3c5d8c7d1d 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -100,12 +100,6 @@ bool SCoreStartupParameter::AutoSetup(EBootBios _BootBios) m_BootType = BOOT_ELF; bNTSC = true; } - else if (!strcasecmp(Extension.c_str(), ".bin")) - { - BaseDataPath = s_DataBasePath_USA; - m_BootType = BOOT_BIN; - bNTSC = true; - } else if (!strcasecmp(Extension.c_str(), ".dol")) { BaseDataPath = s_DataBasePath_USA; diff --git a/Source/Core/Core/Src/CoreParameter.h b/Source/Core/Core/Src/CoreParameter.h index f82cdcc63b..4babf27a07 100644 --- a/Source/Core/Core/Src/CoreParameter.h +++ b/Source/Core/Core/Src/CoreParameter.h @@ -62,13 +62,11 @@ struct SCoreStartupParameter { BOOT_ISO, BOOT_ELF, - BOOT_BIN, BOOT_DOL, BOOT_BIOS }; EBootType m_BootType; - // files std::string m_strVideoPlugin; std::string m_strPadPlugin; diff --git a/Source/Core/Core/Src/HW/DVDInterface.cpp b/Source/Core/Core/Src/HW/DVDInterface.cpp index 7b7aae4220..5f948d003c 100644 --- a/Source/Core/Core/Src/HW/DVDInterface.cpp +++ b/Source/Core/Core/Src/HW/DVDInterface.cpp @@ -194,19 +194,19 @@ void ExecuteCommand(UDIDMAControlRegister& _DMAControlReg); void Init() { - dvdMem.StatusReg.Hex = 0; - dvdMem.CoverReg.Hex = 0; - dvdMem.Command[0] = 0; - dvdMem.Command[1] = 0; - dvdMem.Command[2] = 0; - dvdMem.DMAAddress.Hex = 0; - dvdMem.DMALength.Hex = 0; - dvdMem.DMAControlReg.Hex = 0; - dvdMem.Immediate = 0; - dvdMem.ConfigReg.Hex = 0; - dvdMem.AudioStart = 0; - dvdMem.AudioPos = 0; - dvdMem.AudioLength = 0; + dvdMem.StatusReg.Hex = 0; + dvdMem.CoverReg.Hex = 0; + dvdMem.Command[0] = 0; + dvdMem.Command[1] = 0; + dvdMem.Command[2] = 0; + dvdMem.DMAAddress.Hex = 0; + dvdMem.DMALength.Hex = 0; + dvdMem.DMAControlReg.Hex = 0; + dvdMem.Immediate = 0; + dvdMem.ConfigReg.Hex = 0; + dvdMem.AudioStart = 0; + dvdMem.AudioPos = 0; + dvdMem.AudioLength = 0; // SetLidOpen(true); } diff --git a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp index d6237e19b1..a5354c490b 100644 --- a/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp +++ b/Source/Core/Core/Src/HW/EXI_DeviceIPL.cpp @@ -66,7 +66,7 @@ CEXIIPL::CEXIIPL() : if (pStream != NULL) { fseek(pStream, 0, SEEK_END); - size_t filesize = ftell(pStream); + size_t filesize = (size_t)ftell(pStream); rewind(pStream); fread(m_pIPL + 0x001fcf00, 1, filesize, pStream); @@ -81,7 +81,7 @@ CEXIIPL::CEXIIPL() : if (pStream != NULL) { fseek(pStream, 0, SEEK_END); - size_t filesize = ftell(pStream); + size_t filesize = (size_t)ftell(pStream); rewind(pStream); fread(m_pIPL + 0x001aff00, 1, filesize, pStream); diff --git a/Source/Core/Core/Src/PowerPC/SymbolDB.cpp b/Source/Core/Core/Src/PowerPC/SymbolDB.cpp index ed449d62ec..9d3fed62d8 100644 --- a/Source/Core/Core/Src/PowerPC/SymbolDB.cpp +++ b/Source/Core/Core/Src/PowerPC/SymbolDB.cpp @@ -310,4 +310,4 @@ bool SymbolDB::SaveMap(const char *filename) } fclose(f); return true; -} +} diff --git a/Source/Core/Core/Src/SConscript b/Source/Core/Core/Src/SConscript index ce98ee2e53..501341e7ce 100644 --- a/Source/Core/Core/Src/SConscript +++ b/Source/Core/Core/Src/SConscript @@ -14,6 +14,7 @@ files = ["Console.cpp", "Tracer.cpp", "VolumeHandler.cpp", "Boot/Boot.cpp", + "Boot/Boot_BIOSEmu.cpp", "Boot/Boot_DOL.cpp", "Boot/Boot_ELF.cpp", "Boot/ElfReader.cpp",