libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
System Control

Macros

#define WS_SYSTEM_CLOCK_HZ   (3072000)
 System clock frequency, in hertz.
#define WS_INT_UART_TX   0
#define WS_INT_KEY_SCAN   1
#define WS_INT_CARTRIDGE   2
#define WS_INT_UART_RX   3
#define WS_INT_LINE_MATCH   4
#define WS_INT_VBL_TIMER   5
#define WS_INT_VBLANK   6
#define WS_INT_HBL_TIMER   7
#define ws_int_pop_enabled   ws_int_enable_set

Enumerations

enum  ws_system_model_t { WS_MODEL_MONO = 0x00 , WS_MODEL_PCV2 = 0x01 , WS_MODEL_COLOR = 0x82 , WS_MODEL_CRYSTAL = 0x83 }
 WonderSwan device model. More...
enum  ws_system_mode_t { WS_MODE_MONO = 0x00 , WS_MODE_COLOR = 0x80 , WS_MODE_COLOR_4BPP = 0xC0 , WS_MODE_COLOR_4BPP_PACKED = 0xE0 }
 WonderSwan system mode. More...

Functions

static bool ws_system_is_color_model (void)
 Check if this device is capable of supporting Color mode (= is a WonderSwan Color or above).
static bool ws_system_is_color_active (void)
 Check if this device is currently in Color mode.
ws_system_model_t ws_system_get_model (void)
 Get the device's model.
static ws_system_mode_t ws_system_get_mode (void)
 Get the current system mode.
bool ws_system_set_mode (ws_system_mode_t mode)
 Set the new system mode.
void ws_int_set_handler (uint8_t idx, ia16_int_handler_t handler)
 Register a hardware interrupt handler.
void ws_int_set_default_handler_serial_tx (void)
 Register a default interrupt handler for serial transmission. This handler will automatically disable and acknowledge HWINT_SERIAL_TX .
void ws_int_set_default_handler_key (void)
 Register a default, acknowledge-only interrupt handler.
void ws_int_set_default_handler_serial_rx (void)
 Register a default interrupt handler for serial receiving. This handler will automatically disable and acknowledge HWINT_SERIAL_RX .
void ws_int_set_default_handler_line (void)
 Register a default, acknowledge-only interrupt handler.
void ws_int_set_default_handler_vblank_timer (void)
 Register a default, acknowledge-only interrupt handler.
void ws_int_set_default_handler_vblank (void)
 Register a default, acknowledge-only interrupt handler.
void ws_int_set_default_handler_hblank_timer (void)
 Register a default, acknowledge-only interrupt handler.
static void ws_int_set_enabled (uint8_t mask)
 Set selected hardware interrupts.
static uint8_t ws_int_push_set_enabled (uint8_t mask)
void ws_int_enable (uint8_t mask)
 Enable selected hardware interrupts.
void ws_int_disable (uint8_t mask)
 Disable selected hardware interrupts.
static void ws_int_disable_all (void)
 Disable all hardware interrupts.
static void ws_int_ack (uint8_t mask)
 Acknowledge hardware interrupt.

Detailed Description

Macro Definition Documentation

◆ WS_INT_CARTRIDGE

#define WS_INT_CARTRIDGE   2

Cartridge IRQ pin interrupt.

Definition at line 51 of file system.h.

◆ WS_INT_HBL_TIMER

#define WS_INT_HBL_TIMER   7

Horizontal blank timer interrupt.

Definition at line 71 of file system.h.

◆ WS_INT_KEY_SCAN

#define WS_INT_KEY_SCAN   1

Key scan column non-zero interrupt.

Definition at line 47 of file system.h.

◆ WS_INT_LINE_MATCH

#define WS_INT_LINE_MATCH   4

Display line match interrupt.

Definition at line 59 of file system.h.

◆ ws_int_pop_enabled

#define ws_int_pop_enabled   ws_int_enable_set

Definition at line 249 of file system.h.

◆ WS_INT_UART_RX

#define WS_INT_UART_RX   3

UART RX ready interrupt.

Definition at line 55 of file system.h.

◆ WS_INT_UART_TX

#define WS_INT_UART_TX   0

UART TX ready interrupt.

Definition at line 43 of file system.h.

◆ WS_INT_VBL_TIMER

#define WS_INT_VBL_TIMER   5

Vertical blank timer interrupt.

Definition at line 63 of file system.h.

◆ WS_INT_VBLANK

#define WS_INT_VBLANK   6

Vertical blank interrupt.

Definition at line 67 of file system.h.

◆ WS_SYSTEM_CLOCK_HZ

#define WS_SYSTEM_CLOCK_HZ   (3072000)

System clock frequency, in hertz.

Definition at line 38 of file system.h.

Enumeration Type Documentation

◆ ws_system_mode_t

WonderSwan system mode.

Enumerator
WS_MODE_MONO 

Mono mode.

In this mode, the device acts like a "mono" WonderSwan. This is typically the default mode after boot.

