From 3a54b9178b761800cd8cfe0a51b073b893f59e79 Mon Sep 17 00:00:00 2001 From: StapleButter Date: Thu, 18 Oct 2018 03:04:39 +0200 Subject: [PATCH] RTC done. misc shito. --- src/NDS.cpp | 16 +++++++++++++--- src/RTC.cpp | 24 ++++++++++++++++++++++++ src/RTC.h | 2 ++ 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/NDS.cpp b/src/NDS.cpp index d2551dc1..525c9251 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -501,9 +501,14 @@ bool DoSavestate(Savestate* file) for (int i = 0; i < 8; i++) DMAs[i]->DoSavestate(file); - // MapSharedWRAM - // powcnt shito + file->Var8(&WRAMCnt); + if (!file->Saving) + { + // 'dept of redundancy dept' + // but we do need to update the mappings + MapSharedWRAM(WRAMCnt); + } ARM9->DoSavestate(file); ARM7->DoSavestate(file); @@ -513,9 +518,14 @@ bool DoSavestate(Savestate* file) GPU::DoSavestate(file); SPU::DoSavestate(file); SPI::DoSavestate(file); - // RTC + RTC::DoSavestate(file); // wifi + if (!file->Saving) + { + GPU::DisplaySwap(PowerControl9>>15); + } + return true; } diff --git a/src/RTC.cpp b/src/RTC.cpp index fd60eaf5..cd35643f 100644 --- a/src/RTC.cpp +++ b/src/RTC.cpp @@ -73,6 +73,30 @@ void Reset() FreeReg = 0; } +void DoSavestate(Savestate* file) +{ + file->Section("RTC."); + + file->Var16(&IO); + + file->Var8(&Input); + file->Var32(&InputBit); + file->Var32(&InputPos); + + file->VarArray(Output, sizeof(Output)); + file->Var32(&OutputBit); + file->Var32(&OutputPos); + + file->Var8(&CurCmd); + + file->Var8(&StatusReg1); + file->Var8(&StatusReg2); + file->VarArray(Alarm1, sizeof(Alarm1)); + file->VarArray(Alarm2, sizeof(Alarm2)); + file->Var8(&ClockAdjust); + file->Var8(&FreeReg); +} + u8 BCD(u8 val) { diff --git a/src/RTC.h b/src/RTC.h index 516eb5d3..ebfcda8c 100644 --- a/src/RTC.h +++ b/src/RTC.h @@ -20,6 +20,7 @@ #define RTC_H #include "types.h" +#include "Savestate.h" namespace RTC { @@ -27,6 +28,7 @@ namespace RTC bool Init(); void DeInit(); void Reset(); +void DoSavestate(Savestate* file); u16 Read(); void Write(u16 val, bool byte);