PPU registers: Difference between revisions

From SNESdev Wiki
Jump to navigationJump to search
m (Improves mosaic size description.)
(More registers. Some reformatting and formatting fixes.)
Line 1: Line 1:
==Display configuration==
==Display configuration==
===INIDISP - Screen display ($2100 write)===
===INIDISP - Screen display ($2100 write)===
----
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
Line 9: Line 10:


===BGMODE - BG mode and Character size ($2105 write)===
===BGMODE - BG mode and Character size ($2105 write)===
----
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
Line 20: Line 22:
  +--------- BG4 character size (0 = 8x8, 1 = 16x16)
  +--------- BG4 character size (0 = 8x8, 1 = 16x16)


  Mode | BG bit depth   | Tile  |     Priorities (front -> back)       |                     Notes                      <u>
Mode| BG bit depth |Offsets |     Priorities (front -> back)       |                     Notes                      <u>
      | BG1 BG2 BG3 BG4 | offsets |                                       |                                                
    |BG1 BG2 BG3 BG4|per tile|                                     |                                              
  0   | 2  2  2  2 |  No   |   S3 1H 2H S2 1L 2L S1 3H 4H S0 3L 4L |                                                 </u>
  0 | 2  2  2  2 |  No   |   S3 1H 2H S2 1L 2L S1 3H 4H S0 3L 4L|                                               </u>
  1   | 4  4  2     |  No   |   S3 1H 2H S2 1L 2L S1 3H    S0 3L   | BG3 priority = 0                                <u>
  1 | 4  4  2     |  No   |   S3 1H 2H S2 1L 2L S1 3H    S0 3L   |BG3 priority = 0                                <u>
      |                 |         | 3H S3 1H 2H S2 1L 2L S1      S0 3L   | BG3 priority = 1                                 
    |               |       |3H S3 1H 2H S2 1L 2L S1      S0 3L   |BG3 priority = 1                                 
  2   | 4  4         |   Yes  |   S3 1H    S2 2H    S1 1L    S0 2L   |                                                
  2 | 4  4         | Yes  |   S3 1H    S2 2H    S1 1L    S0 2L   |                                              
  3   | 8  4         |  No   |   S3 1H    S2 2H    S1 1L    S0 2L   |                                                
  3 | 8  4         |  No   |   S3 1H    S2 2H    S1 1L    S0 2L   |                                              
  4   | 8  2         |   Yes  |   S3 1H    S2 2H    S1 1L    S0 2L   |                                                
  4 | 8  2         | Yes  |   S3 1H    S2 2H    S1 1L    S0 2L   |                                              
  5   | 4  2         |  No   |   S3 1H    S2 2H    S1 1L    S0 2L   | Fixed 16 pixel char width. Forced high-res mode.
  5 | 4  2         |  No   |   S3 1H    S2 2H    S1 1L    S0 2L   |Fixed 16 pixel char width. Forced high-res mode.
  6   | 4             |   Yes  |   S3 1H    S2      S1 1L    S0       | Fixed 16 pixel char width. Forced high-res mode.
  6 | 4             | Yes  |   S3 1H    S2      S1 1L    S0     |Fixed 16 pixel char width. Forced high-res mode.
  7   | 8             |  No   |   S3      S2      S1 1L    S0       | Fixed 8x8 char size.                            </u>
  7 | 8             |  No   |   S3      S2      S1 1L    S0     |Fixed 8x8 char size.                            </u>
  7+EXT | 8  7         |  No   |   S3      S2 2H    S1 1L    S0 2L   | Fixed 8x8 char size. BG2 bit 7 acts as priority.
  7EXT| 8  7         |  No   |   S3      S2 2H    S1 1L    S0 2L   |Fixed 8x8 char size. BG2 bit 7 acts as priority.


===MOSAIC - Screen pixelation ($2106 write)===
===MOSAIC - Screen pixelation ($2106 write)===
----
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
Line 45: Line 48:


===BGxSC - BG1-4 tilemap address and size ($2107-$210A write)===
===BGxSC - BG1-4 tilemap address and size ($2107-$210A write)===
----
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
Line 53: Line 57:
  ++++-++--- Tilemap VRAM address (address = AAAAAA << 10)
  ++++-++--- Tilemap VRAM address (address = AAAAAA << 10)


