Prev: 58682 Up: Map Next: 58745
58710: Calculate Screen Address
Used by the routines at PickUpItem and PrintString.
Works out the address on the screen of a position given in pixels, measured from the bottom left of the screen.
Input
H Y position (from the bottom of the screen)
L X position
Output
HL Screen address
CalculateScreenAddress 58710 PUSH DE Keep DE, and put the position in it.
58711 EX DE,HL
58712 LD A,E Work out the column from the X position.
58713 RRCA
58714 RRCA
58715 RRCA
58716 AND 31
58718 LD L,A
58719 LD A,D Work out the character row within a third of the screen, from the Y position measured from the top.
58720 CPL
58721 RLCA
58722 RLCA
58723 AND 224
58725 OR L
58726 LD L,A
58727 LD A,D Work out the third of the screen.
58728 CPL
58729 RRCA
58730 RRCA
58731 RRCA
58732 AND 24
58734 LD H,A
58735 LD A,D Work out the pixel row within the character, and make the high byte of the address.
58736 CPL
58737 AND 7
58739 OR H
58740 ADD A,56
58742 LD H,A
58743 POP DE Get DE back and return.
58744 RET
View the equivalent code in;
Prev: 58682 Up: Map Next: 58745