diff --git a/src/formats/palette.c b/src/formats/palette.c index 6c2a888b6..c2c12142a 100644 --- a/src/formats/palette.c +++ b/src/formats/palette.c @@ -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; @@ -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); } diff --git a/src/formats/palette.h b/src/formats/palette.h index ef3ecb18f..bde049553 100644 --- a/src/formats/palette.h +++ b/src/formats/palette.h @@ -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 diff --git a/src/game/scenes/cutscene.c b/src/game/scenes/cutscene.c index f1c3f625e..188c4ef12 100644 --- a/src/game/scenes/cutscene.c +++ b/src/game/scenes/cutscene.c @@ -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) {