|
|
(41 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
| The WonderSwan's display functionality generally consists of: | | The WonderSwan features a 224x144 display capable of displaying up to 16 shades of gray (mono) or 4096 colors (color). |
|
| |
|
| * a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
| | {| class="wikitable" |
| ** up to sixteen distinct shades of gray
| | ! ↑ Front ↑ |
| ** 12-bit RGB444 color<sup>(color)</sup>
| | ! Window |
| * two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
| | ! Scroll |
| * a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
| | |- |
| * six LCD icons to the bottom or right of the display, usable as additional indicators.
| | | align="center" | Sprites, high priority |
| | | ✔ |
| | | |
| | |- |
| | | align="center" | Screen 2 |
| | | ✔ |
| | | ✔ |
| | |- |
| | | align="center" | Sprites, low priority |
| | | ✔ |
| | | |
| | |- |
| | | align="center" | Screen 1 |
| | | |
| | | ✔ |
| | |- |
| | | align="center" | Background color |
| | | |
| | | |
| | |- |
| | ! ↑ Back ↑ |
| | ! Window |
| | ! Scroll |
| | |} |
|
| |
|
| == Components == | | == Features == |
| | |
| === Tiles ===
| |
| | |
| The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
| |
| | |
| The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
| |
| | |
| <pre>
| |
| plane 0 plane 1
| |
| byte N byte N+1
| |
| 7 bit 0 7 bit 0 full tile
| |
| ---- ---- ---- ----
| |
| .... ...1 .222 22.. .22222.1
| |
| .... ...1 2222 22.. 222222.1
| |
| .... .... 22.. .... 22......
| |
| ...1 1... 22.2 2... --\ 22.33...
| |
| ...1 1... 22.2 2... --/ 22.33...
| |
| .... .... 22.. .... 22......
| |
| .... .... .... .... ........
| |
| 11.. .... .... .... 11......
| |
| </pre>
| |
| | |
| The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
| |
| | |
| * The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
| |
| | |
| The latter two modes extend tiles to four bits per pixel.
| |
| | |
| * The first among them is the planar mode, which works similarly to the two bit per pixel mode:
| |
| | |
| <pre>
| |
| plane 0 plane 1 plane 2 plane 3
| |
| byte N byte N+1 byte N+2 byte N+3
| |
| 7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
| |
| ---- ---- ---- ---- ---- ---- ---- ----
| |
| 1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
| |
| .1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
| |
| </pre>
| |
| | |
| * The second is the chunky (packed) mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
| |
| | |
| <pre>
| |
| byte N byte N+1 byte N+2 byte N+3
| |
| pxl0 pxl1 pxl2 pxl3 pxl4 pxl5 pxl6 pxl7
| |
| 7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
| |
| ---- ---- ---- ---- ---- ---- ---- ----
| |
| .42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
| |
| 8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
| |
| </pre>
| |
| | |
| === Colors, Shades ===
| |
| | |
| The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
| |
| | |
| <pre>
| |
| Palette Global shade LUT
| |
| 1 ===========> 2 ==========================> 5
| |
| ^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| |
| | | |
| |
| Tile pixel Value Displayed shade
| |
| </pre>
| |
| | |
| In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
| |
| | |
| <pre>
| |
| 15 bit 8 7 bit 0
| |
| ---- ---- ---- ----
| |
| .... rrrr gggg bbbb
| |
| |||| |||| ||||
| |
| |||| |||| ++++- Blue (0-15)
| |
| |||| ++++------ Green (0-15)
| |
| ++++------------ Red (0-15)
| |
| </pre>
| |
| | |
| No further processing or look-up tables are applied.
| |
| | |
| === Palettes ===
| |
| | |
| The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
| |
| | |
| In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
| |
| | |
| In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
| |
| | |
| Palettes 8-15 are also referred to as sprite palettes 0-7.
| |
|
| |
|
| === Screens === | | === Screens === |
|
| |
|
| The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
| | Screens are 32x32 tile maps, for a total of 256x256 pixels; each map entry can use one of 512 (mono) or 1024 (color) tiles, one of sixteen distinct palettes, as well as be drawn mirrored or flipped. The screens can be scrolled horizontally and vertically. |
| | |
| <pre>
| |
| 15 bit 8 7 bit 0
| |
| ---- ---- ---- ----
| |
| vhbp pppt tttt tttt
| |
| |||| |||| |||| ||||
| |
| |||| |||+--++++-++++- Tile index (0-511)
| |
| |||+-+++------------- Palette (0-15)
| |
| ||+------------------ Tile bank (0-1) - color only
| |
| |+------------------- Horizontal flip
| |
| +-------------------- Vertical flip
| |
| </pre>
| |
|
| |
|
| === Sprites === | | === Sprites === |
|
| |
|
| The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries: | | The sprite layer consists of 128 distinct sprites. These can use any of the first 512 tiles, palettes 8 through 15, as well as be drawn over or under screen 2. |
|
| |
|
| <pre>
| | Each scanline can display up to 32 sprites at a time; these will be the first 32 sprites found on the list for the given scanline. Sprites are then drawn in order from last to first. |
| (Byte 1) (Byte 0)
| |
| 15 bit 8 7 bit 0
| |
| ---- ---- ---- ----
| |
| vhPi pppt tttt tttt
| |
| |||| |||| |||| ||||
| |
| |||| |||+--++++-++++- Tile index (0-511) - only bank 0
| |
| |||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
| |
| |||+----------------- Window location - 0 = inside, 1 = outside
| |
| ||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
| |
| |+------------------- Horizontal flip
| |
| +-------------------- Vertical flip
| |
|
| |
|
| (Byte 2)
| | === Windows === |
| 7 bit 0
| |
| ---- ----
| |
| yyyy yyyy
| |
| |||| ||||
| |
| ++++-++++- Y coordinate
| |
|
| |
|
| (Byte 3)
| | The window functionality can be used to restrict drawing of Screen 2's tiles, as well as the sprite layer, to a given pixel-perfect window. Individual sprites can be marked as being drawn inside or outside the window. |
| 7 bit 0
| |
| ---- ----
| |
| xxxx xxxx
| |
| |||| ||||
| |
| ++++-++++- X coordinate
| |
| </pre>
| |
|
| |
|
| For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
| | === Palettes === |
|
| |
|
| === Visibility priority ===
| | Each palette consists of four colors, of which the first entry - color zero - is opaque in palettes 0-3 and 8-11 and transparent otherwise. The color models additionally feature a sixteen-color palette mode, in which color zero is always considered transparent. The background color is displayed if no ''opaque'' pixel from any screens or sprites is drawn. |
| | |
| For display components, the visibility priority is as follows:
| |
| | |
| * Sprite 0, high priority
| |
| * Sprite 127, high priority
| |
| * Screen 2
| |
| * Sprite 0, low priority
| |
| * Sprite 127, low priority
| |
| * Screen 1
| |
| * Background color
| |
| | |
| === Windows ===
| |
| | |
| Screen 2 and the sprite layer can optionally be restricted to a specific window.
| |
| | |
| In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
| |
|
| |
|
| === Icons === | | === Icons === |
|
| |
|
| Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
| | In addition, a set of LCD segment-based icons is provided to a side of the display which can be independently controlled as an indicator to the user. |
| | |
| * Aux 3 - large circle,
| |
| * Aux 2 - medium circle,
| |
| * Aux 1 - small circle,
| |
| * Horizontal orientation,
| |
| * Vertical orientation,
| |
| * Sleep.
| |
|
| |
|
| == Interrupts == | | == Interrupts == |
Line 183: |
Line 64: |
| It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts. | | It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts. |
|
| |
|
| == I/O ports == | | == More information == |
| | |
| {{Anchor|Display Control}}
| |
| === Display Control ($00) ===
| |
| | |
| <pre>
| |
| 7 bit 0
| |
| ---- ----
| |
| ..ow Ws21
| |
| || ||||
| |
| || |||+- Enable Screen 1 layer
| |
| || ||+-- Enable Screen 2 layer
| |
| || |+--- Enable Sprite layer
| |
| || +---- Enable Sprite window
| |
| |+------ Enable Screen 2 window
| |
| +------- Screen 2 window location:
| |
| 0 = inside, 1 = outside
| |
| </pre>
| |
| | |
| {{Anchor|Display Background}}
| |
| === Display Background Color ($01) ===
| |
| | |
| <pre>
| |
| (mono) (color)
| |
| 7 bit 0 7 bit 0
| |
| ---- ---- ---- ----
| |
| .... .sss pppp iiii
| |
| ||| |||| ||||
| |
| +++- Value |||| ++++- Index in palette (0-15)
| |
| (0-7) ++++------ Color palette (0-15)
| |
| </pre>
| |
| | |
| {{Anchor|Display Current Line}}
| |
| === Display Current Line ($02 read) ===
| |
| | |
| The current line being drawn by the display.
| |
| | |
| Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
| |
| | |
| {{Anchor|Display Interrupt Line}}
| |
| === Display Interrupt Line ($03) ===
| |
| | |
| The line to emit an interrupt on.
| |
| | |
| {{Anchor|Sprite Table Address}}
| |
| === Sprite Table Address ($04) ===
| |
| | |
| <pre>
| |
| 7 bit 0
| |
| ---- ----
| |
| ..Aa aaaa
| |
| || ||||
| |
| |+-++++- Address (bits 9-13)
| |
| +------- Address (bit 14) - color only
| |
| </pre>
| |
| | |
| {{Anchor|Sprite Table First}}
| |
| === Sprite Table First ($05) ===
| |
| | |
| <pre>
| |
| 7 bit 0
| |
| ---- ----
| |
| .iii iiii
| |
| ||| ||||
| |
| +++-++++- Index of first sprite entry to draw (0-127)
| |
| </pre>
| |
| | |
| {{Anchor|Sprite Table Count}}
| |
| === Sprite Table Count ($06) ===
| |
| | |
| <pre>
| |
| 7 bit 0
| |
| ---- ----
| |
| cccc cccc
| |
| |||| ||||
| |
| ++++-++++- Count of sprite entries to draw (1-128)
| |
| </pre>
| |
| | |
| {{Anchor|Screen Address}}
| |
| === Screen Address ($07) ===
| |
| | |
| <pre>
| |
| 7 bit 0
| |
| ---- ----
| |
| 2222 1111
| |
| |||| ||||
| |
| |||| |+++- Screen 1 address (bits 11-13)
| |
| |||| +---- Screen 1 address (bit 14) - color only
| |
| |+++------ Screen 2 address (bits 11-13)
| |
| +--------- Screen 2 address (bit 14) - color only
| |
| </pre>
| |
| | |
| {{Anchor|Screen 2 Window}}
| |
| === Screen 2 Window Left ($08) ===
| |
| === Screen 2 Window Top ($09) ===
| |
| === Screen 2 Window Right ($0A) ===
| |
| === Screen 2 Window Bottom ($0B) ===
| |
| | |
| {{Anchor|Sprite Window}}
| |
| === Sprite Window Left ($0C) ===
| |
| === Sprite Window Top ($0D) ===
| |
| === Sprite Window Right ($0E) ===
| |
| === Sprite Window Bottom ($0F) ===
| |
| | |
| {{Anchor|Screen Scroll}}
| |
| === Screen 1 Scroll X ($10) ===
| |
| === Screen 1 Scroll Y ($11) ===
| |
| === Screen 2 Scroll X ($12) ===
| |
| === Screen 2 Scroll Y ($13) ===
| |
| | |
| {{Anchor|LCD Control}}
| |
| === LCD Control ($14) ===
| |
| | |
| <pre>
| |
| 7 bit 0
| |
| ---- ----
| |
| .... ..Ce
| |
| ||
| |
| |+- LCD Enable: 0 = sleep, 1 = enabled
| |
| +-- Contrast (WSC): 0 = low, 1 = high
| |
| </pre>
| |
| | |
| {{Anchor|LCD Icon Control}}
| |
| === LCD Icon Control ($15) ===
| |
| | |
| <pre>
| |
| 7 bit 0
| |
| ---- ----
| |
| ..32 1hvs
| |
| || ||||
| |
| || |||+- Sleep
| |
| || ||+-- Vertical orientation
| |
| || |+--- Horizontal orientation
| |
| || +---- Aux 1
| |
| |+------ Aux 2
| |
| +------- Aux 3
| |
| </pre>
| |
| | |
| | |
| {{Anchor|LCD Mono Shade LUT}}
| |
| === LCD Mono Shade LUT ($1C-$1F) ===
| |
| | |
| <pre>
| |
| $1C $1D $1E $1F
| |
| 7 bit 0 7 bit 0 7 bit 0 7 bit 0
| |
| ---- ---- ---- ---- ---- ---- ---- ----
| |
| 1111 0000 3333 2222 5555 4444 7777 6666
| |
| </pre>
| |
| | |
| {{Anchor|LCD Mono Palette}}
| |
| === LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
| |
| | |
| The monochrome palette is laid out as sixteen words:
| |
| | |
| <pre>
| |
| N+1 N
| |
| 15 bit 8 7 bit 0
| |
| ---- ---- ---- ----
| |
| .333 .222 .111 .000
| |
| ||| ||| ||| |||
| |
| ||| ||| ||| +++- Shade LUT index for color 0
| |
| ||| ||| +++------ Shade LUT index for color 1
| |
| ||| +++------------ Shade LUT index for color 2
| |
| +++----------------- Shade LUT index for color 3
| |
| </pre>
| |
| | |
| == Internal I/O ports ==
| |
| | |
| These I/O ports are said to be internal and not intended for use by commercial games.
| |
| | |
| {{Anchor|LCD Final Line}}
| |
| === LCD Final Line ($16) ===
| |
| | |
| The final line preceding line counter restart. By default, this should be set to 158.
| |
| | |
| It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
| |
| | |
| {{Anchor|LCD Back Porch Line}}
| |
| === LCD Back Porch Line ($17, WSC only) ===
| |
| | |
| This port is available on the WonderSwan Color only - not the SwanCrystal!
| |
| | |
| The final line preceding the vertical back porch; by default, this should be set to 155.
| |
| | |
| The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
| |
| | |
| Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
| |
| | |
| {{Anchor|LCD Status}}
| |
| === LCD Status ($1A) ===
| |
| | |
| <pre>
| |
| 7 bit 0
| |
| ---- ----
| |
| ...v vv.s
| |
| | || |
| |
| | || +- LCD sleep: 0 = no, 1 = sleep
| |
| | ||
| |
| | || Volume segments:
| |
| | |+--- Volume B (medium, high)
| |
| | +---- Volume A (low, high)
| |
| +------ Speaker
| |
| </pre>
| |
| | |
| === TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
| |
| | |
| These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
| |
| | |
| They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
| |
|
| |
|
| == Notes ==
| | * [[Display/Tile Data|Tile data]] |
| <references />
| | * [[Display/Palette|Color palette]] |
| | * [[Display/Screens|Screen format]] |
| | * [[Display/Sprites|Sprite format]] |
| | * [[Display/Windows|Windows]] |
| | * [[Display/LCD Icons|LCD icons]] |
| | * [[Display/IO Ports|I/O ports]] |