 | ;
| | ; Pass row in register b
| | ;
| get_screen_offset:
| | | push de | ; Store de safely on the stack
|
| | | ld de, y_lookup | ; Point DE at the start of the look-up table
| ld h, 0
| | | ld l, b | ; Load row into HL
| | add hl, hl | ; Multiply hl by two, because there are two bytes for every row
| | add hl, de | ; Add the address of table to HL
|
| | | ld e, (hl) | ; Load de with the two-byte number stored in the LUT
| | inc hl | ; (2 byte numbers are stored least-significant byte first)
| | ld d, (hl) | ;
|
| | | ld hl, 16384 | ; Load hl with the address of the screen
| | add hl, de | ; Add the offset taken from the LUT to hl
|
| | | pop de | ; Retrieve de from the stack
| ret
| |
| |
|