Display/IO Ports
Graphics I/O ports
Display Control ($00)
7 bit 0 ---- ---- ..wo Ws21 || |||| || |||+- Enable Screen 1 layer || ||+-- Enable Screen 2 layer || |+--- Enable Sprite layer || +---- Enable Sprite window |+------ Screen 2 tiles are drawn (if window enabled): | 0 = inside window, | 1 = outside window. +------- Enable Screen 2 window
Display Background Color ($01)
(mono) (color) 7 bit 0 7 bit 0 ---- ---- ---- ---- .... .sss pppp iiii ||| |||| |||| +++- Value |||| ++++- Index in palette (0-15) (0-7) ++++------ Color palette (0-15)
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 current line == 1
will actually affect line 0.
Display Interrupt Line ($03)
The line to emit an interrupt on.
Sprite Table Address ($04)
7 bit 0 ---- ---- ..Aa aaaa || |||| |+-++++- Address (bits 9-13) +------- Address (bit 14) - color only
Sprite Table First ($05)
7 bit 0 ---- ---- .iii iiii ||| |||| +++-++++- Index of first sprite entry to draw (0-127)
Sprite Table Count ($06)
7 bit 0 ---- ---- cccc cccc |||| |||| ++++-++++- Count of sprite entries to draw (1-128)
Screen Address ($07)
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
Screen 2 Window Left ($08)
Screen 2 Window Top ($09)
Screen 2 Window Right ($0A)
Screen 2 Window Bottom ($0B)
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
- Left - 0,
- Top - 0,
- Right - 199,
- Bottom - 99.
Sprite Window Left ($0C)
Sprite Window Top ($0D)
Sprite Window Right ($0E)
Sprite Window Bottom ($0F)
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
Screen 1 Scroll X ($10)
Screen 1 Scroll Y ($11)
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
Screen 2 Scroll X ($12)
Screen 2 Scroll Y ($13)
The X and Y coordinates that Screen 2 is scrolled by.
Palette I/O ports
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations $FE00 - $FFFF to store the color palette.
Mono Shade LUT ($1C, $1D, $1E, $1F)
$1C $1D $1E $1F 7 bit 0 7 bit 0 7 bit 0 7 bit 0 ---- ---- ---- ---- ---- ---- ---- ---- 1111 0000 3333 2222 5555 4444 7777 6666 |||| |||| |||| |||| |||| |||| |||| |||| |||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6 |||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7 |||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4 |||| |||| |||| |||| ++++------------------ Shade for LUT index 5 |||| |||| |||| ++++------------------------- Shade for LUT index 2 |||| |||| ++++------------------------------ Shade for LUT index 3 |||| ++++------------------------------------- Shade for LUT index 0 ++++------------------------------------------ Shade for LUT index 1
Mono Palette 0..15 ($20, $21 .. $3E, $3F)
The monochrome palette is laid out as sixteen words:
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
LCD I/O ports
LCD Control ($14)
7 bit 0 ---- ---- .... ..Ce || |+- LCD enable: 0 = sleep, 1 = enabled +-- Contrast (WSC): 0 = low, 1 = high
The enable bit controls whether or not the LCD screen is displaying graphics. When it is cleared, the pixel area acts as if it was powered off, but the segment area continues functioning as normal.
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
TODO: Bits 4-7 are writable, but only on WS and WSC. Their effect is unknown.
LCD Icon Control ($15)
7 bit 0 ---- ---- ..32 1hvs || |||| || |||+- Sleep (Star) || ||+-- Vertical orientation || |+--- Horizontal orientation || +---- Etc. 1 (Small circle) |+------ Etc. 2 (Medium circle) +------- Etc. 3 (Large circle)
LCD internal I/O ports
These I/O ports are not used and most likely not intended for use by commercial games.
LCD Final Line ($16)
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,[1] but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.[2]
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 LCD Final Line - 3
.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility[3], but the exact mechanism is unknown.
LCD Line Counter ($18)
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to $00.
LCD Latched Icon Status ($1A read)
7 bit 0 ---- ---- ..cv vvhl || |||| || |||+- LCD block disable: 0 = no, 1 = yes || ||+-- Headphone icon || || || || Volume icons: || |+--- - Volume B (medium, high) || +---- - Volume A (low, high) |+------ - Speaker | +------- Cartridge icon
This port shows the state of latched LCD icons; these are displayed for an additional 128 ticks, counting from the last time they were enabled.
Bit 0 (LCD block disable) reflects the value written to the port.
TODO: This documents the WonderSwan Color. The specifics may work differently on the mono WonderSwan.
LCD Latched Icon Control ($1A write)
7 bit 0 ---- ---- ..cs ...l || | || +- LCD block disable: 0 = no, 1 = yes || (disables LCD panel, including all segments) |+------ Latch sound segments +------- Latch cartridge segment
This port allows disabling the full LCD IP block; if bit 0 is set, all LCD panel control (including segments and sound/cartridge segment display timers) is disabled.
This port also allows manually latching the sound/cartridge segment display with their respective timers; however, this can only be done if bit 0 is set. For example, to latch the cartridge segment timer, one can write $21 to the port to disable the LCD block and latch the cartridge segment. Next, after re-enabling the LCD block by clearing bit 0, the cartridge segment will be shown for 128 vertical blanks.
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
- ↑ REG_LCD_VTOTAL - WSMan
- ↑ W.A. Steer. "LCD monitor technology and tests". Techmind, 2011-12-03. Accessed 2024-11-19.
- ↑ REG_LCD_VSYNC - WSMan