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

View File

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

View File

@ -2,7 +2,14 @@ NEW
AUTO 3,1 AUTO 3,1
.LIST OFF .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 dec
>PUSHA >PUSHA
>PUSHBI 1 >PUSHBI 1
@ -234,10 +241,8 @@ SCRN.UpdateStatusBar
inc inc
>PUSHA >PUSHA
ldy #FileLen+1 >PUSHW BufLen
>PUSHB (pData),y
dey
>PUSHB (pData),y
>PUSHBI 5 >PUSHBI 5
>LDYA L.MSG.STATUSBAR >LDYA L.MSG.STATUSBAR
>SYSCALL printf >SYSCALL printf

View File

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

View File

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

View File

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