Skip to content

Commit

Permalink
Merge branch 'Rubberduckycooly:master' into Vita
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicMastr authored Sep 16, 2022
2 parents 5b72169 + 640372f commit 3593e7c
Show file tree
Hide file tree
Showing 29 changed files with 299 additions and 222 deletions.
7 changes: 7 additions & 0 deletions SonicMania/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@
#define VER_107 (7) // 1.07 (EGS/Origin releases)

#ifdef MANIA_PREPLUS

#ifdef MANIA_FIRST_RELEASE
#define GAME_VERSION VER_100
#else
#ifndef GAME_VERSION
#define GAME_VERSION VER_103
#endif
#endif

#undef RETRO_REV02
#define RETRO_REV02 (0)
Expand Down
35 changes: 29 additions & 6 deletions SonicMania/GameVariables.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ typedef enum {
#if !MANIA_USE_PLUS
MODE_NOSAVE,
#endif
MODE_MANIA,
MODE_MANIA, // officially called "MODE_SAVEGAME" in pre-plus, but it's easier to re-use names lol
#if MANIA_USE_PLUS
MODE_ENCORE,
#endif
MODE_TIMEATTACK,
MODE_COMPETITION,
} GameModes;

typedef enum { MEDIA_DEMO } CategoryIDS;

