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/09/01 22:10] simerppu [2021/09/05 18:10] (current) – [Layer 1 and 2 registers] simer
Line 71: Line 71:
 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 ===== ===== Colors and palettes =====
  
Line 118: Line 140:
 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.  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. 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 palettes 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).+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: 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                ^+^ Color depth ^ Chosen color memory index   ^
 | 2-bit       | Palette * 16 + Index        | | 2-bit       | Palette * 16 + Index        |
 | 4-bit       | Palette * 16 + Index        | | 4-bit       | Palette * 16 + Index        |
ppu.1630527005.txt.gz · Last modified: 2021/09/01 22:10 by simer
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0