| Chase H.Q. | Routines |
| Prev: F3B6 | Up: Map | Next: F414 |
|
Lives at $81D6 when relocated.
Exchanges the contents of $C000..$FFFF in banks 0 and 3, 4K at a time through a buffer at $B000. Each window is copied to the buffer, bank 3 is paged in, the buffer and the window are exchanged byte by byte, bank 0 is paged back in, and the buffer, now holding bank 3's bytes, is copied into the window. Running it a second time undoes the swap.
The CALL to $8209 enters the relocated reset_paging_128k one instruction in, skipping its XOR A, so the OUT pages in the bank number held in A.
|
||||
| swap_bank_3_128k | F3E2 | LD HL,$C000 | HL = $C000 | |
| F3E5 | LD B,$04 | 4 iterations | ||
| F3E7 | LD E,L | E = 0 | ||
| sb_window_loop | F3E8 | PUSH BC | Preserve iterations | |
| F3E9 | LD D,$B0 | DE = $B000 | ||
| F3EB | LD BC,$1000 | 4096 bytes | ||
| F3EE | PUSH BC | Preserve | ||
| F3EF | PUSH HL | |||
| F3F0 | LDIR | Copy bank 0's window to the buffer | ||
| F3F2 | LD A,$03 | Bank 3 | ||
| F3F4 | CALL setup_engine_sfx_48k_0 | Page it in through the relocated F415 | ||
| F3F7 | POP HL | Retrieve from stack | ||
| F3F8 | POP BC | |||
| F3F9 | PUSH BC | |||
| F3FA | PUSH HL | |||
| F3FB | LD D,$B0 | DE = $B000 | ||
| sb_swap_loop | F3FD | LD A,(DE) | A = bank 0's byte from the buffer | |
| F3FE | LDI | Move bank 3's byte to the buffer | ||
| F400 | DEC HL | Store bank 0's byte in bank 3's window | ||
| F401 | LD (HL),A | |||
| F402 | INC HL | |||
| F403 | JP PE,$81F1 | Loop to the relocated sb_swap_loop until BC is zero | ||
| F406 | CALL $8208 | Call the relocated reset_paging_128k to page bank 0 back in | ||
| F409 | POP DE | Restore | ||
| F40A | POP BC | |||
| F40B | LD H,$B0 | HL = $B000 | ||
| F40D | LDIR | Copy bank 3's window from the buffer | ||
| F40F | LD H,D | H = D | ||
| F410 | POP BC | Restore iterations | ||
| F411 | DJNZ sb_window_loop | Loop to sb_window_loop | ||
| F413 | RET | Return | ||
| Prev: F3B6 | Up: Map | Next: F414 |