Prev: 34816 Up: Map Next: 34842
34821: Update Magic Knight's current frame based on x-coordinate
Used by the routines at 27176, 27495 and 28092.
Output
A Frame number
The operand of the instruction at 34821 represents the address of the appropriate "walking" routine to jump to (either 34824 for walking left or 34838 for walking right). This is modified by the instructions at 27327, 29527, 29549 and 29565.
34821 JP 34824 Jump to walking left or walking right version of routine
Update Magic Knight's current frame based on x-coordinate (walking left)
34824 LD B,5 Load B with 5 (as first graphic frame of Magic Knight walking left is frame number 5)
34826 LD HL,25387 Point HL at Magic Knight's current data (x- and y-coordinates, etc.)
34829 LD A,(HL) Load A with Magic Knight's x-coordinate
34830 RRCA Divide Magic Knight's x-coordinate by 2...
34831 AND 3 ...and take lowest two bits (0 - 3)
34833 ADD A,B Add result to B (1 for walking right frames or 5 for walking left frames) to get current required frame
34834 LD (25390),A Load frame number into Magic Knight's properties
34837 RET Return
Update Magic Knight's current frame based on x-coordinate (walking right)
34838 LD B,1 Load B with 1 (as first graphic frame of Magic Knight walking right is frame number 1)
34840 JR 34826 Return to routine at 34821
Prev: 34816 Up: Map Next: 34842