Prince-of-Persia-Apple-II

A running-jumping-swordfighting game Jordan Mechner made on the Apple II from 1985-89
Log | Files | Refs | README | LICENSE

CHARCOMMENTS.S (2979B)


      1 *-------------------------------
      2 *
      3 * Character animation comments
      4 *
      5 *-------------------------------
      6 *
      7 * For each character, we maintain a 16-byte block of data
      8 * (referred to as "character data" or "character vars")
      9 * that describes the character's current position & what
     10 * he is doing.  The 16 bytes are allocated as follows:
     11 *
     12 * CharPosn
     13 *
     14 *   Frame # of the character's current position.  E.g.,
     15 *   CharPosn = 15 refers to frame #15 of the frame list, or
     16 *   "standing still."
     17 *
     18 * CharX
     19 * CharY
     20 *
     21 *   Character X & Y coords, based on a 140 x 192 screen.
     22 *   (Upper left corner is X = 58, Y = 0)
     23 *
     24 * CharFace
     25 *
     26 *   Direction character is facing: 0 = right, -1 = left
     27 *
     28 * CharBlockX
     29 * CharBlockY
     30 *
     31 *   Coords of character's current block (X = 0-9, Y = 0-2).
     32 *   (0,0) is upper left block.
     33 *
     34 * CharAction
     35 *
     36 *   Code containing information about character's current
     37 *   action.  E.g., CharAction = 4 means "falling."  This
     38 *   variable is used in a variety of different ways in
     39 *   different situations
     40 *
     41 * CharXVel
     42 * CharYVel
     43 *
     44 *   X & Y components of character's velocity (during
     45 *   freefall).  Every frame, CharXVel is added to CharX and
     46 *   CharYVel is added to CharY.
     47 *
     48 * CharSeq (2 bytes)
     49 *
     50 *   Pointer to current address in the sequence table.
     51 *
     52 * CharScrn
     53 *
     54 *   Screen # of character's current screen.  (0 for null
     55 *   screen.)
     56 *
     57 * CharRepeat
     58 *
     59 *   When character stands at the edge of a chasm & takes a
     60 *   cautious step forward, the first time he tries it he only
     61 *   "tests" with his foot.  This causes CharRepeat (usually
     62 *   a non-0 value) to be set to 0.  The next time he tries a
     63 *   cautious step, he will step right off the edge.
     64 *
     65 * CharID
     66 *
     67 *   Identifies character:
     68 *   0 = kid
     69 *   1 = shadow man
     70 *   2 = guards, vizier
     71 *   4 = skeleton
     72 *   5 = princess (in princess scenes)
     73 *   6 = vizier (in princess scenes)
     74 *   24 = mouse
     75 *
     76 * CharSword
     77 *
     78 *   2: sword drawn
     79 *   0: sword sheathed
     80 *
     81 * CharLife
     82 *
     83 *   -1: alive
     84 *   0-127: dead
     85 *
     86 *-------------------------------
     87 *
     88 *  Two permanent sets of CharData are maintained: KidData
     89 *  (for the kid) and ShadData (for his opponent).  Note
     90 *  that the opponent data is always referred to by the
     91 *  prefix "Shad" although the character may be the shadow
     92 *  man, skeleton, Vizier, etc.
     93 *
     94 *  CharData itself is used as temporary storage for whichever
     95 *  character we want to deal with.  Typically, we will call
     96 *  LoadKid to "load" the kid as our current character (i.e.,
     97 *  load the 16 bytes of KidData into the CharData space),
     98 *  then call the control routines that change CharData, then
     99 *  when we're done call SaveKid to "save" the modified
    100 *  CharData back into KidVars.  This way we can use the
    101 *  same control routines for both the kid & his opponent.
    102 *
    103 *  There is a second data set used for temporary storage
    104 *  OppData.  OppData always contains the "other" character
    105 *  than CharData -- e.g., when we call LoadKid, we load
    106 *  KidData into CharData and ShadData into OppData.
    107 *
    108 *-------------------------------