A second screen, and one port to say which is shown
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
This commit is contained in:
co-authored by
Claude Opus 5
parent
66e7b84272
commit
023362b05a
@@ -5123,6 +5123,19 @@ screenSane:
|
||||
RSTA
|
||||
OUTA 0x37
|
||||
OUTA 0x38 ; No fraction of a cell in either direction.
|
||||
OUTA 0x3C ; And the screen everybody else's map is in.
|
||||
|
||||
; ---- Which of the two screens is being shown ----
|
||||
;
|
||||
; A program that draws into the back buffer and flips is showing screen one, and the shell
|
||||
; knows nothing about that. Its own scrollback, its prompt and every line the person typed
|
||||
; are in screen NOUGHT, so a program that exited while flipped would hand back a shell
|
||||
; drawing correctly onto a screen nobody had ever written to - blank, and looking for all
|
||||
; the world like the machine had lost everything.
|
||||
;
|
||||
; Put back rather than left, by the same rule as the cursor and the ink in handleExit: a
|
||||
; program that stopped early is not around to put anything back, and the shell owns what
|
||||
; the person is looking at.
|
||||
|
||||
; ---- And glyphs and colours that can be read ----
|
||||
;
|
||||
@@ -5139,8 +5152,12 @@ screenSane:
|
||||
OUTA 0x39
|
||||
RET
|
||||
|
||||
; Video memory as bank 4, which is what makes it reachable at all. Bank 3 is the disk's; see
|
||||
; the table in the CosmOS README, which exists because a program once took 3.
|
||||
; Video memory as banks 4 and 5, which is what makes it reachable at all. Bank 3 is the
|
||||
; disk's; see the table in the CosmOS README, which exists because a program once took 3.
|
||||
;
|
||||
; The BACK BUFFER is not given a number here. The system saves and restores what is on the
|
||||
; screen, and what is on the screen is screen nought - a program that wants the other one
|
||||
; registers it itself, the same as any program wanting memory nobody else is using.
|
||||
screenBank:
|
||||
INIA 0d4
|
||||
OUTA 0xE3
|
||||
|
||||
Reference in New Issue
Block a user