typedef enum {
ID_NONE = 0 << 0,
ID_SONIC = 1 << 0,
Expand Down Expand Up @@ -54,14 +52,37 @@ typedef enum {
#endif
} MedalMods;

typedef enum { FORCE_SPLIT = 2 } ScreenSplit;
typedef enum { MEDIA_DEMO } CategoryIDS;

typedef enum { WIDE_SCR_XSIZE = 424, WIDE_SCR_XCENTER = 212 } ScreenSizes;
typedef enum { FORCE_SPLIT } ScreenSplit;

typedef enum { NO_SAVE_SLOT = 255 } SaveSlots;

typedef enum { WIDE_SCR_XSIZE = 424, WIDE_SCR_XCENTER = 212 } ScreenSizes;

#if RETRO_REV02
typedef enum {
// General Filters
FILTER_NONE = 0 << 0,
FILTER_SLOT1 = 1 << 0,
FILTER_SLOT2 = 1 << 1,
FILTER_SLOT3 = 1 << 2,
FILTER_SLOT4 = 1 << 3,
FILTER_SLOT5 = 1 << 4,
FILTER_SLOT6 = 1 << 5,
FILTER_SLOT7 = 1 << 6,
FILTER_SLOT8 = 1 << 7,
FILTER_ANY = FILTER_SLOT1 | FILTER_SLOT2 | FILTER_SLOT3 | FILTER_SLOT4 | FILTER_SLOT5 | FILTER_SLOT6 | FILTER_SLOT7 | FILTER_SLOT8,
} SceneFilters;
#endif

#if MANIA_USE_PLUS
typedef enum { FILTER_NONE = 0, FILTER_BOTH = 1, FILTER_MANIA = 2, FILTER_ENCORE = 4, FILTER_ANY = 0xFF } ModeFilters;
typedef enum {
// Mania-Specific filter uses
FILTER_BOTH = FILTER_SLOT1,
FILTER_MANIA = FILTER_SLOT2,
FILTER_ENCORE = FILTER_SLOT3,
} ManiaFilters;

typedef enum { DLC_PLUS } GameDLC;
#endif
Expand Down Expand Up @@ -217,7 +238,9 @@ typedef struct {
int32 restartScore;
int32 restartScore1UP;
int32 restartLives[4];
#if GAME_VERSION != VER_100
int32 restartMusicID;
#endif
int32 restartFlags;
int32 tempFlags;
int32 continues;
Expand Down
42 changes: 21 additions & 21 deletions SonicMania/Objects/CPZ/TransportTube.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ void TransportTube_Create(void *data)
self->drawFX = FX_FLIP;
if (!SceneInfo->inEditor) {
self->active = ACTIVE_BOUNDS;
self->updateRange.x = 0xC00000;
self->updateRange.y = 0xC00000;
self->updateRange.x = TO_FIXED(192);
self->updateRange.y = TO_FIXED(192);
TransportTube_SetupDirections(self);

switch (self->type) {
Expand Down Expand Up @@ -88,8 +88,8 @@ void TransportTube_HandleVelocityChange(int32 velX, int32 velY)
}

int32 dir = self->directionIDs[RSDK.Rand(0, self->directionCount - 1)];
self->velocity.x = self->dirVelocity[dir].x << 16;
self->velocity.y = self->dirVelocity[dir].y << 16;
self->velocity.x = TO_FIXED(self->dirVelocity[dir].x);
self->velocity.y = TO_FIXED(self->dirVelocity[dir].y);
}

void TransportTube_State_ChangeDir(void)
Expand All @@ -98,15 +98,15 @@ void TransportTube_State_ChangeDir(void)

for (int32 i = 0; i < Player->playerCount; ++i) {
EntityPlayer *player = RSDK_GET_ENTITY(i, Player);
int32 rx = (player->position.x - self->position.x) >> 16;
int32 ry = (player->position.y - self->position.y) >> 16;
int32 rx = FROM_FIXED(player->position.x - self->position.x);
int32 ry = FROM_FIXED(player->position.y - self->position.y);

if (self->playerTimers[i]) {
if (rx * rx + ry * ry >= 0xC0)
self->playerTimers[i]--;
}
else if (player->state == Player_State_TransportTube && !TransportTube->nextSlot[i] && rx * rx + ry * ry < 192) {
TransportTube_HandleVelocityChange(rx - (player->velocity.x >> 16), ry - (player->velocity.y >> 16));
else if (player->state == Player_State_TransportTube && !TransportTube->nextSlot[i] && rx * rx + ry * ry < 0xC0) {
TransportTube_HandleVelocityChange(rx - FROM_FIXED(player->velocity.x), ry - FROM_FIXED(player->velocity.y));
player->position.x = self->position.x;
player->position.y = self->position.y;
player->velocity = self->velocity;
Expand All @@ -123,8 +123,8 @@ void TransportTube_State_Entry(void)
EntityPlayer *player = RSDK_GET_ENTITY(i, Player);

if (Player_CheckValidState(player)) {
int32 rx = (player->position.x - self->position.x) >> 16;
int32 ry = (player->position.y - self->position.y) >> 16;
int32 rx = FROM_FIXED(player->position.x - self->position.x);
int32 ry = FROM_FIXED(player->position.y - self->position.y);
if (self->playerTimers[i]) {
if (rx * rx + ry * ry >= 0xC0)
self->playerTimers[i]--;
Expand All @@ -142,7 +142,7 @@ void TransportTube_State_Entry(void)
self->playerTimers[i] = 2;
}
else {
TransportTube_HandleVelocityChange(rx - (player->velocity.x >> 16), ry - (player->velocity.y >> 16));
TransportTube_HandleVelocityChange(rx - FROM_FIXED(player->velocity.x), ry - FROM_FIXED(player->velocity.y));
player->velocity = self->velocity;
RSDK.SetSpriteAnimation(player->aniFrames, ANI_JUMP, &player->animator, false, 0);
player->drawGroup = 1;
Expand All @@ -167,8 +167,8 @@ void TransportTube_State_ToTargetEntity(void)

for (int32 i = 0; i < Player->playerCount; ++i) {
EntityPlayer *player = RSDK_GET_ENTITY(i, Player);
int32 rx = (player->position.x - self->position.x) >> 16;
int32 ry = (player->position.y - self->position.y) >> 16;
int32 rx = FROM_FIXED(player->position.x - self->position.x);
int32 ry = FROM_FIXED(player->position.y - self->position.y);

if (self->playerTimers[i]) {
if (rx * rx + ry * ry >= 0xC0)
Expand All @@ -187,7 +187,7 @@ void TransportTube_State_ToTargetEntity(void)
TransportTube->nextSlot[i] = -1;

EntityTransportTube *node = RSDK_GET_ENTITY(SceneInfo->entitySlot + TransportTube->nextSlot[i], TransportTube);
int32 angle = RSDK.ATan2((node->position.x - player->position.x) >> 16, (node->position.y - player->position.y) >> 16);
int32 angle = RSDK.ATan2(FROM_FIXED(node->position.x - player->position.x), FROM_FIXED(node->position.y - player->position.y));
player->velocity.x = 0xC00 * RSDK.Cos256(angle);
player->velocity.y = 0xC00 * RSDK.Sin256(angle);
node->players[i] = player;
Expand All @@ -205,14 +205,14 @@ void TransportTube_State_TargetSeqNode(void)
EntityPlayer *player = self->players[i];
if (player) {
if (player->state == Player_State_TransportTube) {
int32 rx = (player->position.x - self->position.x) >> 16;
int32 ry = (player->position.y - self->position.y) >> 16;
int32 rx = FROM_FIXED(player->position.x - self->position.x);
int32 ry = FROM_FIXED(player->position.y - self->position.y);
if (rx * rx + ry * ry < 0xC0) {
player->position.x = self->position.x;
player->position.y = self->position.y;

EntityTransportTube *node = RSDK_GET_ENTITY(SceneInfo->entitySlot + TransportTube->nextSlot[i], TransportTube);
int32 angle = RSDK.ATan2((node->position.x - player->position.x) >> 16, (node->position.y - player->position.y) >> 16);
int32 angle = RSDK.ATan2(FROM_FIXED(node->position.x - player->position.x), FROM_FIXED(node->position.y - player->position.y));
player->velocity.x = 0xC00 * RSDK.Cos256(angle);
player->velocity.y = 0xC00 * RSDK.Sin256(angle);
self->players[i] = NULL;
Expand All @@ -232,8 +232,8 @@ void TransportTube_State_ChooseDir(void)

for (int32 i = 0; i < Player->playerCount; ++i) {
EntityPlayer *player = RSDK_GET_ENTITY(i, Player);
int32 rx = (player->position.x - self->position.x) >> 16;
int32 ry = (player->position.y - self->position.y) >> 16;
int32 rx = FROM_FIXED(player->position.x - self->position.x);
int32 ry = FROM_FIXED(player->position.y - self->position.y);

if (self->playerTimers[i]) {
if (rx * rx + ry * ry >= 0xC0)
Expand Down Expand Up @@ -271,8 +271,8 @@ void TransportTube_State_Exit(void)
EntityPlayer *player = RSDK_GET_ENTITY(i, Player);

if (Player_CheckValidState(player)) {
int32 rx = (player->position.x - self->position.x) >> 16;
int32 ry = (player->position.y - self->position.y) >> 16;
int32 rx = FROM_FIXED(player->position.x - self->position.x);
int32 ry = FROM_FIXED(player->position.y - self->position.y);

if (self->playerTimers[i]) {
if (rx * rx + ry * ry >= 0xC0)
Expand Down
7 changes: 4 additions & 3 deletions SonicMania/Objects/Common/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,8 @@ void Platform_EditorDraw_Normal(void)
RSDK_THIS(Platform);

if (Platform->aniFrames == (uint16)-1 || self->frameID == -1)
RSDK.DrawRect(self->drawPos.x - 0x200000, self->drawPos.y - 0x100000, 0x400000, 0x200000, 0x8080A0, self->alpha, self->inkEffect, false);
RSDK.DrawRect(self->drawPos.x - TO_FIXED(32), self->drawPos.y - TO_FIXED(16), TO_FIXED(64), TO_FIXED(32), 0x8080A0, self->alpha,
self->inkEffect, false);
else
RSDK.DrawSprite(&self->animator, &self->drawPos, false);
}
Expand Down Expand Up @@ -2198,7 +2199,7 @@ void Platform_EditorDraw_Swinging(Vector2 amplitude)
drawPos.x = angle * RSDK.Cos1024(ang) + self->centerPos.x;
drawPos.y = angle * RSDK.Sin1024(ang) + self->centerPos.y;
if (Platform->aniFrames == (uint16)-1 || self->frameID == -1)
RSDK.DrawRect(self->drawPos.x - TO_FIXED(32), self->drawPos.y - TO_FIXED(16), TO_FIXED(64), TO_FIXED(32), 0x8080A0, self->alpha,
RSDK.DrawRect(drawPos.x - TO_FIXED(32), drawPos.y - TO_FIXED(16), TO_FIXED(64), TO_FIXED(32), 0x8080A0, self->alpha,
self->inkEffect, false);
else
RSDK.DrawSprite(&self->animator, &drawPos, false);
Expand All @@ -2210,7 +2211,7 @@ void Platform_EditorDraw_Swinging(Vector2 amplitude)
self->drawFX = fxStore;
self->animator.frameID = frame + 2;
if (Platform->aniFrames == (uint16)-1 || self->frameID == -1)
RSDK.DrawRect(self->drawPos.x - TO_FIXED(32), self->drawPos.y - TO_FIXED(16), TO_FIXED(64), TO_FIXED(32), 0x8080A0, self->alpha,
RSDK.DrawRect(self->centerPos.x - TO_FIXED(32), self->centerPos.y - TO_FIXED(16), TO_FIXED(64), TO_FIXED(32), 0x8080A0, self->alpha,
self->inkEffect, false);
else
RSDK.DrawSprite(&self->animator, &self->centerPos, false);
Expand Down
34 changes: 17 additions & 17 deletions SonicMania/Objects/ERZ/ERZKing.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ void ERZKing_HandleFrames(void)
int32 angle = self->bodyAngle;

for (int32 i = 0; i < 10; i += 2) {
self->framePositions[i].x = x + 2 * RSDK.Cos512(self->rotation) * RSDK.Cos1024(angle);
self->framePositions[i].y = y + 2 * RSDK.Sin512(self->rotation) * RSDK.Cos1024(angle);
self->frameIDs[i] = angle & 0x3FF;
self->armPositions[i].x = x + 2 * RSDK.Cos512(self->rotation) * RSDK.Cos1024(angle);
self->armPositions[i].y = y + 2 * RSDK.Sin512(self->rotation) * RSDK.Cos1024(angle);
self->armAngles[i] = angle & 0x3FF;

angle += 512;
angle += 0x200;

self->framePositions[i + 1].x = x + 2 * RSDK.Cos512(self->rotation) * RSDK.Cos1024(angle);
self->framePositions[i + 1].y = y + 2 * RSDK.Sin512(self->rotation) * RSDK.Cos1024(angle);
self->frameIDs[i + 1] = angle & 0x3FF;
self->armPositions[i + 1].x = x + 2 * RSDK.Cos512(self->rotation) * RSDK.Cos1024(angle);
self->armPositions[i + 1].y = y + 2 * RSDK.Sin512(self->rotation) * RSDK.Cos1024(angle);
self->armAngles[i + 1] = angle & 0x3FF;

x += RSDK.Sin512(negAng) << 10;
y += RSDK.Cos512(negAng) << 10;
Expand Down Expand Up @@ -205,9 +205,9 @@ void ERZKing_Draw_Body(void)
RSDK.DrawSprite(&self->bodyAnimator, NULL, false);

for (int32 i = 0; i < 10; ++i) {
if (self->frameIDs[i] < 0x200) {
self->particleAnimator.frameID = self->frameIDs[i] / 42 % 6;
RSDK.DrawSprite(&self->particleAnimator, &self->framePositions[i], false);
if (self->armAngles[i] < 0x200) {
self->particleAnimator.frameID = self->armAngles[i] / 42 % 6;
RSDK.DrawSprite(&self->particleAnimator, &self->armPositions[i], false);
}
}

Expand All @@ -216,9 +216,9 @@ void ERZKing_Draw_Body(void)

self->drawFX = self->storeDrawFX | FX_ROTATE | FX_FLIP;
for (int32 i = 0; i < 10; ++i) {
if (self->frameIDs[i] >= 0x200) {
self->particleAnimator.frameID = self->frameIDs[i] / 42 % 6;
RSDK.DrawSprite(&self->particleAnimator, &self->framePositions[i], false);
if (self->armAngles[i] >= 0x200) {
self->particleAnimator.frameID = self->armAngles[i] / 42 % 6;
RSDK.DrawSprite(&self->particleAnimator, &self->armPositions[i], false);
}
}

Expand Down Expand Up @@ -246,11 +246,11 @@ void ERZKing_Draw_Arm(void)
}

for (int32 i = 0; i < 6; ++i) {
RSDK.DrawSprite(&self->armAnimator, &self->framePositions[i], false);
RSDK.DrawSprite(&self->armAnimator, &self->armPositions[i], false);
}

RSDK.DrawSprite(&self->cuffAnimator, &self->framePositions[6], false);
RSDK.DrawSprite(&self->handAnimator, &self->framePositions[6], false);
RSDK.DrawSprite(&self->cuffAnimator, &self->armPositions[6], false);
RSDK.DrawSprite(&self->handAnimator, &self->armPositions[6], false);

if (parent->typeChangeTimer > 0) {
RSDK.CopyPalette(1, 0, 0, 0, 48);
Expand Down Expand Up @@ -462,7 +462,7 @@ void ERZKing_State_Arm(void)

int32 percent = 0x1800;
for (int32 i = 0; i < 7; ++i) {
self->framePositions[i] = MathHelpers_GetBezierPoint(percent, x, y, x2, y2, x2, y2, self->position.x, self->position.y);
self->armPositions[i] = MathHelpers_GetBezierPoint(percent, x, y, x2, y2, x2, y2, self->position.x, self->position.y);
percent += 0x2000;
}

Expand Down
4 changes: 2 additions & 2 deletions SonicMania/Objects/ERZ/ERZKing.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ struct EntityERZKing {
int32 health;
int32 typeChangeTimer;
int32 bodyAngle;
int32 frameIDs[10];
Vector2 framePositions[10];
int32 armAngles[10];
Vector2 armPositions[10];
Vector2 rubyPos;
Vector2 unused;
EntityERZKing *parent;
Expand Down
Loading

0 comments on commit 3593e7c

Please sign in to comment.