Kernel 0.93

This commit is contained in:
Rémy GIBERT 2019-05-27 17:37:31 +02:00
parent f440c4e05b
commit f6a4d5123d
7 changed files with 271 additions and 236 deletions

Binary file not shown.

View File

@ -12,41 +12,36 @@ BUF.InsertClipboard
jsr BUF.ComputeCOffset
ldy #FileLen
lda (pData),y
lda BufLen
sec
ldy #ClipboardLen
adc (pData),y
pha
ldy #FileLen+1
lda (pData),y
ldy #ClipboardLen+1
lda BufLen+1
iny
adc (pData),y
ply
jsr BUF.GetNewYA
bcs .9
>LDYA BUF.COffset
>STYA TmpCount
jsr BUF.CopyCount
jsr BUF.CopyClipboard
jsr BUF.CopyTail
.4 ldy #ClipboardLen+1
lda (pData),y
tax
dey
.4 ldy #ClipboardLen
lda (pData),y
clc
ldy #FileLen
adc (pData),y
adc BufLen
sta (pData),y
iny
txa
adc (pData),y
lda (pData),y
adc BufLen+1
sta (pData),y
.8 clc
@ -59,21 +54,17 @@ BUF.InsertA sta TmpByte
clc
rts
.10 ldy #FileLen
lda (pData),y
sec
adc #1
.10 lda BufLen
clc
adc #2
pha
iny
lda (pData),y
lda BufLen+1
adc #0
ply
jsr BUF.GetNewYA
bcs .9
>LDYA BUF.COffset
>STYA TmpCount
.1 jsr BUF.CopyCount
.2 lda TmpByte
@ -84,7 +75,13 @@ BUF.InsertA sta TmpByte
.3 jsr BUF.CopyTail
.4 >INCW.G FileLen
.4 lda BufLen
clc
adc #1
sta BufLen
bcc .8
inc BufLen+1
.8 clc
.9 rts
@ -95,48 +92,35 @@ BUF.DelSel jsr BUF.GetSelLen
.10 jsr BUF.ComputeCOffset
ldy #SelStart
lda (pData),y
sta TmpCount
sec
sbc BUF.COffset
>LDA.G SelStart
cmp BUF.COffset
iny
lda (pData),y
sta TmpCount+1
sbc BUF.COffset+1
bcs .11
ldy #FileY
lda (pData),y
sec
sbc #1
sta (pData),y
iny
lda (pData),y
sbc #0
sta (pData),y
>DECW.G FileY
ldy #FileX
lda #0
sta (pData),y
>STZ.G FileX
bra .10
.11 ldy #FileLen
lda (pData),y
.11 lda BufLen
sec
sbc SelLen
pha
iny
lda (pData),y
lda BufLen+1
sbc SelLen+1
ply
iny
bne .1
inc
.1 jsr BUF.GetNewYA
bcs .9
>LDYA.G SelStart
jsr BUF.CopyCount
lda BufPtrBackup
@ -150,15 +134,14 @@ BUF.DelSel jsr BUF.GetSelLen
jsr BUF.CopyTail
ldy #FileLen
lda (pData),y
lda BufLen
sec
sbc SelLen
sta (pData),y
ldy #FileLen+1
lda (pData),y
sta BufLen
lda BufLen+1
sbc SelLen+1
sta (pData),y
sta BufLen+1
jsr BUF.ResetSel
@ -167,26 +150,12 @@ BUF.DelSel jsr BUF.GetSelLen
*--------------------------------------
* Erase char at CurXY
*--------------------------------------
BUF.DelChar lda BUF.COffset
sec
sbc #1
tay
lda BUF.COffset+1
sbc #0
bcc .9 deleting char #0
>STYA TmpCount
ldy #FileLen+1
lda (pData),y
pha
dey
lda (pData),y
tay
pla
BUF.DelCharAtCursor
>LDYA BufLen
jsr BUF.GetNewYA BufferLen-1
bcs .9
>LDYA BUF.COffset
jsr BUF.CopyCount
.3 lda (BufPtrBackup)
@ -198,73 +167,79 @@ BUF.DelChar lda BUF.COffset
.4 jsr BUF.CopyTail
ldy #FileLen
lda (pData),y
sec
sbc #1
sta (pData),y
iny
lda (pData),y
sbc #0
sta (pData),y
lda BufLen
bne .5
dec BufLen+1
.5 dec BufLen
jsr BUF.ResetSel
pla Get back deleted char
.8 clc
clc
.9 rts
*--------------------------------------
BUF.SelToClipboard
jsr BUF.GetSelLen
bcs .8
>STYA TmpCount
>STYA SelLen
ldy #hClipBoard
lda (pData),y
>LDA.G hClipBoard
beq .1
>SYSCALL FreeMem
.1 >LDYA TmpCount
.1 >LDYA SelLen
>SYSCALL GetMem
bcs .9
>STYA ClipboardPtr
txa
ldy #hClipBoard
sta (pData),y
ldy #ClipBoardLen
lda TmpCount
sta (pData),y
iny
lda TmpCount+1
sta (pData),y
>STA.G hClipBoard
ldy #hBuffer
lda (pData),y
>SYSCALL GetMemPtr
>STYA BufPtr
lda BufPtr
clc
ldy #SelStart
adc (pData),y
pha
tya
* clc
>ADC.G SelStart
sta BufPtr
lda BufPtr+1
iny
adc (pData),y
pla
>ADC.G SelStart+1
sta BufPtr+1
lda SelLen
ldy #ClipBoardLen+1
sta (pData),y
eor #$ff
tax
iny
lda SelLen
sta (pData),y
eor #$ff
pha
ldy #0
.2 jsr DecTmpCount
.2 inx
bne .3
pla
inc
beq .7
lda (BufPtr),y
pha
.3 lda (BufPtr),y
sta (ClipboardPtr),y
iny
bne .2
inc BufPtr+1
inc ClipboardPtr+1
bra .2
@ -275,59 +250,97 @@ BUF.SelToClipboard
.9 rts
*--------------------------------------
BUF.CopyClipboard
>LDA.G ClipboardLen+1
>LDA.G ClipboardLen
eor #$ff
tax
dey
iny
lda (pData),y
eor #$ff
tax
pha
.1 iny
ldy #0
.1 inx
bne .2
inx
beq .9
.2 lda (ClipboardPtr)
sta (BufPtr)
inc ClipboardPtr
bne .3
pla
inc
beq .3
pha
.2 lda (ClipboardPtr),y
sta (BufPtr),y
iny
bne .1
inc ClipboardPtr+1
inc BufPtr+1
bra .1
.3 tya
clc
adc ClipboardPtr
sta ClipboardPtr
bcc .4
inc ClipboardPtr+1
.3 inc BufPtr
bne .1
.4 tya
clc
adc BufPtr
sta BufPtr
bcc .8
inc BufPtr+1
bra .1
.9 rts
.8 rts
*--------------------------------------
BUF.CopyCount lda TmpCount
eor #$ff
tay
BUF.CopyCount eor #$ff
pha
lda TmpCount+1
tya
eor #$ff
tax
.1 iny
bne .2
inx
beq .9
ldy #0
.2 lda (BufPtrBackup)
sta (BufPtr)
inc BufPtrBackup
bne .3
inc BufPtrBackup+1
.3 inc BufPtr
.1 inx
bne .2
pla
inc
beq .3
pha
.2 lda (BufPtrBackup),y
sta (BufPtr),y
iny
bne .1
inc BufPtrBackup+1
inc BufPtr+1
bra .1
.9 rts
.3 tya
clc
adc BufPtrBackup
sta BufPtrBackup
bcc .4
inc BufPtrBackup+1
.4 tya
clc
adc BufPtr
sta BufPtr
bcc .8
inc BufPtr+1
.8 rts
*--------------------------------------
BUF.CopyTail lda (BufPtrBackup)
sta (BufPtr)
@ -444,7 +457,9 @@ BUF.GetCharAtY tya
clc
rts
*--------------------------------------
BUF.GetNewYA >STYA TmpLen
BUF.GetNewYA phy
pha
>LDA.G hBufferBackup
beq .1
@ -456,7 +471,8 @@ BUF.GetNewYA >STYA TmpLen
>SYSCALL GetMemPtr
>STYA BufPtrBackup
>LDYA TmpLen
pla
ply
>SYSCALL GetMem
bcs .9

