Skip to content

Commit dc84135

Browse files
fixed a bunch of straggler bugs
1 parent a58fe79 commit dc84135

10 files changed

+46
-100
lines changed

Nexus/Collision.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ void ProcessTracedCollision(Player *player)
892892
player->YPos = (sensors[4].YPos - collisionBottom) << 16;
893893
player->angle = sensors[4].angle;
894894
}
895-
else if (sensors[5].collided ) {
895+
else if (sensors[5].collided) {
896896
player->YPos = (sensors[5].YPos - collisionBottom) << 16;
897897
player->angle = sensors[5].angle;
898898
}

Nexus/Debug.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ void InitSystemMenu()
99
ReleaseStageSfx();
1010
fadeMode = 0;
1111

12-
if (Engine.usingBinFile && !Engine.devMenu) {
12+
if (Engine.usingBinFile) {
1313
ClearGraphicsData();
1414
for (int i = 0; i < PLAYER_COUNT; ++i) playerScriptList[i].scriptPath[0] = 0;
1515
LoadPalette("Data/Palettes/MasterPalette.act", 0, 256);
@@ -114,7 +114,7 @@ void ProcessSystemMenu()
114114
else if (keyPress.B) {
115115
ClearGraphicsData();
116116
ClearAnimationData();
117-
LoadPalette("MasterPalette.act", 0, 256);
117+
LoadPalette("Data/Palettes/MasterPalette.act", 0, 256);
118118
activeStageList = 0;
119119
stageMode = STAGEMODE_LOAD;
120120
Engine.gameMode = ENGINE_MAINGAME;

Nexus/Math.cpp

-70
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,14 @@
55
#define M_PI 3.14159265358979323846264338327950288
66
#endif
77

8-
int sinM[512];
9-
int cosM[512];
10-
118
int sinVal512[512];
129
int cosVal512[512];
1310

1411
int sinVal256[256];
1512
int cosVal256[256];
1613

17-
byte atanVal256[0x100 * 0x100];
18-
1914
void CalculateTrigAngles()
2015
{
21-
for (int i = 0; i < 0x200; ++i) {
22-
float Val = sin(((float)i / 256.0) * M_PI);
23-
sinM[i] = (Val * 4096.0);
24-
Val = cos(((float)i / 256.0) * M_PI);
25-
cosM[i] = (Val * 4096.0);
26-
}
27-
28-
cosM[0] = 4096;
29-
cosM[128] = 0;
30-
cosM[256] = -4096;
31-
cosM[384] = 0;
32-
sinM[0] = 0;
33-
sinM[128] = 4096;
34-
sinM[256] = 0;
35-
sinM[384] = -4096;
3616

3717
for (int i = 0; i < 0x200; ++i) {
3818
float Val = sinf(((float)i / 256) * M_PI);
@@ -54,54 +34,4 @@ void CalculateTrigAngles()
5434
sinVal256[i] = (sinVal512[i * 2] >> 1);
5535
cosVal256[i] = (cosVal512[i * 2] >> 1);
5636
}
57-
58-
for (int Y = 0; Y < 0x100; ++Y) {
59-
byte *ATan = (byte *)&atanVal256[Y];
60-
for (int X = 0; X < 0x100; ++X) {
61-
float angle = atan2f(Y, X);
62-
*ATan = (signed int)(angle * 40.743664f);
63-
ATan += 0x100;
64-
}
65-
}
66-
}
67-
68-
byte ArcTanLookup(int X, int Y)
69-
{
70-
int XVal;
71-
byte result = 0;
72-
int YVal;
73-
74-
if (X >= 0)
75-
XVal = X;
76-
else
77-
XVal = -X;
78-
79-
if (Y >= 0)
80-
YVal = Y;
81-
else
82-
YVal = -Y;
83-
84-
if (XVal <= YVal) {
85-
while (YVal > 0xFF) {
86-
XVal >>= 4;
87-
YVal >>= 4;
88-
}
89-
}
90-
else {
91-
while (XVal > 0xFF) {
92-
XVal >>= 4;
93-
YVal >>= 4;
94-
}
95-
}
96-
if (X <= 0) {
97-
if (Y <= 0)
98-
result = atanVal256[0x100 * XVal + YVal] + -0x80;
99-
else
100-
result = -0x80 - atanVal256[0x100 * XVal + YVal];
101-
}
102-
else if (Y <= 0)
103-
result = -atanVal256[0x100 * XVal + YVal];
104-
else
105-
result = atanVal256[0x100 * XVal + YVal];
106-
return result;
10737
}

Nexus/Math.hpp

-8
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@
66
#define MEM_ZERO(x) memset(&(x), 0, sizeof((x)))
77
#define MEM_ZEROP(x) memset((x), 0, sizeof(*(x)))
88

9-
extern int sinM[0x200];
10-
extern int cosM[0x200];
11-
129
extern int sinVal512[0x200];
1310
extern int cosVal512[0x200];
1411

1512
extern int sinVal256[0x100];
1613
extern int cosVal256[0x100];
1714

18-
extern byte atanVal256[0x100 * 0x100];
19-
2015
// Setup Angles
2116
void CalculateTrigAngles();
2217

@@ -51,7 +46,4 @@ inline int cos256(int angle)
5146
return cosVal256[angle];
5247
}
5348

54-
// Get Arc Tan value
55-
byte ArcTanLookup(int X, int Y);
56-
5749
#endif // !MATH_H

Nexus/Palette.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ extern int fadeMode;
3232

3333
#define RGB888_TO_RGB565(r, g, b) ((b) >> 3) | (((g) >> 2) << 5) | (((r) >> 3) << 11)
3434

35-
#define PACK_RGB888(r, g, b) (((b) << 16) | ((g) << 8) | ((b) << 0))
35+
#define PACK_RGB888(r, g, b) ((0xFF << 24) | ((r) << 16) | ((g) << 8) | ((b) << 0))
3636

3737
void LoadPalette(const char *filePath, int startIndex, int endIndex);
3838

Nexus/Player.cpp

+16-15
Original file line numberDiff line numberDiff line change
@@ -186,28 +186,28 @@ void SetMovementStats(PlayerMovementStats *stats)
186186

187187
void DefaultAirMovement(Player *player)
188188
{
189+
if (player->YVelocity > -0x40000 && player->YVelocity < 0)
190+
player->speed -= player->speed >> 5;
191+
189192
if (player->speed <= -player->stats.topSpeed) {
190-
if (player->left)
193+
if (player->left) {
191194
player->direction = FLIP_X;
195+
}
192196
}
193-
else if (player->left) {
194-
player->speed -= player->stats.airAcceleration;
195-
player->direction = FLIP_X;
197+
else {
198+
if (player->left) {
199+
player->speed -= player->stats.airAcceleration;
200+
player->direction = FLIP_X;
201+
}
196202
}
197203

198204
if (player->speed >= player->stats.topSpeed) {
199205
if (player->right)
200206
player->direction = FLIP_NONE;
201207
}
202208
else if (player->right) {
203-
player->speed += player->stats.airAcceleration;
204209
player->direction = FLIP_NONE;
205-
}
206-
207-
if (player->YVelocity > -0x4000) {
208-
if (player->YVelocity < 0) {
209-
player->speed -= player->speed >> 5;
210-
}
210+
player->speed += player->stats.airAcceleration;
211211
}
212212
}
213213

@@ -248,7 +248,7 @@ void DefaultGravityTrue(Player *player)
248248

249249
void DefaultGroundMovement(Player *player)
250250
{
251-
if ((sbyte)player->frictionLoss <= 0) {
251+
if ((signed int)player->frictionLoss <= 0) {
252252
if (player->left && player->speed > -player->stats.topSpeed) {
253253
if (player->speed <= 0) {
254254
player->speed -= player->stats.acceleration;
@@ -370,7 +370,7 @@ void DefaultGroundMovement(Player *player)
370370
void DefaultJumpAction(Player *player)
371371
{
372372
player->frictionLoss = 0;
373-
player->gravity = 1;
373+
player->gravity = true;
374374
player->XVelocity = (player->speed * cosVal256[player->angle] + player->stats.jumpStrength * sinVal256[player->angle]) >> 8;
375375
player->YVelocity = (player->speed * sinVal256[player->angle] + -player->stats.jumpStrength * cosVal256[player->angle]) >> 8;
376376
player->speed = player->XVelocity;
@@ -388,6 +388,7 @@ void DefaultRollingMovement(Player *player)
388388
player->speed += player->stats.rollingDeceleration;
389389
if (player->left && player->speed > 0)
390390
player->speed -= player->stats.rollingDeceleration;
391+
391392
if (player->speed < 0) {
392393
player->speed += player->stats.airDeceleration;
393394
if (player->speed > 0)
@@ -403,14 +404,14 @@ void DefaultRollingMovement(Player *player)
403404

404405
if (player->speed <= 0) {
405406
if (sinVal256[player->angle] >= 0) {
406-
player->speed = (player->stats.rollingDeceleration * sinVal256[player->angle] >> 8) + player->speed;
407+
player->speed += (player->stats.rollingDeceleration * sinVal256[player->angle] >> 8);
407408
}
408409
else {
409410
player->speed += 0x5000 * sinVal256[player->angle] >> 8;
410411
}
411412
}
412413
else if (sinVal256[player->angle] <= 0) {
413-
player->speed = (player->stats.rollingDeceleration * sinVal256[player->angle] >> 8) + player->speed;
414+
player->speed += (player->stats.rollingDeceleration * sinVal256[player->angle] >> 8);
414415
}
415416
else {
416417
player->speed += 0x5000 * sinVal256[player->angle] >> 8;

Nexus/RetroEngine.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ bool processEvents()
6060
case SDLK_ESCAPE:
6161
if (Engine.devMenu)
6262
Engine.gameMode = ENGINE_INITSYSMENU;
63+
else {
64+
Engine.gameMode = ENGINE_EXITGAME;
65+
return false;
66+
}
6367
break;
6468
case SDLK_F4:
6569
Engine.isFullScreen ^= 1;

Nexus/Scene.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ void LoadStageFiles(void)
244244
if (!CheckCurrentStageFolder(stageListPosition)) {
245245
printLog("Loading Scene %s - %s", stageListNames[activeStageList], stageList[activeStageList][stageListPosition].name);
246246
ReleaseStageSfx();
247-
LoadPalette("MasterPalette.act", 0, 256);
247+
LoadPalette("Data/Palettes/MasterPalette.act", 0, 256);
248248
ClearScriptData();
249249
for (int i = SPRITESHEETS_MAX; i > 0; i--) RemoveGraphicsFile((char *)"", i - 1);
250250

Nexus/Script.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ int jumpTableDataPos = 0;
2323
int jumpTableDataOffset = 0;
2424

2525
#define ALIAS_COUNT (0x80)
26+
#if !RETRO_USE_ORIGINAL_CODE
27+
#define COMMONALIAS_COUNT (25)
28+
#else
2629
#define COMMONALIAS_COUNT (14)
30+
#endif
2731
int aliasCount = 0;
2832
int lineID = 0;
2933

@@ -301,7 +305,14 @@ AliasInfo aliases[0x80] = { AliasInfo("true", "1"),
301305
AliasInfo("MENU_2", "1"),
302306
AliasInfo("C_TOUCH", "0"),
303307
AliasInfo("C_BOX", "1"),
304-
AliasInfo("C_PLATFORM", "2") };
308+
AliasInfo("C_PLATFORM", "2"),
309+
#if !RETRO_USE_ORIGINAL_CODE
310+
AliasInfo("INK_NONE", "0"), AliasInfo("INK_BLEND", "1"), AliasInfo("INK_TINT", "2"),
311+
AliasInfo("FX_SCALE", "0"), AliasInfo("FX_ROTATE", "1"), AliasInfo("FX_INK", "2"),
312+
AliasInfo("FX_TINT", "3"), AliasInfo("FLIP_NONE", "0"), AliasInfo("FLIP_X", "1"),
313+
AliasInfo("FLIP_Y", "2"), AliasInfo("FLIP_XY", "3"),
314+
#endif
315+
};
305316

306317

307318
const char scriptEvaluationTokens[][0x4] = {
@@ -2007,7 +2018,8 @@ void ProcessScript(int scriptCodePtr, int jumpTablePtr, byte scriptSub)
20072018
break;
20082019
}
20092020
case FUNC_ATAN2: {
2010-
scriptEng.operands[0] = ArcTanLookup(scriptEng.operands[1], scriptEng.operands[2]);
2021+
opcodeSize = 0;
2022+
//doesn't exist
20112023
break;
20122024
}
20132025
case FUNC_INTERPOLATE:

Nexus/Userdata.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void InitUserdata()
5151
ini.SetInteger("Window", "WindowScale", Engine.windowScale = 2);
5252
ini.SetInteger("Window", "ScreenWidth", SCREEN_XSIZE = DEFAULT_SCREEN_XSIZE);
5353
ini.SetInteger("Window", "RefreshRate", Engine.refreshRate = 60);
54+
ini.SetInteger("Window", "ColourMode", Engine.colourMode = 0);
5455

5556
ini.SetFloat("Audio", "BGMVolume", bgmVolume / (float)MAX_VOLUME);
5657
ini.SetFloat("Audio", "SFXVolume", sfxVolume / (float)MAX_VOLUME);
@@ -133,6 +134,10 @@ void InitUserdata()
133134
SCREEN_XSIZE = DEFAULT_SCREEN_XSIZE;
134135
if (!ini.GetInteger("Window", "RefreshRate", &Engine.refreshRate))
135136
Engine.refreshRate = 60;
137+
int cm = Engine.colourMode;
138+
if (!ini.GetInteger("Window", "ColourMode", &cm))
139+
cm = 1;
140+
Engine.colourMode = cm;
136141

137142
float bv = 0, sv = 0;
138143
if (!ini.GetFloat("Audio", "BGMVolume", &bv))
@@ -283,6 +288,8 @@ void writeSettings() {
283288
ini.SetInteger("Window", "ScreenWidth", SCREEN_XSIZE);
284289
ini.SetComment("Window", "RRComment", "Determines the target FPS");
285290
ini.SetInteger("Window", "RefreshRate", Engine.refreshRate);
291+
ini.SetComment("Window", "CMComment", "Determines the output colour mode (0 = 8-bit, 1 = 16-bit, 2 = 32-bit)");
292+
ini.SetInteger("Window", "ColourMode", Engine.colourMode);
286293

287294
ini.SetFloat("Audio", "BGMVolume", bgmVolume / (float)MAX_VOLUME);
288295
ini.SetFloat("Audio", "SFXVolume", sfxVolume / (float)MAX_VOLUME);

0 commit comments

Comments
 (0)