Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
swadgesona.h File Reference

Detailed Description

The data structures and Helper functions for utilizing Swadgesonas.

Author
Jeremy Stintzcum (jerem.nosp@m.y.st.nosp@m.intzc.nosp@m.um@g.nosp@m.mail..nosp@m.com)
Date
2025-10-5

Overview

Swadgesonas are a Mii-like character that can be edited and personalized. The Swadgesonas are made to be as small as possible to be easily sent via swadgepass, only 12 bytes, and contain all the data that another swadge running the same software needs to reconstruct the sona.

Sonas are 64x64 pixels. Recommend to scale them up when space permits to see the details.

The customizable aspects of a sona are:

  • Skin color
  • Hair style and color
  • Eye shape and color
  • Eyebrow shape
  • Ear type (Cat, Dog, Human, Elf, etc.)
  • Mouth shape
  • Glasses and colour
  • Hats and hat colors
  • Some beauty marks

The Swadgesonas are assembled by the system, so all the user needs to do is provide a space to load the sona into. The Sonas can easily be loaded and saved into the NVS and also regenerated if modifications have been made. Lastly, a random swadgesona can easily be generated to avoid always seeing the default when loading one up before data is initialized.

// Data
swadgesona_t sw; // The swadgesona object
int saveSlot = 4; // You can save to any number of slots. They take 12 bytes each, so make sure there's space!
bool drawBody = true; // If the body should be drawn. If set to false, you get a floating head!
// Load from file
loadSwadgesona(&sw, saveSlot);
// Save to a slot
saveSwadgesona(&sw, saveSlot);
// Regenerate swadgesona image. Only need ot call this when modifying the sona, when loading a sona this function is
// automatically called ***with*** a body. If you need a body without, use this with the drawBody set to false.
generateSwadgesonaImage(&sw, drawBody);
// Draw the sona
drawWsgSimpleScaled(&sw->image, x, y, 3, 3); // Scaled to 3 times
// Generate a random swadgesona
void loadSwadgesona(swadgesona_t *sw, int idx)
Loads a swadgesona from the NVS.
Definition swadgesona.c:231
void saveSwadgesona(swadgesona_t *sw, int idx)
Saves the Swadgesona to the NVS in the given slot.
Definition swadgesona.c:220
void generateRandomSwadgesona(swadgesona_t *sw)
Generates a random Swadgesona automatically.
Definition swadgesona.c:248
void generateSwadgesonaImage(swadgesona_t *sw, bool drawBody)
Generates the image based on the included data.
Definition swadgesona.c:273
wsg_t image
Definition swadgesona.h:516
Larger data for use of use.
Definition swadgesona.h:503
void drawWsgSimpleScaled(const wsg_t *wsg, int16_t xOff, int16_t yOff, int16_t xScale, int16_t yScale)
Draw a WSG to the display without flipping or rotation.
Definition wsg.c:329

Refer to the enums below for the current list of options.

When adding new options, here's the process:

  • Add new item to relevant enum
  • Add new CNFS image to the .c file at the appropriate place in the array
  • Calculate the number of bits required to save the sonas in this .h file.
  • If adding a color, make sure to add the conversions to the palette generation function

If any help is required, try contacting the MAGFest discord, MAGFest slack, or Jeremy Stintzcum (Johnny Wycliffe) for direct assistance. There are plenty of people willing to help!

Go to the source code of this file.

Data Structures

struct  swadgesonaCore_t
 This struct is saved to the NVS. It should contain the bare minimum required to reconstruct a swadgesona. More...
 
struct  swadgesona_t
 Larger data for use of use. More...
 

Enumerations

enum  skinColor_t {
  SKIN_ZERO , SKIN_ONE , SKIN_TWO , SKIN_THREE ,
  SKIN_FOUR , SKIN_FIVE , SKIN_BLUE , SKIN_GRAY ,
  SKIN_GREEN , SKIN_PINK , SKIN_PURPLE , SKIN_RED ,
  SKIN_COLOR_COUNT
}
 List of palette changes. More...
 
