mirror of https://github.com/snes9xgit/snes9x.git
Merge branch 'master' of github.com:snes9x-rr/snes9x
Conflicts: win32/win32.cpp win32/win32_display.cpp win32/wsnes9x.h
This commit is contained in:
commit
64a63fe2df
|
@ -176,7 +176,7 @@
|
|||
|
||||
#pragma comment( lib, "d3d9" )
|
||||
#pragma comment( lib, "d3dx9" )
|
||||
#pragma comment( lib, "DxErr9" )
|
||||
#pragma comment( lib, "DxErr" )
|
||||
|
||||
#include "cdirect3d.h"
|
||||
#include "win32_display.h"
|
||||
|
|
|
@ -203,8 +203,10 @@
|
|||
|
||||
#include <math.h>
|
||||
|
||||
BYTE *ScreenBuf1 = NULL;
|
||||
BYTE *ScreenBuf = NULL;
|
||||
BYTE *ScreenBufBlend = NULL;
|
||||
BYTE *ScreenBuffer = NULL;
|
||||
BYTE *ScreenBufferBlend = NULL;
|
||||
|
||||
struct SJoyState Joystick [16];
|
||||
uint32 joypads [8];
|
||||
|
@ -976,14 +978,17 @@ void InitSnes9X( void)
|
|||
extern void S9xPostRomInit();
|
||||
Memory.PostRomInitFunc = S9xPostRomInit;
|
||||
|
||||
ScreenBuf1 = new BYTE [EXT_PITCH * EXT_HEIGHT];
|
||||
ScreenBuf = new BYTE [EXT_PITCH * EXT_HEIGHT];
|
||||
ScreenBufBlend = new BYTE [EXT_PITCH * EXT_HEIGHT];
|
||||
|
||||
ScreenBuffer = ScreenBuf1 + EXT_OFFSET;
|
||||
memset (ScreenBuf1, 0, EXT_PITCH * EXT_HEIGHT);
|
||||
ScreenBuffer = ScreenBuf + EXT_OFFSET;
|
||||
ScreenBufferBlend = ScreenBufBlend + EXT_OFFSET;
|
||||
memset (ScreenBuf, 0, EXT_PITCH * EXT_HEIGHT);
|
||||
memset (ScreenBufBlend, 0, EXT_PITCH * EXT_HEIGHT);
|
||||
|
||||
GFX.Pitch = EXT_PITCH;
|
||||
GFX.RealPPL = EXT_PITCH;
|
||||
GFX.Screen = (uint16*)(ScreenBuf1 + EXT_OFFSET);
|
||||
GFX.Screen = (uint16*)(ScreenBuffer);
|
||||
|
||||
InitializeCriticalSection(&GUI.SoundCritSect);
|
||||
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
|
@ -1001,8 +1006,10 @@ void InitSnes9X( void)
|
|||
}
|
||||
void DeinitS9x()
|
||||
{
|
||||
if(ScreenBuf1)
|
||||
delete [] ScreenBuf1;
|
||||
if(ScreenBuf)
|
||||
delete [] ScreenBuf;
|
||||
if(ScreenBufBlend)
|
||||
delete [] ScreenBufBlend;
|
||||
DeleteCriticalSection(&GUI.SoundCritSect);
|
||||
CoUninitialize();
|
||||
if(GUI.GunSight)
|
||||
|
|
|
@ -197,6 +197,7 @@ CDirect3D Direct3D;
|
|||
CDirectDraw DirectDraw;
|
||||
COpenGL OpenGL;
|
||||
SSurface Src = {0};
|
||||
extern BYTE *ScreenBufferBlend;
|
||||
|
||||
// Interface used to access the display output
|
||||
IS9xDisplayOutput *S9xDisplayOutput=&Direct3D;
|
||||
|
@ -216,11 +217,20 @@ repeats the last rendered frame
|
|||
*/
|
||||
void WinRefreshDisplay(void)
|
||||
{
|
||||
if(!Src.Width)
|
||||
return;
|
||||
|
||||
SelectRenderMethod ();
|
||||
if(Src.Surface!=NULL) {
|
||||
S9xDisplayOutput->Render(Src);
|
||||
GUI.FlipCounter++;
|
||||
|
||||
Src.Surface = (BYTE *)GFX.Screen;
|
||||
|
||||
if(Src.Width > SNES_WIDTH && GUI.BlendHiRes) {
|
||||
RenderMergeHires(Src.Surface,ScreenBufferBlend,Src.Pitch,Src.Width,Src.Height);
|
||||
Src.Surface = ScreenBufferBlend;
|
||||
}
|
||||
|
||||
S9xDisplayOutput->Render(Src);
|
||||
GUI.FlipCounter++;
|
||||
}
|
||||
|
||||
void WinChangeWindowSize(unsigned int newWidth, unsigned int newHeight)
|
||||
|
@ -368,16 +378,9 @@ bool8 S9xDeinitUpdate (int Width, int Height)
|
|||
Src.Pitch = GFX.Pitch;
|
||||
Src.Surface = (BYTE*)GFX.Screen;
|
||||
|
||||
const int OrigHeight = Height;
|
||||
Height = Src.Height;
|
||||
|
||||
// avi writing
|
||||
DoAVIVideoFrame();
|
||||
|
||||
if(GUI.BlendHiRes) {
|
||||
RenderMergeHires(Src.Surface,Src.Pitch,Src.Width,Src.Height);
|
||||
}
|
||||
|
||||
// Clear some of the old SNES rendered image
|
||||
// when the resolution becomes lower in x or y,
|
||||
// otherwise the image processors (filters) might access
|
||||
|
@ -388,23 +391,23 @@ bool8 S9xDeinitUpdate (int Width, int Height)
|
|||
|
||||
if (Width < LastWidth)
|
||||
{
|
||||
const int hh = max(LastHeight, OrigHeight);
|
||||
const int hh = max(LastHeight, Height);
|
||||
for (int i = 0; i < hh; i++)
|
||||
memset (GFX.Screen + i * (GFX.Pitch>>1) + Width*1, 0, 4);
|
||||
}
|
||||
if (OrigHeight < LastHeight)
|
||||
if (Height < LastHeight)
|
||||
{
|
||||
const int ww = max(LastWidth, Width);
|
||||
for (int i = OrigHeight; i < LastHeight ; i++)
|
||||
for (int i = Height; i < LastHeight ; i++)
|
||||
memset (GFX.Screen + i * (GFX.Pitch>>1), 0, ww * 2);
|
||||
|
||||
// also old clear extended height stuff from drawing surface
|
||||
if((int)Src.Height > OrigHeight)
|
||||
for (int i = OrigHeight; i < (int)Src.Height ; i++)
|
||||
if((int)Src.Height > Height)
|
||||
for (int i = Height; i < (int)Src.Height ; i++)
|
||||
memset (Src.Surface + i * Src.Pitch, 0, Src.Pitch);
|
||||
}
|
||||
LastWidth = Width;
|
||||
LastHeight = OrigHeight;
|
||||
LastHeight = Height;
|
||||
}
|
||||
|
||||
WinRefreshDisplay();
|
||||
|
@ -427,6 +430,31 @@ void S9xSetWinPixelFormat ()
|
|||
S9xDisplayOutput->SetSnes9xColorFormat();
|
||||
}
|
||||
|
||||
char *ReadShaderFileContents(const TCHAR *filename)
|
||||
{
|
||||
HANDLE hFile;
|
||||
DWORD size;
|
||||
DWORD bytesRead;
|
||||
char *contents;
|
||||
|
||||
hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN , 0);
|
||||
if(hFile == INVALID_HANDLE_VALUE){
|
||||
return NULL;
|
||||
}
|
||||
size = GetFileSize(hFile,NULL);
|
||||
contents = new char[size+1];
|
||||
if(!ReadFile(hFile,contents,size,&bytesRead,NULL)) {
|
||||
CloseHandle(hFile);
|
||||
delete[] contents;
|
||||
return NULL;
|
||||
}
|
||||
CloseHandle(hFile);
|
||||
contents[size] = '\0';
|
||||
return contents;
|
||||
|
||||
}
|
||||
|
||||
// TODO: abstract the following functions in some way - only necessary for directdraw
|
||||
|
||||
/* DirectDraw only begin */
|
||||
|
|
|
@ -316,8 +316,8 @@ struct sGUI {
|
|||
bool LocalVidMem;
|
||||
bool Vsync;
|
||||
bool shaderEnabled;
|
||||
TCHAR HLSLshaderFileName[MAX_PATH];
|
||||
TCHAR GLSLshaderFileName[MAX_PATH];
|
||||
TCHAR D3DshaderFileName[MAX_PATH];
|
||||
TCHAR OGLshaderFileName[MAX_PATH];
|
||||
|
||||
bool IgnoreNextMouseMove;
|
||||
RECT window_size;
|
||||
|
|
Loading…
Reference in New Issue