Save mode working (but not create new file yet)

This commit is contained in:
Rémy GIBERT 2016-01-06 23:07:28 +01:00
parent ab46cb81e6
commit 73aee6eb49
3 changed files with 79 additions and 24 deletions

View File

@ -538,9 +538,22 @@ Prompt.Save cmp #3
lda (pData) lda (pData)
beq .8 beq .8
ldy #hFileName
lda (pData),y
beq .11
>SYSCALL SYS.FreeMemA
.11 >LDYA pData
>SYSCALL SYS.NewPStrYA
ldy #hFileName
sta (pData),y
ldy #PromptMode ldy #PromptMode
lda #0 lda #0
sta (pData),y sta (pData),y
jsr SaveFile
bcc .81
jsr UpdateStatusBarErrA
bra .80 bra .80
.2 cmp #127 .2 cmp #127
@ -553,8 +566,7 @@ Prompt.Save cmp #3
sta (pData) sta (pData)
bra .80 bra .80
.3 >DEBUG .3 cmp #$20
cmp #$20
bcc .8 bcc .8
pha pha
lda (pData) lda (pData)
@ -571,6 +583,7 @@ Prompt.Save cmp #3
.8 clc .8 clc
rts rts
.81 jsr UpdateTopBar
.80 jsr UpdateStatusBar .80 jsr UpdateStatusBar
bcs .9 bcs .9
rts rts

View File

@ -235,14 +235,23 @@ UpdateStatusBar ldy #PromptMode
>PUSHA >PUSHA
>LDYA L.MSG.STATUSBAR >LDYA L.MSG.STATUSBAR
>SYSCALL SYS.PSTRoutYA >SYSCALL SYS.PSTRoutYA
rts bcs .9
jmp GotoCurXCurY
.2 >PUSHW pData .2 cmp #PromptModeHelp
ldy #ScreenH beq .3
>PUSHW pData
.3 ldy #ScreenH
lda (pData),y lda (pData),y
>PUSHA >PUSHA
>LDYA L.MSG.STATUSBAR,x >LDYA L.MSG.STATUSBAR,x
>SYSCALL SYS.PSTRoutYA >SYSCALL SYS.PSTRoutYA
.9 rts
*--------------------------------------
UpdateStatusBarErrA
>PUSHA
>LDYA L.MSG.STATUSBAR.E
>SYSCALL SYS.PSTRoutYA
rts rts
*-------------------------------------- *--------------------------------------
GotoCurXCurY ldy #CurX GotoCurXCurY ldy #CurX

View File

