mirror of
https://github.com/dborth/fceugx.git
synced 2025-01-10 07:39:39 +01:00
improved pixel rendering
This commit is contained in:
parent
fb508312c7
commit
e27bc00241
@ -37,7 +37,6 @@ bool SaveState (char * filepath, bool silent)
|
|||||||
if(!FindDevice(filepath, &device))
|
if(!FindDevice(filepath, &device))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// save screenshot - I would prefer to do this from gameScreenTex
|
|
||||||
if(gameScreenPngSize > 0)
|
if(gameScreenPngSize > 0)
|
||||||
{
|
{
|
||||||
char screenpath[1024];
|
char screenpath[1024];
|
||||||
|
@ -57,7 +57,6 @@ static unsigned char texturemem[TEX_WIDTH * TEX_HEIGHT * 4] ATTRIBUTE_ALIGN (32)
|
|||||||
static int UpdateVideo = 1;
|
static int UpdateVideo = 1;
|
||||||
static bool vmode_60hz = true;
|
static bool vmode_60hz = true;
|
||||||
|
|
||||||
u8 * gameScreenTex = NULL; // a GX texture screen capture of the game
|
|
||||||
u8 * gameScreenPng = NULL;
|
u8 * gameScreenPng = NULL;
|
||||||
int gameScreenPngSize = 0;
|
int gameScreenPngSize = 0;
|
||||||
|
|
||||||
@ -191,6 +190,8 @@ static GXRModeObj NTSC_240p =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static GXRModeObj TV_Custom;
|
||||||
|
|
||||||
/* TV Modes table */
|
/* TV Modes table */
|
||||||
static GXRModeObj *tvmodes[2] = {
|
static GXRModeObj *tvmodes[2] = {
|
||||||
&NTSC_240p, &PAL_240p
|
&NTSC_240p, &PAL_240p
|
||||||
@ -411,7 +412,7 @@ UpdateScaling()
|
|||||||
}
|
}
|
||||||
else // unfiltered and filtered mode
|
else // unfiltered and filtered mode
|
||||||
{
|
{
|
||||||
xscale = vmode->fbWidth / 2;
|
xscale = 256;
|
||||||
yscale = vmode->efbHeight / 2;
|
yscale = vmode->efbHeight / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -625,6 +626,14 @@ ResetVideo_Emu ()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
rmode = FindVideoMode();
|
rmode = FindVideoMode();
|
||||||
|
|
||||||
|
if (!GCSettings.widescreen)
|
||||||
|
{
|
||||||
|
memcpy(&TV_Custom, rmode, sizeof(TV_Custom));
|
||||||
|
rmode = &TV_Custom;
|
||||||
|
rmode->fbWidth = 512;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateSampleRate(48130);
|
UpdateSampleRate(48130);
|
||||||
SetSampleRate();
|
SetSampleRate();
|
||||||
}
|
}
|
||||||
@ -641,7 +650,7 @@ ResetVideo_Emu ()
|
|||||||
|
|
||||||
GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight);
|
GX_SetDispCopySrc (0, 0, rmode->fbWidth, rmode->efbHeight);
|
||||||
GX_SetDispCopyDst (rmode->fbWidth, rmode->xfbHeight);
|
GX_SetDispCopyDst (rmode->fbWidth, rmode->xfbHeight);
|
||||||
GX_SetCopyFilter (rmode->aa, rmode->sample_pattern, (GCSettings.render == 1) ? GX_TRUE : GX_FALSE, rmode->vfilter); // deflicker ON only for filtered mode
|
GX_SetCopyFilter(rmode->aa, rmode->sample_pattern, (rmode->xfbMode == VI_XFBMODE_SF) ? GX_FALSE : GX_TRUE, rmode->vfilter);
|
||||||
|
|
||||||
GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
GX_SetFieldMode (rmode->field_rendering, ((rmode->viHeight == 2 * rmode->xfbHeight) ? GX_ENABLE : GX_DISABLE));
|
||||||
|
|
||||||
@ -919,16 +928,15 @@ void RenderStereoFrames(unsigned char *XBufLeft, unsigned char *XBufRight)
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
void TakeScreenshot()
|
void TakeScreenshot()
|
||||||
{
|
{
|
||||||
int texSize = vmode->fbWidth * vmode->efbHeight * 4;
|
IMGCTX pngContext = PNGU_SelectImageFromBuffer(savebuffer);
|
||||||
|
|
||||||
if(gameScreenTex) free(gameScreenTex);
|
if (pngContext != NULL)
|
||||||
gameScreenTex = (u8 *)memalign(32, texSize);
|
{
|
||||||
if(gameScreenTex == NULL) return;
|
gameScreenPngSize = PNGU_EncodeFromEFB(pngContext, vmode->fbWidth, vmode->efbHeight);
|
||||||
GX_SetTexCopySrc(0, 0, vmode->fbWidth, vmode->efbHeight);
|
PNGU_ReleaseImageContext(pngContext);
|
||||||
GX_SetTexCopyDst(vmode->fbWidth, vmode->efbHeight, GX_TF_RGBA8, GX_FALSE);
|
gameScreenPng = (u8 *)malloc(gameScreenPngSize);
|
||||||
GX_CopyTex(gameScreenTex, GX_FALSE);
|
memcpy(gameScreenPng, savebuffer, gameScreenPngSize);
|
||||||
GX_PixModeSync();
|
}
|
||||||
DCFlushRange(gameScreenTex, texSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -51,8 +51,8 @@ static GuiTrigger * trigA = NULL;
|
|||||||
static GuiTrigger * trig2 = NULL;
|
static GuiTrigger * trig2 = NULL;
|
||||||
|
|
||||||
static GuiButton * btnLogo = NULL;
|
static GuiButton * btnLogo = NULL;
|
||||||
|
static GuiImageData * gameScreen = NULL;
|
||||||
static GuiImage * gameScreenImg = NULL;
|
static GuiImage * gameScreenImg = NULL;
|
||||||
static GuiImage * bgImg = NULL;
|
|
||||||
static GuiImage * bgTopImg = NULL;
|
static GuiImage * bgTopImg = NULL;
|
||||||
static GuiImage * bgBottomImg = NULL;
|
static GuiImage * bgBottomImg = NULL;
|
||||||
static GuiSound * bgMusic = NULL;
|
static GuiSound * bgMusic = NULL;
|
||||||
@ -860,11 +860,7 @@ static void WindowCredits(void * ptr)
|
|||||||
{
|
{
|
||||||
UpdatePads();
|
UpdatePads();
|
||||||
|
|
||||||
if(gameScreenImg)
|
gameScreenImg->Draw();
|
||||||
gameScreenImg->Draw();
|
|
||||||
else
|
|
||||||
bgImg->Draw();
|
|
||||||
|
|
||||||
bgBottomImg->Draw();
|
bgBottomImg->Draw();
|
||||||
bgTopImg->Draw();
|
bgTopImg->Draw();
|
||||||
creditsWindow.Draw();
|
creditsWindow.Draw();
|
||||||
@ -1440,19 +1436,17 @@ static int MenuGame()
|
|||||||
{
|
{
|
||||||
if (WindowPrompt("Quit Game", "Quit this game? Any unsaved progress will be lost.", "OK", "Cancel"))
|
if (WindowPrompt("Quit Game", "Quit this game? Any unsaved progress will be lost.", "OK", "Cancel"))
|
||||||
{
|
{
|
||||||
if(gameScreenImg)
|
HaltGui();
|
||||||
{
|
mainWindow->Remove(gameScreenImg);
|
||||||
mainWindow->Remove(gameScreenImg);
|
delete gameScreenImg;
|
||||||
delete gameScreenImg;
|
delete gameScreen;
|
||||||
gameScreenImg = NULL;
|
gameScreen = NULL;
|
||||||
}
|
free(gameScreenPng);
|
||||||
if(gameScreenTex)
|
gameScreenPng = NULL;
|
||||||
{
|
gameScreenImg = new GuiImage(screenwidth, screenheight, (GXColor){240, 225, 230, 255});
|
||||||
free(gameScreenTex);
|
gameScreenImg->ColorStripe(10);
|
||||||
gameScreenTex = NULL;
|
mainWindow->Insert(gameScreenImg, 0);
|
||||||
gameScreenPngSize = 0;
|
ResumeGui();
|
||||||
}
|
|
||||||
bgImg->SetVisible(true);
|
|
||||||
#ifndef NO_SOUND
|
#ifndef NO_SOUND
|
||||||
bgMusic->Play(); // startup music
|
bgMusic->Play(); // startup music
|
||||||
#endif
|
#endif
|
||||||
@ -3810,29 +3804,27 @@ MainMenu (int menu)
|
|||||||
|
|
||||||
mainWindow = new GuiWindow(screenwidth, screenheight);
|
mainWindow = new GuiWindow(screenwidth, screenheight);
|
||||||
|
|
||||||
bgImg = new GuiImage(screenwidth, screenheight, (GXColor){240, 225, 230, 255});
|
if(menu == MENU_GAME)
|
||||||
bgImg->ColorStripe(10);
|
|
||||||
mainWindow->Append(bgImg);
|
|
||||||
|
|
||||||
if(gameScreenTex)
|
|
||||||
{
|
{
|
||||||
IMGCTX pngContext = PNGU_SelectImageFromBuffer(gameScreenPng);
|
gameScreen = new GuiImageData(gameScreenPng);
|
||||||
|
gameScreenImg = new GuiImage(gameScreen);
|
||||||
if (pngContext != NULL)
|
|
||||||
{
|
|
||||||
gameScreenPngSize = PNGU_EncodeFromGXTexture(pngContext, vmode->fbWidth, vmode->efbHeight, gameScreenTex, 0);
|
|
||||||
PNGU_ReleaseImageContext(pngContext);
|
|
||||||
DCFlushRange(gameScreenPng, 512*1024);
|
|
||||||
}
|
|
||||||
|
|
||||||
gameScreenImg = new GuiImage(gameScreenTex, vmode->fbWidth, vmode->efbHeight);
|
|
||||||
gameScreenImg->SetAlpha(192);
|
gameScreenImg->SetAlpha(192);
|
||||||
gameScreenImg->ColorStripe(30);
|
gameScreenImg->ColorStripe(30);
|
||||||
gameScreenImg->SetScaleX(screenwidth/(float)vmode->fbWidth);
|
|
||||||
|
if (GCSettings.render > 0 && !GCSettings.widescreen)
|
||||||
|
gameScreenImg->SetScaleX(screenwidth/(vmode->fbWidth*0.8));
|
||||||
|
else
|
||||||
|
gameScreenImg->SetScaleX(screenwidth/(float)vmode->fbWidth);
|
||||||
|
|
||||||
gameScreenImg->SetScaleY(screenheight/(float)vmode->efbHeight);
|
gameScreenImg->SetScaleY(screenheight/(float)vmode->efbHeight);
|
||||||
mainWindow->Append(gameScreenImg);
|
|
||||||
bgImg->SetVisible(false);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gameScreenImg = new GuiImage(screenwidth, screenheight, (GXColor){240, 225, 230, 255});
|
||||||
|
gameScreenImg->ColorStripe(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
mainWindow->Append(gameScreenImg);
|
||||||
|
|
||||||
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
|
GuiSound btnSoundOver(button_over_pcm, button_over_pcm_size, SOUND_PCM);
|
||||||
GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM);
|
GuiSound btnSoundClick(button_click_pcm, button_click_pcm_size, SOUND_PCM);
|
||||||
@ -3970,23 +3962,20 @@ MainMenu (int menu)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete btnLogo;
|
delete btnLogo;
|
||||||
delete bgImg;
|
delete gameScreenImg;
|
||||||
delete bgTopImg;
|
delete bgTopImg;
|
||||||
delete bgBottomImg;
|
delete bgBottomImg;
|
||||||
delete mainWindow;
|
delete mainWindow;
|
||||||
|
|
||||||
mainWindow = NULL;
|
mainWindow = NULL;
|
||||||
|
|
||||||
if(gameScreenImg)
|
if(gameScreen)
|
||||||
|
delete gameScreen;
|
||||||
|
|
||||||
|
if(gameScreenPng)
|
||||||
{
|
{
|
||||||
delete gameScreenImg;
|
free(gameScreenPng);
|
||||||
gameScreenImg = NULL;
|
gameScreenPng = NULL;
|
||||||
}
|
|
||||||
if(gameScreenTex)
|
|
||||||
{
|
|
||||||
free(gameScreenTex);
|
|
||||||
gameScreenTex = NULL;
|
|
||||||
gameScreenPngSize = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for keys to be depressed
|
// wait for keys to be depressed
|
||||||
|
Loading…
x
Reference in New Issue
Block a user