# MANEDIT loader trace

This traces the separate development editor shipped on the disc. Its preview figure and pose sequences are not used in Apache’s missions. See [the connection to Apache](format.md#connection-to-apache) for actor and placement evidence.

The supplied editor identifies itself as `SCAWEN ROBERTS - MANEDIT 1.05`. It is a bound X-32 executable: its protected-mode image begins at file offset `0x5391`, is `0x12230` bytes long, and contains the Watcom C/C++32 runtime signature. Addresses below are relative to that image.

The text loader begins at `0x8c78`, and the saver at `0x8e8c`. Both append `.ROT` to the supplied basename. The loader reads the first character; `G` and `H` select twelve joint channels and consume a second character as the motion type. Other initial characters are themselves the motion type and select eleven joint channels.

Three decimal header integers are stored as frame count (state offset 4), cycle duration (offset 12) and motion speed (offset 0). `H` implies a component count of three. Other prefixes read another integer for that count. Each frame occupies 108 bytes. Its first two values are multiplied by 1048 and shifted right ten. `H` also reads a third root value; other formats set it to zero. Each joint reads one angle, plus a second when the component count is three. The two angle arrays begin at frame offsets 12 and 60.

The saver always writes `H` followed by the motion type. It writes the header fields in the same order, converts the first two root values with `(value << 10) / 1048`, and writes the remaining root value plus twelve angle pairs.

## Motion evaluation

The evaluator at `0x8fd8` receives a state pointer in EAX and elapsed milliseconds in EDX. State offsets 16, 20 and 24 hold elapsed time, current keyframe and next keyframe. The evaluated pose begins at offset 28, and the keyframe array pointer is at 136.

Type I clamps at the final frame and divides the duration into `frame_count - 1` intervals. Other types wrap and use `frame_count` intervals, including the final-to-first transition. Interpolation uses integer weights derived from the two keyframe times. Its denominator is `duration / interval_count`, rounded down. The two weights are calculated separately with integer division, so they need not add to that rounded denominator. This small arithmetic quirk is retained in the viewer.

The first stored root channel is not drawn. The second becomes vertical body displacement. The third is body yaw. Angles are stored in units of 1/65536 turn; after interpolation, the editor converts them to radians scaled by 1024 with its literal pi value `3.1416`, truncating toward zero. Trigonometry then uses x87 sine/cosine and converts the result to a 1024-scale integer matrix.

## Figure and joints

The constructor at `0x7610` builds the figure directly from constants. Its nineteen parts are pelvis, torso, neck, head, paired upper arms, forearms, hands, thighs, shins, feet and toes, plus a held weapon. The final weapon constructor is called twice for the same destination. The figure faces +Y, with +Z up and +X on its right.

The updater at `0x8a70` supplies these twelve joint pairs:

| Pair | Part | Rotation order |
| ---: | --- | --- |
| 0 | Whole body | X, Y, then the separate root yaw Z |
| 1 | Right upper arm | X, Y |
| 2 | Right forearm | X, Y |
| 3 | Right thigh | X, Y |
| 4 | Right shin | X, Y |
| 5 | Right foot | X, Z |
| 6 | Left upper arm | X, Y |
| 7 | Left forearm | X, Y |
| 8 | Left thigh | X, Y |
| 9 | Left shin | X, Y |
| 10 | Left foot | X, Z |
| 11 | Held weapon | X, Z |

These assignments follow the constructed attachment chains and the updater's matrix destinations. The weapon belongs to the right hand. Older eleven-pair formats omit its extra pair. The split-cycle editor operation pairs the left and right limbs half a cycle apart; it shares the same cyclic playback evaluator.

`editor.json` contains the original generated vertices, attachment translations and hierarchy. The viewer reproduces the integer interpolation and joint matrices, then draws the figure with its own orbit camera and colours. The original-execution check passes 1,040 cases and 31,200 fields across all 104 supported files. The browser math passes 312 samples and 43,056 fields, including rotation matrices.

## Newer files

`DIRFWD.ROT`, `DIRLEFT.ROT`, `DIRRIGHT.ROT`, `DIRSTOP.ROT`, `IHAVCOMM.ROT` and `LEFTTEST.ROT` use II/IC signatures with 29 channels. The shipped loader does not understand these two-letter I-family headers. They remain raw-channel records rather than being passed through the older eleven-joint interpretation. All six supplied MANEDIT executables are byte-identical, including the copy in the Hind demo.
