Prev: 2294 Up: Map Next: 22CB
22AA: THE 'PIXEL ADDRESS' SUBROUTINE
This subroutine is called by POINT_SUB and by PLOT. Is is entered with the co-ordinates of a pixel in the BC register pair and returns with HL holding the address of the display file byte which contains that pixel and A pointing to the position of the pixel within the byte.
Input
B Pixel y-coordinate
C Pixel x-coordinate
Output
A C mod 8
HL Display file address
PIXEL_ADD 22AA LD A,$AF Test that the y co-ordinate (in B) is not greater than 175.
22AC SUB B
22AD JP C,REPORT_B_3
22B0 LD B,A B now contains 175 minus y.
22B1 AND A A holds b7b6b5b4b3b2b1b0, the bits of B.
22B2 RRA And now 0b7b6b5b4b3b2b1.
22B3 SCF Now 10b7b6b5b4b3b2.
22B4 RRA
22B5 AND A Now 010b7b6b5b4b3.
22B6 RRA
22B7 XOR B Finally 010b7b6b2b1b0, so that H becomes 64+8*INT(B/64)+(B mod 8), the high byte of the pixel address.
22B8 AND %11111000
22BA XOR B
22BB LD H,A
22BC LD A,C C contains x.
22BD RLCA A starts as c7c6c5c4c3c2c1c0 and becomes c4c3c2c1c0c7c6c5.
22BE RLCA
22BF RLCA
22C0 XOR B Now c4c3b5b4b3c7c6c5.
22C1 AND %11000111
22C3 XOR B
22C4 RLCA Finally b5b4b3c7c6c5c4c3, so that L becomes 32*INT((B mod 64)/8)+INT(x/8), the low byte.
22C5 RLCA
22C6 LD L,A
22C7 LD A,C A holds x mod 8, so the pixel is bit (7-A) within the byte.
22C8 AND $07
22CA RET
Prev: 2294 Up: Map Next: 22CB