From d1fb2daa4183463f33a2ebef76a6f08ddf871c8e Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Thu, 28 Dec 2023 16:10:00 -0500 Subject: [PATCH] Implement avatar limb animations Refactor helpers to take "impl" objects rather than functions --- avatars.txt | 16 +++++- body.html | 18 +++++- detail.html | 6 +- index.html | 14 ++--- index.js | 163 +++++++++++++++++++++++++++++----------------------- 5 files changed, 130 insertions(+), 87 deletions(-) diff --git a/avatars.txt b/avatars.txt index 939d244..7c7b178 100644 --- a/avatars.txt +++ b/avatars.txt @@ -42,6 +42,8 @@ cels_affected_by_height: ; an index into a table of bitmasks, states are defined as an index into ; the table of cels directly. only one cel is visible per-limb at a time. +; 1 - padding to match prop header? always zero. +; 2 - offset of start_end table ; 1-2 - unknown. first byte seems to always be zero. second byte seems ; to be correlated with the number of frames or cels, but isn't a direct ; count of either. @@ -88,6 +90,14 @@ which suggests these as valid values. define AV_ACT_sit_front = 0x80 + 29 ; choreography tables: -; an array of arrays of bytes, indicating "states". if the high bit is -; set, this signals the end of the inner array. -; unclear at this time how exactly these values are interpreted. +; an array of arrays of bytes, indicating "states". Each byte has three +; values packed into it: ElllAAAA +; E (0x80): "end" bit - if this is set, indicates that this is the last +; byte of the array. +; l (0x70): "limb" - value from 0-6, indexing the 6 limbs. If limb is 6, +; 0x10 is added to S and limb is set to 5. Stored in the X +; register and passed to `init_avatar_chores` (chore.m:252) +; A (0x0f): "animation" - index of animation in the limb's start_end table + +; I believe all limbs default to animation 0 if no alternative animation is given +; for a given chore in the choreography table. \ No newline at end of file diff --git a/body.html b/body.html index 36949b0..db4bc97 100644 --- a/body.html +++ b/body.html @@ -15,10 +15,13 @@ line-height:1.2 } - +

+
+

Limbs

+

Cels

@@ -37,19 +40,28 @@ container.appendChild(textNode(JSON.stringify(prop, propFilter, 2), "pre")) } + const limbNames = ["legs", "legs2", "left arm", "torso", "face", "right arm"] + const labelLimb = (container, ilimb) => { + container.appendChild(textNode(ilimb < limbNames.length ? limbNames[ilimb] : `Limb #${ilimb}??`, "div")) + } const onload = async () => { const q = new URLSearchParams(window.location.search) const filename = q.get("f") document.getElementById("filename").innerText = filename try { - const body = await decodeBinary(filename, decodeBody) + const body = await decodeBinary(filename, BodyImpl) dumpProp(body, document.getElementById("data")) if (body.error) { showError(body.error, filename) } else { const celContainer = document.getElementById("cels") - for (const limb of body.limbs) { + const limbContainer = document.getElementById("limbs") + for (const [ilimb, limb] of body.limbs.entries()) { + labelLimb(celContainer, ilimb) showCels(limb, celContainer) + + labelLimb(limbContainer, ilimb) + showAnimations(limb, limbContainer, LimbImpl) } } } catch (e) { diff --git a/detail.html b/detail.html index fc7dcbc..e593a2c 100644 --- a/detail.html +++ b/detail.html @@ -15,7 +15,7 @@ line-height:1.2 } - +

@@ -48,12 +48,12 @@ const filename = q.get("f") document.getElementById("filename").innerText = filename try { - const prop = await decodeBinary(filename, decodeProp) + const prop = await decodeBinary(filename, PropImpl) dumpProp(prop, document.getElementById("data")) if (prop.error) { showError(prop.error, filename) } else { - showAnimations(prop, document.getElementById("animations")) + showAnimations(prop, document.getElementById("animations"), PropImpl) showStates(prop, document.getElementById("states")) showCels(prop, document.getElementById("cels")) } diff --git a/index.html b/index.html index 873dd17..86aae3c 100644 --- a/index.html +++ b/index.html @@ -15,18 +15,18 @@ line-height:1.2 } - +