Combat & Events
Three systems drive the strategic game once units start meeting: the
encounter scan (who meets whom, and which dialog opens), combat
(one large battle routine, LAB_0A47), and the campaign events (an
8-bit event bitfield, the hourly day panel, and four end conditions). All
three were traced in the disassembly first, and since 2026-11-30 every rule
below has been run on the original code under a 68000 harness and
compared with this project’s TypeScript, each with a null control that
proves the comparison can fail. Method and numbers:
How We Verified the Rules. Raw notes:
docs/wime/amiga/game-logic.md, event-system.md, logic-harness.md and
battle-screen-presentation.md in the main repo (not part of this site).
Corrections published 2026-12-01. Running the real code overturned these claims from an earlier version of this page:
- Event bits 4 and 7 are not raised “around” day 149 (mid-March) and day 169 (early April). They are raised at 08:00 on exactly day 149 (20 February 1419) and day 169 (10 March 1419), with
==tests; a skipped day misses them.- Bit 7’s third trigger is not “a dialog choice”. It is the Palantir.
- Bits 3 and 5 are not raised by “an entity” at Isen Ford: only an evil unit (
obedience == 0) raises them there.- The order names were wrong. The four orders are Charge, Engage, Withdraw, Retreat, and Withdraw is not a lighter commitment: it is inert (no power, no capacity, no casualties).
- A Ring bearer’s death does not “scatter the Ring to a small set of nearby recovery destinations”. The Ring is handed to a new bearer; only on the evil path are the other Nazgûl scattered, to three named places.
- A “credits scroll” after victory does not exist. What an earlier note read as a descending Y coordinate is the x of a row of figures.
When two units meet
Section titled “When two units meet”The trigger: 7 pixels, from the mover’s own turn
Section titled “The trigger: 7 pixels, from the mover’s own turn”A meeting can only start from a unit’s own movement turn, after a step.
A stationary unit never starts one. The scan (CODE+0xF028-0xF27E):
- On a tile corner it scans from entity 1; off a corner it scans only the encounter cast (entities 152-195, the wolves, spiders, wights, balrogs and wanderers), and on the scrolling map (game mode 2, the ordinary playing screen) an off-corner step ends the scan.
- Evil movers see entities 1-78 only; everyone else sees 1-195.
- An ordinary candidate (1-151) is met only within 7 px on each axis
(
CODE+0xF0CA,0xF0EA), and only if it is moving or camped, has no commander and is not the mover. - A cast candidate needs the mover inside its rectangle (
x..destX,y..destY), its day gate passed, arand(50)on the scrolling map (rand(100)elsewhere) at most its courage, and for some kinds a terrain roll. A weak cast member (strength 99 or less) is offered only to movers with an index below 13 (Gandalf and the Fellowship); every other mover meets only strong ones. - The first passing candidate in index order wins, so an ordinary unit always beats a cast member. The pair is then swapped so the good, recruitable side is first; an evil mover is always swapped into second place.
Verified on 24,000 vectors, 0 mismatches; null controls: a mover seen 9 px away is caught on 7,811, a missing swap on 2,139. The scan was also run as one piece with the dispatch below and the loop that carries on after a pair comes to nothing (16,000 vectors, 0 mismatches).
Correction: this project’s live game used a 16 px meeting range and polled every pair every frame. The original’s range is 7 px and it only scans from the mover’s turn.
The evasion roll
Section titled “The evasion roll”When the second unit is evil, the first unit’s troop rolls to evade
(LAB_0960, CODE+0xF382-0xF58A). The troop is every used slot 1-78
whose commander chain roots at the mover:
sum = Σ courage(+0x1D) + 20 × (members carrying the Elven cloak)count = number of members (99 once any member's maxStrength > 99), minimum 1evade if rand(100) < sum / count (integer division)The cloak test is BTST #0 on the high byte of the item word
(CODE+0xF41C), which is word bit 8. A long-standing claim that the Ring
gave this +20 was a misread of that same instruction; the Ring is not
tested anywhere in the encounter path.
Four overrides force an engagement whatever the roll: a mover that is not
a lone figure (maxStrength != 1), a mover on either of two map corners,
(1200, 400) and (1744, 1008), Shelob (entity 151) and the five
balrogs (183-187). A troop of 99 or more meeting a cast monster weaker
than 99 skips the meeting entirely. Verified on 12,000 vectors (9,568
engage, 1,360 evade, 1,072 skip), 0 mismatches.
What the meeting does
Section titled “What the meeting does”CODE+0xF27E-0xFEC2, verified on 13,389 vectors, 0 mismatches (null
controls: evasion skipped 2,684, no pause 4,489):
| Second unit | Dialog | Buttons (command) |
|---|---|---|
| Evil, and the evasion roll fails | Attack, both units paused | “Go there” (184), “Ignore it” (185) |
obedience 3 (the wise: Elrond, Círdan, Bombadil, Bilbo, Galadriel, Treebeard, Radagast) |
Conversation | “Go there” (186), “Continue on” (190) |
obedience above 3 |
Follow | “Follow <other>” (189), “Continue on” (190) |
obedience 2 or less, an ordinary unit |
Plain meeting | “Go there” (187), “Continue on” (190) |
obedience 2 or less, a cast member |
a nod as the party passes (no box in the original) | none |
Nothing opens for a non-evil pair unless the first unit’s obedience is
above 3 (a leader the player controls). After one conversation Círdan,
Galadriel, Treebeard and Bombadil drop to courage 0, and Radagast’s day
gate moves to day + rand(6) + 10.
Follow: the first unit follows the second
Section titled “Follow: the first unit follows the second”The Follow button’s handler (command 189, CODE+0x843E) writes
first.commander := second. Because the trigger’s swap puts the
higher-indexed of two recruitable units first, the higher index always
follows the lower: in the 2026-08-17 savestate diff, Merry (9) took Frodo’s
index (7) as his commander. The same handler then walks Gollum’s commander
chain, and if its top is a wizard (race 4), Gollum is teleported to him and
cut loose with a message; that is the whole of the Gollum detach, and it
runs once per accepted Follow. Verified on 12,000 vectors, 0 mismatches;
null controls: the second unit following the first is caught on 12,000,
Gollum never cut loose on 3,998.
Gollum, Shelob and the balrogs
Section titled “Gollum, Shelob and the balrogs”Players remember evading balrogs and Shelob, and Gollum being good at it.
Running the trigger on the shipped entity table (probe-gollum.ts, 600
seeds per case) settled why, and it is not the evasion roll:
- Balrogs (like every weak cast monster) are only offered to movers below index 13. Gollum (78) standing inside a balrog’s rectangle met nothing in 600 of 600 seeds, and so did an army (30). Aragorn and Boromir met one of the four monsters whose rectangles overlap there in about a quarter of the seeds (the balrog itself 26 of 600). The forced engagement applies only to movers who can meet them, such as the Boromir and Gollum capture near Moria, where Boromir is the mover.
- Shelob starts asleep (state 0, woken when the Ring Bearer’s party is within 9 px), and a sleeping unit is never met. A lone Gollum is not the Ring Bearer, so he walks past her. Once the bearer’s party has woken her, any mover within 7 px meets her (600 of 600) and the override forces the Attack dialog, Gollum included.
- Gollum’s own evasion would be near-certain anyway: his courage is 210,
the highest of all 196 entities, above any
rand(100)roll.
So the Shelob and balrog override is real and ignores courage, and it never fires for Gollum because the meeting that would trigger it cannot happen.
Combat
Section titled “Combat”Still true, and worth repeating: the battle resolver never reads
unitClass, never compares one side’sracewith the other’s, and has no armour stat. Unit class only selects a movement speed weight.
Who fights: the force builder
Section titled “Who fights: the force builder”LAB_03DA (CODE+0x4DDE) with its helper LAB_03CE builds both sides.
Side A is the mover plus every unit with no commander within 9 px of
the battle position among entities 1-78, followed by each member’s
subordinates (flagged 0x100); side B scans entities 79-151 the same way.
Units with the same name string merge into one stack. Overfull sides
are rerun once with single-figure subordinates pruned, then truncated
(caps of 19 slots, 9 in the ignored-battle sub-mode, 7 against a Balrog).
Verified on 4,000 vectors, 0 mismatches; null control: the battle position
moved one tile is caught on 2,483.
The cast is seated by hand. A target above 151 is never reached by the
side-B scan, so the original seats it at two sites (the battle screen at
CODE+0xA35C, the auto-resolve hand-off at 0xD08A) as one side-B slot,
alone, with its own strength, replacing whatever the scan found. On
the battle screen a cast target whose obedience is not 0 joins side A
instead, so there is no battle. Verified on 4,000 vectors, 0 mismatches.
One round
Section titled “One round”LAB_0A47 runs the whole battle. Each slot has an order word
(DATA+0x56B8), set by the player’s clicks and starting at Engage:
| Value | Order | In the round |
|---|---|---|
| 0 | Charge | random power plus strength × combat on top |
| 1 | Engage | random power only (the default) |
| 2 | Withdraw | inert: no power, no absorption capacity, no casualties |
| 3 | Retreat | inert, like Withdraw |
Every loop tests the order as a signed word against 1 (CMPI.W #1 ; BGT
at CODE+0x10F1E, 0x1123A, 0x11CBE), which is why Withdraw and Retreat
are skipped whole. An attended battle accepts order clicks in every round.
In order, a round:
- Power. A lone figure rolls
((randBits(3) + 1) × combat) >> 3, with a 20% chance of+combatand, inside that, a 5% chance of ×16. An army rolls(strength × combat × randBits(3)) >> 4. - Two pools per side. Power goes to the magical pool if the unit’s
+0x18bit 0 is set or it carries the Ancient sword, an Elven blade or the Dwarven hammer (items mask0x0038); otherwise to the ordinary pool. A side’s magical power above the opponent’s warded capacity is demoted to ordinary. - Casualties. Warded units (
+0x18bit 1, the Gnarled staff or Mithril mail, or the Ring worn) are harmed only by magical power, with a small bleed-through from the ordinary pool. Others take a share of the ordinary power proportional to their strength over their side’s total, divided by their toughnesscombat × hitPoints. A lone figure that loses no “troops” loses hit points instead. - Mop-up. Whatever is left in the ordinary pool is spent on unwarded
slots as
pool / defence, capped at the slot’s strength.
All working values are 16-bit words, and two EXT.L sign extensions
change behaviour for pools of 0x8000 or more. One battle round, run on
the original span CODE+0x10E5A-0x123D0, now matches on 95,660 of
95,660 vectors; the first comparison disagreed on 10,599 of 16,920
sampled. Null controls: Charge and Engage swapped is caught on 31,243.
A battle is not replayable from its seed alone. rand(bound)
(CODE+0x320C) is seed = seed × 125 mod 0x2AAAAB, but randBits(n)
(0x31C2) adds the free-running interrupt counter at DATA+0x4FEE to the
seed first. Every combat roll that uses randBits mixes in wall-clock
ticks.
What the player sees
Section titled “What the player sees”- Messages depend on the pass and the side: in pass 1 a good lone
figure “is killed by a foul blow!” and an evil one “is felled by a mighty
attack!”; in pass 2 “is struck down by a frenzied attack!” and “is clove
asunder by a skillful stroke!”. An army’s wording is picked by a
rand(3)the resolver draws. Verified on 16,864 rounds, 0 mismatches (this project’s old pick differed on 4,611). - Swings: a Charging slot swings three times a round, an Engaging slot twice, others never, and only on the battle screen with the player watching.
- The Ring: in an attended battle, a wounded, surviving hero on side A who carries the Ring puts it on in the mop-up (“FRODO puts on the Ring”), becoming warded for the rest of the battle, and takes it off if he survives.
Battles you ignore still happen
Section titled “Battles you ignore still happen”“Ignore it” (command 185) does not cancel the battle. It is fought at once by the same resolver (the scrolling map, sub-mode 3) with the forces gathered at the mover’s own spot, and written back to the entity table just like an attended one. There are no dropped-item sprite rolls, and the Ring is never worn.
What a battle leaves behind
Section titled “What a battle leaves behind”The write-back sweep (CODE+0x1286E-0x13098) runs in every game mode:
- Each slot’s casualties are taken off the real entities of that kind (same
name pointer at
+0x00) whose commander root stands within 8 px of the battle position, in table order. - An entity with no strength or hit points left is retired (state 0) and
every item bit it carried is spilled into the 30-entry item table at
DATA+0x3DB0at the battle position. - Orphaned followers are re-seated under their first living ancestor, or, with none alive, set free at the top commander’s position and destination.
- Side B survivors and entities 152-195 get their hit points back.
Verified on 4,000 vectors across all three game modes, 0 mismatches; the first comparison disagreed on 1,128, because the item spill had been gated on the battle screen (it runs in every mode).
Cast monsters keep their strength. The sweep scans from the slot’s entity up to 151, so a cast slot (152-195) matches nothing, and the whole cast range has its hit points restored. Wolves, spiders and wights that win meet the next comer at full strength. That is the original, not a gap.
The Ring after a battle
Section titled “The Ring after a battle”The pickup that follows the sweep (LAB_0B1B, CODE+0x130A0-0x134CC):
- If the Ring was spilled and side A still has strength, it goes to the first hobbit (race 0) among side A’s surviving lone figures, else the last such figure. Gollum (entity 78) may take it only when side A’s whole remaining strength is exactly 1.
- If side A was wiped out, it goes down side B’s slots instead. If the opposing lead is above 151 (a cast monster, so no army is there), entity 81, “the 3rd NAZGUL is sent to the site”, is spawned on the spot to take it.
- On that evil path the new bearer marches to Barad-dûr (1856, 1120),
and every other living Nazgûl (entities 79-87) is sent by
rand(4)to Dol Guldur (1456, 672), Dagorlad (1744, 1008) or Minas Morgul (1664, 1168); Minas Morgul takes two of the four outcomes.
Verified on 12,000 vectors (7,680 change the bearer, 2,516 scatter, 1,712 summon), 0 mismatches; null controls: a fixed scatter point is caught on 2,516, the Gollum exception ignored on 148.
The campaign
Section titled “The campaign”The campaign bitfield
Section titled “The campaign bitfield”One byte at DATA+0x3E69 records which milestones have fired; the byte
after it holds the Ring Bearer, and raising a bit stamps the day’s low byte into
a timestamp cell beside it. The byte ships as 0x05, so bit
0 is permanently true and no instruction ever writes it.
| Bit | Raised by | Message |
|---|---|---|
| 1, 2 | 08:00, once Gandalf’s state and trigger are both 0 | none |
| 3 | an evil unit stepping onto Isen Ford (1104, 928); or 08:00 with Denethor’s obedience > 1 or bit 7 set |
none |
| 4 | 08:00 on day == 149, or bit 7 set | “Saruman’s army is on the march!” |
| 5 | an evil unit stepping onto Isen Ford; or 08:00 with Théoden’s obedience > 1 |
none |
| 6 | 08:00 with bit 7 set | none |
| 7 | 08:00 on day == 169; a non-evil unit ending a step at x ≥ 1664, y ≥ 1008 (Dagorlad); or a Palantir use with rand(100) > 30 while bit 7 is clear |
“The Dark Lord’s armies march forth!” |
Bit 7 therefore cascades into bits 3, 4 and 6 at the next 08:00. The activation routine reads these bits to wake the dormant armies (see Movement & Time § “Routes: there is no AI”).
The hourly day panel and the Council of Elrond
Section titled “The hourly day panel and the Council of Elrond”LAB_089E (CODE+0xD894) runs once an hour of game time on the scrolling
map. It draws the date line, holds the Council of Elrond, tests for the
Mount Doom victory, and at 08:00 runs the copy-protection question (from
day 92) and the event bits above. Verified as a whole routine on 12,000
state vectors plus 6,000 date vectors, 0 mismatches, with all of DATA
diffed on 300 of them (no stray writes).
The Council fires once, when the top of the Ring Bearer’s commander chain stands on Rivendell (1216, 384) and Gandalf (entity 1) is there too. It then:
- sets the game speed to Normal;
- skips the calendar: before day 32 it adds 60 days, after day 82 it adds 10, and from day 32 to 82 it jumps to day 92;
- heals the Fellowship (entities 5-10 whose chain top is on Rivendell) and puts them under Gandalf, unless they already follow Frodo;
- stands Elrond, Glorfindel and the Nazgûl escort (79-87) down;
- shows the council page (“For nearly two months the fellowship rests and
recuperates.”,
CSTR46-48); - moves every unit with a destination onto it: the two months that pass are the marches the armies already had.
Correction: this project’s live game used to fire the council on the bearer’s arrival alone, with no Gandalf gate, no calendar skip, no speed reset and no teleport. The null controls catch each omission: Gandalf ignored on 2,886 vectors, no teleport on 927, a fixed 60-day skip on 864.
Routes
Section titled “Routes”Most army entities start dormant. The activation routine wakes them and
loads a pre-assigned queue from the 86-slot route table at DATA+0x3B00.
Notable groups: routes 0-8 take the Fellowship from Bree to Rivendell,
9-17 are Saruman’s invasion of Rohan, 21-28 Gondor’s dispositions and 29-39
Sauron’s chain from the Rammas forts towards Rivendell. There is no other
source of orders for computer-controlled armies.
How the war ends
Section titled “How the war ends”There are exactly four game-end trigger sites, found by scanning the whole CODE hunk for the two ending routines’ jump-table operands (two hits each), and each is verified on the real code:
| Ending | Condition | When it is tested | Text |
|---|---|---|---|
| Defeat | an evil unit carrying the Ring ends a step on Barad-dûr (1856, 1120) | the movement turn’s corner block | CSTR 49 (“The Dark Lord’s servant has reached Barad-dur with the Ring…”), 51, 52 |
| Defeat | three of the five capital garrisons at strength 0: Minas Tirith (33), Lórien (61), Thranduil’s Palace (64), Edoras (67), Hornburg (68) | after each battle’s write-back and pickup | CSTR 50 (“With this battle, Sauron’s victory is assured…”), 51, 52 |
| Victory | the top of the Ring Bearer’s commander chain stands on Mount Doom (1808, 1120); no faction gate | once an hour, in the day panel | CSTR 53, 54, 55 (“…SO ENDS THE WAR IN MIDDLE EARTH.”) |
| Victory | entity 148, the 9,500 orcs at Barad-dûr, at strength 0; the only military victory | after each battle; the defeat check runs first and wins a tie | CSTR 53-55 |
Verification: the Mount Doom chain walk on 20,000 vectors and the military checks on 12,000, both 0 mismatches; the Barad-dûr check is part of the corner block’s 24,000. The tests read strength as a word; a null control that reads it as a byte is caught on 2,141. No named character’s death ends the game: Théodred, Brand and Denethor were checked exhaustively. Each ending waits for a key and exits the program, so the first to fire is final.
The ending scenes
Section titled “The ending scenes”Both ending routines draw a scene before the text pages, over the strategic map centred on a viewpoint (the routine sets entity 0, the map viewpoint, to the position):
- Victory (
LAB_02FA, viewpoint Hobbiton (640, 368)): the nine of the Fellowship, Gimli, Merry, Legolas, Frodo, Gandalf, Aragorn, Pippin, Sam and Boromir, each in his own colour set (the blit’s SAS argument is that character’s sheet), drawn from slot 8 down to 0 in a row: x from 245 stepping by -25 plusrand(7), y = 140 +rand(10). Slots 8 to 4 are mirrored. - Defeat (
LAB_02E9, viewpoint Mount Doom (1808, 1120)): an orc horde (FRML 6, frames 10-13 byrand(4)) in four rows at y 106, 114, 122 and 130, a troll at (18, 90), the Balrog at (240, 83) mirrored, a second troll at (2, 95), then a line of wraiths (FRML 8, frame 13) along y = 140 +rand(10): 60 blits in all.
Verified by running both routines with the real rand and recording every
blit’s sprite, position, order and the final seed: 4,000 vectors (18,000
victory blits, 120,000 defeat blits), 0 mismatches; null controls: draw
order swapped is caught on 2,000, slots drawn ascending on 4,000.
Correction: earlier notes described a victory credits scroll. There is none. The value read as a descending Y coordinate is the x of this row of nine figures, stepping left by 25.
Still open: whether the text pages replace the scene or are laid over it,
the map’s exact framing, the fades and music call, and the Dwarves’ slot
asking for frame 17 of a 17-frame sheet (wime-ending-presentation on the
Status page).
Next: Items for what the four recruitment items and the Palantir do to these bits, or How We Verified the Rules.