diff --git a/src/sys/ags.cpp b/src/sys/ags.cpp index 108185d..2287219 100644 --- a/src/sys/ags.cpp +++ b/src/sys/ags.cpp @@ -386,16 +386,16 @@ AGS::~AGS() // 退避領域の開放 for(int i = 0; i < 10; i++) { if(menu_w[i].screen) { - free(menu_w[i].screen); + SDL_FreeSurface(menu_w[i].screen); } if(menu_w[i].window) { - free(menu_w[i].window); + SDL_FreeSurface(menu_w[i].window); } if(text_w[i].screen) { - free(text_w[i].screen); + SDL_FreeSurface(text_w[i].screen); } if(text_w[i].window) { - free(text_w[i].window); + SDL_FreeSurface(text_w[i].window); } } diff --git a/src/sys/ags.h b/src/sys/ags.h index 23fc90e..a12bf17 100644 --- a/src/sys/ags.h +++ b/src/sys/ags.h @@ -181,17 +181,13 @@ public: int ey; bool frame; bool push; - uint8_t* screen; + SDL_Surface* screen; int screen_x; int screen_y; - int screen_width; - int screen_height; Palette screen_palette; - uint8_t* window; + SDL_Surface* window; int window_x; int window_y; - int window_width; - int window_height; Palette window_palette; } WINDOW; WINDOW menu_w[10]; diff --git a/src/sys/ags_window.cpp b/src/sys/ags_window.cpp index 19ac3bd..6b21779 100644 --- a/src/sys/ags_window.cpp +++ b/src/sys/ags_window.cpp @@ -85,23 +85,17 @@ void AGS::open_text_window(int index, bool erase) // 画面退避 if(text_w[index - 1].push) { if(text_w[index - 1].screen) { - free(text_w[index - 1].screen); + SDL_FreeSurface(text_w[index - 1].screen); } - text_w[index - 1].screen = (uint8_t*)malloc(width * height); + 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_width = width; - text_w[index - 1].screen_height = height; + text_w[index - 1].screen_palette = screen_palette; - for(int y = 0; y < height && y + sy < 480; y++) { - uint32_t* scr = surface_line(hBmpDest, y + sy) + sx; - for(int x = 0; x < width && x + sx < 640; x++) { - uint8_t col = vram[0][y + sy][x + sx]; - text_w[index - 1].screen_palette[col] = scr[x]; - text_w[index - 1].screen[x + width * y] = col; - } - } + SDL_Rect rect = {sx, sy, width, height}; + SDL_BlitSurface(hBmpScreen[0], &rect, text_w[index - 1].screen, NULL); } if(erase) { @@ -111,14 +105,11 @@ void AGS::open_text_window(int index, bool erase) // 窓復帰 sx = text_w[index - 1].window_x; sy = text_w[index - 1].window_y; - width = text_w[index - 1].window_width; - height = text_w[index - 1].window_height; + width = text_w[index - 1].window->w; + height = text_w[index - 1].window->h; - for(int y = 0; y < height && y + sy < 480; y++) { - for(int x = 0; x < width && x + sx < 640; x++) { - vram[0][y + sy][x + sx] = text_w[index - 1].window[x + width * y]; - } - } + 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; @@ -144,37 +135,28 @@ void AGS::close_text_window(int index, bool update) // 窓退避 if(text_w[index - 1].push) { if(text_w[index - 1].window) { - free(text_w[index - 1].window); + SDL_FreeSurface(text_w[index - 1].window); } - text_w[index - 1].window = (uint8_t*)malloc(width * height); + 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_width = width; - text_w[index - 1].window_height = height; + text_w[index - 1].window_palette = screen_palette; - for(int y = 0; y < height && y + sy < 480; y++) { - uint32* scr = surface_line(hBmpDest, y + sy) + sx; - for(int x = 0; x < width && x + sx < 640; x++) { - uint8_t col = vram[0][y + sy][x + sx]; - text_w[index - 1].window_palette[col] = scr[x]; - text_w[index - 1].window[x + width * y] = col; - } - } + SDL_Rect rect = {sx, sy, width, height}; + SDL_BlitSurface(hBmpScreen[0], &rect, text_w[index - 1].window, NULL); } // 画面復帰 if(text_w[index - 1].push && text_w[index - 1].screen) { sx = text_w[index - 1].screen_x; sy = text_w[index - 1].screen_y; - width = text_w[index - 1].screen_width; - height = text_w[index - 1].screen_height; + width = text_w[index - 1].screen->w; + height = text_w[index - 1].screen->h; - for(int y = 0; y < height && y + sy < 480; y++) { - for(int x = 0; x < width && x + sx < 640; x++) { - vram[0][y + sy][x + sx] = text_w[index - 1].screen[x + width * y]; - } - } + 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; @@ -214,23 +196,17 @@ void AGS::open_menu_window(int index) // 画面退避 if(menu_w[index - 1].push) { if(menu_w[index - 1].screen) { - free(menu_w[index - 1].screen); + SDL_FreeSurface(menu_w[index - 1].screen); } - menu_w[index - 1].screen = (uint8_t*)malloc(wwidth * wheight); + 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_width = wwidth; - menu_w[index - 1].screen_height = wheight; + menu_w[index - 1].screen_palette = screen_palette; - for(int y = 0; y < wheight && y + wsy < 480; y++) { - uint32* scr = surface_line(hBmpDest, y + wsy) + wsx; - for(int x = 0; x < wwidth && x + wsx < 640; x++) { - uint8_t col = vram[0][y + wsy][x + wsx]; - menu_w[index - 1].screen_palette[col] = scr[x]; - menu_w[index - 1].screen[x + wwidth * y] = col; - } - } + SDL_Rect rect = {wsx, wsy, wwidth, wheight}; + SDL_BlitSurface(hBmpScreen[0], &rect, menu_w[index - 1].screen, NULL); } // メニュー表示 @@ -268,14 +244,11 @@ void AGS::close_menu_window(int index) if(menu_w[index - 1].push && menu_w[index - 1].screen) { int sx = menu_w[index - 1].screen_x; int sy = menu_w[index - 1].screen_y; - int width = menu_w[index - 1].screen_width; - int height = menu_w[index - 1].screen_height; + int width = menu_w[index - 1].screen->w; + int height = menu_w[index - 1].screen->h; - for(int y = 0; y < height && y + sy < 480; y++) { - for(int x = 0; x < width && x + sx < 640; x++) { - vram[0][y + sy][x + sx] = menu_w[index - 1].screen[x + width * y]; - } - } + 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; diff --git a/src/sys/nact.cpp b/src/sys/nact.cpp index 64a1b83..3c35e1d 100644 --- a/src/sys/nact.cpp +++ b/src/sys/nact.cpp @@ -585,11 +585,11 @@ bool NACT::load(int index) fio->getw(); if (ags->menu_w[i].screen) { - free(ags->menu_w[i].screen); + SDL_FreeSurface(ags->menu_w[i].screen); } ags->menu_w[i].screen = NULL; if (ags->menu_w[i].window) { - free(ags->menu_w[i].window); + SDL_FreeSurface(ags->menu_w[i].window); } ags->menu_w[i].window = NULL; } @@ -604,11 +604,11 @@ bool NACT::load(int index) fio->getw(); if (ags->text_w[i].screen) { - free(ags->text_w[i].screen); + SDL_FreeSurface(ags->text_w[i].screen); } ags->text_w[i].screen = NULL; if (ags->text_w[i].window) { - free(ags->text_w[i].window); + SDL_FreeSurface(ags->text_w[i].window); } ags->text_w[i].window = NULL; } diff --git a/src/sys/nact_sys2.cpp b/src/sys/nact_sys2.cpp index 769b91c..a9c9d68 100644 --- a/src/sys/nact_sys2.cpp +++ b/src/sys/nact_sys2.cpp @@ -366,7 +366,7 @@ void NACT_Sys2::cmd_b() // 退避画面の破棄 if(ags->menu_w[index - 1].screen) { - free(ags->menu_w[index - 1].screen); + SDL_FreeSurface(ags->menu_w[index - 1].screen); ags->menu_w[index - 1].screen = NULL; } break; @@ -389,12 +389,12 @@ void NACT_Sys2::cmd_b() // 退避画面の破棄 if(ags->text_w[index - 1].screen) { - free(ags->text_w[index - 1].screen); + SDL_FreeSurface(ags->text_w[index - 1].screen); ags->text_w[index - 1].screen = NULL; } // 退避窓の破棄 if(ags->text_w[index - 1].window) { - free(ags->text_w[index - 1].window); + SDL_FreeSurface(ags->text_w[index - 1].window); ags->text_w[index - 1].window = NULL; } break; diff --git a/src/sys/nact_sys3.cpp b/src/sys/nact_sys3.cpp index 366c64c..8d47586 100644 --- a/src/sys/nact_sys3.cpp +++ b/src/sys/nact_sys3.cpp @@ -263,7 +263,7 @@ void NACT_Sys3::cmd_b() // 退避画面の破棄 if(ags->menu_w[index - 1].screen) { - free(ags->menu_w[index - 1].screen); + SDL_FreeSurface(ags->menu_w[index - 1].screen); ags->menu_w[index - 1].screen = NULL; } break; @@ -280,12 +280,12 @@ void NACT_Sys3::cmd_b() // 退避画面の破棄 if(ags->text_w[index - 1].screen) { - free(ags->text_w[index - 1].screen); + SDL_FreeSurface(ags->text_w[index - 1].screen); ags->text_w[index - 1].screen = NULL; } // 退避窓の破棄 if(ags->text_w[index - 1].window) { - free(ags->text_w[index - 1].window); + SDL_FreeSurface(ags->text_w[index - 1].window); ags->text_w[index - 1].window = NULL; } break; @@ -295,7 +295,7 @@ void NACT_Sys3::cmd_b() if (game_id.is(GameId::PROG_CD) && p4) { // prostudent G オープニング画面化け対策 if(ags->text_w[index - 1].window) { - free(ags->text_w[index - 1].window); + SDL_FreeSurface(ags->text_w[index - 1].window); ags->text_w[index - 1].window = NULL; } }