Skip to content

Commit

Permalink
Simplify division in berry_crush and field weather functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DizzyEggg committed Mar 9, 2024
1 parent 9e67594 commit 82f8636
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
7 changes: 1 addition & 6 deletions src/berry_crush.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,6 @@ static void CreateBerrySprites(struct BerryCrushGame *game, struct BerryCrushGam
u8 spriteId;
s16 distance, var1;
s16 *data;
s32 amplitude;
s16 speed;
u32 var2;

Expand All @@ -1395,11 +1394,7 @@ static void CreateBerrySprites(struct BerryCrushGame *game, struct BerryCrushGam
sYAccel = 32;
sBitfield = 112; // Setting bits in MASK_TARGET_Y
distance = gfx->playerCoords[i]->berryXDest - gfx->playerCoords[i]->berryXOffset;
amplitude = distance;
if (distance < 0)
amplitude += 3;

sAmplitude = amplitude >> 2;
sAmplitude = distance / 4;
distance *= 128;
var2 = speed + 32;
var2 = var2 / 2;
Expand Down
7 changes: 1 addition & 6 deletions src/field_weather.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ static void BuildColorMaps(void)
u16 brightnessDelta;
u16 colorMapIndex;
u16 baseBrightness;
u32 remainingBrightness;
s16 diff;

sPaletteColorMapTypes = sBasePaletteColorMapTypes;
Expand Down Expand Up @@ -305,11 +304,7 @@ static void BuildColorMaps(void)
}

baseBrightness = curBrightness;
remainingBrightness = 0x1f00 - curBrightness;
if ((0x1f00 - curBrightness) < 0)
remainingBrightness += 0xf;

brightnessDelta = remainingBrightness / (NUM_WEATHER_COLOR_MAPS - 3);
brightnessDelta = (0x1f00 - curBrightness) / (NUM_WEATHER_COLOR_MAPS - 3);
if (colorVal < 12)
{
// For shadows (color values < 12), the remaining color mappings are
Expand Down

0 comments on commit 82f8636

Please sign in to comment.