Prev: 56691 Up: Map Next: 56937
56913: Calculate Screen Address
Used by the routines at Print_HelperPreviewImage, Draw_Tile and 57761.
Input
HL X/Y Co-ordinates
Output
DE Screen buffer address
CalculateScreenAddress 56913 LD A,L Load the X co-ordinate into A.
56914 AND %11000000 Keep only bits 6-7.
56916 RRA Rotate the result right through the carry flag.
56917 SCF Set the carry flag.
56918 RRA Rotate right through the carry flag.
56919 RRCA Rotate right (no carry flag).
56920 XOR L Combine the bits with the original X co-ordinate.
56921 AND %11111000 Keep only bits 3-7.
56923 XOR L Combine the bits with the original X co-ordinate again.
56924 LD D,A Store the result in D (high byte of the screen buffer address).
56925 LD A,H Load the Y co-ordinate into A.
56926 RLCA Multiply by 8.
56927 RLCA
56928 RLCA
56929 XOR L Combine the bits with the original X co-ordinate.
56930 AND %11000111 Keep only bits 0-2, 6-7.
56932 XOR L Combine the bits with the original X co-ordinate again.
56933 RLCA Multiply by 4.
56934 RLCA
56935 LD E,A Store result in E (low byte of the screen buffer address).
56936 RET Return.
Prev: 56691 Up: Map Next: 56937