Skip to content

Commit

Permalink
SKETCH: adds more debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Oct 25, 2022
1 parent 87ea711 commit 3208495
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Engine/ac/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,22 +917,28 @@ void render_to_screen()
gfxDriver->SetVsync((scsystem.vsync > 0) && (!scsystem.windowed));

bool succeeded = false;
Debug::Printf("render_to_screen: will while (!succeeded<%d> && !want_exit<%d> && !abort_engine<%d>)", succeeded, want_exit, abort_engine);
while (!succeeded && !want_exit && !abort_engine)
{
try
{
// For software renderer, need to blacken upper part of the game frame when shaking screen moves image down
const Rect &viewport = play.GetMainViewport();
if (play.shake_screen_yoff > 0 && !gfxDriver->RequiresFullRedrawEachFrame())
if (play.shake_screen_yoff > 0 && !gfxDriver->RequiresFullRedrawEachFrame()) {
Debug::Printf("render_to_screen: gfxDriver->ClearRectangle()");
gfxDriver->ClearRectangle(viewport.Left, viewport.Top, viewport.GetWidth() - 1, play.shake_screen_yoff, nullptr);
}
Debug::Printf("render_to_screen: gfxDriver->Render()");
gfxDriver->Render(0, play.shake_screen_yoff, (GraphicFlip)play.screen_flipped);
succeeded = true;
}
catch (Ali3DFullscreenLostException e)
{
Debug::Printf("Renderer exception: %s", e.Message.GetCStr());
Debug::Printf("render_to_screen: will while (game_update_suspend<%d> && !want_exit<%d> && !abort_engine<%d>)", game_update_suspend, want_exit, abort_engine);
while (game_update_suspend && (!want_exit) && (!abort_engine))
{
Debug::Printf("render_to_screen: sys_evt_process_pending()");
sys_evt_process_pending();
platform->Delay(300);
}
Expand Down
7 changes: 6 additions & 1 deletion Engine/ac/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,15 +1332,20 @@ void display_switch_in_resume()
ch->resume();
}
}
Debug::Printf("display_switch_in_resume: video_resume()");
video_resume();

// clear the screen if necessary
if (gfxDriver && gfxDriver->UsesMemoryBackBuffer())
if (gfxDriver && gfxDriver->UsesMemoryBackBuffer()) {
Debug::Printf("display_switch_in_resume: before gfxDriver->ClearRectangle(0, 0, %d, %d)", game.GetGameRes().Width - 1, game.GetGameRes().Height - 1);
gfxDriver->ClearRectangle(0, 0, game.GetGameRes().Width - 1, game.GetGameRes().Height - 1, nullptr);
Debug::Printf("display_switch_in_resume: after gfxDriver->ClearRectangle(0, 0, %d, %d)", game.GetGameRes().Width - 1, game.GetGameRes().Height - 1);
}

// TODO: find out if anything has to be done here for SDL backend

platform->ResumeApplication();
Debug::Printf("display_switch_in_resume: game_update_suspend = false");
game_update_suspend = false;
}

Expand Down
7 changes: 7 additions & 0 deletions Engine/platform/windows/gfx/ali3dd3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,27 @@ void D3DGraphicsDriver::SetGamma(int newGamma)
void D3DGraphicsDriver::ResetDeviceIfNecessary()
{
HRESULT hr = direct3ddevice->TestCooperativeLevel();

Debug::Printf("ResetDeviceIfNecessary: %ld = direct3ddevice->TestCooperativeLevel()", hr);
if (hr == D3DERR_DEVICELOST)
{
Debug::Printf("ResetDeviceIfNecessary: throw Ali3DFullscreenLostException()");
throw Ali3DFullscreenLostException();
}

if (hr == D3DERR_DEVICENOTRESET)
{
hr = ResetD3DDevice();
Debug::Printf("ResetDeviceIfNecessary: after %ld = ResetD3DDevice()", hr);
if (hr != D3D_OK)
{
Debug::Printf("ResetDeviceIfNecessary: throw Ali3DException()");
throw Ali3DException(String::FromFormat("IDirect3DDevice9::Reset: failed: error code: 0x%08X", hr));
}

Debug::Printf("ResetDeviceIfNecessary: InitializeD3DState()");
InitializeD3DState();
Debug::Printf("ResetDeviceIfNecessary: CreateVirtualScreen()");
CreateVirtualScreen();
direct3ddevice->SetGammaRamp(0, D3DSGR_NO_CALIBRATION, &currentgammaramp);
}
Expand Down

0 comments on commit 3208495

Please sign in to comment.