libws libws
WSwan hardware library for the Wonderful toolchain
Loading...
Searching...
No Matches
eeprom.h File Reference
#include <stdbool.h>
#include <stdint.h>
#include "ports.h"
#include "util.h"

Go to the source code of this file.

Data Structures

struct  ws_eeprom_handle_t

Macros

#define WS_IEEP_SIZE_MONO   0x80
#define WS_IEEP_SIZE_COLOR   0x800
#define WS_IEEP_USER_ADDR   0x00
#define WS_IEEP_USER_SIZE   0x60
#define WS_IEEP_OWNER_NAME_ADDR   0x60 /* 16 bytes */
#define WS_IEEP_OWNER_NAME_SIZE   16
#define WS_IEEP_OWNER_BIRTHDAY_YEAR_ADDR   0x70 /* word */
#define WS_IEEP_OWNER_BIRTHDAY_MONTH_ADDR   0x72 /* byte */
#define WS_IEEP_OWNER_BIRTHDAY_DAY_ADDR   0x73 /* byte */
#define WS_IEEP_OWNER_GENDER_ADDR   0x74 /* byte */
#define WS_IEEP_OWNER_BLOOD_TYPE_ADDR   0x75 /* byte */
#define WS_IEEP_LAST_CART_PUBLISHER_ADDR   0x76 /* byte */
#define WS_IEEP_LAST_CART_PLATFORM_ADDR   0x77 /* byte */
#define WS_IEEP_LAST_CART_GAME_ID_ADDR   0x78 /* byte */
#define WS_IEEP_CART_CHANGE_COUNT_ADDR   0x7C /* byte */
#define WS_IEEP_NAME_CHANGE_COUNT_ADDR   0x7D /* byte */
#define WS_IEEP_STARTUP_COUNT_ADDR   0x7E /* word */
#define WS_IEEP_COLOR_SETTINGS_ADDR   0x83 /* byte */
#define WS_IEEP_COLOR_SETTINGS_CUSTOM_SPLASH   0x80
#define WS_IEEP_COLOR_SETTINGS_WSC_HIGH_CONTRAST   0x40
#define WS_IEEP_COLOR_SETTINGS_VOLUME(x)
#define WS_IEEP_COLOR_SETTINGS_VOLUME_MASK   0x03
#define WS_IEEP_NAME_COLOR_ADDR   0x84 /* byte */

Enumerations

enum  ws_ieep_gender { WS_IEEP_GENDER_UNK = 0 , WS_IEEP_GENDER_MALE = 1 , WS_IEEP_GENDER_FEMALE = 2 }
enum  ws_ieep_blood_type {
  WS_IEEP_BLOOD_TYPE_UNK = 0 , WS_IEEP_BLOOD_TYPE_A = 1 , WS_IEEP_BLOOD_TYPE_B = 2 , WS_IEEP_BLOOD_TYPE_0 = 3 ,
  WS_IEEP_BLOOD_TYPE_AB = 4
}
enum  ws_ieep_name_color {
  WS_IEEP_NAME_COLOR_BLACK = 0x00 , WS_IEEP_NAME_COLOR_RED = 0x01 , WS_IEEP_NAME_COLOR_ORANGE = 0x02 , WS_IEEP_NAME_COLOR_YELLOW = 0x03 ,
  WS_IEEP_NAME_COLOR_LIME = 0x04 , WS_IEEP_NAME_COLOR_GREEN = 0x05 , WS_IEEP_NAME_COLOR_TEAL = 0x06 , WS_IEEP_NAME_COLOR_CYAN = 0x07 ,
  WS_IEEP_NAME_COLOR_SEABLUE = 0x08 , WS_IEEP_NAME_COLOR_BLUE = 0x09 , WS_IEEP_NAME_COLOR_PURPLE = 0x0A , WS_IEEP_NAME_COLOR_PINK = 0x0B ,
  WS_IEEP_NAME_COLOR_FUCHSIA = 0x0C , WS_IEEP_NAME_COLOR_WHITE = 0x0D
}

Functions

ws_eeprom_handle_t ws_eeprom_handle_internal (void)
static ws_eeprom_handle_t ws_eeprom_handle_cartridge (uint8_t bits)
uint16_t ws_eeprom_read_word (ws_eeprom_handle_t handle, uint16_t address)
 Read an aligned word from the EEPROM.
