From f3a68ce1b1c0c9048c0b98d73c63a5bdac817046 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sun, 5 Jan 2025 23:59:49 +0000 Subject: [PATCH] Simplify teletext hold handling (#470) Fixes #469 by being simpler too. --- src/teletext.js | 11 ++--------- tests/integration/teletext.js | 13 +++++++++++++ tests/integration/teletext/expected_bug_469.png | Bin 0 -> 1912 bytes tests/test-machine.js | 3 +++ 4 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 tests/integration/teletext/expected_bug_469.png diff --git a/src/teletext.js b/src/teletext.js index 638679c..bf965a4 100644 --- a/src/teletext.js +++ b/src/teletext.js @@ -5,7 +5,6 @@ import { makeFast32 } from "./utils.js"; export class Teletext { constructor() { this.prevCol = 0; - this.holdOff = false; this.col = 7; this.bg = 0; this.sep = false; @@ -149,7 +148,6 @@ export class Teletext { } handleControlCode(data) { - this.holdOff = false; const wasGfx = this.gfx; const wasHoldChar = this.holdChar; @@ -208,7 +206,7 @@ export class Teletext { this.holdChar = true; break; case 31: - this.holdOff = true; + this.holdChar = false; break; } if (wasGfx && (wasHoldChar || this.holdChar) && this.dbl === this.oldDbl) { @@ -322,7 +320,7 @@ export class Teletext { this.heldGlyphs = this.curGlyphs; } } else { - this.holdOff = true; + this.heldChar = 32; } if (this.oldDbl) { @@ -346,10 +344,5 @@ export class Teletext { chardef >>>= 2; } } - - if (this.holdOff) { - this.holdChar = false; - this.heldChar = 32; - } } } diff --git a/tests/integration/teletext.js b/tests/integration/teletext.js index daf98d5..799e320 100644 --- a/tests/integration/teletext.js +++ b/tests/integration/teletext.js @@ -110,4 +110,17 @@ describe("Test other teletext test pages", () => { await testMachine.runUntilInput(); await compare(video, testMachine, `expected_hoglet_held_char.png`); }); + it("should work with the alternative engineer test page bug 469", async () => { + const video = new CapturingVideo(); + const testMachine = new TestMachine(null, { video: video }); + await testMachine.initialise(); + await testMachine.runUntilInput(); + // https://github.com/mattgodbolt/jsbeeb/issues/469 + // Taken from the 7th line of the engineer test page from b2. + await testMachine.type( + "CLS:VDU &81,&80,&81,&A0,&80,&A0,&81,&9E,&A0,&9E,&A0,&97,&AC,&93,&93,&96,&96,&92,&92,&92,&95,&95,&91,&91,&94,&94,&94,&A0,&A0,&94,&80,&81,&80,&81,&80,&81,&80,&81,&B0,&B7", + ); + await testMachine.runUntilInput(); + await compare(video, testMachine, `expected_bug_469.png`); + }); }); diff --git a/tests/integration/teletext/expected_bug_469.png b/tests/integration/teletext/expected_bug_469.png new file mode 100644 index 0000000000000000000000000000000000000000..1a9a03f237bb0fa3c1df7e2ba16e54ec788cf953 GIT binary patch literal 1912 zcmeAS@N?(olHy`uVBq!ia0y~yU~XVwV2a>i0*dVMk^csyI14-?i-8g^K$vlBbx<|~ z1G|=|i(^Q|oVRx!^O_9=90KpxKM($CW#@EtRqv&Mq@)iHbH6`{74T9Li|;YeWCWTr zh=6$T{;i*wAxY_c%uY14Gr6seNbmK4)ZT2t92*{d>99>AuelA2wOV zNbNc{?{D!^@3j~AmwnNf_%DBO@$-c{|Gs+39meoa!GU!JLu%em)2#bOLHgEi-xzF! z7BGc07;XQ{_==0!Vg`fg0;VZD-*N^dmp3S~tN?P)thILNz02q(2vPU0eL~K57K1LZ z!txD!yktzKiio(@q-NhcrTsu{_TE71_dLB z?6sEb_udBvdf(*YeWn?jXV;c7GCbhefA1JC0|R5vV@8IKG#P$|1DqfxhpGdRNMhk< zaFF3wWMmLHenXa_LE+dt28JVsW$X+O<}ld)?nbt1lsy^(qaiRF0;3^7I0Tk-|73Vv W`QiL*s|hzisy$u(T-G@yGywp*_n@T! literal 0 HcmV?d00001 diff --git a/tests/test-machine.js b/tests/test-machine.js index 25d10e0..34fb418 100644 --- a/tests/test-machine.js +++ b/tests/test-machine.js @@ -138,6 +138,9 @@ export class TestMachine { case ";": ch = utils.keyCodes.SEMICOLON; break; + case ":": + ch = utils.keyCodes.APOSTROPHE; + break; case ",": ch = utils.keyCodes.COMMA; break;