Make the Transferpak only init the GBCart when we have either a read or a load to the transferpak.

This commit is contained in:
Emmet Young 2016-05-16 20:20:00 +10:00
parent ff4bd28e3e
commit 6e45f2d90f
2 changed files with 17 additions and 17 deletions

View File

@ -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)
{

View File

@ -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)