Give the screen a bitmap mode

V4. Mode 2 is 320 by 200 with a byte a pixel: no tile to look up and no attribute to add,
the byte IS the palette index. Programs/Examples/picture.asm fills a whole one in 127 bytes
of program and 47,498 cycles.

IT IS THE SAME MEMORY AS THE TILES AND THE MAP, which is what shared video memory has always
been, and there is nowhere else it could be - 64,000 bytes of picture in a 65,536 byte bank
leaves room for nothing beside it. Going to bitmap mode does not clear the text screen, it
stops calling it one, and coming back finds the tiles holding whatever the picture put there.
Taking the screen means taking it.

The palette moves to 0xFC00, the top of video memory, because it is the one thing that has to
mean the same in every mode and 64,000 bytes of picture leaves nowhere in the middle for it
to hide. That is a documented address, so the example, the tests and the manual move with it.

A BITMAP HAS NO COLUMNS AND NO ROWS, and both registers read zero rather than a leftover from
the last mode. The console asks: told there is no character screen, it has nowhere to put a
glyph and draws nothing, while still saying everything down the serial line. The honest
alternative is what a machine with shared video memory really does, which is scribble marks
nobody can read across somebody's picture - honest and useless, since a program that has
taken the screen has not stopped wanting to print.

Six checks in Tests/video.sh, to 55: that the mode is 320 by 200, that a byte is one pixel's
colour and only that pixel, that printing leaves a picture alone while the letter still goes
out, and that the columns register says nought and then forty again.

The example is worth reading for one thing beyond the mode: Fill leaves its destination past
what it touched, so two hundred rows are drawn from one address set once. Working out where
row n begins would be n times 320, and this machine has no multiply.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-29 10:44:15 -04:00
co-authored by Claude Opus 5
parent 1174bd9af5
commit 13b20c8834
10 changed files with 258 additions and 20 deletions
+13
View File
@@ -301,6 +301,19 @@ static void consoleSayCursor(void) {
}
static void consoleDraw(uint8_t byte) {
// ---- Nowhere to put a glyph ----
//
// A console is a display controller, and a display controller draws characters on a
// character screen. In bitmap mode there is not one - the memory it would write into is
// somebody's picture - so it draws nothing and says everything down the serial line
// instead, which is where it was always going as well.
//
// The alternative is what a machine with shared video memory really does, which is
// scribble. That is honest and useless: nobody can read the marks and they ruin the
// picture, and a program that has taken the screen has not stopped wanting to print.
if (videoTextRows() == 0) {
return;
}
switch (byte) {
case '\n':
consoleNewLine();