attempting fun things

This commit is contained in:
Arisotura 2022-04-15 20:31:18 +02:00 committed by Nadia Holmquist Pedersen
parent 2ba7f961a6
commit 9c1f5364ab
3 changed files with 71 additions and 1 deletions

View File

@ -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)
{
//

View File

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

View File

@ -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);