A screen drawn where it can be seen is seen half drawn. A program that moves forty things and rewrites the map underneath them is wrong for as long as it takes to put them all right, and at a megahertz that is long enough to look at. So the device brings a second screen bank, on port 0x3B, and port 0x3C says which of the two is displayed. Everything a program draws into the other one is invisible until one byte shows the whole of it at once. ONE REGISTER IS ENOUGH, where the hardware this imitates needed two. The other said which screen the CPU's window pointed at; there is no window here, because a program reaches a bank through the memory controller by its number. Writing to the screen that is not shown is a matter of naming its bank, and the device never has to be told. And a flip cannot tear: a frame is drawn from one bank in one go, so a flip either happened before that frame or happens before the next. There is nothing to race, where the real machines had to catch the few lines between frames to swap in. The console draws into whichever screen is displayed rather than one of its own, so a fault message lands where somebody can read it even if a game had flipped. And CosmOS puts the displayed screen back at exit, the way it already puts back the cursor and the ink: a program that faulted while flipped could not have, and a shell that only came out right for programs which remembered would come out wrong the day one crashed. Flip.asm is the worked example. It deliberately does NOT restore the display itself - that is the point of the paragraph above, and it is what makes the system's guarantee the thing under test rather than the program's good manners. Written the other way round first, where it passed with the guarantee deleted. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
43 lines
919 B
Plaintext
43 lines
919 B
Plaintext
CosmOS
|
|
> Say before Grid
|
|
it says: before Grid
|
|
finished
|
|
> Grid
|
|
[2J[Hfinished
|
|
>
|
|
> Say after Grid
|
|
it says: after Grid
|
|
finished
|
|
> dir
|
|
greet.sbx 211
|
|
hello.sbx 53
|
|
Life.sbx 1396
|
|
Snake.sbx 2164
|
|
Keys.sbx 664
|
|
Say.sbx 156
|
|
Break.sbx 149
|
|
Grid.sbx 571
|
|
Press.sbx 872
|
|
Mode.sbx 48
|
|
Flip.sbx 291
|
|
Crash.sbx 632
|
|
vars.script 50
|
|
blocks.script 343
|
|
loops.script 272
|
|
tune.sbx 306
|
|
notes.txt 21
|
|
Apps <dir>
|
|
hi.script 121
|
|
bad.script 45
|
|
plain.script 24
|
|
cross.script 280
|
|
nonl.script 38
|
|
outer.script 376
|
|
inner.script 44
|
|
loop.script 35
|
|
25 files, 1 directory
|
|
> exit
|
|
halted
|
|
Execution halted.
|
|
[exit 0]
|