Skip to content

Commit

Permalink
convert Wifi and WifiAP
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisotura committed Nov 4, 2023
1 parent 76976fe commit 2bd09ea
Show file tree
Hide file tree
Showing 7 changed files with 380 additions and 371 deletions.
9 changes: 5 additions & 4 deletions src/ARMJIT_Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ int ClassifyAddress7(u32 addr)
}
}

void WifiWrite32(u32 addr, u32 val)
/*void WifiWrite32(u32 addr, u32 val)
{
Wifi::Write(addr, val & 0xFFFF);
Wifi::Write(addr + 2, val >> 16);
Expand All @@ -1221,7 +1221,7 @@ void WifiWrite32(u32 addr, u32 val)
u32 WifiRead32(u32 addr)
{
return (u32)Wifi::Read(addr) | ((u32)Wifi::Read(addr + 2) << 16);
}
}*/

template <typename T>
void VRAMWrite(u32 addr, T val)
Expand Down Expand Up @@ -1358,7 +1358,8 @@ void* GetFuncForAddr(ARM* cpu, u32 addr, bool store, int size)
}
}
break;
case 0x04800000:
// TODO: the wifi funcs also ought to check POWCNT
/*case 0x04800000:
if (addr < 0x04810000 && size >= 16)
{
switch (size | store)
Expand All @@ -1369,7 +1370,7 @@ void* GetFuncForAddr(ARM* cpu, u32 addr, bool store, int size)
case 33: return (void*)WifiWrite32;
}
}
break;
break;*/
case 0x06000000:
case 0x06800000:
switch (size | store)
Expand Down
29 changes: 15 additions & 14 deletions src/NDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ u16 RCnt;
class SPU* SPU;
class SPIHost* SPI;
class RTC* RTC;
class Wifi* Wifi;

bool Running;

Expand Down Expand Up @@ -222,11 +223,11 @@ bool Init()
SPU = new class SPU;
SPI = new class SPIHost();
RTC = new class RTC();
Wifi = new class Wifi();

if (!NDSCart::Init()) return false;
if (!GBACart::Init()) return false;
if (!GPU::Init()) return false;
if (!Wifi::Init()) return false;

if (!DSi::Init()) return false;

Expand All @@ -253,11 +254,11 @@ void DeInit()
delete SPU; SPU = nullptr;
delete SPI; SPI = nullptr;
delete RTC; RTC = nullptr;
delete Wifi; Wifi = nullptr;

NDSCart::DeInit();
GBACart::DeInit();
GPU::DeInit();
Wifi::DeInit();

DSi::DeInit();

Expand Down Expand Up @@ -646,7 +647,7 @@ void Reset()
SPU->Reset();
SPI->Reset();
RTC->Reset();
Wifi::Reset();
Wifi->Reset();

// TODO: move the SOUNDBIAS/degrade logic to SPU?

Expand Down Expand Up @@ -848,7 +849,7 @@ bool DoSavestate(Savestate* file)
SPU->DoSavestate(file);
SPI->DoSavestate(file);
RTC->DoSavestate(file);
Wifi::DoSavestate(file);
Wifi->DoSavestate(file);

if (ConsoleType == 1)
DSi::DoSavestate(file);
Expand All @@ -858,7 +859,7 @@ bool DoSavestate(Savestate* file)
GPU::SetPowerCnt(PowerControl9);

SPU->SetPowerCnt(PowerControl7 & 0x0001);
Wifi::SetPowerCnt(PowerControl7 & 0x0002);
Wifi->SetPowerCnt(PowerControl7 & 0x0002);
}

#ifdef JIT_ENABLED
Expand Down Expand Up @@ -2542,8 +2543,8 @@ u8 ARM7Read8(u32 addr)
if (addr < 0x04810000)
{
if (!(PowerControl7 & (1<<1))) return 0;
if (addr & 0x1) return Wifi::Read(addr-1) >> 8;
return Wifi::Read(addr) & 0xFF;
if (addr & 0x1) return Wifi->Read(addr-1) >> 8;
return Wifi->Read(addr) & 0xFF;
}
break;

Expand Down Expand Up @@ -2609,7 +2610,7 @@ u16 ARM7Read16(u32 addr)
if (addr < 0x04810000)
{
if (!(PowerControl7 & (1<<1))) return 0;
return Wifi::Read(addr);
return Wifi->Read(addr);
}
break;

Expand Down Expand Up @@ -2675,7 +2676,7 @@ u32 ARM7Read32(u32 addr)
if (addr < 0x04810000)
{
if (!(PowerControl7 & (1<<1))) return 0;
return Wifi::Read(addr) | (Wifi::Read(addr+2) << 16);
return Wifi->Read(addr) | (Wifi->Read(addr+2) << 16);
}
break;

Expand Down Expand Up @@ -2818,7 +2819,7 @@ void ARM7Write16(u32 addr, u16 val)
if (addr < 0x04810000)
{
if (!(PowerControl7 & (1<<1))) return;
Wifi::Write(addr, val);
Wifi->Write(addr, val);
return;
}
break;
Expand Down Expand Up @@ -2898,8 +2899,8 @@ void ARM7Write32(u32 addr, u32 val)
if (addr < 0x04810000)
{
if (!(PowerControl7 & (1<<1))) return;
Wifi::Write(addr, val & 0xFFFF);
Wifi::Write(addr+2, val >> 16);
Wifi->Write(addr, val & 0xFFFF);
Wifi->Write(addr+2, val >> 16);
return;
}
break;
Expand Down Expand Up @@ -4332,7 +4333,7 @@ void ARM7IOWrite16(u32 addr, u16 val)
u16 change = PowerControl7 ^ val;
PowerControl7 = val & 0x0003;
SPU->SetPowerCnt(val & 0x0001);
Wifi::SetPowerCnt(val & 0x0002);
Wifi->SetPowerCnt(val & 0x0002);
if (change & 0x0002) UpdateWifiTimings();
}
return;
Expand Down Expand Up @@ -4462,7 +4463,7 @@ void ARM7IOWrite32(u32 addr, u32 val)
u16 change = PowerControl7 ^ val;
PowerControl7 = val & 0x0003;
SPU->SetPowerCnt(val & 0x0001);
Wifi::SetPowerCnt(val & 0x0002);
Wifi->SetPowerCnt(val & 0x0002);
if (change & 0x0002) UpdateWifiTimings();
}
return;
Expand Down
2 changes: 2 additions & 0 deletions src/NDS.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
class SPU;
class SPIHost;
class RTC;
class Wifi;

namespace NDS
{
Expand Down Expand Up @@ -253,6 +254,7 @@ extern u16 RCnt;
extern class SPU* SPU;
extern class SPIHost* SPI;
extern class RTC* RTC;
extern class Wifi* Wifi;

const u32 ARM7WRAMSize = 0x10000;
extern u8* ARM7WRAM;
Expand Down
Loading

0 comments on commit 2bd09ea

Please sign in to comment.