From 973b5e78d6c9d323fabd801237a31b8b0b19dc74 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Sat, 29 Aug 2026 23:20:17 +0200 Subject: [PATCH] 6502: fixed apple2 reverse video bug and early space flush when leaving span --- src/6502/a2_frontend.s | 11 ++++++++--- src/6502/engine.s | 5 +++++ test/codepoints/codepoints.6502.gold | 1 + test/codepoints/codepoints.aastory | Bin 8506 -> 8622 bytes test/codepoints/codepoints.dg | 7 +++++++ test/codepoints/codepoints.js.gold | 1 + 6 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/6502/a2_frontend.s b/src/6502/a2_frontend.s index 178216f..86deca4 100644 --- a/src/6502/a2_frontend.s +++ b/src/6502/a2_frontend.s @@ -231,6 +231,7 @@ AUXUNDOBANK2 = $d0 ; logical page from ; ---- frontend zero page ---- +curstyle = $04 ; last style bits set by io_mstyle nunread = $05 ; lines scrolled off since last clear ioparam = $06 ; word, used by the engine wrappos = $08 @@ -882,8 +883,11 @@ moretxt .asc "<...>",0 io_mstyle - ; style bits are already in rstyle zp var in engine - jmp io_mflush_nostyle + pha + jsr io_mflush + pla + sta curstyle + rts ; TODO consider refactoring with sprogress? io_mprogress @@ -1358,7 +1362,7 @@ gotoxy mstyle_enter .( - lda `rstyle + lda curstyle lsr ; reverse style bit bcc set_inverse_rts ; fallthrough to set_inverse @@ -3065,6 +3069,7 @@ auxclrlp sta stxoffs sta cury sta strow + sta curstyle #if UNDO sta u_ready sta u_count diff --git a/src/6502/engine.s b/src/6502/engine.s index 7ae9b4a..d24d3bd 100644 --- a/src/6502/engine.s +++ b/src/6502/engine.s @@ -3778,6 +3778,11 @@ op_en_lv_span stx divsp inc nspan + ; ENTER_SPAN emits a pending AUTO/PENDING + ; space before entering the span, + ; so the space has the outer style. + ; op_style does the same thing. + jsr syncspace done jsr unstyle skip diff --git a/test/codepoints/codepoints.6502.gold b/test/codepoints/codepoints.6502.gold index 2e75f34..fbbcf33 100644 --- a/test/codepoints/codepoints.6502.gold +++ b/test/codepoints/codepoints.6502.gold @@ -276,6 +276,7 @@ and must leave the other alone. bold normal bold italic upright italic both italic only both +reverse normal reverse --- The deprecated SET_STYLE/RESET_STYLE opcodes, which bypass the CSS parser diff --git a/test/codepoints/codepoints.aastory b/test/codepoints/codepoints.aastory index 8fc7d4c6f61ddf9bd1d33b335bb4c653046fa423..808cac93bfb29dbf0bbdcc05734e96ea42ed5d29 100644 GIT binary patch delta 917 zcmZurZERCz6h3cnzizj#?PP1$c5o*I*r2d1qv6BVx4o@_&AEhZ;6fm8xxL-G;oU4{ zdNF3@BijPVy1Ygi1V4(X2}DS0Oh<$;6?07hQ8bYljfTiZ7VZ=b$%xCmB{RmvALl&J zInQ&RoC~3k_$AM@Y;FdqdOsN4(!4Pe3Xb{^@!0&eTjG~?n{b&Vsf|W>r2GMp7q@P2)k4AF3~4NUl9M@!T(-JJ(Bnz`yOdN zBZ>d0*($~#<(AU($^5`&qj;%p!sLXmB zTv@Q%UjugV<+O}ZSdpn$1C16*;@l7jn9F#5iSp9Mr8RmU$|4BjT8{72wED4N0TM+?rUf;o`!&dSE5# z5&pR}la-IDK!zR)WN@EQh}Av`s3fEbUV6TWuUsgmZ>3A@N5Ry8kI`IPwVD&i!ByHH zYpK0BfvV}=Vjl|94~vtCrHiZ^=oYI7oy{e!l?Z)DGbLAxHr$D`Wc8i6g)E>Qwv+v^ zb@QfH0Ee&kw@7UIlSszD>u0Q*9&qC`Pb#N}{yf3K^rvZ1%WrdsqVIK$!tF@~vZFDW zxQ^lD$r#+X;IVf8ZLW2(GMs@U%U%s&7!PiAa`2WA*~US8dfzG|B zvL`!Jt%{SgS2RKU+{6#oSB{SylbT8nkLK=|@dn!Bal2=B4yD>cmtHdea%whb@%KJ| z?@G;8?wcPEDm39~@y-O_jh*{^{1TR~@4x#&gN^-6>r)Y9YJ6Xk<~?5eho^$F-Y|V} Uq1P}y^J_mxo4r-JVec9J-#)KMCIA2c delta 820 zcmXwzdq`7Z7{=dkXPet}Zd!UOw>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