From 6e45f2d90f1849ad70e4fd5078327b0db96bd2bf Mon Sep 17 00:00:00 2001 From: Emmet Young Date: Mon, 16 May 2016 20:20:00 +1000 Subject: [PATCH] Make the Transferpak only init the GBCart when we have either a read or a load to the transferpak. --- .../N64System/Mips/Transferpak.cpp | 18 +++++++++++++++++- Source/Project64-core/N64System/N64Class.cpp | 16 ---------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/Project64-core/N64System/Mips/Transferpak.cpp b/Source/Project64-core/N64System/Mips/Transferpak.cpp index dfa77a0d4..f089a77a1 100644 --- a/Source/Project64-core/N64System/Mips/Transferpak.cpp +++ b/Source/Project64-core/N64System/Mips/Transferpak.cpp @@ -32,13 +32,22 @@ void Transferpak::Init() void Transferpak::Release() { - GBCart::release_gb_cart(&tpak.gb_cart); + if (tpak.gb_cart.rom != NULL) + { + GBCart::release_gb_cart(&tpak.gb_cart); + } } void Transferpak::ReadFrom(uint16_t address, uint8_t * data) { if ((address >= 0x8000) && (address <= 0x8FFF)) { + //Ensure we actually have a ROM loaded in first. + if (tpak.gb_cart.rom == NULL) + { + Init(); + } + //Get whether the GB cart is enabled or disabled uint8_t value = (tpak.enabled) ? 0x84 : 0x00; @@ -71,8 +80,15 @@ void Transferpak::ReadFrom(uint16_t address, uint8_t * data) void Transferpak::WriteTo(uint16_t address, uint8_t * data) { + if ((address >= 0x8000) && (address <= 0x8FFF)) { + //Ensure we actually have a ROM loaded in first. + if (tpak.gb_cart.rom == NULL) + { + Init(); + } + //Set whether the gb cart is enabled or disabled. switch (*data) { diff --git a/Source/Project64-core/N64System/N64Class.cpp b/Source/Project64-core/N64System/N64Class.cpp index 2817bc63b..11ad12de7 100644 --- a/Source/Project64-core/N64System/N64Class.cpp +++ b/Source/Project64-core/N64System/N64Class.cpp @@ -687,22 +687,6 @@ 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; - } - } - } - } } if (bReset)