ref: 6c42892d9698d8f66a8be7c0f4716f494c56463b
parent: e7b2bc072676aba34b22ee96d7b137ea3e422715
parent: 82dc512539671c7602878276392cc5dcff3e5e5d
author: Gabriel Ravier <gabravier@gmail.com>
date: Fri May 10 04:49:32 EDT 2019
Merge branch 'master' into improveF
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -338,6 +338,9 @@
# Compile it ourselves
message(STATUS "Using local SDL2")
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
+ if(MSVC)
+ set(LIBC ON) # Needed to prevent possible 'symbol already defined' errors
+ endif()
add_subdirectory("external/SDL2" EXCLUDE_FROM_ALL)
target_link_libraries(CSE2 SDL2-static SDL2main)
endif()
--- a/DoConfig/DoConfig.cpp
+++ b/DoConfig/DoConfig.cpp
@@ -107,6 +107,9 @@
joystuffcontainer->activate();
}
}
+
+const unsigned int button_lookup[8] = {0, 1, 2, 5, 3, 4, 6, 7};
+
void read_Config(){
std::fstream fd;
fd.open("Config.dat", std::ios::in | std::ios::binary);
@@ -135,7 +138,7 @@
for(char i=0;i<8;i++){
const unsigned long button = CharsToLong(config.buttons[i]);
if(button<9 && button>0){
- joyRows[i]->value(button -1);
+ joyRows[button_lookup[i]]->value(button-1);
}
}
}
@@ -148,7 +151,7 @@
LongToChars(displaychoice->value(), config.display);
LongToChars(joychoice->value(), config.useJoy);
for(char i =0;i<8;i++){
- LongToChars(joyRows[i]->value(), config.buttons[i]);
+ LongToChars(joyRows[button_lookup[i]]->value()+1, config.buttons[i]);
}
std::fstream fd;
fd.open("Config.dat", std::ios::out | std::ios::binary);
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -44,7 +44,7 @@
const char *lpWindowName = "Cave Story Engine 2 ~ Doukutsu Monogatari Enjin 2";
#endif
-//A replication of MSVC's rand algorithm
+// A replication of MSVC's rand algorithm
static unsigned long int next = 1;
int rep_rand()
@@ -58,7 +58,7 @@
next = seed;
}
-//Framerate stuff
+// Framerate stuff
void PutFramePerSecound()
{
if (bFps)
@@ -94,12 +94,12 @@
int main(int argc, char *argv[])
{
- //Get executable's path
+ // Get executable's path
strcpy(gModulePath, SDL_GetBasePath());
if (gModulePath[strlen(gModulePath) - 1] == '/' || gModulePath[strlen(gModulePath) - 1] == '\\')
- gModulePath[strlen(gModulePath) - 1] = '\0'; //String cannot end in slash or stuff will probably break (original does this through a windows.h provided function)
+ gModulePath[strlen(gModulePath) - 1] = '\0'; // String cannot end in slash or stuff will probably break (original does this through a windows.h provided function)
- //Get path of the data folder
+ // Get path of the data folder
strcpy(gDataPath, gModulePath);
strcat(gDataPath, "/data");
@@ -109,17 +109,17 @@
SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "102");
#endif
- //Initialize SDL
+ // Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_TIMER) >= 0)
{
- //Load configuration
+ // Load configuration
CONFIG config;
if (!LoadConfigData(&config))
DefaultConfigData(&config);
- //Apply keybinds
- //Swap X and Z buttons
+ // Apply keybinds
+ // Swap X and Z buttons
if (config.attack_button_mode)
{
if (config.attack_button_mode == 1)
@@ -134,7 +134,7 @@
gKeyShot = KEY_X;
}
- //Swap Okay and Cancel buttons
+ // Swap Okay and Cancel buttons
if (config.ok_button_mode)
{
if (config.ok_button_mode == 1)
@@ -149,7 +149,7 @@
gKeyCancel = gKeyShot;
}
- //Swap left and right weapon switch keys
+ // Swap left and right weapon switch keys
if (CheckFileExists("s_reverse"))
{
gKeyArms = KEY_ARMSREV;
@@ -156,7 +156,7 @@
gKeyArmsRev = KEY_ARMS;
}
- //Alternate movement keys
+ // Alternate movement keys
if (config.move_button_mode)
{
if (config.move_button_mode == 1)
@@ -175,7 +175,7 @@
gKeyDown = KEY_DOWN;
}
- //Set gamepad inputs
+ // Set gamepad inputs
for (int i = 0; i < 8; i++)
{
switch (config.joystick_button[i])
@@ -211,7 +211,7 @@
RECT unused_rect = {0, 0, 320, 240};
- //Load cursor
+ // Load cursor
size_t size;
const unsigned char *data = FindResource("CURSOR_NORMAL", "CURSOR", &size);
@@ -236,7 +236,7 @@
printf("Failed to load cursor\n");
}
- //Get window dimensions and colour depth
+ // Get window dimensions and colour depth
int windowWidth;
int windowHeight;
int colourDepth;
@@ -245,7 +245,7 @@
{
case 1:
case 2:
- //Set window dimensions
+ // Set window dimensions
if (config.display_mode == 1)
{
windowWidth = WINDOW_WIDTH;
@@ -257,7 +257,7 @@
windowHeight = WINDOW_HEIGHT * 2;
}
- //Create window
+ // Create window
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
if (gWindow)
@@ -274,16 +274,16 @@
case 0:
case 3:
case 4:
- //Set window dimensions
+ // Set window dimensions
windowWidth = WINDOW_WIDTH * 2;
windowHeight = WINDOW_HEIGHT * 2;
- //Create window
+ // Create window
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
if (gWindow)
{
- //Set colour depth
+ // Set colour depth
switch (config.display_mode)
{
case 0:
@@ -306,17 +306,17 @@
break;
}
- //Create window
+ // Create window
if (gWindow)
{
- //Check debug things
+ // Check debug things
if (CheckFileExists("fps"))
bFps = true;
#ifndef WINDOWS
- //Load icon
+ // Load icon
size_t size;
const unsigned char *data = FindResource("ICON_MINI", "ICON", &size);
@@ -338,24 +338,24 @@
}
#endif
- //Set rects
+ // Set rects
RECT loading_rect = {0, 0, 64, 8};
RECT clip_rect = {0, 0, windowWidth, windowHeight};
- //Load the "LOADING" text
+ // Load the "LOADING" text
MakeSurface_File("Loading", SURFACE_ID_LOADING);
- //Draw loading screen
+ // Draw loading screen
CortBox(&clip_rect, 0x000000);
PutBitmap3(&clip_rect, (WINDOW_WIDTH - 64) / 2, (WINDOW_HEIGHT - 8) / 2, &loading_rect, SURFACE_ID_LOADING);
- //Draw to screen
+ // Draw to screen
if (Flip_SystemTask())
{
- //Initialize sound
+ // Initialize sound
InitDirectSound();
- //Initialize joystick
+ // Initialize joystick
if (config.bJoystick && InitDirectInput())
{
ResetJoystickStatus();
@@ -362,14 +362,14 @@
gbUseJoystick = true;
}
- //Initialize stuff
+ // Initialize stuff
InitTextObject(config.font_name);
InitTriangleTable();
- //Run game code
+ // Run game code
Game();
- //End stuff
+ // End stuff
EndDirectSound();
EndTextObject();
EndDirectDraw();
@@ -417,10 +417,10 @@
if (GetJoystickStatus(&status))
{
- //Clear held buttons
+ // Clear held buttons
gKey &= (KEY_ESCAPE | KEY_F2 | KEY_F1);
- //Set movement buttons
+ // Set movement buttons
if (status.bLeft)
gKey |= gKeyLeft;
if (status.bRight)
@@ -430,7 +430,7 @@
if (status.bDown)
gKey |= gKeyDown;
- //Set held buttons
+ // Set held buttons
for (int i = 0; i < 8; i++)
{
if (status.bButton[i])
@@ -448,7 +448,7 @@
bool SystemTask()
{
- //Handle window events
+ // Handle window events
bool focusGained = true;
while (SDL_PollEvent(NULL) || !focusGained)
@@ -488,11 +488,9 @@
case SDL_KEYDOWN:
case SDL_KEYUP:
#ifdef FIX_BUGS
- //BUG FIX: Pixel relied on key codes for input, but these differ based on keyboard layout.
- //This would break the alternate movement keys on typical English keyboards, since the '=' key
- //is in a completely different place to where it is on a Japanese keyboard.
- //To solve this, we use scancodes instead, which are based on the physical location of keys,
- //rather than their meaning.
+ // BUG FIX: Pixel relied on key codes for input, but these differ based on keyboard layout.
+ // This would break the alternate movement keys on typical English keyboards, since the '=' key is in a completely different place to where it is on a Japanese keyboard.
+ // To solve this, we use scancodes instead, which are based on the physical location of keys, rather than their meaning.
switch (event.key.keysym.scancode)
{
case SDL_SCANCODE_ESCAPE:
@@ -631,7 +629,7 @@
}
}
- //Run joystick code
+ // Run joystick code
if (gbUseJoystick)
JoystickProc();
--- a/src/Map.cpp
+++ b/src/Map.cpp
@@ -67,7 +67,7 @@
}
else
{
- // Read tiledata
+ // Read tile data
fread(gMap.data, 1, gMap.length * gMap.width, fp);
fclose(fp);
return TRUE;
--- a/src/MapName.cpp
+++ b/src/MapName.cpp
@@ -15,15 +15,14 @@
int a;
// Handle "Studio Pixel presents" text in the intro, using an obfuscated string
- unsigned char presentText[24] =
- {
+ unsigned char presentText[24] = {
#ifdef JAPANESE
- // "開発室Pixel presents"
- 0x8A - 1, // 開
+ // "�J����Pixel presents"
+ 0x8A - 1, // �J
0x4A - 1,
- 0x94 - 1, // 発
+ 0x94 - 1, // ��
0xAD - 1,
- 0x8E - 1, // 室
+ 0x8E - 1, // ��
0xBA - 1,
'P' - 1,
'i' - 1,
@@ -80,12 +79,11 @@
str = (char*)presentText;
}
- // Copy map's name to the MapName
+ // Copy map's name to the global map name
strcpy(gMapName.name, str);
// Draw the text to the surface
a = (int)strlen(gMapName.name);
-
CortBox2(&rc, 0, SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * a) / 2 + 6, 1, gMapName.name, RGB(0x11, 0x00, 0x22), SURFACE_ID_ROOM_NAME);
PutText2((160 - 6 * a) / 2 + 6, 0, gMapName.name, RGB(0xFF, 0xFF, 0xFE), SURFACE_ID_ROOM_NAME);
@@ -93,7 +91,7 @@
void PutMapName(BOOL bMini)
{
- // 'unused_rect' isn't the original name. The Linux port optimized this out, so there's no name for it.
+ // 'unused_rect' isn't the original name. The Linux port optimised this out, so there's no name for it.
RECT unused_rect = {0, 0, 160, 16};
if (bMini)
--- a/src/MyChar.cpp
+++ b/src/MyChar.cpp
@@ -112,7 +112,7 @@
if (gMC.ani_no > 4 || gMC.ani_no < 1)
gMC.ani_no = 1;
}
- else if ( gKey & gKeyUp && bKey )
+ else if (gKey & gKeyUp && bKey)
{
if (gMC.cond & 4)
PlaySoundObject(24, 1);
@@ -137,7 +137,7 @@
{
gMC.ani_no = 10;
}
- else if ( gMC.ym <= 0 )
+ else if (gMC.ym <= 0)
{
gMC.ani_no = 3;
}
@@ -165,7 +165,7 @@
{
if ((gMC.cond & 0x80) && !(gMC.cond & 2))
{
- //Draw weapon
+ // Draw weapon
gMC.rect_arms.left = 24 * (gArmsData[gSelectedArms].code % 13);
gMC.rect_arms.right = gMC.rect_arms.left + 24;
gMC.rect_arms.top = 96 * (gArmsData[gSelectedArms].code / 13);
@@ -215,7 +215,7 @@
if (!((gMC.shock >> 1) & 1))
{
- //Draw player
+ // Draw player
RECT rect = gMC.rect;
if (gMC.equip & 0x40)
{
@@ -225,7 +225,7 @@
PutBitmap3(&grcGame, (gMC.x - gMC.view.left) / 0x200 - fx / 0x200, (gMC.y - gMC.view.top) / 0x200 - fy / 0x200, &rect, SURFACE_ID_MY_CHAR);
- //Draw airtank
+ // Draw air tank
RECT rcBubble[2] = {
{56, 96, 80, 120},
{80, 96, 104, 120},
@@ -244,7 +244,7 @@
{
if (!(gMC.cond & 2))
{
- //Get speeds and accelerations
+ // Get speeds and accelerations
int max_dash;
int gravity1;
int gravity2;
@@ -274,17 +274,17 @@
resist = 0x33;
}
- //Don't create "?" effect
+ // Don't create "?" effect
gMC.ques = 0;
- //If can't control player, stop boosting
+ // If can't control player, stop boosting
if (!bKey)
gMC.boost_sw = 0;
- //Movement on the ground
+ // Movement on the ground
if (gMC.flag & 8 || gMC.flag & 0x10 || gMC.flag & 0x20)
{
- //Stop boosting and refuel
+ // Stop boosting and refuel
gMC.boost_sw = 0;
if (gMC.equip & 1)
@@ -300,7 +300,7 @@
gMC.boost_cnt = 0;
}
- //Move in direction held
+ // Move in direction held
if (bKey)
{
if (gKeyTrg != gKeyDown || gKey != gKeyDown || (gMC.cond & 1) || g_GameFlags & 4)
@@ -325,7 +325,7 @@
}
}
- //Friction
+ // Friction
if (!(gMC.cond & 0x20))
{
if (gMC.xm < 0)
@@ -346,12 +346,12 @@
}
else
{
- //Start boosting
+ // Start boosting
if (bKey)
{
if (gMC.equip & 0x21 && gKeyTrg & gKeyJump && gMC.boost_cnt)
{
- //Booster 0.8
+ // Booster 0.8
if (gMC.equip & 1)
{
gMC.boost_sw = 1;
@@ -359,7 +359,7 @@
gMC.ym /= 2;
}
- //Booster 2.0
+ // Booster 2.0
if (gMC.equip & 0x20)
{
if (gKey & gKeyUp)
@@ -368,19 +368,19 @@
gMC.xm = 0;
gMC.ym = -0x5FF;
}
- else if ( gKey & gKeyLeft )
+ else if (gKey & gKeyLeft)
{
gMC.boost_sw = 1;
gMC.ym = 0;
gMC.xm = -0x5FF;
}
- else if ( gKey & gKeyRight )
+ else if (gKey & gKeyRight)
{
gMC.boost_sw = 1;
gMC.ym = 0;
gMC.xm = 0x5FF;
}
- else if ( gKey & gKeyDown )
+ else if (gKey & gKeyDown)
{
gMC.boost_sw = 3;
gMC.xm = 0;
@@ -395,19 +395,19 @@
}
}
- //Move left and right
- if ( gKey & gKeyLeft && gMC.xm > -max_dash )
+ // Move left and right
+ if (gKey & gKeyLeft && gMC.xm > -max_dash)
gMC.xm -= dash2;
- if ( gKey & gKeyRight && gMC.xm < max_dash )
+ if (gKey & gKeyRight && gMC.xm < max_dash)
gMC.xm += dash2;
- if ( gKey & gKeyLeft )
+ if (gKey & gKeyLeft)
gMC.direct = 0;
- if ( gKey & gKeyRight )
+ if (gKey & gKeyRight)
gMC.direct = 2;
}
- //Slow down when stopped boosting (Booster 2.0)
+ // Slow down when stopped boosting (Booster 2.0)
if (gMC.equip & 0x20 && gMC.boost_sw && (!(gKey & gKeyJump) || !gMC.boost_cnt))
{
if (gMC.boost_sw == 1)
@@ -416,15 +416,15 @@
gMC.ym /= 2;
}
- //Stop boosting
+ // Stop boosting
if (!gMC.boost_cnt || !(gKey & gKeyJump))
gMC.boost_sw = 0;
}
- //Jumping
- if ( bKey )
+ // Jumping
+ if (bKey)
{
- //Look up and down
+ // Look up and down
gMC.up = (gKey & gKeyUp) != 0;
gMC.down = gKey & gKeyDown && !(gMC.flag & 8);
@@ -437,15 +437,15 @@
}
}
- //Stop interacting when moved
+ // Stop interacting when moved
if (bKey && (gKeyShot | gKeyJump | gKeyUp | gKeyRight | gKeyLeft) & gKey)
gMC.cond &= ~1;
- //Booster losing fuel
+ // Booster losing fuel
if (gMC.boost_sw && gMC.boost_cnt)
--gMC.boost_cnt;
- //Wind / current forces
+ // Wind / current forces
if (gMC.flag & 0x1000)
gMC.xm -= 0x88;
if (gMC.flag & 0x2000)
@@ -455,22 +455,22 @@
if (gMC.flag & 0x8000)
gMC.ym += 0x55;
- //Booster 2.0 forces and effects
+ // Booster 2.0 forces and effects
if (gMC.equip & 0x20 && gMC.boost_sw)
{
if (gMC.boost_sw == 1)
{
- //Go up when going into a wall
+ // Go up when going into a wall
if (gMC.flag & 5)
gMC.ym = -0x100;
- //Move in direction facing
+ // Move in direction facing
if (!gMC.direct)
gMC.xm -= 0x20;
if (gMC.direct == 2)
gMC.xm += 0x20;
- //Boost particles (and sound)
+ // Boost particles (and sound)
if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1)
{
if (!gMC.direct)
@@ -483,10 +483,10 @@
}
else if (gMC.boost_sw == 2)
{
- //Move upwards
+ // Move upwards
gMC.ym -= 0x20;
- //Boost particles (and sound)
+ // Boost particles (and sound)
if (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1)
{
SetCaret(gMC.x, gMC.y + 0xC00, 7, 3);
@@ -495,20 +495,20 @@
}
else if (gMC.boost_sw == 3 && (gKeyTrg & gKeyJump || gMC.boost_cnt % 3 == 1))
{
- //Boost particles (and sound)
+ // Boost particles (and sound)
SetCaret(gMC.x, gMC.y - 0xC00, 7, 1);
PlaySoundObject(113, 1);
}
}
- //Upwards wind/current
+ // Upwards wind/current
else if (gMC.flag & 0x2000)
{
gMC.ym += gravity1;
}
- //Booster 0.8
+ // Booster 0.8
else if (gMC.equip & 1 && gMC.boost_sw && gMC.ym > -0x400)
{
- //Upwards force
+ // Upwards force
gMC.ym -= 0x20;
if (!(gMC.boost_cnt % 3))
@@ -517,22 +517,22 @@
PlaySoundObject(113, 1);
}
- //Bounce off of ceiling
+ // Bounce off of ceiling
if (gMC.flag & 2)
gMC.ym = 0x200;
}
- //Gravity while jump is held
+ // Gravity while jump is held
else if (gMC.ym < 0 && bKey && gKey & gKeyJump)
{
gMC.ym += gravity2;
}
- //Normal gravity
+ // Normal gravity
else
{
gMC.ym += gravity1;
}
- //Keep player on slopes
+ // Keep player on slopes
if (bKey && !(gKeyTrg & gKeyJump))
{
if (gMC.flag & 0x10 && gMC.xm < 0)
@@ -547,7 +547,7 @@
gMC.ym = 0x400;
}
- //Limit speed
+ // Limit speed
if (!(gMC.flag & 0x100) || gMC.flag & 0xF000)
{
if (gMC.xm < -0x5FF)
@@ -571,7 +571,7 @@
gMC.ym = 0x2FF;
}
- //Water splashing
+ // Water splashing
if (!gMC.sprash && gMC.flag & 0x100)
{
int dir;
@@ -604,11 +604,11 @@
if (!(gMC.flag & 0x100))
gMC.sprash = 0;
- //Spike damage
+ // Spike damage
if (gMC.flag & 0x400)
DamageMyChar(10);
- //Camera
+ // Camera
if (gMC.direct)
{
gMC.index_x += 0x200;
@@ -644,7 +644,7 @@
gMC.tgt_x = gMC.x + gMC.index_x;
gMC.tgt_y = gMC.y + gMC.index_y;
- //Change position
+ // Change position
if (gMC.xm > resist || gMC.xm < -resist)
gMC.x += gMC.xm;
gMC.y += gMC.ym;
@@ -791,12 +791,12 @@
{
if (GetNPCFlag(4000))
{
- //Core cutscene
+ // Core cutscene
StartTextScript(1100);
}
else
{
- //Drown
+ // Drown
StartTextScript(41);
if (gMC.direct)
@@ -813,7 +813,7 @@
gMC.air = 1000;
}
- if ( gMC.flag & 0x100 )
+ if (gMC.flag & 0x100)
{
gMC.air_get = 60;
}
@@ -889,7 +889,7 @@
void ZeroMyCharXMove()
{
- gMC.xm = 0;
+ gMC.xm = 0;
}
int GetUnitMyChar()
--- a/src/MycHit.cpp
+++ b/src/MycHit.cpp
@@ -35,79 +35,79 @@
{
int hit = 0;
- //Left wall
+ // Left wall
if (gMC.y - gMC.hit.top < (2 * (2 * y + 1) - 1) << 11
&& gMC.y + gMC.hit.bottom > (2 * (2 * y - 1) + 1) << 11
&& gMC.x - gMC.hit.left < (2 * x + 1) << 12
&& gMC.x - gMC.hit.left > x << 13)
{
- //Clip
+ // Clip
gMC.x = ((2 * x + 1) << 12) + gMC.hit.left;
- //Halt momentum
+ // Halt momentum
if (gMC.xm < -0x180)
gMC.xm = -0x180;
if (!(gKey & gKeyLeft) && gMC.xm < 0)
gMC.xm = 0;
- //Set that a left wall was hit
+ // Set that a left wall was hit
hit |= 1;
}
- //Right wall
+ // Right wall
if (gMC.y - gMC.hit.top < (2 * (2 * y + 1) - 1) << 11
&& gMC.y + gMC.hit.bottom > (2 * (2 * y - 1) + 1) << 11
&& gMC.x + gMC.hit.right > (2 * x - 1) << 12
&& gMC.x + gMC.hit.left < x << 13)
{
- //Clip
+ // Clip
gMC.x = ((2 * x - 1) << 12) - gMC.hit.right;
- //Halt momentum
+ // Halt momentum
if (gMC.xm > 0x180)
gMC.xm = 0x180;
if (!(gKey & gKeyRight) && gMC.xm > 0)
gMC.xm = 0;
- //Set that a right wall was hit
+ // Set that a right wall was hit
hit |= 4;
}
- //Ceiling
+ // Ceiling
if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600
&& gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12
&& gMC.y - gMC.hit.top > y << 13)
{
- //Clip
+ // Clip
gMC.y = ((2 * y + 1) << 12) + gMC.hit.top;
- //Halt momentum
+ // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar();
if (gMC.ym < 0)
gMC.ym = 0;
- //Set that a ceiling was hit
+ // Set that a ceiling was hit
hit |= 2;
}
- //Floor
+ // Floor
if (gMC.x - gMC.hit.right < ((2 * x + 1) << 12) - 0x600
&& gMC.x + gMC.hit.right > ((2 * x - 1) << 12) + 0x600
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12
&& gMC.y + gMC.hit.bottom < y << 13)
{
- //Clip
+ // Clip
gMC.y = ((2 * y - 1) << 12) - gMC.hit.bottom;
- //Halt momentum
+ // Halt momentum
if (gMC.ym > 0x400)
PlaySoundObject(23, 1);
if (gMC.ym > 0)
gMC.ym = 0;
- //Set that a floor was hit
+ // Set that a floor was hit
hit |= 8;
}
@@ -123,16 +123,16 @@
&& gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{
- //Clip
+ // Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 + gMC.hit.top;
- //Halt momentum
+ // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar();
if (gMC.ym < 0)
gMC.ym = 0;
- //Set that hit a ceiling
+ // Set that hit a ceiling
hit |= 2;
}
@@ -148,16 +148,16 @@
&& gMC.y - gMC.hit.top < (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{
- //Clip
+ // Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top;
- //Halt momentum
+ // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar();
if (gMC.ym < 0)
gMC.ym = 0;
- //Set that hit a ceiling
+ // Set that hit a ceiling
hit |= 2;
}
@@ -173,16 +173,16 @@
&& gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{
- //Clip
+ // Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 + gMC.hit.top;
- //Halt momentum
+ // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar();
if (gMC.ym < 0)
gMC.ym = 0;
- //Set that hit a ceiling
+ // Set that hit a ceiling
hit |= 2;
}
@@ -198,16 +198,16 @@
&& gMC.y - gMC.hit.top < (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y + gMC.hit.bottom > (2 * y - 1) << 12)
{
- //Clip
+ // Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 + gMC.hit.top;
- //Halt momentum
+ // Halt momentum
if (!(gMC.cond & 2) && gMC.ym < -0x200)
PutlittleStar();
if (gMC.ym < 0)
gMC.ym = 0;
- //Set that hit a ceiling
+ // Set that hit a ceiling
hit |= 2;
}
@@ -223,16 +223,16 @@
&& gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12)
{
- //Clip
+ // Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 - 0x800 - gMC.hit.bottom;
- //Halt momentum
+ // Halt momentum
if (gMC.ym > 0x400)
PlaySoundObject(23, 1);
if (gMC.ym > 0)
gMC.ym = 0;
- //Set that hit this slope
+ // Set that hit this slope
hit = 0x10028;
}
@@ -248,16 +248,16 @@
&& gMC.y + gMC.hit.bottom > (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12)
{
- //Clip
+ // Clip
gMC.y = (y << 13) + (-0x2000 * x + gMC.x) / 2 + 0x800 - gMC.hit.bottom;
- //Halt momentum
+ // Halt momentum
if (gMC.ym > 0x400)
PlaySoundObject(23, 1);
if (gMC.ym > 0)
gMC.ym = 0;
- //Set that hit this slope
+ // Set that hit this slope
hit = 0x20028;
}
@@ -273,16 +273,16 @@
&& gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12)
{
- //Clip
+ // Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 + 0x800 - gMC.hit.bottom;
- //Halt momentum
+ // Halt momentum
if (gMC.ym > 0x400)
PlaySoundObject(23, 1);
if (gMC.ym > 0)
gMC.ym = 0;
- //Set that hit this slope
+ // Set that hit this slope
hit = 0x40018;
}
@@ -298,16 +298,16 @@
&& gMC.y + gMC.hit.bottom > (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800
&& gMC.y - gMC.hit.top < (2 * y + 1) << 12)
{
- //Clip
+ // Clip
gMC.y = (y << 13) - (-0x2000 * x + gMC.x) / 2 - 0x800 - gMC.hit.bottom;
- //Halt momentum
+ // Halt momentum
if (gMC.ym > 0x400)
PlaySoundObject(23, 1);
if (gMC.ym > 0)
gMC.ym = 0;
- //Set that hit this slope
+ // Set that hit this slope
hit = 0x80018;
}
@@ -424,12 +424,12 @@
switch (atrb[i])
{
- //Water
+ // Water
case 0x02:
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
- //Block
+ // Block
case 0x05:
case 0x41:
case 0x43:
@@ -437,12 +437,12 @@
gMC.flag |= JudgeHitMyCharBlock(x + offx[i], y + offy[i]);
break;
- //Spikes
+ // Spikes
case 0x42:
gMC.flag |= JudgeHitMyCharDamage(x + offx[i], y + offy[i]);
break;
- //Slopes
+ // Slopes
case 0x50:
gMC.flag |= JudgeHitMyCharTriangleA(x + offx[i], y + offy[i]);
break;
@@ -475,7 +475,7 @@
gMC.flag |= JudgeHitMyCharTriangleH(x + offx[i], y + offy[i]);
break;
- //Water and water blocks
+ // Water and water blocks
case 0x60:
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
@@ -485,53 +485,53 @@
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
- //Water spikes
+ // Water spikes
case 0x62:
gMC.flag |= JudgeHitMyCharDamageW(x + offx[i], y + offy[i]);
break;
- //Water slopes
+ // Water slopes
case 0x70:
- gMC.flag |= JudgeHitMyCharTriangleA(x + offx[i], y + offy[i]);
- gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharTriangleA(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
case 0x71:
- gMC.flag |= JudgeHitMyCharTriangleB(x + offx[i], y + offy[i]);
- gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharTriangleB(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
case 0x72:
- gMC.flag |= JudgeHitMyCharTriangleC(x + offx[i], y + offy[i]);
- gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharTriangleC(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
case 0x73:
- gMC.flag |= JudgeHitMyCharTriangleD(x + offx[i], y + offy[i]);
- gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharTriangleD(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
case 0x74:
- gMC.flag |= JudgeHitMyCharTriangleE(x + offx[i], y + offy[i]);
- gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharTriangleE(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
case 0x75:
- gMC.flag |= JudgeHitMyCharTriangleF(x + offx[i], y + offy[i]);
- gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharTriangleF(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
case 0x76:
- gMC.flag |= JudgeHitMyCharTriangleG(x + offx[i], y + offy[i]);
- gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharTriangleG(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
case 0x77:
- gMC.flag |= JudgeHitMyCharTriangleH(x + offx[i], y + offy[i]);
- gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharTriangleH(x + offx[i], y + offy[i]);
+ gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
break;
- //Wind
+ // Wind
case 0x80:
gMC.flag |= JudgeHitMyCharVectLeft(x + offx[i], y + offy[i]);
break;
@@ -548,7 +548,7 @@
gMC.flag |= JudgeHitMyCharVectDown(x + offx[i], y + offy[i]);
break;
- //Water current
+ // Water current
case 0xA0:
gMC.flag |= JudgeHitMyCharVectLeft(x + offx[i], y + offy[i]);
gMC.flag |= JudgeHitMyCharWater(x + offx[i], y + offy[i]);
@@ -657,7 +657,7 @@
int JudgeHitMyCharNPC4(NPCHAR *npc)
{
- //TODO: comment this
+ // TODO: comment this
int hit = 0;
long double v1, v2;
@@ -688,7 +688,7 @@
{
if (gMC.x - gMC.hit.right < npc->x + npc->hit.back && gMC.x - gMC.hit.right > npc->x)
{
- if ( gMC.xm < npc->xm )
+ if (gMC.xm < npc->xm)
gMC.xm = npc->xm;
gMC.x = npc->hit.back + npc->x + gMC.hit.right;
hit |= 1;
@@ -696,7 +696,7 @@
if (gMC.x + gMC.hit.right > npc->x - npc->hit.back && gMC.hit.right + gMC.x < npc->x)
{
- if ( gMC.xm > npc->xm )
+ if (gMC.xm > npc->xm)
gMC.xm = npc->xm;
gMC.x = npc->x - npc->hit.back - gMC.hit.right;
hit |= 4;
@@ -774,7 +774,7 @@
hit = JudgeHitMyCharNPC3(&gNPC[i]);
}
- //Special NPCs (pickups)
+ // Special NPCs (pickups)
if (hit && gNPC[i].code_char == 1)
{
PlaySoundObject(14, 1);
@@ -796,11 +796,11 @@
gNPC[i].cond = 0;
}
- //Run event on contact
+ // Run event on contact
if (!(g_GameFlags & 4) && hit && gNPC[i].bits & npc_eventTouch)
StartTextScript(gNPC[i].code_event);
- //NPC damage
+ // NPC damage
if (g_GameFlags & 2 && !(gNPC[i].bits & npc_interact))
{
if (gNPC[i].bits & npc_rearTop)
@@ -820,7 +820,7 @@
}
}
- //Interaction
+ // Interaction
if (!(g_GameFlags & 4) && hit && gMC.cond & 1 && gNPC[i].bits & npc_interact)
{
StartTextScript(gNPC[i].code_event);
@@ -830,7 +830,7 @@
}
}
- //Create question mark when NPC hasn't been interacted with
+ // Create question mark when NPC hasn't been interacted with
if (gMC.ques)
SetCaret(gMC.x, gMC.y, 9, 0);
}
--- a/src/MycParam.cpp
+++ b/src/MycParam.cpp
@@ -104,7 +104,7 @@
{
if (!gMC.shock)
{
- //Damage player
+ // Damage player
PlaySoundObject(16, 1);
gMC.cond &= ~1;
gMC.shock = 128;
@@ -112,11 +112,11 @@
gMC.ym = -0x400;
gMC.life -= damage;
- //Lose a whimsical star
+ // Lose a whimsical star
if (gMC.equip & 0x80 && gMC.star > 0)
--gMC.star;
- //Lose experience
+ // Lose experience
if (gMC.equip & 4)
gArmsData[gSelectedArms].exp -= damage;
else
@@ -136,10 +136,10 @@
}
}
- //Tell player how much damage was taken
+ // Tell player how much damage was taken
SetValueView(&gMC.x, &gMC.y, -damage);
- //Death
+ // Death
if (gMC.life <= 0)
{
PlaySoundObject(17, 1);
@@ -161,7 +161,7 @@
void AddBulletMyChar(int no, int val)
{
- //Missile Launcher
+ // Missile Launcher
for (int a = 0; a < ARMS_MAX; a++)
{
if (gArmsData[a].code == 5)
@@ -173,7 +173,7 @@
}
}
- //Super Missile Launcher
+ // Super Missile Launcher
for (int a = 0; a < ARMS_MAX; a++)
{
if (gArmsData[a].code == 10)
@@ -215,7 +215,7 @@
if (gArmsEnergyX < 16)
gArmsEnergyX += 2;
- //Draw max ammo
+ // Draw max ammo
if (gArmsData[gSelectedArms].max_num)
{
PutNumber4(gArmsEnergyX + 32, 16, gArmsData[gSelectedArms].num, 0);
@@ -227,7 +227,7 @@
PutBitmap3(&rcView, gArmsEnergyX + 48, 24, &rcNone, SURFACE_ID_TEXT_BOX);
}
- //Draw experience and ammo
+ // Draw experience and ammo
if (!flash || !((gMC.shock >> 1) & 1))
{
PutBitmap3(&rcView, gArmsEnergyX + 32, 24, &rcPer, SURFACE_ID_TEXT_BOX);
@@ -277,7 +277,7 @@
{
for (int a = 0; a < arms_num; a++)
{
- //Get X position to draw at
+ // Get X position to draw at
int x = 16 * (a - gSelectedArms) + gArmsEnergyX;
if (x >= 8)
@@ -295,7 +295,7 @@
if (x < 72 && x >= 24)
x -= 48;
- //Draw icon
+ // Draw icon
rect.left = 16 * gArmsData[a].code;
rect.right = rect.left + 16;
PutBitmap3(&grcGame, x, 16, &rect, SURFACE_ID_ARMS_IMAGE);
@@ -319,7 +319,7 @@
else if (++gMC.lifeBr_count > 30)
--gMC.lifeBr;
- //Draw bar
+ // Draw bar
rcCase.right = 64;
rcLife.right = 40 * gMC.life / gMC.max_life - 1;
rcBr.right = 40 * gMC.lifeBr / gMC.max_life - 1;
@@ -340,11 +340,11 @@
if (!(gMC.equip & 0x10) && gMC.air_get)
{
- //Draw how much air is left
+ // Draw how much air is left
if (gMC.air_get % 6 <= 3)
PutNumber4(x + 32, y, gMC.air / 10, 0);
- //Draw "AIR" text
+ // Draw "AIR" text
if (gMC.air % 30 <= 10)
PutBitmap3(&grcGame, x, y, &rcAir[1], SURFACE_ID_TEXT_BOX);
else
@@ -362,7 +362,7 @@
if (gMC.equip & 0x100)
{
- //Draw clock and increase time
+ // Draw clock and increase time
if (g_GameFlags & 2)
{
if (time_count < 300000)
@@ -378,7 +378,7 @@
PutBitmap3(&grcGame, x, y, &rcTime[0], SURFACE_ID_TEXT_BOX);
}
- //Draw time
+ // Draw time
PutNumber4(x, y, time_count / 3000, false);
PutNumber4(x + 20, y, time_count / 50 % 60, true);
PutNumber4(x + 32, y, time_count / 5 % 10, false);
@@ -394,11 +394,11 @@
{
REC rec;
- //Quit if player doesn't have the Nikumaru Counter
+ // Quit if player doesn't have the Nikumaru Counter
if (!(gMC.equip & 0x100))
return true;
- //Get last time
+ // Get last time
char path[PATH_LENGTH];
sprintf(path, "%s/290.rec", gModulePath);
@@ -405,7 +405,7 @@
FILE *fp = fopen(path, "rb");
if (fp)
{
- //Read data
+ // Read data
rec.counter[0] = File_ReadLE32(fp);
rec.counter[1] = File_ReadLE32(fp);
rec.counter[2] = File_ReadLE32(fp);
@@ -422,12 +422,12 @@
p[2] -= rec.random[0];
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[0] >> 1) : (rec.random[0]);
- //If this is faster than our new time, quit
+ // If this is faster than our new time, quit
if (rec.counter[0] < time_count)
return true;
}
- //Save new time
+ // Save new time
for (int i = 0; i < 4; i++)
{
rec.counter[i] = time_count;
@@ -457,7 +457,7 @@
int LoadTimeCounter()
{
- //Open file
+ // Open file
char path[PATH_LENGTH];
sprintf(path, "%s/290.rec", gModulePath);
@@ -467,7 +467,7 @@
REC rec;
- //Read data
+ // Read data
rec.counter[0] = File_ReadLE32(fp);
rec.counter[1] = File_ReadLE32(fp);
rec.counter[2] = File_ReadLE32(fp);
@@ -478,7 +478,7 @@
rec.random[3] = fgetc(fp);
fclose(fp);
- //Decode from checksum
+ // Decode from checksum
for (int i = 0; i < 4; i++)
{
uint8_t *p = (uint8_t*)&rec.counter[i];
@@ -488,7 +488,7 @@
p[3] -= (SDL_BYTEORDER == SDL_LIL_ENDIAN) ? (rec.random[i] >> 1) : (rec.random[i]);
}
- //Verify checksum's result
+ // Verify checksum's result
if (rec.counter[0] == rec.counter[1] && rec.counter[0] == rec.counter[2])
{
time_count = rec.counter[0];
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -5,7 +5,6 @@
#include <stdio.h>
#include <string.h>
-#include <SDL_rwops.h>
#include <SDL_thread.h>
#include <SDL_timer.h>
#include <SDL_events.h>