Prev: 08852 Up: Map Next: 08907
08874: 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 08874 LD A,175 Test that the y co-ordinate (in B) is not greater than 175.
08876 SUB B
08877 JP C,REPORT_B_3
08880 LD B,A B now contains 175 minus y.
08881 AND A A holds b7b6b5b4b3b2b1b0, the bits of B.
08882 RRA And now 0b7b6b5b4b3b2b1.
08883 SCF Now 10b7b6b5b4b3b2.
08884 RRA
08885 AND A Now 010b7b6b5b4b3.
08886 RRA
08887 XOR B Finally 010b7b6b2b1b0, so that H becomes 64+8*INT(B/64)+(B mod 8), the high byte of the pixel address.
08888 AND %11111000
08890 XOR B
08891 LD H,A
08892 LD A,C C contains x.
08893 RLCA A starts as c7c6c5c4c3c2c1c0 and becomes c4c3c2c1c0c7c6c5.
08894 RLCA
08895 RLCA
08896 XOR B Now c4c3b5b4b3c7c6c5.
08897 AND %11000111
08899 XOR B
08900 RLCA Finally b5b4b3c7c6c5c4c3, so that L becomes 32*INT((B mod 64)/8)+INT(x/8), the low byte.
08901 RLCA
08902 LD L,A
08903 LD A,C A holds x mod 8, so the pixel is bit (7-A) within the byte.
08904 AND 7
08906 RET
Prev: 08852 Up: Map Next: 08907