Merge pull request #6 from peterferrie/master

v2, run from RAM bank
This commit is contained in:
4am 2016-11-10 19:55:34 -05:00 committed by GitHub
commit 3b3672e249
2 changed files with 154 additions and 35 deletions

View File

@ -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,10 @@
SAVEKEY = $93 ; CTRL-S
;constants
SWAPCOPY = $368
SWAPBUFFER = $800 ; (LoadSaveEnd - LoadSaveStart) size
; currently $39A bytes!
; needed by DiversiDOS
A2E = $06
INVSPACE = $20
LTARROW = $88
@ -72,6 +78,17 @@
;
Install
;switch cursor type depending on Apple revision
;can't delay in case ROM is banked out because DiversiDOS
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
@ -83,6 +100,14 @@ Install
cmp #$BF
bne +
!if <SWAPBUFFER {
ldy #<SWAPBUFFER
}
sty ReadBuffer + BankedCopyStart - $D000
lda #>SWAPBUFFER
sta ReadBuffer + 1 + BankedCopyStart - $D000
lda #$A9
sta ExchangeSwapBanked + SWAPCOPYStart - SWAPCOPY
lda LCBANK2
lda LCBANK2
lda #$DD
@ -101,8 +126,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 +140,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 +181,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,14 +241,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
+
;display the welcome message, now that we're finally done
ldy #0
@ -222,6 +265,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.
@ -235,16 +280,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
jsr FILEMAN
BankInRAM1
bit LCBANK1
bit LCBANK1
ReuseRts
rts
;sorry, I couldn't find a simpler way...
ExchangeSwapBanked
rts ;self-modified to LDA in DiversiDOS environment
!byte <(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
@ -270,10 +376,7 @@ IsDirty
+ pla
tax
;lather, rinse, repeat
jsr RDCHAR
jmp GetKey
rts
ScrollEditBufferIn
lda #<LastLine
@ -305,16 +408,22 @@ VirtualBuff1
VirtualBuff2
- lda $34f3, y ;self-modified
sta $0400, y
CharMap
cmp #0 ;self-modified
bcs +
cmp #("a" + $80)
bcc +
and #$DF
+ sta $0400, y
dey
bpl -
;animation delay
jsr Delay ;returns carry set
tay
lda #-WIDTH
ldx #$FF
ldy #0
jsr UpdateVirtualOff
dec ScrollLine1 + 1
@ -358,10 +467,10 @@ VirtualBuff4
bpl -
;animation delay
jsr Delay
jsr Delay ;returns carry set
tax
lda #WIDTH
ldx #0
ldy #<(VirtualBuff3 - VirtualBuff1)
jsr UpdateVirtualOff
dec ScrollLine2 + 1
@ -685,8 +794,10 @@ CloseMLI_b
CloseMLI_e
rts
ReadFile
WriteFile
jsr ExchangeSwapBanked
ReadFile
jsr DOSMLI
!byte ReadMLI_e - ReadMLI_b
ReadMLI_b
@ -706,9 +817,9 @@ WriteSize
;number of bytes
ReadBuffer
WriteBuffer
!word LoadSaveStart ;buffer
!word LoadSaveStart ;buffer, self-modified in DiversiDOS
ReadMLI_e
rts
jmp ExchangeSwapBanked
;first byte fetched is number of byte to follow,
;copy parameters to file manager parameter list,
@ -748,7 +859,7 @@ MANPARM
bne -
XREG
ldx #"Q" ;self-modified
jmp FILEMAN
jmp SwapFILEMAN
TextCalcHi
!byte $04, $04, $05, $05, $06, $06, $07, $07
@ -761,22 +872,24 @@ TextCalcLo
LoadSaveStart
;;in the future, this field will contain the number of bytes following for write
;;FileSize ;must be first!
;; !text "4s" ;self-modified
;;FileSize ;must be first!
;; !text "4s" ;self-modified
SaveCH
!byte 0 ;loaded from file if exists
SaveCV
!byte 0 ;loaded from file if exists
!ct "lcase.ct"
FirstLine ;lines are stored sequentially, not like text page in memory
!fill WIDTH * 8, $A0
!scrxor $80, " 4LIVE by 4am && qkumba "
!text " 4LIVE by 4am && qkumba "
!fill WIDTH, $A0
!scrxor $80, " Revision 01 / Serial number 161103 "
!text " Revision 02 / Serial number 161107 "
!fill WIDTH * 2, $A0
!scrxor $80, " https://github.com/a2-4am/4live "
!text " https://github.com/a2-4am/4live "
!fill WIDTH * 9, $A0
!ct raw
LoadSaveEnd
;in the current version, the status line is not saved
@ -788,3 +901,5 @@ LoadSaveEnd
LastLine
!fill WIDTH, $A0
}
BankedCopyEnd

4
src/lcase.a Normal file
View File

@ -0,0 +1,4 @@
!to "lcase.ct", plain
*=0
!for i, 128 {!byte i+127}
!for i, 256-128 {!byte i+127}