diff --git a/src/sys/ags.cpp b/src/sys/ags.cpp index 2287219..fa8a1e1 100644 --- a/src/sys/ags.cpp +++ b/src/sys/ags.cpp @@ -81,11 +81,6 @@ AGS::AGS(const Config& config, const GameId& game_id) : game_id(game_id), dirty( for(int i = 0; i < 3; i++) { hBmpScreen[i] = SDL_CreateRGBSurfaceWithFormat(0, 640, 480, 8, SDL_PIXELFORMAT_INDEX8); - // all surfaces share the same palette - if (i > 0) { - SDL_SetSurfacePalette(hBmpScreen[i], hBmpScreen[0]->format->palette); - } - // TODO: clear surface // memset(lpBmpScreen[i], 0, 640 * 480 * sizeof(DWORD)); @@ -95,6 +90,11 @@ AGS::AGS(const Config& config, const GameId& game_id) : game_id(game_id), dirty( } } + // All surfaces share the same palette. + screen_palette = hBmpScreen[0]->format->palette; + SDL_SetSurfacePalette(hBmpScreen[1], screen_palette); + SDL_SetSurfacePalette(hBmpScreen[2], screen_palette); + // DIBSection 24bpp * 1 (最終出力先) display_surface = hBmpDest = SDL_CreateRGBSurface(0, 640, 480, 32, 0, 0, 0, 0); // TODO: clear surface @@ -153,54 +153,54 @@ AGS::AGS(const Config& config, const GameId& game_id) : game_id(game_id), dirty( acg.open("ACG.DAT"); // パレット - program_palette = {0}; - program_palette[0x00] = SETPALETTE16(0x0, 0x0, 0x0); - program_palette[0x01] = SETPALETTE16(0x0, 0x0, 0xa); - program_palette[0x02] = SETPALETTE16(0xa, 0x0, 0x0); - program_palette[0x03] = SETPALETTE16(0xa, 0x0, 0xa); - program_palette[0x04] = SETPALETTE16(0x0, 0x0, 0x0); - program_palette[0x05] = SETPALETTE16(0x0, 0xa, 0xa); - program_palette[0x06] = SETPALETTE16(0xa, 0xa, 0x0); - program_palette[0x07] = SETPALETTE16(0xd, 0xd, 0xd); - program_palette[0x08] = SETPALETTE16(0x7, 0x7, 0x7); - program_palette[0x09] = SETPALETTE16(0x0, 0x0, 0xf); - program_palette[0x0a] = SETPALETTE16(0xf, 0x0, 0x0); - program_palette[0x0b] = SETPALETTE16(0xf, 0x0, 0xf); - program_palette[0x0c] = SETPALETTE16(0x0, 0xf, 0x0); - program_palette[0x0d] = SETPALETTE16(0x0, 0xf, 0xf); - program_palette[0x0e] = SETPALETTE16(0xf, 0xf, 0x0); - program_palette[0x0f] = SETPALETTE16(0xf, 0xf, 0xf); + program_palette = SDL_AllocPalette(256); + program_palette->colors[0x00] = {0x00, 0x00, 0x00, 0xff}; + program_palette->colors[0x01] = {0x00, 0x00, 0xaa, 0xff}; + program_palette->colors[0x02] = {0xaa, 0x00, 0x00, 0xff}; + program_palette->colors[0x03] = {0xaa, 0x00, 0xaa, 0xff}; + program_palette->colors[0x04] = {0x00, 0x00, 0x00, 0xff}; + program_palette->colors[0x05] = {0x00, 0xaa, 0xaa, 0xff}; + program_palette->colors[0x06] = {0xaa, 0xaa, 0x00, 0xff}; + program_palette->colors[0x07] = {0xdd, 0xdd, 0xdd, 0xff}; + program_palette->colors[0x08] = {0x77, 0x77, 0x77, 0xff}; + program_palette->colors[0x09] = {0x00, 0x00, 0xff, 0xff}; + program_palette->colors[0x0a] = {0xff, 0x00, 0x00, 0xff}; + program_palette->colors[0x0b] = {0xff, 0x00, 0xff, 0xff}; + program_palette->colors[0x0c] = {0x00, 0xff, 0x00, 0xff}; + program_palette->colors[0x0d] = {0x00, 0xff, 0xff, 0xff}; + program_palette->colors[0x0e] = {0xff, 0xff, 0x00, 0xff}; + program_palette->colors[0x0f] = {0xff, 0xff, 0xff, 0xff}; if (game_id.sys_ver == 1) { - program_palette[0x10] = SETPALETTE16(0x0, 0x0, 0x0); - program_palette[0x11] = SETPALETTE16(0x0, 0x0, 0xf); - program_palette[0x12] = SETPALETTE16(0xf, 0x0, 0x0); - program_palette[0x13] = SETPALETTE16(0xf, 0x0, 0xf); - program_palette[0x14] = SETPALETTE16(0x0, 0xf, 0x0); - program_palette[0x15] = SETPALETTE16(0x0, 0xf, 0xf); - program_palette[0x16] = SETPALETTE16(0xf, 0xf, 0x0); - program_palette[0x17] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x18] = SETPALETTE16(0x0, 0x0, 0x0); - program_palette[0x19] = SETPALETTE16(0x0, 0x0, 0xf); - program_palette[0x1a] = SETPALETTE16(0xf, 0x0, 0x0); - program_palette[0x1b] = SETPALETTE16(0xf, 0x0, 0xf); - program_palette[0x1c] = SETPALETTE16(0x0, 0xf, 0x0); - program_palette[0x1d] = SETPALETTE16(0x0, 0xf, 0xf); - program_palette[0x1e] = SETPALETTE16(0xf, 0xf, 0x0); + program_palette->colors[0x10] = {0x00, 0x00, 0x00, 0xff}; + program_palette->colors[0x11] = {0x00, 0x00, 0xff, 0xff}; + program_palette->colors[0x12] = {0xff, 0x00, 0x00, 0xff}; + program_palette->colors[0x13] = {0xff, 0x00, 0xff, 0xff}; + program_palette->colors[0x14] = {0x00, 0xff, 0x00, 0xff}; + program_palette->colors[0x15] = {0x00, 0xff, 0xff, 0xff}; + program_palette->colors[0x16] = {0xff, 0xff, 0x00, 0xff}; + program_palette->colors[0x17] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x18] = {0x00, 0x00, 0x00, 0xff}; + program_palette->colors[0x19] = {0x00, 0x00, 0xff, 0xff}; + program_palette->colors[0x1a] = {0xff, 0x00, 0x00, 0xff}; + program_palette->colors[0x1b] = {0xff, 0x00, 0xff, 0xff}; + program_palette->colors[0x1c] = {0x00, 0xff, 0x00, 0xff}; + program_palette->colors[0x1d] = {0x00, 0xff, 0xff, 0xff}; + program_palette->colors[0x1e] = {0xff, 0xff, 0x00, 0xff}; } - program_palette[0x1f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x2f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x3f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x4f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x5f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x6f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x7f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x8f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0x9f] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0xaf] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0xbf] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0xcf] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0xdf] = SETPALETTE16(0xf, 0xf, 0xf); - program_palette[0xef] = SETPALETTE16(0xf, 0xf, 0xf); + program_palette->colors[0x1f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x2f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x3f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x4f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x5f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x6f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x7f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x8f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0x9f] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0xaf] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0xbf] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0xcf] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0xdf] = {0xff, 0xff, 0xff, 0xff}; + program_palette->colors[0xef] = {0xff, 0xff, 0xff, 0xff}; // To improve the quality of text antialiasing, preset the antialiasing // colors for text drawn in the primary colors (red, green, blue, yellow, @@ -208,14 +208,14 @@ AGS::AGS(const Config& config, const GameId& game_id) : game_id(game_id), dirty( for (int i = 1; i <= 7; i++) { for (int j = 0; j <= 7; j++) { int n = 255 * j / 7; - int r = (i & 4) ? n : 0; - int g = (i & 2) ? n : 0; - int b = (i & 1) ? n : 0; - program_palette[0xc0 + i * 8 + j] = SETPALETTE16(r, g, b); + uint8_t r = (i & 4) ? n : 0; + uint8_t g = (i & 2) ? n : 0; + uint8_t b = (i & 1) ? n : 0; + program_palette->colors[0xc0 + i * 8 + j] = {r, g, b, 255}; } } - screen_palette = program_palette; + SDL_SetPaletteColors(screen_palette, program_palette->colors, 0, 256); // Bコマンド for(int i = 0; i < 10; i++) { @@ -416,7 +416,8 @@ AGS::~AGS() SDL_RWclose(rw_font); } - // surface開放 + SDL_FreePalette(program_palette); + for(int i = 0; i < 3; i++) { SDL_FreeSurface(hBmpScreen[i]); } @@ -442,13 +443,25 @@ void AGS::set_cg_file(const char *file_name) acg.open(file_name); } -void AGS::set_palette(int index, int r, int g, int b) +void AGS::set_palette(int index, uint8_t r, uint8_t g, uint8_t b) { - if(index < 16) { - screen_palette[index] = program_palette[index] = SETPALETTE16(r, g, b); - } else { - screen_palette[index] = program_palette[index] = SETPALETTE256(r, g, b); + SDL_Color color = {r, g, b, 255}; + if (index < 16) { + color.r = (color.r & 0xf) * 0x11; + color.g = (color.g & 0xf) * 0x11; + color.b = (color.b & 0xf) * 0x11; } + SDL_SetPaletteColors(screen_palette, &color, index, 1); + SDL_SetPaletteColors(program_palette, &color, index, 1); +} + +std::vector AGS::get_screen_palette() const +{ + std::vector palette(256); + for (int i = 0; i < 256; i++) { + palette[i] = palR(i) << 16 | palG(i) << 8 | palB(i); + } + return palette; } uint8 AGS::get_pixel(int dest, int x, int y) @@ -496,13 +509,8 @@ void AGS::fade_in(int duration_ms) void AGS::flush_screen(bool update) { if(update) { - for(int y = 0; y < screen_height; y++) { - uint8_t* src = vram[0][y]; - uint32* dest = surface_line(hBmpDest, y); - for(int x = 0; x < screen_width; x++) { - dest[x] = screen_palette[src[x]]; - } - } + SDL_Rect rect = {0, 0, screen_width, screen_height}; + SDL_BlitSurface(hBmpScreen[0], &rect, hBmpDest, &rect); } invalidate_screen(0, 0, screen_width, screen_height); } @@ -510,18 +518,8 @@ void AGS::flush_screen(bool update) void AGS::draw_screen(int sx, int sy, int width, int height) { SDL_Rect rect = {sx, sy, width, height}; - SDL_Rect screen = {0, 0, screen_width, screen_height}; - SDL_Rect clip; - SDL_IntersectRect(&rect, &screen, &clip); - - for (int y = clip.y; y < clip.y + clip.h; y++) { - uint8_t* src = vram[0][y]; - uint32* dest = surface_line(hBmpDest, y); - for(int x = clip.x; x < clip.x + clip.w; x++) { - dest[x] = screen_palette[src[x]]; - } - } - invalidate_screen(clip.x, clip.y, clip.w, clip.h); + SDL_BlitSurface(hBmpScreen[0], &rect, hBmpDest, &rect); + invalidate_screen(sx, sy, width, height); } void AGS::invalidate_screen(int sx, int sy, int width, int height) diff --git a/src/sys/ags.h b/src/sys/ags.h index a12bf17..025c017 100644 --- a/src/sys/ags.h +++ b/src/sys/ags.h @@ -7,7 +7,7 @@ #ifndef _AGS_H_ #define _AGS_H_ -#include +#include #include #include #include "../common.h" @@ -17,21 +17,6 @@ #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); -} - -static inline uint32 SETPALETTE16(uint32 R, uint32 G, uint32 B) -{ - R = (255 * (R & 0x0f)) / 15; - G = (255 * (G & 0x0f)) / 15; - B = (255 * (B & 0x0f)) / 15; - return SETPALETTE256(R, G, B); -} - inline uint32* surface_line(SDL_Surface* surface, int y) { return (uint32*)((uint8*)surface->pixels + surface->pitch * y); @@ -77,15 +62,15 @@ private: void draw_screen(int sx, int sy, int width, int heignt); void invalidate_screen(int sx, int sy, int width, int height); - uint8 palR(uint8 col) { return screen_palette[col] >> 16 & 0xff; } - uint8 palG(uint8 col) { return screen_palette[col] >> 8 & 0xff; } - uint8 palB(uint8 col) { return screen_palette[col] & 0xff; } + uint8_t palR(uint8_t col) const { return screen_palette->colors[col].r; } + uint8_t palG(uint8_t col) const { return screen_palette->colors[col].g; } + uint8_t palB(uint8_t col) const { return screen_palette->colors[col].b; } int nearest_color(int r, int g, int b); uint8_t* vram[3][480]; // 仮想VRAMへのポインタ - Palette program_palette; - Palette screen_palette; + SDL_Palette* program_palette; + SDL_Palette* screen_palette; uint8 gaiji[188][32]; int fade_level = 0; // 0-255 @@ -102,8 +87,8 @@ public: void load_cg(int page, int transparent); void set_cg_file(const char *file_name); - void set_palette(int index, int r, int g, int b); - const Palette& get_screen_palette() const { return screen_palette; } + void set_palette(int index, uint8_t r, uint8_t g, uint8_t b); + std::vector get_screen_palette() const; uint8 get_pixel(int dest, int x, int y); void set_pixel(int dest, int x, int y, uint8 color); @@ -184,11 +169,9 @@ public: SDL_Surface* screen; int screen_x; int screen_y; - Palette screen_palette; SDL_Surface* window; int window_x; int window_y; - Palette window_palette; } WINDOW; WINDOW menu_w[10]; WINDOW text_w[10]; diff --git a/src/sys/ags_gl3.cpp b/src/sys/ags_gl3.cpp index 05444c4..15bd092 100644 --- a/src/sys/ags_gl3.cpp +++ b/src/sys/ags_gl3.cpp @@ -31,19 +31,19 @@ void AGS::load_gl3(uint8* data, int page, int transparent) // パレット取得 if(get_palette) { + SDL_Color colors[16]; for(int i = 0; i < 16; i++) { - uint32 b = data[i * 3 + 0]; - uint32 r = data[i * 3 + 1]; - uint32 g = data[i * 3 + 2]; - program_palette[base + i] = SETPALETTE16(r, g, b); + uint8_t b = (data[i * 3 + 0] & 0xf) * 0x11; + uint8_t r = (data[i * 3 + 1] & 0xf) * 0x11; + uint8_t g = (data[i * 3 + 2] & 0xf) * 0x11; + colors[i] = {r, g, b, 255}; } + SDL_SetPaletteColors(program_palette, colors, base, 16); } // パレット展開 if(extract_palette && extract_palette_cg[page]) { - for(int i = 0; i < 16; i++) { - screen_palette[base + i] = program_palette[base + i]; - } + SDL_SetPaletteColors(screen_palette, program_palette->colors + base, base, 16); } // GL3展開 diff --git a/src/sys/ags_gm3.cpp b/src/sys/ags_gm3.cpp index 1ae2317..c0fe065 100644 --- a/src/sys/ags_gm3.cpp +++ b/src/sys/ags_gm3.cpp @@ -29,25 +29,6 @@ void AGS::load_gm3(uint8* data, int page, int transparent) base = (palette_bank & 0x0f) << 4; } -/* - // パレット取得 - if(get_palette) { - for(int i = 0; i < 16; i++) { - uint32 b = data[i * 3 + 0] & 0xf; - uint32 r = data[i * 3 + 1] & 0xf; - uint32 g = data[i * 3 + 2] & 0xf; - program_palette[base + i] = SETPALETTE16(r, g, b); - } - } - - // パレット展開 - if(extract_palette && extract_palette_cg[page]) { - for(int i = 0; i < 16; i++) { - screen_palette[base + i] = program_palette[base + i]; - } - } -*/ - // GM3展開 uint8 cgdata[3][80][3]; int p = 0x36; diff --git a/src/sys/ags_pms.cpp b/src/sys/ags_pms.cpp index aadae9d..88e336f 100644 --- a/src/sys/ags_pms.cpp +++ b/src/sys/ags_pms.cpp @@ -28,43 +28,35 @@ void AGS::load_pms(uint8* data, int page, int transparent) set_cg_dest = false; } - // パレット取得 - uint32 tmp_palette[256]; - if(get_palette) { + SDL_Color colors[256]; int p = 0x20; for(int i = 0; i < 16; i++) { for(int j = 0; j < 16; j++) { - uint32 r = data[p++]; - uint32 g = data[p++]; - uint32 b = data[p++]; - tmp_palette[i * 16 + j] = SETPALETTE256(r, g, b); + uint8_t r = data[p++]; + uint8_t g = data[p++]; + uint8_t b = data[p++]; + colors[i * 16 + j] = {r, g, b, 255}; } } if (game_id.is_rance4x() || game_id.is(GameId::HASHIRIONNA2)) { // 上下16色は取得しない for(int i = 1; i < 15; i++) { - for(int j = 0; j < 16; j++) { - if(!(mask & (0x01 << i))) { - program_palette[i * 16 + j] = tmp_palette[i * 16 + j]; - } + if (!(mask & 1 << i)) { + SDL_SetPaletteColors(program_palette, colors + i * 16, i * 16, 16); } } } else if (game_id.is(GameId::MUGEN) && transparent != -1) { // Uコマンドでは上下32色は取得しない for(int i = 2; i < 14; i++) { - for(int j = 0; j < 16; j++) { - if(!(mask & (0x01 << i))) { - program_palette[i * 16 + j] = tmp_palette[i * 16 + j]; - } + if (!(mask & 1 << i)) { + SDL_SetPaletteColors(program_palette, colors + i * 16, i * 16, 16); } } } else { for(int i = 0; i < 16; i++) { - for(int j = 0; j < 16; j++) { - if(!(mask & (0x01 << i))) { - program_palette[i * 16 + j] = tmp_palette[i * 16 + j]; - } + if (!(mask & 1 << i)) { + SDL_SetPaletteColors(program_palette, colors + i * 16, i * 16, 16); } } } @@ -76,37 +68,29 @@ void AGS::load_pms(uint8* data, int page, int transparent) if (game_id.is_rance4x() || game_id.is(GameId::HASHIRIONNA2)) { // 上下16色は展開しない for(int i = 1; i < 15; i++) { - for(int j = 0; j < 16; j++) { - if(!(mask & (0x01 << i))) { - screen_palette[i * 16 + j] = program_palette[i * 16 + j]; - } + if (!(mask & 1 << i)) { + SDL_SetPaletteColors(screen_palette, program_palette->colors + i * 16, i * 16, 16); } } } else if (game_id.is(GameId::MUGEN) && transparent != -1) { // Uコマンドでは上下32色は展開しない for(int i = 2; i < 14; i++) { - for(int j = 0; j < 16; j++) { - if(!(mask & (0x01 << i))) { - screen_palette[i * 16 + j] = program_palette[i * 16 + j]; - } + if (!(mask & 1 << i)) { + SDL_SetPaletteColors(screen_palette, program_palette->colors + i * 16, i * 16, 16); } } } else { for(int i = 0; i < 16; i++) { - for(int j = 0; j < 16; j++) { - if(!(mask & (0x01 << i))) { - screen_palette[i * 16 + j] = program_palette[i * 16 + j]; - } + if (!(mask & 1 << i)) { + SDL_SetPaletteColors(screen_palette, program_palette->colors + i * 16, i * 16, 16); } } } } } else if(extract_palette && extract_palette_cg[page]) { for(int i = 0; i < 16; i++) { - for(int j = 0; j < 16; j++) { - if(!(mask & (0x01 << i))) { - screen_palette[i * 16 + j] = program_palette[i * 16 + j]; - } + if (!(mask & 1 << i)) { + SDL_SetPaletteColors(screen_palette, program_palette->colors + i * 16, i * 16, 16); } } } diff --git a/src/sys/ags_vsp.cpp b/src/sys/ags_vsp.cpp index 29a4cd2..818876c 100644 --- a/src/sys/ags_vsp.cpp +++ b/src/sys/ags_vsp.cpp @@ -40,26 +40,24 @@ void AGS::load_vsp(uint8* data, int page, int transparent) // パレット取得 if(get_palette && transparent != 101) { int p = 0x0a; + SDL_Color colors[16]; for(int i = 0; i < 16; i++) { - uint32 b = data[p++] & 0xf; - uint32 r = data[p++] & 0xf; - uint32 g = data[p++] & 0xf; - program_palette[base + i] = SETPALETTE16(r, g, b); + uint8_t b = (data[p++] & 0xf) * 0x11; + uint8_t r = (data[p++] & 0xf) * 0x11; + uint8_t g = (data[p++] & 0xf) * 0x11; + colors[i] = {r, g, b, 255}; } + SDL_SetPaletteColors(program_palette, colors, base, 16); } // パレット展開 if (game_id.is(GameId::FUNNYBEE_FD) || game_id.is(GameId::FUNNYBEE_CD)) { if(extract_palette_cg[page]) { - for(int i = 0; i < 16; i++) { - screen_palette[base + i] = program_palette[base + i]; - } + SDL_SetPaletteColors(screen_palette, program_palette->colors + base, base, 16); } } else { if(extract_palette && extract_palette_cg[page]) { - for(int i = 0; i < 16; i++) { - screen_palette[base + i] = program_palette[base + i]; - } + SDL_SetPaletteColors(screen_palette, program_palette->colors + base, base, 16); } } diff --git a/src/sys/ags_vsp2l.cpp b/src/sys/ags_vsp2l.cpp index 5ad34cd..de0a5d1 100644 --- a/src/sys/ags_vsp2l.cpp +++ b/src/sys/ags_vsp2l.cpp @@ -33,14 +33,17 @@ void AGS::load_vsp2l(uint8* data, int page, int transparent) } // パレット取得 - screen_palette[base + 0] = SETPALETTE16(0x0, 0x0, 0x0); - screen_palette[base + 1] = SETPALETTE16(0x0, 0x0, 0xf); - screen_palette[base + 2] = SETPALETTE16(0xf, 0x0, 0x0); - screen_palette[base + 3] = SETPALETTE16(0xf, 0x0, 0xf); - screen_palette[base + 4] = SETPALETTE16(0x0, 0xf, 0x0); - screen_palette[base + 5] = SETPALETTE16(0x0, 0xf, 0xf); - screen_palette[base + 6] = SETPALETTE16(0xf, 0xf, 0x0); - screen_palette[base + 7] = SETPALETTE16(0xf, 0xf, 0xf); + const SDL_Color colors[8] = { + {0x00, 0x00, 0x00, 0xff}, + {0x00, 0x00, 0xff, 0xff}, + {0xff, 0x00, 0x00, 0xff}, + {0xff, 0x00, 0xff, 0xff}, + {0x00, 0xff, 0x00, 0xff}, + {0x00, 0xff, 0xff, 0xff}, + {0xff, 0xff, 0x00, 0xff}, + {0xff, 0xff, 0xff, 0xff} + }; + SDL_SetPaletteColors(screen_palette, colors, base, 8); // VSP2L展開 uint8 cgdata[3][2][200], mask = 0; diff --git a/src/sys/ags_window.cpp b/src/sys/ags_window.cpp index 1b7494c..236d821 100644 --- a/src/sys/ags_window.cpp +++ b/src/sys/ags_window.cpp @@ -89,10 +89,9 @@ void AGS::open_text_window(int index, bool erase) } text_w[index - 1].screen = SDL_CreateRGBSurfaceWithFormat(0, width, height, 8, SDL_PIXELFORMAT_INDEX8); - SDL_SetSurfacePalette(text_w[index - 1].screen, hBmpScreen[0]->format->palette); text_w[index - 1].screen_x = sx; text_w[index - 1].screen_y = sy; - text_w[index - 1].screen_palette = screen_palette; + SDL_SetPaletteColors(text_w[index - 1].screen->format->palette, screen_palette->colors, 0, 256); SDL_Rect rect = {sx, sy, width, height}; SDL_BlitSurface(hBmpScreen[0], &rect, text_w[index - 1].screen, NULL); @@ -108,13 +107,11 @@ void AGS::open_text_window(int index, bool erase) width = text_w[index - 1].window->w; height = text_w[index - 1].window->h; + SDL_SetSurfacePalette(hBmpScreen[0], text_w[index - 1].window->format->palette); SDL_Rect rect = {sx, sy, width, height}; SDL_BlitSurface(text_w[index - 1].window, NULL, hBmpScreen[0], &rect); - - Palette palette = screen_palette; - screen_palette = text_w[index - 1].window_palette; draw_screen(sx, sy, width, height); - screen_palette = palette; + SDL_SetSurfacePalette(hBmpScreen[0], screen_palette); } // テキスト描画位置更新 @@ -139,10 +136,9 @@ void AGS::close_text_window(int index, bool update) } text_w[index - 1].window = SDL_CreateRGBSurfaceWithFormat(0, width, height, 8, SDL_PIXELFORMAT_INDEX8); - SDL_SetSurfacePalette(text_w[index - 1].window, hBmpScreen[0]->format->palette); text_w[index - 1].window_x = sx; text_w[index - 1].window_y = sy; - text_w[index - 1].window_palette = screen_palette; + SDL_SetPaletteColors(text_w[index - 1].window->format->palette, screen_palette->colors, 0, 256); SDL_Rect rect = {sx, sy, width, height}; SDL_BlitSurface(hBmpScreen[0], &rect, text_w[index - 1].window, NULL); @@ -155,13 +151,11 @@ void AGS::close_text_window(int index, bool update) width = text_w[index - 1].screen->w; height = text_w[index - 1].screen->h; + SDL_SetSurfacePalette(hBmpScreen[0], text_w[index - 1].screen->format->palette); SDL_Rect rect = {sx, sy, width, height}; SDL_BlitSurface(text_w[index - 1].screen, NULL, hBmpScreen[0], &rect); - - Palette palette = screen_palette; - screen_palette = text_w[index - 1].screen_palette; draw_screen(sx, sy, width, height); - screen_palette = palette; + SDL_SetSurfacePalette(hBmpScreen[0], screen_palette); } // テキスト描画位置更新 @@ -200,10 +194,9 @@ void AGS::open_menu_window(int index) } menu_w[index - 1].screen = SDL_CreateRGBSurfaceWithFormat(0, wwidth, wheight, 8, SDL_PIXELFORMAT_INDEX8); - SDL_SetSurfacePalette(menu_w[index - 1].screen, hBmpScreen[0]->format->palette); menu_w[index - 1].screen_x = wsx; menu_w[index - 1].screen_y = wsy; - menu_w[index - 1].screen_palette = screen_palette; + SDL_SetPaletteColors(menu_w[index - 1].screen->format->palette, screen_palette->colors, 0, 256); SDL_Rect rect = {wsx, wsy, wwidth, wheight}; SDL_BlitSurface(hBmpScreen[0], &rect, menu_w[index - 1].screen, NULL); @@ -243,13 +236,11 @@ void AGS::close_menu_window(int index) int width = menu_w[index - 1].screen->w; int height = menu_w[index - 1].screen->h; + SDL_SetSurfacePalette(hBmpScreen[0], menu_w[index - 1].screen->format->palette); SDL_Rect rect = {sx, sy, width, height}; SDL_BlitSurface(menu_w[index - 1].screen, NULL, hBmpScreen[0], &rect); - - Palette palette = screen_palette; - screen_palette = menu_w[index - 1].screen_palette; draw_screen(sx, sy, width, height); - screen_palette = palette; + SDL_SetSurfacePalette(hBmpScreen[0], screen_palette); } }