|
|
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),
| | |- |
| * a bar of LCD icon segments to the bottom (WS) or right (WSC/SC) 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 ↑ |
| | ! |
| | ! |
| | |} |
|
| |
|
| == Components == | | == Features == |
|
| |
|
| === Tiles ===
| | Screens are 32x32 tile maps; 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 WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel. | | 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. |
|
| |
|
| The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel. | | 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. |
|
| |
|
| ==== 2 bits per pixel, planar ====
| | 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. |
|
| |
|
| The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
| | 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. |
| | |
| <pre>
| |
| tile data (16 bytes)
| |
| 01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
| |
| | |
| ||
| |
| \/
| |
| | |
| plane 0 plane 1
| |
| 7 bit 0 7 bit 0 full tile
| |
| ---- ---- ---- ----
| |
| .... ...1 = 01 .222 22.. = 7C .22222.1
| |
| .... ...1 = 01 2222 22.. = FC 222222.1
| |
| .... .... = 00 22.. .... = C0 22......
| |
| ...1 1... = 18 22.2 2... = D8 --\ 22.33...
| |
| ...1 1... = 18 22.2 2... = D8 --/ 22.33...
| |
| .... .... = 00 22.. .... = C0 22......
| |
| .... .... = 00 .... .... = 00 ........
| |
| 11.. .... = C0 .... .... = 00 11......
| |
| </pre>
| |
| | |
| This matches the format used by the Game Boy.
| |
| | |
| ==== 4 bits per pixel, planar ====
| |
| | |
| This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
| |
| | |
| | |
| <pre>
| |
| tile data (32 bytes)
| |
| 54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
| |
| | |
| ||
| |
| \/
| |
| | |
| plane 0 plane 1 plane 2 plane 3
| |
| 7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
| |
| ---- ---- ---- ---- ---- ---- ---- ----
| |
| .1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
| |
| .1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
| |
| .1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
| |
| .1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
| |
| .... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
| |
| 1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
| |
| .... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
| |
| .... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
| |
| </pre>
| |
| | |
| This format matches the one used by the Sega Master System and Game Gear family of consoles.
| |
| | |
| ==== 4 bits per pixel, packed ====
| |
| | |
| Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
| |
| | |
| <pre>
| |
| tile data (32 bytes)
| |
| 01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
| |
| | |
| ||
| |
| \/
| |
| | |
| byte 0 1 2 3
| |
| bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
| |
| pixel 0 1 2 3 4 5 6 7 full tile
| |
| --- --- --- --- --- --- --- ---
| |
| . 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
| |
| 4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
| |
| 8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
| |
| C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
| |
| . . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
| |
| 1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
| |
| 2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
| |
| 4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
| |
| </pre>
| |
| | |
| This format matches the one used by the Mega Drive console.
| |
| | |
| === Palettes ===
| |
| | |
| The display system provides sixteen different palettes that can be used to color or shade tiles.
| |
| | |
| * Palettes 0-7 can be used for the two screens only;
| |
| * Palettes 8-15 can be used for both screens and sprites.
| |
| | |
| ==== Mono ====
| |
| | |
| In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table: | |
| | |
| <pre>
| |
| Palette Global shade LUT
| |
| 1 ===========> 2 ==========================> 5
| |
| ^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| |
| | | |
| |
| Palette index Value Displayed shade
| |
| </pre>
| |
| | |
| The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
| |
| | |
| ==== Color ====
| |
| | |
| In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
| |
| | |
| <pre>
| |
| Address
| |
| 15 bit 8 7 bit 0
| |
| ---- ---- ---- ----
| |
| 1111 111p pppi iii.
| |
| | |||| |||
| |
| | |||+-+++-- Index in palette (0-15)
| |
| +--+++------- Palette number (0-15)
| |
| | |
| Data
| |
| 15 bit 8 7 bit 0
| |
| ---- ---- ---- ----
| |
| .... rrrr gggg bbbb
| |
| |||| |||| ||||
| |
| |||| |||| ++++- Blue (0-15)
| |
| |||| ++++------ Green (0-15)
| |
| ++++------------ Red (0-15)
| |
| </pre>
| |
| | |
| In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
| |
| | |
| ==== Transparency ====
| |
| | |
| In two bit per pixel modes:
| |
| | |
| * Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
| |
| * Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
| |
| | |
| In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
| |
| | |
| === Background color ===
| |
| | |
| The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
| |
| | |
| * In mono modes, it is set to an entry in the shade lookup table (0-7),
| |
| * In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
| |
| | |
| === Screens ===
| |
| | |
| A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
| |
| | |
| The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
| |
| | |
| The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
| |
| | |
| <pre>
| |
| Address
| |
| 15 bit 8 7 bit 0
| |
| ---- ---- ---- ----
| |
| 0bbb byyy yyxx xxx.
| |
| ||| |||| |||| |||
| |
| ||| |||| ||++-+++-- X coordinate (0-31)
| |
| ||| |+++--++-------- Y coordinate (0-31)
| |
| +++-+--------------- Base address (from I/O port)
| |
| | |
| Data
| |
| 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>
| |
| | |
| In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
| |
| | |
| === Sprites ===
| |
| | |
| The display system can show up to 128 sprites at once.
| |
| | |
| Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
| |
| | |
| Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
| |
| | |
| <pre>
| |
| (Byte 1) (Byte 0)
| |
| 15 bit 8 7 bit 0
| |
| ---- ---- ---- ----
| |
| vhPi pppt tttt tttt
| |
| |||| |||| |||| ||||
| |
| |||| |||+--++++-++++- Tile index (0-511) - only tile 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)
| |
| 7 bit 0
| |
| ---- ----
| |
| yyyy yyyy
| |
| |||| ||||
| |
| ++++-++++- Y coordinate
| |
| | |
| (Byte 3)
| |
| 7 bit 0
| |
| ---- ----
| |
| xxxx xxxx
| |
| |||| ||||
| |
| ++++-++++- X coordinate
| |
| </pre>
| |
| | |
| There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
| |
| | |
| The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
| |
| | |
| === Visibility priority ===
| |
| | |
| 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 sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
| |
| | |
| Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
| |
| | |
| === Icons ===
| |
| | |
| The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
| |
| | |
| * [[#LCD_Icon_Control_($15)|Six under control of software]]
| |
| ** Large circle
| |
| ** Medium circle
| |
| ** Small circle
| |
| ** Horizontal orientation
| |
| ** Vertical orientation
| |
| ** (Shooting) Star (Sleep)
| |
| | |
| * [[#LCD_Status_($1A)|Four software can query]]
| |
| ** Speaker
| |
| ** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
| |
| ** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
| |
| ** Headphones
| |
| | |
| * [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
| |
| ** Low battery
| |
| | |
| * Two that are entirely invisible to software
| |
| ** Power on ("Egg", resembles the mono power switch)
| |
| ** Cartridge
| |
|
| |
|
| == Interrupts == | | == Interrupts == |
Line 282: |
Line 52: |
| 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. |
|
| |
|
| == See also == | | == More information == |
|
| |
|
| * [[Display/IO Ports|Display I/O ports]] | | * [[Display/Tile Data|Tile data]] |
| | * [[Display/Palettes|Color palettes]] |
| | * [[Display/Screens|Screen format]] |
| | * [[Display/Sprites|Sprite format]] |
| | * [[Display/LCD Icons|LCD icons]] |
| | * [[Display/IO Ports|I/O ports]] |