From 734a557da51bc30d0e18433fd0cffb68e4926e73 Mon Sep 17 00:00:00 2001 From: dborth Date: Mon, 6 Apr 2009 07:27:40 +0000 Subject: [PATCH] save state screenshots, fix video --- source/ngc/fceustate.cpp | 42 +++++++++++++++++++++++++++++++------- source/ngc/gcvideo.cpp | 11 ++++------ source/ngc/preferences.cpp | 2 +- 3 files changed, 40 insertions(+), 15 deletions(-) diff --git a/source/ngc/fceustate.cpp b/source/ngc/fceustate.cpp index 6fb21d5..9095162 100644 --- a/source/ngc/fceustate.cpp +++ b/source/ngc/fceustate.cpp @@ -17,6 +17,8 @@ #include #include #include +#include "pngu/pngu.h" + #include "types.h" #include "state.h" #include "x6502.h" @@ -26,6 +28,7 @@ #include "filebrowser.h" #include "memcardop.h" #include "fileop.h" +#include "gcvideo.h" extern "C" { /*** External functions ***/ @@ -296,6 +299,7 @@ bool SaveState (char * filepath, int method, bool silent) bool retval = false; int datasize; int offset = 0; + int imgSize = 0; // image screenshot bytes written if(method == METHOD_AUTO) method = autoSaveMethod(silent); @@ -320,15 +324,39 @@ bool SaveState (char * filepath, int method, bool silent) } offset = SaveFile(filepath, datasize, method, silent); - - if (offset > 0) - { - if ( !silent ) - InfoPrompt("Save successful"); - retval = true; - } } FreeSaveBuffer (); + + // save screenshot - I would prefer to do this from gameScreenTex + if(gameScreenTex2 != NULL && method != METHOD_MC_SLOTA && method != METHOD_MC_SLOTB) + { + AllocSaveBuffer (); + + IMGCTX pngContext = PNGU_SelectImageFromBuffer(savebuffer); + + if (pngContext != NULL) + { + imgSize = PNGU_EncodeFromGXTexture(pngContext, 640, 480, gameScreenTex2, 0); + PNGU_ReleaseImageContext(pngContext); + } + + if(imgSize > 0) + { + char screenpath[1024]; + filepath[strlen(filepath)-4] = 0; + sprintf(screenpath, "%s.png", filepath); + SaveFile(screenpath, imgSize, method, silent); + } + + FreeSaveBuffer (); + } + + if (offset > 0) + { + if (!silent) + InfoPrompt("Save successful"); + retval = true; + } return retval; } diff --git a/source/ngc/gcvideo.cpp b/source/ngc/gcvideo.cpp index 161af28..a7c4b2f 100644 --- a/source/ngc/gcvideo.cpp +++ b/source/ngc/gcvideo.cpp @@ -242,10 +242,8 @@ vbgetback (void *arg) { while (1) { - /*if(GCSettings.timing != vmode_60hz) - VIDEO_WaitVSync(); - else*/ - SyncSpeed(); + VIDEO_WaitVSync(); + SyncSpeed(); LWP_SuspendThread (vbthread); } @@ -265,7 +263,7 @@ InitVideoThread () LWP_InitQueue (&videoblankqueue); /*** Create the thread on this queue ***/ - LWP_CreateThread (&vbthread, vbgetback, NULL, vbstack, TSTACK, 77); + LWP_CreateThread (&vbthread, vbgetback, NULL, vbstack, TSTACK, 100); } /**************************************************************************** @@ -744,13 +742,12 @@ void RenderFrame(unsigned char *XBuf) // load texture into GX DCFlushRange(texturemem, TEX_WIDTH * TEX_HEIGHT * 2); GX_LoadTexObj (&texobj, GX_TEXMAP0); - GX_InvalidateTexAll(); // render textured quad draw_square(view); GX_DrawDone(); - // EFB is ready to be coied into XFB + // EFB is ready to be copied into XFB VIDEO_SetNextFramebuffer(xfb[whichfb]); VIDEO_Flush(); copynow = GX_TRUE; diff --git a/source/ngc/preferences.cpp b/source/ngc/preferences.cpp index d5571a2..9ec1253 100644 --- a/source/ngc/preferences.cpp +++ b/source/ngc/preferences.cpp @@ -258,7 +258,7 @@ decodePrefsData (int method) verMinor >= 0 && verMinor <= 9 && verPoint >= 0 && verPoint <= 9)) result = false; - else if(verMajor == 2 && verPoint < 7) // less than version 2.0.7 + else if(verMajor <= 3) // less than version 3.0.0 result = false; // reset settings else if(verMajor > curMajor || verMinor > curMinor || verPoint > curPoint) // some future version result = false; // reset settings