@ -52,6 +52,7 @@ L.MSG.STATUSBAR.H .DA MSG.STATUSBAR.H
L.MSG.STATUSBAR.F .DA MSG.STATUSBAR.F L.MSG.STATUSBAR.F .DA MSG.STATUSBAR.F
L.MSG.STATUSBAR.R .DA MSG.STATUSBAR.R L.MSG.STATUSBAR.R .DA MSG.STATUSBAR.R
L.MSG.STATUSBAR.S .DA MSG.STATUSBAR.S L.MSG.STATUSBAR.S .DA MSG.STATUSBAR.S
L.MSG.STATUSBAR.E .DA MSG.STATUSBAR.E
L.MSG.NEWFILE .DA MSG.NEWFILE L.MSG.NEWFILE .DA MSG.NEWFILE
L.MSG.GOTOXY .DA MSG.GOTOXY L.MSG.GOTOXY .DA MSG.GOTOXY
L.MSG.HELP .DA MSG.HELP L.MSG.HELP .DA MSG.HELP
@ -130,10 +131,9 @@ CS.INIT stz hFile
sta (pData),y sta (pData),y
>SYSCALL SYS.LoadFileA >SYSCALL SYS.LoadFileA
bcc .21 bcs .3
jmp .99
.21 stx hFile stx hFile
>STYA TmpLen >STYA TmpLen
.3 >LDYA TmpLen .3 >LDYA TmpLen
@ -400,6 +400,38 @@ CS.QUIT ldy #hBuffer
>SYSCALL SYS.CoutA >SYSCALL SYS.CoutA
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
SaveFile ldy #hFileName
lda (pData),y
>SYSCALL SYS.MLIOpenA
bcs .9
sta hFile
stx TmpByte
ldy #FileLen+1
>PUSHB (pData),y
dey
>PUSHB (pData),y
ldy #hBuffer
lda (pData),y
>SYSCALL SYS.GetMemPtrA
>PUSHYA
>PUSHB hFile
>SYSCALL SYS.MLIWrite
bcs .99
jsr .99
clc
rts
.99 lda hFile
>SYSCALL SYS.MLICloseA
lda TmpByte
>SYSCALL SYS.FreeMemA
sec
.9 rts
*--------------------------------------
DecTmpCount lda TmpCount DecTmpCount lda TmpCount
bne .1 bne .1
lda TmpCount+1 lda TmpCount+1
@ -421,35 +453,36 @@ SEQ.INV >PSTRING "\e[7m"
SEQ.NORM >PSTRING "\e[0m" SEQ.NORM >PSTRING "\e[0m"
SEQ.CEOL >PSTRING "\e[K" SEQ.CEOL >PSTRING "\e[K"
MSG.TOPBAR >PSTRING "\e[1;1H\e[7mA2osX Edit:%S\e[K\e[0m" MSG.TOPBAR >PSTRING "\e[1;1H\e[7mA2osX Edit:%S\e[K\e[0m"
MSG.STATUSBAR >PSTRING "\e[%d;1H\e[7mPress Ctrl-A For Help Length:%D Col:%d Line:%D\e[K\e[0m" MSG.STATUSBAR >PSTRING "\e[%d;1H\e[7mPress Ctrl-A For Help Length:%D Col:%d Line:%D\e[K\e[0m"
MSG.STATUSBAR.H >PSTRING "\e[%d;1H\e[7mPress any key to exit this screen%S\e[K\e[0m" MSG.STATUSBAR.H >PSTRING "\e[%d;1H\e[7mPress any key to exit this screen:\e[K\e[0m"
MSG.STATUSBAR.F >PSTRING "\e[%d;1H\e[7mFind:%S\e[K\e[0m" MSG.STATUSBAR.F >PSTRING "\e[%d;1H\e[7mFind:%S\e[K\e[0m"
MSG.STATUSBAR.R >PSTRING "\e[%d;1H\e[7mReplace:%S\e[K\e[0m" MSG.STATUSBAR.R >PSTRING "\e[%d;1H\e[7mReplace:%S\e[K\e[0m"
MSG.STATUSBAR.S >PSTRING "\e[%d;1H\e[7mSave:%S\e[K\e[0m" MSG.STATUSBAR.S >PSTRING "\e[%d;1H\e[7mSave:%S\e[K\e[0m"
MSG.STATUSBAR.E >PSTRING "\e[%d;1H\e[7mError:%h\e[K\e[0m"
MSG.NEWFILE >PSTRING "(new file)" MSG.NEWFILE >PSTRING "(new file)"
MSG.GOTOXY >PSTRING "\e[%d;%dH" MSG.GOTOXY >PSTRING "\e[%d;%dH"
MSG.HELP >PSTRING "Commands:" MSG.HELP >PSTRING "All commands:"
>PSTRING "---------" >PSTRING "(* = Not yet implemented)"
>PSTRING " Ctrl-A : This help screen" >PSTRING " Ctrl-A : This help screen"
>PSTRING " Ctrl-B : Mark begining of block" >PSTRING " Ctrl-B : Mark begining of block"
>PSTRING " Ctrl-C : Copy block to clipboard" >PSTRING " Ctrl-C : * Copy block to clipboard"
>PSTRING " Ctrl-D : Delete marked block" >PSTRING " Ctrl-D : * Delete marked block"
>PSTRING " Ctrl-E : Mark end of block" >PSTRING " Ctrl-E : Mark end of block"
>PSTRING " Ctrl-F : Find a string..." >PSTRING " Ctrl-F : * Find a string..."
>PSTRING " Ctrl-G : Go to start of current line" >PSTRING " Ctrl-G : Go to start of current line"
>PSTRING " Ctrl-L : Go to end of current line" >PSTRING " Ctrl-L : Go to end of current line"
>PSTRING " Ctrl-N : Find next" >PSTRING " Ctrl-N : * Find next"
>PSTRING " Ctrl-O : Page up" >PSTRING " Ctrl-O : * Page up"
>PSTRING " Ctrl-P : Page down" >PSTRING " Ctrl-P : * Page down"
>PSTRING " Ctrl-Q : Quit" >PSTRING " Ctrl-Q : Quit"
>PSTRING " Ctrl-R : Replace found string with..." >PSTRING " Ctrl-R : * Replace found string with..."
>PSTRING " Ctrl-S : Save file to disk" >PSTRING " Ctrl-S : Save file to disk..."
>PSTRING " Ctrl-T : Go to top of file" >PSTRING " Ctrl-T : * Go to top of file"
>PSTRING " Ctrl-V : Past clipboard" >PSTRING " Ctrl-V : * Past clipboard"
>PSTRING " Ctrl-W : " >PSTRING " Ctrl-W : "
>PSTRING " Ctrl-X : Cut block to clipboard" >PSTRING " Ctrl-X : * Cut block to clipboard"
>PSTRING " Ctrl-Y : " >PSTRING " Ctrl-Y : "
>PSTRING " Ctrl-Z : Undo previous change" >PSTRING " Ctrl-Z : * Undo previous change"
.HS 00 .HS 00
EscChars >PSTRING "DBAC" EscChars >PSTRING "DBAC"
EscAscii .HS 04080A0B15 EscAscii .HS 04080A0B15