mirror of
https://github.com/a2-4am/4live.git
synced 2024-12-30 09:30:41 +00:00
run from banked RAM
This commit is contained in:
parent
89bb91a19c
commit
b55382049e
172
src/4live.a
172
src/4live.a
@ -20,6 +20,8 @@
|
|||||||
!addr KBD = $C000
|
!addr KBD = $C000
|
||||||
!addr STROBE = $C010
|
!addr STROBE = $C010
|
||||||
!addr LCBANK2 = $C083
|
!addr LCBANK2 = $C083
|
||||||
|
!addr ROMIN1 = $C089
|
||||||
|
!addr LCBANK1 = $C08B
|
||||||
!addr APLDETECT = $FBB3 ;#06 if IIe or later
|
!addr APLDETECT = $FBB3 ;#06 if IIe or later
|
||||||
!addr KEYIN = $FD1B
|
!addr KEYIN = $FD1B
|
||||||
!addr RDCHAR = $FD35
|
!addr RDCHAR = $FD35
|
||||||
@ -42,6 +44,9 @@
|
|||||||
SAVEKEY = $93 ; CTRL-S
|
SAVEKEY = $93 ; CTRL-S
|
||||||
|
|
||||||
;constants
|
;constants
|
||||||
|
SWAPCOPY = $368
|
||||||
|
SWAPBUFFER = $800 ; (LoadSaveEnd - LoadSaveStart) size
|
||||||
|
; currently $39A bytes!
|
||||||
A2E = $06
|
A2E = $06
|
||||||
INVSPACE = $20
|
INVSPACE = $20
|
||||||
LTARROW = $88
|
LTARROW = $88
|
||||||
@ -72,6 +77,17 @@
|
|||||||
;
|
;
|
||||||
|
|
||||||
Install
|
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
|
;find a free DOS buffer
|
||||||
|
|
||||||
@ -101,8 +117,8 @@ Install
|
|||||||
|
|
||||||
;set filename pointer in MLI request packet
|
;set filename pointer in MLI request packet
|
||||||
|
|
||||||
stx FileName
|
stx FileName + BankedCopyStart - $D000
|
||||||
sta FileName + 1
|
sta FileName + 1 + BankedCopyStart - $D000
|
||||||
|
|
||||||
;check for empty filename (indicates free buffer)
|
;check for empty filename (indicates free buffer)
|
||||||
|
|
||||||
@ -115,8 +131,8 @@ Install
|
|||||||
jsr GETPARM
|
jsr GETPARM
|
||||||
sty MANPARML
|
sty MANPARML
|
||||||
sta MANPARMH
|
sta MANPARMH
|
||||||
sty MANPARM + 1
|
sty MANPARM + 1 + BankedCopyStart - $D000
|
||||||
sta MANPARM + 2
|
sta MANPARM + 2 + BankedCopyStart - $D000
|
||||||
|
|
||||||
;copy DOS buffer pointers to file manager parameter list
|
;copy DOS buffer pointers to file manager parameter list
|
||||||
|
|
||||||
@ -156,11 +172,35 @@ Install
|
|||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
lsr
|
lsr
|
||||||
sta FileSlot
|
sta FileSlot + BankedCopyStart - $D000
|
||||||
iny ;ldy #IOBDRIVE
|
iny ;ldy #IOBDRIVE
|
||||||
lda (OPSRCL), y
|
lda (OPSRCL), y
|
||||||
sta FileDrive
|
sta FileDrive + BankedCopyStart - $D000
|
||||||
ldx #OPENEXISTING
|
|
||||||
|
;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
|
jsr OpenFile
|
||||||
bcs +
|
bcs +
|
||||||
|
|
||||||
@ -192,16 +232,8 @@ Install
|
|||||||
|
|
||||||
inc ReadWriteCmd ;lda WRITECMD / sta ReadWriteCmd
|
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
|
;display the welcome message, now that we're finally done
|
||||||
|
|
||||||
ldy #0
|
ldy #0
|
||||||
@ -224,6 +256,8 @@ FileName_b
|
|||||||
!scrxor $80, $DF, "4LIVE DATA"
|
!scrxor $80, $DF, "4LIVE DATA"
|
||||||
FileName_e
|
FileName_e
|
||||||
|
|
||||||
|
SWAPCOPYStart
|
||||||
|
!pseudopc SWAPCOPY {
|
||||||
;support enhanced flashing cursor while waiting for key, if available.
|
;support enhanced flashing cursor while waiting for key, if available.
|
||||||
;it works by passing to the routine the character under the cursor.
|
;it works by passing to the routine the character under the cursor.
|
||||||
;the ROM toggles between that character and the Delete character.
|
;the ROM toggles between that character and the Delete character.
|
||||||
@ -237,16 +271,77 @@ GetKey
|
|||||||
;are we on?
|
;are we on?
|
||||||
cmp #HOTKEY
|
cmp #HOTKEY
|
||||||
|
|
||||||
;yes -> branch
|
|
||||||
beq +
|
|
||||||
|
|
||||||
;no -> return to DOS
|
;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
|
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
|
;preserve X across calls
|
||||||
;it's important for DOS
|
;it's important for DOS
|
||||||
|
|
||||||
+ txa
|
txa
|
||||||
pha
|
pha
|
||||||
|
|
||||||
;first, scroll the edit buffer onto the screen
|
;first, scroll the edit buffer onto the screen
|
||||||
@ -272,10 +367,7 @@ IsDirty
|
|||||||
|
|
||||||
+ pla
|
+ pla
|
||||||
tax
|
tax
|
||||||
|
rts
|
||||||
;lather, rinse, repeat
|
|
||||||
jsr RDCHAR
|
|
||||||
jmp GetKey
|
|
||||||
|
|
||||||
ScrollEditBufferIn
|
ScrollEditBufferIn
|
||||||
lda #<LastLine
|
lda #<LastLine
|
||||||
@ -307,22 +399,22 @@ VirtualBuff1
|
|||||||
|
|
||||||
VirtualBuff2
|
VirtualBuff2
|
||||||
- lda $34f3, y ;self-modified
|
- lda $34f3, y ;self-modified
|
||||||
|
CharMap
|
||||||
|
cmp #0 ;self-modified
|
||||||
|
bcs +
|
||||||
cmp #("a" + $80)
|
cmp #("a" + $80)
|
||||||
bcc +
|
bcc +
|
||||||
cmp #("z" + 1 + $80)
|
and #$DF
|
||||||
bcs +
|
+ sta $0400, y
|
||||||
CharMap
|
|
||||||
and #$FF ;self-modified
|
|
||||||
sta $0400, y
|
|
||||||
dey
|
dey
|
||||||
bpl -
|
bpl -
|
||||||
|
|
||||||
;animation delay
|
;animation delay
|
||||||
jsr Delay ;returns carry set
|
jsr Delay ;returns carry set
|
||||||
|
|
||||||
|
tay
|
||||||
lda #-WIDTH
|
lda #-WIDTH
|
||||||
ldx #$FF
|
ldx #$FF
|
||||||
ldy #0
|
|
||||||
jsr UpdateVirtualOff
|
jsr UpdateVirtualOff
|
||||||
dec ScrollLine1 + 1
|
dec ScrollLine1 + 1
|
||||||
|
|
||||||
@ -366,10 +458,10 @@ VirtualBuff4
|
|||||||
bpl -
|
bpl -
|
||||||
|
|
||||||
;animation delay
|
;animation delay
|
||||||
jsr Delay
|
jsr Delay ;returns carry set
|
||||||
|
|
||||||
|
tax
|
||||||
lda #WIDTH
|
lda #WIDTH
|
||||||
ldx #0
|
|
||||||
ldy #<(VirtualBuff3 - VirtualBuff1)
|
ldy #<(VirtualBuff3 - VirtualBuff1)
|
||||||
jsr UpdateVirtualOff
|
jsr UpdateVirtualOff
|
||||||
dec ScrollLine2 + 1
|
dec ScrollLine2 + 1
|
||||||
@ -693,8 +785,10 @@ CloseMLI_b
|
|||||||
CloseMLI_e
|
CloseMLI_e
|
||||||
rts
|
rts
|
||||||
|
|
||||||
ReadFile
|
|
||||||
WriteFile
|
WriteFile
|
||||||
|
jsr ExchangeSwapBanked
|
||||||
|
|
||||||
|
ReadFile
|
||||||
jsr DOSMLI
|
jsr DOSMLI
|
||||||
!byte ReadMLI_e - ReadMLI_b
|
!byte ReadMLI_e - ReadMLI_b
|
||||||
ReadMLI_b
|
ReadMLI_b
|
||||||
@ -714,9 +808,9 @@ WriteSize
|
|||||||
;number of bytes
|
;number of bytes
|
||||||
ReadBuffer
|
ReadBuffer
|
||||||
WriteBuffer
|
WriteBuffer
|
||||||
!word LoadSaveStart ;buffer
|
!word SWAPBUFFER ;buffer
|
||||||
ReadMLI_e
|
ReadMLI_e
|
||||||
rts
|
jmp ExchangeSwapBanked
|
||||||
|
|
||||||
;first byte fetched is number of byte to follow,
|
;first byte fetched is number of byte to follow,
|
||||||
;copy parameters to file manager parameter list,
|
;copy parameters to file manager parameter list,
|
||||||
@ -756,7 +850,7 @@ MANPARM
|
|||||||
bne -
|
bne -
|
||||||
XREG
|
XREG
|
||||||
ldx #"Q" ;self-modified
|
ldx #"Q" ;self-modified
|
||||||
jmp FILEMAN
|
jmp SwapFILEMAN
|
||||||
|
|
||||||
TextCalcHi
|
TextCalcHi
|
||||||
!byte $04, $04, $05, $05, $06, $06, $07, $07
|
!byte $04, $04, $05, $05, $06, $06, $07, $07
|
||||||
@ -769,8 +863,8 @@ TextCalcLo
|
|||||||
|
|
||||||
LoadSaveStart
|
LoadSaveStart
|
||||||
;;in the future, this field will contain the number of bytes following for write
|
;;in the future, this field will contain the number of bytes following for write
|
||||||
;;FileSize ;must be first!
|
;;FileSize ;must be first!
|
||||||
;; !text "4s" ;self-modified
|
;; !text "4s" ;self-modified
|
||||||
|
|
||||||
SaveCH
|
SaveCH
|
||||||
!byte 0 ;loaded from file if exists
|
!byte 0 ;loaded from file if exists
|
||||||
@ -798,3 +892,5 @@ LoadSaveEnd
|
|||||||
|
|
||||||
LastLine
|
LastLine
|
||||||
!fill WIDTH, $A0
|
!fill WIDTH, $A0
|
||||||
|
}
|
||||||
|
BankedCopyEnd
|
||||||
|
Loading…
Reference in New Issue
Block a user