Skip to content

Commit 7d9792f

Browse files
committed
add getbgm button, move all culling patches to one checkbox, expand fov and zoom slider range
1 parent 605220d commit 7d9792f

3 files changed

Lines changed: 34 additions & 60 deletions

File tree

PigPSO2Cam/PSO2CameraTool.cpp

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#include "Asm.h"
88
#include "imgui/settings_form.h"
99

10-
using namespace Asm;
10+
11+
1112

1213
bool m_bCreated = false;
1314
bool wndproc_found = false;
@@ -65,6 +66,8 @@ uintptr_t getCameraNearCullAddy()
6566
}
6667
HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 Device)
6768
{
69+
using namespace Asm;
70+
6871
if (Device == nullptr)
6972
return oEndScene(Device);
7073
if (!m_bCreated)
@@ -78,6 +81,7 @@ HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 Device)
7881

7982
game_hwnd = d3dcp.hFocusWindow;
8083

84+
8185
DWORD farCullScan = AobScan(cameraFarCullAob);
8286
if (farCullScan)
8387
cameraFarCullJna = farCullScan;
@@ -90,7 +94,6 @@ HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 Device)
9094
if (nearCullScan)
9195
cameraNearCullAddy = nearCullScan;
9296

93-
//menu_init(d3dhwnd, Device);
9497
}
9598
if (!wndproc_found) {
9699
HWND wnd = FindWindowA("Phantasy Star Online 2", NULL);
@@ -102,7 +105,7 @@ HRESULT __stdcall hkEndScene(LPDIRECT3DDEVICE9 Device)
102105
}
103106
}
104107

105-
if ((GetAsyncKeyState(0x2D) & 1)) { //insert
108+
if ((GetAsyncKeyState(VK_INSERT) & 1)) {
106109
MENU_DISPLAYING = !MENU_DISPLAYING;
107110
}
108111
if (MENU_DISPLAYING )
@@ -148,7 +151,6 @@ bool CreateDeviceD3D(HWND hWnd)
148151
g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
149152
g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
150153
g_d3dpp.hDeviceWindow = tmpWnd;
151-
//g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; // Present with vsync
152154
g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync, maximum unthrottled framerate
153155
if (g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0)
154156
return false;
@@ -180,23 +182,6 @@ DWORD WINAPI HookThread()
180182
return 0;
181183
}
182184

