aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArisotura <thetotalworm@gmail.com>2019-08-06 13:06:14 +0200
committerArisotura <thetotalworm@gmail.com>2019-08-06 13:06:14 +0200
commit28a9c7d9d1c44066e91664101362eab69ab12f4d (patch)
treead6c03ff08e8e044303caf9b3738e49c1870c378 /src
parent62a605cd9223e63ebeacc6f1270f98447592ebe8 (diff)
camera: enough stub to pass firmware init
Diffstat (limited to 'src')
-rw-r--r--src/DSi_Camera.cpp25
-rw-r--r--src/DSi_Camera.h3
-rw-r--r--src/DSi_I2C.cpp14
3 files changed, 34 insertions, 8 deletions
diff --git a/src/DSi_Camera.cpp b/src/DSi_Camera.cpp
index 66d08cb..45061b2 100644
--- a/src/DSi_Camera.cpp
+++ b/src/DSi_Camera.cpp
@@ -61,6 +61,9 @@ void DSi_Camera::ResetCam()
DataPos = 0;
RegAddr = 0;
RegData = 0;
+
+ PLLCnt = 0;
+ StandbyCnt = 0x4029; // checkme
}
@@ -130,7 +133,11 @@ u16 DSi_Camera::ReadReg(u16 addr)
{
switch (addr)
{
- case 0x301A: return 0x0002; // HAX
+ case 0x0000: return 0x2280; // chip ID
+ case 0x0014: return PLLCnt;
+ case 0x0018: return StandbyCnt;
+
+ case 0x301A: return ((~StandbyCnt) & 0x4000) >> 12;
}
printf("DSi_Camera%d: unknown read %04X\n", Num, addr);
@@ -139,5 +146,21 @@ u16 DSi_Camera::ReadReg(u16 addr)
void DSi_Camera::WriteReg(u16 addr, u16 val)
{
+ switch (addr)
+ {
+ case 0x0014:
+ // shouldn't be instant either?
+ val &= 0x7FFF;
+ val |= ((val & 0x0002) << 14);
+ PLLCnt = val;
+ return;
+ case 0x0018:
+ // TODO: this shouldn't be instant, but uh
+ val &= 0x003F;
+ val |= ((val & 0x0001) << 14);
+ StandbyCnt = val;
+ return;
+ }
+
printf("DSi_Camera%d: unknown write %04X %04X\n", Num, addr, val);
}
diff --git a/src/DSi_Camera.h b/src/DSi_Camera.h
index eba35cb..78629b5 100644
--- a/src/DSi_Camera.h
+++ b/src/DSi_Camera.h
@@ -46,6 +46,9 @@ private:
u16 ReadReg(u16 addr);
void WriteReg(u16 addr, u16 val);
+
+ u16 PLLCnt;
+ u16 StandbyCnt;
};
diff --git a/src/DSi_I2C.cpp b/src/DSi_I2C.cpp
index 907d0ef..ffb724f 100644
--- a/src/DSi_I2C.cpp
+++ b/src/DSi_I2C.cpp
@@ -156,7 +156,7 @@ void Reset()
void WriteCnt(u8 val)
{
- //printf("I2C: write CNT %02X\n", val);
+ //printf("I2C: write CNT %02X, %08X\n", val, NDS::GetPC(1));
// TODO: check ACK flag
// TODO: transfer delay
@@ -179,11 +179,11 @@ void WriteCnt(u8 val)
case 0x7A: Data = DSi_Camera1->Read(islast); break;
default:
printf("I2C: read on unknown device %02X, cnt=%02X, data=%02X, last=%d\n", Device, val, 0, islast);
- Data = 0;
+ Data = 0xFF;
break;
}
- printf("I2C read, device=%02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast);
+ //printf("I2C read, device=%02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast);
}
else
{
@@ -194,7 +194,7 @@ void WriteCnt(u8 val)
if (val & (1<<1))
{
Device = Data & 0xFE;
- printf("I2C: %s start, device=%02X\n", (Data&0x01)?"read":"write", Device);
+ //printf("I2C: %s start, device=%02X\n", (Data&0x01)?"read":"write", Device);
switch (Device)
{
@@ -203,13 +203,13 @@ void WriteCnt(u8 val)
case 0x7A: DSi_Camera1->Start(); break;
default:
printf("I2C: %s start on unknown device %02X\n", (Data&0x01)?"read":"write", Device);
- ack = false;
+ //ack = false;
break;
}
}
else
{
- printf("I2C write, device=%02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast);
+ //printf("I2C write, device=%02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast);
switch (Device)
{
@@ -218,7 +218,7 @@ void WriteCnt(u8 val)
case 0x7A: DSi_Camera1->Write(Data, islast); break;
default:
printf("I2C: write on unknown device %02X, cnt=%02X, data=%02X, last=%d\n", Device, val, Data, islast);
- ack = false;
+ //ack = false;
break;
}
}