My first impulse will be to place on every "512bytes page" code to switch page and jump somewhere, if it would be on the same place (ideally start of the page, as it is simply doable), then it can be simply used even when the page is changed in the middle of the process. (part of bytes would be from old page, part from new, but as the bytes are identical in both ...)
Depending on what you can use the construction may differ, but simply convention would be this - if you want to continue on page YYY at address XXX, then push the XXX, load YYY to A register and jump to start of your page. There will be code to store the A registr to the '377 chip and RTS.
Code:
page00: ; the begin of every page
STA SelectROMpage ; access to the 74LS377
RTS ; jump to the address needed there
.....
; later in the page
LDX #SomeAddress
PUSHX
LDA #pageNumber
JMP page00
If you are lucky to find the sequence of the bytes somewhere in already existing ROM (or can smuggle it somewhere in RAM on start), then you can save those bytes from every page by using this part of other code.
(And it may be some unaligned part of data, or other code too, maybe starting in middle of instruction)