// ********************** // Preprocessor functions // ********************** #include "header.h" // include standard libs static GsOT OTable_Header[2]; // Header files holding OTable info static GsOT_TAG OTable_Array[2][1< -11)) PSpeed -= 2; if ((Pad1 & PADcross)) { PStatus = 1; // Jump status PJump = -20; // Initial upwards force } else { t1 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 63); t2 = GetBlockStatus((PXPos >> 2) + 15, (PYPos >> 2) + 63); t3 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 63); if ((t1 == -1) && (t2 == -1) && (t3 == -1)) // Check if nothing underfoot { PStatus = 1; // Start falling PJump = 4; } } PXPos += PSpeed; // Move according to speed if (PSpeed < 0) // Collision detection for going left { t1 = GetBlockStatus((PXPos >> 2), (PYPos >> 2)); t2 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 16); t3 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 31); t4 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 46); t5 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 61); if ((t1 != -1) || (t2 != -1) || (t3 != -1) || (t4 != -1) || (t5 != -1)) { PSpeed = 0; PXPos -= PXPos % 64 - 64; } } if (PSpeed > 0) // Collision detection for going right { t1 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2)); t2 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 16); t3 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 31); t4 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 46); t5 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 61); if ((t1 != -1) || (t2 != -1) || (t3 != -1) || (t4 != -1) || (t5 != -1)) { PSpeed = 0; PXPos -= PXPos % 64; } } break; case 1: // Jumping/falling if ((Pad1 & PADright) && (PSpeed < 15)) PSpeed += 1; if ((Pad1 & PADleft) && (PSpeed > -15)) PSpeed -= 1; PXPos += PSpeed; // Move according to speed PYPos += PJump; // Change height according to acceleration if (PJump < 25) PJump++; // Drop faster until limit if (PSpeed < 0) // Collision detection 1 for going left { t1 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 16); t2 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 31); t3 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 46); if ((t1 != -1) || (t2 != -1) || (t3 != -1)) { PSpeed = 0; PXPos -= PXPos % 64 - 64; } } if (PSpeed > 0) // Collision detection 1 for going right { t1 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 16); t2 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 31); t3 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 46); if ((t1 != -1) || (t2 != -1) || (t3 != -1)) { PSpeed = 0; PXPos -= PXPos % 64; } } if (PJump < 1) // Cheap check for hitting head { t1 = GetBlockStatus((PXPos >> 2), (PYPos >> 2)); t2 = GetBlockStatus((PXPos >> 2) + 15, (PYPos >> 2)); t3 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2)); if ((t1 != -1) || (t2 != -1) || (t3 != -1)) { PYPos -= PYPos % 64 - 64; PJump = 0; } } if (PJump > 1) // Cheap check for blocks below { t1 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 62); t2 = GetBlockStatus((PXPos >> 2) + 15, (PYPos >> 2) + 62); t3 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 62); if ((t1 != -1) || (t2 != -1) || (t3 != -1)) { PYPos -= MAX(MAX(t1, t2), t3) << 2; // This may not be accurate enough PStatus = 0; } } if (PSpeed < 0) // Collision detection 2 for going left { t1 = GetBlockStatus((PXPos >> 2), (PYPos >> 2)); t2 = GetBlockStatus((PXPos >> 2), (PYPos >> 2) + 61); if ((t1 != -1) || (t2 != -1)) { PSpeed = 0; PXPos -= PXPos % 64 - 64; } } if (PSpeed > 0) // Collision detection 2 for going right { t1 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2)); t2 = GetBlockStatus((PXPos >> 2) + 31, (PYPos >> 2) + 61); if ((t1 != -1) || (t2 != -1)) { PSpeed = 0; PXPos -= PXPos % 64; } } break; } // Process objects UpdateObjects(); // Miscellaneous variable messing if (PSpeed > 0) PSpeed--; // Slow down generally if (PSpeed < 0) PSpeed++; // Slow down generally // Offset the visible area from player's position XScreen = (PXPos >> 2) - 152; YScreen = (PYPos >> 2) - 120; }