mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 07:10:00 -06:00
Revert "camera: model FIFO more accurately (avoids weird bugs when DMA fails)"
This reverts commit 2cb07bf126
.
This commit is contained in:
@ -67,7 +67,9 @@ void DSi_CamModule::Reset()
|
||||
CropStart = 0;
|
||||
CropEnd = 0;
|
||||
|
||||
DataBuffer.Clear();
|
||||
memset(DataBuffer, 0, 512*sizeof(u32));
|
||||
BufferReadPos = 0;
|
||||
BufferWritePos = 0;
|
||||
BufferNumLines = 0;
|
||||
CurCamera = nullptr;
|
||||
|
||||
@ -87,8 +89,6 @@ void DSi_CamModule::DoSavestate(Savestate* file)
|
||||
file->Var16(&ModuleCnt);
|
||||
file->Var16(&Cnt);
|
||||
|
||||
// TODO: should other stuff be savestated? (pixel buffer, etc)
|
||||
|
||||
/*file->VarArray(FrameBuffer, sizeof(FrameBuffer));
|
||||
file->Var32(&TransferPos);
|
||||
file->Var32(&FrameLength);*/
|
||||
@ -113,6 +113,8 @@ void DSi_CamModule::IRQ(u32 param)
|
||||
|
||||
if (Cnt & (1<<15))
|
||||
{
|
||||
BufferReadPos = 0;
|
||||
BufferWritePos = 0;
|
||||
BufferNumLines = 0;
|
||||
CurCamera = activecam;
|
||||
DSi.ScheduleEvent(Event_DSi_CamTransfer, false, kTransferStart, 0, 0);
|
||||
@ -124,10 +126,8 @@ void DSi_CamModule::IRQ(u32 param)
|
||||
|
||||
void DSi_CamModule::TransferScanline(u32 line)
|
||||
{
|
||||
if (Cnt & (1<<4))
|
||||
return;
|
||||
|
||||
int maxlen = DataBuffer.FreeSpace();
|
||||
u32* dstbuf = &DataBuffer[BufferWritePos];
|
||||
int maxlen = 512 - BufferWritePos;
|
||||
|
||||
u32 tmpbuf[512];
|
||||
int lines_next;
|
||||
@ -195,28 +195,28 @@ void DSi_CamModule::TransferScanline(u32 line)
|
||||
u32 col1 = (r1 >> 3) | ((g1 >> 3) << 5) | ((b1 >> 3) << 10) | 0x8000;
|
||||
u32 col2 = (r2 >> 3) | ((g2 >> 3) << 5) | ((b2 >> 3) << 10) | 0x8000;
|
||||
|
||||
DataBuffer.Write(col1 | (col2 << 16));
|
||||
dstbuf[i] = col1 | (col2 << 16);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// return raw data
|
||||
|
||||
for (u32 i = 0; i < copylen; i++)
|
||||
{
|
||||
u32 val = tmpbuf[copystart + i];
|
||||
DataBuffer.Write(val);
|
||||
}
|
||||
memcpy(dstbuf, &tmpbuf[copystart], copylen*sizeof(u32));
|
||||
}
|
||||
|
||||
numscan = Cnt & 0x000F;
|
||||
if (BufferNumLines >= numscan)
|
||||
{
|
||||
BufferReadPos = 0; // checkme
|
||||
BufferWritePos = 0;
|
||||
BufferNumLines = 0;
|
||||
DSi.CheckNDMAs(0, 0x0B);
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferWritePos += copylen;
|
||||
if (BufferWritePos > 512) BufferWritePos = 512;
|
||||
BufferNumLines++;
|
||||
}
|
||||
|
||||
@ -225,9 +225,10 @@ skip_line:
|
||||
{
|
||||
// when the frame is finished, transfer any remaining data if needed
|
||||
// (if the frame height isn't a multiple of the DMA interval)
|
||||
// (TODO: should it be done earlier?)
|
||||
if (BufferNumLines > 0)
|
||||
{
|
||||
BufferReadPos = 0;
|
||||
BufferWritePos = 0;
|
||||
BufferNumLines = 0;
|
||||
DSi.CheckNDMAs(0, 0x0B);
|
||||
}
|
||||
@ -265,19 +266,14 @@ u32 DSi_CamModule::Read32(u32 addr)
|
||||
{
|
||||
case 0x04004204:
|
||||
{
|
||||
u32 ret;
|
||||
u32 ret = DataBuffer[BufferReadPos];
|
||||
if (Cnt & (1<<15))
|
||||
{
|
||||
if (DataBuffer.IsEmpty())
|
||||
{
|
||||
ret = 0;
|
||||
Cnt |= (1<<4);
|
||||
}
|
||||
else
|
||||
ret = DataBuffer.Read();
|
||||
if (BufferReadPos < 511)
|
||||
BufferReadPos++;
|
||||
// CHECKME!!!!
|
||||
// also presumably we should set bit4 in Cnt if there's no new data to be read
|
||||
}
|
||||
else
|
||||
ret = DataBuffer.Peek();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -343,7 +339,8 @@ void DSi_CamModule::Write16(u32 addr, u16 val)
|
||||
if (val & (1<<5))
|
||||
{
|
||||
Cnt &= ~(1<<4);
|
||||
DataBuffer.Clear();
|
||||
BufferReadPos = 0;
|
||||
BufferWritePos = 0;
|
||||
}
|
||||
|
||||
if ((val & (1<<15)) && !(Cnt & (1<<15)))
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include "types.h"
|
||||
#include "Savestate.h"
|
||||
#include "DSi_I2C.h"
|
||||
#include "FIFO.h"
|
||||
|
||||
namespace melonDS
|
||||
{
|
||||
@ -120,7 +119,8 @@ private:
|
||||
u32 CropStart, CropEnd;
|
||||
|
||||
// pixel data buffer holds a maximum of 512 words, regardless of how long scanlines are
|
||||
FIFO<u32, 512> DataBuffer;
|
||||
u32 DataBuffer[512];
|
||||
u32 BufferReadPos, BufferWritePos;
|
||||
u32 BufferNumLines;
|
||||
DSi_Camera* CurCamera;
|
||||
|
||||
|
@ -90,7 +90,6 @@ public:
|
||||
}
|
||||
|
||||
u32 Level() const { return NumOccupied; }
|
||||
u32 FreeSpace() const { return NumEntries - NumOccupied; }
|
||||
bool IsEmpty() const { return NumOccupied == 0; }
|
||||
bool IsFull() const { return NumOccupied >= NumEntries; }
|
||||
|
||||
|
@ -979,7 +979,7 @@ void MainWindow::keyPressEvent(QKeyEvent* event)
|
||||
if (event->isAutoRepeat()) return;
|
||||
|
||||
// TODO!! REMOVE ME IN RELEASE BUILDS!!
|
||||
//if (event->key() == Qt::Key_F11) emuInstance->getNDS()->debug(0);
|
||||
//if (event->key() == Qt::Key_F11) emuThread->NDS->debug(0);
|
||||
|
||||
emuInstance->onKeyPress(event);
|
||||
}
|
||||
|
Reference in New Issue
Block a user