I couldn't make any sense out of the wifi saving code, and I was pretty sure I saw a variable not getting saved, so I redid it. Did I do it right? I don't know, you tell me. Also in this commit I reformatted all of wifi.cpp because I had lost 10 minutes or more to not being able to find `variable = value` or `variable=value` due to it being inexplicably `variable\t=value` all over that file and uhmmmmmmmmmmmm no.

This commit is contained in:
zeromus 2020-03-31 00:18:54 -04:00
parent 600957a840
commit 5f76ba8bb3
3 changed files with 2292 additions and 2275 deletions

View File

@ -1053,6 +1053,11 @@ bool savestate_save (const char *file_name)
} else return false;
}
static void wifi_savestate(EMUFILE &os)
{
wifiHandler->SaveState(os);
}
static void writechunks(EMUFILE &os)
{
@ -1062,7 +1067,6 @@ static void writechunks(EMUFILE &os)
save_time = tm.get_Ticks();
gfx3d_PrepareSaveStateBufferWrite();
wifiHandler->PrepareSaveStateWrite();
savestate_WriteChunk(os,1,SF_ARM9);
savestate_WriteChunk(os,2,SF_ARM7);
@ -1079,7 +1083,7 @@ static void writechunks(EMUFILE &os)
savestate_WriteChunk(os,91,gfx3d_savestate);
savestate_WriteChunk(os,100,SF_MOVIE);
savestate_WriteChunk(os,101,mov_savestate);
savestate_WriteChunk(os,110,SF_WIFI);
savestate_WriteChunk(os,111,&wifi_savestate);
savestate_WriteChunk(os,120,SF_RTC);
savestate_WriteChunk(os,130,SF_NDS_INFO);
savestate_WriteChunk(os,140,s_slot1_savestate);
@ -1144,18 +1148,9 @@ static bool ReadStateChunks(EMUFILE &is, s32 totalsize)
case 100: if(!ReadStateChunk(is,SF_MOVIE, size)) ret=false; break;
case 101: if(!mov_loadstate(is, size)) ret=false; break;
case 110:
{
if (ReadStateChunk(is,SF_WIFI,size))
{
wifiHandler->ParseSaveStateRead();
}
else
{
ret = false;
}
case 111:
if(!wifiHandler->LoadState(is,size)) ret=false; break;
break;
}
case 120: if(!ReadStateChunk(is,SF_RTC,size)) ret=false; break;
case 130: if(!ReadStateChunk(is,SF_INFO,size)) ret=false; else haveInfo=true; break;

View File

@ -1184,7 +1184,7 @@ void WIFI_write16(u32 address, u16 val)
case REG_WIFI_POWERFORCE: // 0x040
{
io.POWERFORCE.value = val & 0x8001;
io.POWERFORCE.value = val & (u16)0x8001;
if(io.POWERFORCE.ApplyNewPowerOffState != 0)
{
@ -1203,6 +1203,7 @@ void WIFI_write16(u32 address, u16 val)
{
// Delayed action
io.POWERSTATE.WillPowerOn = 1;
DebugBreak();
}
// This probably shouldn't happen right here, but we need to write to
@ -2387,6 +2388,10 @@ u16 WIFI_read16(u32 address)
return io.POWER_TX.value;
case REG_WIFI_POWERSTATE: // 0x03C
if(io.POWERSTATE.IsPowerOff)
{
int zzz=9;
}
return io.POWERSTATE.value;
case REG_WIFI_POWERFORCE: // 0x040
@ -5048,6 +5053,20 @@ void WifiHandler::PrepareSaveStateWrite()
memcpy(legacyWifiSF.wifiRAM, this->_wifi.RAM, sizeof(this->_wifi.RAM));
}
bool WifiHandler::LoadState(EMUFILE& is, int size)
{
int version;
if(is.read_32LE(version) != 1) return false;
is.fread(&_wifi, sizeof(_wifi));
return true;
}
void WifiHandler::SaveState(EMUFILE& f)
{
f.write_32LE(1); //version
f.fwrite(&_wifi, sizeof(_wifi));
}
void WifiHandler::ParseSaveStateRead()
{
RF2958_IOREG_MAP& rf = this->_wifi.rf;

View File

@ -29,6 +29,7 @@
#include <deque>
#include <string>
#include <vector>
#include "emufile.h"
#define REG_WIFI_ID 0x000
#define REG_WIFI_MODE 0x004
@ -3414,6 +3415,8 @@ public:
void PrepareSaveStateWrite();
void ParseSaveStateRead();
bool LoadState(EMUFILE &is, int size);
void SaveState(EMUFILE &f);
static size_t ConvertDataFrame80211To8023(const u8 *inIEEE80211Frame, const size_t txLength, u8 *outIEEE8023Frame);
static size_t ConvertDataFrame8023To80211(const u8 *inIEEE8023Frame, const size_t txLength, u8 *outIEEE80211Frame);