Four pages of tiles, in bits that were already there
A tile number is a byte and a byte reaches 256, which is not many once a font has taken 135 of them and a game wants a character, a background and a wall. Bits 4 and 5 of the attribute now say which page of 256 the number is in - bits already written on every cell and every sprite, and reserved for this since the attribute was defined. Four pages of 16K is 64K, which is the whole atlas, so THE FOURTH PAGE IS THE MEMORY THE SPRITE TABLE AND THE PALETTE ARE IN. That is not a hole in the design; it is the answer shared video memory has always given, and it is checked rather than forbidden. The atlas is 1024 tiles, and what a program spends on sprites and colours comes out of them: no sprites means page 3 is art, and sprites means 768 tiles and a reason. The page is a property of the CELL and not a mode, so one screen shows tiles from all four at once and nothing has to decide which page it is in. Both places a tile is drawn from now ask one function where the art is. They would otherwise drift: the sprite pass was written days after the map pass and neither is where the other is looked at. Nothing in CosmOS changes. The shell draws from page 0, which the screen save covers; a tile left in another page is invisible unless a map cell names that page, and the map is given back or cleared. Both breaks were tried and both failed the checks - and the second had to be tried twice, because the constant it needed lives in video.h and the harness was only editing video.c. That is the same silent no-op as yesterday's uncompiled break, in a different disguise. 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
a916103a7f
commit
9eed23120f
@@ -621,11 +621,12 @@ Two rather than one because the two halves of a screen are written at completely
|
||||
|
||||
| Bank | Address | Holds |
|
||||
| --- | --- | --- |
|
||||
| Atlas | 0x0000 - 0x3FFF | Tile memory. 256 tiles of 8 by 8, one byte a pixel, so tile n begins at n times 64. |
|
||||
| Atlas | 0x4000 - 0xBFFF | Free. Two more 16K pages of tiles would fit here. |
|
||||
| Atlas | 0xC000 - 0xC7FF | The sprite table. 256 entries of eight bytes. |
|
||||
| Atlas | 0xC800 - 0xFBFF | Free. |
|
||||
| Atlas | 0xFC00 - 0xFFFF | The palette. 256 entries of four bytes: red, green, blue, and one unused. |
|
||||
| Atlas | 0x0000 - 0x3FFF | Tile page 0. 256 tiles of 8 by 8, one byte a pixel, so tile n begins at n times 64. |
|
||||
| Atlas | 0x4000 - 0x7FFF | Tile page 1. |
|
||||
| Atlas | 0x8000 - 0xBFFF | Tile page 2. |
|
||||
| Atlas | 0xC000 - 0xC7FF | The sprite table. 256 entries of eight bytes - and tiles 0 to 31 of page 3. |
|
||||
| Atlas | 0xC800 - 0xFBFF | Free - and tiles 32 to 239 of page 3. |
|
||||
| Atlas | 0xFC00 - 0xFFFF | The palette. 256 entries of four bytes: red, green, blue, and one unused - and tiles 240 to 255 of page 3. |
|
||||
| Screen | 0x0000 - 0x3FFF | Free in a tile mode. |
|
||||
| Screen | 0x4000 - 0xBFFF | The map. 128 rows of 256 bytes. |
|
||||
| Screen | 0x0000 - 0xF9FF | In bitmap mode, the picture instead: 64,000 bytes, one to a pixel. |
|
||||
@@ -678,14 +679,16 @@ A palette entry is four bytes for the same reason. Entry n begins at n times fou
|
||||
|
||||
Things that move without the map moving. A cell is where it is; something between two cells meant rewriting both of them, and something moving a pixel at a time meant rewriting them sixty times a second - which is affordable for one thing and not for twenty. A sprite is put at a **pixel**, and the device draws it over whatever is behind.
|
||||
|
||||
A sprite's attribute is a cell's attribute, read the same way and by the same code - which is what lets one piece of art be a wall in one place and a moving thing in another with nothing rewritten.
|
||||
|
||||
**A sprite is m by n tiles**, taken in reading order from one index. That is the decision the rest follows from: it needs no pixel format of its own, no second kind of memory, and nothing its art can be that the map could not also show. A 16 by 16 character is four tiles, and a program that wants the same picture in the background just names the same four.
|
||||
|
||||
The table is 256 entries of 8 bytes at **0xC000 in the atlas**. Eight so that entry n begins at n times eight, which is a shift - the same reason a palette entry is four bytes.
|
||||
|
||||
| Byte | Holds |
|
||||
| --- | --- |
|
||||
| 0 | The top left tile. The rest follow it in reading order, wrapping at 255. |
|
||||
| 1 | Attribute. Its low nibble times sixteen is added to every index in the art, exactly as a cell's is. |
|
||||
| 0 | The top left tile, in the page its attribute names. The rest follow it in reading order, wrapping at 255 inside that page. |
|
||||
| 1 | Attribute, which means exactly what a cell's does: low nibble the colour scheme, bits 4 and 5 the tile page. |
|
||||
| 2, 3 | X, low byte first, **signed**. |
|
||||
| 4, 5 | Y, the same. |
|
||||
| 6 | Size: tiles across in the high nibble, tiles down in the low. |
|
||||
@@ -711,7 +714,13 @@ Two bytes. The first says which tile, the second how to colour it.
|
||||
|
||||
The low nibble of the second byte is **added to every palette index in the tile, sixteen at a time**. A tile drawn in indices 0 to 15 therefore appears in any of sixteen colour schemes without a second copy of it in tile memory. A tile that wants all 256 colours leaves the nibble at zero and gets them. The addition wraps, because a byte plus a byte is a byte.
|
||||
|
||||
The high nibble is reserved and should be left at zero, so that a meaning can be given to it later without changing what already-written programs mean. The meaning waiting for it is a tile page: there is room in the atlas for two more pages of 256, and one bit of that nibble would reach them.
|
||||
**Bits 4 and 5 say which page of tiles the number is in.** A tile number is a byte and a byte reaches 256, which is not many once a font has taken 135 of them and a game wants a character, a background and a wall. Two bits that were already being written on every cell reach 1024.
|
||||
|
||||
Four pages of 16K is 64K, which is the whole atlas, so **the fourth page is the memory the sprite table and the palette are in.** That is not a hole in the design; it is the same answer shared video memory has always given. The atlas is 1024 tiles, and what a program spends on sprites and colours comes out of them. A program that wants no sprites may use page 3 for art, and one that wants sprites has 768 tiles and knows why.
|
||||
|
||||
The page is a property of the **cell**, not a mode, so one screen can show tiles from all four pages at once and a program never has to decide which page it is "in".
|
||||
|
||||
Bits 6 and 7 are still reserved and should be left at zero.
|
||||
|
||||
### Registers:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user