Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better color slides for HARs in cinematics #763

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions src/formats/palette.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,6 @@ void palette_load_player_colors(vga_palette *src, int player) {
vga_state_set_base_palette_from_range(src, dst_offset, 1, 47);
}

void palette_load_player_cutscene_colors(vga_palette *src) {
vga_palette pal;
for(int i = 1; i < 48; i++) {
memcpy(pal.colors + i * 2, src->colors + i, 3);
memcpy(pal.colors + i * 2 + 1, src->colors + i, 3);
// TODO do real palette interpolation
}
vga_state_set_base_palette_from_range(&pal, 1, 1, 47);
}

void palette_load_altpal_player_color(vga_palette *dst, int player, int src_color, int dst_color) {
int dst_index = dst_color * 16 + player * 48;
int src_index = src_color * 16;
Expand All @@ -236,6 +226,26 @@ void palette_set_player_color(int player, int src_color, int dst_color) {
vga_state_set_base_palette_from_range(&pal, dst_index, src_index, 16 * 3);
}

void palette_set_player_expanded_color(int src_row, int dst_row) {
int dst_index = dst_row * 32;
int src_index = src_row * 16;
vga_palette tmp;
vga_color start = altpals->palettes[0].colors[src_index];
vga_color end = altpals->palettes[0].colors[src_index + 15];

// Slide the colors over 32 indexes
float r = (end.r - start.r) / 32.0;
float g = (end.g - start.g) / 32.0;
float b = (end.b - start.b) / 32.0;
for (int i = 0; i < 32; i++) {
tmp.colors[i].r = start.r + (int)(r * i);
tmp.colors[i].g = start.g + (int)(g * i);
tmp.colors[i].b = start.b + (int)(b * i);
}

vga_state_set_base_palette_from_range(&tmp, dst_index, 0, 32);
}

void palette_copy(vga_palette *dst, const vga_palette *src, int index_start, int index_count) {
memcpy(&dst->colors[index_start], &src->colors[index_start], index_count * 3);
}
2 changes: 1 addition & 1 deletion src/formats/palette.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ void palette_save_range(sd_writer *writer, const vga_palette *pal, int index_sta
void palette_save(sd_writer *writer, const vga_palette *pal);
void palette_remaps_save(sd_writer *writer, const vga_remap_tables *remaps);
void palette_load_player_colors(vga_palette *src, int player);
void palette_load_player_cutscene_colors(vga_palette *src);
void palette_load_altpal_player_color(vga_palette *dst, int player, int src_color, int dst_color);
void palette_set_player_color(int player, int src_color, int dst_color);
void palette_set_player_expanded_color(int src_row, int dst_row);
void palette_copy(vga_palette *dst, const vga_palette *src, int index_start, int index_count);

#endif // PALETTE_H
10 changes: 8 additions & 2 deletions src/game/scenes/cutscene.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,22 @@ int cutscene_create(scene *scene) {
case SCENE_NORTHAM:
case SCENE_KATUSHAI:
case SCENE_WAR:
// Load colors for the HAR -- note that cutscenes use an expanded HAR color slides.
// World championship does not use these.
palette_set_player_expanded_color(p1->chr->pilot.color_3, PRIMARY);
palette_set_player_expanded_color(p1->chr->pilot.color_2, SECONDARY);
palette_set_player_expanded_color(p1->chr->pilot.color_1, TERTIARY);

// Fall through!
case SCENE_WORLD:
audio_play_music(PSM_END);

palette_load_player_cutscene_colors(&p1->pilot->palette);

// load all the animations, in order
// including the one for our HAR
for(int i = 0; i < 256; i++) {
if(i >= 10 && i <= 20 && i != 10 + p1->pilot->har_id) {
continue;

}
bk_info *bki = bk_get_info(scene->bk_data, i);
if(bki) {
Expand Down
Loading