Skip to content

Commit

Permalink
Allow option to specify which bank to page out to, as 128k mode and R…
Browse files Browse the repository at this point in the history
…OMS are a bit problematic when patched.
  • Loading branch information
HexTank committed Dec 18, 2019
1 parent 071b55b commit 90893aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Tools/Client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct SNA_Regs
struct SmartLINK_Regs : SNA_Regs
{
uint16_t pc;
uint8_t bank;
}
#ifdef __GNUC__
__attribute((packed))
Expand Down Expand Up @@ -631,7 +632,7 @@ vector<shared_ptr<vector<uint8_t>>> send_z80(string snapshot_to_load)
outRegs.im = inRegs->im;
outRegs.pc = isV1 ? inRegs->pc : static_cast<Z80_V2_Shared_Regs*>(inRegs)->_pc; // v2 has pc address for all subsequent versions.
outRegs.border = inRegs->border;

outRegs.bank = isV1 || static_cast<Z80_V2_Shared_Regs*>(inRegs)->hardwareMode == 0 ? 3 : 0x80;

int snapshotIndex = sizeof(Z80_V1_Shared_Regs) + (isV1 ? 0 : (static_cast<Z80_V2_Shared_Regs*>(inRegs)->headerSize + sizeof(uint16_t))); // v2 has extra header size for all subsequent versions.
shared_ptr<vector<uint8_t>> payload;
Expand Down
14 changes: 9 additions & 5 deletions targets/spectrum/smartcard/smartcard_rom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ restart_snapshot:
; setup the jmp PC in video memory
ld bc, (sna_header+27)
ld ((rst_pc_val - rst_cust_begin) + screen_mem), bc
; setup the rom we want to page out to
ld a, (sna_header+29)
ld ((rst_rom_val - rst_cust_begin) + screen_mem), a
endif
ei ; wait until just after a Spectrum frame IRQ before restarting snapshot
halt ; (to absorb any pending IRQ)
Expand Down Expand Up @@ -565,18 +568,19 @@ slink_image: incbin "smartlink.scr.zx7"
; -- Code to be placed at the top of vmem for restoring snapshot registers before execution
; --------------------------------------------------------------------------------------------

rst_cust_begin: db $ed, $79 ; out (c),a - start point when paging custom roms, not paging out / turning off smart card
db $01 ; ld bc
rst_bc_val: db $00, $00 ; ,xxxx
rst_cust_begin: db $3e ; ld a, - start point when paging custom roms, not paging out / turning off smart card
rst_rom_val: db $00 ; xx
db $ed, $79 ; out (c),a
db $01 ; ld bc,
rst_bc_val: db $00, $00 ; xxxx
db $3e ; ld a,
rst_r_val: db $00 ; xx
db $d3, $fe ; out (254),a - set border colour
db $ed, $4f ; ld r, a
db $3e ; ld a,
rst_a_val: db $00 ; xx
rst_ei_val: db $fb ; ei
rst_orig_begin: db $c3 ; jp - start point when paging original spectrum rom / turning off smart card
rst_pc_val: db $00, $00 ; ,xxxx
rst_pc_val: db $00, $00 ; xxxx
rst_end:

; --------------------------------------------------------------------------------------------
Expand Down

0 comments on commit 90893aa

Please sign in to comment.