Jordan Mechner's released Apple II source names its build in VERSION.S, "Prince of Persia 1.0 9/7/89", and its MASTER.S is headed as the 3.5-inch disk version; the game code the other claims here read is shared with the 5.25-inch build. | 01 POP Source/Source/VERSION.S L901 POP Source/Source/MASTER.S L9–11 | Code |
The kid's horizontal position, CharX, counts in units of 14 to a block: the left edges of the blocks (BlockEdge) step by 14, and the screen is 140 units wide, so it holds 10 blocks (computed). A floor is 63 px tall (BlockHeight). | 01 POP Source/Source/TABLES.S L143–15401 POP Source/Source/EQ.S L47601 POP Source/Source/TABLES.S L36 | Code |
Both of the kid's jumps are fixed sequences in SEQTABLE.S, with no speed or gravity: each cycle ANIMCHAR reads the sequence up to the next frame number, adding each chx byte to CharX in the direction he faces and each chy byte to his height. The frames of both jumps add no horizontal offset of their own (Fdx 0 in FRAMEDEF.S). | 01 POP Source/Source/COLL.S L996–101601 POP Source/Source/CTRLSUBS.S L346–36301 POP Source/Source/FRAMEDEF.S L2101 POP Source/Source/FRAMEDEF.S L38–6601 POP Source/Source/CTRLSUBS.S L1654–1664 | Code |
The standing jump (standjump) runs frames 16 to 33. Its chx steps are 2, 2, 2, 2, 2, 7, 9, 5, 1, 4, −3, 5, and 1 units, 39 in all (computed); its only chy steps lift the kid 6 px and set him back down on the next frame. Frames 20 to 25 lack the floor-check bit, so onground doesn't test the floor under him there, and the steps between frame 19 and frame 26 move him 28 units, 2 blocks (computed). | 01 POP Source/Source/SEQTABLE.S L442–46401 POP Source/Source/FRAMEDEF.S L41–4801 POP Source/Source/GAMEEQ.S L65301 POP Source/Source/CTRL.S L311–316 | Code |
The running jump (runjump) runs frames 34 to 44. Its chx steps are 5, 6, 3, 5, 7, 12, 8, 8, 4, 4, and 5 units, 67 in all (computed), and its chy steps raise the kid 14 px over three frames and lower him 14 px over the next two. Frames 39 to 43 lack the floor-check bit, and the steps between frame 38 and frame 44 move him 43 units, 3 blocks and 1 unit (computed). | 01 POP Source/Source/SEQTABLE.S L469–48501 POP Source/Source/FRAMEDEF.S L60–6601 POP Source/Source/CTRL.S L311–316 | Code |
GENCTRL, which turns the player's input into moves, picks its branch by the frame the kid shows (standing, starting a run, running, starting a jump up, hanging, turning, or crouching). The frames of the standing and running jumps, 16 to 44, match none of them, and it returns without reading the joystick, so a jump can't be steered once it starts. | 01 POP Source/Source/CTRL.S L689–71801 POP Source/Source/CTRL.S L720–723 | Code |
In a run (frames 4 to 14), arunning reaches the running jump only while the joystick is held forward (centered stops the run, back turns it), and then only on a fresh press of up (clrU negative), with forward and up the names Mechner's comments give the joystick signs; in a full run (frame 7 or later) that calls DoRunjump, which Mechner's comment describes as "Calibrate jump so that foot will push off at edge". It looks for a gap or spikes in the next two blocks and measures from the kid's position 4 units on to that floor's end. When the end is 6 to 15 units off, it moves him so the jump starts with CharX 14 units (one block) short of the end (computed). Farther off, it returns without jumping (comment: "still too far away--wait till next frame"); nearer, it moves him 1 unit (computed) and jumps (comment: "He jumped too late; he'll miss edge"). With no gap in sight, he jumps where he is. | 01 POP Source/Source/CTRL.S L1742–175001 POP Source/Source/CTRL.S L1752–179201 POP Source/Source/CTRL.S L1793–183601 POP Source/Source/CTRL.S L1348–137801 POP Source/Source/CTRL.S L638–64301 POP Source/Source/CTRL.S L702–71201 POP Source/Source/SPECIALK.S L917–930 | Code |
A falling kid grabs a ledge while the button is down (either Apple II button, unless manual control splits them) and he is alive, his downward speed is under 32 px per cycle, and his feet are within 25 px above the floor plane he is falling toward. fallon then tests for a ledge 8 units behind him (grabreach), requiring clear space above it and a floor piece in front, and on a catch it aligns him to the block, stops his fall, and starts the hang. It runs on the first frames of a fall (102 to 105) and through the free fall. | 01 POP Source/Source/CTRL.S L45–4701 POP Source/Source/CTRL.S L248–29801 POP Source/Source/CTRL.S L76–8401 POP Source/Source/CTRL.S L120–12901 POP Source/Source/CTRLSUBS.S L1814–185801 POP Source/Source/GRAFIX.S L1045–1049 | Code |
With the weightless flag clear, a fall (action 4) adds 3 px per cycle to the kid's downward speed, up to 33 px per cycle (AccelGravity, TermVelocity); with it set, gravity is 1 and the cap 4 (WtlessGravity, WtlessTermVel). The fall sequences that start it set the speed to 15 (setfall). In any other action, including the jumps' (action 1) and a fall's first frames (action 3), gravity does nothing. | 01 POP Source/Source/SUBS.S L1613–164401 POP Source/Source/SEQTABLE.S L640–65401 POP Source/Source/SEQTABLE.S L882–884 | Code |
A landing's cost goes by the kid's downward speed when he reaches a floor: under 22 (OofVelocity) he lands softly; from 22 up to 33 (DeathVelocity) he loses 1 hit point and dies if it was his last; at 33 he loses 100, and dies. A guard who lands at 22 or more dies, and the shadow lands softly at any speed under 33. | 01 POP Source/Source/CTRL.S L42–4301 POP Source/Source/CTRL.S L184–21101 POP Source/Source/MISC.S L691–696 | Code |
Computed from the fall sequence and gravity: a kid who steps off a ledge has fallen 30 px when the free fall starts at speed 15, and reaches the floor below at speed 21 after one floor (63 px), 30 after two, and 33 after three or more. One floor costs nothing, two cost a hit point, and three or more kill him. The count assumes weightless is clear and that a fall crossing to the screen below keeps its speed and its distance to the next floor, which the atlas hasn't read in the screen-change code. | 01 POP Source/Source/SEQTABLE.S L640–65401 POP Source/Source/TOPCTRL.S L661–66401 POP Source/Source/SUBS.S L1651–165501 POP Source/Source/SUBS.S L1613–161401 POP Source/Source/TABLES.S L3601 POP Source/Source/CTRL.S L42–4301 POP Source/Source/CTRL.S L76–97 | Code |