From 882dcdff9a245eff867ae9916fdaa9ea3c74c462 Mon Sep 17 00:00:00 2001 From: Nach Date: Mon, 19 Nov 2007 19:58:21 +0000 Subject: [PATCH] Makefile is now more compatible, whitespace trim. git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@98 a31d4220-a93d-0410-bf67-fe4944624d44 --- Makefile | 4 +- src/hq_shared32.cpp | 2 +- src/win32/MainWndOptions.cpp | 2 +- src/win32/SelectPlugin.cpp | 352 ++++++++++++++++----------------- src/win32/SelectPlugin.h | 110 +++++------ src/win32/rpi.cpp | 374 +++++++++++++++++------------------ src/win32/rpi.h | 124 ++++++------ 7 files changed, 485 insertions(+), 483 deletions(-) diff --git a/Makefile b/Makefile index 9024403e..c2fa1942 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,8 @@ CFLAGS=-W -Wall -Wno-unused -DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DFINAL_VERSI CXXFLAGS=${CFLAGS} ASM=nasm ASMFLAGS=-w-orphan-labels -f elf -DELF -O1 -Isrc/ -LFLAGS=-lz -lpng -lSDL -s +LFLAGS=-lz -lpng `sdl-config --libs` +STRIP=strip -s MAINDIR=src SDLDIR=src/sdl @@ -50,6 +51,7 @@ ALL: vba vba: ${OBJECTS} ${LIB} $(CPPC) -o $@ ${OBJECTS} ${LIB} ${LFLAGS} + $(STRIP) $@ ${RESAMPLEDIR}/libresample.a: make -C ${RESAMPLEDIR} -f Make diff --git a/src/hq_shared32.cpp b/src/hq_shared32.cpp index 006a76ca..ba4e5692 100644 --- a/src/hq_shared32.cpp +++ b/src/hq_shared32.cpp @@ -3,7 +3,7 @@ // Copyright (C) 2005 Forgotten and the VBA development team // This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by +// it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or(at your option) // any later version. // diff --git a/src/win32/MainWndOptions.cpp b/src/win32/MainWndOptions.cpp index 3b3c8133..31f1010c 100644 --- a/src/win32/MainWndOptions.cpp +++ b/src/win32/MainWndOptions.cpp @@ -1968,7 +1968,7 @@ void MainWnd::OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI) pCmdUI->SetCheck(!theApp.dsoundDisableHardwareAcceleration); } -void MainWnd::OnOptionsSelectPlugin() +void MainWnd::OnOptionsSelectPlugin() { SelectPlugin dlg; diff --git a/src/win32/SelectPlugin.cpp b/src/win32/SelectPlugin.cpp index 15b5ac50..d6e75c3d 100644 --- a/src/win32/SelectPlugin.cpp +++ b/src/win32/SelectPlugin.cpp @@ -1,176 +1,176 @@ -// SelectPlugin.cpp : implementation file -// - -#include "stdafx.h" -#include "vba.h" -#include "SelectPlugin.h" -#include "rpi.h" -#include "reg.h" -#include -#include - -using namespace std; - -#ifdef _DEBUG -#define new DEBUG_NEW -#undef THIS_FILE -static char THIS_FILE[] = __FILE__; -#endif - -vector rpiPool; - -///////////////////////////////////////////////////////////////////////////// -// SelectPlugin dialog - - -SelectPlugin::SelectPlugin(CWnd* pParent /*=NULL*/) - : CDialog(SelectPlugin::IDD, pParent) -{ - //{{AFX_DATA_INIT(SelectPlugin) - //}}AFX_DATA_INIT -} - - -void SelectPlugin::DoDataExchange(CDataExchange* pDX) -{ - CDialog::DoDataExchange(pDX); - //{{AFX_DATA_MAP(SelectPlugin) - DDX_Control(pDX, IDC_COMBO_PLUGIN, m_comboPlugin); - //}}AFX_DATA_MAP -} - - -BEGIN_MESSAGE_MAP(SelectPlugin, CDialog) - //{{AFX_MSG_MAP(SelectPlugin) - //}}AFX_MSG_MAP -END_MESSAGE_MAP() - -///////////////////////////////////////////////////////////////////////////// -// SelectPlugin message handlers - -void SelectPlugin::OnOK() -{ - // TODO: Add extra validation here - if (m_comboPlugin.GetCount() > 0) - { - int nSel = m_comboPlugin.GetCurSel(); - if (nSel >= 0 && nSel < rpiPool.size()) - strcpy(theApp.pluginName, rpiPool[nSel].sFile); - } - - CDialog::OnOK(); -} - -void SelectPlugin::OnCancel() -{ - // TODO: Add extra cleanup here - - CDialog::OnCancel(); -} - -BOOL SelectPlugin::OnInitDialog() -{ - CDialog::OnInitDialog(); - - m_comboPlugin.ResetContent(); - - int nPluginCnt = EnumPlugins(); - if (nPluginCnt > 0) - { - for (int i = 0; i < rpiPool.size(); i++) - m_comboPlugin.AddString(rpiPool[i].sDesc); - - for (int ii = 0; ii < rpiPool.size(); ii++) - { - if (stricmp(theApp.pluginName, rpiPool[ii].sFile) == 0) - { - m_comboPlugin.SetCurSel(ii); - break; - } - } - } - - - return TRUE; // return TRUE unless you set the focus to a control - // EXCEPTION: OCX Property Pages should return FALSE -} - -int SelectPlugin::EnumPlugins() -{ - rpiPool.clear(); - - char sFindFile[MAX_PATH]; - char *ptr; - - GetModuleFileName(NULL, sFindFile, sizeof(sFindFile)); - ptr = strrchr(sFindFile, '\\'); - if (ptr) - *ptr = '\0'; - strcat(sFindFile, "\\plugins\\*.rpi"); - - PluginDesc plugDesc; - WIN32_FIND_DATA FindFileData; - HANDLE hFind; - - memset(&FindFileData, 0, sizeof(FindFileData)); - hFind = FindFirstFile(sFindFile, &FindFileData); - if (hFind != INVALID_HANDLE_VALUE) - { - if (GetPluginDesc(FindFileData.cFileName, &plugDesc)) - rpiPool.push_back(plugDesc); - - while (true) - { - memset(&FindFileData, 0, sizeof(FindFileData)); - if (!FindNextFile(hFind, &FindFileData)) - break; - - if (GetPluginDesc(FindFileData.cFileName, &plugDesc)) - rpiPool.push_back(plugDesc); - } - FindClose(hFind); - } - - return rpiPool.size(); -} - -bool SelectPlugin::GetPluginDesc(const char *sRpi, PluginDesc *pDesc) -{ - HINSTANCE rpiDLL = NULL; - char sFile[MAX_PATH]; - char *ptr; - - GetModuleFileName(NULL, sFile, sizeof(sFile)); - ptr = strrchr(sFile, '\\'); - if (ptr) - *ptr = '\0'; - strcat(sFile, "\\plugins\\"); - strcat(sFile, sRpi); - - rpiDLL = LoadLibrary(sFile); - if (!rpiDLL) - return false; - - RENDPLUG_GetInfo fnGetInfo = (RENDPLUG_GetInfo) GetProcAddress(rpiDLL, "RenderPluginGetInfo"); - RENDPLUG_Output fnOutput = (RENDPLUG_Output) GetProcAddress(rpiDLL, "RenderPluginOutput"); - if (fnGetInfo == NULL || fnOutput == NULL) - { - FreeLibrary(rpiDLL); - rpiDLL = NULL; - return false; - } - - RENDER_PLUGIN_INFO *pRPI = fnGetInfo(); - if (pRPI == NULL) - { - FreeLibrary(rpiDLL); - return false; - } - - memset(pDesc, 0, sizeof(PluginDesc)); - strcpy(pDesc->sFile, sRpi); - strcpy(pDesc->sDesc, pRPI->Name); - FreeLibrary(rpiDLL); - - return true; -} +// SelectPlugin.cpp : implementation file +// + +#include "stdafx.h" +#include "vba.h" +#include "SelectPlugin.h" +#include "rpi.h" +#include "reg.h" +#include +#include + +using namespace std; + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +vector rpiPool; + +///////////////////////////////////////////////////////////////////////////// +// SelectPlugin dialog + + +SelectPlugin::SelectPlugin(CWnd* pParent /*=NULL*/) + : CDialog(SelectPlugin::IDD, pParent) +{ + //{{AFX_DATA_INIT(SelectPlugin) + //}}AFX_DATA_INIT +} + + +void SelectPlugin::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(SelectPlugin) + DDX_Control(pDX, IDC_COMBO_PLUGIN, m_comboPlugin); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(SelectPlugin, CDialog) + //{{AFX_MSG_MAP(SelectPlugin) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// SelectPlugin message handlers + +void SelectPlugin::OnOK() +{ + // TODO: Add extra validation here + if (m_comboPlugin.GetCount() > 0) + { + int nSel = m_comboPlugin.GetCurSel(); + if (nSel >= 0 && nSel < rpiPool.size()) + strcpy(theApp.pluginName, rpiPool[nSel].sFile); + } + + CDialog::OnOK(); +} + +void SelectPlugin::OnCancel() +{ + // TODO: Add extra cleanup here + + CDialog::OnCancel(); +} + +BOOL SelectPlugin::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_comboPlugin.ResetContent(); + + int nPluginCnt = EnumPlugins(); + if (nPluginCnt > 0) + { + for (int i = 0; i < rpiPool.size(); i++) + m_comboPlugin.AddString(rpiPool[i].sDesc); + + for (int ii = 0; ii < rpiPool.size(); ii++) + { + if (stricmp(theApp.pluginName, rpiPool[ii].sFile) == 0) + { + m_comboPlugin.SetCurSel(ii); + break; + } + } + } + + + return TRUE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +int SelectPlugin::EnumPlugins() +{ + rpiPool.clear(); + + char sFindFile[MAX_PATH]; + char *ptr; + + GetModuleFileName(NULL, sFindFile, sizeof(sFindFile)); + ptr = strrchr(sFindFile, '\\'); + if (ptr) + *ptr = '\0'; + strcat(sFindFile, "\\plugins\\*.rpi"); + + PluginDesc plugDesc; + WIN32_FIND_DATA FindFileData; + HANDLE hFind; + + memset(&FindFileData, 0, sizeof(FindFileData)); + hFind = FindFirstFile(sFindFile, &FindFileData); + if (hFind != INVALID_HANDLE_VALUE) + { + if (GetPluginDesc(FindFileData.cFileName, &plugDesc)) + rpiPool.push_back(plugDesc); + + while (true) + { + memset(&FindFileData, 0, sizeof(FindFileData)); + if (!FindNextFile(hFind, &FindFileData)) + break; + + if (GetPluginDesc(FindFileData.cFileName, &plugDesc)) + rpiPool.push_back(plugDesc); + } + FindClose(hFind); + } + + return rpiPool.size(); +} + +bool SelectPlugin::GetPluginDesc(const char *sRpi, PluginDesc *pDesc) +{ + HINSTANCE rpiDLL = NULL; + char sFile[MAX_PATH]; + char *ptr; + + GetModuleFileName(NULL, sFile, sizeof(sFile)); + ptr = strrchr(sFile, '\\'); + if (ptr) + *ptr = '\0'; + strcat(sFile, "\\plugins\\"); + strcat(sFile, sRpi); + + rpiDLL = LoadLibrary(sFile); + if (!rpiDLL) + return false; + + RENDPLUG_GetInfo fnGetInfo = (RENDPLUG_GetInfo) GetProcAddress(rpiDLL, "RenderPluginGetInfo"); + RENDPLUG_Output fnOutput = (RENDPLUG_Output) GetProcAddress(rpiDLL, "RenderPluginOutput"); + if (fnGetInfo == NULL || fnOutput == NULL) + { + FreeLibrary(rpiDLL); + rpiDLL = NULL; + return false; + } + + RENDER_PLUGIN_INFO *pRPI = fnGetInfo(); + if (pRPI == NULL) + { + FreeLibrary(rpiDLL); + return false; + } + + memset(pDesc, 0, sizeof(PluginDesc)); + strcpy(pDesc->sFile, sRpi); + strcpy(pDesc->sDesc, pRPI->Name); + FreeLibrary(rpiDLL); + + return true; +} diff --git a/src/win32/SelectPlugin.h b/src/win32/SelectPlugin.h index 1dd27e30..c1ab0057 100644 --- a/src/win32/SelectPlugin.h +++ b/src/win32/SelectPlugin.h @@ -1,55 +1,55 @@ -#if !defined(AFX_SELECTPLUGIN_H__A097B9D0_7C23_4C1A_A2D3_1AEC07501BBC__INCLUDED_) -#define AFX_SELECTPLUGIN_H__A097B9D0_7C23_4C1A_A2D3_1AEC07501BBC__INCLUDED_ - -#if _MSC_VER > 1000 -#pragma once -#endif // _MSC_VER > 1000 -// SelectPlugin.h : header file -// - -///////////////////////////////////////////////////////////////////////////// -// SelectPlugin dialog -struct PluginDesc -{ - char sFile[MAX_PATH]; - char sDesc[60]; -}; - -class SelectPlugin : public CDialog -{ -// Construction -public: - SelectPlugin(CWnd* pParent = NULL); // standard constructor - int EnumPlugins(); - bool GetPluginDesc(const char *sRpi, PluginDesc *pDesc); - -// Dialog Data - //{{AFX_DATA(SelectPlugin) - enum { IDD = IDD_SELECT_PLUGIN }; - CComboBox m_comboPlugin; - //}}AFX_DATA - - -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(SelectPlugin) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(SelectPlugin) - virtual void OnOK(); - virtual void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - -//{{AFX_INSERT_LOCATION}} -// Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SELECTPLUGIN_H__A097B9D0_7C23_4C1A_A2D3_1AEC07501BBC__INCLUDED_) +#if !defined(AFX_SELECTPLUGIN_H__A097B9D0_7C23_4C1A_A2D3_1AEC07501BBC__INCLUDED_) +#define AFX_SELECTPLUGIN_H__A097B9D0_7C23_4C1A_A2D3_1AEC07501BBC__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 +// SelectPlugin.h : header file +// + +///////////////////////////////////////////////////////////////////////////// +// SelectPlugin dialog +struct PluginDesc +{ + char sFile[MAX_PATH]; + char sDesc[60]; +}; + +class SelectPlugin : public CDialog +{ +// Construction +public: + SelectPlugin(CWnd* pParent = NULL); // standard constructor + int EnumPlugins(); + bool GetPluginDesc(const char *sRpi, PluginDesc *pDesc); + +// Dialog Data + //{{AFX_DATA(SelectPlugin) + enum { IDD = IDD_SELECT_PLUGIN }; + CComboBox m_comboPlugin; + //}}AFX_DATA + + +// Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(SelectPlugin) + protected: + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + //}}AFX_VIRTUAL + +// Implementation +protected: + + // Generated message map functions + //{{AFX_MSG(SelectPlugin) + virtual void OnOK(); + virtual void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_SELECTPLUGIN_H__A097B9D0_7C23_4C1A_A2D3_1AEC07501BBC__INCLUDED_) diff --git a/src/win32/rpi.cpp b/src/win32/rpi.cpp index c43d14d1..7372141c 100644 --- a/src/win32/rpi.cpp +++ b/src/win32/rpi.cpp @@ -1,187 +1,187 @@ -#include "stdafx.h" -#include "rpi.h" - -extern void SuperEagle(u8*,u32,u8*,u8*,u32,int,int); - -static HINSTANCE rpiDLL = NULL; -static RENDPLUG_Output fnOutput = NULL; -static RENDPLUG_GetInfo fnGetInfo = NULL; -static RENDER_PLUGIN_INFO MyPlugInfo; -static RENDER_PLUGIN_OUTP MyPlugOutput; -static int nScaleFactor; - -extern int systemRedShift, systemGreenShift, systemBlueShift; -extern int realsystemRedShift, realsystemGreenShift, realsystemBlueShift; -extern int realsystemColorDepth; -u8 *pBuffer16 = NULL; -u32 Buffer16Size = 0; - -bool rpiInit(const char *sPluginName) -{ - rpiCleanup(); - - char sBuffer[256]; - char *ptr; - - GetModuleFileName(NULL, sBuffer, sizeof(sBuffer)); - ptr = strrchr(sBuffer, '\\'); - if (ptr) - *ptr = '\0'; - strcat(sBuffer, "\\plugins\\"); - strcat(sBuffer, sPluginName); - - rpiDLL = LoadLibrary(sBuffer); - if (!rpiDLL) - return false; - - fnGetInfo = (RENDPLUG_GetInfo) GetProcAddress(rpiDLL, "RenderPluginGetInfo"); - fnOutput = (RENDPLUG_Output) GetProcAddress(rpiDLL, "RenderPluginOutput"); - if (fnGetInfo == NULL || fnOutput == NULL) - { - FreeLibrary(rpiDLL); - rpiDLL = NULL; - return false; - } - - RENDER_PLUGIN_INFO *pRPI = fnGetInfo(); - if (pRPI == NULL) - { - FreeLibrary(rpiDLL); - rpiDLL = NULL; - return false; - } - - memcpy(&MyPlugInfo, pRPI, sizeof(MyPlugInfo)); - - unsigned long Flags = MyPlugInfo.Flags & 0x0000F0000; - - if (Flags == RPI_OUT_SCL2) - { - nScaleFactor = 2; - } - else if (Flags == RPI_OUT_SCL3) - { - nScaleFactor = 3; - } - else if (Flags == RPI_OUT_SCL4) - { - nScaleFactor = 4; - } - else - { - nScaleFactor = 2; - } - - return true; -} - -void rpiFilter(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height) -{ - u8 *pBuff; - - if (realsystemColorDepth == 32) - { - // Kega filters are 16 bit only. Assumes we've forced 16 bit input - ASSERT(systemColorDepth == 16); - u32 bufferNeeded = dstPitch * (height + nScaleFactor) * nScaleFactor; - if (Buffer16Size < bufferNeeded) - { - Buffer16Size = bufferNeeded; - if (pBuffer16) - free(pBuffer16); - pBuffer16 = (u8 *)malloc(Buffer16Size); - } - pBuff = pBuffer16; - } - else - pBuff = dstPtr; - - MyPlugOutput.Size = sizeof(MyPlugOutput); - MyPlugOutput.Flags = MyPlugInfo.Flags; - MyPlugOutput.SrcPtr = srcPtr; - MyPlugOutput.SrcPitch = srcPitch; - MyPlugOutput.SrcW = width; - // Without this funky math on the height value, the RPI filter isn't fully - // rendering the frame. I don't like passing in values that seem - // to be greater than the buffer size, but it's the only way to get - // proper results. - MyPlugOutput.SrcH = height+(nScaleFactor/2); - MyPlugOutput.DstPtr = pBuff; - MyPlugOutput.DstPitch = dstPitch; - MyPlugOutput.DstW = width * nScaleFactor; - MyPlugOutput.DstH = (height+(nScaleFactor/2)) * nScaleFactor; - MyPlugOutput.OutW = width * nScaleFactor; - MyPlugOutput.OutH = (height+(nScaleFactor/2)) * nScaleFactor; - - fnOutput(&MyPlugOutput); - - if (realsystemColorDepth == 32) - { - register int i,j; - int rshiftDiff = realsystemRedShift - systemRedShift; - int gshiftDiff = realsystemGreenShift - systemGreenShift; - int bshiftDiff = realsystemBlueShift - systemBlueShift; - - u16 *pI, *pICur; - u32 *pO, *pOCur; - - pI = pICur = (u16 *)pBuff; - pO = pOCur = (u32 *)dstPtr; - - if (rshiftDiff >= 0) - { - for(j=0;j> rshiftDiff) | - ((*pICur & 0x07E0) << gshiftDiff) | - ((*pICur & 0x001F) << bshiftDiff); - *pICur++; - } - pI = pICur = (u16 *)((char *)pI + dstPitch); - pO = pOCur = (u32 *)((char *)pO + dstPitch); - } - - } - } -} - -int rpiScaleFactor() -{ - return nScaleFactor; -} - -void rpiCleanup() -{ - if (rpiDLL != NULL) - { - FreeLibrary(rpiDLL); - rpiDLL = NULL; - } - if (pBuffer16) - { - free(pBuffer16); - pBuffer16 = NULL; - Buffer16Size = 0; - } -} +#include "stdafx.h" +#include "rpi.h" + +extern void SuperEagle(u8*,u32,u8*,u8*,u32,int,int); + +static HINSTANCE rpiDLL = NULL; +static RENDPLUG_Output fnOutput = NULL; +static RENDPLUG_GetInfo fnGetInfo = NULL; +static RENDER_PLUGIN_INFO MyPlugInfo; +static RENDER_PLUGIN_OUTP MyPlugOutput; +static int nScaleFactor; + +extern int systemRedShift, systemGreenShift, systemBlueShift; +extern int realsystemRedShift, realsystemGreenShift, realsystemBlueShift; +extern int realsystemColorDepth; +u8 *pBuffer16 = NULL; +u32 Buffer16Size = 0; + +bool rpiInit(const char *sPluginName) +{ + rpiCleanup(); + + char sBuffer[256]; + char *ptr; + + GetModuleFileName(NULL, sBuffer, sizeof(sBuffer)); + ptr = strrchr(sBuffer, '\\'); + if (ptr) + *ptr = '\0'; + strcat(sBuffer, "\\plugins\\"); + strcat(sBuffer, sPluginName); + + rpiDLL = LoadLibrary(sBuffer); + if (!rpiDLL) + return false; + + fnGetInfo = (RENDPLUG_GetInfo) GetProcAddress(rpiDLL, "RenderPluginGetInfo"); + fnOutput = (RENDPLUG_Output) GetProcAddress(rpiDLL, "RenderPluginOutput"); + if (fnGetInfo == NULL || fnOutput == NULL) + { + FreeLibrary(rpiDLL); + rpiDLL = NULL; + return false; + } + + RENDER_PLUGIN_INFO *pRPI = fnGetInfo(); + if (pRPI == NULL) + { + FreeLibrary(rpiDLL); + rpiDLL = NULL; + return false; + } + + memcpy(&MyPlugInfo, pRPI, sizeof(MyPlugInfo)); + + unsigned long Flags = MyPlugInfo.Flags & 0x0000F0000; + + if (Flags == RPI_OUT_SCL2) + { + nScaleFactor = 2; + } + else if (Flags == RPI_OUT_SCL3) + { + nScaleFactor = 3; + } + else if (Flags == RPI_OUT_SCL4) + { + nScaleFactor = 4; + } + else + { + nScaleFactor = 2; + } + + return true; +} + +void rpiFilter(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height) +{ + u8 *pBuff; + + if (realsystemColorDepth == 32) + { + // Kega filters are 16 bit only. Assumes we've forced 16 bit input + ASSERT(systemColorDepth == 16); + u32 bufferNeeded = dstPitch * (height + nScaleFactor) * nScaleFactor; + if (Buffer16Size < bufferNeeded) + { + Buffer16Size = bufferNeeded; + if (pBuffer16) + free(pBuffer16); + pBuffer16 = (u8 *)malloc(Buffer16Size); + } + pBuff = pBuffer16; + } + else + pBuff = dstPtr; + + MyPlugOutput.Size = sizeof(MyPlugOutput); + MyPlugOutput.Flags = MyPlugInfo.Flags; + MyPlugOutput.SrcPtr = srcPtr; + MyPlugOutput.SrcPitch = srcPitch; + MyPlugOutput.SrcW = width; + // Without this funky math on the height value, the RPI filter isn't fully + // rendering the frame. I don't like passing in values that seem + // to be greater than the buffer size, but it's the only way to get + // proper results. + MyPlugOutput.SrcH = height+(nScaleFactor/2); + MyPlugOutput.DstPtr = pBuff; + MyPlugOutput.DstPitch = dstPitch; + MyPlugOutput.DstW = width * nScaleFactor; + MyPlugOutput.DstH = (height+(nScaleFactor/2)) * nScaleFactor; + MyPlugOutput.OutW = width * nScaleFactor; + MyPlugOutput.OutH = (height+(nScaleFactor/2)) * nScaleFactor; + + fnOutput(&MyPlugOutput); + + if (realsystemColorDepth == 32) + { + register int i,j; + int rshiftDiff = realsystemRedShift - systemRedShift; + int gshiftDiff = realsystemGreenShift - systemGreenShift; + int bshiftDiff = realsystemBlueShift - systemBlueShift; + + u16 *pI, *pICur; + u32 *pO, *pOCur; + + pI = pICur = (u16 *)pBuff; + pO = pOCur = (u32 *)dstPtr; + + if (rshiftDiff >= 0) + { + for(j=0;j> rshiftDiff) | + ((*pICur & 0x07E0) << gshiftDiff) | + ((*pICur & 0x001F) << bshiftDiff); + *pICur++; + } + pI = pICur = (u16 *)((char *)pI + dstPitch); + pO = pOCur = (u32 *)((char *)pO + dstPitch); + } + + } + } +} + +int rpiScaleFactor() +{ + return nScaleFactor; +} + +void rpiCleanup() +{ + if (rpiDLL != NULL) + { + FreeLibrary(rpiDLL); + rpiDLL = NULL; + } + if (pBuffer16) + { + free(pBuffer16); + pBuffer16 = NULL; + Buffer16Size = 0; + } +} diff --git a/src/win32/rpi.h b/src/win32/rpi.h index a60ce76c..f0bc2249 100644 --- a/src/win32/rpi.h +++ b/src/win32/rpi.h @@ -1,63 +1,63 @@ -//--------------------------------------------------------------------------------------------------------------------------- -// hq2x plugin example - Steve Snake 2004. -// This plugin uses (modified) code by Maxim Stepin - see "hq2x16.asm" for info -// The original code and description of the algorithm can be found at: -// http://www.hiend3d.com/hq2x.html -//--------------------------------------------------------------------------------------------------------------------------- -#include - -//--------------------------------------------------------------------------------------------------------------------------- -typedef struct -{ - unsigned long Size; - unsigned long Flags; - void *SrcPtr; - unsigned long SrcPitch; - unsigned long SrcW; - unsigned long SrcH; - void *DstPtr; - unsigned long DstPitch; - unsigned long DstW; - unsigned long DstH; - unsigned long OutW; - unsigned long OutH; -} RENDER_PLUGIN_OUTP; - -//--------------------------------------------------------------------------------------------------------------------------- - -typedef void (*RENDPLUG_Output)(RENDER_PLUGIN_OUTP *); - -//--------------------------------------------------------------------------------------------------------------------------- - -typedef struct -{ - char Name[60]; - unsigned long Flags; - HMODULE Handle; - RENDPLUG_Output Output; -} RENDER_PLUGIN_INFO; - -//--------------------------------------------------------------------------------------------------------------------------- - -typedef RENDER_PLUGIN_INFO *(*RENDPLUG_GetInfo)(void); - -//--------------------------------------------------------------------------------------------------------------------------- - -#define RPI_VERSION 0x02 - -#define RPI_MMX_USED 0x000000100 -#define RPI_MMX_REQD 0x000000200 -#define RPI_555_SUPP 0x000000400 -#define RPI_565_SUPP 0x000000800 -#define RPI_888_SUPP 0x000001000 - -#define RPI_OUT_SCL2 0x000020000 -#define RPI_OUT_SCL3 0x000030000 -#define RPI_OUT_SCL4 0x000040000 - -//--------------------------------------------------------------------------------------------------------------------------- - -int rpiScaleFactor(); -bool rpiInit(const char *sPluginName); +//--------------------------------------------------------------------------------------------------------------------------- +// hq2x plugin example - Steve Snake 2004. +// This plugin uses (modified) code by Maxim Stepin - see "hq2x16.asm" for info +// The original code and description of the algorithm can be found at: +// http://www.hiend3d.com/hq2x.html +//--------------------------------------------------------------------------------------------------------------------------- +#include + +//--------------------------------------------------------------------------------------------------------------------------- +typedef struct +{ + unsigned long Size; + unsigned long Flags; + void *SrcPtr; + unsigned long SrcPitch; + unsigned long SrcW; + unsigned long SrcH; + void *DstPtr; + unsigned long DstPitch; + unsigned long DstW; + unsigned long DstH; + unsigned long OutW; + unsigned long OutH; +} RENDER_PLUGIN_OUTP; + +//--------------------------------------------------------------------------------------------------------------------------- + +typedef void (*RENDPLUG_Output)(RENDER_PLUGIN_OUTP *); + +//--------------------------------------------------------------------------------------------------------------------------- + +typedef struct +{ + char Name[60]; + unsigned long Flags; + HMODULE Handle; + RENDPLUG_Output Output; +} RENDER_PLUGIN_INFO; + +//--------------------------------------------------------------------------------------------------------------------------- + +typedef RENDER_PLUGIN_INFO *(*RENDPLUG_GetInfo)(void); + +//--------------------------------------------------------------------------------------------------------------------------- + +#define RPI_VERSION 0x02 + +#define RPI_MMX_USED 0x000000100 +#define RPI_MMX_REQD 0x000000200 +#define RPI_555_SUPP 0x000000400 +#define RPI_565_SUPP 0x000000800 +#define RPI_888_SUPP 0x000001000 + +#define RPI_OUT_SCL2 0x000020000 +#define RPI_OUT_SCL3 0x000030000 +#define RPI_OUT_SCL4 0x000040000 + +//--------------------------------------------------------------------------------------------------------------------------- + +int rpiScaleFactor(); +bool rpiInit(const char *sPluginName); void rpiFilter(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height); -void rpiCleanup(); \ No newline at end of file +void rpiCleanup();