From 4cc9ea687ae4a5c124109fbe2cb3c7d925b2b46d Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Fri, 30 Oct 2026 15:14:10 +0000 Subject: [PATCH] Decompile 2 functions in Source/Render/Primitives/ScreenLine.cpp, Source/UI/Window/UIRoMapWnd.h Batch #5724 by Yommy: 0 byte-identical, 2 confirmed by peer review. - fn_12591 UIRoMapWnd::DrawRecordAreas: logic confirmed by peer review - fn_12595 UIRoMapWnd::DrawKafraIcon: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, willerthal Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). Adds to the build: Source/Render/Primitives/ScreenLine.cpp --- Source/Render/Primitives/ScreenLine.cpp | 146 ++++++++++++++++++++++++ Source/UI/Window/UIRoMapWnd.h | 7 ++ data/compile.json | 1 + 3 files changed, 154 insertions(+) create mode 100644 Source/Render/Primitives/ScreenLine.cpp diff --git a/Source/Render/Primitives/ScreenLine.cpp b/Source/Render/Primitives/ScreenLine.cpp new file mode 100644 index 00000000..ebca59b1 --- /dev/null +++ b/Source/Render/Primitives/ScreenLine.cpp @@ -0,0 +1,146 @@ +#include "UI/Window/UIRoMapWnd.h" + +#include "Contents/MapSkyMgr.h" +#include "Render/Primitives/AlphaRectangle.h" +#include "Render/Renderer.h" +#include "Render/TextureQuad.h" +#include "Contents/Configuration/ServiceConfiguration.h" +#include "Render/Primitives/RenderPrimitive.h" +#include "Render/Primitives/RenderPrimitivePool.h" +#include "Render/Primitives/RenderQueues.h" +#include "Render/Textures/SpriteAtlas.h" +#include "Render/Textures/SpritePixels.h" +#include "Resource/ResourceMgr.h" +#include "Resource/Sprites/ActionResource.h" +#include "Resource/Sprites/SpriteResource.h" + +#include +#include + +// GLOBAL: gl_25021 +std::uint32_t g_roMapRecordColors[12] = { + 0x66DC143C, 0x66FFA500, 0x66FFFF00, 0x66ADFF2F, 0x6600BFFF, 0x66483D8B, 0x669400D3, 0x66FF1493, 0x66FFF5EE, 0x66F5FFFA, 0x66F0F8FF, 0x66778899, +}; + +// OFFSET: 0x00918190 +// FUNCTION: fn_12591 +void UIRoMapWnd::DrawRecordAreas() { + int color = 0; + for (std::list::const_iterator it = this->m_records.begin(); it != this->m_records.end(); ++it) { + if (g_worldViewMgr.currentWorld != it->worldIndex) { + continue; + } + + if (color == 12) { + color = 0; + } + DrawAlphaRectangle( + g_renderer->primitives, g_renderer->queues, it->left, it->top, it->right - it->left, it->bottom - it->top, g_roMapRecordColors[color], + g_renderer->fog.supported != 0, g_depthStart, g_depthEnd + ); + ++color; + } +} + +// OFFSET: 0x009189C0 +// FUNCTION: fn_12595 +void UIRoMapWnd::DrawKafraIcon(float x, float y) { + const float scale = static_cast(g_worldViewMgr.screenScale) * 0.2f + g_depthAverageHalf; + CSprRes* sprite = dynamic_cast(ResourceMgr::Instance().Load("npc\\4_f_kafra6.spr")); + CActRes* action = dynamic_cast(ResourceMgr::Instance().Load("npc\\4_f_kafra6.act")); + if (!sprite || !action) { + return; + } + + const std::vector& frames = action->Animation(0); + const int count = static_cast(frames.size()); + if (count == 0) { + return; + } + + const int tick = static_cast(timeGetTime() % 4000); + const int step = tick == 0 ? 0 : tick / (4000 / count); + const int last = count > step ? step : count - 1; + const int frame = last < 0 ? 0 : last; + const std::uint32_t* palette = sprite->palette; + + const SpriteFrameCell* cell = &frames[0].Cell(0); + if (cell->image == -1) { + return; + } + + const SpriteRleImage* image = sprite->images[cell->imageType][cell->image]; + if (!image) { + return; + } + + const int top = static_cast(y - (static_cast(image->height) * scale + 23.0f)); + const int lift = top <= 0 ? top : 0; + if (frame > 0) { + cell = &frames[frame].Cell(0); + if (cell->image == -1) { + return; + } + + image = sprite->images[cell->imageType][cell->image]; + if (!image) { + return; + } + } + + SpriteAtlasRecord record{}; + CTexture* texture; + if (cell->imageType == 0) { + texture = g_renderer->atlas.Find(image, palette, record); + if (!texture) { + texture = g_renderer->atlas.Insert(this->m_context->renderSystem, image, palette, record, g_serviceType, g_resourceReuseDelay); + } + } else { + texture = static_cast(const_cast(image->unknown_0008)); + } + + const int height = static_cast(static_cast(image->height) * scale); + const int halfWidth = static_cast(static_cast(image->width) * scale * g_depthAverageHalf); + RenderPrimitive* primitive = g_renderer->primitives.Acquire(); + RenderVertex* vertices = primitive->vertices; + const float left = x - static_cast(halfWidth); + const float right = static_cast(halfWidth) + x; + const float upper = y - static_cast(height) - static_cast(lift); + const float lower = y - static_cast(lift); + vertices[0].x = left; + vertices[0].y = upper; + vertices[1].y = upper; + vertices[2].x = left; + vertices[1].x = right; + vertices[3].x = right; + vertices[3].z = 0.8f; + vertices[2].z = 0.8f; + vertices[1].z = 0.8f; + vertices[0].z = 0.8f; + vertices[2].y = lower; + vertices[3].y = lower; + vertices[3].rhw = 1.0f; + vertices[2].rhw = 1.0f; + vertices[1].rhw = 1.0f; + vertices[0].rhw = 1.0f; + vertices[3].diffuse = 0xFFFFFFFF; + vertices[2].diffuse = 0xFFFFFFFF; + vertices[1].diffuse = 0xFFFFFFFF; + vertices[0].diffuse = 0xFFFFFFFF; + vertices[0].u = record.u0; + vertices[0].v = record.v0; + vertices[1].u = record.u1; + vertices[1].v = record.v0; + vertices[2].u = record.u0; + vertices[2].v = record.v1; + vertices[3].u = record.u1; + vertices[3].v = record.v1; + primitive->texture = texture; + primitive->unknown_0018 = 2; + primitive->unknown_001C = 4; + g_renderer->queues.Submit(primitive, 513, g_renderer->fog.supported != 0, g_depthStart, g_depthEnd); + this->m_kafraTop = static_cast(vertices[0].y); + this->m_kafraBottom = static_cast(vertices[3].y); + this->m_kafraLeft = static_cast(vertices[0].x); + this->m_kafraRight = static_cast(vertices[3].x); +} diff --git a/Source/UI/Window/UIRoMapWnd.h b/Source/UI/Window/UIRoMapWnd.h index 69ed22ef..81c32752 100644 --- a/Source/UI/Window/UIRoMapWnd.h +++ b/Source/UI/Window/UIRoMapWnd.h @@ -40,6 +40,8 @@ public: void DrawDungeonLinks(); void DrawMarks(); void DrawRecordFaces(int unused); + void DrawRecordAreas(); + void DrawKafraIcon(float x, float y); private: /* 00B4 */ std::list m_records; @@ -52,6 +54,11 @@ private: /* 00D4 */ unsigned char m_showLabels; /* 00D5 */ unsigned char unknown_00D5[0x133]; /* 0208 */ int unknown_0208; + /* 020C */ unsigned char unknown_020C[0xC]; + /* 0218 */ int m_kafraLeft; + /* 021C */ int m_kafraTop; + /* 0220 */ int m_kafraRight; + /* 0224 */ int m_kafraBottom; }; #if defined(_WIN32) && !defined(_WIN64) diff --git a/data/compile.json b/data/compile.json index 061fe1ac..165d02e6 100644 --- a/data/compile.json +++ b/data/compile.json @@ -731,6 +731,7 @@ "Source/Render/Primitives/RenderPrimitivePool.cpp": 0, "Source/Render/Primitives/RenderQueues.cpp": 0, "Source/Render/Primitives/RenderVertexPool.cpp": 0, + "Source/Render/Primitives/ScreenLine.cpp": 0, "Source/Render/Primitives/UIRPData.cpp": 0, "Source/Render/Projection/RenderProjection.cpp": 0, "Source/Render/Projection/RenderRay.cpp": 0,