Prev: 55334 Up: Map Next: 55397
55368: Calculate Attribute Address
Used by the routines at PrintText and DisplayObjectsCarried.
Finds the address in the attributes of the character square that holds a pixel.
Input
H Pixel Y coordinate (from the bottom of the screen)
L Pixel X coordinate
Output
DE Address of the attribute
Convert the pixel position into a character-square address.
CalculateAttributeAddress 55368 PUSH HL Stash HL on the stack.
55369 LD A,H Invert the pixel Y coordinate, to get the line from the top.
55370 CPL
55371 LD H,A
55372 SRL H Move the line into the low bits of the high byte.
55374 SRL H
55376 SRL H
55378 SRL H
55380 RR L Move the lowest bit of the line into the low byte.
55382 SRL H Move the next bit.
55384 RR L
55386 SRL H Move the next bit, so that HL holds the number of the square.
55388 RR L
55390 LD DE,22272 Point DE at the attributes of the screen, less one page.
55393 ADD HL,DE Add the two.
55394 EX DE,HL Put the address in DE.
55395 POP HL Restore HL from the stack.
55396 RET Return.
View the equivalent code in;
Prev: 55334 Up: Map Next: 55397