From b55382049e597e047b0bcd19033da35a8ed3b3b0 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Thu, 10 Nov 2016 15:35:25 -0800 Subject: [PATCH] run from banked RAM --- src/4live.a | 172 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 134 insertions(+), 38 deletions(-) diff --git a/src/4live.a b/src/4live.a index 668a47d..51e377e 100644 --- a/src/4live.a +++ b/src/4live.a @@ -20,6 +20,8 @@ !addr KBD = $C000 !addr STROBE = $C010 !addr LCBANK2 = $C083 +!addr ROMIN1 = $C089 +!addr LCBANK1 = $C08B !addr APLDETECT = $FBB3 ;#06 if IIe or later !addr KEYIN = $FD1B !addr RDCHAR = $FD35 @@ -42,6 +44,9 @@ SAVEKEY = $93 ; CTRL-S ;constants + SWAPCOPY = $368 + SWAPBUFFER = $800 ; (LoadSaveEnd - LoadSaveStart) size + ; currently $39A bytes! A2E = $06 INVSPACE = $20 LTARROW = $88 @@ -72,6 +77,17 @@ ; Install + ;switch cursor type depending on Apple revision + ;can't delay in case ROM is banked out because Diversi-DOS + + lda APLDETECT + cmp #A2E + beq + + lda #INVSPACE + sta CharDel + 1 + BankedCopyStart - $D000 + lda #("z" + 1 + $80) + sta CharMap + 1 + BankedCopyStart - $D000 ++ ;find a free DOS buffer @@ -101,8 +117,8 @@ Install ;set filename pointer in MLI request packet - stx FileName - sta FileName + 1 + stx FileName + BankedCopyStart - $D000 + sta FileName + 1 + BankedCopyStart - $D000 ;check for empty filename (indicates free buffer) @@ -115,8 +131,8 @@ Install jsr GETPARM sty MANPARML sta MANPARMH - sty MANPARM + 1 - sta MANPARM + 2 + sty MANPARM + 1 + BankedCopyStart - $D000 + sta MANPARM + 2 + BankedCopyStart - $D000 ;copy DOS buffer pointers to file manager parameter list @@ -156,11 +172,35 @@ Install lsr lsr lsr - sta FileSlot + sta FileSlot + BankedCopyStart - $D000 iny ;ldy #IOBDRIVE lda (OPSRCL), y - sta FileDrive - ldx #OPENEXISTING + sta FileDrive + BankedCopyStart - $D000 + + ;copy to swap space + + ldy #(SWAPCOPYEnd - SWAPCOPYStart) +- lda SWAPCOPYStart - 1, y + sta SWAPCOPY - 1, y + dey + bne - + + ;copy to banked RAM + + jsr BankInRAM1 + ldx #>(BankedCopyEnd + 255 - BankedCopyStart) + +CopyMod +- lda BankedCopyStart, y + sta $D000, y + iny + bne - + inc CopyMod + 2 + inc CopyMod + 5 + dex + bne - + + inx ;ldx #OPENEXISTING jsr OpenFile bcs + @@ -192,16 +232,8 @@ Install inc ReadWriteCmd ;lda WRITECMD / sta ReadWriteCmd - ;switch cursor type depending on Apple revision + lda ROMIN1 - lda APLDETECT - cmp #A2E - beq + - lda #INVSPACE - sta CharDel + 1 - lda #$DF - sta CharMap + 1 -+ ;display the welcome message, now that we're finally done ldy #0 @@ -224,6 +256,8 @@ FileName_b !scrxor $80, $DF, "4LIVE DATA" FileName_e +SWAPCOPYStart +!pseudopc SWAPCOPY { ;support enhanced flashing cursor while waiting for key, if available. ;it works by passing to the routine the character under the cursor. ;the ROM toggles between that character and the Delete character. @@ -237,16 +271,77 @@ GetKey ;are we on? cmp #HOTKEY - ;yes -> branch - beq + - ;no -> return to DOS + bne ReuseRts + + jsr BankInRAM1 + jsr RunFromBankedRAM + lda ROMIN1 + + ;lather, rinse, repeat + jsr RDCHAR + jmp GetKey + +SwapFILEMAN + lda ROMIN1 + jsr FILEMAN + +BankInRAM1 + bit LCBANK1 + bit LCBANK1 + +ReuseRts rts + ;sorry, I couldn't find a simpler way... + +ExchangeSwapBanked + lda #<(SWAPBUFFER + LoadSaveEnd - LoadSaveStart) + sta ExchangeSwapSource1 + 1 + sta ExchangeSwapTarget1 + 1 + lda #((>SWAPBUFFER) - >((<(LoadSaveEnd - LoadSaveStart)) + 255)) + sta ExchangeSwapSource1 + 2 + sta ExchangeSwapTarget1 + 2 + lda #<(LoadSaveStart + LoadSaveEnd - LoadSaveStart) + sta ExchangeSwapSource2 + 1 + sta ExchangeSwapTarget2 + 1 + lda #((>LoadSaveStart) - >((<(LoadSaveEnd - LoadSaveStart)) + 255)) + sta ExchangeSwapSource2 + 2 + sta ExchangeSwapTarget2 + 2 + ldx #>(LoadSaveEnd - LoadSaveStart) + ldy #<(LoadSaveStart - LoadSaveEnd) +ExchangeSwapSource1 + lda $34f3, y ;self-modified + pha +ExchangeSwapSource2 + lda $34f3, y ;self-modified +ExchangeSwapTarget1 + sta $34f3, y ;self-modified + pla +ExchangeSwapTarget2 + sta $34f3, y ;self-modified + iny + bne ExchangeSwapSource1 + inc ExchangeSwapSource1 + 2 + inc ExchangeSwapSource2 + 2 + inc ExchangeSwapTarget1 + 2 + inc ExchangeSwapTarget2 + 2 + dex + bpl ExchangeSwapSource1 + rts +} +SWAPCOPYEnd +!if ((SWAPCOPYEnd + SWAPCOPY - SWAPCOPYStart) > $3d0) { + !error "swap code too large, ends at ",SWAPCOPYEnd + SWAPCOPY - SWAPCOPYStart +} + +BankedCopyStart +!pseudopc $D000 { +RunFromBankedRAM ;preserve X across calls ;it's important for DOS -+ txa + txa pha ;first, scroll the edit buffer onto the screen @@ -272,10 +367,7 @@ IsDirty + pla tax - - ;lather, rinse, repeat - jsr RDCHAR - jmp GetKey + rts ScrollEditBufferIn lda #