![]() |
Routines |
| Prev: B37F | Up: Map | Next: B3B6 |
|
Finds the address in the display file of the byte that holds a pixel. The pixel y position counts up from the bottom of the screen, so the first step is to invert it. A y position of C0 or more is above the top of the screen, and gives an address below 4000.
|
||||||||||||||
|
Work out the byte from the position.
|
||||||||||||||
| CalculateScreenAddress | B394 | LD A,C | Divide C by eight. | |||||||||||
| B395 | RRCA | |||||||||||||
| B396 | RRCA | |||||||||||||
| B397 | RRCA | |||||||||||||
| B398 | AND %00011111 | Keep only the five bits of the column. | ||||||||||||
| B39A | LD E,A | Set E to the column. | ||||||||||||
|
Find the line within the character square.
|
||||||||||||||
| B39B | LD A,B | Invert the y co-ordinate, to count down from the top of the screen. | ||||||||||||
| B39C | CPL | |||||||||||||
| B39D | AND %00000111 | Keep the three bits of the line within the character square. | ||||||||||||
| B39F | EX AF,AF' | Copy it to A'. | ||||||||||||
|
Find the character row within the third of the screen, and merge it with the column to make the low byte of the address.
|
||||||||||||||
| B3A0 | LD A,B | Fetch B and invert it. | ||||||||||||
| B3A1 | CPL | |||||||||||||
| B3A2 | RLCA | Move the character row into bits 5 to 7. | ||||||||||||
| B3A3 | RLCA | |||||||||||||
| B3A4 | AND %11100000 | Keep bits 5 to 7. | ||||||||||||
| B3A6 | OR E | Combine them with the column in E. | ||||||||||||
| B3A7 | LD E,A | Copy it to E. | ||||||||||||
|
Find the third of the screen and merge it with the line to make the high byte of the address.
|
||||||||||||||
| B3A8 | LD A,B | Fetch B and invert it. | ||||||||||||
| B3A9 | CPL | |||||||||||||
| B3AA | RRCA | Move the third into bits 3 and 4. | ||||||||||||
| B3AB | RRCA | |||||||||||||
| B3AC | RRCA | |||||||||||||
| B3AD | AND %00011000 | Keep bits 3 and 4. | ||||||||||||
| B3AF | LD D,A | Copy it to D. | ||||||||||||
| B3B0 | EX AF,AF' | Fetch the line within the character square. | ||||||||||||
| B3B1 | OR D | Merge D. | ||||||||||||
| B3B2 | ADD A,$38 | Add 38, which corrects for the inverted y co-ordinate and adds the display file base of 40. | ||||||||||||
| B3B4 | LD D,A | Copy it to D. | ||||||||||||
| B3B5 | RET | Return. | ||||||||||||
|
View the equivalent code in;
|
||||||||||||||
| Prev: B37F | Up: Map | Next: B3B6 |