Routines |
Prev: E958 | Up: Map | Next: E9DD |
|
||||
This routine calculates the vertical direction and speed of the servant/spell cursor icon, and adds/subtracts it from the sprite's vertical pixel position.
|
||||
E987 | LD A,($EB02) | Get sprite vertical movement speed | ||
E98A | LD C,A | |||
E98B | LD A,($EAFE) | Get up/down sprite control value (determine whether the sprite is moving and in which direction) | ||
E98E | CALL $DFBC | Calculate the new sprite speed/position offset based on direction/speed (returned in H register) | ||
E991 | LD A,H | Retrieve calculated offset from H register... | ||
E992 | LD ($EB02),A | ...and store | ||
E995 | LD A,($EAFF) | Get the sprite's current vertical screen position | ||
E998 | LD C,A | Temp store in C register | ||
E999 | ADD A,H | Add (or subtract) the offset calculated earlier | ||
Check top of playing area boundary
|
||||
E99A | CP $E0 | If new position is < 8 or a negative value, upwards movement will have taken the graphic past the top border of the playing area | ||
E99C | JR NC,$E9A2 | |||
E99E | CP $08 | |||
E9A0 | JR NC,$E9A9 | |||
E9A2 | LD A,$00 | ...If so, reset movement speed to zero... | ||
E9A4 | LD ($EB02),A | |||
E9A7 | LD A,$08 | ...And vertical pixel position to 8, two pixels below the top of the playing area (top of playing area is zero, but the servant and cursor icon both have a -6 vertical pixel offset). | ||
E9A9 | LD ($EAFF),A | Store the new (or reset) vertical pixel position | ||
Check bottom of playing area boundary
|
||||
E9AC | CP $78 | Check if vertical sprite position is greater than 120 pixels from top of playing area | ||
E9AE | JR C,$E9B5 | |||
E9B0 | LD A,$00 | If so, set vertical movement speed to zero. HTML[<br/>]No further action is required at this point because the spell will be cancelled in the following routine. | ||
E9B2 | LD ($EB02),A | |||
E9B5 | LD A,$00 | |||
E9B7 | LD ($EAD4),A | High byte of screen position (0 = current viewport, no offset) | ||
Erase the graphic at the old position and draw it at its new one
|
||||
E9BA | LD ($EACF),A | ...Set draw/erase flag to ERASE | ||
E9BD | LD HL,($EC94) | Get the graphic address pointer ready to ERASE the graphic | ||
E9C0 | CALL $DB98 | Run screen boundary checks and erase the servant/icon graphic | ||
E9C3 | LD A,($EB00) | Copy the (new) horizontal pixel position into store | ||
E9C6 | LD ($EAD3),A | |||
E9C9 | LD A,($EAFF) | ...and also the vertical pixel position | ||
E9CC | LD ($EAD2),A | |||
E9CF | LD A,$01 | Set draw/erase flag to DRAW | ||
E9D1 | LD ($EACF),A | |||
E9D4 | LD HL,($EB51) | Copy graphic address pointer to (table at 97C3) into store | ||
E9D7 | LD ($EC94),HL | |||
E9DA | CALL $DB98 | Run screen boundary checks and draw the servant/icon graphic in its new position |
Prev: E958 | Up: Map | Next: E9DD |