Spyro 1 Reverse Engineering
Decompilation of functions from Spyro 1 into human readable C
 
Loading...
Searching...
No Matches
common.h File Reference
#include "custom_types.h"
#include "vector.h"

Go to the source code of this file.

Data Structures

struct  RECT
 
struct  RGBA_u8
 
struct  RGB_u8
 
struct  BGR_u8
 

Macros

#define SCREEN_LEFT_EDGE   0x0
 
#define SCREEN_RIGHT_EDGE   0x200
 
#define SCREEN_TOP_EDGE   0x0
 
#define SCREEN_BOTTOM_EDGE   0xE8
 
#define FPS   30
 
#define WORLD_UNIT   4096
 
#define GAME_UNIT   64
 

Enumerations

enum  Direction { LEFT , RIGHT }
 
enum  Buttons {
  X_BUTTON = 0x0040 , SQUARE_BUTTON = 0x0080 , CIRCLE_BUTTON = 0x0020 , TRIANGLE_BUTTON = 0x0010 ,
  UP_BUTTON = 0x1000 , RIGHT_BUTTON = 0x2000 , DOWN_BUTTON = 0x4000 , LEFT_BUTTON = 0x8000 ,
  SELECT_BUTTON = 0x0100 , START_BUTTON = 0x0800 , R1_BUTTON = 0x0008 , L1_BUTTON = 0x0004 ,
  R2_BUTTON = 0x0002 , L2_BUTTON = 0x0001 , L3_BUTTON = 0x0200 , R3_BUTTON = 0x0400
}
 
enum  GameState {
  GAMESTATE_GAMEPLAY = 0 , GAMESTATE_LOADING = 0x1 , GAMESTATE_PAUSED = 0x2 , GAMESTATE_INVENTORY = 0x3 ,
  GAMESTATE_DEATH = 0x4 , GAMESTATE_GAME_OVER = 0x5 , GAMESTATE_BETA_DRAGON_TEXTBOX_MAYBE = 0x6 , GAMESTATE_FLIGHT_LEVEL_MENU = 0x7 ,
  GAMESTATE_DRAGON_STATE = 0x8 , GAMESTATE_FLY_IN = 0x9 , GAMESTATE_EXITING_LEVEL = 0xA , GAMESTATE_DRAGON_FAIRY_TEXTBOX = 0xB ,
  GAMESTATE_BALLOONIST = 0xC , GAMESTATE_TITLE_SCREEN = 0xD , GAMESTATE_CUTSCENE = 0xE , GAMESTATE_CREDITS = 0xF
}
 
enum  SpyroHealthStates { YELLOW_SPARX = 3 , BLUE_SPARX = 2 , GREEN_SPARX = 1 , NO_SPARX = 0 }
 
enum  LevelIDS {
  ARTISANS_ID = 0xA , STONE_HILL_ID = 0xB , TOWN_SQUARE_ID = 0xD , DARK_HALLOW_ID = 0xC ,
  TOASTY_ID = 0xE , SUNNY_FLIGHT_ID = 0xF , PEACE_KEEPERS_ID = 0x14 , DRY_CANYON_ID = 0x15 ,
  CLIFF_TOWN_ID = 0x16 , ICE_CAVERN_ID = 0x17 , SHEMP_ID = 0x18 , NIGHT_FLIGHT_ID = 0x19 ,
  MAGIC_CRAFTERS_ID = 0x1E , ALPINE_RIDGE_ID = 0x1F , HIGH_CAVES_ID = 0x20 , WIZARD_PEAK_ID = 0x21 ,
  BLOWHARD_ID = 0x22 , CRYSTAL_FLIGHT_ID = 0x23 , BEAST_MAKERS_ID = 0x28 , TERRACE_VILLAGE_ID = 0x29 ,
  MISTY_BOG_ID = 0x2A , TREE_TOPS_ID = 0x2B , METALHEAD_ID = 0x2C , WILD_FLIGHT_ID = 0x2C ,
  DREAM_WEAVERS_ID = 0x32 , HAUNTED_TOWERS_ID = 0x35 , DARK_PASSAGE_ID = 0x33 , LOFTY_CASTLE_ID = 0x34 ,
  JACQUES_ID = 0x36 , ICY_FLIGHT_ID = 0x37 , GNASTYS_WORLD_ID = 0x3C , GNORC_COVE_ID = 0x3D ,
  TWILIGHT_HARBOR_ID = 0x3E , GNASTY_GNORC_ID = 0x3F , GNASTYS_LOOT_ID = 0x40
}
 
enum  InventoryMenuSelections {
  ARTISANS_MENU = 0 , PEACE_KEEPERS_MENU = 1 , MAGIC_CRAFTERS_MENU = 2 , BEAST_MAKERS_MENU = 3 ,
  DREAM_WEAVERS_MENU = 4 , GNASTYS_WORLD_MENU = 5
}
 
enum  StartMenuSelections {
  STARTMENU_CONTINUE = 0 , STARTMENU_OPTIONS = 1 , STARTMENU_INVENTORY = 2 , STARTMENU_EXIT_LEVEL = 3 ,
  STARTMENU_QUIT_GAME = 3
}
 
enum  MovementSubStates { MOVEMENT_SUBSTATE_LOADING = 0x8 , MOVEMENT_SUBSTATE_EXIT_PORTAL = 0x9 , MOVEMENT_SUBSTATE_FLY_IN_LOOP = 0xA , MOVEMENT_SUBSTATE_FLY_IN_CAMERA_180 = 0xA }
 
enum  BalloonistStates {
  BALLOONIST_STATE_NEVER_TALKED_TO_BALLOONIST = 0x0 , BALLOONIST_STATE_TEXTBOX = 0x1 , BALLOONIST_STATE_JUMPING_ONTO_BALLOON = 0x2 , BALLOONIST_STATE_BALLOON_RISING = 0x3 ,
  BALLOONIST_STATE_BALLOON_LOADING_PART_1 = 0x4 , BALLOONIST_STATE_BALLOON_LOADING_PART_2 = 0x5 , BALLOONIST_STATE_BALLOON_LOWERING = 0x6 , BALLOONIST_STATE_JUMPING_OUT_OF_BALLOON = 0x7
}
 
enum  LevelFlyInAnimations {
  FACING_LEFT = 0xCA6C , FACING_RIGHT = 0xCA3C , FACING_FORWARD = 0xCA24 , FACING_BACKWARDS = 0xCA84 ,
  FACING_DIAGONAL = 0xCA9C , RETURNING_HOME = 0xCA54
}
 

Functions

int printf (const char *format,...)
 
int sprintf (char *output, const char *format,...)
 
void memset (void *str, int c, int n)
 
int rand ()
 
void srand (int seed)
 
void Maybe_ArrayCopy (int *outputArray, int *inputArray, int arrayLength)
 
void RenderShadedMobys ()
 Renders shaded moby objects in the world. (Gems, HUD Elements, etc.)
Address: 0x80022a2c.
 
void RenderNormalMobys ()
 Renders normal moby objects in the world. (Enemies, Chests, Dragons, etc.)
Address: 0x8001f798.
 
void RenderAllObjects ()
 Renders all objects in the world. (Enemies, Chests, Dragons, etc.)
Address: 0x8001f798.
 
void PrimitiveAlphaHack (void *param_1, int param_2, int param_3, short colorSpace, int param_5)
 This is a weird hack that seems to be related to transparency for primitaves?
Address: 0x80060670.
 
void CopyHudToShaded ()
 
void DrawLine (int point1X, int point1Y, int point2X, int point2Y)
 Draws a golden line to the screen
Address: 0x8001844c.
 
void FillScreenColor (int colorSpace, char r, char g, char b)
 
void PlayIntroCutscenes ()
 
void TheAdventureBegins ()
 
void TheAdventureContinues ()
 
void LockCameraToSpyro (void)
 
void Vec3IntToShortDiv4 (short *Vec3ShortPTR, int *Vec3PTR)
 
char * GetNextParticleSlot (char param_1)
 
void CreateParticle (int param_1, int param_2, int **ptrToMoby, int *param_4)
 
void UpdateMobyCollision (int param_1, unsigned int param_2)
 
int PlaySoundEffect (int soundEffectID, int ptrToMoby, int playbackMode, char *param_4)
 
void PlayMusicTrack (int track_number, int flags)
 Plays/Continues a music track
Address: 0x800567f4.
 
int LoadImageOrTexture (RECT *rect, int *p)
 
int DrawSync (int mode)
 
void Maybe_ResetHudTimers (void)
 

Variables

bool _isPastTitleScreen
 If has started new game/continue game, then is 1 for true. Basically after you leave the title screen this is always 1.
Address: 0x8007566c.
 
bool _isLoading
 true/1 if is in loading screen.
Address: 0x800756B0
 
bool _isInsideOptionsMenu
 true/1 If inside options menu in start menu.
Address: 0x800757C8
 
bool _canFlyIn
 true/1 If can fly in to level. This is always 1. If set to 0, will just fade in instead of flying in. I assume this is a leftover from prototypes?
Address: 0x800756D0
 
int _globalTimer
 This is the global timer. It is running at all times from game boot up past BIOS.
Address: 0x800749e0.
 
int _pausedTimer
 This is the pause/inventory menu timer. It is only running in those menus.
Address: 0x800758B8.
 
int _loadingTimer
 This is the pause/inventory menu timer. It is only running in those menus.
Address: 0x8007588c.
 
int _levelTimerWhenActive
 This is a level specific timer. This timer is running when when you are able to control spyro, and doesn't reset until you enter a new level.
Address: 0x8007572C.
 
int _levelTimer_60fps
 This is a level specific timer that runs at 60fps. This timer is running at all times, and doesn't reset until you enter a new level.
Address: 0x800758C8.
 
int _vSyncTimer_60fps
 This is a global timer at 60fps. It is running at all times, and controls the vSync. If frozen, video freezes. Can be unfrozen.
Address: 0x800749E0.
 
int _wobbleAndOpacityTimer
 This is a timer that is often used for changing the opacity of things like lines, the shimmer of text, etc.
Address: 0x800770f4.
 
int _gameState
 Main gamestate. Gamestate values are stored in the GameState enums.
Address: 0x800757D8.
 
unsigned short _currentButtonsHeld
 Value coorsponding the the current button(s) being held.
Address: 0x80077380.
 
unsigned short _currentButtonsPressed
 Value coorsponding the the current button(s) that were pressed for 1 frame. Goes back to 0 after 1 frame.
Address: 0x80077378.
 
int _secondController
 STILL RESEARCHING
Address: 0x80078E50.
 
int _movementSubState
 Research this more. 0xA is the loop for example.
Address: 0x80078AD4.
 
int _isInPortal
 0x5 for in portal, 0xF for loading afterwards. Stays on 0xF until next portal.
Address: 0x80078C70
 
short _globalGemCount
 Total amount of global gems
Address: 0x80075860.
 
int _globalDragonCount
 Total amount of global dragons
Address: 0x80075750.
 
int _globalEggCount
 Total amount of global eggs
Address: 0x80075810.
 
int _levelID
 Current Level ID according to the LevelIDS enum
Address: 0x800758B4.
 
char _portalToExitFromInHW
 Level ID for which portal to exit from in Homeworld. Uses same LevelIDS enum
Address: 0x800758AC.
 
short _flyInAnimation
 This is what determines the fly in animation during the loading screen of a level
Address: 0x80076EA8.
 
Vec3 _cameraPosition
 Camera Position
Address: 0x80076DF8.
 
CameraAngle _cameraAngle
 Camera Angle (yaw, pitch, roll)
Address: 0x80076E1C.
 
short _cameraRotationMatrix [3][3]
 
short _cameraPureRotationMatrix [3][3]
 
short _sinArray [256]
 A scaled up sin lookup table