View File

@ -9,11 +9,12 @@ NEW
* ^E = End Block
* ^F = Find...
* ^G = Go To SOL
***** ^H
* ^I =
***** J,K
******** ^H = BS
******** ^I = TAB
******** ^J = LF
******** ^K = VT
* ^L = Go To EOL
***** ^M
******** ^M = CR
* ^N = Find Next
* ^O = Page Up
* ^P = Page Down
@ -21,13 +22,49 @@ NEW
* ^R = Replace...
* ^S = Save
* ^T = Go To Top of file
***** ^U
******** ^U = FS
* ^V = Paste Block
* ^W = Erase line
* ^X = Cut Block
* ^Y = End Of File
* ^Z = Undo
*--------------------------------------
Prompt.Editor cmp #C.DEL
beq Ctrl.DEL
cmp #C.SPACE
bcc .3
jsr BUF.InsertA
bcs .9
jsr SCRN.UpdateCurrentLine
bcs .9
jsr Ctrl.FS
bcs .9
.8 clc
rts
.3 asl
tax
jmp (J.CTRL,x)
.9 jmp Ctrl.Q
*--------------------------------------
Ctrl.DEL jsr BUF.ComputeCOffset
lda BUF.COffset
ora BUF.COffset+1 No Backspace possible
beq .8
jsr Ctrl.BS
bcs .9
jmp Ctrl.Z.1
.8 clc
.9 rts
*--------------------------------------
Ctrl.Invalid
clc
rts
@ -514,25 +551,18 @@ Ctrl.Y ldy #FileY+1
rts
.9 jmp Ctrl.Q
*--------------------------------------
Ctrl.Z clc
rts
*--------------------------------------
Ctrl.ESC clc
rts
*--------------------------------------
Prompt.Editor cmp #C.DEL
bne .2
jsr BUF.ComputeCOffset
lda BUF.COffset
ora BUF.COffset+1 No Backspace possible
beq .8
Ctrl.Z jsr BUF.ComputeCOffset
jsr Ctrl.BS
bcs .9
lda BUF.COffset
cmp BufLen
lda BUF.COffset+1
sbc BufLen+1
bcc Ctrl.Z.1
jsr BUF.DelChar
clc
rts
Ctrl.Z.1 jsr BUF.DelCharAtCursor
bcs .9
cmp #C.CR did we DEL a CR ?
@ -540,31 +570,13 @@ Prompt.Editor cmp #C.DEL
jsr SCRN.UpdateMain
bcs .9
jsr SCRN.UpdateStatusBar
rts
jmp SCRN.UpdateStatusBar
.1 jsr SCRN.UpdateCurrentLine
jsr SCRN.UpdateStatusBar
rts
.2 cmp #C.SPACE
bcc .3
jsr BUF.InsertA
bcs .9
jsr SCRN.UpdateCurrentLine
bcs .9
jsr Ctrl.FS
bcs .9
.8 clc
rts
.3 asl
tax
jmp (J.CTRL,x)
jmp SCRN.UpdateStatusBar
.9 jmp Ctrl.Q
.9 rts
*--------------------------------------
Prompt.Help >STZ.G PromptMode

