diff --git a/basic.js b/basic.js index e73bea7..d7b2408 100644 --- a/basic.js +++ b/basic.js @@ -412,7 +412,15 @@ this.basic = (function() { 0xC060: function() { return env.tty.getButtonState ? env.tty.getButtonState(3) : 0; }, 0xC061: function() { return env.tty.getButtonState ? env.tty.getButtonState(0) : 0; }, 0xC062: function() { return env.tty.getButtonState ? env.tty.getButtonState(1) : 0; }, - 0xC063: function() { return env.tty.getButtonState ? env.tty.getButtonState(2) : 0; } + 0xC063: function() { return env.tty.getButtonState ? env.tty.getButtonState(2) : 0; }, + + // Graphics State + 0xC01A: function() { return (env.display && !env.display.getState().graphics) * 128; }, + 0xC01B: function() { return (env.display && !env.display.getState().full) * 128; }, + 0xC01C: function() { return (env.display && !env.display.getState().page1) * 128; }, + 0xC01D: function() { return (env.display && !env.display.getState().lores) * 128; }, + 0xC01E: function() { return (env.tty.isAltCharset && env.tty.isAltCharset()) * 128; }, + 0xC01F: function() { return (env.tty.isFirmwareActive && env.tty.isFirmwareActive()) * 128; } }; poke_table = { diff --git a/index.js b/index.js index dff3f40..c4de80f 100644 --- a/index.js +++ b/index.js @@ -58,6 +58,9 @@ window.addEventListener('DOMContentLoaded', function() { hires2.show(false); tty.splitScreen(0); } + }, + getState: function() { + return Object.assign({}, this.state); } }; var pdl = [0, 0, 0, 0]; diff --git a/reference.html b/reference.html index b993f49..e2965bc 100644 --- a/reference.html +++ b/reference.html @@ -304,6 +304,14 @@ can be literals (unquoted strings), strings, or numbers
  • PEEK(230) — Hi-Res plotting page (32 = page 1, 64 = page 2)
  • PEEK(49152) — Read Keyboard
  • PEEK(49168) — Clear Keyboard strobe + +
  • PEEK(49178) — See if text mode (> 127) or graphics mode (< 128) +
  • PEEK(49179) — See if mixed mode (> 127) or full mode (< 128) +
  • PEEK(49180) — See if page2 (> 127) or page1 (< 128) +
  • PEEK(49181) — See if hires mode (> 127) or lores mode (< 128) +
  • PEEK(49182) — See if mousetext mode (> 127) +
  • PEEK(49188) — See if 80-column mode (> 127) +
  • PEEK(49200) — Click Speaker (no-op)
  • PEEK(49248) — Read Paddle Button #3 — Use the PageDown key
  • PEEK(49249) — Read Paddle Button #0 — Use the Home key diff --git a/samples/sample.unittests.txt b/samples/sample.unittests.txt index 50bb95f..f15838d 100644 --- a/samples/sample.unittests.txt +++ b/samples/sample.unittests.txt @@ -403,9 +403,8 @@ 7001 IF NOT LR THEN PRINT "" : GOTO 8000 7010 T$ = "GR" -: U = PEEK(36) : V = PEEK(37) -: GR : S = (PEEK(37) = 23) : TEXT : POKE 36,U : POKE 37,V : GOSUB 1 -: GR : S = (PEEK(34) = 20) : TEXT : POKE 36,U : POKE 37,V : GOSUB 1 +: U = PEEK(36) : V = PEEK(37) : GR : S = (PEEK(37) = 23) : TEXT : POKE 36,U : POKE 37,V : GOSUB 1 +: U = PEEK(36) : V = PEEK(37) : GR : S = (PEEK(34) = 20) : TEXT : POKE 36,U : POKE 37,V : GOSUB 1 7011 POKE 49232,0 : POKE 49234,0 : POKE 49238,0 @@ -659,7 +658,7 @@ : DEF FN A$(X$) = X$ + X$ : S = (FN A$("ABC") = "ABCABC") : GOSUB 1 15000 PRINT : PRINT "PEEK Compatibility Shims "; -: PRINT "UNIT TESTS NOT YET IMPLEMENTED "; +: PRINT "UNIT TESTS NOT FULLY IMPLEMENTED "; 15001 X = PEEK(49152) : X = PEEK(-16384) : REM Read keyboard 15002 X = PEEK(49168) : X = PEEK(-16368) : REM Clear keyboard strobe 15003 X = PEEK(49200) : X = PEEK(-16336) : REM Toggle speaker (no-op) @@ -673,6 +672,29 @@ 15010 REM Do as part of I/O follow-on module 15010 REM ********************************************** +15020 T$ = "PEEK(49178) RdTEXT" +: S = (PEEK(49178) > 127) : GOSUB 1 +: U = PEEK(36) : V = PEEK(37) : GR : S = (PEEK(49178) < 128) : TEXT : POKE 36,U : POKE 37,V : GOSUB 1 + +15030 T$ = "PEEK(49179) RdMIXED" +: HGR : S = (PEEK(49179) > 127) : TEXT : GOSUB 1 +: HGR2 : S = (PEEK(49179) < 128) : TEXT : GOSUB 1 + +15040 T$ = "PEEK(49180) RdPage2" +: HGR2 : S = (PEEK(49180) > 127) : TEXT : GOSUB 1 +: HGR : S = (PEEK(49180) < 128) : TEXT : GOSUB 1 + +15050 T$ = "PEEK(49181) RdHiRes" +: HGR : S = (PEEK(49181) > 127) : TEXT : GOSUB 1 +: U = PEEK(36) : V = PEEK(37) : GR : S = (PEEK(49181) < 128) : TEXT : POKE 36,U : POKE 37,V : GOSUB 1 + +15060 T$ = "PEEK(49182) RdAltChar" +: S = (PEEK(49182) < 128) : GOSUB 1 +: PRINT CHR$(15);CHR$(27); : S = (PEEK(49182) > 127) : PRINT CHR$(24);CHR$(14); : GOSUB 1 + +15070 T$ = "PEEK(49183) Rd80Col" +: S = (PEEK(49183) > 127) : GOSUB 1 + 16000 PRINT : PRINT "Operators "; diff --git a/script.js b/script.js index fa4f637..f91e9b4 100644 --- a/script.js +++ b/script.js @@ -69,6 +69,9 @@ hires2.show(false); tty.splitScreen(0); } + }, + getState: function() { + return Object.assign({}, this.state); } }; var pdl = [0, 0, 0, 0]; diff --git a/tty.js b/tty.js index 8858657..4e2c642 100644 --- a/tty.js +++ b/tty.js @@ -239,6 +239,13 @@ function TTY(screenElement, keyboardElement) { init(active, 24, active ? 80 : 40); }; + this.isFirmwareActive = function isFirmwareActive() { + return firmwareActive; + }; + + this.isAltCharset = function isAltCharset() { + return mousetext; + }; function scrollUp() { var x, y, cell;