Merge pull request #97 from cellos51/optimizations

Removed floating point operations to improve performance
This commit is contained in:
MeirGavish
2025-08-12 11:44:07 +03:00
committed by GitHub
3 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -1576,7 +1576,7 @@ static void played_cards_update_loop(bool* discarded_card, int* played_selection
FIXED played_x = int2fx(120);
FIXED played_y = int2fx(70);
FIXED played_scale = float2fx(1.0f);
FIXED played_scale = FIX_ONE;
played_x = played_x + (int2fx(played_top - i) - int2fx(played_top) / 2) * -27;
+1 -1
View File
@@ -44,7 +44,7 @@ void init()
// BG1 is the main background layer
REG_BG1CNT = BG_PRIO(1) | BG_CBB(MAIN_BG_CBB) | BG_SBB(MAIN_BG_SBB) | BG_8BPP;
// BG2 is the affine background layer
REG_BG2CNT = BG_PRIO(2) | BG_CBB(AFFINE_BG_CBB) | BG_SBB(AFFINE_BG_CBB) | BG_8BPP | BG_WRAP | BG_AFF_32x32;
REG_BG2CNT = BG_PRIO(2) | BG_CBB(AFFINE_BG_CBB) | BG_SBB(AFFINE_BG_SBB) | BG_8BPP | BG_WRAP | BG_AFF_32x32;
int win1_left = 72;
int win1_top = 44;
+5 -5
View File
@@ -145,9 +145,9 @@ void sprite_object_reset_transform(SpriteObject* sprite_object)
sprite_object->y = 0;
sprite_object->vx = 0;
sprite_object->vy = 0;
sprite_object->tscale = float2fx(1.0f); // Target scale
sprite_object->scale = float2fx(1.0f);
sprite_object->vscale = float2fx(0.0f);
sprite_object->tscale = FIX_ONE; // Target scale
sprite_object->scale = FIX_ONE;
sprite_object->vscale = 0;
sprite_object->trotation = 0; // Target rotation
sprite_object->rotation = 0;
sprite_object->vrotation = 0;
@@ -163,7 +163,7 @@ void sprite_object_update(SpriteObject* sprite_object)
sprite_object->vrotation += (sprite_object->trotation - sprite_object->rotation) / 8; // Rotate the card when it's played
// set velocity to 0 if it's close enough to the target
const float epsilon = float2fx(0.01f);
const FIXED epsilon = float2fx(0.01f);
if (sprite_object->vx < epsilon && sprite_object->vx > -epsilon && sprite_object->vy < epsilon && sprite_object->vy > -epsilon)
{
sprite_object->vx = 0;
@@ -211,7 +211,7 @@ void sprite_object_update(SpriteObject* sprite_object)
void sprite_object_shake(SpriteObject* sprite_object, mm_word sound_id)
{
sprite_object->vscale = float2fx(0.3f); // Scale down the card when it's scored
sprite_object->vscale = float2fx(0.3f);
sprite_object->vrotation = float2fx(8.0f); //Rotate the card when it's scored
if (sound_id == UNDEFINED) return; // If no sound ID is provided, do nothing