enum  hairColor_t {
  HAIR_GRAY , HAIR_BLONDE , HAIR_ORANGE , HAIR_RED ,
  HAIR_DARK_RED , HAIR_BROWN , HAIR_BLACK , HAIR_WHITE ,
  HAIR_PINK , HAIR_HOT_PINK , HAIR_PURPLE , HAIR_DARK_PURPLE ,
  HAIR_TEAL , HAIR_BLUE , HAIR_GREEN , HAIR_DARK_GREEN ,
  HAIR_COLOR_COUNT
}
 List of valid hair colors. More...
 
enum  eyeColor_t {
  EYES_BLACK , EYES_BLUE , EYES_BROWN , EYES_GRAY ,
  EYES_GREEN , EYES_PINK , EYES_PURPLE , EYES_RED ,
  EYES_YELLOW , EYE_COLOR_COUNT
}
 List of valid eye colors. More...
 
enum  clothsColor_t {
  C_BLACK , C_BLUE , C_BROWN , C_CYAN ,
  C_DARK_PINK , C_DARK_PURPLE , C_GRAY , C_GREEN ,
  C_HOT_PINK , C_HOTTER_PINK , C_LIGHT_TEAL , C_LIME ,
  C_OFF_BLACK , C_ORANGE , C_PEACH , C_PINK ,
  C_PURPLE , C_RED , C_TAN , C_TEAL ,
  C_WHITE , C_YELLOW , C_COUNT
}
 List of valid clothes colors. More...
 
enum  hatColor_t {
  HA_BLUE , HA_CYAN , HA_DARK_BLUE , HA_DARK_GREEN ,
  HA_GRAY , HA_GREEN , HA_HOT_PINK , HA_MAUVE ,
  HA_ORANGE , HA_PALE_BLUE , HA_PALE_YELLOW , HA_PINK ,
  HA_PURPLE , HA_YELLOW , HA_COLOR_COUNT
}
 List of valid hat colors. More...
 
enum  glassesColor_t { GC_BLACK , GC_BROWN , GC_RED , GC_COUNT }
 List of valid glasses colors. More...
 
enum  bodyMarks_t {
  BME_NONE , BME_BEARD , BME_BLUSH , BME_BOTTOM ,
  BME_BOTTOM_MOLE , BME_CHIN , BME_CHIN_PATCH , BME_CHIN_STRAP ,
  BME_COP , BME_COWBOY , BME_EYE_MOLE , BME_FRECKLES ,
  BME_FULL_SCRAGGLY , BME_HALF_STACHE , BME_HEART_STACHE , BME_LESS_WISE ,
  BME_MAGICIAN , BME_MARILYN , BME_OLD , BME_PILLOW ,
  BME_S_AND_P , BME_SCRAGGLY , BME_SMALL_CURL , BME_SMALL_STACHE ,
  BME_SOUL_PATCH , BME_STACHE_AND_STRAP , BME_STRONGMAN , BME_THIN_CHIN ,
  BME_THIS , BME_TIRED , BME_WISE_MAN , BME_COUNT
}
 Accessories, beauty marks, etc options. More...
 
enum  earsShape_t {
  EAE_HUMAN , EAE_BIG_HOOPS , EAE_BUNNY , EAE_CAT ,
  EAE_DOG , EAE_DOWN_COW , EAE_DWARF , EAE_EARRINGS ,
  EAE_ELF , EAE_LEFT , EAE_MEDIUM_HOOP , EAE_OPEN_COW ,
  EAE_RIGHT , EAE_SMALL_HOOP , EAE_COUNT
}
 Ear variations. More...
 
enum  eyebrowShape_t {
  EBE_ARCHED , EBE_BUSHY , EBE_CONCERN , EBE_CUT_LEFT ,
  EBE_CUT_LEFT_PIERCING , EBE_CUT_RIGHT , EBE_CUT_RIGHT_PIERCING , EBE_DOT ,
  EBE_DOWNTURNED , EBE_HMMM , EBE_MISCHIEVOUS , EBE_ODD ,
  EBE_PUFFY , EBE_SLIGHT_CONCERN , EBE_THICC , EBE_THIN ,
  EBE_TINY , EBE_COUNT
}
 List of eyebrow options. More...
 
