Add affine background color functionality and integrate into game loop

This commit is contained in:
cellos51
2025-08-05 14:35:52 -04:00
parent 46b53db8a0
commit 592d7ae8bc
5 changed files with 85 additions and 58 deletions
+3 -16
View File
@@ -11,6 +11,7 @@
#include "hand_analysis.h"
#include "blind.h"
#include "joker.h"
#include "affine_background.h"
#include "graphic_utils.h"
#include "tonc_video.h"
#include "audio_utils.h"
@@ -430,22 +431,7 @@ void change_background(int id)
{
main_bg_se_copy_rect(BOSS_BLIND_TITLE_SRC_RECT, TOP_LEFT_BLIND_TITLE_POINT);
const int palette_length = 5;
memcpy16(&pal_bg_mem[16 * 15], affine_background_gfxPal, palette_length);
for (int i = 0; i < palette_length; i++)
{
COLOR old_color = 0;
memcpy16(&old_color, &pal_bg_mem[16 * 15] + i, 1); // Copy the color from the background palette
int r, g, b;
r = (old_color >> 10) & 0b11111; // Extract red component
g = (old_color >> 5) & 0b11111; // Extract green component
b = old_color & 0b11111; // Extract blue component
COLOR new_color = blind_get_color(BOSS_BLIND, BLIND_MAIN_COLOR_INDEX);
int brightness = (r + g + b) / 3; // Calculate brightness
clr_adj_brightness(&pal_bg_mem[16 * 15] + i, &new_color, 1, float2fx(-0.6f + (brightness * 0.05f))); // Adjust brightness for the palette colors
}
affine_background_set_color(blind_get_color(BOSS_BLIND, BLIND_SHADOW_COLOR_INDEX));
}
bg_copy_current_item_to_top_left_panel();
@@ -2004,6 +1990,7 @@ void game_round_end()
tte_erase_rect_wrapper(BLIND_REWARD_RECT);
tte_erase_rect_wrapper(BLIND_REQ_TEXT_RECT);
obj_hide(playing_blind_token->obj);
affine_background_set_color(AFFINE_BG_DEFAULT_COLOR);
state = 5;
timer = 0;
}