diff options
author | Arisotura <thetotalworm@gmail.com> | 2022-10-22 13:11:57 +0200 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2022-10-22 13:11:57 +0200 |
commit | dd74e936ed69c7267ebb3f6d58634bd68cf7f642 (patch) | |
tree | f44078f59b89dc261e88e9b7bf8ff30d8090c1f1 /src | |
parent | b6776bd826fbe31c62a7222d34cf387fb6f3d260 (diff) |
force-align all read/write accesses. fixes #1540 (unaligned DMA address)
Diffstat (limited to 'src')
-rw-r--r-- | src/DSi.cpp | 16 | ||||
-rw-r--r-- | src/NDS.cpp | 18 |
2 files changed, 33 insertions, 1 deletions
diff --git a/src/DSi.cpp b/src/DSi.cpp index a4379dd..59d1c05 100644 --- a/src/DSi.cpp +++ b/src/DSi.cpp @@ -1283,6 +1283,8 @@ u8 ARM9Read8(u32 addr) u16 ARM9Read16(u32 addr) { + addr &= ~0x1; + if ((addr >= 0xFFFF0000) && (!(SCFG_BIOS & (1<<1)))) { if ((addr >= 0xFFFF8000) && (SCFG_BIOS & (1<<0))) @@ -1331,6 +1333,8 @@ u16 ARM9Read16(u32 addr) u32 ARM9Read32(u32 addr) { + addr &= ~0x3; + if ((addr >= 0xFFFF0000) && (!(SCFG_BIOS & (1<<1)))) { if ((addr >= 0xFFFF8000) && (SCFG_BIOS & (1<<0))) @@ -1488,6 +1492,8 @@ void ARM9Write8(u32 addr, u8 val) void ARM9Write16(u32 addr, u16 val) { + addr &= ~0x1; + switch (addr & 0xFF000000) { case 0x03000000: @@ -1578,6 +1584,8 @@ void ARM9Write16(u32 addr, u16 val) void ARM9Write32(u32 addr, u32 val) { + addr &= ~0x3; + switch (addr & 0xFF000000) { case 0x03000000: @@ -1763,6 +1771,8 @@ u8 ARM7Read8(u32 addr) u16 ARM7Read16(u32 addr) { + addr &= ~0x1; + if ((addr < 0x00010000) && (!(SCFG_BIOS & (1<<9)))) { if ((addr >= 0x00008000) && (SCFG_BIOS & (1<<8))) @@ -1820,6 +1830,8 @@ u16 ARM7Read16(u32 addr) u32 ARM7Read32(u32 addr) { + addr &= ~0x3; + if ((addr < 0x00010000) && (!(SCFG_BIOS & (1<<9)))) { if ((addr >= 0x00008000) && (SCFG_BIOS & (1<<8))) @@ -1972,6 +1984,8 @@ void ARM7Write8(u32 addr, u8 val) void ARM7Write16(u32 addr, u16 val) { + addr &= ~0x1; + switch (addr & 0xFF800000) { case 0x03000000: @@ -2067,6 +2081,8 @@ void ARM7Write16(u32 addr, u16 val) void ARM7Write32(u32 addr, u32 val) { + addr &= ~0x3; + switch (addr & 0xFF800000) { case 0x03000000: diff --git a/src/NDS.cpp b/src/NDS.cpp index 966b252..60f7731 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -1995,7 +1995,7 @@ void debug(u32 param) // printf("VRAM %c: %02X\n", 'A'+i, GPU::VRAMCNT[i]); FILE* - shit = fopen("debug/inazuma.bin", "wb"); + shit = fopen("debug/crayon.bin", "wb"); fwrite(ARM9->ITCM, 0x8000, 1, shit); for (u32 i = 0x02000000; i < 0x02400000; i+=4) { @@ -2093,6 +2093,8 @@ u8 ARM9Read8(u32 addr) u16 ARM9Read16(u32 addr) { + addr &= ~0x1; + if ((addr & 0xFFFFF000) == 0xFFFF0000) { return *(u16*)&ARM9BIOS[addr & 0xFFF]; @@ -2151,6 +2153,8 @@ u16 ARM9Read16(u32 addr) u32 ARM9Read32(u32 addr) { + addr &= ~0x3; + if ((addr & 0xFFFFF000) == 0xFFFF0000) { return *(u32*)&ARM9BIOS[addr & 0xFFF]; @@ -2255,6 +2259,8 @@ void ARM9Write8(u32 addr, u8 val) void ARM9Write16(u32 addr, u16 val) { + addr &= ~0x1; + switch (addr & 0xFF000000) { case 0x02000000: @@ -2319,6 +2325,8 @@ void ARM9Write16(u32 addr, u16 val) void ARM9Write32(u32 addr, u32 val) { + addr &= ~0x3; + switch (addr & 0xFF000000) { case 0x02000000: @@ -2484,6 +2492,8 @@ u8 ARM7Read8(u32 addr) u16 ARM7Read16(u32 addr) { + addr &= ~0x1; + if (addr < 0x00004000) { if (ARM7->R[15] >= 0x00004000) @@ -2548,6 +2558,8 @@ u16 ARM7Read16(u32 addr) u32 ARM7Read32(u32 addr) { + addr &= ~0x3; + if (addr < 0x00004000) { if (ARM7->R[15] >= 0x00004000) @@ -2682,6 +2694,8 @@ void ARM7Write8(u32 addr, u8 val) void ARM7Write16(u32 addr, u16 val) { + addr &= ~0x1; + switch (addr & 0xFF800000) { case 0x02000000: @@ -2760,6 +2774,8 @@ void ARM7Write16(u32 addr, u16 val) void ARM7Write32(u32 addr, u32 val) { + addr &= ~0x3; + switch (addr & 0xFF800000) { case 0x02000000: |