diff --git a/include/memory.hpp b/include/memory.hpp index 86fb9f369..3ddd00cc9 100644 --- a/include/memory.hpp +++ b/include/memory.hpp @@ -159,7 +159,9 @@ class Memory { Regions region = Regions::USA; const EmulatorConfig& config; -public: + static constexpr std::array MACAddress = {0x40, 0xF4, 0x07, 0xFF, 0xFF, 0xEE}; + + public: u16 kernelVersion = 0; u32 usedUserMemory = u32(0_MB); // How much of the APPLICATION FCRAM range is used (allocated to the appcore) u32 usedSystemMemory = u32(0_MB); // Similar for the SYSTEM range (reserved for the syscore) diff --git a/include/panda_qt/main_window.hpp b/include/panda_qt/main_window.hpp index 3bbabf35d..b5b93d56a 100644 --- a/include/panda_qt/main_window.hpp +++ b/include/panda_qt/main_window.hpp @@ -7,8 +7,8 @@ #include #include #include -#include #include +#include #include "emulator.hpp" #include "panda_qt/screen.hpp" diff --git a/src/core/memory.cpp b/src/core/memory.cpp index f03e80f77..83248ef51 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -122,6 +122,13 @@ u8 Memory::read8(u32 vaddr) { case ConfigMem::FirmVersionMajor: return firm.major; case ConfigMem::WifiLevel: return 0; // No wifi :( + case ConfigMem::WifiMac: + case ConfigMem::WifiMac + 1: + case ConfigMem::WifiMac + 2: + case ConfigMem::WifiMac + 3: + case ConfigMem::WifiMac + 4: + case ConfigMem::WifiMac + 5: return MACAddress[vaddr - ConfigMem::WifiMac]; + default: Helpers::panic("Unimplemented 8-bit read, addr: %08X", vaddr); } } @@ -136,7 +143,7 @@ u16 Memory::read16(u32 vaddr) { return *(u16*)(pointer + offset); } else { switch (vaddr) { - case ConfigMem::WifiMac + 4: return 0xEEFF; // Wifi MAC: Last 2 bytes of MAC Address + case ConfigMem::WifiMac + 4: return (MACAddress[5] << 8) | MACAddress[4]; // Wifi MAC: Last 2 bytes of MAC Address default: Helpers::panic("Unimplemented 16-bit read, addr: %08X", vaddr); } } @@ -166,7 +173,10 @@ u32 Memory::read32(u32 vaddr) { case ConfigMem::AppMemAlloc: return appResourceLimits.maxCommit; case ConfigMem::SyscoreVer: return 2; case 0x1FF81000: return 0; // TODO: Figure out what this config mem address does - case ConfigMem::WifiMac: return 0xFF07F440; // Wifi MAC: First 4 bytes of MAC Address + // Wifi MAC: First 4 bytes of MAC Address + case ConfigMem::WifiMac: + return (u32(MACAddress[3]) << 24) | (u32(MACAddress[2]) << 16) | (u32(MACAddress[1]) << 8) | + MACAddress[0]; // 3D slider. Float in range 0.0 = off, 1.0 = max. case ConfigMem::SliderState3D: return Helpers::bit_cast(0.0f);