![]() |
Routines |
| Prev: 933E | Up: Map | Next: 9395 |
|
Used by the routines at StartTeleport and LevelNew.
Redraw the whole strip of moon surface along the bottom of the screen for the current scroll position, then colour the row of ground beneath it.
Jetman always stands at pixel column 78 so the left-hand edge of the screen is 78 pixels behind his world X in Jetman_Position. That is divided by 08 to find the terrain cell at the left edge, as the world is 2000 pixels wide and TerrainData_Active holds one cell for every 08 of them (0400 cells), wrapping round at the far end. The 20 cells from there are drawn side by side along character row 16.
|
||||
|
Work out which terrain cell sits at the left-hand edge of the screen.
|
||||
| DrawTerrain | 9356 | LD HL,($607A) | Fetch Jetman's world X from Jetman_Position. | |
| DrawTerrain_Target | 9359 | LD DE,$FF88 | DE=FF88 (minus 78). | |
| 935C | ADD HL,DE | Subtract 78 to find the world X of the left-hand edge of the screen. | ||
|
The world is 2000 pixels wide, so wrap anything left of its start back round to the far end.
|
||||
| 935D | LD A,H | A=H. | ||
| 935E | AND %00011111 | Keep only bits 0-4 so the position wraps round the world. | ||
| 9360 | LD H,A | H=A. | ||
| 9361 | SRA H | Divide the world X by 08 to give the terrain cell index. | ||
| 9363 | RR L | |||
| 9365 | SRA H | |||
| 9367 | RR L | |||
| 9369 | SRA H | |||
| 936B | RR L | |||
|
Start at the left-hand end of the terrain row on the screen.
|
||||
| 936D | LD DE,$50C0 | Set the screen address to 50C0 (the start of character row 16). | ||
| 9370 | LD BC,$7000 | Set the terrain base in BC to TerrainData_Active. | ||
| 9373 | LD A,$20 | Set a column counter in A for 20 loops. | ||
|
Draw the graphic for one terrain cell.
|
||||
| DrawTerrain_Loop | 9375 | PUSH AF | Stash the counter and the cell index on the stack. | |
| 9376 | PUSH HL | |||
| 9377 | ADD HL,BC | Add the terrain base to get the address of the cell. | ||
| 9378 | PUSH BC | Stash the terrain base and the screen address on the stack. | ||
| 9379 | PUSH DE | |||
| 937A | CALL DrawTerrainColumn | Call DrawTerrainColumn to copy the cell graphic onto the screen. | ||
| 937D | POP DE | Restore the screen address from the stack. | ||
| 937E | INC E | Move along to the next screen column. | ||
| 937F | POP BC | Restore the terrain base and the cell index from the stack. | ||
| 9380 | POP HL | |||
|
Step on to the next terrain cell, wrapping round at the end of the world, and loop until every column is drawn.
|
||||
| 9381 | INC HL | Move onto the next cell index. | ||
| 9382 | LD A,H | A=H. | ||
| 9383 | AND %00000011 | Keep only bits 0-1 so the index wraps round after 0400 cells. | ||
| 9385 | LD H,A | H=A. | ||
| 9386 | POP AF | Restore the counter from the stack. | ||
| 9387 | DEC A | Decrease the column counter by one. | ||
| 9388 | JR NZ,DrawTerrain_Loop | Jump back to DrawTerrain_Loop until all 20 columns are drawn. | ||
|
Colour the ground beneath the terrain; the black border columns at either edge of the window are left alone.
|
||||
| 938A | LD HL,$5AE1 | Set the attribute pointer to 5AE1 (the second column of the bottom row). | ||
| 938D | LD BC,$1E5B | Set a column counter in B for 1E loops and the ground colour in C to INK:MAGENTA, PAPER:MAGENTA (BRIGHT). | ||
| DrawTerrain_WriteByte | 9390 | LD (HL),C | Write the ground colour to the attribute buffer. | |
| 9391 | INC HL | Move onto the next column. | ||
| 9392 | DJNZ DrawTerrain_WriteByte | Decrease the column counter by one and loop back to DrawTerrain_WriteByte until the ground is coloured. | ||
| 9394 | RET | Return. | ||
| Prev: 933E | Up: Map | Next: 9395 |