From c696cb79c37ebdac5c96b781706aa551455caff1 Mon Sep 17 00:00:00 2001 From: Emmet Young Date: Tue, 9 Feb 2016 18:57:30 +1100 Subject: [PATCH 1/2] Ensures paks are only being initialized when they have actually been selected, Transferpak needs multi controller support eventually as it currently just loads from the one singular option. --- Source/Project64-core/N64System/Mips/Mempak.H | 2 +- .../Project64-core/N64System/Mips/Mempak.cpp | 35 +++++++++---------- .../N64System/Mips/Transferpak.cpp | 12 ++++--- Source/Project64-core/N64System/N64Class.cpp | 21 +++++++++-- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/Mempak.H b/Source/Project64-core/N64System/Mips/Mempak.H index d344dc6f2..1f0fda70f 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.H +++ b/Source/Project64-core/N64System/Mips/Mempak.H @@ -14,7 +14,7 @@ class Mempak { public: static uint8_t CalculateCrc(uint8_t * DataToCrc); - static void Load(); + static void Load(int32_t Control); static void Format(int32_t Control); static void ReadFrom(int32_t Control, uint32_t address, uint8_t * data); static void WriteTo(int32_t Control, uint32_t address, uint8_t * data); diff --git a/Source/Project64-core/N64System/Mips/Mempak.cpp b/Source/Project64-core/N64System/Mips/Mempak.cpp index 10b2e01c2..ab03b58dd 100644 --- a/Source/Project64-core/N64System/Mips/Mempak.cpp +++ b/Source/Project64-core/N64System/Mips/Mempak.cpp @@ -17,30 +17,27 @@ uint8_t Mempaks[4][128 * 256]; /* [CONTROLLERS][PAGES][BYTES_PER_PAGE] */ CPath MempakNames[4]; -void Mempak::Load() +void Mempak::Load(int32_t Control) { stdstr MempakName; - for (int i = 0; i < 3; i++) + MempakName.Format("%s_Cont_%d", g_Settings->LoadStringVal(Game_GameName).c_str(), Control + 1); + + MempakNames[Control] = CPath(g_Settings->LoadStringVal(Directory_NativeSave).c_str(), stdstr_f("%s.mpk",MempakName.c_str()).c_str()); + if (!MempakNames[Control].DirectoryExists()) { - MempakName.Format("%s_Cont_%d", g_Settings->LoadStringVal(Game_GameName).c_str(), i + 1); + MempakNames[Control].DirectoryCreate(); + } - MempakNames[i] = CPath(g_Settings->LoadStringVal(Directory_NativeSave).c_str(), stdstr_f("%s.mpk",MempakName.c_str()).c_str()); - if (!MempakNames[i].DirectoryExists()) - { - MempakNames[i].DirectoryCreate(); - } - - if (MempakNames[i].Exists()) - { - FILE *mempak = fopen(MempakNames[i], "rb"); - fread(Mempaks[i], 1, 0x8000, mempak); - fclose(mempak); - } - else - { - Mempak::Format(i); - } + if (MempakNames[Control].Exists()) + { + FILE *mempak = fopen(MempakNames[Control], "rb"); + fread(Mempaks[Control], 1, 0x8000, mempak); + fclose(mempak); + } + else + { + Mempak::Format(Control); } } diff --git a/Source/Project64-core/N64System/Mips/Transferpak.cpp b/Source/Project64-core/N64System/Mips/Transferpak.cpp index 29c90f3ff..dfa77a0d4 100644 --- a/Source/Project64-core/N64System/Mips/Transferpak.cpp +++ b/Source/Project64-core/N64System/Mips/Transferpak.cpp @@ -21,11 +21,13 @@ uint16_t gb_cart_address(unsigned int bank, uint16_t address) void Transferpak::Init() { - - memset(&tpak, 0, sizeof(tpak)); - tpak.access_mode = (!GBCart::init_gb_cart(&tpak.gb_cart, g_Settings->LoadStringVal(Game_Transferpak_ROM).c_str())) ? CART_NOT_INSERTED : CART_ACCESS_MODE_0; - - tpak.access_mode_changed = 0x44; + //Quick check to ensure we dont have a ROM already + if (tpak.gb_cart.rom == NULL) + { + memset(&tpak, 0, sizeof(tpak)); + tpak.access_mode = (!GBCart::init_gb_cart(&tpak.gb_cart, g_Settings->LoadStringVal(Game_Transferpak_ROM).c_str())) ? CART_NOT_INSERTED : CART_ACCESS_MODE_0; + tpak.access_mode_changed = 0x44; + } } void Transferpak::Release() diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index 8b44c92ae..4da8b9cfb 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -66,8 +66,6 @@ m_CheatsSlectionChanged(false) m_Limiter.SetHertz(gameHertz); g_Settings->SaveDword(GameRunning_ScreenHertz, gameHertz); m_Cheats.LoadCheats(!g_Settings->LoadDword(Setting_RememberCheats), Plugins); - Mempak::Load(); - Transferpak::Init(); } CN64System::~CN64System() @@ -694,6 +692,25 @@ bool CN64System::SetActiveSystem(bool bActive) { WriteTrace(TraceN64System, TraceError, "g_Plugins->Initiate Failed"); } + else + { + CONTROL * Controllers = g_Plugins->Control()->PluginControllers(); + for (int i = 0; i < 3; i++) + { + if (Controllers[i].Present) + { + switch (Controllers[i].Plugin) + { + case PLUGIN_TANSFER_PAK: + Transferpak::Init(); + break; + case PLUGIN_MEMPAK: + Mempak::Load(i); + break; + } + } + } + } } if (bReset) From 2be94b513e37795b2d02ab167e2ef4799e2a8592 Mon Sep 17 00:00:00 2001 From: Lithium64 Date: Wed, 10 Feb 2016 00:45:33 -0300 Subject: [PATCH 2/2] Updated brazilian language file --- Lang/Brazilian Portuguese.pj.Lang | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lang/Brazilian Portuguese.pj.Lang b/Lang/Brazilian Portuguese.pj.Lang index 8e55922f5..2fa053c87 100644 --- a/Lang/Brazilian Portuguese.pj.Lang +++ b/Lang/Brazilian Portuguese.pj.Lang @@ -5,7 +5,7 @@ #1 # "Português Brasileiro" // LANGUAGE ID #2 # "Project64 team" // Author #3 # "2.2" // Version -#4 # "Dezembro, 2015" // Date +#4 # "Fevereiro, 2016" // Date //About DLL Dialog #5 # "Idioma Atual" @@ -96,6 +96,7 @@ #212# "Editar as Configurações do Jogo" #213# "Editar as Trapaças" #214# "Plugin Gráfico" +#215# "Jogar com Disco" //Alternate Name to save Slot #220# "Slot Padrão"