Document numeric HUD opcode contracts

This commit is contained in:
gamer147
2026-07-21 15:40:46 -04:00
parent 9fd94ff540
commit e2973f66b1
5 changed files with 112 additions and 46 deletions

View File

@@ -2467,6 +2467,38 @@ Focused tests cover stability, overflow, and zero count. A real-script regressio
SYSTEM4-to-SC0000 state into CHMENU and stops after `0x1db8`, proving selected slot 2 survives the first
release roster sort without a fallback. No startup seed or menu-specific roster injection is involved.
### Numeric glyph styles/draws and half-byte string length — `0x13a` / `0x23b` / `0x1a6` (2026-07-21)
The missing values in the first working `DEBUGMAP` field HUD are not missing globals or a failed texture
load. They are generated by a dedicated decimal-glyph subsystem whose two opcodes were still skipped by
the port:
- `op_0x13a_register_numeric_glyph_style@0x421ab0` takes
`(style_index, surface_slot, atlas_x, atlas_y, digit_width, digit_height)`. It accepts style indices
`0..10` and stores the remaining five operands in the 20-byte record at
`EngineCtx+0x55180+style_index*0x14`; an invalid index raises the standard script error. The corpus has
74 registrations in 24 scripts, including eight in `DRAWCHP.BIN`.
- `op_0x23b_draw_decimal_glyphs@0x424190` takes
`(base_handle, style_index, value, x, y, digit_capacity, flags)`. It first erases the destination handle
range, splits the signed integer through division/remainder by ten, and binds one retained object per
displayed digit using horizontally adjacent cells from the selected style record. Flag bit `0x1`
includes leading zeroes, bit `0x2` centers the used digits, and bit `0x4` left-aligns them; without an
alignment flag the value is right-aligned in the requested capacity. An invalid or unregistered style
raises the script error. The corpus has 147 draws in the same 24 scripts; `DRAWCHP.BIN` has 22 and uses
them for the field HUD's turn/control/mana/level/HP/SP/FS values.
This path creates ordinary retained graphics objects, so the existing atlas decode and compositor are
already the correct backend. The missing engine model is the 11 style records plus the two VM dispatches;
it is not an immediate `GodotAdvHost.DrawTexture` raster operation.
The absent unit and weapon names are a separate layout-compute gap. `DRAWCHP.BIN` does populate both
strings and calls `draw-string` at `0x9c6`/`0x9f5`, but first centers each one with opcode `0x1a6`.
`op_0x1a6_half_byte_strlen@0x427020` resolves the NUL-terminated engine byte string and writes
`strlen(bytes) >> 1`. The script multiplies that result by 21 and subtracts it from x=257 on a 263-pixel
scratch surface. With the opcode skipped, x remains 257 and Godot correctly clips nearly all of the text.
An implementation must preserve the original encoded byte count (or reproduce it with CP932 encoding),
not use the .NET UTF-16 character count.
---
## Native walls backlog (targets for this loop)