Skip to content

Commit

Permalink
Documented Stranger of Sword City config, added to whitelist
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterTh committed Jun 7, 2016
1 parent ca6294f commit 817c7dc
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pack/config/StrangerOfSwordCity/GeDoSaTo.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

# This is a profile file for StrangerOfSwordCity

logLevel 0
# required to improve rendering of 2D elements after enforcing higher internal resolution
forceAnisoLevel 16
5 changes: 3 additions & 2 deletions pack/config/whitelist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ Risen2 || Risen 2
Risen3 || Risen 3
RoA || Rock of Ages
runner2 || BIT:TRIP Runner 2
sec* || Tales of Symphonia
Shadowrun || Shadowrun Returns
Sherlock || Sherlock Holmes: Crimes and Punishments
ShippingPC-BmGame || Batman: Arkham Asylum GOTY
Expand All @@ -154,6 +155,7 @@ SonicGenerations || Sonic Generations
SpaceMarine || Warhammer 40,000: Space Marine
SpecOpsTheLine || Spec Ops: The Line
StateOfDecay || State Of Decay
StrangerOfSwordCity || Stranger of Sword City
Tales of Zestiria || Tales of Zestiria
TESV || The Elder Scrolls V: Skyrim
TFOC || Transformers: Fall of Cybertron
Expand All @@ -172,5 +174,4 @@ Valkyria || Valkyria Chronicles
witcher2 || The Witcher 2
WL2 || Wasteland 2
Wolverine || X-Men Origins: Wolverine
yso_win || Ys Origin
sec* || Tales of Symphonia
yso_win || Ys Origin
82 changes: 82 additions & 0 deletions source/plugins/stranger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#include "plugins/stranger.h"

#include "renderstate_manager_dx9.h"
#include "d3d9/d3d9tex.h"
#include "utils/d3d9_utils.h"

#include "utils/win_utils.h"

using PluginBase = GenericPlugin;

void StrangerOfSwordCityPlugin::reportStatus() {
PluginBase::reportStatus();
Console::get().add("!! Stranger of Sword City Plugin");
}

StrangerOfSwordCityPlugin::StrangerOfSwordCityPlugin(IDirect3DDevice9* device, RSManagerDX9 &manager) : PluginBase(device, manager) {

}

void StrangerOfSwordCityPlugin::initialize(unsigned rw, unsigned rh, D3DFORMAT bbformat, D3DFORMAT dssformat) {
PluginBase::initialize(rw, rh, bbformat, dssformat);
}

void StrangerOfSwordCityPlugin::prePresent() {
PluginBase::prePresent();
}

HRESULT StrangerOfSwordCityPlugin::redirectCreateTexture(UINT Width, UINT Height, UINT Levels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, IDirect3DTexture9** ppTexture, HANDLE* pSharedHandle) {
if((Usage & D3DUSAGE_RENDERTARGET || Format == D3DFMT_D24S8) && Width == 1280 && Height == 720) {
SDLOG(-1, "Sosc: CreateTexture override\n");
Width *= 3;
Height *= 3;
}
return PluginBase::redirectCreateTexture(Width, Height, Levels, Usage, Format, Pool, ppTexture, pSharedHandle);
}

HRESULT StrangerOfSwordCityPlugin::redirectCreateDepthStencilSurface(UINT Width, UINT Height, D3DFORMAT Format, D3DMULTISAMPLE_TYPE MultiSample, DWORD MultisampleQuality, BOOL Discard, IDirect3DSurface9** ppSurface, HANDLE* pSharedHandle) {
if(Width == 1280 && Height == 720) {
Width*=3;
Height*=3;
}
return PluginBase::redirectCreateDepthStencilSurface(Width, Height, Format, MultiSample, MultisampleQuality, Discard, ppSurface, pSharedHandle);
}

HRESULT StrangerOfSwordCityPlugin::redirectSetViewport(CONST D3DVIEWPORT9 * pViewport) {
SDLOG(-1, "Sosc: SetViewport override");
D3DVIEWPORT9 newView = *pViewport;
newView.X *= 3;
newView.Y *= 3;
newView.Width *= 3;
newView.Height *= 3;
return GenericPlugin::redirectSetViewport(&newView);
}

HRESULT StrangerOfSwordCityPlugin::redirectSetPixelShader(IDirect3DPixelShader9* pShader) {
return PluginBase::redirectSetPixelShader(pShader);
}

HRESULT StrangerOfSwordCityPlugin::redirectDrawPrimitiveUP(D3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, CONST void* pVertexStreamZeroData, UINT VertexStreamZeroStride) {
if(PrimitiveCount==2) {
//float* vertexData = (float*)pVertexStreamZeroData;
auto floatStride = VertexStreamZeroStride / sizeof(float);
//static float replacementVertexData[100];// = (float*)alloca(floatStride * 2 * sizeof(float));
//memcpy(replacementVertexData, pVertexStreamZeroData, VertexStreamZeroStride*2);
float* vertexData = (float*)pVertexStreamZeroData;
float orientation = 1.0f;
if(vertexData[6 + 1*floatStride] < vertexData[6 + 2*floatStride]) orientation = -1.0f;
for(int vert = 0; vert < 4; ++vert) {
for(int i = 0; i < floatStride; ++i) {
//SDLOG(20, "%8.4f ", vertexData[i]);
float& val = vertexData[i + vert*floatStride];
if(i == 0 && !FLT_EQ(val, 2560)) val *= 3;
if(i == 1 && !FLT_EQ(val, 1440)) val *= 3;
if(i == 5 && vert <= 1) val -= 1.0f / (1280.0f * 1.333f);
if(i == 6 && vert%2==1) val -= orientation * (1.0f / ( 720.0f * 1.666f));
}
//SDLOG(20, "\n");
}
return PluginBase::redirectDrawPrimitiveUP(PrimitiveType, PrimitiveCount, vertexData, VertexStreamZeroStride);
}
return PluginBase::redirectDrawPrimitiveUP(PrimitiveType, PrimitiveCount, pVertexStreamZeroData, VertexStreamZeroStride);
}

0 comments on commit 817c7dc

Please sign in to comment.