enum  eyeShape_t {
  EE_ANGRY , EE_ANGY , EE_BABY , EE_BIG ,
  EE_BIG_LINER , EE_BOOPED , EE_CAT , EE_CLOSED ,
  EE_CLOSED_LASHES , EE_CLOSED_LINER , EE_CRAZY , EE_CROSSES ,
  EE_CUTE , EE_DOOFY , EE_EXASPERATED , EE_HEARTS ,
  EE_LINER , EE_MAKEUP , EE_SEXY , EE_SEXY_LASHES ,
  EE_SLEEPING , EE_SMALL_LASHES , EE_SQUINTING , EE_SQUINTING_LASHES ,
  EE_STARE , EE_STARING , EE_SWIRLS , EE_THIN ,
  EE_WIDE , EE_COUNT
}
 List of eye shapes. More...
 
enum  hairStyle_t {
  HE_BALLET_BUN , HE_BOWL_CUT , HE_CHIBI_USA , HE_CURLY ,
  HE_CUTE , HE_CUTE_BANGS , HE_DOLLY , HE_DOWN_DREADS ,
  HE_DOWN_DREADS_R , HE_FRANKENSTEIN , HE_FRO , HE_HINATA ,
  HE_JINX , HE_LONG , HE_LONG_PIGS , HE_MAIN_CHARACTER ,
  HE_MAIN_CHARACTER_R , HE_MAIN_VILLAIN , HE_MAIN_VILLAIN_R , HE_MALE_PATTERN ,
  HE_MCR , HE_MINAKO , HE_MOHAWK , HE_POMPADOUR ,
  HE_RAVEN , HE_SHORT , HE_SHORT_PIGS , HE_SIDE_PUFFS ,
  HE_SIDE_PUFFS_R , HE_SKULL , HE_SKULL_R , HE_SMALL_BUNS ,
  HE_SPOCK , HE_STAR_PUFF_N_B , HE_STAR_PUFF , HE_STAR_PUFFS_R ,
  HE_TATTOO , HE_THING , HE_USAGI , HE_VBANG ,
  HE_WAVY_HAWK , HE_WAVY_HAWK_R , HE_WAVY_SHORT , HE_WAVY_LONG ,
  HE_WEDNESDAY , HE_WEDNESDAY_R , HE_WET_CURLY , HE_WET_SHORT ,
  HE_COUNT
}
 hairstyle variations More...
 
enum  hat_t {
  HAE_NONE , HAE_BATTRICE , HAE_BEANIE , HAE_BIGMA ,
  HAE_CHEF , HAE_COOL_HAT , HAE_COWBOY , HAE_GARBOTNIK ,
  HAE_GRAD_CAP , HAE_HEART , HAE_KINETIC_DONUT , HAE_MET_HELMET ,
  HAE_PUFFBALL , HAE_PULSE , HAE_SAWTOOTH , HAE_TRON ,
  HAE_COUNT
}
 Hat options. More...
 
enum  mouthShape_t {
  ME_AH , ME_ANGEL_BITE , ME_BAR_PIERCING , ME_BITE ,
  ME_BITE_PIERCING , ME_CENSOR , ME_CONCERN , ME_CONTENT ,
  ME_DROOL , ME_HALF_SMILE , ME_KET , ME_KISSES ,
  ME_LIP , ME_LITTLE_DROOL , ME_MISCHIEF , ME_MLEM ,
  ME_NO_CUPID_BOW , ME_OH , ME_OH_PIERCING , ME_OPEN_SMILE ,
  ME_POUTY , ME_SAD , ME_SAD_PIERCING , ME_SATISFIED ,
  ME_SMILE , ME_STOIC , ME_TONGUE , ME_TONGUE_PIERCING ,
  ME_UHM , ME_VAMPIRE , ME_YELLING , ME_COUNT
}
 List of mouth options. More...
 
enum  glasses_t {
  G_NONE , G_3D , G_ANIME , G_BANDAGE ,
  G_BIG , G_BIGANGLE , G_BIGANGLE_SUN , G_BIGSQUARE ,
  G_BIGSQUARE_SUN , G_BLACK_SUN , G_EGGMAN , G_GOEORDI ,
  G_LINDA , G_LINDA_SUN , G_LOW , G_LOW_SUN ,
  G_PATCH , G_RAYBAN , G_RAYBAN_SUN , G_READING ,
  G_SCOUTER , G_SMALL , G_SQUARE , G_SQUARE_SUN ,
  G_SQUIRTLE , G_THINANGLE , G_THINANGLE_SUN , G_UPTURNED ,
  G_UPTURNED_SUN , G_WIDENOSE , G_WIDENOSE_SUN , G_COUNT
}
 Glasses options. More...
 

