From d93528716b342f82153802a139adbcf970abc7c1 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Fri, 20 Jan 2017 13:38:30 -0800 Subject: [PATCH 1/2] fix the header corruption on single-page autosave --- src/4live.a | 61 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/src/4live.a b/src/4live.a index d292080..95b97fd 100644 --- a/src/4live.a +++ b/src/4live.a @@ -73,7 +73,7 @@ WIDTH = 40 HEIGHT = 24 LDRBASE = $2E9 - INSTALLBUFFER = $23B ; yes, the overlay overwrites the loader... + INSTALLBUFFER = $232 ; yes, the overlay overwrites the loader... ; see also "warning!" below SWAPBUFFER = $900 ; (LoadSaveEnd - LoadSaveStart) size ; needed by Diversi-DOS, must be page-aligned @@ -351,14 +351,15 @@ InstallStart 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 jsr SetTextCoords1 @@ -776,7 +777,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) @@ -927,7 +928,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 @@ -1007,17 +1008,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 +1018,7 @@ HandleKeyPrevPage pha adc #0 sta ReadBuffer + 1 - ldx SaveCV + ldx CurPage + 1 jsr SeekReadWrite pla sta ReadBuffer + 1 @@ -1241,6 +1232,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 +1529,7 @@ SecondLine !fill WIDTH * 7, SPACE !text " 4LIVE by 4am && qkumba " !fill WIDTH, SPACE - !text " Revision 03 / Serial number 170112 " + !text " Revision 03 / Serial number 170120 " !fill WIDTH * 2, SPACE !text " https://github.com/a2-4am/4live " !fill WIDTH * 9, SPACE From f7f330b6e3a1741eda0ca4c87dd6a37b355e5acb Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Sun, 22 Jan 2017 21:32:23 -0800 Subject: [PATCH 2/2] fix import and page 3 state, faster l/r scroll --- src/4live.a | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/4live.a b/src/4live.a index 95b97fd..f5c2a0c 100644 --- a/src/4live.a +++ b/src/4live.a @@ -895,9 +895,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 - WIDTH) + lda #>LoadSaveEnd sta OPSRC1H ldx #(HEIGHT - 2) @@ -962,6 +962,7 @@ PreventAddPage lda MyCV + 1 pha lda #0 + sta PreventAddPage + 1 sta MyCH + 1 sta MyCV + 1 jsr SeekReadWrite @@ -1180,13 +1181,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 @@ -1529,7 +1526,7 @@ SecondLine !fill WIDTH * 7, SPACE !text " 4LIVE by 4am && qkumba " !fill WIDTH, SPACE - !text " Revision 03 / Serial number 170120 " + !text " Revision 03 / Serial number 170122 " !fill WIDTH * 2, SPACE !text " https://github.com/a2-4am/4live " !fill WIDTH * 9, SPACE