Skip to content

Commit

Permalink
properly stop any started cameras upon reset/shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Arisotura committed Oct 2, 2022
1 parent 62879c4 commit 571d1c4
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/DSi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ void Reset()
GPU::DispStat[1] |= (1<<6);
}

void Stop()
{
DSi_CamModule::Stop();
}

void DoSavestate(Savestate* file)
{
file->Section("DSIG");
Expand Down
1 change: 1 addition & 0 deletions src/DSi.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ extern u32 NWRAMMask[2][3];
bool Init();
void DeInit();
void Reset();
void Stop();

void DoSavestate(Savestate* file);

Expand Down
13 changes: 13 additions & 0 deletions src/DSi_Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ void Reset()
NDS::ScheduleEvent(NDS::Event_DSi_CamIRQ, true, kIRQInterval, IRQ, 0);
}

void Stop()
{
Camera0->Stop();
Camera1->Stop();
}

void DoSavestate(Savestate* file)
{
file->Section("CAMi");
Expand Down Expand Up @@ -418,6 +424,8 @@ void Camera::DoSavestate(Savestate* file)

void Camera::Reset()
{
Platform::Camera_Stop(Num);

DataPos = 0;
RegAddr = 0;
RegData = 0;
Expand All @@ -439,6 +447,11 @@ void Camera::Reset()
memset(FrameBuffer, 0, (640*480/2)*sizeof(u32));
}

void Camera::Stop()
{
Platform::Camera_Stop(Num);
}

bool Camera::IsActivated()
{
if (StandbyCnt & (1<<14)) return false; // standby
Expand Down
2 changes: 2 additions & 0 deletions src/DSi_Camera.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ extern Camera* Camera1;
bool Init();
void DeInit();
void Reset();
void Stop();

void DoSavestate(Savestate* file);

Expand All @@ -56,6 +57,7 @@ class Camera
void DoSavestate(Savestate* file);

void Reset();
void Stop();
bool IsActivated();

void StartTransfer();
Expand Down
3 changes: 3 additions & 0 deletions src/NDS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,9 @@ void Stop()
Platform::StopEmu();
GPU::Stop();
SPU::Stop();

if (ConsoleType == 1)
DSi::Stop();
}

bool DoSavestate_Scheduler(Savestate* file)
Expand Down

0 comments on commit 571d1c4

Please sign in to comment.