mirror of
https://github.com/a2-4am/4live.git
synced 2024-09-27 02:55:02 +00:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
0528bef255 | ||
|
058ad84ca0 | ||
|
ed27b90a7f | ||
|
093776ae8a | ||
|
c3238a4002 | ||
|
1b8e0e3083 | ||
|
e479eac6af | ||
|
30af162c18 | ||
|
f7f330b6e3 | ||
|
d93528716b |
@ -10,7 +10,7 @@
|
||||
|
||||
### Memory usage
|
||||
|
||||
When you first run 4LIVE, it will load only a small code stub in low memory, at $023B. This stub will load the rest of 4LIVE directly into LC RAM bank 1. Thereafter, 4LIVE uses $0309-$03CF in main memory and $D000-$DFFF in LC RAM bank 1. 4LIVE never uses LC RAM bank 2, auxiliary memory, or any other region in main memory.
|
||||
When you first run 4LIVE, it will load only a small code stub in low memory, at $0232. This stub will load the rest of 4LIVE directly into LC RAM bank 1. Thereafter, 4LIVE uses $0309-$03CF in main memory and $D000-$DFFF in LC RAM bank 1. 4LIVE never uses LC RAM bank 2, auxiliary memory, or any other region in main memory.
|
||||
|
||||
## For users
|
||||
|
||||
|
BIN
bin/V2Make.scpt
BIN
bin/V2Make.scpt
Binary file not shown.
267
src/4live.a
267
src/4live.a
@ -1,6 +1,6 @@
|
||||
;
|
||||
; 4LIVE
|
||||
; Copyright (c) 2016-7 by 4am && qkumba
|
||||
; Copyright (c) 2016-8 by 4am && qkumba
|
||||
; 100% open source, see LICENSE file
|
||||
;
|
||||
!cpu 6502
|
||||
@ -8,6 +8,7 @@
|
||||
|
||||
;user-defined
|
||||
HOTKEY = $80 ; CTRL-@
|
||||
FINDKEY = $86 ; CTRL-F
|
||||
HIGHLIGHTKEY = $82 ; CTRL-B
|
||||
CLEARKEY = $83 ; CTRL-C
|
||||
PREVPAGEKEY = $92 ; CTRL-R
|
||||
@ -17,6 +18,7 @@
|
||||
|
||||
VERBOSE = $0 ; set to 1 to show memory usage during build
|
||||
;
|
||||
!addr PROMPT = $33
|
||||
!addr KSWL = $38
|
||||
!addr KSWH = $39
|
||||
!addr FCBFOP = $40
|
||||
@ -30,9 +32,12 @@
|
||||
!addr LCBANK2 = $C083
|
||||
!addr ROMIN1 = $C089
|
||||
!addr LCBANK1 = $C08B
|
||||
!addr SCRN2P2 = $F87B ;SCRN2 +2
|
||||
!addr PRNTYX = $F940
|
||||
!addr APLDETECT = $FBB3 ;#06 if IIe or later
|
||||
!addr KEYIN = $FD1B
|
||||
!addr RDCHAR = $FD35
|
||||
!addr CROUT = $FD8E
|
||||
!addr COUT = $FDED
|
||||
|
||||
;private arbitrary addresses, shared with DOS to avoid conflict
|
||||
@ -58,6 +63,8 @@
|
||||
SPACE = $A0
|
||||
DELETE = $FF
|
||||
|
||||
WILDCARD = $97
|
||||
|
||||
IOBSLOT = 1
|
||||
IOBDRIVE = 2
|
||||
NAMELEN = 30
|
||||
@ -72,9 +79,8 @@
|
||||
POSRDWRRANGE = 4
|
||||
WIDTH = 40
|
||||
HEIGHT = 24
|
||||
LDRBASE = $2E9
|
||||
INSTALLBUFFER = $23B ; yes, the overlay overwrites the loader...
|
||||
; see also "warning!" below
|
||||
LDRBASE = $2DB
|
||||
INSTALLBUFFER = $20E ; yes, the overlay overwrites the loader...
|
||||
SWAPBUFFER = $900 ; (LoadSaveEnd - LoadSaveStart) size
|
||||
; needed by Diversi-DOS, must be page-aligned
|
||||
; region is preserved across calls
|
||||
@ -108,12 +114,8 @@ LdrStart
|
||||
sta FileDrive
|
||||
dey ;ldy #IOBSLOT
|
||||
lda (OPSRC1L), y
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
jsr SCRN2P2
|
||||
sta FileSlot
|
||||
dey ;ldy #00
|
||||
|
||||
;open self and read first overlay
|
||||
|
||||
@ -231,6 +233,18 @@ BankInRAM1
|
||||
bit LCBANK1
|
||||
rts
|
||||
|
||||
PrintAddr
|
||||
bit ROMIN1
|
||||
jsr PRNTYX
|
||||
|
||||
PrintCR
|
||||
lda #RETURN
|
||||
|
||||
PrintChar
|
||||
bit ROMIN1
|
||||
jsr COUT
|
||||
bne BankInRAM1
|
||||
|
||||
;read file content into memory
|
||||
;with swapping of the memory contents in Diversi-DOS,
|
||||
;in order to preserve the original memory region
|
||||
@ -347,18 +361,27 @@ InstallStart
|
||||
+
|
||||
;open source file and read header if available
|
||||
|
||||
lda SWAPBUFFER
|
||||
pha
|
||||
lda SWAPBUFFER+1
|
||||
pha
|
||||
jsr LoadSaveHeader
|
||||
bcs +
|
||||
lda SaveCH
|
||||
sta Pages + 1
|
||||
sta OrgPages + 1
|
||||
ldx SaveCV
|
||||
stx CurPage + 1
|
||||
stx OrgPage + 1
|
||||
jsr SeekReadWrite
|
||||
dec ClearOnFirstKeypress + 1
|
||||
dec PreventAddPage + 1 ;tri-state flag because Diversi-DOS
|
||||
inc HeaderExists + 1
|
||||
+
|
||||
;set to true if no data file found (carry is set)
|
||||
|
||||
rol ClearOnFirstKeypress + 1
|
||||
rol PreventAddPage + 1 ;tri-state flag because Diversi-DOS
|
||||
pla
|
||||
sta SWAPBUFFER+1
|
||||
pla
|
||||
sta SWAPBUFFER
|
||||
|
||||
jsr SetTextCoords1
|
||||
|
||||
@ -443,11 +466,19 @@ GetKey
|
||||
|
||||
cmp #HOTKEY
|
||||
|
||||
;yes -> let's do that
|
||||
|
||||
beq +
|
||||
|
||||
;memory search?
|
||||
|
||||
cmp #FINDKEY
|
||||
|
||||
;no -> return to DOS
|
||||
|
||||
bne ReuseRts
|
||||
|
||||
jsr BankInRAM1
|
||||
+ jsr BankInRAM1
|
||||
jsr RunFromBankedRAM
|
||||
lda ROMIN1
|
||||
|
||||
@ -474,6 +505,9 @@ InstallEnd
|
||||
BankedCopyStart
|
||||
!pseudopc $D000 {
|
||||
RunFromBankedRAM
|
||||
cmp #FINDKEY
|
||||
beq FindChars
|
||||
|
||||
;preserve X across calls
|
||||
;it's important for DOS
|
||||
|
||||
@ -506,6 +540,148 @@ RunFromBankedRAM
|
||||
tax
|
||||
rts
|
||||
|
||||
FindChars
|
||||
sty CharCount + 1
|
||||
ldx #0
|
||||
ldy #0
|
||||
|
||||
ConvertChars
|
||||
cmp #$10
|
||||
bcs NextChar
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
asl
|
||||
sta OPSRC1L
|
||||
jsr Char2Nib
|
||||
ora OPSRC1L
|
||||
sta SECTORBUFFER, y
|
||||
iny
|
||||
|
||||
NextChar
|
||||
jsr Char2Nib
|
||||
|
||||
CharCount
|
||||
cpx #0 ;self-modified
|
||||
bcc ConvertChars
|
||||
jsr PrintCR
|
||||
dex
|
||||
beq CancelLine
|
||||
jsr SearchMemory
|
||||
|
||||
CancelLine
|
||||
ldx #0
|
||||
lda PROMPT
|
||||
tay ;in case Y was zero
|
||||
jmp PrintChar
|
||||
|
||||
SearchMemory
|
||||
lda DOSBASE
|
||||
sta .endvalue+1
|
||||
lda #8
|
||||
sta search+2
|
||||
sty match_size1+1
|
||||
sty match_size2+1
|
||||
|
||||
; fetch last byte to improve search speed
|
||||
|
||||
dey
|
||||
|
||||
match_buffer1
|
||||
lda SECTORBUFFER,y
|
||||
sta check_byte1+1
|
||||
sta check_byte2+1
|
||||
|
||||
; set low part of initial search position
|
||||
|
||||
sty cont_search+1
|
||||
|
||||
lda #<cont_search-branch_cont-2
|
||||
sta branch_cont+1
|
||||
|
||||
; search...
|
||||
|
||||
cont_search
|
||||
ldy #$d1 ; modified at runtime
|
||||
|
||||
search
|
||||
lda $d100,y ; modified at runtime
|
||||
iny
|
||||
beq check_end
|
||||
|
||||
check_byte1
|
||||
cmp #$d1 ; modified at runtime
|
||||
bne search
|
||||
|
||||
; point to first byte
|
||||
|
||||
sty cont_search+1
|
||||
|
||||
check_match
|
||||
tya
|
||||
|
||||
match_size1
|
||||
sbc #$d1 ; modified at runtime
|
||||
sta match_buffer2+1
|
||||
lda search+2
|
||||
sbc #$00
|
||||
sta match_buffer2+2
|
||||
ldy #$00
|
||||
|
||||
match_all
|
||||
lda SECTORBUFFER,y
|
||||
cmp #WILDCARD
|
||||
beq found_wild
|
||||
|
||||
match_buffer2
|
||||
cmp $d1d1,y ; modified at runtime
|
||||
|
||||
branch_cont
|
||||
bne cont_search
|
||||
|
||||
found_wild
|
||||
iny
|
||||
|
||||
match_size2
|
||||
cpy #$d1 ; modified at runtime
|
||||
bne match_all
|
||||
|
||||
; point to start of match
|
||||
|
||||
ldx match_buffer2+1
|
||||
ldy match_buffer2+2
|
||||
jsr PrintAddr
|
||||
tya
|
||||
bne branch_cont
|
||||
|
||||
; cold path
|
||||
|
||||
check_end
|
||||
inc search+2
|
||||
ldx search+2
|
||||
.endvalue
|
||||
cpx #$D1
|
||||
bne check_byte1
|
||||
ldx #<all_done_set-branch_cont-2
|
||||
stx branch_cont+1
|
||||
|
||||
check_byte2
|
||||
cmp #$d1 ; modified at runtime
|
||||
beq check_match
|
||||
|
||||
all_done_set
|
||||
;fall through
|
||||
|
||||
Char2Nib
|
||||
lda $0200, x
|
||||
inx
|
||||
sec
|
||||
sbc #$B0
|
||||
cmp #$0A
|
||||
bcc +
|
||||
sbc #7
|
||||
+ rts
|
||||
|
||||
ScrollEditBufferIn
|
||||
ldy #(<(ScrollParmsDown - ScrollParms) - 1)
|
||||
jsr SetScrollLine
|
||||
@ -567,7 +743,7 @@ HexToDec ;called with X=hex value to print
|
||||
+ jsr AToScr
|
||||
txa
|
||||
|
||||
AToScr ;called with A=dec value to print
|
||||
AToScr ;called with A=dec value to print
|
||||
ora #"0"
|
||||
sta (OPSRC2L), y
|
||||
dey
|
||||
@ -776,7 +952,7 @@ EditorMode
|
||||
;we require this trigger to allow us to work around a bug in Diversi-DOS
|
||||
|
||||
ClearOnFirstKeypress
|
||||
ldy #0 ;self-modified
|
||||
ldy #1 ;self-modified
|
||||
beq +
|
||||
dec ClearOnFirstKeypress + 1
|
||||
php ;save carry (don't care about the rest)
|
||||
@ -894,9 +1070,9 @@ ClearScreen ; does not clear status line
|
||||
;copy from virtual buffer to real screen
|
||||
;;todo: add camera flash and click effect ;-)
|
||||
HandleKeyImportScreen ;called with carry set
|
||||
lda #<(LoadSaveEnd - WIDTH)
|
||||
lda #<LoadSaveEnd
|
||||
sta OPSRC1L
|
||||
lda #>(LoadSaveEnd - WIDTH)
|
||||
lda #>LoadSaveEnd
|
||||
sta OPSRC1H
|
||||
|
||||
ldx #(HEIGHT - 2)
|
||||
@ -927,7 +1103,7 @@ PageReturn
|
||||
|
||||
HandleKeyAddPage
|
||||
PreventAddPage
|
||||
lda #0 ;self-modified
|
||||
lda #1 ;self-modified
|
||||
beq + ;page 1 exists already, go directly to add
|
||||
bpl PageReturn ;page 1 doesn't exist and nothing to write
|
||||
|
||||
@ -961,6 +1137,7 @@ PreventAddPage
|
||||
lda MyCV + 1
|
||||
pha
|
||||
lda #0
|
||||
sta PreventAddPage + 1
|
||||
sta MyCH + 1
|
||||
sta MyCV + 1
|
||||
jsr SeekReadWrite
|
||||
@ -1007,17 +1184,7 @@ HandleKeyPrevPage
|
||||
++ php ;save carry (don't care about the rest)
|
||||
jsr ExchangeVirtualBuffer
|
||||
|
||||
;update header to specify new page count and current page
|
||||
|
||||
+++ jsr LoadSaveHeader
|
||||
|
||||
;Diversi-DOS has a critical bug when reading from a just-written sector
|
||||
;IT RETURNS THE ORIGINAL DATA UNLESS YOU CLOSE THE FILE AND RE-OPEN IT
|
||||
;so that's what we do
|
||||
|
||||
jsr CloseFile
|
||||
jsr OpenDataFile
|
||||
|
||||
+++ jsr OpenDataFile
|
||||
dec ReadWriteCmd ;lda #CMDREAD / sta ReadWriteCmd
|
||||
lda ReadBuffer
|
||||
pha
|
||||
@ -1027,7 +1194,7 @@ HandleKeyPrevPage
|
||||
pha
|
||||
adc #0
|
||||
sta ReadBuffer + 1
|
||||
ldx SaveCV
|
||||
ldx CurPage + 1
|
||||
jsr SeekReadWrite
|
||||
pla
|
||||
sta ReadBuffer + 1
|
||||
@ -1189,13 +1356,9 @@ ScrollEditPatch2
|
||||
inc OPDST1H
|
||||
+ dex
|
||||
bpl -
|
||||
|
||||
;animation delay
|
||||
|
||||
jsr Delay ;returns A=0
|
||||
plp ;restore carry
|
||||
bcc + ;the ScrollRight path
|
||||
tay
|
||||
ldy #0
|
||||
inc SCROLLLINE
|
||||
bne --
|
||||
rts
|
||||
@ -1241,6 +1404,36 @@ CopyColumnPatch2
|
||||
WriteIfDirty1
|
||||
jsr SetPrevPage
|
||||
|
||||
;update header if number of pages changed, or if current page changed
|
||||
|
||||
OrgPages
|
||||
cmp #0 ;self-modified
|
||||
bne UpdateHeader
|
||||
lda CurPage + 1
|
||||
OrgPage
|
||||
cmp #0 ;self-modified
|
||||
bne UpdateHeader
|
||||
|
||||
;or if the page is dirty and we've never written the header before
|
||||
|
||||
lda WriteIfDirty2 + 1
|
||||
beq OpenReturn
|
||||
|
||||
HeaderExists
|
||||
lda #0 ;self-modified
|
||||
bne WriteIfDirty2
|
||||
|
||||
;update header to specify new page count and current page
|
||||
|
||||
UpdateHeader
|
||||
jsr LoadSaveHeader
|
||||
|
||||
;Diversi-DOS has a critical bug when reading from a just-written sector
|
||||
;IT RETURNS THE ORIGINAL DATA UNLESS YOU CLOSE THE FILE AND RE-OPEN IT
|
||||
;so that's what we do
|
||||
|
||||
jsr CloseFile
|
||||
|
||||
WriteIfDirty2
|
||||
lda #"Q" ;self-modified
|
||||
beq OpenReturn
|
||||
@ -1508,7 +1701,7 @@ SecondLine
|
||||
!fill WIDTH * 7, SPACE
|
||||
!text " 4LIVE by 4am && qkumba "
|
||||
!fill WIDTH, SPACE
|
||||
!text " Revision 03 / Serial number 170112 "
|
||||
!text " Revision 06 / Serial number 190318 "
|
||||
!fill WIDTH * 2, SPACE
|
||||
!text " https://github.com/a2-4am/4live "
|
||||
!fill WIDTH * 9, SPACE
|
||||
|
Loading…
Reference in New Issue
Block a user