Functions

void saveSwadgesona (swadgesona_t *sw, int idx)
 Saves the Swadgesona to the NVS in the given slot.
 
void loadSwadgesona (swadgesona_t *sw, int idx)
 Loads a swadgesona from the NVS.
 
void generateRandomSwadgesona (swadgesona_t *sw)
 Generates a random Swadgesona automatically.
 
void generateSwadgesonaImage (swadgesona_t *sw, bool drawBody)
 Generates the image based on the included data.
 
cnfsFileIdx_t getHairWSG (swadgesona_t *sw)
 Get the hair CNFS index from the swadgesona for drawing behind custom bodies.
 

Data Structure Documentation

◆ swadgesonaCore_t

struct swadgesonaCore_t
Data Fields
int32_t packedName
skinColor_t skin: 4
hairColor_t hairColor: 5
eyeColor_t eyeColor: 4
hatColor_t hatColor: 4
clothsColor_t clothes: 5
glassesColor_t glassesColor: 2
bodyMarks_t bodyMarks: 5
earsShape_t earShape: 4
eyebrowShape_t eyebrows: 5
eyeShape_t eyeShape: 5
hairStyle_t hairStyle: 6
hat_t hat: 5
mouthShape_t mouthShape: 5
glasses_t glasses: 5

◆ swadgesona_t

struct swadgesona_t
Data Fields
swadgesonaCore_t core Data that is saved to the NVS.
nameData_t name The name of the swadgesona.
wsgPalette_t pal Palette for changing colors of images.
wsg_t image

Enumeration Type Documentation

◆ skinColor_t

List of palette changes.

Enumerator
SKIN_ZERO 
SKIN_ONE 
SKIN_TWO 
SKIN_THREE 
SKIN_FOUR 
SKIN_FIVE 
SKIN_BLUE 
SKIN_GRAY 
SKIN_GREEN 
SKIN_PINK 
SKIN_PURPLE 
SKIN_RED 
SKIN_COLOR_COUNT 

◆ hairColor_t

List of valid hair colors.

Enumerator
HAIR_GRAY 
HAIR_BLONDE 
HAIR_ORANGE 
HAIR_RED 
HAIR_DARK_RED 
HAIR_BROWN 
HAIR_BLACK 
HAIR_WHITE 
HAIR_PINK 
HAIR_HOT_PINK 
HAIR_PURPLE 
HAIR_DARK_PURPLE 
HAIR_TEAL 
HAIR_BLUE 
HAIR_GREEN 
HAIR_DARK_GREEN 
HAIR_COLOR_COUNT 

◆ eyeColor_t

enum eyeColor_t

List of valid eye colors.

Enumerator
EYES_BLACK 
EYES_BLUE 
EYES_BROWN 
EYES_GRAY 
EYES_GREEN 
EYES_PINK 
EYES_PURPLE 
EYES_RED 
EYES_YELLOW 
EYE_COLOR_COUNT 

Total number of eye colors.

◆ clothsColor_t

List of valid clothes colors.

Enumerator
C_BLACK 
C_BLUE 
C_BROWN 
C_CYAN 
C_DARK_PINK 
C_DARK_PURPLE 
C_GRAY 
C_GREEN 
C_HOT_PINK 
C_HOTTER_PINK 
C_LIGHT_TEAL 
C_LIME 
C_OFF_BLACK 
C_ORANGE 
C_PEACH 
C_PINK 
C_PURPLE 
C_RED 
C_TAN 
C_TEAL 
C_WHITE 
C_YELLOW 
C_COUNT 

◆ hatColor_t

enum hatColor_t

List of valid hat colors.

Enumerator
HA_BLUE 
HA_CYAN 
HA_DARK_BLUE 
HA_DARK_GREEN 
HA_GRAY 
HA_GREEN 
HA_HOT_PINK 
HA_MAUVE 
HA_ORANGE 
HA_PALE_BLUE 
HA_PALE_YELLOW 
HA_PINK 
HA_PURPLE 
HA_YELLOW 
HA_COLOR_COUNT 

