Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ppu [2021/08/30 20:27] – [Special effects] pulkomandyppu [2021/09/05 18:10] (current) – [Layer 1 and 2 registers] simer
Line 11: Line 11:
 The PPU provides two background layers (which can use either tiled or bitmap modes), on top of which sprites can also be displayed. The PPU provides two background layers (which can use either tiled or bitmap modes), on top of which sprites can also be displayed.
  
-====== Basic info about tiles ======+===== Basic info about tiles =====
  
 The PPU works with tiles. The idea of tiles is to have small square or rectangular images (8x8 up to 64x64 pixels) and use them to compose a larger image. The advantage of this is that some tiles can be reused in multiple places, which provides a simple compression method. Also, a tile can be quickly replaced by another, without copying a lot of bytes around in RAM, to animate things. The PPU works with tiles. The idea of tiles is to have small square or rectangular images (8x8 up to 64x64 pixels) and use them to compose a larger image. The advantage of this is that some tiles can be reused in multiple places, which provides a simple compression method. Also, a tile can be quickly replaced by another, without copying a lot of bytes around in RAM, to animate things.
Line 23: Line 23:
 It's also possible to use a bitmap mode, but this needs a lot of memory. Since the V.Smile doesn't have much RAM, typically, only fixed bitmaps read directly from ROM will be used in this case. It's also possible to use a bitmap mode, but this needs a lot of memory. Since the V.Smile doesn't have much RAM, typically, only fixed bitmaps read directly from ROM will be used in this case.
  
-====== Register map ======+===== Register map =====
  
 ^ Address   ^ Contents                ^ ^ Address   ^ Contents                ^
Line 67: Line 67:
 | 2820/2821 | Tile data segment     | | 2820/2821 | Tile data segment     |
  
-Each layer can be positionned at any X and Y coordinate on screen. They have a fixed size of 512x256 pixels (tbcis it a fixed size, or a fixed number of tiles?)+Each layer can be positioned at any X and Y coordinate on screen. They have a fixed size of 512x256 pixels, with the number of tiles depending on the chosen tile size.
  
 The following global attributes are available: The following global attributes are available:
  
-  * Bit depth (bits 0 and 1) can be 246, or 8 bits per pixel +  * Bit depth (bits 0 and 1) 
-  * Bit 2: mirror the tiles horizontally +    * 00 - bits per pixel 
-  * Bit 3: mirror the tiles vertically +    * 01 - bits per pixel 
-  * Bits 4 and 5: width of tiles (81632 or 64 pixels) +    * 10 - bits per pixel 
-  * Bits 6 and 7: height of tiles +    * 11 - 8 bits per pixel 
-  * Bits 8 to 11: palette bank to use +  * Bit 2: Mirror the tiles horizontally 
-  * Bits 12 and 13: define the layer depth (wether it is under or over sprites and the other layer) +  * Bit 3: Mirror the tiles vertically 
-  * Bits 14 and 15: unused (in later PPU generations it sets the layer size)+  * Bits 4-5: Width of tiles 
 +    * 00 - pixels 
 +    * 01 - 16 pixels 
 +    * 10 - 32 pixels 
 +    * 11 - 64 pixels 
 +  * Bits 6-7: Height of tiles 
 +      * Same format as width register 
 +  * Bits 8-11: Palette bank to use 
 +  * Bits 12-13: Layer depth (wether it is under or over sprites and the other layer) 
 +      * 00 - bottom layer 
 +      * 01 - second-bottom layer 
 +      * 10 - second-top layer 
 +      * 11 - top layer 
 +  * Bits 14-15: unused (in later PPU generations it sets the layer size)
  
 The control register can do the following: The control register can do the following:
  
-  * Bit 0: use bitmap mode instead of tile mode +  * Bit 0: Use bitmap mode instead of tile mode 
-  * Bit 1: If set, the attribute register is used. If clear, the attributes are fetched from RAM (like the tilemap) and can be different for each tile +  * Bit 1: If set, the attribute register is used. If clear, the attributes are fetched from the attribute map in RAM (like the tilemap) and can be different for each tile. 
-  * Bit 2: Wallpaper effect (only first character/line attribute is effective) +  * Bit 2: Use wallpaper effect (only first character/line attribute is effective) 
-  * Bit 3: enable the layer +  * Bit 3: Enable the layer 
-  * Bit 4: enable horizontal movement +  * Bit 4: Enable horizontal movement 
-  * Bit 5: enable horizontal compression +  * Bit 5: Enable horizontal compression 
-  * Bit 6: enable vertical compression +  * Bit 6: Enable vertical compression 
-  * Bit 7: use direct colors instead of palette (each 16-bit word is a RGB15 value) +  * Bit 7: Use direct colors instead of palette (each 16-bit word is a 15-bit RGB value) 
-  * Bit 8: enable blending+  * Bit 8: Enable blending
  
