basic provision for feeding external pictures to the cameras

This commit is contained in:
Arisotura 2022-04-17 14:53:57 +02:00 committed by Nadia Holmquist Pedersen
parent 59a5923463
commit ee61062aa1
5 changed files with 49 additions and 1 deletions

View File

@ -758,6 +758,30 @@ void Camera::MCU_Write(u16 addr, u8 val)
MCURegs[addr] = val; MCURegs[addr] = val;
} }
void Camera::InputFrame(u32* data, int width, int height)
{
// TODO: double-buffering?
if (width == 640 && height == 480)
{
memcpy(FrameBuffer, data, 640*480*sizeof(u32));
return;
}
for (int dy = 0; dy < 480; dy++)
{
int sy = (dy * height) / 480;
for (int dx = 0; dx < 640; dx++)
{
int sx = (dx * width) / 640;
FrameBuffer[dy*640 + dx] = data[sy*width + sx];
}
}
}
} }

View File

@ -68,6 +68,8 @@ public:
u8 I2C_Read(bool last); u8 I2C_Read(bool last);
void I2C_Write(u8 val, bool last); void I2C_Write(u8 val, bool last);
void InputFrame(u32* data, int width, int height);
u32 Num; u32 Num;
private: private:

View File

@ -1261,6 +1261,21 @@ void SetLidClosed(bool closed)
} }
} }
void CamInputFrame(int cam, u32* data, int width, int height)
{
// TODO: support things like the GBA-slot camera addon
// whenever these are emulated
if (ConsoleType == 1)
{
switch (cam)
{
case 0: return DSi_CamModule::Camera0->InputFrame(data, width, height);
case 1: return DSi_CamModule::Camera1->InputFrame(data, width, height);
}
}
}
void MicInputFrame(s16* data, int samples) void MicInputFrame(s16* data, int samples)
{ {
return SPI_TSC::MicInputFrame(data, samples); return SPI_TSC::MicInputFrame(data, samples);

View File

@ -260,6 +260,7 @@ void SetKeyMask(u32 mask);
bool IsLidClosed(); bool IsLidClosed();
void SetLidClosed(bool closed); void SetLidClosed(bool closed);
void CamInputFrame(int cam, u32* data, int width, int height);
void MicInputFrame(s16* data, int samples); void MicInputFrame(s16* data, int samples);
void ScheduleEvent(u32 id, bool periodic, s32 delay, void (*func)(u32), u32 param); void ScheduleEvent(u32 id, bool periodic, s32 delay, void (*func)(u32), u32 param);

View File

@ -430,6 +430,9 @@ void EmuThread::run()
char melontitle[100]; char melontitle[100];
QImage testimg("test.jpg");
QImage testimg_conv = testimg.convertToFormat(QImage::Format_RGB32);
while (EmuRunning != 0) while (EmuRunning != 0)
{ {
Input::Process(); Input::Process();
@ -510,6 +513,9 @@ void EmuThread::run()
OSD::AddMessage(0, lid ? "Lid closed" : "Lid opened"); OSD::AddMessage(0, lid ? "Lid closed" : "Lid opened");
} }
// camera input test
NDS::CamInputFrame(0, (u32*)testimg_conv.bits(), testimg_conv.width(), testimg_conv.height());
// microphone input // microphone input
micProcess(); micProcess();
@ -1834,7 +1840,7 @@ void MainWindow::keyPressEvent(QKeyEvent* event)
if (event->isAutoRepeat()) return; if (event->isAutoRepeat()) return;
// TODO!! REMOVE ME IN RELEASE BUILDS!! // TODO!! REMOVE ME IN RELEASE BUILDS!!
//if (event->key() == Qt::Key_F11) NDS::debug(0); if (event->key() == Qt::Key_F11) NDS::debug(0);
Input::KeyPress(event); Input::KeyPress(event);
} }