View File

@ -2,7 +2,14 @@ NEW
AUTO 3,1
.LIST OFF
*--------------------------------------
SCRN.Init >LDA.G ScreenH
SCRN.Init >LDYAI 256+5+5+1 potentially NORM,INV & \0
>SYSCALL Getmem
bcs .9
>STYA LineBufPtr
txa
>STA.G hLineBuffer
>LDA.G ScreenH
dec
>PUSHA
>PUSHBI 1
@ -234,10 +241,8 @@ SCRN.UpdateStatusBar
inc
>PUSHA
ldy #FileLen+1
>PUSHB (pData),y
dey
>PUSHB (pData),y
>PUSHW BufLen
>PUSHBI 5
>LDYA L.MSG.STATUSBAR
>SYSCALL printf

View File

@ -22,14 +22,16 @@ BUF.COffset .BS 2
BUF.TmpLine1 .BS 2
BUF.TmpLine2 .BS 2
TmpLen .BS 2
TmpCount .BS 2
TmpIndex .BS 2
BufLen .BS 2
SelLen .BS 2
ZPPTR1 .BS 2
bNotRepaint .BS 1
bSelected .BS 1
ZPPTR1 .BS 2
TmpLen .BS 2
TmpIndex .BS 2
TmpCount .BS 1
TmpByte .BS 1
ZS.END .ED
@ -111,7 +113,7 @@ J.CTRL .DA Ctrl.Invalid
.DA Ctrl.X
.DA Ctrl.Y
.DA Ctrl.Z
.DA Ctrl.ESC
.DA Ctrl.Invalid
.DA Ctrl.Invalid
.DA Ctrl.Invalid
.DA Ctrl.Invalid
@ -153,7 +155,7 @@ CS.RUN >PUSHBI 0
bcs CS.RUN.RTS
txa
>STA.G hBuffer FileLen already set to 0
>STA.G hBuffer BufLen already set to 0
.3 lda #$ff
>STA.G bSaved
@ -164,7 +166,7 @@ CS.RUN >PUSHBI 0
CS.RUN.LOOP >SYSCALL GetChar
bcs CS.RUN.RTS I/O error
.1 jsr CharIn
jsr CharIn
>LDA.G bCancel
bpl CS.RUN.LOOP
@ -352,55 +354,53 @@ LoadFile >PUSHWI 0 Aux type
>SYSCALL LoadTXTFile
bcs .9
>STYA BufPtr
>STYA ZPPTR1
txa
>STA.G hBuffer
>SYSCALL GetMemPtr
>STYA BufPtr
>STYA BufPtrBackup
stz TmpLen
stz TmpLen+1
stz BufLen
stz BufLen+1
ldy #0
ldx #0
.2 lda (BufPtr),y
.1 lda (BufPtrBackup),y
beq .8
cpx #C.CR
bne .3
bne .2
cmp #C.LF
beq .5
.3 cmp #C.SPACE
bcs .31
.2 cmp #C.SPACE
bcs .3
cmp #C.CR
bne .5
.31 sta (ZPPTR1)
inc ZPPTR1
.3 sta (BufPtr)
inc BufPtr
bne .4
inc ZPPTR1+1
inc BufPtr+1
.4 inc TmpLen
.4 inc BufLen
bne .5
inc TmpLen+1
inc BufLen+1
.5 tax set previous char
iny
bne .2
bne .1
inc ZPPTR1+1
bra .2
inc BufPtrBackup+1
bra .1
.8 lda #0
sta (ZPPTR1)
.8 sta (BufPtr)
>LDYA TmpLen
>STYA.G FileLen
clc
.9 rts
*--------------------------------------
@ -415,7 +415,7 @@ SaveFile >PUSHWI 0 Aux type
pha
>PUSHW.G FileLen
>PUSHW BufLen
>LDA.G hBuffer
>SYSCALL GetMemPtr
@ -439,15 +439,6 @@ SaveFile >PUSHWI 0 Aux type
>SYSCALL FClose
.9 rts
*--------------------------------------
DecTmpCount lda TmpCount
bne .1
lda TmpCount+1
beq .9
dec TmpCount+1
.1 dec TmpCount
ora #$ff make sure NZ
.9 rts
*--------------------------------------
.INB USR/SRC/BIN/EDIT.S.BUF
.INB USR/SRC/BIN/EDIT.S.CTRL
@ -492,7 +483,6 @@ MSG.HELP >PSTR "All commands: (* = Not yet implemented)"
>PSTR " Ctrl-W : Erase current line"
>PSTR " Ctrl-X : Cut block to clipboard"
>PSTR " Ctrl-Y : Go to end of file"
>PSTR " Ctrl-Z : * Undo previous change"
.HS 00
*--------------------------------------
MSG.NEWFILE .AZ "(new file)"
@ -515,7 +505,6 @@ hReplace .BS 1
hLineBuffer .BS 1
hBuffer .BS 1
hBufferBackup .BS 1
FileLen .BS 2
hClipBoard .BS 1
ClipBoardLen .BS 2
ScreenW .BS 1

View File

@ -93,7 +93,7 @@ CL.CHARIN.CTRL cpx #C.CR
jmp CL.CLR
.12 cpx #24 Ctrl-X
.12 cpx #26 Ctrl-Z
bne .13
jmp CL.SUPPR

View File

@ -235,9 +235,9 @@ AUTO 4,1
sbc (pData),y
.EM
*--------------------------------------
.MA DEC.G
>LDA.G ]1
dec
.MA STZW.G
>STZ.G ]1
iny
sta (pData),y
.EM
*--------------------------------------
@ -246,12 +246,6 @@ AUTO 4,1
inc
sta (pData),y
.EM
*--------------------------------------
.MA STZW.G
>STZ.G ]1
iny
sta (pData),y
.EM
*--------------------------------------
.MA INCW.G
>INC.G ]1
@ -264,6 +258,25 @@ AUTO 4,1
:1 .EQ *
.EM
*--------------------------------------
.MA DEC.G
>LDA.G ]1
dec
sta (pData),y
.EM
*--------------------------------------
.MA DECW.G
>LDA.G ]1
bne :1
dec
sta (pData),y
iny
lda (pData),y
:1 dec
sta (pData),y
.EM
*--------------------------------------
.MA LDYA.G
>LDA.G ]1