background: pack the cabinet movies' per-frame channels into strings #56

Merged
GanYiZhong merged 1 commits from GanYiZhong/YataiDONNijiiro:perf/packed-anim-channels into main 2026-10-14 03:00:56 +02:00
Collaborator

The cabinet backdrops from #48, and the default donbg band, replay exported movies whose per-frame channels (tx, ty, sx, sy, rot, a, tint, mirror) were Lua tables of numbers. That's 38 MB of number constants, and Lua compiled it on every song start. This is the slow load Yonokid/YataiDON#295 tried to cache on the engine side; as noted there, it belongs in the skin.

Each per-frame array is now packed into a string:

tx = {base, step, width, "digits"}   -- value(i) = base + step * n, n = frame i's `width` chars in base 92

Constants stay plain numbers, and plain per-frame tables still work. bg_objects/packed_channel.lua decodes the frame being drawn, and bg_anim.lua and donbg/anim_player.lua use it instead of their own ch().

Quantization is below anything visible: 0.05 px for positions, 0.005° for rotation, 5e-5 for scale, and 1/1024 for alpha and tint (output is 8-bit). Every value of all 77 files (22.5 M frame values) was checked against the original and is within half a step.

before after
all movie data 38.4 MB, compiles in 4.0 s 26.7 MB, 0.28 s
TOHO pack (3 files) 0.72 s 0.05 s
YOKAI pack (3 files) 0.28 s 0.05 s
TOHO pack, Lua memory 19.3 MB 4.1 MB
in game, game screen init, TOHO (3 runs) 1.46–1.62 s 0.91–1.00 s
in game, game screen init, YOKAI (3 runs) 1.11–1.19 s 0.86–0.88 s

Decoding costs about 0.1 ms per frame for the heaviest layer (TOHO fever, ~1000 channel reads per frame). The backdrops draw the same as before.

🤖 Generated with Claude Code

The cabinet backdrops from #48, and the default donbg band, replay exported movies whose per-frame channels (`tx`, `ty`, `sx`, `sy`, `rot`, `a`, tint, mirror) were Lua tables of numbers. That's 38 MB of number constants, and Lua compiled it on every song start. This is the slow load Yonokid/YataiDON#295 tried to cache on the engine side; as noted there, it belongs in the skin. Each per-frame array is now packed into a string: ```lua tx = {base, step, width, "digits"} -- value(i) = base + step * n, n = frame i's `width` chars in base 92 ``` Constants stay plain numbers, and plain per-frame tables still work. `bg_objects/packed_channel.lua` decodes the frame being drawn, and `bg_anim.lua` and `donbg/anim_player.lua` use it instead of their own `ch()`. Quantization is below anything visible: 0.05 px for positions, 0.005° for rotation, 5e-5 for scale, and 1/1024 for alpha and tint (output is 8-bit). Every value of all 77 files (22.5 M frame values) was checked against the original and is within half a step. | | before | after | |---|---|---| | all movie data | 38.4 MB, compiles in 4.0 s | 26.7 MB, 0.28 s | | TOHO pack (3 files) | 0.72 s | 0.05 s | | YOKAI pack (3 files) | 0.28 s | 0.05 s | | TOHO pack, Lua memory | 19.3 MB | 4.1 MB | | in game, game screen init, TOHO (3 runs) | 1.46–1.62 s | 0.91–1.00 s | | in game, game screen init, YOKAI (3 runs) | 1.11–1.19 s | 0.86–0.88 s | Decoding costs about 0.1 ms per frame for the heaviest layer (TOHO fever, ~1000 channel reads per frame). The backdrops draw the same as before. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
GanYiZhong added 1 commit 2026-10-14 03:00:48 +02:00
The collab backdrops (and the default donbg band) replay exported movies
whose per-frame channels were Lua tables of numbers: 38 MB that Lua
compiled on every song start (0.7 s for the TOHO pack; game screen init
1.5-1.6 s -> 0.9-1.0 s in-game), plus ~19 MB of Lua memory per pack.

Each per-frame array is now {base, step, width, "digits"}: value = base +
step * n, n being the frame's width chars in base 92 (printable ASCII
without '"' and '\'). One string constant compiles in a fraction of the
time; bg_objects/packed_channel.lua decodes the frame being drawn.
Quantization: 0.05 px, 0.005 deg, 5e-5 scale, 1/1024 alpha and tint;
every value of all 77 files checked against the original within half a
step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GanYiZhong merged commit 59c743ab90 into main 2026-10-14 03:00:56 +02:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Yonokid/YataiDONNijiiro#56