===BG12NBA - BG1 and BG2 CHR word base address ($210B write)===
===CHR word base address===
----
====BG12NBA - BG1 and BG2 CHR word base address ($210B write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
  BBBB AAAA
  BBBB AAAA
|||| ||||
  |||| ++++- BG1 CHR word base address (address = AAAA << 12)
  |||| ++++- BG1 CHR word base address (address = AAAA << 12)
  ++++------ BG2 CHR word base address (address = BBBB << 12)
  ++++------ BG2 CHR word base address (address = BBBB << 12)


===BG34NBA - BG3 and BG4 CHR word base address ($210C write)===
====BG34NBA - BG3 and BG4 CHR word base address ($210C write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
  DDDD CCCC
  DDDD CCCC
|||| ||||
  |||| ++++- BG3 CHR word base address (address = CCCC << 12)
  |||| ++++- BG3 CHR word base address (address = CCCC << 12)
  ++++------ BG4 CHR word base address (address = DDDD << 12)
  ++++------ BG4 CHR word base address (address = DDDD << 12)


===W12SEL - Window Mask Settings for BG1 and BG2 ($2123 write)===
===Layer enable===
----
====TM - Main screen layer enable ($212C write)====
7  bit  0
---- ----
...O 4321
    | ||||
    | |||+- Enable BG1 on main screen
    | ||+-- Enable BG2 on main screen
    | |+--- Enable BG3 on main screen
    | +---- Enable BG4 on main screen
    +------ Enable OBJ on main screen
 
====TS - Subscreen layer enable ($212D write)====
7  bit  0
---- ----
...O 4321
    | ||||
    | |||+- Enable BG1 on subscreen
    | ||+-- Enable BG2 on subscreen
    | |+--- Enable BG3 on subscreen
    | +---- Enable BG4 on subscreen
    +------ Enable OBJ on subscreen
 
===SETINI - Screen Mode/Video Select ($2133 write)===
----
7  bit  0
---- ----
EX.. HOiI
||  ||||
||  |||+- Screen interlacing
||  ||+-- OBJ interlacing
||  |+--- Overscan mode
||  +---- High-res mode
|+-------- EXTBG mode
+--------- External sync
 
==Windows==
===Window mask settings===
----
====W12SEL - Window Mask Settings for BG1 and BG2 ($2123 write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
Line 81: Line 129:
  +--------- Enable window 2 for BG2
  +--------- Enable window 2 for BG2


===W34SEL - Window Mask Settings for BG3 and BG4 ($2124 write)===
====W34SEL - Window Mask Settings for BG3 and BG4 ($2124 write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
Line 95: Line 143:
  +--------- Enable window 2 for BG4
  +--------- Enable window 2 for BG4


===WOBJSEL - Window Mask Settings for OBJ and Color Window ($2125 write)===
====WOBJSEL - Window Mask Settings for OBJ and Color Window ($2125 write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
Line 109: Line 157:
  +--------- Enable window 2 for color math
  +--------- Enable window 2 for color math


===TM - Main screen layer enable ($212C write)===
===Window positions===
----
====WH0 - Window 1 left position ($2126 write)====
7  bit  0
---- ----
LLLL LLLL
|||| ||||
++++-++++- Window 1 left edge position
 
====WH1 - Window 1 right position ($2127 write)====
7  bit  0
---- ----
RRRR RRRR
|||| ||||
++++-++++- Window 1 right edge position
 
====WH2 - Window 2 left position ($2128 write)====
7  bit  0
---- ----
LLLL LLLL
|||| ||||
++++-++++- Window 2 left edge position
 
====WH3 - Window 2 right position ($2129 write)====
7  bit  0
---- ----
RRRR RRRR
|||| ||||
++++-++++- Window 2 left edge position
 
===Window mask logic===
----
====WBGLOG - Window BG mask logic ($212A write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
  ...O 4321
  4433 2211
    | |||+- Enable BG1 on main screen
|||| ||||
    | ||+-- Enable BG2 on main screen
|||| ||++- BG1 window mask logic
    | |+--- Enable BG3 on main screen
|||| ++--- BG2 window mask logic
    | +---- Enable BG4 on main screen
||++------ BG3 window mask logic
    +------ Enable OBJ on main screen
++-------- BG4 window mask logic


===TS - Subscreen layer enable ($212D write)===
====WOBJLOG - Window OBJ and color math mask logic ($212B write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
  ...O 4321
  .... CCOO
    | |||+- Enable BG1 on subscreen
      ||||
    | ||+-- Enable BG2 on subscreen
      ||++- OBJ window mask logic
    | |+--- Enable BG3 on subscreen
      ++--- Color window mask logic
    | +---- Enable BG4 on subscreen
 
    +------ Enable OBJ on subscreen
<b>Mask logic types</b>
<u>Value|Logic</u>
  00 | OR
  01 | AND
  10 | XOR
  11 | XNOR


===TMW - Main screen layer window enable ($212E write)===
===Window enable===
----
====TMW - Main screen layer window enable ($212E write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
  ...O 4321
  ...O 4321
    | ||||
     | |||+- Apply enabled windows to main screen BG1
     | |||+- Apply enabled windows to main screen BG1
     | ||+-- Apply enabled windows to main screen BG2
     | ||+-- Apply enabled windows to main screen BG2
Line 139: Line 227:
     +------ Apply enabled windows to main screen OBJ
     +------ Apply enabled windows to main screen OBJ


===TSW - Subscreen layer window enable ($212F write)===
====TSW - Subscreen layer window enable ($212F write)====
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
  ...O 4321
  ...O 4321
    | ||||
     | |||+- Apply enabled windows to subscreen BG1
     | |||+- Apply enabled windows to subscreen BG1
     | ||+-- Apply enabled windows to subscreen BG2
     | ||+-- Apply enabled windows to subscreen BG2
Line 149: Line 238:
     +------ Apply enabled windows to subscreen OBJ
     +------ Apply enabled windows to subscreen OBJ


===SETINI - Screen Mode/Video Select ($2133 write)===
==Color math==
===CGWSEL - Color addition select ($2130 write)===
----
7  bit  0
---- ----
BBMM ..AD
||||  ||
||||  |+- Direct color mode
||||  +-- Addend (0 = fixed color, 1 = subscreen)
||++------ Color math disable region
++-------- Clip colors to black before math region
 
<B>Region types</B>
<u>Value|Region              </u>
  00 |Nowhere
  01 |Outside color window
  10 |Inside color window
  11 |Everywhere
 
===CGADSUB - Color math designation ($2131 write)===
----
7  bit  0
---- ----
MHBO 4321
|||| ||||
|||| |||+- BG1 color math enable
|||| ||+-- BG2 color math enable
|||| |+--- BG3 color math enable
|||| +---- BG4 color math enable
|||+------ OBJ color math enable
||+------- Backdrop color math enable
|+-------- Half color math
+--------- Operator type (0 = add, 1 = subtract)
 
===COLDATA - Fixed color data ($2131 write)===
----
  7  bit  0
  7  bit  0
  ---- ----
  ---- ----
  EX.. HOiI
  BGRC CCCC
  ||   ||||
  |||| ||||
||  |||+- Screen interlacing
  |||+-++++- Color value
  |||+-- OBJ interlacing
  ||+------- Write color value to blue channel
  ||+--- Overscan mode
  |+-------- Write color value to green channel
||  +---- High-res mode
  +--------- Write color value to red channel
  |+-------- EXTBG mode
  +--------- External sync

Revision as of 04:33, 4 May 2022

Display configuration

INIDISP - Screen display ($2100 write)


7  bit  0
---- ----
F... BBBB
|    ||||
|    ++++- Screen brightness (linear steps from 0 = none to $F = full)
+--------- Force blanking

BGMODE - BG mode and Character size ($2105 write)


7  bit  0
---- ----
4321 PMMM
|||| ||||
|||| |+++- BG mode
|||| +---- Mode 1 BG3 priority (0 = normal, 1 = high)
|||+------ BG1 character size (0 = 8x8, 1 = 16x16)
||+------- BG2 character size (0 = 8x8, 1 = 16x16)
|+-------- BG3 character size (0 = 8x8, 1 = 16x16)
+--------- BG4 character size (0 = 8x8, 1 = 16x16)
Mode| BG bit depth  |Offsets |     Priorities (front -> back)       |                     Notes                      
    |BG1 BG2 BG3 BG4|per tile|                                      |                                                
 0  | 2   2   2   2 |   No   |   S3 1H 2H S2 1L 2L S1 3H 4H S0 3L 4L|                                                
 1  | 4   4   2     |   No   |   S3 1H 2H S2 1L 2L S1 3H    S0 3L   |BG3 priority = 0                                
    |               |        |3H S3 1H 2H S2 1L 2L S1       S0 3L   |BG3 priority = 1                                
 2  | 4   4         |  Yes   |   S3 1H    S2 2H    S1 1L    S0 2L   |                                                
 3  | 8   4         |   No   |   S3 1H    S2 2H    S1 1L    S0 2L   |                                                
 4  | 8   2         |  Yes   |   S3 1H    S2 2H    S1 1L    S0 2L   |                                                
 5  | 4   2         |   No   |   S3 1H    S2 2H    S1 1L    S0 2L   |Fixed 16 pixel char width. Forced high-res mode.
 6  | 4             |  Yes   |   S3 1H    S2       S1 1L    S0      |Fixed 16 pixel char width. Forced high-res mode.
 7  | 8             |   No   |   S3       S2       S1 1L    S0      |Fixed 8x8 char size.                            
7EXT| 8   7         |   No   |   S3       S2 2H    S1 1L    S0 2L   |Fixed 8x8 char size. BG2 bit 7 acts as priority.

MOSAIC - Screen pixelation ($2106 write)


7  bit  0
---- ----
SSSS 4321
|||| ||||
|||| |||+- Enable BG1 mosaic
|||| ||+-- Enable BG2 mosaic
|||| |+--- Enable BG3 mosaic
|||| +---- Enable BG4 mosaic
++++------ Mosaic size in pixels (0 = 1x1, ..., 15 = 16x16)

BGxSC - BG1-4 tilemap address and size ($2107-$210A write)


7  bit  0
---- ----
AAAA AAYX
|||| ||||
|||| |||+- Horizontal tilemap count (0 = 1 tilemap, 1 = 2 tilemaps)
|||| ||+-- Vertical tilemap count (0 = 1 tilemap, 1 = 2 tilemaps)
++++-++--- Tilemap VRAM address (address = AAAAAA << 10)

CHR word base address


BG12NBA - BG1 and BG2 CHR word base address ($210B write)

7  bit  0
---- ----
BBBB AAAA
|||| ||||
|||| ++++- BG1 CHR word base address (address = AAAA << 12)
++++------ BG2 CHR word base address (address = BBBB << 12)

BG34NBA - BG3 and BG4 CHR word base address ($210C write)

7  bit  0
---- ----
DDDD CCCC
|||| ||||
|||| ++++- BG3 CHR word base address (address = CCCC << 12)
++++------ BG4 CHR word base address (address = DDDD << 12)

Layer enable


TM - Main screen layer enable ($212C write)

7  bit  0
---- ----
...O 4321
   | ||||
   | |||+- Enable BG1 on main screen
   | ||+-- Enable BG2 on main screen
   | |+--- Enable BG3 on main screen
   | +---- Enable BG4 on main screen
   +------ Enable OBJ on main screen

TS - Subscreen layer enable ($212D write)

7  bit  0
---- ----
...O 4321
   | ||||
   | |||+- Enable BG1 on subscreen
   | ||+-- Enable BG2 on subscreen
   | |+--- Enable BG3 on subscreen
   | +---- Enable BG4 on subscreen
   +------ Enable OBJ on subscreen

SETINI - Screen Mode/Video Select ($2133 write)


7  bit  0
---- ----
EX.. HOiI
||   ||||
||   |||+- Screen interlacing
||   ||+-- OBJ interlacing
||   |+--- Overscan mode
||   +---- High-res mode
|+-------- EXTBG mode
+--------- External sync

Windows

Window mask settings


W12SEL - Window Mask Settings for BG1 and BG2 ($2123 write)

7  bit  0
---- ----
DdCc BbAa
|||| ||||
|||| |||+- Invert window 1 for BG1
|||| ||+-- Enable window 1 for BG1
|||| |+--- Invert window 2 for BG1
|||| +---- Enable window 2 for BG1
|||+------ Invert window 1 for BG2
||+------- Enable window 1 for BG2
|+-------- Invert window 2 for BG2
+--------- Enable window 2 for BG2

W34SEL - Window Mask Settings for BG3 and BG4 ($2124 write)

7  bit  0
---- ----
HhGg FfEe
|||| ||||
|||| |||+- Invert window 1 for BG3
|||| ||+-- Enable window 1 for BG3
|||| |+--- Invert window 2 for BG3
|||| +---- Enable window 2 for BG3
|||+------ Invert window 1 for BG4
||+------- Enable window 1 for BG4
|+-------- Invert window 2 for BG4
+--------- Enable window 2 for BG4

WOBJSEL - Window Mask Settings for OBJ and Color Window ($2125 write)

7  bit  0
---- ----
LlKk JjIi
|||| ||||
|||| |||+- Invert window 1 for OBJ
|||| ||+-- Enable window 1 for OBJ
|||| |+--- Invert window 2 for OBJ
|||| +---- Enable window 2 for OBJ
|||+------ Invert window 1 for color math
||+------- Enable window 1 for color math
|+-------- Invert window 2 for color math
+--------- Enable window 2 for color math

Window positions


WH0 - Window 1 left position ($2126 write)

7  bit  0
---- ----
LLLL LLLL
|||| ||||
++++-++++- Window 1 left edge position

WH1 - Window 1 right position ($2127 write)

7  bit  0
---- ----
RRRR RRRR
|||| ||||
++++-++++- Window 1 right edge position

WH2 - Window 2 left position ($2128 write)

7  bit  0
---- ----
LLLL LLLL
|||| ||||
++++-++++- Window 2 left edge position

WH3 - Window 2 right position ($2129 write)

7  bit  0
---- ----
RRRR RRRR
|||| ||||
++++-++++- Window 2 left edge position

Window mask logic


WBGLOG - Window BG mask logic ($212A write)

7  bit  0
---- ----
4433 2211
|||| ||||
|||| ||++- BG1 window mask logic
|||| ++--- BG2 window mask logic
||++------ BG3 window mask logic
++-------- BG4 window mask logic

WOBJLOG - Window OBJ and color math mask logic ($212B write)

7  bit  0
---- ----
.... CCOO
     ||||
     ||++- OBJ window mask logic
     ++--- Color window mask logic
Mask logic types
Value|Logic
  00 | OR
  01 | AND
  10 | XOR
  11 | XNOR

Window enable


TMW - Main screen layer window enable ($212E write)

7  bit  0
---- ----
...O 4321
   | ||||
   | |||+- Apply enabled windows to main screen BG1
   | ||+-- Apply enabled windows to main screen BG2
   | |+--- Apply enabled windows to main screen BG3
   | +---- Apply enabled windows to main screen BG4
   +------ Apply enabled windows to main screen OBJ

TSW - Subscreen layer window enable ($212F write)

7  bit  0
---- ----
...O 4321
   | ||||
   | |||+- Apply enabled windows to subscreen BG1
   | ||+-- Apply enabled windows to subscreen BG2
   | |+--- Apply enabled windows to subscreen BG3
   | +---- Apply enabled windows to subscreen BG4
   +------ Apply enabled windows to subscreen OBJ

Color math

CGWSEL - Color addition select ($2130 write)


7  bit  0
---- ----
BBMM ..AD
||||   ||
||||   |+- Direct color mode
||||   +-- Addend (0 = fixed color, 1 = subscreen)
||++------ Color math disable region
++-------- Clip colors to black before math region
Region types
Value|Region               
  00 |Nowhere
  01 |Outside color window
  10 |Inside color window
  11 |Everywhere

CGADSUB - Color math designation ($2131 write)


7  bit  0
---- ----
MHBO 4321
|||| ||||
|||| |||+- BG1 color math enable
|||| ||+-- BG2 color math enable
|||| |+--- BG3 color math enable
|||| +---- BG4 color math enable
|||+------ OBJ color math enable
||+------- Backdrop color math enable
|+-------- Half color math
+--------- Operator type (0 = add, 1 = subtract)

COLDATA - Fixed color data ($2131 write)


7  bit  0
---- ----
BGRC CCCC
|||| ||||
|||+-++++- Color value
||+------- Write color value to blue channel
|+-------- Write color value to green channel
+--------- Write color value to red channel