On this page
  1. Related
  2. Games
  3. References
  4. Sources

A ledge grab stops a fall at a floor’s edge. In Prince of Persia the kid catches a ledge he falls past while the button is down, if he is falling slower than a set speed and his feet are near the floor plane below it1.

  • Button heldPrince of Persia (1989). The button held, while falling slower than 32 px per cycle and within 25 px of the floor plane below the ledge.1

Games

GameYearHowNote
Prince of Persia1989Button heldthe button held, while falling slower than 32 px per cycle and within 25 px of the floor plane below the ledge
Every claim about this mechanic, by game (1)

References

  1. ^ abA 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.Codejmechner/Prince-of-Persia-Apple-II
    How we know
    45grabreach = -8
    46grabspeed = 32 ;max Y-vel to grab ledge
    47grablead = 25 ;increase to grab ledge earlier
    
    01 POP Source/Source/CTRL.S lines 45–47 at 2524355 · upstream ↗
    248fallon
    249 lda btn ;is button down?
    250 and CharLife ;& is he alive?
    251 bpl ]rts
    ⋮
    253 lda CharYVel
    254 cmp #grabspeed
    255 bcs ]rts ;no--falling too fast
    ⋮
    257 lda CharY
    258 clc
    259 adc #grablead
    ⋮
    262 cmp FloorY,x
    263 bcc ]rts  ;not within grabbing range yet
    ⋮
    
    01 POP Source/Source/CTRL.S lines 248–298 at 2524355 · upstream ↗
    76falling
    77 lda CharY
    ⋮
    81 cmp FloorY,x
    82 bcs :1
    ⋮
    84 jmp fallon ;Hasn't reached floor yet
    
    01 POP Source/Source/CTRL.S lines 76–84 at 2524355 · upstream ↗
    120:2 cmp #4 ;freefall
    121 beq falling
    122 cmp #3
    123 bne :1
    124 lda CharPosn
    125 cmp #102
    126 bcc ]rts
    127 cmp #106
    128 bcs ]rts
    129 jmp fallon
    
    01 POP Source/Source/CTRL.S lines 120–129 at 2524355 · upstream ↗
    1814CHECKLEDGE
    ⋮
    1820 lda blockid ;must be clear
    ⋮
    1834* Clear above -- is there a ledge in front?
    ⋮
    1836 lda ztemp ;must be a solid floorpiece
    1837;with exposed ledge
    
    01 POP Source/Source/CTRLSUBS.S lines 1814–1858 at 2524355 · upstream ↗
    1045 lda BTN1
    1046 ldx ManCtrl ;When manual ctrl is on, btn 0 belongs
    1047 bmi :1 ;to kbd and btn 1 to jstk.  With manual ctrl
    1048 ora BTN0 ;off, btns can be used interchangeably.
    1049:1 sta btn
    
    01 POP Source/Source/GRAFIX.S lines 1045–1049 at 2524355 · upstream ↗

    Checked against the evidence by its author, an AI model, 2026-10-22.

    Checked by a second AI model, 2026-10-22.

    In the claim ledger

Sources

Code