From 697ccd63e95dccbcff49d3c206f2a724edfd02eb Mon Sep 17 00:00:00 2001 From: Joshua Bell Date: Wed, 24 Jun 2020 21:19:49 -0700 Subject: [PATCH] Fix window text bottom - should not be changed if top changes. The TTY module stores top/height but the Apple monitor stores top/bottom. If top changes, bottom should remain unchanged. Improve the POKE 34 shim, and add a test. --- basic.js | 6 +++++- samples/sample.unittests.txt | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/basic.js b/basic.js index d7b2408..e5d7a6e 100644 --- a/basic.js +++ b/basic.js @@ -427,7 +427,11 @@ this.basic = (function() { // Text window 0x0020: function(v) { if (env.tty.textWindow) { env.tty.textWindow.left = v; } }, 0x0021: function(v) { if (env.tty.textWindow) { env.tty.textWindow.width = v; } }, - 0x0022: function(v) { if (env.tty.textWindow) { env.tty.textWindow.top = v; } }, + 0x0022: function(v) { if (env.tty.textWindow) { + var bottom = env.tty.textWindow.top + env.tty.textWindow.height; + env.tty.textWindow.top = v; + env.tty.textWindow.height = bottom - env.tty.textWindow.top; + } }, 0x0023: function(v) { if (env.tty.textWindow) { env.tty.textWindow.height = v - env.tty.textWindow.top; } }, 0x0024: function(v) { env.tty.setCursorPosition(v, void 0); }, 0x0025: function(v) { env.tty.setCursorPosition(void 0, v); }, diff --git a/samples/sample.unittests.txt b/samples/sample.unittests.txt index f15838d..2e61b39 100644 --- a/samples/sample.unittests.txt +++ b/samples/sample.unittests.txt @@ -506,7 +506,7 @@ 9000 PRINT : PRINT "POKE Compatibility Shims "; -: PRINT "UNIT TESTS NOT YET IMPLEMENTED "; +: PRINT "UNIT TESTS NOT FULLY IMPLEMENTED "; 9001 POKE 49168,0 : POKE -16368,0 : REM Clear kbd strobe 9002 POKE 49200,0 : POKE -16336,0 : REM Toggle speaker 9003 POKE 49232,0 : POKE -16304,0 : REM Graphics mode @@ -517,6 +517,9 @@ 9008 POKE 49233,0 : POKE -16303,0 : REM Text mode 9009 SPEED= 0 : SPEED= 255 : REM SPEED= (no-op) +9010 T$ = "POKE 34" +: T = PEEK(34) : U = PEEK(35) : POKE 34,T+1 : S = (PEEK(35) = U) : GOSUB 1 : POKE 34,T : POKE 35,U + 10000 PRINT : PRINT "Numeric Functions "; 10001 DEF FN E(X) = ABS(X) < 0.001 : REM Within-Epsilon