diff --git a/RSDKv3/Animation.cpp b/RSDKv3/Animation.cpp index 5948624c..4da8269c 100644 --- a/RSDKv3/Animation.cpp +++ b/RSDKv3/Animation.cpp @@ -25,7 +25,7 @@ void LoadAnimationFile(const char *filePath) byte sheetCount = 0; FileRead(&sheetCount, 1); // Sheet Count - //Read & load each spritesheet + // Read & load each spritesheet for (int s = 0; s < sheetCount; ++s) { FileRead(&fileBuffer, 1); if (fileBuffer) { @@ -45,7 +45,7 @@ void LoadAnimationFile(const char *filePath) animFile->animCount = animCount; animFile->aniListOffset = animationCount; - //Read animations + // Read animations for (int a = 0; a < animCount; ++a) { SpriteAnimation *anim = &animationList[animationCount++]; anim->frameListOffset = animFrameCount; @@ -82,7 +82,7 @@ void LoadAnimationFile(const char *filePath) anim->frameCount >>= 1; } - //Read Hitboxes + // Read Hitboxes animFile->hitboxListOffset = hitboxCount; FileRead(&fileBuffer, 1); for (int i = 0; i < fileBuffer; ++i) { @@ -119,7 +119,7 @@ AnimationFile *AddAnimationFile(const char *filePath) StrCopy(path, "Data/Animations/"); StrAdd(path, filePath); - //If matching anim is found return that, otherwise load a new anim + // If matching anim is found return that, otherwise load a new anim for (int a = 0; a < 0x100; ++a) { if (StrLength(animationFileList[a].fileName) <= 0) { StrCopy(animationFileList[a].fileName, filePath); @@ -137,7 +137,7 @@ void ProcessObjectAnimation(void *objScr, void *ent) { ObjectScript *objectScript = (ObjectScript *)objScr; Entity *entity = (Entity *)ent; - SpriteAnimation *sprAnim = &animationList[objectScript->animFile->aniListOffset + entity->animation]; + SpriteAnimation *sprAnim = &animationList[objectScript->animFile->aniListOffset + entity->animation]; if (entity->animationSpeed <= 0) { entity->animationTimer += sprAnim->speed; diff --git a/RSDKv3/Animation.hpp b/RSDKv3/Animation.hpp index 57cbf77c..c42f1d1c 100644 --- a/RSDKv3/Animation.hpp +++ b/RSDKv3/Animation.hpp @@ -1,17 +1,16 @@ #ifndef ANIMATION_H #define ANIMATION_H -#define ANIFILE_COUNT (0x100) -#define ANIMATION_COUNT (0x400) +#define ANIFILE_COUNT (0x100) +#define ANIMATION_COUNT (0x400) #define SPRITEFRAME_COUNT (0x1000) -#define HITBOX_COUNT (0x20) +#define HITBOX_COUNT (0x20) #define HITBOX_DIR_COUNT (0x8) enum AnimrotationFlags { ROTFLAG_NONE, ROTFLAG_FULL, ROTFLAG_45DEG, ROTFLAG_STATICFRAMES }; -struct AnimationFile -{ +struct AnimationFile { char fileName[0x20]; int animCount; int aniListOffset; diff --git a/RSDKv3/Collision.cpp b/RSDKv3/Collision.cpp index 295c19c6..76ab05a0 100644 --- a/RSDKv3/Collision.cpp +++ b/RSDKv3/Collision.cpp @@ -57,22 +57,23 @@ inline Hitbox *getPlayerHitbox(Player *player) void FindFloorPosition(Player *player, CollisionSensor *sensor, int startY) { - int c = 0; + int c = 0; int angle = sensor->angle; int tsm1 = (TILE_SIZE - 1); for (int i = 0; i < TILE_SIZE * 3; i += TILE_SIZE) { if (!sensor->collided) { - int XPos = sensor->XPos >> 16; + int XPos = sensor->XPos >> 16; int chunkX = XPos >> 7; - int tileX = (XPos & 0x7F) >> 4; + int tileX = (XPos & 0x7F) >> 4; int YPos = (sensor->YPos >> 16) + i - TILE_SIZE; int chunkY = YPos >> 7; - int tileY = (YPos & 0x7F) >> 4; + int tileY = (YPos & 0x7F) >> 4; if (XPos > -1 && YPos > -1) { int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; tile += tileX + (tileY << 3); int tileIndex = tiles128x128.tileIndex[tile]; - if (tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_LRB && tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_NONE) { + if (tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_LRB + && tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_NONE) { switch (tiles128x128.direction[tile]) { case FLIP_NONE: { c = (XPos & tsm1) + (tileIndex << 4); @@ -101,7 +102,7 @@ void FindFloorPosition(Player *player, CollisionSensor *sensor, int startY) sensor->YPos = tsm1 - collisionMasks[player->collisionPlane].roofMasks[c] + (chunkY << 7) + (tileY << 4); sensor->collided = true; - byte cAngle = (collisionMasks[player->collisionPlane].angles[tileIndex] & 0xFF000000) >> 24; + byte cAngle = (collisionMasks[player->collisionPlane].angles[tileIndex] & 0xFF000000) >> 24; sensor->angle = (byte)(-0x80 - cAngle); break; } @@ -148,20 +149,20 @@ void FindFloorPosition(Player *player, CollisionSensor *sensor, int startY) } void FindLWallPosition(Player *player, CollisionSensor *sensor, int startX) { - int c = 0; + int c = 0; int angle = sensor->angle; - int tsm1 = (TILE_SIZE - 1); + int tsm1 = (TILE_SIZE - 1); for (int i = 0; i < TILE_SIZE * 3; i += TILE_SIZE) { if (!sensor->collided) { int XPos = (sensor->XPos >> 16) + i - TILE_SIZE; int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; - int YPos = sensor->YPos >> 16; + int YPos = sensor->YPos >> 16; int chunkY = YPos >> 7; - int tileY = (YPos & 0x7F) >> 4; + int tileY = (YPos & 0x7F) >> 4; if (XPos > -1 && YPos > -1) { - int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; - tile = tile + tileX + (tileY << 3); + int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; + tile = tile + tileX + (tileY << 3); int tileIndex = tiles128x128.tileIndex[tile]; if (tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { switch (tiles128x128.direction[tile]) { @@ -237,20 +238,20 @@ void FindLWallPosition(Player *player, CollisionSensor *sensor, int startX) } void FindRoofPosition(Player *player, CollisionSensor *sensor, int startY) { - int c = 0; + int c = 0; int angle = sensor->angle; int tsm1 = (TILE_SIZE - 1); for (int i = 0; i < TILE_SIZE * 3; i += TILE_SIZE) { if (!sensor->collided) { - int XPos = sensor->XPos >> 16; + int XPos = sensor->XPos >> 16; int chunkX = XPos >> 7; - int tileX = (XPos & 0x7F) >> 4; + int tileX = (XPos & 0x7F) >> 4; int YPos = (sensor->YPos >> 16) + TILE_SIZE - i; int chunkY = YPos >> 7; int tileY = (YPos & 0x7F) >> 4; if (XPos > -1 && YPos > -1) { - int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; - tile = tile + tileX + (tileY << 3); + int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; + tile = tile + tileX + (tileY << 3); int tileIndex = tiles128x128.tileIndex[tile]; if (tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { switch (tiles128x128.direction[tile]) { @@ -281,7 +282,7 @@ void FindRoofPosition(Player *player, CollisionSensor *sensor, int startY) sensor->YPos = tsm1 - collisionMasks[player->collisionPlane].floorMasks[c] + (chunkY << 7) + (tileY << 4); sensor->collided = true; - byte cAngle = collisionMasks[player->collisionPlane].angles[tileIndex] & 0xFF; + byte cAngle = collisionMasks[player->collisionPlane].angles[tileIndex] & 0xFF; sensor->angle = (byte)(-0x80 - cAngle); break; } @@ -337,12 +338,12 @@ void FindRWallPosition(Player *player, CollisionSensor *sensor, int startX) int XPos = (sensor->XPos >> 16) + TILE_SIZE - i; int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; - int YPos = sensor->YPos >> 16; + int YPos = sensor->YPos >> 16; int chunkY = YPos >> 7; - int tileY = (YPos & 0x7F) >> 4; + int tileY = (YPos & 0x7F) >> 4; if (XPos > -1 && YPos > -1) { - int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; - tile = tile + tileX + (tileY << 3); + int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; + tile = tile + tileX + (tileY << 3); int tileIndex = tiles128x128.tileIndex[tile]; if (tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { switch (tiles128x128.direction[tile]) { @@ -407,7 +408,7 @@ void FindRWallPosition(Player *player, CollisionSensor *sensor, int startX) sensor->XPos = startX >> 16; sensor->collided = false; } - else if (sensor->XPos - startX < -(TILE_SIZE -2)) { + else if (sensor->XPos - startX < -(TILE_SIZE - 2)) { sensor->XPos = startX << 16; sensor->collided = false; } @@ -421,15 +422,15 @@ void FloorCollision(Player *player, CollisionSensor *sensor) { int c; int startY = sensor->YPos >> 16; - int tsm1 = (TILE_SIZE - 1); + int tsm1 = (TILE_SIZE - 1); for (int i = 0; i < TILE_SIZE * 3; i += TILE_SIZE) { if (!sensor->collided) { - int XPos = sensor->XPos >> 16; + int XPos = sensor->XPos >> 16; int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; int YPos = (sensor->YPos >> 16) + i - TILE_SIZE; int chunkY = YPos >> 7; - int tileY = (YPos & 0x7F) >> 4; + int tileY = (YPos & 0x7F) >> 4; if (XPos > -1 && YPos > -1) { int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; tile += tileX + (tileY << 3); @@ -477,7 +478,7 @@ void FloorCollision(Player *player, CollisionSensor *sensor) sensor->YPos = tsm1 - collisionMasks[player->collisionPlane].roofMasks[c] + (chunkY << 7) + (tileY << 4); sensor->collided = true; - int cAngle = (collisionMasks[player->collisionPlane].angles[tileIndex] & 0xFF000000) >> 24; + int cAngle = (collisionMasks[player->collisionPlane].angles[tileIndex] & 0xFF000000) >> 24; sensor->angle = 0x100 - (byte)(-0x80 - cAngle); break; } @@ -487,10 +488,10 @@ void FloorCollision(Player *player, CollisionSensor *sensor) if (sensor->collided) { if (sensor->angle < 0) sensor->angle += 0x100; - + if (sensor->angle > 0xFF) sensor->angle -= 0x100; - + if (sensor->YPos - startY > (TILE_SIZE - 2)) { sensor->YPos = startY << 16; sensor->collided = false; @@ -508,20 +509,21 @@ void LWallCollision(Player *player, CollisionSensor *sensor) { int c; int startX = sensor->XPos >> 16; - int tsm1 = (TILE_SIZE - 1); + int tsm1 = (TILE_SIZE - 1); for (int i = 0; i < TILE_SIZE * 3; i += TILE_SIZE) { if (!sensor->collided) { int XPos = (sensor->XPos >> 16) + i - TILE_SIZE; int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; - int YPos = sensor->YPos >> 16; + int YPos = sensor->YPos >> 16; int chunkY = YPos >> 7; - int tileY = (YPos & 0x7F) >> 4; + int tileY = (YPos & 0x7F) >> 4; if (XPos > -1 && YPos > -1) { int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; - tile += tileX + (tileY << 3); + tile += tileX + (tileY << 3); int tileIndex = tiles128x128.tileIndex[tile]; - if (tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_TOP && tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { + if (tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_TOP + && tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { switch (tiles128x128.direction[tile]) { case FLIP_NONE: { c = (YPos & tsm1) + (tileIndex << 4); @@ -580,20 +582,21 @@ void RoofCollision(Player *player, CollisionSensor *sensor) { int c; int startY = sensor->YPos >> 16; - int tsm1 = (TILE_SIZE - 1); + int tsm1 = (TILE_SIZE - 1); for (int i = 0; i < TILE_SIZE * 3; i += TILE_SIZE) { if (!sensor->collided) { - int XPos = sensor->XPos >> 16; + int XPos = sensor->XPos >> 16; int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; int YPos = (sensor->YPos >> 16) + TILE_SIZE - i; int chunkY = YPos >> 7; - int tileY = (YPos & 0x7F) >> 4; + int tileY = (YPos & 0x7F) >> 4; if (XPos > -1 && YPos > -1) { int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; - tile += tileX + (tileY << 3); + tile += tileX + (tileY << 3); int tileIndex = tiles128x128.tileIndex[tile]; - if (tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_TOP && tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { + if (tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_TOP + && tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { switch (tiles128x128.direction[tile]) { case FLIP_NONE: { c = (XPos & tsm1) + (tileIndex << 4); @@ -632,7 +635,7 @@ void RoofCollision(Player *player, CollisionSensor *sensor) sensor->YPos = tsm1 - collisionMasks[player->collisionPlane].floorMasks[c] + (chunkY << 7) + (tileY << 4); sensor->collided = true; - sensor->angle = 0x100 - (byte)(-0x80 - (collisionMasks[player->collisionPlane].angles[tileIndex] & 0xFF)); + sensor->angle = 0x100 - (byte)(-0x80 - (collisionMasks[player->collisionPlane].angles[tileIndex] & 0xFF)); break; } } @@ -662,20 +665,21 @@ void RWallCollision(Player *player, CollisionSensor *sensor) { int c; int startX = sensor->XPos >> 16; - int tsm1 = (TILE_SIZE - 1); + int tsm1 = (TILE_SIZE - 1); for (int i = 0; i < TILE_SIZE * 3; i += TILE_SIZE) { if (!sensor->collided) { int XPos = (sensor->XPos >> 16) + TILE_SIZE - i; int chunkX = XPos >> 7; - int tileX = (XPos & 0x7F) >> 4; - int YPos = sensor->YPos >> 16; + int tileX = (XPos & 0x7F) >> 4; + int YPos = sensor->YPos >> 16; int chunkY = YPos >> 7; - int tileY = (YPos & 0x7F) >> 4; + int tileY = (YPos & 0x7F) >> 4; if (XPos > -1 && YPos > -1) { int tile = stageLayouts[0].tiles[chunkX + (chunkY << 8)] << 6; - tile += tileX + (tileY << 3); + tile += tileX + (tileY << 3); int tileIndex = tiles128x128.tileIndex[tile]; - if (tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_TOP && tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { + if (tiles128x128.collisionFlags[player->collisionPlane][tile] != SOLID_TOP + && tiles128x128.collisionFlags[player->collisionPlane][tile] < SOLID_NONE) { switch (tiles128x128.direction[tile]) { case FLIP_NONE: { c = (YPos & tsm1) + (tileIndex << 4); @@ -733,13 +737,12 @@ void RWallCollision(Player *player, CollisionSensor *sensor) void ProcessAirCollision(Player *player) { - Hitbox *playerHitbox = getPlayerHitbox(player); - collisionLeft = playerHitbox->left[0]; - collisionTop = playerHitbox->top[0]; - collisionRight = playerHitbox->right[0]; - collisionBottom = playerHitbox->bottom[0]; + Hitbox *playerHitbox = getPlayerHitbox(player); + collisionLeft = playerHitbox->left[0]; + collisionTop = playerHitbox->top[0]; + collisionRight = playerHitbox->right[0]; + collisionBottom = playerHitbox->bottom[0]; - byte movingDown = 0; byte movingUp = 1; byte movingLeft = 0; @@ -775,17 +778,17 @@ void ProcessAirCollision(Player *player) movingDown = 0; } else { - movingDown = 1; + movingDown = 1; sensors[2].YPos = player->YPos + (collisionBottom << 16); sensors[3].YPos = player->YPos + (collisionBottom << 16); } sensors[4].YPos = player->YPos + ((collisionTop - 1) << 16); sensors[5].YPos = player->YPos + ((collisionTop - 1) << 16); - int cnt = (abs(player->XVelocity) <= abs(player->YVelocity) ? (abs(player->YVelocity) >> 19) + 1 : (abs(player->XVelocity) >> 19) + 1); - int XVel = player->XVelocity / cnt; - int YVel = player->YVelocity / cnt; - int XVel2 = player->XVelocity - XVel * (cnt - 1); - int YVel2 = player->YVelocity - YVel * (cnt - 1); + int cnt = (abs(player->XVelocity) <= abs(player->YVelocity) ? (abs(player->YVelocity) >> 19) + 1 : (abs(player->XVelocity) >> 19) + 1); + int XVel = player->XVelocity / cnt; + int YVel = player->YVelocity / cnt; + int XVel2 = player->XVelocity - XVel * (cnt - 1); + int YVel2 = player->YVelocity - YVel * (cnt - 1); while (cnt > 0) { if (cnt < 2) { XVel = XVel2; @@ -810,29 +813,29 @@ void ProcessAirCollision(Player *player) } if (movingRight == 2) { - player->XVelocity = 0; - player->speed = 0; - player->XPos = (sensors[0].XPos - collisionRight) << 16; - sensors[2].XPos = player->XPos + ((collisionLeft + 1) << 16); - sensors[3].XPos = player->XPos + ((collisionRight - 2) << 16); - sensors[4].XPos = sensors[2].XPos; - sensors[5].XPos = sensors[3].XPos; - XVel = 0; - XVel2 = 0; - movingRight = 3; + player->XVelocity = 0; + player->speed = 0; + player->XPos = (sensors[0].XPos - collisionRight) << 16; + sensors[2].XPos = player->XPos + ((collisionLeft + 1) << 16); + sensors[3].XPos = player->XPos + ((collisionRight - 2) << 16); + sensors[4].XPos = sensors[2].XPos; + sensors[5].XPos = sensors[3].XPos; + XVel = 0; + XVel2 = 0; + movingRight = 3; } if (movingLeft == 2) { - player->XVelocity = 0; - player->speed = 0; - player->XPos = (sensors[1].XPos - collisionLeft + 1) << 16; - sensors[2].XPos = player->XPos + ((collisionLeft + 1) << 16); - sensors[3].XPos = player->XPos + ((collisionRight - 2) << 16); - sensors[4].XPos = sensors[2].XPos; - sensors[5].XPos = sensors[3].XPos; - XVel = 0; - XVel2 = 0; - movingLeft = 3; + player->XVelocity = 0; + player->speed = 0; + player->XPos = (sensors[1].XPos - collisionLeft + 1) << 16; + sensors[2].XPos = player->XPos + ((collisionLeft + 1) << 16); + sensors[3].XPos = player->XPos + ((collisionRight - 2) << 16); + sensors[4].XPos = sensors[2].XPos; + sensors[5].XPos = sensors[3].XPos; + XVel = 0; + XVel2 = 0; + movingLeft = 3; } if (movingDown == 1) { @@ -845,7 +848,7 @@ void ProcessAirCollision(Player *player) } if (sensors[2].collided || sensors[3].collided) { movingDown = 2; - cnt = 0; + cnt = 0; } } @@ -916,7 +919,7 @@ void ProcessAirCollision(Player *player) } else { speed = (abs(player->XVelocity) <= abs(player->YVelocity >> 1) ? (player->YVelocity + player->YVelocity / 12) >> 1 - : player->XVelocity); + : player->XVelocity); } } else if (player->angle > 240) { @@ -927,7 +930,7 @@ void ProcessAirCollision(Player *player) } else { speed = (abs(player->XVelocity) <= abs(player->YVelocity >> 1) ? -((player->YVelocity + player->YVelocity / 12) >> 1) - : player->XVelocity); + : player->XVelocity); } } else if (player->angle < 0x80) { @@ -951,7 +954,6 @@ void ProcessAirCollision(Player *player) speed = (abs(player->XVelocity) <= abs(player->YVelocity >> 1) ? -(player->YVelocity >> 1) : player->XVelocity); } - if (speed < -0x180000) speed = -0x180000; if (speed > 0x180000) @@ -982,30 +984,30 @@ void ProcessAirCollision(Player *player) sensorAngle = sensors[5].angle; } sensorAngle &= 0xFF; - + int angle = ArcTanLookup(player->XVelocity, player->YVelocity); if (sensorAngle > 0x40 && sensorAngle < 0x62 && angle > 0xA0 && angle < 0xC2) { - player->gravity = 0; + player->gravity = 0; player->angle = sensorAngle; player->boundEntity->rotation = player->angle << 1; - player->collisionMode = CMODE_RWALL; - player->XPos = player->XPos + 0x40000; - player->YPos = player->YPos - 0x20000; + player->collisionMode = CMODE_RWALL; + player->XPos = player->XPos + 0x40000; + player->YPos = player->YPos - 0x20000; if (player->angle <= 0x60) player->speed = player->YVelocity; else player->speed = player->YVelocity >> 1; } if (sensorAngle > 0x9E && sensorAngle < 0xC0 && angle > 0xBE && angle < 0xE0) { - player->gravity = 0; + player->gravity = 0; player->angle = sensorAngle; player->boundEntity->rotation = player->angle << 1; player->collisionMode = CMODE_LWALL; - player->XPos = player->XPos - 0x40000; - player->YPos = player->YPos - 0x20000; - if (player->angle >= 0xA0) + player->XPos = player->XPos - 0x40000; + player->YPos = player->YPos - 0x20000; + if (player->angle >= 0xA0) player->speed = -player->YVelocity; - else + else player->speed = -player->YVelocity >> 1; } if (player->YVelocity < 0) @@ -1017,14 +1019,14 @@ void ProcessPathGrip(Player *player) { int cosValue256; int sinValue256; - sensors[4].XPos = player->XPos; - sensors[4].YPos = player->YPos; + sensors[4].XPos = player->XPos; + sensors[4].YPos = player->YPos; for (int i = 0; i < 6; ++i) { sensors[i].angle = player->angle; sensors[i].collided = false; } SetPathGripSensors(player); - int absSpeed = abs(player->speed); + int absSpeed = abs(player->speed); int checkDist = absSpeed >> 18; absSpeed &= 0x3FFFF; byte cMode = player->collisionMode; @@ -1046,9 +1048,9 @@ void ProcessPathGrip(Player *player) sinValue256 = -sinValue256; } - sensors[0].collided = false; - sensors[1].collided = false; - sensors[2].collided = false; + sensors[0].collided = false; + sensors[1].collided = false; + sensors[2].collided = false; sensors[4].XPos += cosValue256; sensors[4].YPos += sinValue256; int tileDistance = -1; @@ -1087,7 +1089,6 @@ void ProcessPathGrip(Player *player) } else if (sensors[i].collided) tileDistance = i; - } if (tileDistance <= -1) { @@ -1119,7 +1120,7 @@ void ProcessPathGrip(Player *player) if (player->speed > 0) RoofCollision(player, &sensors[3]); - if (player->speed < 0) + if (player->speed < 0) FloorCollision(player, &sensors[3]); if (sensors[3].collided) { @@ -1131,7 +1132,7 @@ void ProcessPathGrip(Player *player) sensors[i].YPos += sinValue256; FindLWallPosition(player, &sensors[i], sensors[i].XPos >> 16); } - + tileDistance = -1; for (int i = 0; i < 3; i++) { if (tileDistance > -1) { @@ -1184,7 +1185,7 @@ void ProcessPathGrip(Player *player) sensors[i].YPos += sinValue256; FindRoofPosition(player, &sensors[i], sensors[i].YPos >> 16); } - + tileDistance = -1; for (int i = 0; i < 3; i++) { if (tileDistance > -1) { @@ -1212,7 +1213,7 @@ void ProcessPathGrip(Player *player) sensors[4].XPos = sensors[1].XPos; sensors[4].YPos = sensors[0].YPos - ((collisionTop - 1) << 16); } - + if (sensors[0].angle > 0xA2) player->collisionMode = CMODE_LWALL; if (sensors[0].angle < 0x5E) @@ -1226,7 +1227,7 @@ void ProcessPathGrip(Player *player) if (player->speed > 0) FloorCollision(player, &sensors[3]); - if (player->speed < 0) + if (player->speed < 0) RoofCollision(player, &sensors[3]); if (sensors[3].collided) { @@ -1238,7 +1239,7 @@ void ProcessPathGrip(Player *player) sensors[i].YPos += sinValue256; FindRWallPosition(player, &sensors[i], sensors[i].XPos >> 16); } - + tileDistance = -1; for (int i = 0; i < 3; i++) { if (tileDistance > -1) { @@ -1284,11 +1285,11 @@ void ProcessPathGrip(Player *player) switch (cMode) { case CMODE_FLOOR: { if (sensors[0].collided || sensors[1].collided || sensors[2].collided) { - player->angle = sensors[0].angle; + player->angle = sensors[0].angle; player->boundEntity->rotation = player->angle << 1; - player->flailing[0] = sensors[0].collided; - player->flailing[1] = sensors[1].collided; - player->flailing[2] = sensors[2].collided; + player->flailing[0] = sensors[0].collided; + player->flailing[1] = sensors[1].collided; + player->flailing[2] = sensors[2].collided; if (!sensors[3].collided) { player->pushing = 0; player->XPos = sensors[4].XPos; @@ -1352,7 +1353,7 @@ void ProcessPathGrip(Player *player) player->angle = 0; } else if (player->speed >= 0x28000 || player->speed <= -0x28000 || player->controlLock != 0) { - player->angle = sensors[0].angle; + player->angle = sensors[0].angle; player->boundEntity->rotation = player->angle << 1; } else { @@ -1408,7 +1409,7 @@ void ProcessPathGrip(Player *player) } } else if (player->speed <= -0x28000 || player->speed >= 0x28000) { - player->angle = sensors[0].angle; + player->angle = sensors[0].angle; player->boundEntity->rotation = player->angle << 1; if (!sensors[3].collided) { player->XPos = sensors[4].XPos; @@ -1461,7 +1462,7 @@ void ProcessPathGrip(Player *player) player->angle = 0; } else if (player->speed <= -0x28000 || player->speed >= 0x28000 || player->controlLock != 0) { - player->angle = sensors[0].angle; + player->angle = sensors[0].angle; player->boundEntity->rotation = player->angle << 1; } else { @@ -1486,8 +1487,7 @@ void ProcessPathGrip(Player *player) player->XPos = sensors[4].XPos; return; } - default: - return; + default: return; } } @@ -1496,10 +1496,10 @@ void SetPathGripSensors(Player *player) Hitbox *playerHitbox = getPlayerHitbox(player); switch (player->collisionMode) { case CMODE_FLOOR: { - collisionLeft = playerHitbox->left[0]; - collisionTop = playerHitbox->top[0]; - collisionRight = playerHitbox->right[0]; - collisionBottom = playerHitbox->bottom[0]; + collisionLeft = playerHitbox->left[0]; + collisionTop = playerHitbox->top[0]; + collisionRight = playerHitbox->right[0]; + collisionBottom = playerHitbox->bottom[0]; sensors[0].YPos = sensors[4].YPos + (collisionBottom << 16); sensors[1].YPos = sensors[0].YPos; sensors[2].YPos = sensors[0].YPos; @@ -1515,10 +1515,10 @@ void SetPathGripSensors(Player *player) return; } case CMODE_LWALL: { - collisionLeft = playerHitbox->left[2]; - collisionTop = playerHitbox->top[2]; - collisionRight = playerHitbox->right[2]; - collisionBottom = playerHitbox->bottom[2]; + collisionLeft = playerHitbox->left[2]; + collisionTop = playerHitbox->top[2]; + collisionRight = playerHitbox->right[2]; + collisionBottom = playerHitbox->bottom[2]; sensors[0].XPos = sensors[4].XPos + (collisionRight << 16); sensors[1].XPos = sensors[0].XPos; sensors[2].XPos = sensors[0].XPos; @@ -1534,10 +1534,10 @@ void SetPathGripSensors(Player *player) return; } case CMODE_ROOF: { - collisionLeft = playerHitbox->left[4]; - collisionTop = playerHitbox->top[4]; - collisionRight = playerHitbox->right[4]; - collisionBottom = playerHitbox->bottom[4]; + collisionLeft = playerHitbox->left[4]; + collisionTop = playerHitbox->top[4]; + collisionRight = playerHitbox->right[4]; + collisionBottom = playerHitbox->bottom[4]; sensors[0].YPos = sensors[4].YPos + ((collisionTop - 1) << 16); sensors[1].YPos = sensors[0].YPos; sensors[2].YPos = sensors[0].YPos; @@ -1553,10 +1553,10 @@ void SetPathGripSensors(Player *player) return; } case CMODE_RWALL: { - collisionLeft = playerHitbox->left[6]; - collisionTop = playerHitbox->top[6]; - collisionRight = playerHitbox->right[6]; - collisionBottom = playerHitbox->bottom[6]; + collisionLeft = playerHitbox->left[6]; + collisionTop = playerHitbox->top[6]; + collisionRight = playerHitbox->right[6]; + collisionBottom = playerHitbox->bottom[6]; sensors[0].XPos = sensors[4].XPos + ((collisionLeft - 1) << 16); sensors[1].XPos = sensors[0].XPos; sensors[2].XPos = sensors[0].XPos; @@ -1571,16 +1571,15 @@ void SetPathGripSensors(Player *player) sensors[3].YPos = sensors[4].YPos + ((collisionTop - 1) << 16); return; } - default: - return; + default: return; } } void ProcessPlayerTileCollisions(Player *player) { - player->flailing[0] = 0; - player->flailing[1] = 0; - player->flailing[2] = 0; + player->flailing[0] = 0; + player->flailing[1] = 0; + player->flailing[2] = 0; scriptEng.checkResult = false; if (player->gravity == 1) ProcessAirCollision(player); @@ -1592,9 +1591,9 @@ void ObjectFloorCollision(int xOffset, int yOffset, int cPath) { scriptEng.checkResult = false; Entity *entity = &objectEntityList[objectLoop]; - int c = 0; - int XPos = (entity->XPos >> 16) + xOffset; - int YPos = (entity->YPos >> 16) + yOffset; + int c = 0; + int XPos = (entity->XPos >> 16) + xOffset; + int YPos = (entity->YPos >> 16) + yOffset; if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7) { int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; @@ -1609,7 +1608,7 @@ void ObjectFloorCollision(int xOffset, int yOffset, int cPath) if ((YPos & 15) <= collisionMasks[cPath].floorMasks[c]) { break; } - YPos = collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); + YPos = collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1618,7 +1617,7 @@ void ObjectFloorCollision(int xOffset, int yOffset, int cPath) if ((YPos & 15) <= collisionMasks[cPath].floorMasks[c]) { break; } - YPos = collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); + YPos = collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1627,7 +1626,7 @@ void ObjectFloorCollision(int xOffset, int yOffset, int cPath) if ((YPos & 15) <= 15 - collisionMasks[cPath].roofMasks[c]) { break; } - YPos = 15 - collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); + YPos = 15 - collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1636,7 +1635,7 @@ void ObjectFloorCollision(int xOffset, int yOffset, int cPath) if ((YPos & 15) <= 15 - collisionMasks[cPath].roofMasks[c]) { break; } - YPos = 15 - collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); + YPos = 15 - collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1652,8 +1651,8 @@ void ObjectLWallCollision(int xOffset, int yOffset, int cPath) int c; scriptEng.checkResult = false; Entity *entity = &objectEntityList[objectLoop]; - int XPos = (entity->XPos >> 16) + xOffset; - int YPos = (entity->YPos >> 16) + yOffset; + int XPos = (entity->XPos >> 16) + xOffset; + int YPos = (entity->YPos >> 16) + yOffset; if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7) { int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; @@ -1669,7 +1668,7 @@ void ObjectLWallCollision(int xOffset, int yOffset, int cPath) if ((XPos & 15) <= collisionMasks[cPath].lWallMasks[c]) { break; } - XPos = collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); + XPos = collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1678,7 +1677,7 @@ void ObjectLWallCollision(int xOffset, int yOffset, int cPath) if ((XPos & 15) <= 15 - collisionMasks[cPath].rWallMasks[c]) { break; } - XPos = 15 - collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); + XPos = 15 - collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1687,7 +1686,7 @@ void ObjectLWallCollision(int xOffset, int yOffset, int cPath) if ((XPos & 15) <= collisionMasks[cPath].lWallMasks[c]) { break; } - XPos = collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); + XPos = collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1696,7 +1695,7 @@ void ObjectLWallCollision(int xOffset, int yOffset, int cPath) if ((XPos & 15) <= 15 - collisionMasks[cPath].rWallMasks[c]) { break; } - XPos = 15 - collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); + XPos = 15 - collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1712,8 +1711,8 @@ void ObjectRoofCollision(int xOffset, int yOffset, int cPath) int c; scriptEng.checkResult = false; Entity *entity = &objectEntityList[objectLoop]; - int XPos = (entity->XPos >> 16) + xOffset; - int YPos = (entity->YPos >> 16) + yOffset; + int XPos = (entity->XPos >> 16) + xOffset; + int YPos = (entity->YPos >> 16) + yOffset; if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7) { int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; @@ -1729,7 +1728,7 @@ void ObjectRoofCollision(int xOffset, int yOffset, int cPath) if ((YPos & 15) >= collisionMasks[cPath].roofMasks[c]) { break; } - YPos = collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); + YPos = collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1738,7 +1737,7 @@ void ObjectRoofCollision(int xOffset, int yOffset, int cPath) if ((YPos & 15) >= collisionMasks[cPath].roofMasks[c]) { break; } - YPos = collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); + YPos = collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1747,7 +1746,7 @@ void ObjectRoofCollision(int xOffset, int yOffset, int cPath) if ((YPos & 15) >= 15 - collisionMasks[cPath].floorMasks[c]) { break; } - YPos = 15 - collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); + YPos = 15 - collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1756,7 +1755,7 @@ void ObjectRoofCollision(int xOffset, int yOffset, int cPath) if ((YPos & 15) >= 15 - collisionMasks[cPath].floorMasks[c]) { break; } - YPos = 15 - collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); + YPos = 15 - collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1772,8 +1771,8 @@ void ObjectRWallCollision(int xOffset, int yOffset, int cPath) int c; scriptEng.checkResult = false; Entity *entity = &objectEntityList[objectLoop]; - int XPos = (entity->XPos >> 16) + xOffset; - int YPos = (entity->YPos >> 16) + yOffset; + int XPos = (entity->XPos >> 16) + xOffset; + int YPos = (entity->YPos >> 16) + yOffset; if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7) { int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; @@ -1789,7 +1788,7 @@ void ObjectRWallCollision(int xOffset, int yOffset, int cPath) if ((XPos & 15) >= collisionMasks[cPath].rWallMasks[c]) { break; } - XPos = collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); + XPos = collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1798,7 +1797,7 @@ void ObjectRWallCollision(int xOffset, int yOffset, int cPath) if ((XPos & 15) >= 15 - collisionMasks[cPath].lWallMasks[c]) { break; } - XPos = 15 - collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); + XPos = 15 - collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1807,7 +1806,7 @@ void ObjectRWallCollision(int xOffset, int yOffset, int cPath) if ((XPos & 15) >= collisionMasks[cPath].rWallMasks[c]) { break; } - XPos = collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); + XPos = collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1816,7 +1815,7 @@ void ObjectRWallCollision(int xOffset, int yOffset, int cPath) if ((XPos & 15) >= 15 - collisionMasks[cPath].lWallMasks[c]) { break; } - XPos = 15 - collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); + XPos = 15 - collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1833,13 +1832,12 @@ void ObjectFloorGrip(int xOffset, int yOffset, int cPath) int c; scriptEng.checkResult = false; Entity *entity = &objectEntityList[objectLoop]; - int XPos = (entity->XPos >> 16) + xOffset; - int YPos = (entity->YPos >> 16) + yOffset; - int chunkX = YPos; - YPos = YPos - 16; + int XPos = (entity->XPos >> 16) + xOffset; + int YPos = (entity->YPos >> 16) + yOffset; + int chunkX = YPos; + YPos = YPos - 16; for (int i = 3; i > 0; i--) { - if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7 - && !scriptEng.checkResult) { + if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7 && !scriptEng.checkResult) { int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; int chunkY = YPos >> 7; @@ -1853,7 +1851,7 @@ void ObjectFloorGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].floorMasks[c] >= 64) { break; } - entity->YPos = collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); + entity->YPos = collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1862,7 +1860,7 @@ void ObjectFloorGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].floorMasks[c] >= 64) { break; } - entity->YPos = collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); + entity->YPos = collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1871,7 +1869,7 @@ void ObjectFloorGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].roofMasks[c] <= -64) { break; } - entity->YPos = 15 - collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); + entity->YPos = 15 - collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1880,7 +1878,7 @@ void ObjectFloorGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].roofMasks[c] <= -64) { break; } - entity->YPos = 15 - collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); + entity->YPos = 15 - collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -1894,7 +1892,7 @@ void ObjectFloorGrip(int xOffset, int yOffset, int cPath) entity->YPos = (entity->YPos - yOffset) << 16; return; } - entity->YPos = (chunkX - yOffset) << 16; + entity->YPos = (chunkX - yOffset) << 16; scriptEng.checkResult = false; } } @@ -1903,13 +1901,12 @@ void ObjectLWallGrip(int xOffset, int yOffset, int cPath) int c; scriptEng.checkResult = false; Entity *entity = &objectEntityList[objectLoop]; - int XPos = (entity->XPos >> 16) + xOffset; - int YPos = (entity->YPos >> 16) + yOffset; - int startX = XPos; - XPos = XPos - 16; + int XPos = (entity->XPos >> 16) + xOffset; + int YPos = (entity->YPos >> 16) + yOffset; + int startX = XPos; + XPos = XPos - 16; for (int i = 3; i > 0; i--) { - if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7 - && !scriptEng.checkResult) { + if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7 && !scriptEng.checkResult) { int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; int chunkY = YPos >> 7; @@ -1923,7 +1920,7 @@ void ObjectLWallGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].lWallMasks[c] >= 64) { break; } - entity->XPos = collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); + entity->XPos = collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1932,7 +1929,7 @@ void ObjectLWallGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].rWallMasks[c] <= -64) { break; } - entity->XPos = 15 - collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); + entity->XPos = 15 - collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1941,7 +1938,7 @@ void ObjectLWallGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].lWallMasks[c] >= 64) { break; } - entity->XPos = collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); + entity->XPos = collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1950,7 +1947,7 @@ void ObjectLWallGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].rWallMasks[c] <= -64) { break; } - entity->XPos = 15 - collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); + entity->XPos = 15 - collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -1964,7 +1961,7 @@ void ObjectLWallGrip(int xOffset, int yOffset, int cPath) entity->XPos = (entity->XPos - xOffset) << 16; return; } - entity->XPos = (startX - xOffset) << 16; + entity->XPos = (startX - xOffset) << 16; scriptEng.checkResult = false; } } @@ -1973,13 +1970,12 @@ void ObjectRoofGrip(int xOffset, int yOffset, int cPath) int c; scriptEng.checkResult = false; Entity *entity = &objectEntityList[objectLoop]; - int XPos = (entity->XPos >> 16) + xOffset; - int YPos = (entity->YPos >> 16) + yOffset; - int startY = YPos; - YPos = YPos + 16; + int XPos = (entity->XPos >> 16) + xOffset; + int YPos = (entity->YPos >> 16) + yOffset; + int startY = YPos; + YPos = YPos + 16; for (int i = 3; i > 0; i--) { - if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7 - && !scriptEng.checkResult) { + if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7 && !scriptEng.checkResult) { int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; int chunkY = YPos >> 7; @@ -1993,7 +1989,7 @@ void ObjectRoofGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].roofMasks[c] <= -64) { break; } - entity->YPos = collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); + entity->YPos = collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -2002,7 +1998,7 @@ void ObjectRoofGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].roofMasks[c] <= -64) { break; } - entity->YPos = collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); + entity->YPos = collisionMasks[cPath].roofMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -2011,7 +2007,7 @@ void ObjectRoofGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].floorMasks[c] >= 64) { break; } - entity->YPos = 15 - collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); + entity->YPos = 15 - collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -2020,7 +2016,7 @@ void ObjectRoofGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].floorMasks[c] >= 64) { break; } - entity->YPos = 15 - collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); + entity->YPos = 15 - collisionMasks[cPath].floorMasks[c] + (chunkY << 7) + (tileY << 4); scriptEng.checkResult = true; break; } @@ -2034,7 +2030,7 @@ void ObjectRoofGrip(int xOffset, int yOffset, int cPath) entity->YPos = (entity->YPos - yOffset) << 16; return; } - entity->YPos = (startY - yOffset) << 16; + entity->YPos = (startY - yOffset) << 16; scriptEng.checkResult = false; } } @@ -2043,13 +2039,12 @@ void ObjectRWallGrip(int xOffset, int yOffset, int cPath) int c; scriptEng.checkResult = false; Entity *entity = &objectEntityList[objectLoop]; - int XPos = (entity->XPos >> 16) + xOffset; - int YPos = (entity->YPos >> 16) + yOffset; - int startX = XPos; - XPos = XPos + 16; + int XPos = (entity->XPos >> 16) + xOffset; + int YPos = (entity->YPos >> 16) + yOffset; + int startX = XPos; + XPos = XPos + 16; for (int i = 3; i > 0; i--) { - if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7 - && !scriptEng.checkResult) { + if (XPos > 0 && XPos < stageLayouts[0].width << 7 && YPos > 0 && YPos < stageLayouts[0].height << 7 && !scriptEng.checkResult) { int chunkX = XPos >> 7; int tileX = (XPos & 0x7F) >> 4; int chunkY = YPos >> 7; @@ -2063,7 +2058,7 @@ void ObjectRWallGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].rWallMasks[c] <= -64) { break; } - entity->XPos = collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); + entity->XPos = collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -2072,7 +2067,7 @@ void ObjectRWallGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].lWallMasks[c] >= 64) { break; } - entity->XPos = 15 - collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); + entity->XPos = 15 - collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -2081,7 +2076,7 @@ void ObjectRWallGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].rWallMasks[c] <= -64) { break; } - entity->XPos = collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); + entity->XPos = collisionMasks[cPath].rWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -2090,7 +2085,7 @@ void ObjectRWallGrip(int xOffset, int yOffset, int cPath) if (collisionMasks[cPath].lWallMasks[c] >= 64) { break; } - entity->XPos = 15 - collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); + entity->XPos = 15 - collisionMasks[cPath].lWallMasks[c] + (chunkX << 7) + (tileX << 4); scriptEng.checkResult = true; break; } @@ -2104,7 +2099,7 @@ void ObjectRWallGrip(int xOffset, int yOffset, int cPath) entity->XPos = (entity->XPos - xOffset) << 16; return; } - entity->XPos = (startX - xOffset) << 16; + entity->XPos = (startX - xOffset) << 16; scriptEng.checkResult = false; } } @@ -2132,7 +2127,7 @@ void TouchCollision(int left, int top, int right, int bottom) right -= entity->XPos >> 16; bottom -= entity->YPos >> 16; - int thisHitboxID = addDebugHitbox(H_TYPE_TOUCH, entity, left, top, right, bottom); + int thisHitboxID = addDebugHitbox(H_TYPE_TOUCH, entity, left, top, right, bottom); if (thisHitboxID >= 0 && scriptEng.checkResult) debugHitboxList[thisHitboxID].collision |= 1; @@ -2153,10 +2148,10 @@ void BoxCollision(int left, int top, int right, int bottom) Player *player = &playerList[activePlayer]; Hitbox *playerHitbox = getPlayerHitbox(player); - collisionLeft = playerHitbox->left[0]; - collisionTop = playerHitbox->top[0]; - collisionRight = playerHitbox->right[0]; - collisionBottom = playerHitbox->bottom[0]; + collisionLeft = playerHitbox->left[0]; + collisionTop = playerHitbox->top[0]; + collisionRight = playerHitbox->right[0]; + collisionBottom = playerHitbox->bottom[0]; scriptEng.checkResult = false; int spd = 0; @@ -2199,9 +2194,9 @@ void BoxCollision(int left, int top, int right, int bottom) player->gravity = 0; player->YVelocity = 0; player->angle = 0; - player->boundEntity->rotation = 0; + player->boundEntity->rotation = 0; player->controlLock = 0; - scriptEng.checkResult = true; + scriptEng.checkResult = true; } else { sensors[0].collided = false; @@ -2345,9 +2340,9 @@ void BoxCollision(int left, int top, int right, int bottom) player->gravity = 0; player->YVelocity = 0; player->angle = 0; - player->boundEntity->rotation = 0; + player->boundEntity->rotation = 0; player->controlLock = 0; - scriptEng.checkResult = true; + scriptEng.checkResult = true; } else { sensors[0].collided = false; @@ -2377,7 +2372,7 @@ void BoxCollision(int left, int top, int right, int bottom) } #if !RETRO_USE_ORIGINAL_CODE - int thisHitboxID = 0; + int thisHitboxID = 0; if (showHitboxes) { Entity *entity = &objectEntityList[objectLoop]; left -= entity->XPos; @@ -2406,12 +2401,12 @@ void BoxCollision2(int left, int top, int right, int bottom) Player *player = &playerList[activePlayer]; Hitbox *playerHitbox = getPlayerHitbox(player); - collisionLeft = playerHitbox->left[0]; - collisionTop = playerHitbox->top[0]; - collisionRight = playerHitbox->right[0]; - collisionBottom = playerHitbox->bottom[0]; + collisionLeft = playerHitbox->left[0]; + collisionTop = playerHitbox->top[0]; + collisionRight = playerHitbox->right[0]; + collisionBottom = playerHitbox->bottom[0]; scriptEng.checkResult = false; - int spd = 0; + int spd = 0; switch (player->collisionMode) { case CMODE_FLOOR: case CMODE_ROOF: @@ -2451,9 +2446,9 @@ void BoxCollision2(int left, int top, int right, int bottom) player->gravity = 0; player->YVelocity = 0; player->angle = 0; - player->boundEntity->rotation = 0; + player->boundEntity->rotation = 0; player->controlLock = 0; - scriptEng.checkResult = 1; + scriptEng.checkResult = 1; } else { sensors[0].collided = false; @@ -2602,9 +2597,9 @@ void BoxCollision2(int left, int top, int right, int bottom) player->gravity = 0; player->YVelocity = 0; player->angle = 0; - player->boundEntity->rotation = 0; + player->boundEntity->rotation = 0; player->controlLock = 0; - scriptEng.checkResult = 1; + scriptEng.checkResult = 1; } else { sensors[0].collided = false; @@ -2635,7 +2630,7 @@ void BoxCollision2(int left, int top, int right, int bottom) } #if !RETRO_USE_ORIGINAL_CODE - int thisHitboxID = 0; + int thisHitboxID = 0; if (showHitboxes) { Entity *entity = &objectEntityList[objectLoop]; left -= entity->XPos; @@ -2664,19 +2659,19 @@ void PlatformCollision(int left, int top, int right, int bottom) Player *player = &playerList[activePlayer]; Hitbox *playerHitbox = getPlayerHitbox(player); - collisionLeft = playerHitbox->left[0]; - collisionTop = playerHitbox->top[0]; - collisionRight = playerHitbox->right[0]; - collisionBottom = playerHitbox->bottom[0]; - sensors[0].collided = false; - sensors[1].collided = false; - sensors[2].collided = false; - sensors[0].XPos = player->XPos + ((collisionLeft + 1) << 16); - sensors[1].XPos = player->XPos; - sensors[2].XPos = player->XPos + (collisionRight << 16); - sensors[0].YPos = player->YPos + (collisionBottom << 16); - sensors[1].YPos = sensors[0].YPos; - sensors[2].YPos = sensors[0].YPos; + collisionLeft = playerHitbox->left[0]; + collisionTop = playerHitbox->top[0]; + collisionRight = playerHitbox->right[0]; + collisionBottom = playerHitbox->bottom[0]; + sensors[0].collided = false; + sensors[1].collided = false; + sensors[2].collided = false; + sensors[0].XPos = player->XPos + ((collisionLeft + 1) << 16); + sensors[1].XPos = player->XPos; + sensors[2].XPos = player->XPos + (collisionRight << 16); + sensors[0].YPos = player->YPos + (collisionBottom << 16); + sensors[1].YPos = sensors[0].YPos; + sensors[2].YPos = sensors[0].YPos; scriptEng.checkResult = false; for (int i = 0; i < 3; ++i) { if (sensors[i].XPos > left && sensors[i].XPos < right && sensors[i].YPos > top - 2 && sensors[i].YPos < bottom && player->YVelocity >= 0) { @@ -2700,7 +2695,7 @@ void PlatformCollision(int left, int top, int right, int bottom) } #if !RETRO_USE_ORIGINAL_CODE - int thisHitboxID = 0; + int thisHitboxID = 0; if (showHitboxes) { Entity *entity = &objectEntityList[objectLoop]; left -= entity->XPos; @@ -2712,8 +2707,8 @@ void PlatformCollision(int left, int top, int right, int bottom) if (thisHitboxID >= 0 && scriptEng.checkResult) debugHitboxList[thisHitboxID].collision |= 1 << 0; - int otherHitboxID = addDebugHitbox(H_TYPE_PLAT, NULL, playerHitbox->left[0], playerHitbox->top[0], playerHitbox->right[0], - playerHitbox->bottom[0]); + int otherHitboxID = + addDebugHitbox(H_TYPE_PLAT, NULL, playerHitbox->left[0], playerHitbox->top[0], playerHitbox->right[0], playerHitbox->bottom[0]); if (otherHitboxID >= 0) { debugHitboxList[otherHitboxID].XPos = player->XPos; debugHitboxList[otherHitboxID].YPos = player->YPos; diff --git a/RSDKv3/Collision.hpp b/RSDKv3/Collision.hpp index 13e6459a..87fe3979 100644 --- a/RSDKv3/Collision.hpp +++ b/RSDKv3/Collision.hpp @@ -23,14 +23,13 @@ enum CollisionSolidity { }; enum ObjectCollisionTypes { - C_TOUCH = 0, - C_BOX = 1, - C_BOX2 = 2, - C_PLATFORM = 3, + C_TOUCH = 0, + C_BOX = 1, + C_BOX2 = 2, + C_PLATFORM = 3, }; -struct CollisionSensor -{ +struct CollisionSensor { int XPos; int YPos; int angle; diff --git a/RSDKv3/Debug.cpp b/RSDKv3/Debug.cpp index 08bf374b..6f18a990 100644 --- a/RSDKv3/Debug.cpp +++ b/RSDKv3/Debug.cpp @@ -8,8 +8,8 @@ void initDevMenu() for (int m = 0; m < modList.size(); ++m) scanModFolder(&modList[m]); #endif drawStageGFXHQ = false; - xScrollOffset = 0; - yScrollOffset = 0; + xScrollOffset = 0; + yScrollOffset = 0; StopMusic(); StopAllSfx(); ReleaseStageSfx(); @@ -65,8 +65,8 @@ void initDevMenu() void initErrorMessage() { drawStageGFXHQ = false; - xScrollOffset = 0; - yScrollOffset = 0; + xScrollOffset = 0; + yScrollOffset = 0; StopMusic(); StopAllSfx(); ReleaseStageSfx(); @@ -106,11 +106,11 @@ void processStageSelect() CheckKeyDown(&keyDown, 0xFF); CheckKeyPress(&keyPress, 0xFF); -//#if defined RETRO_USING_MOUSE || defined RETRO_USING_TOUCH + //#if defined RETRO_USING_MOUSE || defined RETRO_USING_TOUCH DrawSprite(32, 0x42, 16, 16, 78, 240, textMenuSurfaceNo); DrawSprite(32, 0xB2, 16, 16, 95, 240, textMenuSurfaceNo); DrawSprite(SCREEN_XSIZE - 32, SCREEN_YSIZE - 32, 16, 16, 112, 240, textMenuSurfaceNo); -//#endif + //#endif if (!keyDown.start && !keyDown.up && !keyDown.down) { int tFlags = touchFlags; @@ -225,7 +225,7 @@ void processStageSelect() gameMenu[0].selectionCount = 1; gameMenu[1].timer = 0; gameMenu[1].visibleRowOffset = 0; - stageMode = DEVMENU_MODMENU; + stageMode = DEVMENU_MODMENU; } #endif else { @@ -326,22 +326,22 @@ void processStageSelect() DrawTextMenu(&gameMenu[0], SCREEN_CENTERX - 80, 72); bool nextMenu = false; switch (gameMenu[0].selection2) { - case 3: //Presentation + case 3: // Presentation if (stageListCount[0] > 0) nextMenu = true; activeStageList = 0; break; - case 5: //Regular + case 5: // Regular if (stageListCount[1] > 0) nextMenu = true; activeStageList = 1; break; - case 7: //Special + case 7: // Special if (stageListCount[3] > 0) nextMenu = true; activeStageList = 3; break; - case 9: //Bonus + case 9: // Bonus if (stageListCount[2] > 0) nextMenu = true; activeStageList = 2; @@ -366,19 +366,19 @@ void processStageSelect() gameMenu[0].selectionCount = 1; gameMenu[1].timer = 0; gameMenu[1].visibleRowOffset = 0; - stageMode = DEVMENU_STAGESEL; + stageMode = DEVMENU_STAGESEL; } else if (keyPress.B) { SetupTextMenu(&gameMenu[0], 0); AddTextMenuEntry(&gameMenu[0], "SELECT A PLAYER"); SetupTextMenu(&gameMenu[1], 0); LoadConfigListText(&gameMenu[1], 0); - gameMenu[0].alignment = 2; - gameMenu[1].alignment = 0; + gameMenu[0].alignment = 2; + gameMenu[1].alignment = 0; gameMenu[1].selectionCount = 1; gameMenu[1].visibleRowCount = 0; - gameMenu[1].selection1 = playerListPos; - stageMode = DEVMENU_PLAYERSEL; + gameMenu[1].selection1 = playerListPos; + stageMode = DEVMENU_PLAYERSEL; } break; } @@ -564,7 +564,7 @@ void processStageSelect() char buffer[0x100]; if (gameMenu[1].selection1 < modList.size() && (keyPress.A || keyPress.start || keyPress.left || keyPress.right)) { - modList[gameMenu[1].selection1].active ^= 1; + modList[gameMenu[1].selection1].active ^= 1; StrCopy(buffer, modList[gameMenu[1].selection1].name.c_str()); StrAdd(buffer, ": "); StrAdd(buffer, (modList[gameMenu[1].selection1].active ? " Active" : "Inactive")); @@ -576,7 +576,6 @@ void processStageSelect() modList[preOption] = modList[option]; modList[option] = swap; - SetupTextMenu(&gameMenu[0], 0); AddTextMenuEntry(&gameMenu[0], "MOD LIST"); SetupTextMenu(&gameMenu[1], 0); diff --git a/RSDKv3/Debug.hpp b/RSDKv3/Debug.hpp index 4d852574..c8843697 100644 --- a/RSDKv3/Debug.hpp +++ b/RSDKv3/Debug.hpp @@ -27,7 +27,7 @@ inline void printLog(const char *msg, ...) sprintf(pathBuffer, "%s/log.txt", gamePath); __android_log_print(ANDROID_LOG_INFO, "RSDKv3", "%s", buffer); #else - sprintf(pathBuffer, BASE_PATH"log.txt"); + sprintf(pathBuffer, BASE_PATH "log.txt"); #endif FileIO *file = fOpen(pathBuffer, "a"); if (file) { @@ -50,4 +50,4 @@ void initDevMenu(); void initErrorMessage(); void processStageSelect(); -#endif //!DEBUG_H +#endif //! DEBUG_H diff --git a/RSDKv3/Drawing.cpp b/RSDKv3/Drawing.cpp index 3886964b..988c32b1 100644 --- a/RSDKv3/Drawing.cpp +++ b/RSDKv3/Drawing.cpp @@ -4,8 +4,8 @@ short blendLookupTable[BLENDTABLE_SIZE]; short subtractLookupTable[BLENDTABLE_SIZE]; short tintLookupTable[TINTTABLE_SIZE]; -int SCREEN_XSIZE = 424; -int SCREEN_CENTERX = 424 / 2; +int SCREEN_XSIZE = 424; +int SCREEN_CENTERX = 424 / 2; int SCREEN_XSIZE_CONFIG = 424; int touchWidth = SCREEN_XSIZE; @@ -622,7 +622,7 @@ void FlipScreen() if (dimAmount < 1.0 && stageMode != STAGEMODE_PAUSED) DrawRectangle(0, 0, SCREEN_XSIZE, SCREEN_YSIZE, 0, 0, 0, 0xFF - (dimAmount * 0xFF)); - bool fb = Engine.useFBTexture; + bool fb = Engine.useFBTexture; Engine.useFBTexture = Engine.useFBTexture || stageMode == STAGEMODE_PAUSED; if (Engine.gameMode == ENGINE_VIDEOWAIT) @@ -630,7 +630,7 @@ void FlipScreen() else Engine.highResMode ? FlipScreenHRes() : Engine.useFBTexture ? FlipScreenFB() : FlipScreenNoFB(); - Engine.useFBTexture = fb; + Engine.useFBTexture = fb; } } @@ -1033,18 +1033,18 @@ void setFullScreen(bool fs) float width = w; #if RETRO_PLATFORM != RETRO_iOS && RETRO_PLATFORM != RETRO_ANDROID float aspect = SCREEN_XSIZE_CONFIG / (float)SCREEN_YSIZE; - width = aspect * h; + width = aspect * h; viewOffsetX = abs(w - width) / 2; if (width > w) { int gameWidth = (w / (float)h) * SCREEN_YSIZE; SetScreenSize(gameWidth, (gameWidth + 9) & -0x10); - + width = 0; while (width <= w) { width += SCREEN_XSIZE; } width -= SCREEN_XSIZE; - viewOffsetX = abs(w - width) / 2; + viewOffsetX = abs(w - width) / 2; } #else viewOffsetX = 0; @@ -1247,14 +1247,13 @@ void SetScreenDimensions(int width, int height, int winWidth, int winHeight) bufferHeight = height; bufferWidth = viewWidth = touchWidth = winWidth; bufferHeight = viewHeight = touchHeight = winHeight; - viewAspect = 0.75f; if (viewHeight > SCREEN_YSIZE * 2) hq3DFloorEnabled = true; else hq3DFloorEnabled = false; - + SetScreenSize(width, (width + 9) & -0x10); #if RETRO_USING_OPENGL @@ -1273,14 +1272,14 @@ void SetScreenDimensions(int width, int height, int winWidth, int winHeight) // Setup framebuffer texture int bufferW = 0; - int val = 0; + int val = 0; do { val = 1 << bufferW++; } while (val < SCREEN_XSIZE); bufferW--; int bufferH = 0; - val = 0; + val = 0; do { val = 1 << bufferH++; } while (val < SCREEN_YSIZE); diff --git a/RSDKv3/Input.cpp b/RSDKv3/Input.cpp index ee1b4ad8..4d0755dc 100644 --- a/RSDKv3/Input.cpp +++ b/RSDKv3/Input.cpp @@ -413,7 +413,7 @@ void ProcessInput() #ifdef RETRO_USING_MOUSE if (touches <= 0) { -#endif //! RETRO_USING_SDL2 +#endif //! RETRO_USING_SDL2 int mx = 0, my = 0; SDL_GetMouseState(&mx, &my); diff --git a/RSDKv3/Math.cpp b/RSDKv3/Math.cpp index dda98bd4..294d6b50 100644 --- a/RSDKv3/Math.cpp +++ b/RSDKv3/Math.cpp @@ -22,10 +22,10 @@ void CalculateTrigAngles() srand((unsigned)time(NULL)); for (int i = 0; i < 0x200; ++i) { - float Val = sin(((float)i / 256.0) * M_PI); - sinM[i] = (Val * 4096.0); - Val = cos(((float)i / 256.0) * M_PI); - cosM[i] = (Val * 4096.0); + float Val = sin(((float)i / 256.0) * M_PI); + sinM[i] = (Val * 4096.0); + Val = cos(((float)i / 256.0) * M_PI); + cosM[i] = (Val * 4096.0); } cosM[0] = 4096; @@ -38,9 +38,9 @@ void CalculateTrigAngles() sinM[384] = -4096; for (int i = 0; i < 0x200; ++i) { - float Val = sinf(((float)i / 256) * M_PI); + float Val = sinf(((float)i / 256) * M_PI); sinVal512[i] = (signed int)(Val * 512.0); - Val = cosf(((float)i / 256) * M_PI); + Val = cosf(((float)i / 256) * M_PI); cosVal512[i] = (signed int)(Val * 512.0); } @@ -76,12 +76,12 @@ byte ArcTanLookup(int X, int Y) if (X >= 0) XVal = X; - else + else XVal = -X; if (Y >= 0) YVal = Y; - else + else YVal = -Y; if (XVal <= YVal) { @@ -104,7 +104,7 @@ byte ArcTanLookup(int X, int Y) } else if (Y <= 0) result = -atanVal256[0x100 * XVal + YVal]; - else + else result = atanVal256[0x100 * XVal + YVal]; return result; } diff --git a/RSDKv3/Math.hpp b/RSDKv3/Math.hpp index 4545e5a9..e5be0aa6 100644 --- a/RSDKv3/Math.hpp +++ b/RSDKv3/Math.hpp @@ -20,7 +20,8 @@ extern byte atanVal256[0x100 * 0x100]; // Setup Angles void CalculateTrigAngles(); -inline int sin512(int angle) { +inline int sin512(int angle) +{ if (angle < 0) angle = 0x200 - angle; angle &= 0x1FFu; diff --git a/RSDKv3/Object.cpp b/RSDKv3/Object.cpp index fc088cef..322bac44 100644 --- a/RSDKv3/Object.cpp +++ b/RSDKv3/Object.cpp @@ -26,7 +26,7 @@ void SetObjectTypeName(const char *objectName, int objectID) void ProcessStartupObjects() { - scriptFrameCount = 0; + scriptFrameCount = 0; ClearAnimationData(); activePlayer = 0; activePlayerCount = 1; @@ -59,8 +59,8 @@ void ProcessObjects() case PRIORITY_ACTIVE_BOUNDS: x = entity->XPos >> 16; y = entity->YPos >> 16; - active = x > xScrollOffset - OBJECT_BORDER_X1 && x < OBJECT_BORDER_X2 + xScrollOffset - && y > yScrollOffset - OBJECT_BORDER_Y1 && y < yScrollOffset + OBJECT_BORDER_Y2; + active = x > xScrollOffset - OBJECT_BORDER_X1 && x < OBJECT_BORDER_X2 + xScrollOffset && y > yScrollOffset - OBJECT_BORDER_Y1 + && y < yScrollOffset + OBJECT_BORDER_Y2; break; case PRIORITY_ACTIVE: active = true; break; case PRIORITY_ACTIVE_PAUSED: active = true; break; @@ -71,8 +71,8 @@ void ProcessObjects() case PRIORITY_ACTIVE_BOUNDS_REMOVE: x = entity->XPos >> 16; y = entity->YPos >> 16; - if (x <= xScrollOffset - OBJECT_BORDER_X1 || x >= OBJECT_BORDER_X2 + xScrollOffset - || y <= yScrollOffset - OBJECT_BORDER_Y1 || y >= yScrollOffset + OBJECT_BORDER_Y2) { + if (x <= xScrollOffset - OBJECT_BORDER_X1 || x >= OBJECT_BORDER_X2 + xScrollOffset || y <= yScrollOffset - OBJECT_BORDER_Y1 + || y >= yScrollOffset + OBJECT_BORDER_Y2) { active = false; entity->type = OBJ_TYPE_BLANKOBJECT; } diff --git a/RSDKv3/Object.hpp b/RSDKv3/Object.hpp index 4dc22db0..45bdcd2a 100644 --- a/RSDKv3/Object.hpp +++ b/RSDKv3/Object.hpp @@ -1,9 +1,9 @@ #ifndef OBJECT_H #define OBJECT_H -#define ENTITY_COUNT (0x4A0) +#define ENTITY_COUNT (0x4A0) #define TEMPENTITY_START (ENTITY_COUNT - 0x80) -#define OBJECT_COUNT (0x100) +#define OBJECT_COUNT (0x100) struct Entity { int XPos; @@ -27,7 +27,7 @@ struct Entity { }; enum ObjectTypes { - OBJ_TYPE_BLANKOBJECT = 0 //0 is always blank obj + OBJ_TYPE_BLANKOBJECT = 0 // 0 is always blank obj }; enum ObjectPriority { diff --git a/RSDKv3/Palette.cpp b/RSDKv3/Palette.cpp index 7a691d56..25a9d095 100644 --- a/RSDKv3/Palette.cpp +++ b/RSDKv3/Palette.cpp @@ -59,7 +59,7 @@ void SetLimitedFade(byte paletteID, byte R, byte G, byte B, ushort alpha, int st paletteMode = 1; activePalette = fullPalette[paletteID]; activePalette32 = fullPalette32[paletteID]; - + if (alpha >= PALETTE_SIZE) { alpha = PALETTE_SIZE - 1; } diff --git a/RSDKv3/Palette.hpp b/RSDKv3/Palette.hpp index c60019c8..b9bbfa2f 100644 --- a/RSDKv3/Palette.hpp +++ b/RSDKv3/Palette.hpp @@ -38,7 +38,7 @@ extern int texPaletteNum; extern uint gfxPalette16to32[0x10000]; #define RGB888_TO_RGB5551(r, g, b) ((((b) >> 3) << 1) | (((g) >> 3) << 6) | (((r) >> 3) << 11) | 0) // used in mobile vers -#define RGB888_TO_RGB565(r, g, b) ((b) >> 3) | (((g) >> 2) << 5) | (((r) >> 3) << 11) // used in pc vers +#define RGB888_TO_RGB565(r, g, b) ((b) >> 3) | (((g) >> 2) << 5) | (((r) >> 3) << 11) // used in pc vers #define PACK_RGB888(colour, r, g, b) \ if (renderType == RENDER_SW) \ @@ -94,7 +94,7 @@ inline void CopyPalette(byte src, byte dest) { if (src < PALETTE_COUNT && dest < PALETTE_COUNT) { for (int i = 0; i < PALETTE_SIZE; ++i) { - fullPalette[dest][i] = fullPalette[src][i]; + fullPalette[dest][i] = fullPalette[src][i]; fullPalette32[dest][i] = fullPalette32[src][i]; } } @@ -109,7 +109,7 @@ inline void RotatePalette(byte startIndex, byte endIndex, bool right) activePalette[i] = activePalette[i - 1]; activePalette32[i] = activePalette32[i - 1]; } - activePalette[startIndex] = startClr; + activePalette[startIndex] = startClr; activePalette32[startIndex] = startClr32; } else { diff --git a/RSDKv3/Reader.cpp b/RSDKv3/Reader.cpp index e4531561..5a315cda 100644 --- a/RSDKv3/Reader.cpp +++ b/RSDKv3/Reader.cpp @@ -18,7 +18,7 @@ byte eNybbleSwap; char encryptionStringA[] = { "4RaS9D7KaEbxcp2o5r6t" }; char encryptionStringB[] = { "3tRaUxLmEaSn" }; #if RETRO_USE_MOD_LOADER -byte isModdedFile = false; +byte isModdedFile = false; #endif FileIO *cFileHandle = nullptr; @@ -26,16 +26,16 @@ FileIO *cFileHandle = nullptr; bool CheckRSDKFile(const char *filePath) { FileInfo info; - + char filePathBuffer[0x100]; sprintf(filePathBuffer, "%s", filePath); #if RETRO_PLATFORM == RETRO_OSX || RETRO_PLATFORM == RETRO_ANDROID sprintf(filePathBuffer, "%s/%s", gamePath, filePath); #endif - Engine.usingDataFile = false; + Engine.usingDataFile = false; Engine.usingDataFileStore = false; - Engine.usingBytecode = false; + Engine.usingBytecode = false; cFileHandle = fOpen(filePathBuffer, "rb"); if (cFileHandle) { @@ -57,7 +57,7 @@ bool CheckRSDKFile(const char *filePath) } else { Engine.usingDataFile = false; - cFileHandle = NULL; + cFileHandle = NULL; if (LoadFile("Data/Scripts/ByteCode/GlobalCode.bin", &info)) { Engine.usingBytecode = true; Engine.bytecodeMode = BYTECODE_MOBILE; @@ -93,7 +93,6 @@ bool LoadFile(const char *filePath, FileInfo *fileInfo) char filePathBuf[0x100]; StrCopy(filePathBuf, filePath); - if (Engine.forceFolder) Engine.usingDataFile = Engine.usingDataFileStore; Engine.forceFolder = false; @@ -154,7 +153,7 @@ bool LoadFile(const char *filePath, FileInfo *fileInfo) } } #endif - + #if RETRO_PLATFORM == RETRO_OSX || RETRO_PLATFORM == RETRO_ANDROID if (addPath) { char pathBuf[0x100]; @@ -162,7 +161,7 @@ bool LoadFile(const char *filePath, FileInfo *fileInfo) sprintf(filePathBuf, "%s", pathBuf); } #endif - + StrCopy(fileInfo->fileName, ""); StrCopy(fileName, ""); @@ -174,7 +173,7 @@ bool LoadFile(const char *filePath, FileInfo *fileInfo) bufferPosition = 0; readSize = 0; readPos = 0; - + StrCopy(fileInfo->fileName, filePath); StrCopy(fileName, filePath); if (!ParseVirtualFileSystem(fileInfo)) { @@ -201,17 +200,17 @@ bool LoadFile(const char *filePath, FileInfo *fileInfo) printLog("Couldn't load file '%s'", filePathBuf); return false; } - + StrCopy(fileInfo->fileName, filePathBuf); StrCopy(fileName, filePathBuf); virtualFileOffset = 0; fSeek(cFileHandle, 0, SEEK_END); - fileInfo->fileSize = (int)fTell(cFileHandle); + fileInfo->fileSize = (int)fTell(cFileHandle); fileInfo->vFileSize = fileInfo->fileSize; fileSize = fileInfo->fileSize; vFileSize = fileInfo->fileSize; fSeek(cFileHandle, 0, SEEK_SET); - readPos = 0; + readPos = 0; fileInfo->readPos = readPos; fileInfo->virtualFileOffset = 0; fileInfo->eStringNo = 0; @@ -277,8 +276,8 @@ bool ParseVirtualFileSystem(FileInfo *fileInfo) FileRead(&fileBuffer, 1); dirCount += fileBuffer << 8; - i = 0; - fileOffset = 0; + i = 0; + fileOffset = 0; int nextFileOffset = 0; while (i < dirCount) { FileRead(&fileBuffer, 1); @@ -298,10 +297,10 @@ bool ParseVirtualFileSystem(FileInfo *fileInfo) FileRead(&fileBuffer, 1); fileOffset += fileBuffer << 24; - //Grab info for next dir to know when we've found an error - //Ignore dir name we dont care + // Grab info for next dir to know when we've found an error + // Ignore dir name we dont care if (i == dirCount - 1) { - nextFileOffset = fileSize - headerSize; //There is no next dir, so just make this the EOF + nextFileOffset = fileSize - headerSize; // There is no next dir, so just make this the EOF } else { FileRead(&fileBuffer, 1); @@ -382,7 +381,7 @@ bool ParseVirtualFileSystem(FileInfo *fileInfo) virtualFileOffset += j; } - //No File has been found (next file would be in a new dir) + // No File has been found (next file would be in a new dir) if (virtualFileOffset >= nextFileOffset + headerSize) { Engine.usingDataFile = true; return false; @@ -399,7 +398,7 @@ bool ParseVirtualFileSystem(FileInfo *fileInfo) Engine.usingDataFile = true; return true; } - //Engine.usingDataFile = true; + // Engine.usingDataFile = true; return false; } @@ -468,7 +467,7 @@ void SetFileInfo(FileInfo *fileInfo) #if RETRO_USE_MOD_LOADER } else { - Engine.forceFolder = true; + Engine.forceFolder = true; } #endif diff --git a/RSDKv3/Reader.hpp b/RSDKv3/Reader.hpp index 29486959..407c8b5b 100644 --- a/RSDKv3/Reader.hpp +++ b/RSDKv3/Reader.hpp @@ -23,7 +23,7 @@ #define fClose(file) SDL_RWclose(file) #define fWrite(buffer, elementSize, elementCount, file) SDL_RWwrite(file, buffer, elementSize, elementCount) #else -#define FileIO FILE +#define FileIO FILE #define fOpen(path, mode) fopen(path, mode) #define fRead(buffer, elementSize, elementCount, file) fread(buffer, elementSize, elementCount, file) #define fSeek(file, offset, whence) fseek(file, offset, whence) @@ -107,7 +107,7 @@ inline size_t FillFileBuffer() { if (readPos + 0x2000 <= fileSize) readSize = 0x2000; - else + else readSize = fileSize - readPos; size_t result = fRead(fileBuffer, 1u, readSize, cFileHandle); @@ -129,7 +129,7 @@ inline void GetFileInfo(FileInfo *fileInfo) fileInfo->eStringNo = eStringNo; fileInfo->eNybbleSwap = eNybbleSwap; #if RETRO_USE_MOD_LOADER - fileInfo->isMod = isModdedFile; + fileInfo->isMod = isModdedFile; #endif } void SetFileInfo(FileInfo *fileInfo); diff --git a/RSDKv3/RetroEngine.cpp b/RSDKv3/RetroEngine.cpp index 9c0edad5..932f2dc1 100644 --- a/RSDKv3/RetroEngine.cpp +++ b/RSDKv3/RetroEngine.cpp @@ -69,8 +69,8 @@ bool processEvents() int width = 0, height = 0; SDL_GetWindowSize(Engine.window, &width, &height); - touchX[0] = ((touchX[0] - viewOffsetX) / (float)width) * SCREEN_XSIZE; - touchY[0] = (touchY[0] / (float)height) * SCREEN_YSIZE; + touchX[0] = ((touchX[0] - viewOffsetX) / (float)width) * SCREEN_XSIZE; + touchY[0] = (touchY[0] / (float)height) * SCREEN_YSIZE; touchDown[0] = state & SDL_BUTTON_LMASK; if (touchDown[0]) @@ -281,9 +281,9 @@ void RetroEngine::Run() const Uint64 frequency = SDL_GetPerformanceFrequency(); Uint64 frameStart = SDL_GetPerformanceCounter(), frameEnd = SDL_GetPerformanceCounter(); Uint64 frameStartBlunt = SDL_GetTicks(), frameEndBlunt = SDL_GetTicks(); - float frameDelta = 0.0f; + float frameDelta = 0.0f; float frameDeltaBlunt = 0.0f; - + while (running) { #if !RETRO_USE_ORIGINAL_CODE frameStartBlunt = SDL_GetTicks(); @@ -292,14 +292,14 @@ void RetroEngine::Run() if (frameDeltaBlunt < 1000.0f / (float)refreshRate) { SDL_Delay(1000.0f / (float)refreshRate - frameDeltaBlunt); continue; - } - + } + frameStart = SDL_GetPerformanceCounter(); frameDelta = frameStart - frameEnd; if (frameDelta < frequency / (float)refreshRate) { continue; } - frameEnd = SDL_GetPerformanceCounter(); + frameEnd = SDL_GetPerformanceCounter(); frameEndBlunt = SDL_GetTicks(); #endif running = processEvents(); @@ -328,7 +328,7 @@ void RetroEngine::Run() indexSize3D = 0; render3DEnabled = false; } - ProcessStage(); + ProcessStage(); break; case ENGINE_INITDEVMENU: LoadGameConfig("Data/Game/GameConfig.bin"); @@ -372,11 +372,11 @@ void RetroEngine::Run() int hapticID = GetHapticEffectNum(); if (hapticID >= 0) { - //playHaptics(hapticID); + // playHaptics(hapticID); } else if (hapticID == HAPTIC_STOP) { - //stopHaptics(); - } + // stopHaptics(); + } } ReleaseAudioDevice(); @@ -490,19 +490,19 @@ void RetroEngine::LoadXMLPalettes() bool success = doc->Parse(xmlData) == tinyxml2::XML_SUCCESS; if (success) { - const tinyxml2::XMLElement *gameElement = firstXMLChildElement(doc, nullptr, "game"); + const tinyxml2::XMLElement *gameElement = firstXMLChildElement(doc, nullptr, "game"); const tinyxml2::XMLElement *paletteElement = firstXMLChildElement(doc, gameElement, "palette"); if (paletteElement) { const tinyxml2::XMLElement *clrElement = firstXMLChildElement(doc, paletteElement, "color"); if (clrElement) { do { const tinyxml2::XMLAttribute *bankAttr = findXMLAttribute(clrElement, "bank"); - int clrBank = 0; + int clrBank = 0; if (bankAttr) clrBank = getXMLAttributeValueInt(bankAttr); const tinyxml2::XMLAttribute *indAttr = findXMLAttribute(clrElement, "index"); - int clrInd = 0; + int clrInd = 0; if (indAttr) clrInd = getXMLAttributeValueInt(indAttr); @@ -627,7 +627,7 @@ void RetroEngine::LoadXMLSoundFX() if (sfxElement) { do { const tinyxml2::XMLAttribute *pathAttr = findXMLAttribute(sfxElement, "path"); - const char *sfxPath = "unknownSFX.wav"; + const char *sfxPath = "unknownSFX.wav"; if (pathAttr) sfxPath = getXMLAttributeValueString(pathAttr); @@ -745,7 +745,7 @@ void RetroEngine::LoadXMLStages(TextMenu *menu, int listNo) stgID = getXMLAttributeValueString(idAttr); const tinyxml2::XMLAttribute *highlightAttr = findXMLAttribute(stgElement, "highlight"); - bool stgHighlighted = false; + bool stgHighlighted = false; if (stgHighlighted) stgHighlighted = getXMLAttributeValueBool(highlightAttr); @@ -794,7 +794,7 @@ bool RetroEngine::LoadGameConfig(const char *filePath) byte fileBuffer2 = 0; char data[0x40]; char strBuffer[0x40]; - StrCopy(gameWindowText, "Retro-Engine"); //this is the default window name + StrCopy(gameWindowText, "Retro-Engine"); // this is the default window name globalVariablesCount = 0; #if RETRO_USE_MOD_LOADER @@ -904,11 +904,10 @@ bool RetroEngine::LoadGameConfig(const char *filePath) // Read Stage Mode FileRead(&fileBuffer, 1); stageList[cat][s].highlighted = fileBuffer; - } } - //Temp maybe? + // Temp maybe? if (controlMode >= 0) { saveRAM[35] = controlMode; SetGlobalVariableByName("Options.OriginalControls", controlMode); @@ -982,7 +981,7 @@ void RetroEngine::Callback(int callbackID) printLog("Callback: Buy Full Game Selected"); break; case CALLBACK_TERMS_SELECTED: // PC = How to play, Mobile = Full Game Only Screen - //Uncomment when Hi Res mode is added + // Uncomment when Hi Res mode is added /*if (bytecodeMode == BYTECODE_PC) { for (int s = 0; s < stageListCount[STAGELIST_PRESENTATION]; ++s) { if (StrComp("HELP", stageList[STAGELIST_PRESENTATION][s].name)) { @@ -1063,7 +1062,7 @@ void RetroEngine::Callback(int callbackID) printLog("Callback: Staff Credits Requested"); } else { - //Go to this URL http://www.sega.com/legal/privacy_mobile.php + // Go to this URL http://www.sega.com/legal/privacy_mobile.php printLog("Callback: Privacy Requested"); } break; diff --git a/RSDKv3/RetroEngine.hpp b/RSDKv3/RetroEngine.hpp index 61857451..d5571dac 100644 --- a/RSDKv3/RetroEngine.hpp +++ b/RSDKv3/RetroEngine.hpp @@ -71,7 +71,7 @@ typedef unsigned int uint; #error "Unknown Apple platform" #endif #elif defined __ANDROID__ -#define RETRO_PLATFORM (RETRO_ANDROID) +#define RETRO_PLATFORM (RETRO_ANDROID) #elif defined __vita__ #define RETRO_PLATFORM (RETRO_VITA) #else @@ -87,7 +87,7 @@ typedef unsigned int uint; #define DEFAULT_SCREEN_XSIZE 424 #define DEFAULT_FULLSCREEN false #else -#define BASE_PATH "" +#define BASE_PATH "" #define RETRO_USING_MOUSE #define RETRO_USING_TOUCH #define DEFAULT_SCREEN_XSIZE 424 @@ -332,8 +332,8 @@ class RetroEngine bool initialised = false; bool running = false; - int gameMode = 1; - int language = RETRO_EN; + int gameMode = 1; + int language = RETRO_EN; int message = 0; bool highResMode = false; bool useFBTexture = false; @@ -394,7 +394,7 @@ class RetroEngine // No_Haptics is default for pc but people with controllers exist #if RETRO_USE_HAPTICS - const char *gameHapticSetting = "Use_Haptics"; + const char *gameHapticSetting = "Use_Haptics"; #else const char *gameHapticSetting = "No_Haptics"; #endif @@ -426,7 +426,7 @@ class RetroEngine #if RETRO_USING_SDL2 SDL_Window *window = nullptr; #if !RETRO_USING_OPENGL - SDL_Renderer *renderer = nullptr; + SDL_Renderer *renderer = nullptr; SDL_Texture *screenBuffer = nullptr; SDL_Texture *screenBuffer2x = nullptr; SDL_Texture *videoBuffer = nullptr; diff --git a/RSDKv3/Scene.cpp b/RSDKv3/Scene.cpp index eaac1c63..3856030f 100644 --- a/RSDKv3/Scene.cpp +++ b/RSDKv3/Scene.cpp @@ -48,7 +48,7 @@ int lastXSize = -1; bool pauseEnabled = true; bool timeEnabled = true; bool debugMode = false; -int frameCounter = 0; +int frameCounter = 0; int stageMilliseconds = 0; int stageSeconds = 0; int stageMinutes = 0; @@ -103,10 +103,10 @@ void InitFirstStage() #if RETRO_USE_MOD_LOADER Engine.LoadXMLPalettes(); #endif - stageMode = STAGEMODE_LOAD; - Engine.gameMode = ENGINE_MAINGAME; - //activeStageList = 0; - //stageListPosition = 0; + stageMode = STAGEMODE_LOAD; + Engine.gameMode = ENGINE_MAINGAME; + // activeStageList = 0; + // stageListPosition = 0; activeStageList = Engine.startList; stageListPosition = Engine.startStage; } @@ -114,7 +114,7 @@ void InitFirstStage() void ProcessStage(void) { #if !RETRO_USE_ORIGINAL_CODE - debugHitboxCount = 0; + debugHitboxCount = 0; #endif switch (stageMode) { @@ -167,7 +167,7 @@ void ProcessStage(void) stageMinutes = 0; Engine.frameCount = 0; stageMode = STAGEMODE_NORMAL; -#if RETRO_USE_MOD_LOADER +#if RETRO_USE_MOD_LOADER for (int m = 0; m < modList.size(); ++m) scanModFolder(&modList[m]); #endif ResetBackgroundSettings(); @@ -245,9 +245,9 @@ void ProcessStage(void) } stageMilliseconds = 100 * frameCounter / Engine.refreshRate; } - else { - frameCounter = Engine.refreshRate * stageMilliseconds / 100; - } + else { + frameCounter = Engine.refreshRate * stageMilliseconds / 100; + } // Update ProcessObjects(); @@ -317,7 +317,7 @@ void LoadStageFiles(void) FileInfo info; byte fileBuffer = 0; byte fileBuffer2 = 0; - int scriptID = 1; + int scriptID = 1; char strBuffer[0x100]; if (!CheckCurrentStageFolder(stageListPosition)) { @@ -562,9 +562,9 @@ void LoadStageFiles(void) Init3DFloorBuffer(0); ProcessStartupObjects(); xScrollA = (playerList[0].XPos >> 16) - SCREEN_CENTERX; - xScrollB = (playerList[0].XPos >> 16) - SCREEN_CENTERX + SCREEN_XSIZE; + xScrollB = (playerList[0].XPos >> 16) - SCREEN_CENTERX + SCREEN_XSIZE; yScrollA = (playerList[0].YPos >> 16) - SCREEN_SCROLL_UP; - yScrollB = (playerList[0].YPos >> 16) - SCREEN_SCROLL_UP + SCREEN_YSIZE; + yScrollB = (playerList[0].YPos >> 16) - SCREEN_SCROLL_UP + SCREEN_YSIZE; } int LoadActFile(const char *ext, int stageID, FileInfo *info) { @@ -755,7 +755,6 @@ void LoadStageBackground() stageLayouts[i].scrollSpeed = fileBuffer << 10; stageLayouts[i].scrollPos = 0; - memset(stageLayouts[i].tiles, 0, TILELAYER_CHUNK_MAX * sizeof(ushort)); byte *lineScrollPtr = stageLayouts[i].lineScroll; memset(stageLayouts[i].lineScroll, 0, 0x7FFF); @@ -832,7 +831,7 @@ void LoadStageCollisions() if (LoadStageFile("CollisionMasks.bin", stageListPosition, &info)) { byte fileBuffer = 0; - int tileIndex = 0; + int tileIndex = 0; for (int t = 0; t < 1024; ++t) { for (int p = 0; p < 2; ++p) { FileRead(&fileBuffer, 1); @@ -954,7 +953,7 @@ void LoadStageCollisions() id <<= 1; } - //LWall rotations + // LWall rotations for (int c = 0; c < TILE_SIZE; ++c) { int h = 0; while (h > -1) { @@ -972,7 +971,7 @@ void LoadStageCollisions() } } - //RWall rotations + // RWall rotations for (int c = 0; c < TILE_SIZE; ++c) { int h = TILE_SIZE - 1; while (h < TILE_SIZE) { @@ -1014,8 +1013,8 @@ void LoadStageGIFFile(int stageID) height += (fileBuffer << 8); FileRead(&fileBuffer, 1); // Palette Size - //int has_pallete = (fileBuffer & 0x80) >> 7; - //int colors = ((fileBuffer & 0x70) >> 4) + 1; + // int has_pallete = (fileBuffer & 0x80) >> 7; + // int colors = ((fileBuffer & 0x70) >> 4) + 1; int palette_size = (fileBuffer & 0x7) + 1; if (palette_size > 0) palette_size = 1 << palette_size; @@ -1023,8 +1022,7 @@ void LoadStageGIFFile(int stageID) FileRead(&fileBuffer, 1); // BG Colour index (thrown away) FileRead(&fileBuffer, 1); // Pixel aspect ratio (thrown away) - if (palette_size == 256) - { + if (palette_size == 256) { byte clr[3]; for (int c = 0; c < 0x80; ++c) FileRead(clr, 3); @@ -1150,7 +1148,7 @@ void SetLayerDeformation(int selectedDef, int waveLength, int waveWidth, int wav int id = 0; if (waveType == 1) { - id = YPos; + id = YPos; for (int i = 0; i < waveSize; ++i) { deformPtr[id] = waveWidth * sinVal512[(i << 9) / waveLength & 0x1FF] >> shift; ++id; @@ -1712,10 +1710,10 @@ void SetPlayerLockedScreenPosition(Player *player) } } - int yscrollA = yScrollA; - int yscrollB = yScrollB; - int adjustY = cameraAdjustY + playerYPos; - //int adjustOffset = player->lookPos + adjustY - (yScrollA + SCREEN_SCROLL_UP); + int yscrollA = yScrollA; + int yscrollB = yScrollB; + int adjustY = cameraAdjustY + playerYPos; + // int adjustOffset = player->lookPos + adjustY - (yScrollA + SCREEN_SCROLL_UP); if (player->lookPos + adjustY <= yScrollA + SCREEN_SCROLL_UP) { player->screenYPos = adjustY - yScrollA - cameraShakeY; yScrollOffset = cameraShakeY + yscrollA; diff --git a/RSDKv3/Scene.hpp b/RSDKv3/Scene.hpp index 527a1cc0..1abb586c 100644 --- a/RSDKv3/Scene.hpp +++ b/RSDKv3/Scene.hpp @@ -9,12 +9,12 @@ #define TILE_COUNT (0x400) #define TILE_SIZE (0x10) -#define CHUNK_SIZE (0x80) +#define CHUNK_SIZE (0x80) #define TILE_DATASIZE (TILE_SIZE * TILE_SIZE) #define TILESET_SIZE (TILE_COUNT * TILE_DATASIZE) -#define TILELAYER_CHUNK_W (0x100) -#define TILELAYER_CHUNK_H (0x100) +#define TILELAYER_CHUNK_W (0x100) +#define TILELAYER_CHUNK_H (0x100) #define TILELAYER_CHUNK_MAX (TILELAYER_CHUNK_W * TILELAYER_CHUNK_H) #define TILELAYER_SCROLL_MAX (TILELAYER_CHUNK_H * CHUNK_SIZE) @@ -27,7 +27,7 @@ enum StageListNames { STAGELIST_REGULAR = 1, STAGELIST_BONUS = 2, STAGELIST_SPECIAL = 3, - STAGELIST_MAX, //StageList size + STAGELIST_MAX, // StageList size }; enum TileLayerTypes { diff --git a/RSDKv3/Scene3D.cpp b/RSDKv3/Scene3D.cpp index e33b31a0..2463f66f 100644 --- a/RSDKv3/Scene3D.cpp +++ b/RSDKv3/Scene3D.cpp @@ -50,7 +50,7 @@ void matrixMultiply(Matrix *matrixA, Matrix *matrixB) for (int i = 0; i < 0x10; ++i) { uint RowB = i & 3; - uint RowA = (i & 0xC)/4; + uint RowA = (i & 0xC) / 4; output[i] = (matrixA->values[RowA][3] * matrixB->values[3][RowB] >> 8) + (matrixA->values[RowA][2] * matrixB->values[2][RowB] >> 8) + (matrixA->values[RowA][1] * matrixB->values[1][RowB] >> 8) + (matrixA->values[RowA][0] * matrixB->values[0][RowB] >> 8); } @@ -148,8 +148,8 @@ void matrixRotateZ(Matrix *matrix, int rotationZ) if (rotationZ < 0) rotationZ = 0x200 - rotationZ; rotationZ &= 0x1FF; - int sine = sinVal512[rotationZ] >> 1; - int cosine = cosVal512[rotationZ] >> 1; + int sine = sinVal512[rotationZ] >> 1; + int cosine = cosVal512[rotationZ] >> 1; matrix->values[0][0] = cosine; matrix->values[0][1] = 0; matrix->values[0][2] = sine; diff --git a/RSDKv3/Scene3D.hpp b/RSDKv3/Scene3D.hpp index 9d670656..d0bb078a 100644 --- a/RSDKv3/Scene3D.hpp +++ b/RSDKv3/Scene3D.hpp @@ -2,7 +2,7 @@ #define DRAWING3D_H #define VERTEXBUFFER_SIZE (0x1000) -#define FACEBUFFER_SIZE (0x400) +#define FACEBUFFER_SIZE (0x400) enum FaceFlags { FACE_FLAG_TEXTURED_3D = 0, @@ -13,8 +13,8 @@ enum FaceFlags { enum MatrixTypes { MAT_WORLD = 0, - MAT_VIEW = 1, - MAT_TEMP = 2, + MAT_VIEW = 1, + MAT_TEMP = 2, }; struct Matrix { diff --git a/RSDKv3/Script.hpp b/RSDKv3/Script.hpp index 15854e15..9e396403 100644 --- a/RSDKv3/Script.hpp +++ b/RSDKv3/Script.hpp @@ -2,8 +2,8 @@ #define SCRIPT_H #define SCRIPTDATA_COUNT (0x40000) -#define JUMPTABLE_COUNT (0x4000) -#define FUNCTION_COUNT (0x200) +#define JUMPTABLE_COUNT (0x4000) +#define FUNCTION_COUNT (0x200) #define JUMPSTACK_COUNT (0x400) #define FUNCSTACK_COUNT (0x400) @@ -21,8 +21,8 @@ struct ObjectScript { ScriptPtr subDraw; ScriptPtr subStartup; int frameListOffset; - AnimationFile* animFile; - bool mobile; //flag for detecting mobile/updated bytecode + AnimationFile *animFile; + bool mobile; // flag for detecting mobile/updated bytecode }; struct ScriptEngine { @@ -43,8 +43,8 @@ extern int jumpTableData[JUMPTABLE_COUNT]; extern int jumpTableStack[JUMPSTACK_COUNT]; extern int functionStack[FUNCSTACK_COUNT]; -extern int scriptCodePos; //Bytecode file readpos -extern int jumpTablePos; //Bytecode file readpos +extern int scriptCodePos; // Bytecode file readpos +extern int jumpTablePos; // Bytecode file readpos extern int jumpTableStackPos; extern int functionStackPos; diff --git a/RSDKv3/Sprite.cpp b/RSDKv3/Sprite.cpp index d2a78430..8fd4a889 100644 --- a/RSDKv3/Sprite.cpp +++ b/RSDKv3/Sprite.cpp @@ -59,10 +59,10 @@ void InitGifDecoder() void ReadGifLine(byte *line, int length, int offset) { int i = 0; - int stackPtr = gifDecoder.stackPtr; + int stackPtr = gifDecoder.stackPtr; int eofCode = gifDecoder.eofCode; int clearCode = gifDecoder.clearCode; - int prevCode = gifDecoder.prevCode; + int prevCode = gifDecoder.prevCode; if (stackPtr != 0) { while (stackPtr != 0) { if (i >= length) { @@ -115,7 +115,7 @@ void ReadGifLine(byte *line, int length, int offset) int c = 0; while (c++ <= LZ_MAX_CODE && code > clearCode && code <= LZ_MAX_CODE) { gifDecoder.stack[stackPtr++] = gifDecoder.suffix[code]; - code = gifDecoder.prefix[code]; + code = gifDecoder.prefix[code]; } if (c >= LZ_MAX_CODE | code > LZ_MAX_CODE) { return; @@ -335,8 +335,8 @@ int LoadGIFFile(const char *filePath, byte sheetID) surface->height += (fileBuffer << 8); FileRead(&fileBuffer, 1); // Palette Size - //int has_pallete = (fileBuffer & 0x80) >> 7; - //int colors = ((fileBuffer & 0x70) >> 4) + 1; + // int has_pallete = (fileBuffer & 0x80) >> 7; + // int colors = ((fileBuffer & 0x70) >> 4) + 1; int palette_size = (fileBuffer & 0x7) + 1; if (palette_size > 0) palette_size = 1 << palette_size; @@ -479,7 +479,7 @@ int LoadRSVFile(const char *filePath, byte sheetID) FileRead(&fileBuffer, 1); videoHeight += fileBuffer << 8; - videoFilePos = (int)GetFilePosition(); + videoFilePos = (int)GetFilePosition(); videoPlaying = true; surface->width = videoWidth; surface->height = videoHeight; diff --git a/RSDKv3/Text.cpp b/RSDKv3/Text.cpp index d2cdb3e4..9237c343 100644 --- a/RSDKv3/Text.cpp +++ b/RSDKv3/Text.cpp @@ -8,7 +8,7 @@ FontCharacter fontCharacterList[FONTCHAR_COUNT]; void LoadFontFile(const char *filePath) { byte fileBuffer = 0; - int cnt = 0; + int cnt = 0; FileInfo info; if (LoadFile(filePath, &info)) { while (!ReachedEndOfFile()) { @@ -74,7 +74,7 @@ void LoadFontFile(const char *filePath) fontCharacterList[cnt].xAdvance += fileBuffer << 8; } - //Unused + // Unused FileRead(&fileBuffer, 1); FileRead(&fileBuffer, 1); cnt++; @@ -88,8 +88,8 @@ void LoadTextFile(TextMenu *menu, const char *filePath, byte mapCode) FileInfo info; byte fileBuffer = 0; if (LoadFile(filePath, &info)) { - menu->textDataPos = 0; - menu->rowCount = 0; + menu->textDataPos = 0; + menu->rowCount = 0; menu->entryStart[menu->rowCount] = menu->textDataPos; menu->entrySize[menu->rowCount] = 0; FileRead(&fileBuffer, 1); @@ -339,12 +339,12 @@ void LoadConfigListText(TextMenu *menu, int listNo) // Variables FileRead(&count, 1); for (int v = 0; v < count; ++v) { - //Var Name + // Var Name FileRead(&strLen, 1); FileRead(&strBuf, strLen); strBuf[strLen] = 0; - //Var Value + // Var Value FileRead(&fileBuffer, 1); FileRead(&fileBuffer, 1); FileRead(&fileBuffer, 1); @@ -366,7 +366,7 @@ void LoadConfigListText(TextMenu *menu, int listNo) FileRead(&strBuf, strLen); strBuf[strLen] = '\0'; - if (listNo == 0) //Player List + if (listNo == 0) // Player List AddTextMenuEntry(menu, strBuf); } @@ -375,22 +375,22 @@ void LoadConfigListText(TextMenu *menu, int listNo) byte stageCnt = 0; FileRead(&stageCnt, 1); for (int s = 0; s < stageCnt; ++s) { - //Stage Folder + // Stage Folder FileRead(&strLen, 1); FileRead(&strBuf, strLen); strBuf[strLen] = 0; - //Stage ID + // Stage ID FileRead(&strLen, 1); FileRead(&strBuf, strLen); strBuf[strLen] = 0; - //Stage Name + // Stage Name FileRead(&strLen, 1); FileRead(&strBuf, strLen); strBuf[strLen] = '\0'; - //IsHighlighted + // IsHighlighted FileRead(&fileBuffer, 1); if (listNo == c) { menu->entryHighlight[s] = fileBuffer; diff --git a/RSDKv3/Text.hpp b/RSDKv3/Text.hpp index 20fd8b48..82a89efa 100644 --- a/RSDKv3/Text.hpp +++ b/RSDKv3/Text.hpp @@ -3,7 +3,7 @@ #define TEXTDATA_COUNT (0x2800) #define TEXTENTRY_COUNT (0x200) -#define TEXTMENU_COUNT (0x2) +#define TEXTMENU_COUNT (0x2) #define FONTCHAR_COUNT (0x400) @@ -25,8 +25,7 @@ struct TextMenu { sbyte timer; }; -struct FontCharacter -{ +struct FontCharacter { int id; short srcX; short srcY; diff --git a/RSDKv3/Userdata.hpp b/RSDKv3/Userdata.hpp index 363617d4..e5b22d9e 100644 --- a/RSDKv3/Userdata.hpp +++ b/RSDKv3/Userdata.hpp @@ -77,4 +77,4 @@ void SetLeaderboard(int leaderboardID, int result); inline void LoadAchievementsMenu() { ReadUserdata(); } inline void LoadLeaderboardsMenu() { ReadUserdata(); } -#endif //!USERDATA_H +#endif //! USERDATA_H diff --git a/RSDKv3/fcaseopen.c b/RSDKv3/fcaseopen.c index 5b0a23b1..23fcaa69 100644 --- a/RSDKv3/fcaseopen.c +++ b/RSDKv3/fcaseopen.c @@ -34,71 +34,64 @@ THE SOFTWARE. static int casepath(char const *path, char *r) { size_t l = strlen(path); - char *p = (char*)alloca(l + 1); + char *p = (char *)alloca(l + 1); strcpy(p, path); size_t rl = 0; - + DIR *d; - if (p[0] == '/') - { + if (p[0] == '/') { d = opendir("/"); p = p + 1; } - else - { - d = opendir("."); + else { + d = opendir("."); r[0] = '.'; r[1] = 0; - rl = 1; + rl = 1; } - + int last = 0; - char *c = strsep(&p, "/"); - while (c) - { - if (!d) - { + char *c = strsep(&p, "/"); + while (c) { + if (!d) { return 0; } - - if (last) - { + + if (last) { closedir(d); return 0; } - + r[rl] = '/'; rl += 1; r[rl] = 0; - + struct dirent *e = readdir(d); - while (e) - { - if (strcasecmp(c, e->d_name) == 0) - { + while (e) { + if (strcasecmp(c, e->d_name) == 0) { strcpy(r + rl, e->d_name); rl += strlen(e->d_name); closedir(d); d = opendir(r); - + break; } - + e = readdir(d); } - - if (!e) - { + + if (!e) { strcpy(r + rl, c); rl += strlen(c); last = 1; } - + c = strsep(&p, "/"); } - - if (d) closedir(d); + + if (d) + closedir(d); return 1; } #endif @@ -107,11 +100,9 @@ FILE *fcaseopen(char const *path, char const *mode) { FILE *f = fopen(path, mode); #if !defined(_WIN32) - if (!f) - { - char *r = (char*)alloca(strlen(path) + 2); - if (casepath(path, r)) - { + if (!f) { + char *r = (char *)alloca(strlen(path) + 2); + if (casepath(path, r)) { f = fopen(r, mode); } } @@ -122,13 +113,11 @@ FILE *fcaseopen(char const *path, char const *mode) void casechdir(char const *path) { #if !defined(_WIN32) - char *r = (char*)alloca(strlen(path) + 2); - if (casepath(path, r)) - { + char *r = (char *)alloca(strlen(path) + 2); + if (casepath(path, r)) { chdir(r); } - else - { + else { errno = ENOENT; } #else diff --git a/RSDKv3/resource.h b/RSDKv3/resource.h index 1a903cf1..eff5e1d9 100644 --- a/RSDKv3/resource.h +++ b/RSDKv3/resource.h @@ -2,15 +2,15 @@ // Microsoft Visual C++ generated include file. // Used by RSDKv3.rc // -#define IDI_ICON1 101 +#define IDI_ICON1 101 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 #endif #endif