Skip to navigation


Drawing pixels: yLookupHi

Name: yLookupHi [Show more] Type: Variable Category: Drawing pixels Summary: Lookup table for converting pixel y-coordinate to high byte of screen address
Context: See this variable in context in the source code References: This variable is used as follows: * GetScreenAddress uses yLookupHi

This table returns the high byte of the screen address of the start of the row, for the custom screen mode. Note that the custom screen mode starts at address &5A80, so the first two entries in this table do not point to screen memory; the first two character rows in this table are off the top of the custom screen, so the first row on-screen is the third row. This is why, when we print the top two lines of text in the custom screen with the PrintCharacter routine, we do so at the following y-coordinates: * yCursor = 24 for the first line of text * yCursor = 33 for the second line of text To see where these are on-screen, we need to subtract 16 for the first two character rows which are off the top of the screen, to give: * y-coordinate = 8 for the first line of text * y-coordinate = 17 for the second line of text The value passed to PrintCharacter points to the bottom row of the character to print, so the first coordinate points to the ninth pixel row (as the first pixel row is row 0), and the second points to the 18th pixel row. There are eight pixels in each character row, so this prints the first row of text so that it has a one-pixel margin between the top of the text and the top of the screen, and it prints the second row so that it has a one-pixel margin between the top of the text and the bottom of the line above. I don't know why this table starts at &5800 and not &5A80, but that's how it is.
.yLookupHi FOR I%, 0, 31 EQUB HI(&5800 + (I% * &140)) NEXT