◆ glassesColor_t

List of valid glasses colors.

Enumerator
GC_BLACK 
GC_BROWN 
GC_RED 
GC_COUNT 

◆ bodyMarks_t

Accessories, beauty marks, etc options.

Enumerator
BME_NONE 
BME_BEARD 
BME_BLUSH 
BME_BOTTOM 
BME_BOTTOM_MOLE 
BME_CHIN 
BME_CHIN_PATCH 
BME_CHIN_STRAP 
BME_COP 
BME_COWBOY 
BME_EYE_MOLE 
BME_FRECKLES 
BME_FULL_SCRAGGLY 
BME_HALF_STACHE 
BME_HEART_STACHE 
BME_LESS_WISE 
BME_MAGICIAN 
BME_MARILYN 
BME_OLD 
BME_PILLOW 
BME_S_AND_P 
BME_SCRAGGLY 
BME_SMALL_CURL 
BME_SMALL_STACHE 
BME_SOUL_PATCH 
BME_STACHE_AND_STRAP 
BME_STRONGMAN 
BME_THIN_CHIN 
BME_THIS 
BME_TIRED 
BME_WISE_MAN 
BME_COUNT 

◆ earsShape_t

Ear variations.

Enumerator
EAE_HUMAN 
EAE_BIG_HOOPS 
EAE_BUNNY 
EAE_CAT 
EAE_DOG 
EAE_DOWN_COW 
EAE_DWARF 
EAE_EARRINGS 
EAE_ELF 
EAE_LEFT 
EAE_MEDIUM_HOOP 
EAE_OPEN_COW 
EAE_RIGHT 
EAE_SMALL_HOOP 
EAE_COUNT 

◆ eyebrowShape_t

List of eyebrow options.

Enumerator
EBE_ARCHED 
EBE_BUSHY 
EBE_CONCERN 
EBE_CUT_LEFT 
EBE_CUT_LEFT_PIERCING 
EBE_CUT_RIGHT 
EBE_CUT_RIGHT_PIERCING 
EBE_DOT 
EBE_DOWNTURNED 
EBE_HMMM 
EBE_MISCHIEVOUS 
EBE_ODD 
EBE_PUFFY 
EBE_SLIGHT_CONCERN 
EBE_THICC 
EBE_THIN 
EBE_TINY 
EBE_COUNT 

◆ eyeShape_t

enum eyeShape_t

List of eye shapes.

Enumerator
EE_ANGRY 
EE_ANGY 
EE_BABY 
EE_BIG 
EE_BIG_LINER 
EE_BOOPED 
EE_CAT 
EE_CLOSED 
EE_CLOSED_LASHES 
EE_CLOSED_LINER 
EE_CRAZY 
EE_CROSSES 
EE_CUTE 
EE_DOOFY 
EE_EXASPERATED 
EE_HEARTS 
EE_LINER 
EE_MAKEUP 
EE_SEXY 
EE_SEXY_LASHES 
EE_SLEEPING 
EE_SMALL_LASHES 
EE_SQUINTING 
EE_SQUINTING_LASHES 
EE_STARE 
EE_STARING 
EE_SWIRLS 
EE_THIN 
EE_WIDE 
EE_COUNT 

◆ hairStyle_t

hairstyle variations

Enumerator
HE_BALLET_BUN 
HE_BOWL_CUT 
HE_CHIBI_USA 
HE_CURLY 
HE_CUTE 
HE_CUTE_BANGS 
HE_DOLLY 
HE_DOWN_DREADS 
HE_DOWN_DREADS_R 
HE_FRANKENSTEIN 
HE_FRO 
HE_HINATA 
HE_JINX 
HE_LONG 
HE_LONG_PIGS 
HE_MAIN_CHARACTER 
HE_MAIN_CHARACTER_R 
HE_MAIN_VILLAIN 
HE_MAIN_VILLAIN_R 
HE_MALE_PATTERN 
HE_MCR 
HE_MINAKO 
HE_MOHAWK 
HE_POMPADOUR 
HE_RAVEN 
HE_SHORT 
HE_SHORT_PIGS 
HE_SIDE_PUFFS 
HE_SIDE_PUFFS_R 
HE_SKULL 
HE_SKULL_R 
HE_SMALL_BUNS 
HE_SPOCK 
HE_STAR_PUFF_N_B 
HE_STAR_PUFF 
HE_STAR_PUFFS_R 
HE_TATTOO 
HE_THING 
HE_USAGI 
HE_VBANG 
HE_WAVY_HAWK 
HE_WAVY_HAWK_R 
HE_WAVY_SHORT 
HE_WAVY_LONG 
HE_WEDNESDAY 
HE_WEDNESDAY_R 
HE_WET_CURLY 
HE_WET_SHORT 
HE_COUNT 