-The tilemap and attribute addresses are 13 bit valueso the tilemap has to be in RAM.+When the attribute map mode is usedeach word stores attributes for one tile in each byte in the following format: 
 +  * Bits 0-3: Palette bank to use 
 +  * Bit 4: Mirror the tiles horizontally 
 +  * Bit 5: Mirror the tiles vertically 
 +  * Bit 6: Enable blending
  
-The tiles themselves, however, are usually stored in flash. The data segment register defines the segment where to find tiles.+The tile map and attribute map addresses are 13-bit values, so they have to be in RAM. 
 + 
 +The tile graphics themselves, however, are usually stored in flash. The data segment register defines the segment where to find tiles.
 To compute where the data for a tile is, use: data segment * 0x40 + tile id * tile size in words To compute where the data for a tile is, use: data segment * 0x40 + tile id * tile size in words
  
Line 106: Line 125:
 Each sprite has an X and Y position and an attribute register that works the same as for the layers. The attribute register has an extra bit (bit 14) to enable blending. The blending level is global for all sprites and there are only 4 possible values. The sprite is disabled by setting the char select to 0. Each sprite has an X and Y position and an attribute register that works the same as for the layers. The attribute register has an extra bit (bit 14) to enable blending. The blending level is global for all sprites and there are only 4 possible values. The sprite is disabled by setting the char select to 0.
  
-Unlike for layers, there is no tile and attribute map: a sprite is made of one single tile, which ID is stored directly in the corresponding register for the sprite.+The sprite position refers to the center of the sprite (rather than top left corner) and contains signed values with pixel position x=160,y=128 as the origin of the coordinate system and positive Y going upwards. 
 + 
 +Unlike for layers, there is no tile and attribute map: a sprite is made of one single tile, with the character ID is stored directly in the corresponding register for the sprite. 
 + 
 +The sprite attribute register format is the same as the one for tile layers, with the exception of bit 14 being assigned to blend enable. 
 +===== Colors and palettes ===== 
 + 
 +The PPU supports 15-bit color, with colors stored in the following format: 
 +  * Bits 0-4: Blue value 
 +  * Bits 5-9: Green value 
 +  * Bits 10-14: Red value 
 +  * Bit 15: Set if transparent 
 + 
 +In the 16-bit color mode, the value of each pixel in the segment memory directly stores a color, otherwise the value refers to a palette index.  
 +The palette memory is mapped to 0x2B00-0x2BFF and stores 256 different colors in the format mentioned above. 
 +This memory can be split into multiple palette banks which can then chosen by a 4-bit value stored for each sprite, tile layer or individual tile (if the attribute map mode is enabled). 
 + 
 +The chosen color from the palette memory is determined by the chosen color depth and palette of each tile/sprite and value of each pixel as follows: 
 + 
 +^ Color depth ^ Chosen color memory index   ^ 
 +| 2-bit       | Palette * 16 + Index        | 
 +| 4-bit       | Palette * 16 + Index        | 
 +| 6-bit       | (Palette & ~3) * 64 + Index | 
 +| 8-bit       | Index                       |
  
 ===== Special effects ===== ===== Special effects =====
Line 114: Line 156:
 {{:sunplus:sunplus_fade.png?nolink|}} {{:sunplus:sunplus_fade.png?nolink|}}
  
-The blend effect allows for partially transparent sprites.+The blend effect allows for partially transparent tiles and sprites. There is a single blending level shared by all blended objects, but each object can be either blended or fully opaque. When the tile layer is in attribute map mode, the blend effect can be set for each individual tile, otherwise the same blending will be applied to the entire layer.
  
 {{:sunplus:blend.png?nolink|}} {{:sunplus:blend.png?nolink|}}
ppu.1630348031.txt.gz · Last modified: 2021/08/30 20:27 by pulkomandy
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0