Changes

Jump to navigation Jump to search
3,880 bytes added ,  15:09, 5 July 2019
Line 2: Line 2:     
== Map ==
 
== Map ==
 +
Address mappings for the external registers. GSPGPU:WriteHWRegs takes these addresses relative to 0x1EB00000.
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
! User VA
 
! User VA
Line 74: Line 75:  
| [[#Transfer_Engine|Transfer Engine]] "DMA"
 
| [[#Transfer_Engine|Transfer Engine]] "DMA"
 
|
 
|
 +
|-
 +
|colspan="5"| 0x1EF01000/0x10401000 - 0x1EF01C00/0x10401C00 maps to [[GPU/Internal_Registers|GPU internal registers]]. These registers are usually not read/written directly here, but are written using the command list interface below (corresponding to the GPUREG_CMDBUF_* internal registers)
 
|-
 
|-
 
| 0x1EF01000
 
| 0x1EF01000
Line 135: Line 138:     
== LCD Source Framebuffer Setup ==
 
== LCD Source Framebuffer Setup ==
 +
 +
All of these registers must be accessed with 32bit operations regardless of the registers' actual bit size.
 +
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
 
! Offset
 
! Offset
! Length
   
! Name
 
! Name
 
! Comments
 
! Comments
 
|-
 
|-
 
| 0x00
 
| 0x00
| 4
+
| Pixel clock
| Pixel timer (not pixel clock)
+
| Higher values are slower, 12bits.
| Higher values are slower, min. 0x1C1, bitmask 0xFFF
+
 
 +
Setting this value too low will make the screen not be able to sync any pixels other than a single one from the wrong location. The lowest the screen can handle is 0x1C2, at 0x1C1 the display loses a few scanlines worth of pixel clock (though not noticable).
 
|-
 
|-
 
| 0x04
 
| 0x04
| 4
+
| HBlank timer(?)
| VScanStart(?)
+
| Seems to determine the horizontal blanking interval.
| Values 0xD1-0x1C1 inclusive are valid (except 2DS bottom screen)
+
 
min. 0xD1, bitmask 0xFFF
+
 
 +
Setting this to lower than <code>HTotal - HDisp</code> will make the screen not catch up with the scanlines, some will be skipped, some will be misaligned.
 +
 
 +
Setting this to higher than <code>HTotal - HDisp</code> will make the displayed image misaligned to the right.
 +
 
 +
Setting this to higher than <code>HTotal</code> seems to make the horizontal synchronization never happen.
 
|-
 
|-
 
| 0x08
 
| 0x08
| 4
   
| ?
 
| ?
|  
+
| must be >= REG#0x00
 
|-
 
|-
 
| 0x0C
 
| 0x0C
| 4
   
| ?
 
| ?
|  
+
| must be >= REG#0x08
 
|-
 
|-
 
| 0x10
 
| 0x10
| 4
+
| Window X start (LgyFb)
| VAdjustGranule
+
| Offsets the viewing window on the display's physical X co-ordinate relative to its front porch end.
 
  −
or
  −
HAdjust(2DS bottom screen)
  −
| Finetune vertical pixel offset, 0x1C2 max = half pixel
     −
or
+
Outside of LgyFb changing this value only seems to cause weird pixel interpolation and blurryness.
offset the bottom screen (0 to kill 2DS top screen, 0x1C2 max on bottom screen)
   
|-
 
|-
 
| 0x14
 
| 0x14
| 4
+
| Window X end (LgyFb)
| HEndOffset(?) (poor 2DS emulation)
+
| Window X start + window width - 1 is written here to set the end display scan pixel offset.
| Moves the frame left/right(after some conditions are met)
     −
default value is 0xCF
+
Outside of LgyFb it seems to offset the screen to the left if this value is high enough, but can glitch out the syncing on the bottom screen. High enough values will make the screen skip too many "pixels". If this value is higher or equal to *some value* (aka. if less than one pixel per line is displayed on the screen) then the screen will lose synchronization.
 
|-
 
|-
 
| 0x18
 
| 0x18
| 4
+
| Window Y start (LgyFb)
| ???
+
| Offsets the viewing window on the display's physical Y co-ordinate relative to the first visible scanline.
|  
   
|-
 
|-
 
| 0x20
 
| 0x20
| 4
+
| Low: Window Y end (LgyFb)
| ?
+
High: ???
| ??? the screen gets vertically offset with wrap-around
+
| Low: Window Y start + window height - 1 is written here to set the last display scanline relative to the first visible scanline.
horizontal timing gets messed up
+
 
 +
High: This is cleared to zero when displaying LgyFb. Outside of LgyFb this doesn't really seem to do anything useful.
 +
 
 +
 
 +
??? extra pixels get inserted in the first displayed scanline and thus the image gets shifted to the right. Seems to make horizontal syncing a bit glitchy. If a HSync occurs, the pixel data is suspended until the first pixel is supposed to be displayed, then the pixel stream will continue where it left off until a delayed HSync gets processed relative to the pixel data.
 
|-
 
|-
 
| 0x24
 
| 0x24
| 4
+
| Low: ???
| HSync timer?
+
High: ???
|  
+
| The low 12bit halfword seems to affect:
 +
 
 +
- the total amount of scanlines displayed
 +
 
 +
- vertical pixel data offset if the GPU can't VSync properly
 +
 
 +
- VSync length
 
|-
 
|-
 
| 0x28
 
| 0x28
| 4
+
| VBlank timer(?)
| VStart(?)
+
| Seems to determine the vertical blanking interval.
|
+
 
 +
 
 +
Setting this to lower than <code>VTotal - VDisp</code> will cut off the top <code>VTotal - VDisp - thisvalue</code> lines.
 +
 
 +
Setting this to higher than <code>VTotal - VDisp</code> will make the image be pushed downwards with the overscan color visible.
 +
 
 +
Setting this to higher than <code>HTotal</code> will make the GPU skip vertical pixel data synchronization (hence filling the screen with the rest of the pixel data past the given screen framebuffer size). Also will skip <code>thisvalue + somevalue - HTotal</code> lines into the "global" pixel buffer.
 
|-
 
|-
 
| 0x30
 
| 0x30
| 4
   
| VTotal
 
| VTotal
| Total amount of vertical scanlines
+
| Total amount of vertical scanlines in the pixel buffer, must be bigger than *an unknown blanking-like value*. If this value is less than VDisp then the last two scanlines will be repeated interlaced until VDisp is reached.
 
|-
 
|-
 
| 0x34
 
| 0x34
| 4
+
| VDisp(?)
| VDisp
+
| Total amonut of vertical scanlines displayed (only for top screen it seems like). If this value is less than VTotal then the rest of the scanlines will not be updated on the screen, so those will slowly fade out. Must be bigger than *an unknown blanking-like value*, otherwise an underflow will happen.
| Total amonut of vertical scanlines displayed
+
|-
 +
| 0x38
 +
| Vertical data offset(?)
 +
| ??? Seems to offset the screen upwards if this value is high enough. If this value is higher or equal to *some value* (aka. if less than one scanline is displayed on the screen) then the screen will lose synchronization.
 
|-
 
|-
 
| 0x44
 
| 0x44
| 4
   
| ???
 
| ???
 
| similar functionality to 0x10
 
| similar functionality to 0x10
 +
|-
 +
| 0x48
 +
| ???
 +
| bit0 seems to disable HSync, bit8 seems to disable VSync, rest of the bits aren't writable.
 
|-
 
|-
 
| 0x4C
 
| 0x4C
| 4
   
| Overscan filler color
 
| Overscan filler color
 
|  
 
|  
 
|-
 
|-
 
| 0x50
 
| 0x50
| 4
+
| Horizontal position counter
| Vertical scanline counter
   
| read-only
 
| read-only
 
|-
 
|-
 
| 0x54
 
| 0x54
| 4
+
| Horizontal scanline (HBlank) counter
| Horizontal scanline counter
   
| read-only
 
| read-only
 
|-
 
|-
 
| 0x5C
 
| 0x5C
| 4
   
| ???
 
| ???
 
| low u16: framebuffer width
 
| low u16: framebuffer width
Line 238: Line 257:  
|-
 
|-
 
| 0x60
 
| 0x60
| 4
   
| ???
 
| ???
 
| low u16: timing data(?)
 
| low u16: timing data(?)
Line 244: Line 262:  
|-
 
|-
 
| 0x64
 
| 0x64
| 4
   
| ???
 
| ???
 
| low u16: unknown
 
| low u16: unknown
Line 250: Line 267:  
|-
 
|-
 
| 0x68
 
| 0x68
| 4
   
| Framebuffer A first address
 
| Framebuffer A first address
 
| For top screen, this is the left eye 3D framebuffer.
 
| For top screen, this is the left eye 3D framebuffer.
 
|-
 
|-
 
| 0x6C
 
| 0x6C
| 4
   
| Framebuffer A second address
 
| Framebuffer A second address
 
| For top screen, this is the left eye 3D framebuffer.
 
| For top screen, this is the left eye 3D framebuffer.
 
|-
 
|-
 
| 0x70
 
| 0x70
| 4
   
| Framebuffer format
 
| Framebuffer format
 
| Bit0-15: framebuffer format, bit16-31: unknown
 
| Bit0-15: framebuffer format, bit16-31: unknown
 
|-
 
|-
 
| 0x78
 
| 0x78
| 4
   
| Framebuffer select
 
| Framebuffer select
 
| Bit0: which framebuffer to display, bit1-7: unknown
 
| Bit0: which framebuffer to display, bit1-7: unknown
 +
|-
 +
| 0x80
 +
| Color lookup table index select
 +
| 8bits, write-only
 
|-
 
|-
 
| 0x84
 
| 0x84
| 4
+
| Color lookup table indexed element
| Color adjustment register
+
| Contains the value of the color lookup table indexed by the above register, 24bits, RGB8 (0x00BBGGRR) 
| Each poke changes the color blended over the screens content randomly.
+
Accessing this register will increase the index register by one
 
|-
 
|-
 
| 0x90
 
| 0x90
| 4
   
| Framebuffer stride
 
| Framebuffer stride
 
| Distance in bytes between the start of two framebuffer rows (must be a multiple of 8).
 
| Distance in bytes between the start of two framebuffer rows (must be a multiple of 8).
 
|-
 
|-
 
| 0x94
 
| 0x94
| 4
   
| Framebuffer B first address
 
| Framebuffer B first address
 
| For top screen, this is the right eye 3D framebuffer. Unused for bottom screen.
 
| For top screen, this is the right eye 3D framebuffer. Unused for bottom screen.
 
|-
 
|-
 
| 0x98
 
| 0x98
| 4
   
| Framebuffer B second address
 
| Framebuffer B second address
 
| For top screen, this is the right eye 3D framebuffer. Unused for bottom screen.
 
| For top screen, this is the right eye 3D framebuffer. Unused for bottom screen.
Line 379: Line 393:  
|-
 
|-
 
| 0x1EF00C24
 
| 0x1EF00C24
| TextureCopy input line width (bits 0-15) and gap (bits 16-31), in 16 bytes.
+
| TextureCopy input line width (bits 0-15) and gap (bits 16-31), in 16 byte units.
 
|-
 
|-
 
| 0x1EF00C28
 
| 0x1EF00C28
Line 440: Line 454:  
=== TextureCopy ===
 
=== TextureCopy ===
   −
When bit 3 of the control register is set, the hardware performs a TextureCopy-mode transfer. In this mode, all other bits of the control register (except for bit 2, which still needs to be set correctly) and the regular dimension registers are ignored, and no format conversions are done. Instead, it performs a raw data copy from the source to the destination, but with a configurable gap between lines. The total amount of bytes to copy is specified in the size register, and the hardware loops reading lines from the input and writing them to the output until this amount is copied. The "gap" specified in the input/output dimension register is the number of 16 bytes to skip after each "width" 16 bytes of the input/output, and is NOT counted towards the total size of the transfer.
+
When bit 3 of the control register is set, the hardware performs a TextureCopy-mode transfer. In this mode, all other bits of the control register (except for bit 2, which still needs to be set correctly) and the regular dimension registers are ignored, and no format conversions are done. Instead, it performs a raw data copy from the source to the destination, but with a configurable gap between lines. The total amount of bytes to copy is specified in the size register, and the hardware loops reading lines from the input and writing them to the output until this amount is copied. The "gap" specified in the input/output dimension register is the number of chunks to skip after each "width" chunks of the input/output, and is NOT counted towards the total size of the transfer.
    
By correctly calculating the input and output gap sizes it is possible to use this functionality to copy arbitrary sub-rectangles between differently-sized framebuffers or textures, which is one of its main uses over a regular no-conversion DisplayTransfer. When copying tiled textures/framebuffers it's important to remember that the contents of a tile are laid out sequentially in memory, and so this should be taken into account when calculating the transfer parameters.
 
By correctly calculating the input and output gap sizes it is possible to use this functionality to copy arbitrary sub-rectangles between differently-sized framebuffers or textures, which is one of its main uses over a regular no-conversion DisplayTransfer. When copying tiled textures/framebuffers it's important to remember that the contents of a tile are laid out sequentially in memory, and so this should be taken into account when calculating the transfer parameters.
215

edits

Navigation menu