Last active
January 26, 2023 23:15
-
-
Save up-n-atom/dbe521034ac0a64fffc2ef1df8f7d573 to your computer and use it in GitHub Desktop.
010 Editor WonderSwan EEPROM binary template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //------------------------------------------------ | |
| //--- 010 Editor v8.0 Binary Template | |
| // | |
| // File: WSC_EEPROM.bt | |
| // Authors: up-n-atom | |
| // Version: 1.0 | |
| // Purpose: Parse WonderSwan Color/SwanCrystal internal EEPROM | |
| // Category: | |
| // File Mask: *.bin | |
| // ID Bytes: | |
| // History: | |
| //------------------------------------------------ | |
| LittleEndian(); | |
| string ReadNameChar( ubyte &c ) | |
| { | |
| local char extra[] = "+-?."; | |
| if ( c > 0 && c < 11 ) // 0-9 | |
| return ( char )( c + 47 ); | |
| else if ( c > 10 && c < 37 ) // A-Z | |
| return ( char )( c + 54 ); | |
| else if ( c == 37 ) | |
| return "Heart"; | |
| else if ( c == 38 ) | |
| return "Eighth Note"; | |
| else if ( c > 38 && c < 43 ) | |
| return extra[ c - 39 ]; | |
| return " "; | |
| } | |
| void SetNameBackColor( ubyte x ) | |
| { | |
| local int palette[ 16 ] = { | |
| 0x000000, | |
| 0x0000FF, | |
| 0x0077FF, | |
| 0x00FFFF, | |
| 0x00FF77, | |
| 0x00FF00, | |
| 0x77FF00, | |
| 0xFFFF00, | |
| 0xFF7700, | |
| 0xFF0000, | |
| 0xFF0077, | |
| 0xFF00FF, | |
| 0x7700FF, | |
| 0xFFFFFF, | |
| 0x777777, | |
| 0x777777 | |
| }; | |
| if ( x > 15 ) | |
| SetBackColor( cNone ); | |
| else | |
| SetBackColor( palette[ x ] ); | |
| } | |
| string ReadOffset( ushort &offset ) | |
| { | |
| string s; | |
| SPrintf( s, "%Xh", offset + 128 ); | |
| return s; | |
| } | |
| typedef struct { | |
| ushort year; | |
| ubyte month; | |
| ubyte day; | |
| } DATE; | |
| typedef enum <ubyte> { | |
| AGENDER, | |
| MALE, | |
| FEMALE | |
| } GENDER; | |
| typedef enum <ubyte> { | |
| UNSPECIFIED, | |
| A, | |
| B, | |
| O, | |
| AB | |
| } BLOOD_TYPE; | |
| typedef enum <ubyte> { | |
| BAN = 1, // Bandai | |
| TAT, // Taito | |
| TMY, // Tomy | |
| KEX, // Koei | |
| DTE, // Data East | |
| AAE, // Asmik Ace | |
| MDE, // Media Entertainment | |
| NHB, // Nichibutsu | |
| CCJ = 10, // Coconuts Japan | |
| SUM, // Sammy | |
| SUN, // Sun Soft | |
| PAW, // Mebius | |
| BPR, // Banpresto | |
| JLC = 16, // Jaleco | |
| MGA, // Imagineer | |
| KNM, // Konami | |
| KBS = 22, // Kobunsha | |
| BTM, // Bottom Up | |
| KGT, // Kaga Tech | |
| SRV, // Sunrise | |
| CFT, // Cyber Front | |
| MGH, // Mega House | |
| BEC = 29, // Interbec | |
| NAP, // Nihon Application | |
| BVL, // Bandai Visual | |
| ATN, // Athena | |
| KDX, // KID | |
| HAL, // HAL Corporation | |
| YKE, // Yuki Enterprise | |
| OMN, // Omega Micott | |
| LAY, // Layup | |
| KDK, // Kadokawa Shoten | |
| SHL, // Shall Luck | |
| SQR, // Squaresoft | |
| SCC = 42, | |
| TMC, // Tom Create | |
| NMC = 45, // Namco | |
| SES, | |
| HTR, | |
| VGD = 49, // Vanguard | |
| MGT, // Megatron | |
| WIZ, // Wiz | |
| TAN = 53, // Tanita | |
| CPC = 54 // Capcom | |
| } PUBLISHER; | |
| typedef struct { | |
| PUBLISHER publisher; | |
| ubyte color; | |
| ubyte id; | |
| } CART <read=ReadCartridge>; | |
| string ReadCartridge( CART &c ) | |
| { | |
| string s = EnumToString( c.publisher ); | |
| if ( Strlen( s ) > 0 ) | |
| { | |
| SPrintf( s, "SWJ-%s%03d", s, c.id ); | |
| if ( c.color ) | |
| s[ 7 ] = 'C'; | |
| } | |
| return s; | |
| } | |
| typedef enum <ubyte> { | |
| MUTED, | |
| LEVEL1, | |
| LEVEL2, | |
| LEVEL3 | |
| } VOLUME; | |
| typedef enum <ubyte> { | |
| LOW, | |
| HIGH | |
| } CONTRAST; | |
| typedef struct { | |
| VOLUME volumeLevel : 2; | |
| ubyte : 4; | |
| CONTRAST contrast : 1; | |
| ubyte customSplash : 1; | |
| } SYSTEM_FLAGS; | |
| typedef enum <ubyte> { | |
| ONE, | |
| TWO | |
| } BITS_PER_PIXEL; | |
| typedef struct { | |
| ubyte paletteCount : 5; | |
| ubyte unknown : 2 <hidden=true>; | |
| BITS_PER_PIXEL bitsPerPixel : 1; | |
| } PALETTE_FLAGS; | |
| typedef struct { | |
| ubyte x; | |
| ubyte y; | |
| } POSITION; | |
| typedef struct { | |
| BitfieldDisablePadding(); | |
| ubyte b : 4 <format=hex>; | |
| ubyte g : 4 <format=hex>; | |
| ubyte r : 4 <format=hex>; | |
| ubyte : 4; | |
| } COLOR <read=ReadColor, format=hex>; | |
| string ReadColor( COLOR &c ) | |
| { | |
| string s; | |
| SPrintf( s, "%06Xh", ( ( c.b * 17 ) << 16 ) | ( ( c.g * 17 ) << 8 ) | ( c.r * 17 ) ); | |
| return s; | |
| } | |
| void SetPaletteBackColor( ushort x ) | |
| { | |
| SetBackColor( ( ( ( x & 0xF ) * 17 ) << 16 ) | ( ( ( ( x >> 4 ) & 0xF ) * 17 ) << 8 ) | ( ( ( x >> 8 ) & 0xF ) * 17 ) ); | |
| } | |
| typedef struct ( int endPos ) { | |
| while( !FEof( ) && FTell() != endPos ) | |
| { | |
| SetPaletteBackColor( ReadUShort( ) ); | |
| COLOR color; | |
| } | |
| SetBackColor( cNone ); | |
| } PALETTE; | |
| typedef struct { | |
| ubyte saveData[ 96 ]; | |
| ubyte name[ 16 ] <read=ReadNameChar>; | |
| DATE birthday; | |
| GENDER gender; | |
| BLOOD_TYPE bloodType; | |
| CART lastCart; | |
| ubyte unknown <hidden=true>; | |
| ushort swanId <format=hex>; | |
| ubyte cartCount; | |
| ubyte saveCount; | |
| ushort bootCount; | |
| if ( FEof() ) | |
| return; | |
| ubyte padding[ 3 ] <hidden=true>; | |
| SYSTEM_FLAGS systemFlags; | |
| if ( systemFlags.customSplash ) | |
| { | |
| SetNameBackColor( ReadUByte( FTell( ) ) ); | |
| ubyte nameColor; | |
| SetBackColor( cNone ); | |
| ubyte unknown1 <hidden=true>; | |
| ubyte size; | |
| ubyte startFrame; | |
| ubyte endFrame; | |
| ubyte spriteCount; | |
| PALETTE_FLAGS paletteFlags; | |
| ubyte tileCount; | |
| ushort paletteOffset <read=ReadOffset>; | |
| ushort tilesetOffset <read=ReadOffset>; | |
| ushort tilemapOffset <read=ReadOffset>; | |
| ushort horizontalTilemapDestOffset <format=hex>; | |
| ushort verticalTilemapDestOffset <format=hex>; | |
| ubyte tilemapWidth; | |
| ubyte tilemapHeight; | |
| ulong codePointer <format=hex>; | |
| POSITION nameHPosition; | |
| POSITION nameVPosition; | |
| ubyte unknown2[ 2 ] <hidden=true>; | |
| ushort soundOffset <read=ReadOffset>; | |
| ushort channelOffset[ 4 ] <read=ReadOffset>; | |
| FSeek( paletteOffset + 128 ); | |
| PALETTE palette ( tilesetOffset + 128 ); | |
| ubyte tileset[ tileCount * ( 8 * ( paletteFlags.bitsPerPixel + 1 ) ) ]; | |
| ushort tilemap[ tilemapWidth * tilemapHeight ]; | |
| ubyte code[ ( soundOffset + 128 ) - FTell( ) ]; | |
| } | |
| } EEPROM; | |
| EEPROM eeprom; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment