Skip to content

Commit

Permalink
Vita Builds!
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicMastr committed Aug 18, 2022
1 parent 6f0f547 commit 1d9f6df
Show file tree
Hide file tree
Showing 25 changed files with 127 additions and 94 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,4 @@ Ignored/
android/local.properties

*.res
export.yml
24 changes: 22 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,37 @@ set(GAME_NAME SonicMania CACHE STRING "The game directory to look into")

set(OUTPUT_NAME "Game" CACHE STRING "The name of the built library")

add_library(SonicMania SHARED
set(sources
${GAME_NAME}/Game.c
${GAME_NAME}/Objects/All.c
)

if (VITA)
set(VITASDK_CMAKE_FILE "$ENV{VITASDK}/share/vita.cmake" CACHE PATH "VitaSDK CMake functions file")
include("${VITASDK_CMAKE_FILE}" REQUIRED)

add_executable(SonicMania
${sources}
)
else()
add_library(SonicMania SHARED
${sources}
)
endif()

target_include_directories(SonicMania PRIVATE
${GAME_NAME}/
${GAME_NAME}/Objects/
)

set_target_properties(SonicMania PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
if (VITA)
vita_create_self(${OUTPUT_NAME}.suprx SonicMania
GEN_EXPORTS export.yml
UNSAFE
)
else()
set_target_properties(SonicMania PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
endif()

unset(GAME_NAME CACHE)
unset(OUTPUT_NAME CACHE)
6 changes: 6 additions & 0 deletions SonicMania/Game.c
Original file line number Diff line number Diff line change
Expand Up @@ -885,3 +885,9 @@ int32 RSDK_main(int32 argc, char **argv, void *linkLogicPtr); // make sure other

int32 GAME_MAIN(int32 argc, char *argv[]) { return RSDK_main(argc, argv, LinkGameLogicDLL); }
#endif

#ifdef __vita__
void main() __attribute__ ((weak, alias ("module_start")));
int module_start(int argc, const void *args) {};
int module_stop(int argc, const void *args) {};
#endif
17 changes: 8 additions & 9 deletions SonicMania/GameVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ typedef enum {
typedef enum { ITEMS_FIXED, ITEMS_RANDOM, ITEMS_TELEPORT } ItemModes;

typedef enum {
MEDAL_DEBUGMODE,
MEDAL_ANDKNUCKLES,
MEDAL_PEELOUT,
MEDAL_INSTASHIELD,
MEDAL_NODROPDASH,
MEDAL_DEBUGMODE = 1 << 0,
MEDAL_ANDKNUCKLES = 1 << 1,
MEDAL_PEELOUT = 1 << 2,
MEDAL_INSTASHIELD = 1 << 3,
MEDAL_NODROPDASH = 1 << 4,
#if MANIA_USE_PLUS
MEDAL_NOTIMEOVER,
MEDAL_NOTIMEOVER = 1 << 5,
#endif
} MedalMods;
#define GET_MEDAL_MOD(medal) (1 << medal)

typedef enum { FORCE_SPLIT = 2 } ScreenSplit;

Expand Down Expand Up @@ -164,8 +163,8 @@ typedef enum {

#if MANIA_USE_PLUS
typedef enum {
SECRET_RICKYMODE = 0,
SECRET_SUPERDASH = 1,
SECRET_RICKYMODE = 1 << 0,
SECRET_SUPERDASH = 1 << 1,
} GameCheats;
#endif

Expand Down
5 changes: 1 addition & 4 deletions SonicMania/Objects/Common/BreakableWall.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,7 @@ void BreakableWall_CheckBreak_Wall(void)
switch (player->characterID) {
default: break;

case ID_SONIC:
canBreak |= player->animator.animationID == ANI_DROPDASH;
canBreak |= player->superState == SUPERSTATE_SUPER;
break;
case ID_SONIC: canBreak |= player->superState == SUPERSTATE_SUPER; break;

case ID_KNUCKLES: canBreak = true; break;
}
Expand Down
6 changes: 3 additions & 3 deletions SonicMania/Objects/FBZ/FBZSetup.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void FBZSetup_StageLoad(void)

BGSwitch->switchCallback[FBZ_BG_INSIDE1] = FBZSetup_BGSwitch_ShowInside1;
BGSwitch->switchCallback[FBZ_BG_INSIDE2] = FBZSetup_BGSwitch_ShowInside2;
BGSwitch->switchCallback[FBZ_BG_INSIDE1_DUP] = FBZSetup_BGSwitch_ShowInside1_Dup;
BGSwitch->switchCallback[FBZ_BG_INSIDE1_NOSTORM] = FBZSetup_BGSwitch_ShowInside1_NoStorm;

TileLayer *backgroundInside = RSDK.GetTileLayer(0);
backgroundInside->drawGroup[0] = 0;
Expand Down Expand Up @@ -231,7 +231,7 @@ void FBZSetup_BGSwitch_ShowInside2(void)
}
}

void FBZSetup_BGSwitch_ShowInside1_Dup(void)
void FBZSetup_BGSwitch_ShowInside1_NoStorm(void)
{
RSDK.GetTileLayer(0)->drawGroup[BGSwitch->screenID] = DRAWGROUP_COUNT;

Expand Down Expand Up @@ -285,7 +285,7 @@ void FBZSetup_EditorLoad(void)
RSDK_ACTIVE_VAR(BGSwitch, bgID);
RSDK_ENUM_VAR("Show Inside 1", FBZ_BG_INSIDE1);
RSDK_ENUM_VAR("Show Inside 2", FBZ_BG_INSIDE2);
RSDK_ENUM_VAR("Show Inside 1 (Duplicate)", FBZ_BG_INSIDE1_DUP);
RSDK_ENUM_VAR("Show Inside 1 (No Storm)", FBZ_BG_INSIDE1_NOSTORM);

RSDK_ACTIVE_VAR(Decoration, type);
RSDK_ENUM_VAR("Blueprint 1", FBZ_DECORATION_BLUEPRINT1);
Expand Down
4 changes: 2 additions & 2 deletions SonicMania/Objects/FBZ/FBZSetup.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ typedef enum { FBZ_GENERICTRIGGER_EXTERIOR, FBZ_GENERICTRIGGER_INTERIOR } Generi
typedef enum {
FBZ_BG_INSIDE1,
FBZ_BG_INSIDE2,
FBZ_BG_INSIDE1_DUP,
FBZ_BG_INSIDE1_NOSTORM,
} BGSwitchIDsFBZ;

typedef enum {
Expand Down Expand Up @@ -65,7 +65,7 @@ void FBZSetup_Scanline_BGInside(ScanlineInfo *scanlines);

void FBZSetup_BGSwitch_ShowInside1(void);
void FBZSetup_BGSwitch_ShowInside2(void);
void FBZSetup_BGSwitch_ShowInside1_Dup(void);
void FBZSetup_BGSwitch_ShowInside1_NoStorm(void);

void FBZSetup_Trigger_ShowExterior(void);
void FBZSetup_Trigger_ShowInterior(void);
Expand Down
2 changes: 1 addition & 1 deletion SonicMania/Objects/GHZ/DERobot.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ void DERobot_State_SetupBoss(void)
if (self->timer == 60) {
CREATE_ENTITY(DERobot, INT_TO_VOID(DEROBOT_TARGET_EDGE), self->position.x, 0x3080000);
RSDK.PlaySfx(DERobot->sfxTargeting, false, 255);
Music_TransitionTrack(TRACK_EGGMAN1, 0.125);
Music_TransitionTrack(TRACK_EGGMAN1, 0.0125);
}

if (self->timer == 160) {
Expand Down
2 changes: 1 addition & 1 deletion SonicMania/Objects/Global/ActClear.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void ActClear_Create(void *data)
case 9:
if (!SceneInfo->debugMode && globals->gameMode < MODE_TIMEATTACK && SceneInfo->seconds == 59) {
#if MANIA_USE_PLUS
if (globals->gameMode != MODE_ENCORE && !(globals->medalMods & GET_MEDAL_MOD(MEDAL_NOTIMEOVER)))
if (globals->gameMode != MODE_ENCORE && !(globals->medalMods & MEDAL_NOTIMEOVER))
#endif
self->timeBonus = 100000;
}
Expand Down
2 changes: 1 addition & 1 deletion SonicMania/Objects/Global/Animals.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void Animals_Create(void *data)

int32 type = ANIMAL_POCKY;
#if MANIA_USE_PLUS
if (!(globals->secrets & GET_MEDAL_MOD(SECRET_RICKYMODE)))
if (!(globals->secrets & SECRET_RICKYMODE))
#endif
type = VOID_TO_INT(data);

Expand Down
4 changes: 2 additions & 2 deletions SonicMania/Objects/Global/HUD.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void HUD_Draw(void)
#if GAME_VERSION != VER_100
#if MANIA_USE_PLUS
self->timeFlashFrame = 0;
if ((SceneInfo->minutes == 9 && isMainGameMode() && !(globals->medalMods & GET_MEDAL_MOD(MEDAL_NOTIMEOVER))) && ActClear->disableTimeBonus)
if ((SceneInfo->minutes == 9 && isMainGameMode() && !(globals->medalMods & MEDAL_NOTIMEOVER)) && ActClear->disableTimeBonus)
self->timeFlashFrame = (Zone->persistentTimer >> 3) & 1;
#else
if (SceneInfo->minutes == 9 && globals->gameMode < MODE_TIMEATTACK)
Expand Down Expand Up @@ -173,7 +173,7 @@ void HUD_Draw(void)
// Draw Minutes
drawPos.x -= TO_FIXED(9);
#if MANIA_USE_PLUS
if (SceneInfo->minutes > 9 && globals->medalMods & GET_MEDAL_MOD(MEDAL_NOTIMEOVER))
if (SceneInfo->minutes > 9 && globals->medalMods & MEDAL_NOTIMEOVER)
HUD_DrawNumbersBase10(&drawPos, SceneInfo->minutes, 2);
else
#endif
Expand Down
4 changes: 2 additions & 2 deletions SonicMania/Objects/Global/ItemBox.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,11 +1112,11 @@ void ItemBox_HandleObjectCollisions(void)
if (RSDK.CheckObjectCollisionBox(ice, &ice->hitboxBlock, self, &ItemBox->hitboxItemBox, true) == C_TOP) {
self->position.x += ice->playerMoveOffset.x;
self->position.y += ice->playerMoveOffset.y;
self->position.y = TO_FIXED(self->position.y);
self->position.y &= 0xFFFF0000;

self->contentsPos.x += ice->playerMoveOffset.x;
self->contentsPos.y += ice->playerMoveOffset.y;
self->contentsPos.y = TO_FIXED(self->contentsPos.y);
self->contentsPos.y &= 0xFFFF0000;

self->moveOffset.x = ice->playerMoveOffset.x;
self->moveOffset.y = ice->playerMoveOffset.y;
Expand Down
32 changes: 16 additions & 16 deletions SonicMania/Objects/Global/Player.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ void Player_LateUpdate(void)
Player_TryTransform(self, 0x7F);

if (self->state == Player_State_FlyCarried) {
self->flyCarryLeaderPos.x = TO_FIXED(self->position.x);
self->flyCarryLeaderPos.y = TO_FIXED(self->position.y);
self->flyCarryLeaderPos.x = self->position.x & 0xFFFF0000;
self->flyCarryLeaderPos.y = self->position.y & 0xFFFF0000;
}

if (self->deathType) {
Expand Down Expand Up @@ -556,7 +556,7 @@ void Player_Create(void *data)
self->stateAbility = Player_JumpAbility_Sonic;
self->sensorY = TO_FIXED(20);

if (globals->medalMods & GET_MEDAL_MOD(MEDAL_PEELOUT)) {
if (globals->medalMods & MEDAL_PEELOUT) {
self->statePeelout = Player_Action_Peelout;
for (int32 f = 0; f < 4; ++f) {
SpriteFrame *dst = RSDK.GetFrame(self->aniFrames, ANI_DASH, f + 1);
Expand Down Expand Up @@ -691,12 +691,12 @@ void Player_StageLoad(void)
if (!globals->playerID)
globals->playerID = RSDK.CheckSceneFolder("MSZCutscene") ? ID_KNUCKLES : ID_DEFAULT_PLAYER;

SceneInfo->debugMode = globals->medalMods & GET_MEDAL_MOD(MEDAL_DEBUGMODE);
SceneInfo->debugMode = globals->medalMods & MEDAL_DEBUGMODE;
#if MANIA_USE_PLUS
RSDK.AddViewableVariable("Debug Mode", &SceneInfo->debugMode, VIEWVAR_BOOL, false, true);
#endif

if (globals->medalMods & GET_MEDAL_MOD(MEDAL_ANDKNUCKLES)) {
if (globals->medalMods & MEDAL_ANDKNUCKLES) {
globals->playerID &= 0xFF;
globals->playerID |= ID_KNUCKLES_ASSIST;
}
Expand Down Expand Up @@ -991,7 +991,7 @@ void Player_ChangeCharacter(EntityPlayer *entity, int32 character)
entity->stateAbility = Player_JumpAbility_Sonic;
entity->sensorY = TO_FIXED(20);

if (globals->medalMods & GET_MEDAL_MOD(MEDAL_PEELOUT)) {
if (globals->medalMods & MEDAL_PEELOUT) {
entity->statePeelout = Player_Action_Peelout;
for (int32 f = 0; f < 4; ++f) {
SpriteFrame *dst = RSDK.GetFrame(entity->aniFrames, ANI_DASH, f);
Expand Down Expand Up @@ -1182,7 +1182,7 @@ bool32 Player_TryTransform(EntityPlayer *player, uint8 emeraldMasks)

#if MANIA_USE_PLUS
RSDK.StopSfx(Player->sfxSwapFail);
if (globals->medalMods & GET_MEDAL_MOD(SECRET_SUPERDASH))
if (globals->secrets & SECRET_SUPERDASH)
player->stateAbility = ERZStart_Player_StartSuperFly;
#endif

Expand Down Expand Up @@ -2892,19 +2892,19 @@ void Player_HandleGroundAnimation(void)
}
else if (velocity < self->minDashVelocity) {
if (self->animator.animationID == ANI_DASH || self->animator.animationID == ANI_RUN)
RSDK.SetSpriteAnimation(self->aniFrames, ANI_RUN, &self->animator, false, 1);
else
RSDK.SetSpriteAnimation(self->aniFrames, ANI_RUN, &self->animator, false, 0);
else
RSDK.SetSpriteAnimation(self->aniFrames, ANI_RUN, &self->animator, false, 1);

self->animator.speed = MIN((velocity >> 12) + 0x60, 0x200);
self->minRunVelocity = 0x58000;
self->minDashVelocity = 0xC0000;
}
else {
if (self->animator.animationID == ANI_DASH || self->animator.animationID == ANI_RUN)
RSDK.SetSpriteAnimation(self->aniFrames, ANI_DASH, &self->animator, false, 1);
else
RSDK.SetSpriteAnimation(self->aniFrames, ANI_DASH, &self->animator, false, 0);
else
RSDK.SetSpriteAnimation(self->aniFrames, ANI_DASH, &self->animator, false, 1);
self->minDashVelocity = 0xB8000;
}
}
Expand Down Expand Up @@ -6015,14 +6015,14 @@ void Player_JumpAbility_Sonic(void)
EntityShield *shield = RSDK_GET_ENTITY(Player->playerCount + RSDK.GetEntitySlot(self), Shield);
if (self->invincibleTimer) {
if (shield->classID != Shield->classID || shield->shieldAnimator.animationID != SHIELDANI_INSTA) {
if (!(globals->medalMods & GET_MEDAL_MOD(MEDAL_NODROPDASH)))
if (!(globals->medalMods & MEDAL_NODROPDASH))
++self->jumpAbilityState;
}
}
else {
switch (self->shield) {
case SHIELD_NONE:
if (globals->medalMods & GET_MEDAL_MOD(MEDAL_INSTASHIELD)) {
if (globals->medalMods & MEDAL_INSTASHIELD) {
self->invincibleTimer = -8;
self->jumpAbilityState = 0;
RSDK.PlaySfx(Shield->sfxInstaShield, false, 255);
Expand All @@ -6037,8 +6037,8 @@ void Player_JumpAbility_Sonic(void)
// returns 0 if dropdash (bit 4) is disabled
// returns 1 if dropdash is enabled and instashield (bit 3) is disabled
// returns 2 if dropdash AND instashield are enabled
if (!(globals->medalMods & GET_MEDAL_MOD(MEDAL_NODROPDASH)))
self->jumpAbilityState = ((~(globals->medalMods & 0xFF) >> 3) & 2);
if (!(globals->medalMods & MEDAL_NODROPDASH))
self->jumpAbilityState = (~(globals->medalMods & 0xFF) >> 3) & 2;
break;

case SHIELD_BUBBLE:
Expand Down Expand Up @@ -6091,7 +6091,7 @@ void Player_JumpAbility_Sonic(void)
}

if ((self->jumpAbilityState >= 2 || dropdashAllowed) && self->jumpHold) {
if (++self->jumpAbilityState > 22) {
if (++self->jumpAbilityState >= 22) {
self->state = Player_State_DropDash;
self->nextGroundState = StateMachine_None;
self->nextAirState = StateMachine_None;
Expand Down
2 changes: 1 addition & 1 deletion SonicMania/Objects/Global/Spikes.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ void Spikes_StageLoad(void)
if (RSDK.CheckSceneFolder("FBZ")) {
Spikes->aniFrames = RSDK.LoadSpriteAnimation("FBZ/Spikes.bin", SCOPE_STAGE);
}
if (RSDK.CheckSceneFolder("PSZ2")) {
else if (RSDK.CheckSceneFolder("PSZ2")) {
Spikes->aniFrames = RSDK.LoadSpriteAnimation("PSZ2/Spikes.bin", SCOPE_STAGE);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion SonicMania/Objects/HCZ/DCEvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void DCEvent_StateEggmanBomber_PlacedAllBombs(void)

Water->targetWaterLevel = 0x8DC0000;
Water->waterMoveSpeed = 0x8000;
Music_TransitionTrack(TRACK_MINIBOSS, 0.0125);
Music_TransitionTrack(TRACK_STAGE, 0.0125);
self->state = DCEvent_State_Collapse;
}
}
Expand Down
17 changes: 8 additions & 9 deletions SonicMania/Objects/Menu/LevelSelect.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ void LevelSelect_Cheat_MaxContinues(void)
void LevelSelect_Cheat_MaxControl(void)
{
RSDK.PlaySfx(LevelSelect->sfxRing, false, 255);
globals->medalMods &= ~GET_MEDAL_MOD(MEDAL_NODROPDASH);
globals->medalMods |= GET_MEDAL_MOD(MEDAL_INSTASHIELD);
globals->medalMods |= GET_MEDAL_MOD(MEDAL_PEELOUT);
globals->medalMods &= ~MEDAL_NODROPDASH;
globals->medalMods |= MEDAL_INSTASHIELD;
globals->medalMods |= MEDAL_PEELOUT;
}

void LevelSelect_Cheat_RickyMode(void)
Expand All @@ -167,16 +167,15 @@ void LevelSelect_Cheat_SwapGameMode(void)
}
else {
globals->gameMode = MODE_ENCORE;
if ((globals->medalMods & GET_MEDAL_MOD(MEDAL_ANDKNUCKLES))) {
globals->medalMods &= -GET_MEDAL_MOD(MEDAL_ANDKNUCKLES);
}
if (globals->medalMods & MEDAL_ANDKNUCKLES)
globals->medalMods &= ~MEDAL_ANDKNUCKLES;
}
}
}

void LevelSelect_Cheat_UnlockAllMedals(void)
{
if (globals->superSecret && (globals->secrets & GET_MEDAL_MOD(SECRET_RICKYMODE))) {
if (globals->superSecret && (globals->secrets & SECRET_RICKYMODE)) {
RSDK.PlaySfx(LevelSelect->sfxMedalGot, false, 255);
GameProgress_UnlockAll();
GameProgress_LockAllSpecialClear();
Expand Down Expand Up @@ -263,8 +262,8 @@ void LevelSelect_State_Init(void)

for (int32 i = 0; i < self->labelCount; ++i) {
if (!self->zoneNameLabels[i]) {
for (int32 v = i; i >= 0; --i) {
if (self->stageIDLabels[v]) {
for (int32 v = i; v >= 0; --v) {
if (self->zoneNameLabels[v]) {
self->zoneNameLabels[i] = self->zoneNameLabels[v];
break;
}
Expand Down
Loading

0 comments on commit 1d9f6df

Please sign in to comment.