Address: 0x8006cbf8.
 
char _mainMenuState
 This is the current state of the main menu. Should make an enum for this
Address: 0x80078D88.
 
int _balloonistState
 The State for the balloonist. Should make an enum for this.
Address: 0x800777e8.
 
int _startMenuSelection
 This is the current option selected in the main start menu, according to the StartMenuSelections enum.
Address: 0x80075720.
 
int _inventoryMenuScreen
 This is the current homeworld menu in the inventory menu according to the InventoryMenuSelections enum's.
Address: 0x80075744.
 
char _whichCutscene
 Which cutscene is currently being played
Address: 0x80078D94.
 
char _effect_ScreenFadeIn
 This is what determines how much to fill the screen with a black fade in effect.
Address: 0x80075918.
 
char _effect_ScreenLetterBox
 This is what determines how much to fill the screen with the top and bottom letterbox effect.
Address: 0x800756C0.
 
char _collectablesStateFlags [1231]
 The array for what collectables you have collected globally so far.
Address: 0x80077900.
 
int * _ptr_levelMobys
 This is a pointer to the start of the level moby's array of stucts.
Address: 0x80075828.
 
int * _ptr_dynamicLevelMobys
 This is a pointer to the start of the dynamic level moby's array.
Address: 0x8007573C.
 
int * _ptr_levelMobySpecialData
 This is a pointer to the start of the level moby's special data array of structs.
Address: 0x80075930.
 
int * _ptr_primitivesArray
 
int * _ptr_arrayGraphicsRelatedPointers
 
int _ptrTextUnk
 
char * _ptr_hudMobys
 
char * _ptr_particleLinkedList
 
char _hudChestState
 
char _hudDragonState
 
char _hudLivesState
 
char _hudEggsState
 
char _hudAnimationState
 
int _hudElementsSpinTimer
 
int _unk_spinRelated
 
char * _localSoundEffects
 
int _musicLevelTrack
 The music track that is associated with the level you're currently in.
Address: 0x80075828.
 
int * _maybe_ptr_levelTextureRelated
 
byte _cdStatus
 

Macro Definition Documentation

◆ FPS

#define FPS   30

Definition at line 16 of file common.h.

◆ GAME_UNIT

#define GAME_UNIT   64

Definition at line 19 of file common.h.

◆ SCREEN_BOTTOM_EDGE

#define SCREEN_BOTTOM_EDGE   0xE8

Definition at line 14 of file common.h.

◆ SCREEN_LEFT_EDGE

#define SCREEN_LEFT_EDGE   0x0

Definition at line 11 of file common.h.

◆ SCREEN_RIGHT_EDGE

#define SCREEN_RIGHT_EDGE   0x200

Definition at line 12 of file common.h.

◆ SCREEN_TOP_EDGE

#define SCREEN_TOP_EDGE   0x0

Definition at line 13 of file common.h.

◆ WORLD_UNIT

#define WORLD_UNIT   4096

Definition at line 18 of file common.h.

Enumeration Type Documentation

◆ BalloonistStates

Enumerator
BALLOONIST_STATE_NEVER_TALKED_TO_BALLOONIST 
BALLOONIST_STATE_TEXTBOX 
BALLOONIST_STATE_JUMPING_ONTO_BALLOON 
BALLOONIST_STATE_BALLOON_RISING 
BALLOONIST_STATE_BALLOON_LOADING_PART_1 
BALLOONIST_STATE_BALLOON_LOADING_PART_2 
BALLOONIST_STATE_BALLOON_LOWERING 
BALLOONIST_STATE_JUMPING_OUT_OF_BALLOON 

Definition at line 151 of file common.h.

◆ Buttons

enum Buttons
Enumerator
X_BUTTON 
SQUARE_BUTTON 
CIRCLE_BUTTON 
TRIANGLE_BUTTON 
UP_BUTTON 
RIGHT_BUTTON 
DOWN_BUTTON 
LEFT_BUTTON 
SELECT_BUTTON 
START_BUTTON 
R1_BUTTON 
L1_BUTTON 
R2_BUTTON 
L2_BUTTON 
L3_BUTTON 
R3_BUTTON 

