![]() |
Routines |
| Prev: D4F3 | Up: Map | Next: D564 |
|
Used by the routines at DRAW_OUTLINE and DRAW_WALLS.
The projection, and the scrolling: everything is placed relative to the knight, who therefore stays at the middle of the screen while the town moves under him. For a point at U and V, with dU and dV its distance from the knight's U and V (both turned round with the town if it is): DRAW_X = (dU + dV + $F0) / 2 and DRAW_Y = (dV - dU + $1B0) / 4, signed. So U runs right and down the screen and V right and up, 256 units a cell: a cell is a diamond 256 pixels wide and 128 lines high, bigger than the play area, and the knight's own point is at x 120, the middle of the part of the buffer that is shown, and line 108. DRAW_Y counts up the screen, as the buffer's lines do. It is Filmation's projection, x from U + V and y from V - U, at half the scale and with no height.
PROJECT_CELL projects the corner of the cell last looked up (CELL_LOOKED_UP, in the view's terms): its lowest U and V, where the wall along its first face starts. PROJECT_POINT, entered from PROJECT_THING with a U in HL and a V pushed, both turned already if the town is, projects any point.
|
||||
| PROJECT_CELL | D508 | LD A,($BBB5) | V = the cell's row times 256, saved | |
| D50B | LD L,$00 | |||
| D50D | LD H,A | |||
| D50E | PUSH HL | |||
| D50F | LD A,(CELL_LOOKED_UP) | U = its column times 256 | ||
| D512 | LD L,$00 | |||
| D514 | LD H,A | |||
|
This entry point is used by the routine at PROJECT_THING.
|
||||
| PROJECT_POINT | D515 | LD DE,(KNIGHT_U) | The knight's U, turned if the town is | |
| D519 | LD A,(VIEW) | |||
| D51C | AND $01 | |||
| D51E | JR Z,PROJECT_CELL_0 | |||
| D520 | LD A,E | |||
| D521 | CPL | |||
| D522 | LD E,A | |||
| D523 | LD A,D | |||
| D524 | CPL | |||
| D525 | AND $1F | |||
| D527 | LD D,A | |||
| PROJECT_CELL_0 | D528 | AND A | DE = dU | |
| D529 | SBC HL,DE | |||
| D52B | EX DE,HL | |||
| D52C | POP HL | The knight's V, the same | ||
| D52D | LD BC,(KNIGHT_V) | |||
| D531 | LD A,(VIEW) | |||
| D534 | AND $01 | |||
| D536 | JR Z,PROJECT_CELL_1 | |||
| D538 | LD A,C | |||
| D539 | CPL | |||
| D53A | LD C,A | |||
| D53B | LD A,B | |||
| D53C | CPL | |||
| D53D | AND $1F | |||
| D53F | LD B,A | |||
| PROJECT_CELL_1 | D540 | AND A | HL = dV | |
| D541 | SBC HL,BC | |||
| D543 | PUSH HL | |||
| D544 | LD BC,$00F0 | DRAW_X = (dU + dV + $F0) / 2 | ||
| D547 | ADD HL,DE | |||
| D548 | ADD HL,BC | |||
| D549 | SRA H | |||
| D54B | RR L | |||
| D54D | LD (DRAW_X),HL | |||
| D550 | POP HL | DRAW_Y = (dV - dU + $1B0) / 4 | ||
| D551 | AND A | |||
| D552 | SBC HL,DE | |||
| D554 | LD BC,$01B0 | |||
| D557 | ADD HL,BC | |||
| D558 | SRA H | |||
| D55A | RR L | |||
| D55C | SRA H | |||
| D55E | RR L | |||
| D560 | LD (DRAW_Y),HL | |||
| D563 | RET | |||
| Prev: D4F3 | Up: Map | Next: D564 |