183-
BOOL CALLBACK find_game_hwnd(HWND hwnd, LPARAM game_pid) {
184-
DWORD hwnd_pid = NULL;
185-
GetWindowThreadProcessId(hwnd, &hwnd_pid);
186-
if (hwnd_pid != game_pid)
187-
return TRUE;
188-
game_hwnd = hwnd;
189-
return FALSE;
190-
}
191-
void ShowDebugConsole()
192-
{
193-
AllocConsole();
194-
AttachConsole(GetCurrentProcessId());
195-
196-
char charConsoleName[128];
197-
sprintf_s(charConsoleName, "PSO2DEBUG | PID: %08X (%d)", GetCurrentProcessId(), GetCurrentProcessId());
198-
SetConsoleTitleA(charConsoleName);
199-
}
200185
int Initialize() {
201186
/*while (hmRendDx9Base == NULL)
202187
{

PigPSO2Cam/imgui/settings_form.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ void luaPrint(std::string s) {
2020

2121
runLuaAsync(dist.c_str());
2222
}
23-
/*
24-
void resetParam() {
25-
const char *a1 = "ResetParam()";
26-
runLuaAsync(a1);
27-
}*/
2823

2924
bool runLuaAsync(std::string a1) {
3025
if (initLuaHook()) {
@@ -47,11 +42,9 @@ bool initLuaHook() {
4742
return true;
4843
HMODULE pso2h = GetModuleHandleA("pso2h.dll");
4944
if (!pso2h) {
50-
// Log("Failed to load pso2h.dll");
5145
return false;
5246
}
5347
_executeLua = (pso2hDoLua)GetProcAddress(pso2h, MAKEINTRESOURCEA(8)); //pso2hDoLua ordinal
54-
5548

5649
if (_executeLua) {
5750
return true;
@@ -66,11 +59,9 @@ void menu_init(void *game_hwnd, LPDIRECT3DDEVICE9 Device)
6659
ImGui_ImplWin32_Init(game_hwnd);
6760
ImGui_ImplDX9_Init(Device);
6861
ImGuiIO &io = ImGui::GetIO();
69-
// io.WantCaptureKeyboard = true;
7062
io.WantCaptureMouse = true;
7163
io.Fonts->AddFontDefault();
7264
io.IniFilename = NULL;
73-
//io.DisplaySize = ImVec2(vp.Height, vp.Width);
7465
hwnd = game_hwnd;
7566
ImGuiStyle& style = ImGui::GetStyle();
7667
style.Alpha = 1.0;

PigPSO2Cam/imgui/settings_form.h

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "../PSO2CameraTool.hpp"
1212

13-
1413
typedef HRESULT(__stdcall* pso2hDoLua)(const char* a1);
1514
static pso2hDoLua _executeLua = 0;
1615

@@ -76,13 +75,13 @@ static void draw_menu(bool* status)
7675
ImGui::GetIO().MouseDrawCursor = true;
7776

7877
ImGui::SetNextWindowPos(ImVec2(ImGui::GetWindowSize().x / 2, ImGui::GetWindowSize().y / 2), ImGuiCond_Appearing);
79-
ImGui::SetNextWindowSize(ImVec2(480.0f, 245.f), ImGuiCond_Appearing);
78+
ImGui::SetNextWindowSize(ImVec2(480.0f, 200.f), ImGuiCond_Appearing);
8079

8180
ImGuiWindowFlags window_flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar;
8281

8382
ImGui::Begin("PIG PSO2", status, window_flags);
8483

85-
84+
8685
switch (currTab) {
8786
case 0:
8887
{
@@ -93,10 +92,10 @@ static void draw_menu(bool* status)
9392

9493
ImGui::Text(("Zoom "));
9594
ImGui::SameLine(50.0, ImGui::GetStyle().ItemSpacing.y);
96-
ImGui::SliderInt(("##zoomslider"), &Camera::cameraBase.Offset.Dist, 6, 14);
95+
ImGui::SliderInt(("##zoomslider"), &Camera::cameraBase.Offset.Dist, 6, 25);
9796
ImGui::Text(("Fovy "));
9897
ImGui::SameLine(50.0, ImGui::GetStyle().ItemSpacing.y);
99-
ImGui::SliderInt(("##fovslider"), &Camera::cameraBase.Fovy, 40, 58);
98+
ImGui::SliderInt(("##fovslider"), &Camera::cameraBase.Fovy, 40, 90);
10099

101100
ImGui::NextColumn();
102101
if (ImGui::Button("Set Zoom", ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
@@ -111,11 +110,7 @@ static void draw_menu(bool* status)
111110
ImGui::Separator();
112111

113112
ImGui::Columns(2);
114-
ImGui::Text("Disable Terrain Far Culling ");
115-
ImGui::Spacing();//meme alignment
116-
ImGui::Text("Disable Object Far Culling ");
117-
ImGui::Spacing();
118-
ImGui::Text("Disable Object Near Culling ");
113+
ImGui::Text("Culling Patches");
119114
ImGui::Spacing();
120115
ImGui::Spacing();
121116

@@ -124,7 +119,7 @@ static void draw_menu(bool* status)
124119
ImGui::InputText("##BGM", bgmbuf, sizeof(bgmbuf));
125120

126121
ImGui::NextColumn();
127-
if (ImGui::Checkbox("##farcullcheck", &farCullDisabled))
122+
if (ImGui::Checkbox("##cullcheck", &farCullDisabled))
128123
{
129124
BYTE b = 0x76; //original conditional jmp byte
130125
if (farCullDisabled)
@@ -133,39 +128,37 @@ static void draw_menu(bool* status)
133128
uintptr_t tFarCull = getTerrainFarCullAddy();
134129
if (tFarCull)
135130
*(BYTE*)(tFarCull) = b;
136-
}
137-
138-
if (ImGui::Checkbox("##farcullcheckobjects", &farCullObjectsDisabled))
139-
{
140-
uintptr_t tFarCull = getObjectFarCullAddy();
141-
if (tFarCull)
131+
132+
//if (ImGui::Checkbox("##farcullcheckobjects", &farCullObjectsDisabled))
133+
134+
uintptr_t tFarCullObj = getObjectFarCullAddy();
135+
if (tFarCullObj)
142136
{
143-
BYTE b = 0x0F;
144-
if (farCullObjectsDisabled)
137+
BYTE c = 0x0F;
138+
if (farCullDisabled)
145139
{
146-
b = 0xE9;
140+
c = 0xE9;
147141

148-
*(BYTE*)(tFarCull) = 0x90;
149-
*(BYTE*)(tFarCull+1) = b;
142+
*(BYTE*)(tFarCullObj) = 0x90;
143+
*(BYTE*)(tFarCullObj + 1) = c;
150144
}
151145
else
152146
{
153-
*(BYTE*)(tFarCull) = b;
154-
*(BYTE*)(tFarCull + 1) = 0x84;
147+
*(BYTE*)(tFarCullObj) = b;
148+
*(BYTE*)(tFarCullObj + 1) = 0x84;
155149
}
156150
}
157-
}
158151

159-
if (ImGui::Checkbox("##nearcullcheck", &nearCullDisabled))
160-
{
152+
//if (ImGui::Checkbox("##nearcullcheck", &nearCullDisabled))
153+
161154
uintptr_t tNearCull = getCameraNearCullAddy();
162155
if (tNearCull) {
163-
156+
164157
if (oNearCullBytes == 0x0)
165158
oNearCullBytes = *(DWORD*)(tNearCull);
166159

167160
//meme
168-
if (nearCullDisabled)
161+
if (farCullDisabled)
169162
*(DWORD*)(tNearCull) = (DWORD)(0x90909090);
170163
else
171164
*(DWORD*)(tNearCull) = (DWORD)(oNearCullBytes);
@@ -176,6 +169,11 @@ static void draw_menu(bool* status)
176169
std::string s("Skit.Sound.BGM.Play('"+std::string(bgmbuf)+"')");
177170
runLuaAsync(s);
178171
}
172+
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 5);
173+
if (ImGui::Button("Get BGM", ImVec2(ImGui::GetContentRegionAvail().x, 0))) {
174+
std::string s("Window.ShowError(Skit.Sound.BGM.Get('" + std::string(bgmbuf) + "'))");
175+
runLuaAsync(s);
176+
}
179177
ImGui::EndColumns();
180178

181179

@@ -187,7 +185,7 @@ static void draw_menu(bool* status)
187185

188186
std::string pig("pig");
189187
ImVec2 txt = ImGui::CalcTextSize(pig.c_str());
190-
ImGui::SetCursorPosY(ImGui::GetWindowSize().y * .90f);
188+
ImGui::SetCursorPosY(ImGui::GetWindowSize().y * .87f);
191189
//ImGui::SetCursorPosY(ImGui::GetContentRegionAvail().y * 0.94f);
192190
ImGui::Separator();
193191

0 commit comments

Comments
 (0)