libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
Functions - System control

Macros

#define ws_mode_t   ws_system_mode_t
 
#define ws_mode_get   ws_system_mode_get
 
#define ws_mode_set   ws_system_mode_set
 
#define ws_hwint_pop   ws_hwint_push
 

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 (void)
 Check if this device is capable of supporting Color mode (= is a WonderSwan Color or above).
 
static bool ws_system_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_mode_get (void)
 Get the current system mode.
 
bool ws_system_mode_set (ws_system_mode_t mode)
 Set the new system mode.
 
typedef __attribute__ ((interrupt)) void __far(*ws_int_handler_t)(void)
 
void ws_cpuint_set_handler (uint8_t idx, ws_int_handler_t handler)
 Register a CPU interrupt handler.
 
void ws_hwint_set_handler (uint8_t idx, ws_int_handler_t handler)
 Register a hardware interrupt handler.
 
void ws_hwint_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_hwint_set_default_handler_key (void)
 Register a default, acknowledge-only interrupt handler.
 
void ws_hwint_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_hwint_set_default_handler_line (void)
 Register a default, acknowledge-only interrupt handler.
 
void ws_hwint_set_default_handler_vblank_timer (void)
 Register a default, acknowledge-only interrupt handler.
 
void ws_hwint_set_default_handler_vblank (void)
 Register a default, acknowledge-only interrupt handler.
 
void ws_hwint_set_default_handler_hblank_timer (void)
 Register a default, acknowledge-only interrupt handler.
 
static void ws_hwint_set (uint8_t mask)
 Set selected hardware interrupts.
 
static uint8_t ws_hwint_push (uint8_t mask)
 
void ws_hwint_enable (uint8_t mask)
 Enable selected hardware interrupts.
 
void ws_hwint_disable (uint8_t mask)
 Disable selected hardware interrupts.
 
static void ws_hwint_disable_all (void)
 Disable all hardware interrupts.
 
static void ws_hwint_ack (uint8_t mask)
 Acknowledge hardware interrupt.
 

Detailed Description

Macro Definition Documentation

◆ ws_hwint_pop

#define ws_hwint_pop   ws_hwint_push

Definition at line 223 of file system.h.

◆ ws_mode_get

#define ws_mode_get   ws_system_mode_get

Definition at line 154 of file system.h.

◆ ws_mode_set

#define ws_mode_set   ws_system_mode_set

Definition at line 155 of file system.h.

◆ ws_mode_t

#define ws_mode_t   ws_system_mode_t

Definition at line 153 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 97 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 65 of file system.h.

Function Documentation

◆ __attribute__()

typedef __attribute__ ( (interrupt) )

◆ ws_cpuint_set_handler()

void ws_cpuint_set_handler ( uint8_t idx,
ws_int_handler_t handler )

Register a CPU interrupt handler.

Parameters
idxThe INDEX of an interrupt (CPUINT_IDX_*).
handlerThe interrupt handler function.

◆ ws_hwint_ack()

static void ws_hwint_ack ( uint8_t mask)
inlinestatic

Acknowledge hardware interrupt.

Parameters
maskThe MASK of an interrupt (HWINT_*).

Definition at line 251 of file system.h.

◆ ws_hwint_disable()

void ws_hwint_disable ( uint8_t mask)

Disable selected hardware interrupts.

Parameters
maskThe MASK of an interrupt (HWINT_*).

◆ ws_hwint_disable_all()

static void ws_hwint_disable_all ( void )
inlinestatic

Disable all hardware interrupts.

Definition at line 242 of file system.h.

◆ ws_hwint_enable()

void ws_hwint_enable ( uint8_t mask)

Enable selected hardware interrupts.

Parameters
maskThe MASK of an interrupt (HWINT_*).

◆ ws_hwint_push()

static uint8_t ws_hwint_push ( uint8_t mask)
inlinestatic

Definition at line 218 of file system.h.

◆ ws_hwint_set()

static void ws_hwint_set ( uint8_t mask)
inlinestatic

Set selected hardware interrupts.

Parameters
maskThe MASK of an interrupt (HWINT_*).

Definition at line 214 of file system.h.

◆ ws_hwint_set_default_handler_hblank_timer()

void ws_hwint_set_default_handler_hblank_timer ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_hwint_set_default_handler_key()

void ws_hwint_set_default_handler_key ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_hwint_set_default_handler_line()

void ws_hwint_set_default_handler_line ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_hwint_set_default_handler_serial_rx()

void ws_hwint_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_hwint_set_default_handler_serial_tx()

void ws_hwint_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_hwint_set_default_handler_vblank()

void ws_hwint_set_default_handler_vblank ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_hwint_set_default_handler_vblank_timer()

void ws_hwint_set_default_handler_vblank_timer ( void )

Register a default, acknowledge-only interrupt handler.

◆ ws_hwint_set_handler()

void ws_hwint_set_handler ( uint8_t idx,
ws_int_handler_t handler )

Register a hardware interrupt handler.

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

Parameters
idxThe INDEX of an interrupt (HWINT_IDX_*).
handlerThe interrupt handler function.

◆ ws_system_color_active()

static bool ws_system_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 58 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()

static bool ws_system_is_color ( 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 48 of file system.h.

◆ ws_system_mode_get()

static ws_system_mode_t ws_system_mode_get ( void )
inlinestatic

Get the current system mode.

Returns
ws_system_mode_t The current system mode.

Definition at line 137 of file system.h.

◆ ws_system_mode_set()

bool ws_system_mode_set ( 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).