Path: blob/master/SonicMania/GameVariables.h
338 views
#ifndef GAME_VARIABLES_H1#define GAME_VARIABLES_H23// =========================4// GAME ENUMS5// =========================67typedef enum {8#if !MANIA_USE_PLUS9MODE_NOSAVE,10#endif11MODE_MANIA, // officially called "MODE_SAVEGAME" in pre-plus, but it's easier to re-use names lol12#if MANIA_USE_PLUS13MODE_ENCORE,14#endif15MODE_TIMEATTACK,16MODE_COMPETITION,17} GameModes;1819typedef enum {20ID_NONE = 0 << 0,21ID_SONIC = 1 << 0,22ID_TAILS = 1 << 1,23ID_KNUCKLES = 1 << 2,24#if MANIA_USE_PLUS25ID_MIGHTY = 1 << 3,26ID_RAY = 1 << 4,27#endif28ID_TAILS_ASSIST = ID_TAILS << 8,29ID_KNUCKLES_ASSIST = ID_KNUCKLES << 8, // custom-added, can be used to check if "& knux" is active30ID_DEFAULT_PLAYER = ID_SONIC | ID_TAILS_ASSIST,31} PlayerIDs;3233#define GET_CHARACTER_ID(playerNum) (((globals->playerID >> (8 * ((playerNum)-1))) & 0xFF))34#define CHECK_CHARACTER_ID(characterID, playerNum) (((globals->playerID >> (8 * ((playerNum)-1))) & 0xFF) == (characterID))3536#if MANIA_USE_PLUS37#define GET_STOCK_ID(stockNum) (((globals->stock >> (8 * ((stockNum)-1))) & 0xFF))38#define CHECK_STOCK_ID(characterID, stockNum) (((globals->stock >> (8 * ((stockNum)-1))) & 0xFF) == (characterID))39#endif4041typedef enum { ITEMS_FIXED, ITEMS_RANDOM, ITEMS_TELEPORT } ItemModes;4243typedef enum {44MEDAL_DEBUGMODE = 1 << 0,45MEDAL_ANDKNUCKLES = 1 << 1,46MEDAL_PEELOUT = 1 << 2,47MEDAL_INSTASHIELD = 1 << 3,48MEDAL_NODROPDASH = 1 << 4,49#if MANIA_USE_PLUS50MEDAL_NOTIMEOVER = 1 << 5,51#endif52} MedalMods;5354typedef enum { MEDIA_DEMO } CategoryIDS;5556typedef enum { FORCE_SPLIT } ScreenSplit;5758typedef enum { NO_SAVE_SLOT = 255 } SaveSlots;5960typedef enum { WIDE_SCR_XSIZE = 424, WIDE_SCR_XCENTER = 212 } ScreenSizes;6162#if RETRO_REV0263typedef enum {64// General Filters65FILTER_NONE = 0 << 0,66FILTER_SLOT1 = 1 << 0,67FILTER_SLOT2 = 1 << 1,68FILTER_SLOT3 = 1 << 2,69FILTER_SLOT4 = 1 << 3,70FILTER_SLOT5 = 1 << 4,71FILTER_SLOT6 = 1 << 5,72FILTER_SLOT7 = 1 << 6,73FILTER_SLOT8 = 1 << 7,74FILTER_ANY = FILTER_SLOT1 | FILTER_SLOT2 | FILTER_SLOT3 | FILTER_SLOT4 | FILTER_SLOT5 | FILTER_SLOT6 | FILTER_SLOT7 | FILTER_SLOT8,75} SceneFilters;76#endif7778#if MANIA_USE_PLUS79typedef enum {80// Mania-Specific filter uses81FILTER_BOTH = FILTER_SLOT1,82FILTER_MANIA = FILTER_SLOT2,83FILTER_ENCORE = FILTER_SLOT3,84} ManiaFilters;8586typedef enum { DLC_PLUS } GameDLC;87#endif8889typedef enum {90PLANEFILTER_NONE,91PLANEFILTER_AL, // - Plane A, Low Layer92PLANEFILTER_BL, // - Plane B, Low Layer93PLANEFILTER_AH, // - Plane A, High Layer94PLANEFILTER_BH, // - Plane B, High Layer95} PlaneFilterTypes;9697typedef enum {98SLOT_PLAYER1 = 0,99SLOT_PLAYER2 = 1,100#if MANIA_USE_PLUS101SLOT_PLAYER3 = 2,102SLOT_PLAYER4 = 3,103SLOT_POWERUP1 = 4,104SLOT_PLAYER5 = 4, // Used in TMZ2Outro105SLOT_POWERUP2 = 5,106SLOT_PLAYER6 = 5, // Used in TMZ2Outro107SLOT_POWERUP3 = 6,108SLOT_POWERUP4 = 7,109SLOT_POWERUP1_2 = 8,110SLOT_POWERUP2_2 = 9,111SLOT_POWERUP3_2 = 10,112SLOT_POWERUP4_2 = 11,113#else114SLOT_POWERUP1 = 2,115SLOT_POWERUP2 = 3,116SLOT_POWERUP1_2 = 4,117SLOT_POWERUP2_2 = 5,118#endif119SLOT_BSS_SETUP = 8,120SLOT_PBL_SETUP = 8,121SLOT_UFO_SETUP = 8,122SLOT_MUSIC = 9,123SLOT_BSS_HUD = 10,124SLOT_UFO_CAMERA = 10,125SLOT_PBL_CAMERA = 10,126SLOT_BSS_MESSAGE = 11,127SLOT_UFO_HUD = 11,128SLOT_ZONE = MANIA_USE_PLUS ? 12 : 8,129// 13 = ???130// 14 = ???131SLOT_CUTSCENESEQ = 15,132SLOT_PAUSEMENU = 16,133SLOT_GAMEOVER = 16,134SLOT_ACTCLEAR = 16,135SLOT_PAUSEMENU_UICONTROL = 17,136SLOT_PAUSEMENU_BUTTON1 = 18,137SLOT_PAUSEMENU_BUTTON2 = 19,138SLOT_PAUSEMENU_BUTTON3 = 20,139SLOT_DIALOG = 21,140SLOT_DIALOG_UICONTROL = 22,141SLOT_DIALOG_BUTTONS = 23,142SLOT_DIALOG_BUTTON2 = 24,143SLOT_DIALOG_BUTTON3 = 25,144#if MANIA_USE_PLUS145SLOT_POPOVER = 26,146SLOT_POPOVER_UICONTROL = 27,147SLOT_POPOVER_BUTTONS = 28,148SLOT_POPOVER_BUTTON2 = 29,149SLOT_POPOVER_BUTTON3 = 30,150SLOT_POPOVER_BUTTON4 = 31,151#endif152SLOT_BIGBUBBLE_P1 = 32,153SLOT_BIGBUBBLE_P2 = 33,154#if MANIA_USE_PLUS155SLOT_BIGBUBBLE_P3 = 34,156SLOT_BIGBUBBLE_P4 = 36,157#endif158SLOT_BSS_HORIZON = 32,159SLOT_UFO_SPEEDLINES = 34,160SLOT_UFO_PLASMA = 36,161#if MANIA_USE_PLUS162SLOT_REPLAYRECORDER_PLAYBACK = 36,163SLOT_REPLAYRECORDER_RECORD = 37,164SLOT_MUSICSTACK_START = 40,165//[41-47] are part of the music stack166SLOT_MUSICSTACK_END = 48,167#endif168SLOT_CAMERA1 = 60,169SLOT_CAMERA2 = 61,170SLOT_CAMERA3 = 62,171SLOT_CAMERA4 = 63,172} ReservedEntities;173174typedef enum {175PRESENCE_GENERIC,176PRESENCE_MENU,177PRESENCE_MANIA,178#if MANIA_USE_PLUS179PRESENCE_ENCORE,180#endif181PRESENCE_TA,182PRESENCE_COMP,183PRESENCE_TITLE,184} PresenceTypes;185186#if MANIA_USE_PLUS187typedef enum {188SECRET_RICKYMODE = 1 << 0,189SECRET_SUPERDASH = 1 << 1,190} GameCheats;191#endif192193// =========================194// GLOBAL VARIABLES195// =========================196197typedef struct {198int32 gameMode;199int32 playerID; // active character IDs (usually leader & sidekick)200int32 specialCleared;201int32 specialRingID;202int32 blueSpheresID;203int32 blueSpheresInit;204int32 atlEnabled;205int32 atlEntityCount;206int32 atlEntitySlot[0x20];207int32 atlEntityData[0x4000];208int32 saveLoaded;209int32 saveRAM[0x4000];210int32 saveSlotID;211int32 noSaveSlot[0x400];212int32 menuParam[0x4000];213int32 itemMode;214int32 suppressTitlecard;215int32 suppressAutoMusic;216int32 competitionSession[0x4000];217int32 medalMods;218int32 parallaxOffset[0x100];219int32 enableIntro;220int32 optionsLoaded;221int32 optionsRAM[0x80];222int32 presenceID;223int32 medallionDebug;224int32 noSave;225int32 notifiedAutosave;226int32 recallEntities;227int32 restartRings;228int32 restart1UP;229int32 restartPowerups;230int32 restartPos[8];231int32 restartSlot[4];232int32 restartDir[4];233int32 restartMinutes;234int32 restartSeconds;235int32 restartMilliseconds;236int32 tempMinutes;237int32 tempSeconds;238int32 tempMilliseconds;239int32 restartScore;240int32 restartScore1UP;241int32 restartLives[4];242#if GAME_VERSION != VER_100243int32 restartMusicID;244#endif245int32 restartFlags;246int32 tempFlags;247int32 continues;248int32 initCoolBonus;249int32 coolBonus[4];250#if MANIA_USE_PLUS251int32 replayWriteBuffer[0x40000];252int32 replayReadBuffer[0x40000];253int32 replayTempWBuffer[0x40000];254int32 replayTempRBuffer[0x40000];255int32 replayTableID;256int32 replayTableLoaded;257int32 taTableID;258int32 taTableLoaded;259int32 stock; // order of buddies (not including the leader/sidekick)260int32 characterFlags; // characters in the "party"261int32 vapeMode;262int32 secrets;263int32 superSecret;264int32 superMusicEnabled;265int32 lastHasPlus;266int32 hasPlusInitial;267#endif268} GlobalVariables;269270extern GlobalVariables *globals;271272// =========================273// GAME HELPERS274// =========================275276#if MANIA_USE_PLUS277#define isMainGameMode() (globals->gameMode == MODE_MANIA || globals->gameMode == MODE_ENCORE)278#else279#define isMainGameMode() (globals->gameMode == MODE_NOSAVE || globals->gameMode == MODE_MANIA)280#endif281282// used mainly for cutscenes283#define MANIA_GET_PLAYER(p1, p2, cam) \284EntityPlayer *p1 = RSDK_GET_ENTITY(SLOT_PLAYER1, Player); \285EntityPlayer *p2 = RSDK_GET_ENTITY(SLOT_PLAYER2, Player); \286EntityCamera *cam = RSDK_GET_ENTITY(SLOT_CAMERA1, Camera);287288// "Base" Classes289#define MANIA_PLATFORM_BASE \290RSDK_ENTITY \291StateMachine(state); \292StateMachine(stateCollide); \293int32 type; \294Vector2 amplitude; \295int32 speed; \296bool32 hasTension; \297int8 frameID; \298uint8 collision; \299Vector2 tileOrigin; \300Vector2 centerPos; \301Vector2 drawPos; \302Vector2 collisionOffset; \303int32 stood; \304int32 timer; \305int32 stoodAngle; \306uint8 stoodPlayers; \307uint8 pushPlayersL; \308uint8 pushPlayersR; \309Hitbox hitbox; \310Animator animator; \311int32 childCount;312313#define MANIA_BUTTON_BASE \314RSDK_ENTITY \315int32 type; \316bool32 walkOnto; \317uint8 tag; \318bool32 down; \319bool32 toggled; \320bool32 currentlyActive; \321bool32 activated; \322bool32 wasActivated; \323int32 pressPos;324325#define MANIA_UI_ITEM_BASE \326RSDK_ENTITY \327StateMachine(state); \328void (*processButtonCB)(void); \329bool32 (*touchCB)(void); \330void (*actionCB)(void); \331void (*selectedCB)(void); \332void (*failCB)(void); \333void (*buttonEnterCB)(void); \334void (*buttonLeaveCB)(void); \335bool32 (*checkButtonEnterCB)(void); \336bool32 (*checkSelectedCB)(void); \337int32 timer; \338Vector2 startPos; \339Entity *parent; \340Vector2 touchPosSizeS; \341Vector2 touchPosOffsetS; \342bool32 touchPressed; \343Vector2 touchPosSizeM[4]; /*size of the touchPos: in 16-bit shifted format*/ \344Vector2 touchPosOffsetM[4]; /*offset of the touchPos: 0,0 is entity pos, negative is left/up, positive is right/down*/ \345void (*touchPosCallbacks[4])(void); \346int32 touchPosCount; \347int32 touchPosID; \348bool32 isSelected; \349bool32 disabled;350351#define MANIA_CUTSCENE_BASE \352RSDK_ENTITY \353Vector2 size; \354bool32 activated; \355Animator animator; /* unused, afaik */ \356Hitbox hitbox;357358#endif //! GAME_VARIABLES_H359360361