uint8_t ws_eeprom_read_byte (ws_eeprom_handle_t handle, uint16_t address)
 Read a byte from the EEPROM.
void ws_eeprom_read_data (ws_eeprom_handle_t handle, uint16_t address, uint8_t *data, uint16_t length)
 Read bytes from the EEPROM.
bool ws_eeprom_write_word (ws_eeprom_handle_t handle, uint16_t address, uint16_t value)
 Write a word to the EEPROM.
bool ws_eeprom_erase_word (ws_eeprom_handle_t handle, uint16_t address)
 Erase a word from the EEPROM, setting it to 0xFFFF.
bool ws_eeprom_write_lock (ws_eeprom_handle_t handle)
 Lock the EEPROM, preventing writes and erases.
bool ws_eeprom_write_unlock (ws_eeprom_handle_t handle)
 Unlock the EEPROM, allowing writes and erases.
void ws_ieep_read_owner_name (uint8_t *data)
 Read the owner name, as raw data.
void ws_ieep_read_owner_name_ascii (char *str)
 Read the owner name, as an ASCII string.
uint16_t ws_ieep_name_color_to_rgb (uint8_t value)
 Convert a given name color to its RGB value.
static void ws_ieep_set_protect (void)
 Protect the non-cartridge area of the internal EEPROM.
static bool ws_ieep_is_protected (void)
 Check if the non-cartridge area of the internal EEPROM is currently protected.

Detailed Description

Functionality related to EEPROM.

Definition in file eeprom.h.

Macro Definition Documentation

◆ WS_IEEP_CART_CHANGE_COUNT_ADDR

#define WS_IEEP_CART_CHANGE_COUNT_ADDR   0x7C /* byte */

Definition at line 90 of file eeprom.h.

◆ WS_IEEP_COLOR_SETTINGS_ADDR

#define WS_IEEP_COLOR_SETTINGS_ADDR   0x83 /* byte */

Definition at line 94 of file eeprom.h.

◆ WS_IEEP_COLOR_SETTINGS_CUSTOM_SPLASH

#define WS_IEEP_COLOR_SETTINGS_CUSTOM_SPLASH   0x80

Definition at line 95 of file eeprom.h.

◆ WS_IEEP_COLOR_SETTINGS_VOLUME

#define WS_IEEP_COLOR_SETTINGS_VOLUME ( x)
Value:
((x) & 3)

Definition at line 97 of file eeprom.h.

◆ WS_IEEP_COLOR_SETTINGS_VOLUME_MASK

#define WS_IEEP_COLOR_SETTINGS_VOLUME_MASK   0x03

Definition at line 98 of file eeprom.h.

◆ WS_IEEP_COLOR_SETTINGS_WSC_HIGH_CONTRAST

#define WS_IEEP_COLOR_SETTINGS_WSC_HIGH_CONTRAST   0x40

Definition at line 96 of file eeprom.h.

◆ WS_IEEP_LAST_CART_GAME_ID_ADDR

#define WS_IEEP_LAST_CART_GAME_ID_ADDR   0x78 /* byte */

Definition at line 89 of file eeprom.h.

◆ WS_IEEP_LAST_CART_PLATFORM_ADDR

#define WS_IEEP_LAST_CART_PLATFORM_ADDR   0x77 /* byte */

Definition at line 88 of file eeprom.h.

◆ WS_IEEP_LAST_CART_PUBLISHER_ADDR

#define WS_IEEP_LAST_CART_PUBLISHER_ADDR   0x76 /* byte */

Definition at line 87 of file eeprom.h.

◆ WS_IEEP_NAME_CHANGE_COUNT_ADDR

#define WS_IEEP_NAME_CHANGE_COUNT_ADDR   0x7D /* byte */

Definition at line 91 of file eeprom.h.

◆ WS_IEEP_NAME_COLOR_ADDR

#define WS_IEEP_NAME_COLOR_ADDR   0x84 /* byte */

Definition at line 100 of file eeprom.h.

◆ WS_IEEP_OWNER_BIRTHDAY_DAY_ADDR

#define WS_IEEP_OWNER_BIRTHDAY_DAY_ADDR   0x73 /* byte */

