User:ParadiseAdi/Code

From Bejeweled Wiki
Jump to navigation Jump to search

This page is used as a pastebin for different code snippets.

Bejeweled Twist Savegame

Highlighted structure

This is a C-style structure, usable with Hex Workshop (.hsl).

The useful structures are Savegame which can be applied to the start of the file, and Gem which describes one grid entry with a gem.

savegame.hsl

// Version 3 #pragma byteorder(little_endian) #pragma hide() typedef struct _string16 { short len; char string[len]; } string16; #pragma enumsize(2) typedef enum _color { Red = 0, White = 1, Green = 2, Yellow = 3, Purple = 4, Orange = 5, Blue = 6, Coal = 7 // Game crash, only use with Coal type. } Color; #pragma show() struct Gem { Color Color1; Color Color2; // unused? struct Type { unsigned short Fruit  : 1; // = 1, unsigned short Skull  : 1; // = 2, unsigned short Locked  : 1; // = 4, unsigned short Lightning  : 1; // = 8, unsigned short Flame  : 1; // = 0x10, unsigned short LockedHidden  : 1; // = 0x20, unsigned short Ice  : 1; // = 0x40, unsigned short Angel  : 1; // = 0x80, unsigned short Doom  : 1; // = 0x100, unsigned short Bomb  : 1; // = 0x200, unsigned short Coal  : 1; // = 0x400, unsigned short UnknownGem1  : 1; // = 0x800, unsigned short VioletSparkles : 1; // = 0x1000, unsigned short UnknownGem2  : 1; // = 0x2000, unsigned short UnknownGem3  : 1; // = 0x4000, unsigned short UnknownGem4  : 1; // = 0x8000 }; short Unknown1; // always 0, unused? short Counter; short Unknown2; short Unknown3; short Unknown4; // always 0x100 short Matchable; // Boolean short Unknown5; // always 0 short Unknown6; // always 0 short Unknown7; // always 0 }; struct Savegame { #pragma lockAt(0) blob UnknownHeader[739]; string16 SecondsPlayed; // unsure blob UnknownData1[50]; struct Board { int Width; int Length; struct GemLines { // Bug: struct X {...}[N] does not work struct Gem Gems[8]; }[8]; }; };