.ylookup FOR I%, 0, 255 EQUB &40 + ((I% DIV 8) * 2) NEXTName: ylookup [Show more] Type: Variable Category: Drawing pixels Summary: Lookup table for converting pixel y-coordinate to page number of screen addressContext: See this variable in context in the source code References: This variable is used as follows: * CPIX2 uses ylookup * HANGER uses ylookup * HLOIN uses ylookup * LOIN (Part 2 of 7) uses ylookup * LOIN (Part 5 of 7) uses ylookup * PIXEL uses ylookup
Elite's screen mode is based on mode 1, so it allocates two pages of screen memory to each character row (where a character row is 8 pixels high). This table enables us to convert a pixel y-coordinate in the range 0-247 into the page number for the start of the character row containing that coordinate. Screen memory is from &4000 to &7DFF, so the lookup works like this: Y = 0 to 7, lookup value = &40 (so row 1 is from &4000 to &41FF) Y = 8 to 15, lookup value = &42 (so row 2 is from &4200 to &43FF) Y = 16 to 23, lookup value = &44 (so row 3 is from &4400 to &45FF) Y = 24 to 31, lookup value = &46 (so row 4 is from &4600 to &47FF) ... Y = 232 to 239, lookup value = &7A (so row 31 is from &7A00 to &7BFF) Y = 240 to 247, lookup value = &7C (so row 32 is from &7C00 to &7DFF) There is also a lookup value for y-coordinates from 248 to 255, but that's off the end of the screen, as the special Elite screen mode only has 31 character rows.