Definition at line 27 of file common.h.

◆ Direction

enum Direction
Enumerator
LEFT 
RIGHT 

Definition at line 21 of file common.h.

◆ GameState

enum GameState
Enumerator
GAMESTATE_GAMEPLAY 
GAMESTATE_LOADING 
GAMESTATE_PAUSED 
GAMESTATE_INVENTORY 
GAMESTATE_DEATH 
GAMESTATE_GAME_OVER 
GAMESTATE_BETA_DRAGON_TEXTBOX_MAYBE 
GAMESTATE_FLIGHT_LEVEL_MENU 
GAMESTATE_DRAGON_STATE 
GAMESTATE_FLY_IN 
GAMESTATE_EXITING_LEVEL 
GAMESTATE_DRAGON_FAIRY_TEXTBOX 
GAMESTATE_BALLOONIST 
GAMESTATE_TITLE_SCREEN 
GAMESTATE_CUTSCENE 
GAMESTATE_CREDITS 

Definition at line 51 of file common.h.

◆ InventoryMenuSelections

Enumerator
ARTISANS_MENU 
PEACE_KEEPERS_MENU 
MAGIC_CRAFTERS_MENU 
BEAST_MAKERS_MENU 
DREAM_WEAVERS_MENU 
GNASTYS_WORLD_MENU 

Definition at line 123 of file common.h.

◆ LevelFlyInAnimations

Enumerator
FACING_LEFT 
FACING_RIGHT 
FACING_FORWARD 
FACING_BACKWARDS 
FACING_DIAGONAL 
RETURNING_HOME 

Definition at line 165 of file common.h.

◆ LevelIDS

enum LevelIDS
Enumerator
ARTISANS_ID 
STONE_HILL_ID 
TOWN_SQUARE_ID 
DARK_HALLOW_ID 
TOASTY_ID 
SUNNY_FLIGHT_ID 
PEACE_KEEPERS_ID 
DRY_CANYON_ID 
CLIFF_TOWN_ID 
ICE_CAVERN_ID 
SHEMP_ID 
NIGHT_FLIGHT_ID 
MAGIC_CRAFTERS_ID 
ALPINE_RIDGE_ID 
HIGH_CAVES_ID 
WIZARD_PEAK_ID 
BLOWHARD_ID 
CRYSTAL_FLIGHT_ID 
BEAST_MAKERS_ID 
TERRACE_VILLAGE_ID 
MISTY_BOG_ID 
TREE_TOPS_ID 
METALHEAD_ID 
WILD_FLIGHT_ID 
DREAM_WEAVERS_ID 
HAUNTED_TOWERS_ID 
DARK_PASSAGE_ID 
LOFTY_CASTLE_ID 
JACQUES_ID 
ICY_FLIGHT_ID 
GNASTYS_WORLD_ID 
GNORC_COVE_ID 
TWILIGHT_HARBOR_ID 
GNASTY_GNORC_ID 
GNASTYS_LOOT_ID 

Definition at line 79 of file common.h.

◆ MovementSubStates

Enumerator
MOVEMENT_SUBSTATE_LOADING 
MOVEMENT_SUBSTATE_EXIT_PORTAL 
MOVEMENT_SUBSTATE_FLY_IN_LOOP 
MOVEMENT_SUBSTATE_FLY_IN_CAMERA_180 

Definition at line 143 of file common.h.

◆ SpyroHealthStates

Enumerator
YELLOW_SPARX 
BLUE_SPARX 
GREEN_SPARX 
NO_SPARX 

Definition at line 71 of file common.h.

◆ StartMenuSelections

Enumerator
STARTMENU_CONTINUE 
STARTMENU_OPTIONS 
STARTMENU_INVENTORY 
STARTMENU_EXIT_LEVEL 
STARTMENU_QUIT_GAME 

Definition at line 133 of file common.h.