From daeef22a29a466eaa4244ab4b2fbdc926ef1b041 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 21 Dec 2024 09:35:09 +0900 Subject: [PATCH] AGS: Introduce Palette type --- src/sys/ags.cpp | 4 ++-- src/sys/ags.h | 11 +++++++---- src/sys/ags_window.cpp | 21 +++++++++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/sys/ags.cpp b/src/sys/ags.cpp index 276e7d8..b9afe3c 100644 --- a/src/sys/ags.cpp +++ b/src/sys/ags.cpp @@ -162,7 +162,7 @@ AGS::AGS(const Config& config, const GameId& game_id) : game_id(game_id), dirty( acg.open("ACG.DAT"); // パレット - memset(program_palette, 0, sizeof(program_palette)); + program_palette = {0}; program_palette[0x00] = SETPALETTE16(0x0, 0x0, 0x0); program_palette[0x01] = SETPALETTE16(0x0, 0x0, 0xa); program_palette[0x02] = SETPALETTE16(0xa, 0x0, 0x0); @@ -224,7 +224,7 @@ AGS::AGS(const Config& config, const GameId& game_id) : game_id(game_id), dirty( } } - memcpy(screen_palette, program_palette, sizeof(program_palette)); + screen_palette = program_palette; // Bコマンド for(int i = 0; i < 10; i++) { diff --git a/src/sys/ags.h b/src/sys/ags.h index 7f9fa87..2ebf718 100644 --- a/src/sys/ags.h +++ b/src/sys/ags.h @@ -7,6 +7,7 @@ #ifndef _AGS_H_ #define _AGS_H_ +#include #include #include #include "../common.h" @@ -16,6 +17,8 @@ #define MAX_CG 10000 +using Palette = std::array; + static inline uint32 SETPALETTE256(uint32 R, uint32 G, uint32 B) { return ((R & 0xff) << 16) | ((G & 0xff) << 8) | (B & 0xff); @@ -81,8 +84,8 @@ private: uint32* vram[3][480]; // 仮想VRAMへのポインタ - uint32 program_palette[256]; - uint32 screen_palette[256]; + Palette program_palette; + Palette screen_palette; uint8 gaiji[188][32]; int fade_level = 0; // 0-255 @@ -182,13 +185,13 @@ public: int screen_y; int screen_width; int screen_height; - uint32 screen_palette[256]; + Palette screen_palette; uint32* window; int window_x; int window_y; int window_width; int window_height; - uint32 window_palette[256]; + Palette window_palette; } WINDOW; WINDOW menu_w[10]; WINDOW text_w[10]; diff --git a/src/sys/ags_window.cpp b/src/sys/ags_window.cpp index 9262ab3..98c8437 100644 --- a/src/sys/ags_window.cpp +++ b/src/sys/ags_window.cpp @@ -122,11 +122,10 @@ void AGS::open_text_window(int index, bool erase) } } - uint32 palette[256]; - memcpy(palette, screen_palette, sizeof(screen_palette)); - memcpy(screen_palette, text_w[index - 1].window_palette, sizeof(screen_palette)); + Palette palette = screen_palette; + screen_palette = text_w[index - 1].window_palette; draw_screen(sx, sy, width, height); - memcpy(screen_palette, palette, sizeof(screen_palette)); + screen_palette = palette; } // テキスト描画位置更新 @@ -181,11 +180,10 @@ void AGS::close_text_window(int index, bool update) } } - uint32 palette[256]; - memcpy(palette, screen_palette, sizeof(screen_palette)); - memcpy(screen_palette, text_w[index - 1].screen_palette, sizeof(screen_palette)); + Palette palette = screen_palette; + screen_palette = text_w[index - 1].screen_palette; draw_screen(sx, sy, width, height); - memcpy(screen_palette, palette, sizeof(screen_palette)); + screen_palette = palette; } // テキスト描画位置更新 @@ -285,11 +283,10 @@ void AGS::close_menu_window(int index) } } - uint32 palette[256]; - memcpy(palette, screen_palette, sizeof(screen_palette)); - memcpy(screen_palette, menu_w[index - 1].screen_palette, sizeof(screen_palette)); + Palette palette = screen_palette; + screen_palette = menu_w[index - 1].screen_palette; draw_screen(sx, sy, width, height); - memcpy(screen_palette, palette, sizeof(screen_palette)); + screen_palette = palette; } }