The console's attribute has always meant something to the screen and nothing to the serial line: its low nibble picks one of sixteen ink and paper pairs, and only videoPutCell ever read it. So the fault screen's red was red in the window and grey down the wire, and Examples/colours printed " ordinary highlighted " with nothing to tell them apart. It is said in ANSI now, on the same terms the cursor is said in: a register write only marks it and the next character sends it, so setting a scheme and printing nothing says nothing, and setting the same scheme twice costs one sequence rather than two. Only the scheme nibble crosses - the page bits say which tiles a cell draws from, which is a fact about the screen's own art. THE ORDER WAS ALREADY RIGHT, which is worth saying because it looks like a borrowing and is not. Both sets enumerate a three-bit colour, red green blue counted in binary: one is red in both, three is yellow in both, six is cyan in both. The same arithmetic done twice, forty years apart. The one place they differ is slot 0, and that difference is forced - this screen is ink on black, so ink cannot be black, and slot 0 is grey where ANSI's is black. Every sequence begins with a reset, so going from bank 8 to bank 1 does not write red on the grey paper bank 8 left behind. Scheme 0 is a bare reset rather than grey on black, and a terminal is assumed to start plain - so a machine that never asks for a colour says nothing at all, and one that does put the terminal back on its way out. Two ways out, because the two endings have different rules: stopping on purpose goes through stdio, since atexit runs BEFORE the buffer is flushed and a reset written to the file descriptor would arrive in front of the text it is meant to follow. Dying on a signal writes the four bytes directly and accepts that the buffer may be lost. colourTest walks all sixteen and then halts WITH ONE STILL SET, so the recording shows the reset after the halt line rather than before it. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
83 lines
2.2 KiB
NASM
83 lines
2.2 KiB
NASM
; What the console's attribute register says down a serial line.
|
|
;
|
|
; The attribute has always meant something to the SCREEN and nothing to a terminal: its low
|
|
; nibble picks one of sixteen ink and paper pairs, and only videoPutCell ever read it. So a
|
|
; fault printed in red was red in the window and grey down the wire, and every program that
|
|
; chose a colour was choosing it for half its audience.
|
|
;
|
|
; This walks all sixteen schemes and then stops WITH ONE STILL SET, which is the second half
|
|
; of what is being checked: the machine has to put the terminal back to plain on its way out,
|
|
; and the reset has to come out AFTER the text rather than in front of it. An atexit handler
|
|
; runs before stdio flushes what is buffered, so a reset written straight to the file
|
|
; descriptor would arrive first and colour nothing.
|
|
;
|
|
; Written by Anachronaut
|
|
|
|
#Include print.asm
|
|
|
|
#Program
|
|
|
|
start:
|
|
; Banks 0 to 7 are ink on black. Nought is plain and is expected to say nothing at all: a
|
|
; terminal is assumed to start plain, so a machine that never asks for a colour must be
|
|
; silent rather than opening every session with a reset nobody wanted.
|
|
RSTA
|
|
SETD Scheme
|
|
STA
|
|
|
|
inkNext:
|
|
SETD Scheme
|
|
LDA
|
|
OUTA 0x06
|
|
SETD InkText
|
|
CALL printString
|
|
SETD Scheme
|
|
LDA
|
|
CALL printDigit
|
|
CALL lineFeed
|
|
|
|
SETD Scheme
|
|
LDA
|
|
INCA
|
|
STA
|
|
INIB 0d16
|
|
CCF
|
|
SUB
|
|
BNQ inkNext
|
|
|
|
; ---- And it stops in colour, on purpose ----
|
|
;
|
|
; Fifteen is the last of them and nothing puts it back. What follows this in the recording
|
|
; is whatever the machine says on its way out, which is the check.
|
|
HALT
|
|
|
|
; A is nought to fifteen, said as ONE HEX CHARACTER. The scheme is a nibble, so a nibble is
|
|
; what it should read as - and one character means no scratch byte to hold the second digit
|
|
; while the first goes out, which is what the decimal version needed and got wrong.
|
|
printDigit:
|
|
INIB 0d10
|
|
CCF
|
|
SUB
|
|
BRC digitLow ; Borrowed, so it is below ten.
|
|
MVQA ; What is left once the ten is taken off.
|
|
INIB 0d65 ; 'A', because the ten has already gone.
|
|
CCF
|
|
ADD
|
|
MVQA
|
|
OUTA 0x00
|
|
RET
|
|
digitLow:
|
|
INIB 0d48
|
|
CCF
|
|
ADD
|
|
MVQA
|
|
OUTA 0x00
|
|
RET
|
|
|
|
#Data
|
|
|
|
InkText:
|
|
"scheme "
|
|
Scheme:
|
|
0x00
|