I/O port map: Difference between revisions

From WSdev Wiki
Jump to navigationJump to search
(add cartridge I/o link)
(→‎I/O port map: fix typo)
 
(33 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* If two Bits rows are provided, the second one refers to the "Color" mode.
Line 16: Line 32:
! $00
! $00
| [[Display#Display Control|Display Control]]
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
| RW8
|  
|  
Line 91: Line 107:
| Coordinate (y)
| Coordinate (y)
|-
|-
! $0B
! $0C
| [[Display#Sprite Window|Sprite Window Left]]
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
Line 97: Line 113:
| Coordinate (x)
| Coordinate (x)
|-
|-
! $0C
! $0D
| [[Display#Sprite Window|Sprite Window Top]]
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
Line 166: Line 182:
! $1A
! $1A
| [[Display#LCD Status|LCD Status]]
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| style="text-align: right" | <tt style="white-space: nowrap">...v vvhs</tt>
| RW8
| RW8
| Volume segment status (v), Enable (e)
| Volume segments (v), Headphone segment (h), Sleep (s)
|-
|-
! $1C
! $1C
Line 293: Line 309:
! $40
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| RW16
| Linear address, low 16 bits (l)
| Linear address, low 16 bits (l)
Line 305: Line 321:
! $44
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| RW16
| IRAM address (a)
| IRAM address (a)
Line 311: Line 327:
! $46
! $46
| [[DMA#General DMA|GDMA Length]]
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| RW16
| Bytes (b)
| Bytes (b)
Line 347: Line 363:
! $52
! $52
| [[DMA#Sound DMA|SDMA Control]]
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| RW8
| Enable (e), Decrement (d), Target (t),
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
Repeat (r), Hold (h), Frequency (f)
|-
|-
! rowspan="2" | System<sup>(color)</sup>
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
! $60
| System Control 2
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| RW8
| Color (c), 4BPP (4), Chunky (C)
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
|-
! $62
! $62
| System Control 3
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| RW8
| SwanCrystal (S), Power off (p)
| SwanCrystal (S), Power off (p)
|-
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
! $64
| Hyper Voice Left Output
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| W16
Line 373: Line 391:
|-
|-
! $66
! $66
| Hyper Voice Right Output
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| W16
| Raw sample (s)
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
|-
! $69
! $69
| Hyper Voice Right Input
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| W8
| Sample (s)
| Sample (s)
|-
|-
! $6A
! $6A
| Hyper Voice Control
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| RW16
| Mask (m), Channel (c), Enable (e),
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
Rate (r), Format (f), Shift (s)
|-
|-
Line 446: Line 458:
|
|
|-
|-
! rowspan="20" | [[Sound]]
! rowspan="22" | [[Sound]]
! $80
! $80
| Sound Channel 1 Frequency
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| RW16
Line 454: Line 466:
|-
|-
! $82
! $82
| Sound Channel 2 Frequency
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| RW16
Line 460: Line 472:
|-
|-
! $84
! $84
| Sound Channel 3 Frequency
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| RW16
Line 466: Line 478:
|-
|-
! $86
! $86
| Sound Channel 4 Frequency
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| RW16
Line 472: Line 484:
|-
|-
! $88
! $88
| Sound Channel 1 Volume
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| RW8
Line 478: Line 490:
|-
|-
! rowspan="2" | $89
! rowspan="2" | $89
| Sound Channel 2 Volume
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| RW8
| Left (l), Right (r)
| Left (l), Right (r)
|-
|-
| Sound Channel 2 Voice Sample
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| RW8
Line 489: Line 501:
|-
|-
! $8A
! $8A
| Sound Channel 3 Volume
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| RW8
Line 495: Line 507:
|-
|-
! $8B
! $8B
| Sound Channel 4 Volume
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| RW8
Line 501: Line 513:
|-
|-
! $8C
! $8C
| Sound Channel 3 Sweep Amount
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| RW8
Line 507: Line 519:
|-
|-
! $8D
! $8D
| Sound Channel 3 Sweep Ticks
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| RW8
Line 513: Line 525:
|-
|-
! $8E
! $8E
| Sound Channel 4 Noise Control
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| RW8
Line 519: Line 531:
|-
|-
! $8F
! $8F
| Sound Wavetable Address
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| RW8
Line 525: Line 537:
|-
|-
! $90
! $90
| Sound Channel Control
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| RW8
Line 532: Line 544:
|-
|-
! $91
! $91
| Sound Output Control
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| RW8
Line 540: Line 552:
|-
|-
! $92
! $92
| Sound Channel 4 LFSR
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| R16
Line 546: Line 558:
|-
|-
! $94
! $94
| Sound Channel 2 Voice Volume
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| RW8
| Left Half (l), Full (L)
| Left Half (l), Full (L)
Right Half (r), Full (R)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
|-
! $96
! $96
| Sound Sequencer Output Right
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| R16
Line 559: Line 577:
|-
|-
! $98
! $98
| Sound Sequencer Output Left
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| R16
Line 565: Line 583:
|-
|-
! $9A
! $9A
| Sound Sequencer Output Sum
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| R16
| Sample (s)
| Sample (s)
|-
|-
! System
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
! $A0
| System Control
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
Color system (c), Boot ROM lockout (l)
|-
|-
! rowspan="5" | Timers
! rowspan="5" | [[Timers]]
! $A2
! $A2
| Timer Control
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| RW8
Line 587: Line 611:
|-
|-
! $A4
! $A4
| Horizontal Blank Timer Reload
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| RW16
Line 593: Line 617:
|-
|-
! $A6
! $A6
| Vertical Blank Timer Reload
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| RW16
Line 599: Line 623:
|-
|-
! $A8
! $A8
| Horizontal Blank Timer Counter
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| R16
Line 605: Line 629:
|-
|-
! $AA
! $AA
| Vertical Blank Timer Counter
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| R16
| Ticks (t)
| Ticks (t)
|-
|-
! Interrupts
! ?
! $B0
! $AC
| Interrupt Vector
| ?
| style="text-align: right" | <tt style="white-space: nowrap">vvvv v...</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| RW8
| W8?
| Vector offset (v)
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
|-
! UART
! $B1
! $B1
| Serial Data
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| W8
| Data (d)
| Transmit buffer data (d)
|-
|-
! Interrupts
! [[Interrupts]]
! $B2
! $B2
| Interrupt Enable
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
|
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| RW8
|
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
|-
! UART
! $B3
! $B3
| Serial Control
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .rot</tt>
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| RW8
| W8
| Enable (e), Baud rate (b), Reset Overrun (O),
| Enable (e), Baud rate (b), Reset Overrun (O)
Receive ready (r), Overrun (o), Transfer ready (t)
|-
|-
! Interrupts
! [[Interrupts]]
! $B4
! $B4
| Interrupt Status
| [[Interrupts#Interrupt Status|Interrupt Status]]
|
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| R8
|
| Interrupt index (i)
|-
|-
! [[Keypad]]
! [[Keypad]]
Line 653: Line 701:
| Input row (i), Output column (o)
| Input row (i), Output column (o)
|-
|-
! rowspan="2" | Interrupts
! rowspan="2" | [[Interrupts]]
! $B6
! $B6
| Interrupt Acknowledge
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
|
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| W8
|
| Interrupt index (i)
|-
|-
! $B7
! $B7
| Interrupt NMI Control
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| RW8
| Low battery (b)
| Low battery (b)
|-
|-
! rowspan="3" | Internal EEPROM
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
! $BA
| Internal EEPROM Data
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| RW16
Line 674: Line 722:
|-
|-
! $BC
! $BC
| Internal EEPROM Command
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
|
| RW16
| RW16
|
|
|-
|-
! $BE
! rowspan="2" | $BE
| Internal EEPROM Control
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| RW16
| R16
| Protect (P), Erase (E), Write (W), Read (R),
| Protected (p), Ready (R), Done (D)
Ready (r), Done (d)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
|-
! [[Mapper|Cartridge]]
! [[Mapper|Cartridge]]
! $C0<br />
! $C0<br />...<br />
$FF
$FF
| Cartridge I/O
| Cartridge I/O
|
|
|
| RW8
| Forwarded by the SoC
| Forwarded by the SoC
|}
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.

Latest revision as of 14:38, 13 September 2024

The WonderSwan SoC has three general blocks of I/O port accesses:

From To Holder Width Speed
$00 $B7 WonderSwan SoC 16-bit 1 cycle
$B8 $BF Internal EEPROM control 16-bit 1 cycle
$C0 $FF Cartridge bus 8-bit 1(color)/2 cycles (configurable)

With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.

I/O port map

  • Superscripts are used to mark ports specific to a given mode or platform:
    • Color mode: (color). Such ports are only accessible when color mode is enabled through port $60.
    • WS/WSC/SC console: (WS), (WSC), (SC).
  • If two Bits rows are provided, the second one refers to the "Color" mode.
  • The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
Category Port Description Bits Type Notes
Display $00 Display Control ..wo Ws21 RW8
$01 Display Background .... .sss

pppp iiii

RW8 Shade (s)

Palette (p), Index (i)

$02 Display Current Line llll llll R8 Line (l)
$03 Display Interrupt Line llll llll RW8 Line (l)
$04 Sprite Table Address ...a aaaa

..aa aaaa

RW8 Address >> 9 (a)
$05 Sprite Table First .iii iiii RW8 Index (i)
$06 Sprite Table Count cccc cccc RW8 Count (c)
$07 Screen Address .222 .111

2222 1111

RW8 Screen 1 address >> 11 (1)

Screen 2 address >> 11 (2)

$08 Screen 2 Window Left xxxx xxxx RW8 Coordinate (x)
$09 Screen 2 Window Top yyyy yyyy RW8 Coordinate (y)
$0A Screen 2 Window Right xxxx xxxx RW8 Coordinate (x)
$0B Screen 2 Window Bottom yyyy yyyy RW8 Coordinate (y)
$0C Sprite Window Left xxxx xxxx RW8 Coordinate (x)
$0D Sprite Window Top yyyy yyyy RW8 Coordinate (y)
$0E Sprite Window Right xxxx xxxx RW8 Coordinate (x)
$0F Sprite Window Bottom yyyy yyyy RW8 Coordinate (y)
$10 Screen 1 Scroll X xxxx xxxx RW8 Coordinate (x)
$11 Screen 1 Scroll Y yyyy yyyy RW8 Coordinate (y)
$12 Screen 2 Scroll X xxxx xxxx RW8 Coordinate (x)
$13 Screen 2 Scroll Y yyyy yyyy RW8 Coordinate (y)
$14 LCD Control .... ..Ce RW8 Contrast (C)(WSC), Enable (e)
$15 LCD Icon Control ..32 1hvs RW8 Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),

Horizontal (h), Vertical (v), Sleep (s)

$16 LCD Final Line llll llll RW8 Line (l)
$17 LCD Back Porch Line(WSC) llll llll RW8 Line (l)
$1A LCD Status ...v vvhs RW8 Volume segments (v), Headphone segment (h), Sleep (s)
$1C LCD Mono Shade LUT 0/1 1111 0000 RW8 Shade index
$1D LCD Mono Shade LUT 2/3 3333 2222 RW8 Shade index
$1E LCD Mono Shade LUT 4/5 5555 4444 RW8 Shade index
$1F LCD Mono Shade LUT 6/7 7777 6666 RW8 Shade index
$20 LCD Mono Palette 0 .333 .222 .111 .000 RW16 Shade LUT index
$22 LCD Mono Palette 1 .333 .222 .111 .000 RW16 Shade LUT index
$24 LCD Mono Palette 2 .333 .222 .111 .000 RW16 Shade LUT index
$26 LCD Mono Palette 3 .333 .222 .111 .000 RW16 Shade LUT index
$28 LCD Mono Palette 4 .333 .222 .111 .000 RW16 Shade LUT index
$2A LCD Mono Palette 5 .333 .222 .111 .000 RW16 Shade LUT index
$2C LCD Mono Palette 6 .333 .222 .111 .000 RW16 Shade LUT index
$2E LCD Mono Palette 7 .333 .222 .111 .000 RW16 Shade LUT index
$30 LCD Mono Palette 8 .333 .222 .111 .000 RW16 Shade LUT index
$32 LCD Mono Palette 9 .333 .222 .111 .000 RW16 Shade LUT index
$34 LCD Mono Palette 10 .333 .222 .111 .000 RW16 Shade LUT index
$36 LCD Mono Palette 11 .333 .222 .111 .000 RW16 Shade LUT index
$38 LCD Mono Palette 12 .333 .222 .111 .000 RW16 Shade LUT index
$3A LCD Mono Palette 13 .333 .222 .111 .000 RW16 Shade LUT index
$3C LCD Mono Palette 14 .333 .222 .111 .000 RW16 Shade LUT index
$3E LCD Mono Palette 15 .333 .222 .111 .000 RW16 Shade LUT index
DMA(color) $40 GDMA Source Address Low llll llll llll lll. RW16 Linear address, low 16 bits (l)
$42 GDMA Source Address High .... hhhh RW8 Linear address, high 4 bits (h)
$44 GDMA Destination Address aaaa aaaa aaaa aaa. RW16 IRAM address (a)
$46 GDMA Length bbbb bbbb bbbb bbb. RW16 Bytes (b)
$48 GDMA Control ed.. .... RW8 Enable (e), Decrement (d)
$4A SDMA Source Address Low llll llll llll llll RW16 Linear address, low 16 bits (l)
$4C SDMA Source Address High .... hhhh RW8 Linear address, high 4 bits (h)
$4E SDMA Length Low llll llll llll llll RW16 Length, low 16 bits (l)
$50 SDMA Length High .... hhhh RW8 Length, high 4 bits (h)
$52 SDMA Control ed.t rhff RW8 Enable (e), Decrement (d), Target (t),

Repeat (r), Hold (h), Frequency (f)

SoC(color) $60 System Control 2 c4C. i?sl RW8 Color (c), 4BPP (4), Chunky (C),

Cart I/O wait state (i), SRAM wait state (s),
Cart clock speed (l).

$62 System Control 3 S... ...p RW8 SwanCrystal (S), Power off (p)
Hyper Voice(color) $64 Hyper Voice Left Output ssss ssss ssss ssss W16 Raw sample (s)
$66 Hyper Voice Right Output ssss ssss ssss ssss W16 Raw sample (s)
$69 Hyper Voice Right Input ssss ssss W8 Sample (s)
$6A Hyper Voice Control .mmc ???? errr ffss RW16 Mask (m), Channel reset (c), Enable (e),

Rate (r), Format (f), Shift (s)

Display(SC) $70 LCD Timing Configuration 1? ???? ???? RL8
$71 LCD Timing Configuration 2? ???? ???? RL8
$72 LCD Timing Configuration 3? ???? ???? RL8
$73 LCD Timing Configuration 4? ???? ???? RL8
$74 LCD Timing Configuration 5? ???? ???? RL8
$75 LCD Timing Configuration 6? ???? ???? RL8
$76 LCD Timing Configuration 7? ???? ???? RL8
$77 LCD Timing Configuration 8? ???? ???? RL8
Sound $80 Sound Channel 1 Frequency .... .ddd dddd dddd RW16 Divider (d)
$82 Sound Channel 2 Frequency .... .ddd dddd dddd RW16 Divider (d)
$84 Sound Channel 3 Frequency .... .ddd dddd dddd RW16 Divider (d)
$86 Sound Channel 4 Frequency .... .ddd dddd dddd RW16 Divider (d)
$88 Sound Channel 1 Volume llll rrrr RW8 Left (l), Right (r)
$89 Sound Channel 2 Volume llll rrrr RW8 Left (l), Right (r)
Sound Channel 2 Voice Sample ssss ssss RW8 Sample (s)
$8A Sound Channel 3 Volume llll rrrr RW8 Left (l), Right (r)
$8B Sound Channel 4 Volume llll rrrr RW8 Left (l), Right (r)
$8C Sound Channel 3 Sweep Amount vvvv vvvv RW8 Value (v)
$8D Sound Channel 3 Sweep Ticks ...t tttt RW8 Ticks (t)
$8E Sound Channel 4 Noise Control ...e rttt RW8 Enable (e), Reset (r), Tap (t)
$8F Sound Wavetable Address wwww wwww RW8 Address >> 6 (w)
$90 Sound Channel Control nsv. 4321 RW8 Channel enable (1234)

Noise (n), Sweep (s), Voice (v)

$91 Sound Output Control H... hrrs RW8 Headphones connected (H)

Headphone output (h) Speaker output (s), range (r)

$92 Sound Channel 4 LFSR Register .rrr rrrr rrrr rrrr R16 PRNG state (r)
$94 Sound Channel 2 Voice Volume .... lLrR RW8 Left Half (l), Full (L)

Right Half (r), Full (R)

$95 Sound Test 425? ???h RW8
$96 Sound Channel Output Right .... ..ss ssss ssss R16 Sample (s)
$98 Sound Channel Output Left .... ..ss ssss ssss R16 Sample (s)
$9A Sound Channel Output Sum .... .sss ssss ssss R16 Sample (s)
$9E Sound Speaker Main Volume(color) .... ..vv RW8 Main volume (v)
SoC $A0 System Control t??? swcl RW8 Test OK (t), ROM wait state (s), ROM width (w),

Color system (c), Boot ROM lockout (l)

Timers $A2 Timer Control .... VvHh RW8 Horizontal enable (h), auto reload (H)

Vertical enable (v), auto reload (V)

$A4 Horizontal Blank Timer Reload tttt tttt tttt tttt RW16 Ticks (t)
$A6 Vertical Blank Timer Reload tttt tttt tttt tttt RW16 Ticks (t)
$A8 Horizontal Blank Timer Counter tttt tttt tttt tttt R16 Ticks (t)
$AA Vertical Blank Timer Counter tttt tttt tttt tttt R16 Ticks (t)
? $AC ? .... ...p W8? Power off (p)
Interrupts $B0 Interrupt Vector Offset VVVV V... W8 Vector offset (V)
Interrupt Vector Request vvvv vvvv R8 Requested vector offset (v)
UART $B1 Serial Receive Data dddd dddd R8 Receive buffer data (d)
$B1 Serial Transmit Data dddd dddd W8 Transmit buffer data (d)
Interrupts $B2 Interrupt Enable iiii iiii RW8 Interrupt index (i)
UART $B3 Serial Status eb.. .tor R8 Enable (e), Baud rate (b),

Transfer ready (t), Overrun (o), Receive ready (r)

$B3 Serial Control ebO. .... W8 Enable (e), Baud rate (b), Reset Overrun (O)
Interrupts $B4 Interrupt Status iiii iiii R8 Interrupt index (i)
Keypad $B5 Keypad Scan .iii oooo RW8 Input row (i), Output column (o)
Interrupts $B6 Interrupt Acknowledge iiii iiii W8 Interrupt index (i)
$B7 Interrupt NMI Control ...b .... RW8 Low battery (b)
Internal EEPROM $BA Internal EEPROM Data dddd dddd dddd dddd RW16 Data (d)
$BC Internal EEPROM Command RW16
$BE Internal EEPROM Status .... .... p... ..RD R16 Protected (p), Ready (R), Done (D)
Internal EEPROM Control .... .... pewr .... W16 Protect (p), Erase (e), Write (w), Read (r)
Cartridge $C0
...

$FF

Cartridge I/O RW8 Forwarded by the SoC

I/O port routing

The NEC V30MZ supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:

  • If an address is between $00B8 and $00BF inclusive, it is routed to the internal EEPROM control block.
  • If an address is between $00C0 and $00FF inclusive, it is routed to the cartride bus.
  • If an address's bits 0 through 8 inclusive are between $000 and $0B7 inclusive, they are routed to the SoC block.
  • If none of these conditions are reached, open bus is read.

On the monochrome models, as well as color models in mono emulation, open bus is always 0x90.