WS_MODE_COLOR 

Color mode.

In this mode, the device enables the functionality specific to the WonderSwan Color. The 2BPP tile area is utilized - only the first four colors of each palette are used.

WS_MODE_COLOR_4BPP 

Color/4bpp mode.

In this mode, the device enables the functionality specific to the WonderSwan Color. The 4BPP tile area is utilized.

WS_MODE_COLOR_4BPP_PACKED 

Color/4bpp/Packed mode.

In this mode, the device enables the functionality specific to the WonderSwan Color. The 4BPP tile area is utilized. Tiles are stored in packed form - with two complete pixels per byte, as opposed to four separate consecutive planes.

Definition at line 138 of file system.h.

◆ ws_system_model_t

WonderSwan device model.

Enumerator
WS_MODEL_MONO 

WonderSwan (mono).

WS_MODEL_PCV2 

Pocket Challenge V2.

WS_MODEL_COLOR 

WonderSwan Color.

WS_MODEL_CRYSTAL 

SwanCrystal.

Definition at line 106 of file system.h.

Function Documentation

◆ ws_int_ack()

void ws_int_ack ( uint8_t mask)
inlinestatic

Acknowledge hardware interrupt.

Parameters
maskThe MASK of an interrupt (HWINT_*).

Definition at line 277 of file system.h.

◆ ws_int_disable()

void ws_int_disable ( uint8_t mask)

Disable selected hardware interrupts.

Parameters
maskThe enablement mask of an interrupt (WS_INT_ENABLE_*).

◆ ws_int_disable_all()

void ws_int_disable_all ( void )
inlinestatic

Disable all hardware interrupts.

Definition at line 268 of file system.h.

◆ ws_int_enable()

void ws_int_enable ( uint8_t mask)

Enable selected hardware interrupts.

Parameters
maskThe enablement mask of an interrupt (WS_INT_ENABLE_*).

◆ ws_int_push_set_enabled()

uint8_t ws_int_push_set_enabled ( uint8_t mask)
inlinestatic

Definition at line 244 of file system.h.

◆ ws_int_set_default_handler_hblank_timer()

void ws_int_set_default_handler_hblank_timer ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_int_set_default_handler_key()

void ws_int_set_default_handler_key ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_int_set_default_handler_line()

void ws_int_set_default_handler_line ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_int_set_default_handler_serial_rx()

void ws_int_set_default_handler_serial_rx ( void )

Register a default interrupt handler for serial receiving. This handler will automatically disable and acknowledge HWINT_SERIAL_RX .

◆ ws_int_set_default_handler_serial_tx()

void ws_int_set_default_handler_serial_tx ( void )

Register a default interrupt handler for serial transmission. This handler will automatically disable and acknowledge HWINT_SERIAL_TX .

◆ ws_int_set_default_handler_vblank()

void ws_int_set_default_handler_vblank ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_int_set_default_handler_vblank_timer()

void ws_int_set_default_handler_vblank_timer ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_int_set_enabled()

void ws_int_set_enabled ( uint8_t mask)
inlinestatic

Set selected hardware interrupts.

Parameters
maskThe MASK of an interrupt (HWINT_*).

Definition at line 240 of file system.h.

◆ ws_int_set_handler()

void ws_int_set_handler ( uint8_t idx,
ia16_int_handler_t handler )

Register a hardware interrupt handler.

Note that hardware interrupts are level-triggered and thus must be acknowledged. See ws_int_ack for more information.

Parameters
idxThe interrupt (WS_INT_*)
handlerThe interrupt handler function.

◆ ws_system_get_mode()

ws_system_mode_t ws_system_get_mode ( void )
inlinestatic

Get the current system mode.

Returns
ws_system_mode_t The current system mode.

Definition at line 178 of file system.h.

◆ ws_system_get_model()

ws_system_model_t ws_system_get_model ( void )

Get the device's model.

Returns
ws_system_model_t The device's model.

◆ ws_system_is_color_active()

bool ws_system_is_color_active ( void )
inlinestatic

Check if this device is currently in Color mode.

Returns
true This device can currently access WonderSwan Color functionality.
false This device is limited to "mono" WonderSwan functionality.

Definition at line 99 of file system.h.

◆ ws_system_is_color_model()

bool ws_system_is_color_model ( void )
inlinestatic

Check if this device is capable of supporting Color mode (= is a WonderSwan Color or above).

This is useful for gating functionality specific to Color mode - see ws_system_mode_t for more information.

Returns
true This device is a WonderSwan Color or above.
false This device is a "mono" WonderSwan.

Definition at line 89 of file system.h.

◆ ws_system_set_mode()

bool ws_system_set_mode ( ws_system_mode_t mode)

Set the new system mode.

Note that any non-Mono modes require a WonderSwan Color or above - see system_is_color

Parameters
modeThe new system mode.
Returns
true If the operation was successful.
false If the operation was unsuccessful (trying to apply a color mode on a "mono" WonderSwan).