Prev: F39F Up: Map Next: F3E2
F3B6: Call a routine in RAM bank 3
Lives at $81AA when relocated. Saves $B000..$BFFF to $F000, since swap_bank_3_128k uses it as a buffer, moves the stack to $A214, below the swapped area, then calls the entry point with bank 3's contents swapped into $C000..$FFFF. The saved copy at $F000 travels to bank 3 and back with the swap, and is restored to $B000 afterwards.
Input
HL Address of entry point ($C000 + 0/3/6/9)
call_bank_3_128k F3B6 LD ($81C6),HL Self modify 'CALL xxxx' @ $81C5 (F3D1 here - below)
F3B9 LD HL,$B000 Set up registers to copy 4096 bytes from $B000 to $F000
F3BC LD DE,$F000
F3BF LD BC,$1000
F3C2 PUSH HL Preserve registers for later
F3C3 PUSH DE
F3C4 PUSH BC
F3C5 LDIR Copy 4096 bytes from $B000 to $F000
F3C7 LD ($81CE),SP Self modify 'LD SP,xxxx' @ $81CD (F3D9 here - below)
F3CB LD SP,$A214 Set stack pointer
F3CE CALL $81D6 Call swap_bank_3_128k to swap bank 3 in
F3D1 CALL $0000 Call the entry point requested. Self modified by call_bank_3_128k
F3D4 PUSH AF Preserve the called routine's AF result across the page switch
F3D5 CALL $81D6 Call swap_bank_3_128k again to swap it back out
F3D8 POP AF Restore
F3D9 LD SP,$0000 Restore original SP (self modified by F3C7 above)
F3DC POP BC Restore registers but swap source and destination around
F3DD POP HL
F3DE POP DE
F3DF LDIR Copy 4096 bytes from $F000 to $B000
F3E1 RET Return
Prev: F39F Up: Map Next: F3E2