mirror of
https://github.com/TheBozos/VP2S_Recomp.git
synced 2026-12-01 07:38:48 -10:00
Field pause: the frozen town under the menu, as the game draws it again
VP2's pause freezes the town's objects (+0x6A bit 0x01, set by mod001 0x266490 from the pause module) and the cull drops them, on the PS2 too (PCSX2 save states: master list 0x6D -> 0x22). What PCSX2 shows is the last field frame, kept by the GS and drawn again by a scene object of class 0x1670D0: at 112/128, then 16 copies at 80/128 with alpha 12/128, copy k moved by (-k, -2k) GS pixels. Natively: the renderer's captureFrame when that object appears in the master list, drawn the same way between the 3D and the interface (vp2sUiFrozenFrame, from the post effect hook). Pause / town brightness ratio 0.70 here, 0.58 on PCSX2: still to see. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
d4fdebbfe6
commit
79d217fdba
4 files changed
+69
-1
No files matched your search
Vendored
+1
-1
Submodule external/PS2Recomp updated: 8a59849900...6be6dfa1e8.
@@ -8,6 +8,7 @@
|
||||
#include "vp2s_battle_hud.h"
|
||||
#include "vp2s_loads.h"
|
||||
#include "vp2s_textures.h"
|
||||
#include "vp2s_ui.h"
|
||||
|
||||
#include "ps2_overlay_modules.h"
|
||||
#include "ps2_runtime.h"
|
||||
@@ -297,6 +298,7 @@ namespace
|
||||
const uint8_t *g_rdram = nullptr; // EE memory, for the frame end's diagnostics
|
||||
size_t g_interfaceStart = SIZE_MAX; // the frame's first interface batch (vp2sModelsInterfaceStarts)
|
||||
bool g_sceneOverlaysDrawn = false; // this frame's scene overlays (the minimap) are in, before its effect passes
|
||||
uint32_t g_scene = 0; // the scene pass's scene (its a0), last seen
|
||||
|
||||
// The scene's own 2D (the minimap) goes after the 3D and before the game's effect passes, as the GS gets them:
|
||||
// drawn at the first effect pass of the frame.
|
||||
@@ -1080,6 +1082,7 @@ void vp2sInstallModels(PS2Runtime &)
|
||||
if (s_scenePass)
|
||||
ps2_overlays::replaceModuleFunction("mod001", kScenePass, [](uint8_t *rdram, R5900Context *ctx, PS2Runtime *runtime) {
|
||||
g_rdram = rdram;
|
||||
g_scene = getRegU32(ctx, 4) & 0x1FFFFFFu;
|
||||
s_scenePass(rdram, ctx, runtime);
|
||||
vp2sModelsFrameEnd();
|
||||
});
|
||||
@@ -1099,6 +1102,8 @@ void vp2sInstallModels(PS2Runtime &)
|
||||
ps2_overlays::replaceModuleFunction("mod001", kPostEffect, [](uint8_t *rdram, R5900Context *ctx, PS2Runtime *runtime) {
|
||||
s_post(rdram, ctx, runtime);
|
||||
sceneOverlays();
|
||||
if (g_scene >= 0x100000u)
|
||||
vp2sUiFrozenFrame(rdram, g_scene);
|
||||
const uint32_t owner = word(rdram, 0x0035DDF8u) & 0x1FFFFFFu;
|
||||
const uint32_t post = owner ? word(rdram, owner + 0x4448u) & 0x1FFFFFFu : 0u; // the object (docs/vp2_dof.md)
|
||||
if (post < 0x100000u)
|
||||
|
||||
@@ -744,6 +744,35 @@ namespace
|
||||
drawQuadCorners(x0, y0, x1, y1, u0, v0, u1, v1, corners, std::move(texture));
|
||||
}
|
||||
|
||||
// The renderer's captured frame over the whole screen, moved by (dx, dy), grey `colour` and `alpha` (0x80 = 1).
|
||||
void drawFrozenFrame(float dx, float dy, uint32_t colour, uint32_t alpha)
|
||||
{
|
||||
static const float s_identity[16] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
|
||||
ps2x::native::Material material;
|
||||
material.blend = ps2x::native::Material::Blend::Alpha;
|
||||
material.alphaBlend = true;
|
||||
material.depthTest = false;
|
||||
material.depthWrite = true;
|
||||
material.textured = true;
|
||||
material.tex0 = ps2x::native::Renderer::kCapturedFrame;
|
||||
material.clampU = material.clampV = true;
|
||||
const uint32_t rgba = colour | colour << 8 | colour << 16 | alpha << 24;
|
||||
const auto vertex = [&](float vx, float vy, float u, float v) {
|
||||
ps2x::native::Vertex out;
|
||||
out.x = 1728.0f + vx + dx;
|
||||
out.y = 1824.0f + (vy + dy) * (448.0f / 480.0f);
|
||||
out.z = 16777215.0f;
|
||||
out.u = u;
|
||||
out.v = v;
|
||||
out.rgba = rgba;
|
||||
return out;
|
||||
};
|
||||
const ps2x::native::Vertex quad[6] = {vertex(0, 0, 0, 0), vertex(640, 0, 1, 0), vertex(0, 480, 0, 1),
|
||||
vertex(640, 0, 1, 0), vertex(640, 480, 1, 1), vertex(0, 480, 0, 1)};
|
||||
vp2sModelsInterfaceStarts();
|
||||
ps2x::native::Renderer::instance().draw(material, s_identity, quad, 6u);
|
||||
}
|
||||
|
||||
uint32_t scaled(uint32_t rgba, uint32_t colourScale, uint32_t alpha)
|
||||
{
|
||||
const auto channel = [&](int c) { return std::min<uint32_t>(((rgba >> (8 * c)) & 0xFFu) * colourScale / 128u, 0xFFu); };
|
||||
@@ -1042,6 +1071,35 @@ void vp2sUiNoteFixedSheet(uint32_t dbp, uint32_t tag, uint32_t index)
|
||||
g_fixedSheets[dbp & 0x3FFFu] = {tag, index};
|
||||
}
|
||||
|
||||
void vp2sUiFrozenFrame(uint8_t *rdram, uint32_t scene)
|
||||
{
|
||||
// The scene's master list (+0x7C, count +0xFB80) with an object of class 0x1670D0 in it, not frozen or hidden
|
||||
// (+0x6A & 0x49, the cull's own test at 0x2207EC).
|
||||
const uint32_t list = word(rdram, scene + 0x7Cu) & 0x1FFFFFFu, count = std::min(word(rdram, scene + 0xFB80u), 0x2000u);
|
||||
uint32_t frozen = 0;
|
||||
for (uint32_t i = 0; list >= 0x100000u && i < count && !frozen; ++i)
|
||||
{
|
||||
const uint32_t object = word(rdram, list + 4u * i) & 0x1FFFFFFu;
|
||||
if (object >= 0x100000u && (word(rdram, object) & 0x1FFFFFFu) == 0x1670D0u && !(rdram[object + 0x6Au] & 0x49u))
|
||||
frozen = object;
|
||||
}
|
||||
// Captured as the object appears (the frame on screen is the last one without it), not again while it stays.
|
||||
static uint32_t s_object = 0;
|
||||
const uint32_t before = s_object;
|
||||
s_object = frozen;
|
||||
if (!frozen)
|
||||
return;
|
||||
if (frozen != before)
|
||||
{
|
||||
ps2x::native::Renderer::instance().captureFrame();
|
||||
std::printf("[vp2s-ui] frozen frame %x: the frame on screen captured\n", frozen);
|
||||
std::fflush(stdout);
|
||||
}
|
||||
drawFrozenFrame(0.0f, 0.0f, 0x70u, 0x80u);
|
||||
for (int k = 1; k <= 16; ++k)
|
||||
drawFrozenFrame(-k * 640.0f / 512.0f, -2.0f * k * 480.0f / 448.0f, 0x50u, 0x0Cu);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
// VP2S_MENU_LOG: the data menu's state machine (mod016 0x4992A0(a0 menu): state +0x70; its dialog *(menu + 4),
|
||||
|
||||
@@ -7,3 +7,8 @@ void vp2sInstallUi(PS2Runtime &runtime);
|
||||
bool vp2sUiFixedSheet(uint32_t dbp, uint32_t &tag, uint32_t &index);
|
||||
// Notes a sheet another module's uploader put at a fixed DBP (the battle's mod027 0x36B3A0).
|
||||
void vp2sUiNoteFixedSheet(uint32_t dbp, uint32_t tag, uint32_t index);
|
||||
// The field pause's background (scene object class 0x1670D0): the game draws its last field frame again, which the GS
|
||||
// kept, as its packet does: at 112/128, then 16 copies at 80/128 with alpha 12/128, copy k moved by (-k, -2k) pixels
|
||||
// of the 512 x 448 GS frame. Natively: a picture of the frame on screen when the object appears (the renderer's
|
||||
// captureFrame), drawn the same way. Called between the 3D and the interface, with the scene pass's scene.
|
||||
void vp2sUiFrozenFrame(uint8_t *rdram, uint32_t scene);
|
||||
Reference in new issue
Block a user