Definition at line 40 of file eeprom.h.

◆ WS_IEEP_OWNER_BIRTHDAY_MONTH_ADDR

#define WS_IEEP_OWNER_BIRTHDAY_MONTH_ADDR   0x72 /* byte */

Definition at line 39 of file eeprom.h.

◆ WS_IEEP_OWNER_BIRTHDAY_YEAR_ADDR

#define WS_IEEP_OWNER_BIRTHDAY_YEAR_ADDR   0x70 /* word */

Definition at line 38 of file eeprom.h.

◆ WS_IEEP_OWNER_BLOOD_TYPE_ADDR

#define WS_IEEP_OWNER_BLOOD_TYPE_ADDR   0x75 /* byte */

Definition at line 62 of file eeprom.h.

◆ WS_IEEP_OWNER_GENDER_ADDR

#define WS_IEEP_OWNER_GENDER_ADDR   0x74 /* byte */

Definition at line 41 of file eeprom.h.

◆ WS_IEEP_OWNER_NAME_ADDR

#define WS_IEEP_OWNER_NAME_ADDR   0x60 /* 16 bytes */

Definition at line 36 of file eeprom.h.

◆ WS_IEEP_OWNER_NAME_SIZE

#define WS_IEEP_OWNER_NAME_SIZE   16

Definition at line 37 of file eeprom.h.

◆ WS_IEEP_SIZE_COLOR

#define WS_IEEP_SIZE_COLOR   0x800

Definition at line 31 of file eeprom.h.

◆ WS_IEEP_SIZE_MONO

#define WS_IEEP_SIZE_MONO   0x80

Definition at line 30 of file eeprom.h.

◆ WS_IEEP_STARTUP_COUNT_ADDR

#define WS_IEEP_STARTUP_COUNT_ADDR   0x7E /* word */

Definition at line 92 of file eeprom.h.

◆ WS_IEEP_USER_ADDR

#define WS_IEEP_USER_ADDR   0x00

Definition at line 33 of file eeprom.h.

◆ WS_IEEP_USER_SIZE

#define WS_IEEP_USER_SIZE   0x60

Definition at line 34 of file eeprom.h.

Enumeration Type Documentation

◆ ws_ieep_blood_type

Possible IEEPROM blood type values.

Enumerator
WS_IEEP_BLOOD_TYPE_UNK 
WS_IEEP_BLOOD_TYPE_A 
WS_IEEP_BLOOD_TYPE_B 
WS_IEEP_BLOOD_TYPE_0 
WS_IEEP_BLOOD_TYPE_AB 

Definition at line 77 of file eeprom.h.

◆ ws_ieep_gender

Possible IEEPROM gender values.

Enumerator
WS_IEEP_GENDER_UNK 
WS_IEEP_GENDER_MALE 
WS_IEEP_GENDER_FEMALE 

Definition at line 54 of file eeprom.h.

◆ ws_ieep_name_color

Possible IEEPROM name color values.

Enumerator
WS_IEEP_NAME_COLOR_BLACK 

RGB(0, 0, 0)

WS_IEEP_NAME_COLOR_RED 

RGB(15, 0, 0)

WS_IEEP_NAME_COLOR_ORANGE 

RGB(15, 7, 0)

WS_IEEP_NAME_COLOR_YELLOW 

RGB(15, 15, 0)

WS_IEEP_NAME_COLOR_LIME 

RGB(7, 15, 0)

WS_IEEP_NAME_COLOR_GREEN 

RGB(0, 15, 0)

WS_IEEP_NAME_COLOR_TEAL 

RGB(0, 15, 7)

WS_IEEP_NAME_COLOR_CYAN 

RGB(0, 15, 15)

WS_IEEP_NAME_COLOR_SEABLUE 

RGB(0, 7, 15)

WS_IEEP_NAME_COLOR_BLUE 

RGB(0, 0, 15)

WS_IEEP_NAME_COLOR_PURPLE 

RGB(7, 0, 15)

WS_IEEP_NAME_COLOR_PINK 

RGB(15, 0, 15)

WS_IEEP_NAME_COLOR_FUCHSIA 

RGB(15, 0, 7)

WS_IEEP_NAME_COLOR_WHITE 

RGB(15, 15, 15)

Definition at line 124 of file eeprom.h.