From 9c1f5364ab3737c90cabd217f2324ebbba49059e Mon Sep 17 00:00:00 2001 From: Arisotura Date: Fri, 15 Apr 2022 20:31:18 +0200 Subject: [PATCH] attempting fun things --- src/DSi_Camera.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++ src/DSi_Camera.h | 3 +++ src/DSi_NDMA.cpp | 2 +- 3 files changed, 71 insertions(+), 1 deletion(-) diff --git a/src/DSi_Camera.cpp b/src/DSi_Camera.cpp index e83434f8..2c696b49 100644 --- a/src/DSi_Camera.cpp +++ b/src/DSi_Camera.cpp @@ -202,6 +202,8 @@ void DSi_Camera::ResetCam() ClocksCnt = 0; StandbyCnt = 0x4029; // checkme MiscCnt = 0; + + memset(MCURegs, 0, 0x8000); } bool DSi_Camera::IsActivated() @@ -287,6 +289,23 @@ u16 DSi_Camera::I2C_ReadReg(u16 addr) case 0x0018: return StandbyCnt; case 0x001A: return MiscCnt; + case 0x098C: return MCUAddr; + case 0x0990: + case 0x0992: + case 0x0994: + case 0x0996: + case 0x0998: + case 0x099A: + case 0x099C: + case 0x099E: + { + addr -= 0x0990; + u16 ret = MCU_Read((MCUAddr & 0x7FFF) + addr); + if (!(MCUAddr & (1<<15))) + ret |= (MCU_Read((MCUAddr & 0x7FFF) + addr+1) << 8); + return ret; + } + case 0x301A: return ((~StandbyCnt) & 0x4000) >> 12; } @@ -325,12 +344,60 @@ void DSi_Camera::I2C_WriteReg(u16 addr, u16 val) MiscCnt = val & 0x0B7B; printf("CAM%d MISCCNT=%04X (%04X)\n", Num, MiscCnt, val); return; + + case 0x098C: + MCUAddr = val; + return; + case 0x0990: + case 0x0992: + case 0x0994: + case 0x0996: + case 0x0998: + case 0x099A: + case 0x099C: + case 0x099E: + addr -= 0x0990; + MCU_Write((MCUAddr & 0x7FFF) + addr, val&0xFF); + if (!(MCUAddr & (1<<15))) + MCU_Write((MCUAddr & 0x7FFF) + addr+1, val>>8); + return; } if(Num==1)printf("DSi_Camera%d: unknown write %04X %04X\n", Num, addr, val); } +// TODO: not sure at all what is the accessible range +// or if there is any overlap in the address range + +u8 DSi_Camera::MCU_Read(u16 addr) +{ + addr &= 0x7FFF; + printf("CAM%d MCU READ %04X\n", Num, addr); + + return MCURegs[addr]; +} + +void DSi_Camera::MCU_Write(u16 addr, u8 val) +{ + addr &= 0x7FFF; + printf("CAM%d MCU WRITE %04X %02X\n", Num, addr, val); + + switch (addr) + { + case 0x2103: // SEQ_CMD + { + MCURegs[addr] = 0; + //MCURegs[0x2104] = 3; + } + return; + } + + MCURegs[addr] = val; +} + + + u8 DSi_Camera::Read8(u32 addr) { // diff --git a/src/DSi_Camera.h b/src/DSi_Camera.h index e5926bb0..3c0666ea 100644 --- a/src/DSi_Camera.h +++ b/src/DSi_Camera.h @@ -77,6 +77,9 @@ private: u8 MCURegs[0x8000]; + u8 MCU_Read(u16 addr); + void MCU_Write(u16 addr, u8 val); + static u16 ModuleCnt; static u16 Cnt; diff --git a/src/DSi_NDMA.cpp b/src/DSi_NDMA.cpp index 3c61e676..ca834eb1 100644 --- a/src/DSi_NDMA.cpp +++ b/src/DSi_NDMA.cpp @@ -132,7 +132,7 @@ void DSi_NDMA::WriteCnt(u32 val) // * microphone (ARM7 0C) // * NDS-wifi?? (ARM7 07, likely not working) - if (StartMode <= 0x03 || StartMode == 0x05 || (StartMode >= 0x0B && StartMode <= 0x0F) || + if (StartMode <= 0x03 || StartMode == 0x05 || (StartMode >= 0x0C && StartMode <= 0x0F) || (StartMode >= 0x20 && StartMode <= 0x23) || StartMode == 0x25 || StartMode == 0x27 || (StartMode >= 0x2C && StartMode <= 0x2F)) printf("UNIMPLEMENTED ARM%d NDMA%d START MODE %02X, %08X->%08X LEN=%d BLK=%d CNT=%08X\n", CPU?7:9, Num, StartMode, SrcAddr, DstAddr, TotalLength, BlockLength, Cnt);