Give the console colour and a cursor
COLOUR COSTS A NIBBLE AND NO HARDWARE. A glyph is drawn in palette indices 0 and 1, paper and ink, and a cell's attribute nibble adds sixteen to both - so sixteen banks is already sixteen ink and paper pairs, and all that was missing was a register saying which one the console draws in. That is port 0x06, read as well as written like the rest. The palette a machine wakes up with is arranged so that HIGHLIGHTING IS ONE BIT: banks 0 to 7 are colours on black, banks 8 to 15 are the same colours as paper with black ink. So attribute XOR 8 turns any pair inside out. That is a convention rather than a rule of the machine - the device only ever adds the nibble and looks the answer up - but it is the convention that makes a highlighted line and a cursor free. Bank 0 is still grey on black, so nothing that was written before this has changed colour. THE CURSOR IS THE SAME BIT AGAIN. It is drawn by turning its cell inside out rather than by putting a block over it, so the character underneath stays readable, which matters to somebody editing a line. The device draws it rather than the window, because on a machine with a screen a cursor is a hardware feature - one drawn by the presenter would not be in a picture the machine saved. It blinks on the machine's own clock, half a second each way, so the phase is a pure function of the cycle count and a screen saved at a given cycle is the same screen every time. A blink on the host's clock would have made every saved picture a matter of luck. Off unless asked for, with bit 2 of the control port. That is right for a machine - a program painting its own screen does not want something blinking in the middle of it - and CosmOS asks for one at boot. It also asks again when it takes the console back from a program that has stopped, because a program handing key mode back the way it was told to writes zero, which turns the cursor off. The shell owns the prompt, so the shell is what makes sure there is something blinking at it. Nine more checks in Tests/video.sh, to 41: that the attribute colours the ink and not the paper, that XOR 8 turns both, that it reads back, that a cursor appears where the registers put it and only when asked for, and that it goes dark again half a million cycles later. 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
978aec4809
commit
d6feddd1b6
@@ -96,6 +96,21 @@ void videoReset(void);
|
||||
// of one-bit rows against 16 kilobytes of tiles.
|
||||
void videoLoadFont(void);
|
||||
|
||||
// ---- The cursor ----
|
||||
//
|
||||
// Drawn by the device rather than by whatever is presenting, because on a machine with a
|
||||
// screen the cursor IS a hardware feature - a display controller blinks it from a counter,
|
||||
// and one drawn by the window would not be in a picture the machine saved.
|
||||
//
|
||||
// It blinks on the machine's own clock, so the phase is a pure function of the cycle count
|
||||
// and a screen saved at a given cycle is the same screen every time.
|
||||
#define VIDEO_BLINK_CYCLES 500000
|
||||
|
||||
void videoSetCursor(int row, int column, int visible);
|
||||
|
||||
// The machine's clock, for anything that has to know time has passed.
|
||||
void videoTick(unsigned long now);
|
||||
|
||||
int videoColumns(void);
|
||||
int videoRows(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user