force-align all read/write accesses. fixes #1540 (unaligned DMA address)

This commit is contained in:
Arisotura 2022-10-22 13:11:57 +02:00
parent b6776bd826
commit dd74e936ed
2 changed files with 33 additions and 1 deletions

View File

@ -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:

View File

@ -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: