mirror of
https://github.com/a2-4am/4live.git
synced 2024-09-28 08:54:35 +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
|
### 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
|
## For users
|
||||||
|
|
||||||
|
BIN
bin/V2Make.scpt
BIN
bin/V2Make.scpt
Binary file not shown.
265
src/4live.a
265
src/4live.a
@ -1,6 +1,6 @@
|
|||||||
;
|
;
|
||||||
; 4LIVE
|
; 4LIVE
|
||||||
; Copyright (c) 2016-7 by 4am && qkumba
|
; Copyright (c) 2016-8 by 4am && qkumba
|
||||||
; 100% open source, see LICENSE file
|
; 100% open source, see LICENSE file
|
||||||
;
|
;
|
||||||
!cpu 6502
|
!cpu 6502
|
||||||
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
;user-defined
|
;user-defined
|
||||||
HOTKEY = $80 ; CTRL-@
|
HOTKEY = $80 ; CTRL-@
|
||||||
|
FINDKEY = $86 ; CTRL-F
|
||||||
HIGHLIGHTKEY = $82 ; CTRL-B
|
HIGHLIGHTKEY = $82 ; CTRL-B
|
||||||
CLEARKEY = $83 ; CTRL-C
|
CLEARKEY = $83 ; CTRL-C
|
||||||
PREVPAGEKEY = $92 ; CTRL-R
|
PREVPAGEKEY = $92 ; CTRL-R
|
||||||
@ -17,6 +18,7 @@
|
|||||||
|
|
||||||
VERBOSE = $0 ; set to 1 to show memory usage during build
|
VERBOSE = $0 ; set to 1 to show memory usage during build
|
||||||
;
|
;
|
||||||
|
!addr PROMPT = $33
|
||||||
!addr KSWL = $38
|
!addr KSWL = $38
|
||||||
!addr KSWH = $39
|
!addr KSWH = $39
|
||||||
!addr FCBFOP = $40
|
!addr FCBFOP = $40
|
||||||
@ -30,9 +32,12 @@
|
|||||||
!addr LCBANK2 = $C083
|
!addr LCBANK2 = $C083
|
||||||
!addr ROMIN1 = $C089
|
!addr ROMIN1 = $C089
|
||||||
!addr LCBANK1 = $C08B
|
!addr LCBANK1 = $C08B
|
||||||
|
!addr SCRN2P2 = $F87B ;SCRN2 +2
|
||||||
|
!addr PRNTYX = $F940
|
||||||
!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
|
||||||
|
!addr CROUT = $FD8E
|
||||||
!addr COUT = $FDED
|
!addr COUT = $FDED
|
||||||
|
|
||||||
;private arbitrary addresses, shared with DOS to avoid conflict
|
;private arbitrary addresses, shared with DOS to avoid conflict
|
||||||
@ -58,6 +63,8 @@
|
|||||||
SPACE = $A0
|
SPACE = $A0
|
||||||
DELETE = $FF
|
DELETE = $FF
|
||||||
|
|
||||||
|
WILDCARD = $97
|
||||||
|
|
||||||
IOBSLOT = 1
|
IOBSLOT = 1
|
||||||
IOBDRIVE = 2
|
IOBDRIVE = 2
|
||||||
NAMELEN = 30
|
NAMELEN = 30
|
||||||
@ -72,9 +79,8 @@
|
|||||||
POSRDWRRANGE = 4
|
POSRDWRRANGE = 4
|
||||||
WIDTH = 40
|
WIDTH = 40
|
||||||
HEIGHT = 24
|
HEIGHT = 24
|
||||||
LDRBASE = $2E9
|
LDRBASE = $2DB
|
||||||
INSTALLBUFFER = $23B ; yes, the overlay overwrites the loader...
|
INSTALLBUFFER = $20E ; yes, the overlay overwrites the loader...
|
||||||
; see also "warning!" below
|
|
||||||
SWAPBUFFER = $900 ; (LoadSaveEnd - LoadSaveStart) size
|
SWAPBUFFER = $900 ; (LoadSaveEnd - LoadSaveStart) size
|
||||||
; needed by Diversi-DOS, must be page-aligned
|
; needed by Diversi-DOS, must be page-aligned
|
||||||
; region is preserved across calls
|
; region is preserved across calls
|
||||||
@ -108,12 +114,8 @@ LdrStart
|
|||||||
sta FileDrive
|
sta FileDrive
|
||||||
dey ;ldy #IOBSLOT
|
dey ;ldy #IOBSLOT
|
||||||
lda (OPSRC1L), y
|
lda (OPSRC1L), y
|
||||||
lsr
|
jsr SCRN2P2
|
||||||
lsr
|
|
||||||
lsr
|
|
||||||
lsr
|
|
||||||
sta FileSlot
|
sta FileSlot
|
||||||
dey ;ldy #00
|
|
||||||
|
|
||||||
;open self and read first overlay
|
;open self and read first overlay
|
||||||
|
|
||||||
@ -231,6 +233,18 @@ BankInRAM1
|
|||||||
bit LCBANK1
|
bit LCBANK1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
PrintAddr
|
||||||
|
bit ROMIN1
|
||||||
|
jsr PRNTYX
|
||||||
|
|
||||||
|
PrintCR
|
||||||
|
lda #RETURN
|
||||||
|
|
||||||
|
PrintChar
|
||||||
|
bit ROMIN1
|
||||||
|
jsr COUT
|
||||||
|
bne BankInRAM1
|
||||||
|
|
||||||
;read file content into memory
|
;read file content into memory
|
||||||
;with swapping of the memory contents in Diversi-DOS,
|
;with swapping of the memory contents in Diversi-DOS,
|
||||||
;in order to preserve the original memory region
|
;in order to preserve the original memory region
|
||||||
@ -347,18 +361,27 @@ InstallStart
|
|||||||
+
|
+
|
||||||
;open source file and read header if available
|
;open source file and read header if available
|
||||||
|
|
||||||
|
lda SWAPBUFFER
|
||||||
|
pha
|
||||||
|
lda SWAPBUFFER+1
|
||||||
|
pha
|
||||||
jsr LoadSaveHeader
|
jsr LoadSaveHeader
|
||||||
bcs +
|
bcs +
|
||||||
lda SaveCH
|
lda SaveCH
|
||||||
sta Pages + 1
|
sta Pages + 1
|
||||||
|
sta OrgPages + 1
|
||||||
ldx SaveCV
|
ldx SaveCV
|
||||||
stx CurPage + 1
|
stx CurPage + 1
|
||||||
|
stx OrgPage + 1
|
||||||
jsr SeekReadWrite
|
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)
|
pla
|
||||||
|
sta SWAPBUFFER+1
|
||||||
rol ClearOnFirstKeypress + 1
|
pla
|
||||||
rol PreventAddPage + 1 ;tri-state flag because Diversi-DOS
|
sta SWAPBUFFER
|
||||||
|
|
||||||
jsr SetTextCoords1
|
jsr SetTextCoords1
|
||||||
|
|
||||||
@ -443,11 +466,19 @@ GetKey
|
|||||||
|
|
||||||
cmp #HOTKEY
|
cmp #HOTKEY
|
||||||
|
|
||||||
|
;yes -> let's do that
|
||||||
|
|
||||||
|
beq +
|
||||||
|
|
||||||
|
;memory search?
|
||||||
|
|
||||||
|
cmp #FINDKEY
|
||||||
|
|
||||||
;no -> return to DOS
|
;no -> return to DOS
|
||||||
|
|
||||||
bne ReuseRts
|
bne ReuseRts
|
||||||
|
|
||||||
jsr BankInRAM1
|
+ jsr BankInRAM1
|
||||||
jsr RunFromBankedRAM
|
jsr RunFromBankedRAM
|
||||||
lda ROMIN1
|
lda ROMIN1
|
||||||
|
|
||||||
@ -474,6 +505,9 @@ InstallEnd
|
|||||||
BankedCopyStart
|
BankedCopyStart
|
||||||
!pseudopc $D000 {
|
!pseudopc $D000 {
|
||||||
RunFromBankedRAM
|
RunFromBankedRAM
|
||||||
|
cmp #FINDKEY
|
||||||
|
beq FindChars
|
||||||
|
|
||||||
;preserve X across calls
|
;preserve X across calls
|
||||||
;it's important for DOS
|
;it's important for DOS
|
||||||
|
|
||||||
@ -506,6 +540,148 @@ RunFromBankedRAM
|
|||||||
tax
|
tax
|
||||||
rts
|
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
|
ScrollEditBufferIn
|
||||||
ldy #(<(ScrollParmsDown - ScrollParms) - 1)
|
ldy #(<(ScrollParmsDown - ScrollParms) - 1)
|
||||||
jsr SetScrollLine
|
jsr SetScrollLine
|
||||||
@ -776,7 +952,7 @@ EditorMode
|
|||||||
;we require this trigger to allow us to work around a bug in Diversi-DOS
|
;we require this trigger to allow us to work around a bug in Diversi-DOS
|
||||||
|
|
||||||
ClearOnFirstKeypress
|
ClearOnFirstKeypress
|
||||||
ldy #0 ;self-modified
|
ldy #1 ;self-modified
|
||||||
beq +
|
beq +
|
||||||
dec ClearOnFirstKeypress + 1
|
dec ClearOnFirstKeypress + 1
|
||||||
php ;save carry (don't care about the rest)
|
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
|
;copy from virtual buffer to real screen
|
||||||
;;todo: add camera flash and click effect ;-)
|
;;todo: add camera flash and click effect ;-)
|
||||||
HandleKeyImportScreen ;called with carry set
|
HandleKeyImportScreen ;called with carry set
|
||||||
lda #<(LoadSaveEnd - WIDTH)
|
lda #<LoadSaveEnd
|
||||||
sta OPSRC1L
|
sta OPSRC1L
|
||||||
lda #>(LoadSaveEnd - WIDTH)
|
lda #>LoadSaveEnd
|
||||||
sta OPSRC1H
|
sta OPSRC1H
|
||||||
|
|
||||||
ldx #(HEIGHT - 2)
|
ldx #(HEIGHT - 2)
|
||||||
@ -927,7 +1103,7 @@ PageReturn
|
|||||||
|
|
||||||
HandleKeyAddPage
|
HandleKeyAddPage
|
||||||
PreventAddPage
|
PreventAddPage
|
||||||
lda #0 ;self-modified
|
lda #1 ;self-modified
|
||||||
beq + ;page 1 exists already, go directly to add
|
beq + ;page 1 exists already, go directly to add
|
||||||
bpl PageReturn ;page 1 doesn't exist and nothing to write
|
bpl PageReturn ;page 1 doesn't exist and nothing to write
|
||||||
|
|
||||||
@ -961,6 +1137,7 @@ PreventAddPage
|
|||||||
lda MyCV + 1
|
lda MyCV + 1
|
||||||
pha
|
pha
|
||||||
lda #0
|
lda #0
|
||||||
|
sta PreventAddPage + 1
|
||||||
sta MyCH + 1
|
sta MyCH + 1
|
||||||
sta MyCV + 1
|
sta MyCV + 1
|
||||||
jsr SeekReadWrite
|
jsr SeekReadWrite
|
||||||
@ -1007,17 +1184,7 @@ HandleKeyPrevPage
|
|||||||
++ php ;save carry (don't care about the rest)
|
++ php ;save carry (don't care about the rest)
|
||||||
jsr ExchangeVirtualBuffer
|
jsr ExchangeVirtualBuffer
|
||||||
|
|
||||||
;update header to specify new page count and current page
|
+++ jsr OpenDataFile
|
||||||
|
|
||||||
+++ 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
|
|
||||||
|
|
||||||
dec ReadWriteCmd ;lda #CMDREAD / sta ReadWriteCmd
|
dec ReadWriteCmd ;lda #CMDREAD / sta ReadWriteCmd
|
||||||
lda ReadBuffer
|
lda ReadBuffer
|
||||||
pha
|
pha
|
||||||
@ -1027,7 +1194,7 @@ HandleKeyPrevPage
|
|||||||
pha
|
pha
|
||||||
adc #0
|
adc #0
|
||||||
sta ReadBuffer + 1
|
sta ReadBuffer + 1
|
||||||
ldx SaveCV
|
ldx CurPage + 1
|
||||||
jsr SeekReadWrite
|
jsr SeekReadWrite
|
||||||
pla
|
pla
|
||||||
sta ReadBuffer + 1
|
sta ReadBuffer + 1
|
||||||
@ -1189,13 +1356,9 @@ ScrollEditPatch2
|
|||||||
inc OPDST1H
|
inc OPDST1H
|
||||||
+ dex
|
+ dex
|
||||||
bpl -
|
bpl -
|
||||||
|
|
||||||
;animation delay
|
|
||||||
|
|
||||||
jsr Delay ;returns A=0
|
|
||||||
plp ;restore carry
|
plp ;restore carry
|
||||||
bcc + ;the ScrollRight path
|
bcc + ;the ScrollRight path
|
||||||
tay
|
ldy #0
|
||||||
inc SCROLLLINE
|
inc SCROLLLINE
|
||||||
bne --
|
bne --
|
||||||
rts
|
rts
|
||||||
@ -1241,6 +1404,36 @@ CopyColumnPatch2
|
|||||||
WriteIfDirty1
|
WriteIfDirty1
|
||||||
jsr SetPrevPage
|
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
|
WriteIfDirty2
|
||||||
lda #"Q" ;self-modified
|
lda #"Q" ;self-modified
|
||||||
beq OpenReturn
|
beq OpenReturn
|
||||||
@ -1508,7 +1701,7 @@ SecondLine
|
|||||||
!fill WIDTH * 7, SPACE
|
!fill WIDTH * 7, SPACE
|
||||||
!text " 4LIVE by 4am && qkumba "
|
!text " 4LIVE by 4am && qkumba "
|
||||||
!fill WIDTH, SPACE
|
!fill WIDTH, SPACE
|
||||||
!text " Revision 03 / Serial number 170112 "
|
!text " Revision 06 / Serial number 190318 "
|
||||||
!fill WIDTH * 2, SPACE
|
!fill WIDTH * 2, SPACE
|
||||||
!text " https://github.com/a2-4am/4live "
|
!text " https://github.com/a2-4am/4live "
|
||||||
!fill WIDTH * 9, SPACE
|
!fill WIDTH * 9, SPACE
|
||||||
|
Loading…
Reference in New Issue
Block a user