![]() |
Routines |
| Prev: 62363 | Up: Map |
|
Used by the routines at 62468 and 62597. Updates the screen refresh buffer (SRB) for a window (or window-pair) after a light switch has been flipped or a blind has been raised or lowered.
|
||||||||||||
| 62368 | RES 6,L | Now L=X'/8 (where X' is the x-coordinate of the left edge of the window), and HL points at the Z value corresponding to the window | ||||||||||
| 62370 | LD BC,(32766) | The play area coordinates of the top-left corner of the screen are stored at 32766 and 32767 | ||||||||||
| 62374 | LD A,C | A=X (the x-coordinate of the leftmost column of the play area on screen) | ||||||||||
| 62375 | RRCA | A=X/8 | ||||||||||
| 62376 | RRCA | |||||||||||
| 62377 | RRCA | |||||||||||
| 62378 | LD E,A | E=X/8 (0-31) | ||||||||||
| 62379 | LD A,L | A=X'/8 (0-31) | ||||||||||
| 62380 | SUB E | A=X'/8-X/8 | ||||||||||
| 62381 | CP 4 | Is the window off screen to the right or left? | ||||||||||
| 62383 | RET NC | Return if so | ||||||||||
| 62384 | LD E,A | E=0-3 (index of the 8-tile wide column containing the window) | ||||||||||
| 62385 | LD A,H | A=1 (5th floor), 2, 3, 4 or 5 (1st floor) | ||||||||||
| 62386 | SUB 184 | |||||||||||
| 62388 | LD D,A | D=6 (5th floor), 12, 18, 24 or 30 (1st floor) | ||||||||||
| 62389 | ADD A,A | |||||||||||
| 62390 | ADD A,D | |||||||||||
| 62391 | ADD A,A | |||||||||||
| 62392 | LD D,A | |||||||||||
| 62393 | SUB B | Subtract Y, the y-coordinate of the topmost row of the play area on screen (2, 8, 14 or 20) | ||||||||||
| 62394 | ADD A,4 | Is the window off screen? | ||||||||||
| 62396 | CP 21 | |||||||||||
| 62398 | RET NC | Return if so | ||||||||||
| 62399 | ADD A,A | A=4*(D-Y+4)+E | ||||||||||
| 62400 | ADD A,A | |||||||||||
| 62401 | ADD A,E | |||||||||||
| 62402 | LD E,A | Point DE at the SRB byte corresponding to the top row of the window | ||||||||||
| 62403 | LD D,127 | |||||||||||
| 62405 | LD C,128 | C=128 (10000000) | ||||||||||
| 62407 | LD A,(HL) | Pick up the Z value for the window | ||||||||||
| 62408 | LD L,A | Point HL at the Z'' value for the leftmost column of tiles in the 8-tile wide segment that contains the window | ||||||||||
| 62409 | SET 7,L | |||||||||||
| 62411 | LD H,184 | |||||||||||
| 62413 | EXX | |||||||||||
| 62414 | LD L,A | Point HL' at the Z' value for the 8x6 block of tiles that contains the window | ||||||||||
| 62415 | LD H,191 | |||||||||||
| 62417 | LD C,1 | C'=1 (00000001) | ||||||||||
| 62419 | EXX | |||||||||||
|
The following loop examines the 8x6 block of tiles that contains the window and updates the relevant SRB bytes for the affected window tiles.
|
||||||||||||
| 62420 | EXX | |||||||||||
| 62421 | RRC C | Rotate the set bit in C' one place to the right | ||||||||||
| 62423 | LD A,(HL) | A=Z' value | ||||||||||
| 62424 | AND C | Set the zero flag if we should use the T values in pages 160, 162, 164, 166, 168 and 170 | ||||||||||
| 62425 | EXX | |||||||||||
| 62426 | PUSH HL | Save the pointer to the Z'' value | ||||||||||
| 62427 | LD L,(HL) | L=Z'' value | ||||||||||
| 62428 | LD H,160 | Point HL at the T value in page 160 | ||||||||||
| 62430 | JR Z,62434 | Jump unless we should use the T values in pages 172, 174, 176, 178, 180 and 182 | ||||||||||
| 62432 | LD H,172 | Point HL at the T value in page 172 | ||||||||||
| 62434 | LD B,6 | There are 6 rows of tiles to consider | ||||||||||
| 62436 | LD A,(HL) | A=T | ||||||||||
| 62437 | AND 192 | Keep only bits 6 and 7 | ||||||||||
| 62439 | CP 128 | Is there a window tile here? | ||||||||||
| 62441 | JR NZ,62446 | Jump if not | ||||||||||
| 62443 | LD A,(DE) | Set the appropriate bit in the SRB byte | ||||||||||
| 62444 | OR C | |||||||||||
| 62445 | LD (DE),A | |||||||||||
| 62446 | INC H | Point HL at the next T value (in page 162, 164, 166, 168, 170, 174, 176, 178, 180 or 182) | ||||||||||
| 62447 | INC H | |||||||||||
| 62448 | LD A,E | Point DE at the SRB byte for the next row down | ||||||||||
| 62449 | ADD A,4 | |||||||||||
| 62451 | LD E,A | |||||||||||
| 62452 | DJNZ 62436 | Jump back to consider the tile in the next row down | ||||||||||
| 62454 | LD A,E | Point DE back at the SRB byte corresponding to the top row of the window | ||||||||||
| 62455 | SUB 24 | |||||||||||
| 62457 | LD E,A | |||||||||||
| 62458 | POP HL | Restore the Z'' value pointer to HL | ||||||||||
| 62459 | INC H | Point HL at the Z'' value for the next column of tiles to the right (in page 185-191) | ||||||||||
| 62460 | RRC C | Rotate the set bit in C one place to the right | ||||||||||
| 62462 | JR NC,62420 | Jump back until 8 tile columns have been checked | ||||||||||
| 62464 | RET | |||||||||||
| Prev: 62363 | Up: Map |