Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
rubberduckycooly
GitHub Repository: rubberduckycooly/Sonic-Mania-Decompilation
Path: blob/master/SonicMania/Objects/ERZ/ERZSetup.c
338 views
1
// ---------------------------------------------------------------------
2
// RSDK Project: Sonic Mania
3
// Object Description: ERZSetup Object
4
// Object Author: Christian Whitehead/Simon Thomley/Hunter Bridges
5
// Decompiled by: Rubberduckycooly & RMGRich
6
// ---------------------------------------------------------------------
7
8
#include "Game.h"
9
10
ObjectERZSetup *ERZSetup;
11
12
void ERZSetup_Update(void) {}
13
14
void ERZSetup_LateUpdate(void) {}
15
16
void ERZSetup_StaticUpdate(void)
17
{
18
ERZSetup->timer += 0x10000;
19
ERZSetup->timer &= 0x7FFFFFFF;
20
21
if (!(Zone->timer & 3)) {
22
ERZSetup->aniTileTimer += 0x80;
23
ERZSetup->aniTileTimer &= 0xFFF;
24
RSDK.DrawAniTiles(ERZSetup->aniTiles, 520, ERZSetup->aniTileTimer & 0x1FF, (ERZSetup->aniTileTimer >> 2) & 0xFF80, 128, 128);
25
}
26
}
27
28
void ERZSetup_Draw(void) {}
29
30
void ERZSetup_Create(void *data) {}
31
32
void ERZSetup_StageLoad(void)
33
{
34
ERZSetup->aniTiles = RSDK.LoadSpriteSheet("Phantom/Sky.gif", SCOPE_STAGE);
35
36
RSDK.GetTileLayer(1)->scanlineCallback = ERZSetup_Scanline_Sky;
37
38
// Animal Types in ERZ...? why is that? no animals would exist so it'd be safe to not define types
39
Animals->animalTypes[0] = ANIMAL_POCKY;
40
Animals->animalTypes[1] = ANIMAL_ROCKY;
41
42
// Remove all players except for P1
43
for (int32 p = 1; p < Player->playerCount; ++p) destroyEntitySlot(p);
44
Player->playerCount = 1;
45
}
46
47
void ERZSetup_Scanline_Sky(ScanlineInfo *scanlines)
48
{
49
RSDKScreenInfo *screen = &ScreenInfo[SceneInfo->currentScreenID];
50
51
RSDK.SetClipBounds(0, 0, 0, screen->size.x, 136);
52
53
int32 a = 0x1000000;
54
int32 sineAngle = RSDK.Sin256(0);
55
int32 cosineAngle = RSDK.Cos256(0);
56
57
for (int32 i = 160; i > 16; --i) {
58
int32 angle = a / (8 * i);
59
int32 sin = sineAngle * angle;
60
int32 cos = cosineAngle * angle;
61
62
scanlines->deform.y = sin >> 7;
63
scanlines->deform.x = -cos >> 7;
64
scanlines->position.x = sin - screen->center.x * (-cos >> 7) - (screen->position.x << 14);
65
scanlines->position.y = ERZSetup->timer + 2 * cos - screen->center.x * (sin >> 7);
66
67
a -= 0xC000;
68
scanlines++;
69
}
70
}
71
72
#if GAME_INCLUDE_EDITOR
73
void ERZSetup_EditorDraw(void) {}
74
75
void ERZSetup_EditorLoad(void) {}
76
#endif
77
78
void ERZSetup_Serialize(void) {}
79
80