From e1f3fc75ea8618bfc997f401d64e55eb164d7f99 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Mon, 30 Aug 2021 21:42:35 +0200 Subject: [PATCH] * add TSC shito * fix possible modcrypt shittiness --- src/DSi.cpp | 15 +++++++++++---- src/DSi_SPI_TSC.cpp | 5 +++++ src/DSi_SPI_TSC.h | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/DSi.cpp b/src/DSi.cpp index 8346a1a8..01e501b6 100644 --- a/src/DSi.cpp +++ b/src/DSi.cpp @@ -26,6 +26,7 @@ #include "GPU.h" #include "NDSCart.h" #include "SPI.h" +#include "DSi_SPI_TSC.h" #include "Platform.h" #ifdef JIT_ENABLED @@ -89,6 +90,9 @@ u8 ITCMInit[0x8000]; u8 ARM7Init[0x3C00]; +void Set_SCFG_Clock9(u16 val); + + bool Init() { #ifndef JIT_ENABLED @@ -230,13 +234,14 @@ void DecryptModcryptArea(u32 offset, u32 size, u8* iv) // find a matching binary area u32 binaryaddr, binarysize; + u32 roundedsize = (size + 0xF) & ~0xF; // CHECKME: GBAtek says the modcrypt area should be the same size, or bigger, // than the binary area being considered // but I have seen modcrypt areas smaller than the ARM9i binary #define BINARY_GOOD(name) \ ((offset >= NDSCart::Header.name##ROMOffset) && \ - (offset+size) <= (NDSCart::Header.name##ROMOffset+NDSCart::Header.name##Size)) + (offset+roundedsize) <= (NDSCart::Header.name##ROMOffset + ((NDSCart::Header.name##Size + 0xF) & ~0xF))) if (BINARY_GOOD(ARM9)) { @@ -314,7 +319,8 @@ void SetupDirectBoot() NDS::MapSharedWRAM(3); - // TODO: clock speed! + DSi_SPI_TSC::SetMode(0x00); + Set_SCFG_Clock9(0x0000); } else { @@ -363,6 +369,9 @@ void SetupDirectBoot() MBK[1][8] = mbk[11] & 0x00FFFF0F; NDS::MapSharedWRAM(mbk[11] >> 24); + + if (!(NDSCart::Header.AppFlags & (1<<0))) + DSi_SPI_TSC::SetMode(0x00); } u32 arm9start = 0; @@ -489,8 +498,6 @@ void SetupDirectBoot() NDS::ARM7BIOSProt = 0x20; - // TODO: SCFG setup, permissions, etc - SPI_Firmware::SetupDirectBoot(true); } diff --git a/src/DSi_SPI_TSC.cpp b/src/DSi_SPI_TSC.cpp index 24bbde08..061feb1a 100644 --- a/src/DSi_SPI_TSC.cpp +++ b/src/DSi_SPI_TSC.cpp @@ -81,6 +81,11 @@ void DoSavestate(Savestate* file) // TODO!! } +void SetMode(u8 mode) +{ + TSCMode = mode; +} + void SetTouchCoords(u16 x, u16 y) { if (TSCMode == 0x00) diff --git a/src/DSi_SPI_TSC.h b/src/DSi_SPI_TSC.h index cf3e3173..13b7883e 100644 --- a/src/DSi_SPI_TSC.h +++ b/src/DSi_SPI_TSC.h @@ -29,6 +29,9 @@ void DeInit(); void Reset(); void DoSavestate(Savestate* file); +// 00=DS-mode 01=normal +void SetMode(u8 mode); + void SetTouchCoords(u16 x, u16 y); void MicInputFrame(s16* data, int samples);