HUD reticle + weapon pips LIVE: dpl2d 2D display-list port (task #35)

- dpl2d API fully recovered from the binary recorders (@487f34-488630):
  opcode model (points/lines/polyline/circle/color/width/matrix/push-pop),
  CallList = INLINE include (state persists to caller), centered coordinate
  frame (unit = half viewport height). game/reconstructed/dpl2d.cpp rework.
- BTReticleRenderable ctor @004cc40c transcribed with the authentic
  calibration (originX .35, originY .25, scaleY .5, 0..1200m right range
  ladder, bottom heading tape, FUN_004cd938 tick ladders, lock rings,
  turn arrows); range caret slides from the live target range fed by the
  mech4 targeting step (BTSetHudTargetRange).
- Weapon pips: the binary gate is IsDerivedFrom(0x511830 =
  MechWeapon::ClassDerivations) [T1: part_014.c:5386 hard-aborts on missing
  weapon attrs; part_012 counts + roster ORs capabilityFlags@+0x334] so ALL
  7 BLH weapons register (3 lasers + 2 PPCs + 2 MissileLaunchers). Pip A
  (lit, authored PipColor) on TargetWithinRange, else dark ring B.
- AddWeapon @004cdac0 store map corrected to the verified order
  (part_014.c:4827-4837); both state attrs are literally named
  "SimulationState" (strings @51d526/51d577) -> weapon simulationState.
- Mech roster this[0x1ef] renamed poweredSubsystems -> weaponRoster
  (0x511830 is MechWeapon, not PoweredSubsystem=0x50f4bc); derivation-tag
  table added to context/decomp-reference.md.
- Draw hook BTDrawReticle after the 3D scene, cockpit view only. Binary
  Execute @004cdcf0 is an un-exported gap -> Draw dynamics [T3], tracked
  in context/open-questions.md with the blx_cop canopy + PNAME pip meshes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
arcattack
2026-07-08 20:05:44 -05:00
co-authored by Claude Fable 5
parent 1cd8ca1a80
commit 48b17750e5
15 changed files with 593 additions and 109 deletions
+23 -8
View File
@@ -341,6 +341,16 @@ namespace
Mat2x3 mat;
};
//
// COORDINATE MODEL (from the reticle's authored constants): centred origin,
// +x right, +y down, unit = half the viewport HEIGHT on both axes (keeps
// circles round; the reticle content spans roughly +-0.5).
//
inline float MapX(float x, float ox, float vw, float vh)
{ return ox + vw * 0.5f + x * (vh * 0.5f); }
inline float MapY(float y, float oy, float vh)
{ return oy + vh * 0.5f + y * (vh * 0.5f); }
void DrawVertexRun(IDirect3DDevice9 *device, const Command &cmd,
const ExecState &st, float ox, float oy, float vw, float vh)
{
@@ -352,7 +362,7 @@ namespace
{
Vec2 p = st.mat.Apply(cmd.verts[i].x, cmd.verts[i].y);
Vertex2D v;
v.x = ox + p.x * vw; v.y = oy + p.y * vh;
v.x = MapX(p.x, ox, vw, vh); v.y = MapY(p.y, oy, vh);
v.z = 0.0f; v.rhw = 1.0f; v.color = st.color;
verts.push_back(v);
}
@@ -389,11 +399,11 @@ namespace
}
void ExecuteListInner(Dpl2dList *self, IDirect3DDevice9 *device,
ExecState st, float ox, float oy, float vw, float vh, int depth)
ExecState &st, std::vector<ExecState> &stack,
float ox, float oy, float vw, float vh, int depth)
{
if (self == 0 || depth > 8)
return;
std::vector<ExecState> stack;
Vertex2D ring[kCircleSegments + 2];
for (size_t i = 0; i < self->commands.size(); ++i)
@@ -412,8 +422,12 @@ namespace
st.mat = Mat2x3::Mul(cmd.mat, st.mat);
break;
case Command::kCallList:
// INLINE include: a called list's state changes (matrices,
// colours) PERSIST into the caller -- the reticle's range
// caret is a called list holding just a translate that shifts
// the master's subsequent geometry.
ExecuteListInner((Dpl2dList *)cmd.callee, device,
st, ox, oy, vw, vh, depth + 1);
st, stack, ox, oy, vw, vh, depth + 1);
break;
case Command::kPoints:
case Command::kLineStrip:
@@ -424,9 +438,9 @@ namespace
case Command::kCircleOutline:
{
Vec2 p = st.mat.Apply(cmd.a, cmd.b);
const float cx = ox + p.x * vw;
const float cy = oy + p.y * vh;
const float r = cmd.c * vw; // width-relative -> stays round
const float cx = MapX(p.x, ox, vw, vh);
const float cy = MapY(p.y, oy, vh);
const float r = cmd.c * (vh * 0.5f); // height-unit -> stays round
if (cmd.kind == Command::kCircleFill)
{
ring[0].x = cx; ring[0].y = cy; ring[0].z = 0.0f;
@@ -497,8 +511,9 @@ void dpl2d_ExecuteList(dpl2d_DISPLAY *list, IDirect3DDevice9 *device)
st.color = 0xFFFFFFFF;
st.width = 1.0f;
st.mat.Identity();
std::vector<ExecState> stack;
ExecuteListInner(self, device,
st, (float)vp.X, (float)vp.Y, (float)vp.Width, (float)vp.Height, 0);
st, stack, (float)vp.X, (float)vp.Y, (float)vp.Width, (float)vp.Height, 0);
device->SetTexture(0, oldTex);
if (oldTex) oldTex->Release();