diff --git a/Programs/CosmOS/Apps/Flip.asm b/Programs/CosmOS/Apps/Flip.asm index 18553a4..d2f1f81 100644 --- a/Programs/CosmOS/Apps/Flip.asm +++ b/Programs/CosmOS/Apps/Flip.asm @@ -28,18 +28,11 @@ #Base 0x5000 start: - ; ---- The two banks this touches ---- + ; ---- The one bank this touches ---- ; - ; Four is the atlas, where the tiles are. Six is the other screen: three is the disk's and - ; four and five are the ones the system registers to save a screen with, so six is the - ; first number free. Nothing hands these out - see the table in the CosmOS README. - INIA 0d4 - OUTA 0xE3 - INIA 0x30 - OUTA 0xE2 - INIA 0x03 - OUTA 0xE8 - + ; Six: three is the disk's and four and five are the ones the system registers to save a + ; screen with, so six is the first number free. Nothing hands these out - see the table in + ; the CosmOS README. INIA 0d6 OUTA 0xE3 INIA 0x3B @@ -47,50 +40,57 @@ start: INIA 0x03 OUTA 0xE8 - ; The screen back afterwards, because the tile overwritten below is one the shell spells - ; with. Refused is survivable and is not checked: there is nothing this could do about it, - ; and the system puts the font back at exit whether or not it saved anything. - SWI osTakeScreen + ; ---- And it does NOT take the screen ---- + ; + ; osTakeScreen saves what is on the screen and puts it back at exit, and this program + ; called it at first. That was wrong in a way worth keeping written down: it saves the + ; screen AS IT WAS BEFORE, so the line printed below - the line whose whole job is to still + ; be there afterwards - was wiped out by the restore that was meant to be tidy. + ; + ; It was not needed either. NOTHING THIS TOUCHES IS THE SHELL'S: the only memory it writes + ; is the map of the screen nobody is looking at, and the only register it leaves changed is + ; which screen that is - which the system puts back itself. + ; + ; A program that wants a screen saved should ask. A program that damages nothing should + ; not, and asking anyway is not free - it costs the screen it was standing on. SETD.0 Message SWI osPrintString + INIA 0x0A + OUTA 0x00 ; The assembler has no escapes; a newline is a byte. ; Key mode, so a key arrives when it is pressed rather than when Return is. INIA 0x01 OUTA 0x02 - ; ---- Tile one, made solid ---- + ; ---- Every cell of the other screen, in one command ---- ; - ; Sixty four pixels of index one, FILLED rather than blitted, which is why this program - ; carries no picture of its own. - INIA 0d4 - OUTA 0xE3 - RSTA - OUTA 0xE4 - INIA 0x40 - OUTA 0xE5 ; Tile one begins at sixty four. - INIA 0x01 - OUTA 0xE2 ; Fill takes the byte it writes from SourceLow. - RSTA - OUTA 0xE6 - INIA 0x40 - OUTA 0xE7 ; Sixty four bytes of it. - INIA 0x02 - OUTA 0xE8 - - ; ---- And every cell of the other screen ---- + ; TEN, and the reason is worth the paragraph. Fill writes one byte, and a cell is two, so + ; whatever is filled with is BOTH the tile and the attribute - there is no filling a map + ; with a tile and a colour that are different numbers. ; - ; One byte fills both halves of a cell, so this is tile one and attribute one everywhere: - ; the tile is index one at every pixel and the attribute adds sixteen to all of them, which - ; comes out as a screen solidly in scheme one's ink. + ; Ten as a tile is an asterisk, because the font begins at the space and glyph n is + ; character n plus thirty two. Ten as an attribute is one of the eight REVERSED schemes, + ; whose paper is a colour and whose ink is black. So the screen comes out green, covered in + ; black asterisks, without a single tile being redefined. + ; + ; The high nibble stays at nought, which the manual asks for: it is reserved. That is the + ; real constraint on which byte this can be - it has to be under sixteen to leave the + ; nibble alone, and eight or over to land on a reversed scheme whose PAPER is the colour. + ; + ; Which means THIS PROGRAM WRITES NOTHING BUT THE SCREEN NOBODY IS LOOKING AT. It was + ; drawn with a tile of its own first, and that tile was one the system copies the font back + ; over at every exit - so the screen it had filled turned blank the moment it left, and a + ; check that it had been put back could not tell a restored screen from an abandoned one. + ; A picture that depends on the atlas does not survive leaving. INIA 0d6 OUTA 0xE3 INIA 0x40 OUTA 0xE4 RSTA OUTA 0xE5 - INIA 0x01 - OUTA 0xE2 + INIA 0x0A + OUTA 0xE2 ; Fill takes the byte it writes from SourceLow. INIA 0x80 OUTA 0xE6 RSTA @@ -141,5 +141,8 @@ waitKey: #Base 0x3000 +; One line and no newline in it. A string literal is terminated where it ends, so a second +; one after a 0x0A byte would never be reached - printing stops at the first terminator. The +; newline is written to the console directly instead. Message: -"A whole screen is about to be drawn where you cannot see it - this line will still\nbe here when it is done. Press a key to show it, and another to come back.\n" +"A screen is drawn where you cannot see it. A key shows it, another comes back." diff --git a/Programs/CosmOS/README.md b/Programs/CosmOS/README.md index 39d1211..4288fad 100644 --- a/Programs/CosmOS/README.md +++ b/Programs/CosmOS/README.md @@ -725,7 +725,7 @@ from every assembly file in it. Several are old programs written for the bare ma | Files | Writes a file, reads it back, renames it and deletes it, in 675 bytes, including nothing but the service names. It is what says a program does not need a filesystem inside it. | | Break | Stops itself twice with SWI osBreak, so that the registers can be seen changing between one stop and the next. | | Grid | The first program to use the screen as a screen. Redefines a tile above the font, fills all 128 map rows, and scrolls it diagonally a pixel at a time. | -| Flip | Draws a whole screen into the bank that is not being shown, waits, and then shows it in one byte out of one port. It deliberately does not put the displayed screen back, because that is the system's to restore - a program that faulted while flipped could not have. | +| Flip | Draws a whole screen into the bank that is not being shown, waits, and then shows it in one byte out of one port. It writes nothing else at all - not a tile, not a colour - so it does not ask for the screen to be saved, and the line it printed is still there when it comes back. It deliberately does not put the displayed screen back either, because that is the system's to restore: a program that faulted while flipped could not have. | | Edit | A line editor. | | Stream | Reads an 84,000 byte file through a buffer of 256, which is what says a file bigger than Data Memory can be read at all. | | Type | Prints a named text file a block at a time, including one too large to fit in Data Memory. | diff --git a/SplitBit Test Manual.md b/SplitBit Test Manual.md index 5070174..552ce1e 100644 --- a/SplitBit Test Manual.md +++ b/SplitBit Test Manual.md @@ -79,7 +79,7 @@ from `make`, not from here. ### 1. Recorded output `Tests/run.sh` assembles each program named in `Tests/manifest`, runs it, and compares -everything it printed against a file in `Tests/expected`. 203 tests, of which 141 run, 35 +everything it printed against a file in `Tests/expected`. 204 tests, of which 142 run, 35 only assemble, 16 are expected to fail to assemble, and 11 boot from ROM with no image given at all. diff --git a/Tests/expected/cosmosCrossDisk.out b/Tests/expected/cosmosCrossDisk.out index bf72de1..fb61fe9 100644 --- a/Tests/expected/cosmosCrossDisk.out +++ b/Tests/expected/cosmosCrossDisk.out @@ -22,7 +22,7 @@ Break.sbx 149 Grid.sbx 571 Press.sbx 872 Mode.sbx 48 -Flip.sbx 291 +Flip.sbx 173 Crash.sbx 632 vars.script 50 blocks.script 343 diff --git a/Tests/expected/cosmosDrives.out b/Tests/expected/cosmosDrives.out index 5d22b1d..3227acc 100644 --- a/Tests/expected/cosmosDrives.out +++ b/Tests/expected/cosmosDrives.out @@ -12,7 +12,7 @@ Break.sbx 149 Grid.sbx 571 Press.sbx 872 Mode.sbx 48 -Flip.sbx 291 +Flip.sbx 173 Crash.sbx 632 vars.script 50 blocks.script 343 diff --git a/Tests/expected/cosmosFault.out b/Tests/expected/cosmosFault.out index 4040d16..64868e0 100644 --- a/Tests/expected/cosmosFault.out +++ b/Tests/expected/cosmosFault.out @@ -29,7 +29,7 @@ Break.sbx 149 Grid.sbx 571 Press.sbx 872 Mode.sbx 48 -Flip.sbx 291 +Flip.sbx 173 Crash.sbx 632 vars.script 50 blocks.script 343 diff --git a/Tests/expected/cosmosFlip.out b/Tests/expected/cosmosFlip.out new file mode 100644 index 0000000..1162360 --- /dev/null +++ b/Tests/expected/cosmosFlip.out @@ -0,0 +1,42 @@ +CosmOS +> Say before Flip +it says: before Flip +finished +> Flip +A screen is drawn where you cannot see it. A key shows it, another comes back. +finished +> Say after Flip +it says: after Flip +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 173 +Crash.sbx 632 +vars.script 50 +blocks.script 343 +loops.script 272 +tune.sbx 306 +notes.txt 21 +Apps