Prev: 44512 Up: Map Next: 44567
44536: Calculate Screen Address
Input
HL Position (L is the x position, H is the y position)
Output
HL Display file address
ScreenAddress 44536 LD A,L Fetch the x position.
44537 RRCA Divide it by 8.
44538 RRCA
44539 RRCA
44540 AND 31 Keep only five bits.
44542 LD L,A Store the column in L.
44543 LD A,H Fetch the y position.
44544 RLCA Multiply it by 4.
44545 RLCA
44546 AND 224 Keep only the bits that give the character row within a third.
44548 OR L Combine them with the column.
44549 LD L,A Store the low byte of the address in L.
44550 LD A,H Fetch the y position.
44551 AND 7 Keep only the pixel line within the character.
44553 EX AF,AF' Stash the line in AF'.
44554 LD A,H Fetch the y position.
44555 RRCA Divide it by 8.
44556 RRCA
44557 RRCA
44558 AND 24 Keep only the bits that give the third of the screen.
44560 OR 64 Add the start of the display file.
44562 LD H,A Store the result in H.
44563 EX AF,AF' Retrieve the pixel line from AF'.
44564 OR H Combine it with the high byte of the address.
44565 LD H,A Store the high byte of the address in H.
44566 RET Return.
Prev: 44512 Up: Map Next: 44567