Replace the escape parser with cursor registers
The console had grown an ANSI parser, and that was the wrong shape. ANSI exists because a screen used to be on the other end of a serial line and a byte stream was the only channel there was. This screen is memory the program can already address, so reaching it by sending characters for a state machine to take apart is a middleman for something the machine does better - and it meant accepting an open protocol somebody else defines, in hardware, with no natural end to it. Everything else on this machine is registers. So the console gets three: cursor row at 0x03, cursor column at 0x04, and a command port at 0x05 where 1 clears the screen. Both cursor registers are READ as well as written, which is the thing an escape cannot do without sending a query and parsing a reply - a routine that wants to put the cursor back where it found it can now ask. Clearing is one command against a thousand cells walked one at a time. Snake and Life are smaller for it: 2,168 bytes to 2,163 and 1,410 to 1,396. A HOST TERMINAL STILL SPEAKS ANSI, and bridging to the host is the emulator's job, the same job it does reading standard input. So the escapes are now GENERATED, outbound, for the set this device chooses, rather than parsed inbound as though the machine were a terminal. The set cannot grow behind our backs because we are the ones saying it. The cursor is announced lazily, at the next character rather than at the register write, so setting a row and a column costs one sequence rather than two. The console's block widens from three ports to six, which registryTest noticed: it had been asking about port 0x05 precisely BECAUSE nothing was there, and the console had just moved in. Re-blessing it would have left it checking nothing, so it asks about 0x80 instead - clear of the console, the disk, the screen, the controller, and the sound device coming to 0x40. Six checks in Tests/video.sh swapped from the sequences to the registers, including that the cursor reads back and that one sent past the edge is clamped rather than refusing. Those checks also stopped counting bytes from the ends of a file, which had quietly started measuring an escape the moment the console began announcing the cursor. SplitLint caught the one thing worth catching in the port: the clear command leaves A at 1 and key mode is also 1, so the second load looks redundant. Acting on it would tie a console command to a console mode by coincidence, and break silently if either ever moved, so it is suppressed with that reason rather than removed. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
co-authored by
Claude Opus 5
parent
bdb2d0d8e6
commit
43a05b3df1
@@ -1,4 +1,4 @@
|
||||
[2J[H #
|
||||
[2J[1;1H #
|
||||
#
|
||||
###
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
# #
|
||||
##
|
||||
#
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
#
|
||||
# #
|
||||
##
|
||||
@@ -46,7 +46,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
#
|
||||
##
|
||||
##
|
||||
@@ -62,7 +62,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
#
|
||||
#
|
||||
###
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
# #
|
||||
##
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
#
|
||||
# #
|
||||
@@ -110,7 +110,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
#
|
||||
##
|
||||
@@ -126,7 +126,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
#
|
||||
#
|
||||
@@ -142,7 +142,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
# #
|
||||
@@ -158,7 +158,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
#
|
||||
@@ -174,7 +174,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
#
|
||||
@@ -190,7 +190,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
#
|
||||
@@ -206,7 +206,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -254,7 +254,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -302,7 +302,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -318,7 +318,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -382,7 +382,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -398,7 +398,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -414,7 +414,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -430,7 +430,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -446,7 +446,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
@@ -462,7 +462,7 @@
|
||||
|
||||
|
||||
|
||||
[H
|
||||
[1;1H
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user