Skip to content

Commit

Permalink
Simplify teletext hold handling (#470)
Browse files Browse the repository at this point in the history
Fixes #469 by being simpler too.
  • Loading branch information
mattgodbolt authored Jan 5, 2025
1 parent 09dbaa4 commit f3a68ce
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/teletext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,7 +148,6 @@ export class Teletext {
}

handleControlCode(data) {
this.holdOff = false;
const wasGfx = this.gfx;
const wasHoldChar = this.holdChar;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -322,7 +320,7 @@ export class Teletext {
this.heldGlyphs = this.curGlyphs;
}
} else {
this.holdOff = true;
this.heldChar = 32;
}

if (this.oldDbl) {
Expand All @@ -346,10 +344,5 @@ export class Teletext {
chardef >>>= 2;
}
}

if (this.holdOff) {
this.holdChar = false;
this.heldChar = 32;
}
}
}
13 changes: 13 additions & 0 deletions tests/integration/teletext.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
});
});
Binary file added tests/integration/teletext/expected_bug_469.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tests/test-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f3a68ce

Please sign in to comment.