His state lives in a record starting at 0xE134:
| address | what it is |
|---|---|
0xE134 |
state, 0 to 6; indexes tabla_4c7f |
0xE135 |
the processed controller input |
0xE136 |
bit 0: which way he faces |
0xE137 |
Y, in pixels |
0xE138 |
X, fractional part (1/256 of a pixel) |
0xE139 |
X, low byte |
0xE13A |
X, high byte |
The seven states are walking, digging, pushing and the transitions between
them. avanza_estado_del_jugador (0x4C59) steps the machine once a frame, and
pushes monta_sprite_del_jugador as the return address so the figure gets
redrawn on the way out whatever the state was.
Only states 0 and 3 accept fresh input; in the others the explorer is midway through an action and the controller does not count.
The state machine at 0xE134 has seven states, and avanza_estado_del_jugador
(0x4C59) steps it once a frame, pushing monta_sprite_del_jugador as the
return address so the figure gets redrawn whatever the state was:
| state | what he is doing |
|---|---|
| 0 | walking |
| 1 | jumping |
| 2 | falling |
| 3 | on a ladder |
| 4 | throwing the knife |
| 5 | digging with the pickaxe |
| 6 | going through a revolving door |
Only states 0 and 3 accept fresh input; in the others he is midway through something and the controller does not count.
What the button does depends on what he is carrying, which is the high nibble of 0xE144: 0 nothing, 1 the knife, 2 the pickaxe. That same nibble picks one of three sprite sets, all of which load into the same VRAM address, so he is drawn empty-handed, with a knife or with a pickaxe.
Digging opens a hole in the brick floor, and the explorer and the mummies
fall through it. The holes are their own list, seven bytes per entry, at
0xE31E; marca_el_agujero_que_se_abre (0x69C9) finds the one right where he is
digging and sets bit 0 of its field 0, and from there
anima_bloques_que_se_abren opens it in six steps, one every eight frames.
Pushing against a revolving door for sixteen consecutive frames sends him to state 6 with sound effect 0x03. The counter for that run is at 0xE146 and resets the moment it is broken.
An exit door is a stamp of three rows by five columns, written into the room buffer with its corner sixteen pixels left and eight pixels up from the door's own coordinates. It has three states — closed, closing and open — each a fifteen-byte table at 0x67C5, 0x67D4 and 0x67E3.
Until every jewel is collected only the door you came in through is visible, and it is drawn open. Collect them all and the exits appear, closed, with a lever beside them; touching the lever opens the way out. Clearing a pyramid for the first time is also worth 2,000 points.
suma_al_marcador (0x4412) keeps six digits in packed BCD at
0xE049-0xE04B, with a daa after every addition. On passing the threshold at
0xE052 it grants an extra round and raises the threshold by 2, also in BCD,
clamping it at 0xFF — past that there are no more extra lives. Then it compares
against the high score at 0xE043-0xE045 and updates it if due.
All of this only counts with bit 6 of 0xE002 set, which is what tells a real game from the demo.