aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRSDuck <RSDuck@users.noreply.github.com>2022-08-21 21:31:11 +0200
committerRSDuck <RSDuck@users.noreply.github.com>2022-08-21 21:31:11 +0200
commit22b312bc431637aa209ef0a10efbf4f70ded7dda (patch)
tree19cdbdce7d87ef972b5e4f6d51db46eb62ebcc0e /src
parent4c977314686510adeb5b11d05177627f71e79963 (diff)
implement 8- and 16-bit DSi AES register accesses
fixes NAND access through Godmode9i
Diffstat (limited to 'src')
-rw-r--r--src/DSi.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/DSi.cpp b/src/DSi.cpp
index 83f1b09..c1e87b9 100644
--- a/src/DSi.cpp
+++ b/src/DSi.cpp
@@ -2806,6 +2806,39 @@ void ARM7IOWrite8(u32 addr, u8 val)
return;
}
+ if (addr >= 0x04004420 && addr < 0x04004430)
+ {
+ u32 shift = (addr&3)*8;
+ addr -= 0x04004420;
+ addr &= ~3;
+ DSi_AES::WriteIV(addr, (u32)val << shift, 0xFF << shift);
+ return;
+ }
+ if (addr >= 0x04004430 && addr < 0x04004440)
+ {
+ u32 shift = (addr&3)*8;
+ addr -= 0x04004430;
+ addr &= ~3;
+ DSi_AES::WriteMAC(addr, (u32)val << shift, 0xFF << shift);
+ return;
+ }
+ if (addr >= 0x04004440 && addr < 0x04004500)
+ {
+ u32 shift = (addr&3)*8;
+ addr -= 0x04004440;
+ addr &= ~3;
+
+ int n = 0;
+ while (addr >= 0x30) { addr -= 0x30; n++; }
+
+ switch (addr >> 4)
+ {
+ case 0: DSi_AES::WriteKeyNormal(n, addr&0xF, (u32)val << shift, 0xFF << shift); return;
+ case 1: DSi_AES::WriteKeyX(n, addr&0xF, (u32)val << shift, 0xFF << shift); return;
+ case 2: DSi_AES::WriteKeyY(n, addr&0xF, (u32)val << shift, 0xFF << shift); return;
+ }
+ }
+
return NDS::ARM7IOWrite8(addr, val);
}
@@ -2849,6 +2882,39 @@ void ARM7IOWrite16(u32 addr, u16 val)
return;
}
+ if (addr >= 0x04004420 && addr < 0x04004430)
+ {
+ u32 shift = (addr&1)*16;
+ addr -= 0x04004420;
+ addr &= ~1;
+ DSi_AES::WriteIV(addr, (u32)val << shift, 0xFFFF << shift);
+ return;
+ }
+ if (addr >= 0x04004430 && addr < 0x04004440)
+ {
+ u32 shift = (addr&1)*16;
+ addr -= 0x04004430;
+ addr &= ~1;
+ DSi_AES::WriteMAC(addr, (u32)val << shift, 0xFFFF << shift);
+ return;
+ }
+ if (addr >= 0x04004440 && addr < 0x04004500)
+ {
+ u32 shift = (addr&1)*16;
+ addr -= 0x04004440;
+ addr &= ~1;
+
+ int n = 0;
+ while (addr >= 0x30) { addr -= 0x30; n++; }
+
+ switch (addr >> 4)
+ {
+ case 0: DSi_AES::WriteKeyNormal(n, addr&0xF, (u32)val << shift, 0xFFFF << shift); return;
+ case 1: DSi_AES::WriteKeyX(n, addr&0xF, (u32)val << shift, 0xFFFF << shift); return;
+ case 2: DSi_AES::WriteKeyY(n, addr&0xF, (u32)val << shift, 0xFFFF << shift); return;
+ }
+ }
+
if (addr >= 0x04004800 && addr < 0x04004A00)
{
SDMMC->Write(addr, val);