From c4acc26076dffc9b02094541be1c29434a7c1f36 Mon Sep 17 00:00:00 2001 From: Arisotura Date: Wed, 21 Sep 2022 18:53:49 +0200 Subject: [PATCH] fake enough of WEP processing to make Inazuma Eleven work --- src/NDS.cpp | 25 ++++++++++++++++++------- src/Wifi.cpp | 22 +++++++++++++++++++++- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/NDS.cpp b/src/NDS.cpp index d0d16745..5262059c 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -1977,7 +1977,7 @@ void debug(u32 param) // printf("VRAM %c: %02X\n", 'A'+i, GPU::VRAMCNT[i]); FILE* - shit = fopen("debug/tetrisDS.bin", "wb"); + shit = fopen("debug/inazuma.bin", "wb"); fwrite(ARM9->ITCM, 0x8000, 1, shit); for (u32 i = 0x02000000; i < 0x02400000; i+=4) { @@ -1989,6 +1989,11 @@ void debug(u32 param) u32 val = ARM7Read32(i); fwrite(&val, 4, 1, shit); } + for (u32 i = 0x06000000; i < 0x06040000; i+=4) + { + u32 val = ARM7Read32(i); + fwrite(&val, 4, 1, shit); + } fclose(shit); /*FILE* @@ -2974,7 +2979,8 @@ u8 ARM9IORead8(u32 addr) return (u8)(emuID[idx]); } - printf("unknown ARM9 IO read8 %08X %08X\n", addr, ARM9->R[15]); + if ((addr & 0xFFFFF000) != 0x04004000) + printf("unknown ARM9 IO read8 %08X %08X\n", addr, ARM9->R[15]); return 0; } @@ -3120,7 +3126,8 @@ u16 ARM9IORead16(u32 addr) return GPU3D::Read16(addr); } - printf("unknown ARM9 IO read16 %08X %08X\n", addr, ARM9->R[15]); + if ((addr & 0xFFFFF000) != 0x04004000) + printf("unknown ARM9 IO read16 %08X %08X\n", addr, ARM9->R[15]); return 0; } @@ -3263,7 +3270,8 @@ u32 ARM9IORead32(u32 addr) return GPU3D::Read32(addr); } - printf("unknown ARM9 IO read32 %08X %08X\n", addr, ARM9->R[15]); + if ((addr & 0xFFFFF000) != 0x04004000) + printf("unknown ARM9 IO read32 %08X %08X\n", addr, ARM9->R[15]); return 0; } @@ -3799,7 +3807,8 @@ u8 ARM7IORead8(u32 addr) return SPU::Read8(addr); } - printf("unknown ARM7 IO read8 %08X %08X\n", addr, ARM7->R[15]); + if ((addr & 0xFFFFF000) != 0x04004000) + printf("unknown ARM7 IO read8 %08X %08X\n", addr, ARM7->R[15]); return 0; } @@ -3892,7 +3901,8 @@ u16 ARM7IORead16(u32 addr) return SPU::Read16(addr); } - printf("unknown ARM7 IO read16 %08X %08X\n", addr, ARM7->R[15]); + if ((addr & 0xFFFFF000) != 0x04004000) + printf("unknown ARM7 IO read16 %08X %08X\n", addr, ARM7->R[15]); return 0; } @@ -3992,7 +4002,8 @@ u32 ARM7IORead32(u32 addr) return SPU::Read32(addr); } - printf("unknown ARM7 IO read32 %08X %08X\n", addr, ARM7->R[15]); + if ((addr & 0xFFFFF000) != 0x04004000) + printf("unknown ARM7 IO read32 %08X %08X\n", addr, ARM7->R[15]); return 0; } diff --git a/src/Wifi.cpp b/src/Wifi.cpp index 841fb969..c2614e73 100644 --- a/src/Wifi.cpp +++ b/src/Wifi.cpp @@ -839,6 +839,21 @@ bool ProcessTX(TXSlot* slot, int num) slot->CurPhase = 1; slot->CurPhaseTime = len; + u16 framectl = *(u16*)&RAM[slot->Addr + 0xC]; + if (framectl & (1<<14)) + { + // WEP frame + // TODO: what happens when sending a WEP frame while WEP processing is off? + // TODO: some form of actual WEP processing? + // for now we just set the WEP FCS to a nonzero value, because some games require it + + if (IOPORT(W_WEPCnt) & (1<<15)) + { + u32 wep_fcs = (slot->Addr + 0xC + slot->Length - 7) & ~0x1; + *(u32*)&RAM[wep_fcs] = 0x22334466; + } + } + u64 oldts; if (num == 4) { @@ -891,7 +906,6 @@ bool ProcessTX(TXSlot* slot, int num) // any packet sent via CMD/REPLY/BEACON isn't going to have much use outside of local MP if (num == 0 || num == 2 || num == 3) { - u16 framectl = *(u16*)&RAM[slot->Addr + 0xC]; if ((framectl & 0x00FF) == 0x0010) { u16 aid = *(u16*)&RAM[slot->Addr + 0xC + 24 + 4]; @@ -1401,7 +1415,10 @@ void MPClientReplyRX(int client) // TODO: what are the maximum crop values? u16 framectl = *(u16*)&reply[12]; if (framectl & (1<<14)) + { framelen -= (IOPORT(W_RXLenCrop) >> 7) & 0x1FE; + if (framelen > 24) memmove(&RXBuffer[12+24], &RXBuffer[12+28], framelen); + } else framelen -= (IOPORT(W_RXLenCrop) << 1) & 0x1FE; @@ -1470,7 +1487,10 @@ bool CheckRX(int type) // 0=regular 1=MP replies 2=MP host frames // TODO: what are the maximum crop values? if (framectl & (1<<14)) + { framelen -= (IOPORT(W_RXLenCrop) >> 7) & 0x1FE; + if (framelen > 24) memmove(&RXBuffer[12+24], &RXBuffer[12+28], framelen); + } else framelen -= (IOPORT(W_RXLenCrop) << 1) & 0x1FE;