◆ hat_t

enum hat_t

Hat options.

Enumerator
HAE_NONE 
HAE_BATTRICE 
HAE_BEANIE 
HAE_BIGMA 
HAE_CHEF 
HAE_COOL_HAT 
HAE_COWBOY 
HAE_GARBOTNIK 
HAE_GRAD_CAP 
HAE_HEART 
HAE_KINETIC_DONUT 
HAE_MET_HELMET 
HAE_PUFFBALL 
HAE_PULSE 
HAE_SAWTOOTH 
HAE_TRON 
HAE_COUNT 

◆ mouthShape_t

List of mouth options.

Enumerator
ME_AH 
ME_ANGEL_BITE 
ME_BAR_PIERCING 
ME_BITE 
ME_BITE_PIERCING 
ME_CENSOR 
ME_CONCERN 
ME_CONTENT 
ME_DROOL 
ME_HALF_SMILE 
ME_KET 
ME_KISSES 
ME_LIP 
ME_LITTLE_DROOL 
ME_MISCHIEF 
ME_MLEM 
ME_NO_CUPID_BOW 
ME_OH 
ME_OH_PIERCING 
ME_OPEN_SMILE 
ME_POUTY 
ME_SAD 
ME_SAD_PIERCING 
ME_SATISFIED 
ME_SMILE 
ME_STOIC 
ME_TONGUE 
ME_TONGUE_PIERCING 
ME_UHM 
ME_VAMPIRE 
ME_YELLING 
ME_COUNT 

◆ glasses_t

enum glasses_t

Glasses options.

Enumerator
G_NONE 
G_3D 
G_ANIME 
G_BANDAGE 
G_BIG 
G_BIGANGLE 
G_BIGANGLE_SUN 
G_BIGSQUARE 
G_BIGSQUARE_SUN 
G_BLACK_SUN 
G_EGGMAN 
G_GOEORDI 
G_LINDA 
G_LINDA_SUN 
G_LOW 
G_LOW_SUN 
G_PATCH 
G_RAYBAN 
G_RAYBAN_SUN 
G_READING 
G_SCOUTER 
G_SMALL 
G_SQUARE 
G_SQUARE_SUN 
G_SQUIRTLE 
G_THINANGLE 
G_THINANGLE_SUN 
G_UPTURNED 
G_UPTURNED_SUN 
G_WIDENOSE 
G_WIDENOSE_SUN 
G_COUNT 

Function Documentation

◆ saveSwadgesona()

void saveSwadgesona ( swadgesona_t * sw,
int idx )

Saves the Swadgesona to the NVS in the given slot.

Parameters
swSwadgesona data to save. provide the entire wrapper
idxIndex of slot to put swadgesona into

◆ loadSwadgesona()

void loadSwadgesona ( swadgesona_t * sw,
int idx )

Loads a swadgesona from the NVS.

Parameters
swSwadgesona data to load. Will be randomized if the data doesn't exist.
idxIndex of slot to put swadgesona into

◆ generateRandomSwadgesona()

void generateRandomSwadgesona ( swadgesona_t * sw)

Generates a random Swadgesona automatically.

Parameters
swSwadgesona to load data into.

◆ generateSwadgesonaImage()

void generateSwadgesonaImage ( swadgesona_t * sw,
bool drawBody )

Generates the image based on the included data.

Parameters
swSwadgesona wrapper used ot generate the image
drawBodyWhether or not to draw the shirt/neck

◆ getHairWSG()

cnfsFileIdx_t getHairWSG ( swadgesona_t * sw)

Get the hair CNFS index from the swadgesona for drawing behind custom bodies.

Parameters
swSwadgesona to extract wsg from
Returns
cnfsFileIdx_t index into the CNFS system where the hairstyle is at.