From e45aee492d6976ae8625bcc7b6322e149dcd1abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Luis=20Rodr=C3=ADguez=20Gonz=C3=A1lez?= Date: Tue, 27 Jul 2021 09:12:04 +0200 Subject: [PATCH] Restore code for missing libraries and calls to SDL_QuitSubsystem --- Makefile.dingux | 1 + src/sdl-dingux/gui_main.cpp | 44 +++++++++++------------ src/sdl-dingux/sdl_menu.cpp | 67 ++++++++++++++++++------------------ src/sdl-dingux/sdl_video.cpp | 3 +- 4 files changed, 56 insertions(+), 59 deletions(-) diff --git a/Makefile.dingux b/Makefile.dingux index 2aa302bb0..9f678e0ae 100644 --- a/Makefile.dingux +++ b/Makefile.dingux @@ -200,6 +200,7 @@ depobj += \ ioapi.o unzip.o dat.o state.o zipfn.o \ \ gui_config.o gui_gfx.o gui_main.o gui_romlist.o gui_setpath.o \ + gui_language_pack.o \ \ interface.o lowpass2.o \ \ diff --git a/src/sdl-dingux/gui_main.cpp b/src/sdl-dingux/gui_main.cpp index e276267bc..72ab50bbb 100644 --- a/src/sdl-dingux/gui_main.cpp +++ b/src/sdl-dingux/gui_main.cpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include @@ -249,7 +248,7 @@ void lang_put_stringM( uint32_t romID, unsigned int pos_x, unsigned int pos_y, u if(romID>=nBurnDrvCount || pos_x<0 || pos_y<0 || !idx2RGBAcolor.count(coloridx)) return; -// lang_DrawString( romID, (uint32_t *)lang_fontsurf->pixels, pos_x, pos_y, GUI_SCREEN_W, idx2RGBAcolor[coloridx] ); + lang_DrawString( romID, (uint32_t *)lang_fontsurf->pixels, pos_x, pos_y, GUI_SCREEN_W, idx2RGBAcolor[coloridx] ); } static inline void lang_show_gamelist_lines() @@ -1755,7 +1754,7 @@ void ss_prog_run(void) options.rotate = 0; ConfigGameSave(); -// SDL_QuitSubSystem(SDL_INIT_VIDEO); + SDL_QuitSubSystem(SDL_INIT_VIDEO); // run emulator here RunEmulator(nBurnDrvActive); @@ -1839,14 +1838,14 @@ void set_language() gui_lang.gamelist_line_height = LINE_HEIGHT; gui_lang.gamelist_line_count = LINES_COUNT; gui_lang.gamelist_line_count_half = LINES_COUNT_HALF; -// if(!use_language_pack) return; -// -// extern size_t pixfont_height; -// if(!pixfont_height) -// return; -// gui_lang.gamelist_line_height = pixfont_height; -// gui_lang.gamelist_line_count = (LINE_HEIGHT * LINES_COUNT+pixfont_height-1) / gui_lang.gamelist_line_height; -// gui_lang.gamelist_line_count_half = gui_lang.gamelist_line_count / 2; + if(!use_language_pack) return; + + extern size_t pixfont_height; + if(!pixfont_height) + return; + gui_lang.gamelist_line_height = pixfont_height; + gui_lang.gamelist_line_count = (LINE_HEIGHT * LINES_COUNT+pixfont_height-1) / gui_lang.gamelist_line_height; + gui_lang.gamelist_line_count_half = gui_lang.gamelist_line_count / 2; } void gui_menu_main() @@ -1909,11 +1908,11 @@ void gui_menu_main() romlist_y, // y ROMLIST(longueur, fID), // length df_color? BLANC : ROMLIST(etat, fID)); // color -// else -// lang_put_stringM(romID, -// START_X, // x -// romlist_y, // y -// df_color? BLANC : ROMLIST(etat, fID)); // color + else + lang_put_stringM(romID, + START_X, // x + romlist_y, // y + df_color? BLANC : ROMLIST(etat, fID)); // color romlist_y += gui_lang.gamelist_line_height; } } else { @@ -1926,11 +1925,11 @@ void gui_menu_main() romlist_y, ROMLIST(longueur, fID), df_color? BLANC : ROMLIST(etat, fID)); -// else -// lang_put_stringM(romID, -// START_X, // x -// romlist_y, // y -// df_color? BLANC : ROMLIST(etat, fID)); // color + else + lang_put_stringM(romID, + START_X, // x + romlist_y, // y + df_color? BLANC : ROMLIST(etat, fID)); // color romlist_y += gui_lang.gamelist_line_height; } } @@ -2213,8 +2212,7 @@ void GuiRun() { // fill data with data gui_sort_romlist(); - //use_language_pack = gui_load_language_pack(); - use_language_pack = false; + use_language_pack = gui_load_language_pack(); set_language(); gui_screen = SDL_SetVideoMode(GUI_SCREEN_W, GUI_SCREEN_H, 16, SDL_SWSURFACE); diff --git a/src/sdl-dingux/sdl_menu.cpp b/src/sdl-dingux/sdl_menu.cpp index 8b2db53ca..66fb39ecd 100644 --- a/src/sdl-dingux/sdl_menu.cpp +++ b/src/sdl-dingux/sdl_menu.cpp @@ -25,9 +25,8 @@ #include #include #include -#include -//#include -//#include +#include +#include #include "version.h" #include "burner.h" @@ -100,37 +99,37 @@ static inline inGameScreen_t * CopyScreen(SDL_Surface * src) void pngsave(const char * filename, uint16_t * rgb565, int w, int h, int outw, int outh) { -// if(w <= 0 || h <= 0 || !rgb565 || !filename || outw <= 0 || outh <= 0) -// return; -// try { -// const size_t ow = outw; -// const size_t oh = outh; -// png::image< png::rgb_pixel,png::solid_pixel_buffer > img(ow,oh); -// const int npixels = w * h; -// std::vector imgu8(npixels * 3); -// // We have to convert from RGB565 to RGB each coded on uint8 because PNG doesn't support RGB565 -// for (int i = 0; i < npixels; ++i) { -// const uint16_t v = rgb565[i]; -// // Convert and rescale to the full 0-255 range -// // See http://stackoverflow.com/a/29326693 -// const uint8_t red5 = (v & 0xF800) >> 11; -// const uint8_t green6 = (v & 0x7E0) >> 5; -// const uint8_t blue5 = (v & 0x001F); -// imgu8[3 * i] = ((red5 * 255 + 15) / 31); -// imgu8[3 * i + 1] = ((green6 * 255 + 31) / 63); -// imgu8[3 * i + 2] = ((blue5 * 255 + 15) / 31); -// } -// avir :: CImageResizer<> imageResizer( 8 ); -// uint8_t * Inbuf = (uint8_t *)imgu8.data(); -// uint8_t * Outbuf = (uint8_t *)img.get_pixbuf().get_bytes().data(); -// imageResizer.resizeImage( Inbuf, w, h, 0, Outbuf, ow, oh, 3, 0 ); -// img.write(filename); -// } -// catch(std::exception const& error) -// { -// std::cerr << "png++ err: " << error.what() << std::endl; -// return; -// } + if(w <= 0 || h <= 0 || !rgb565 || !filename || outw <= 0 || outh <= 0) + return; + try { + const size_t ow = outw; + const size_t oh = outh; + png::image< png::rgb_pixel,png::solid_pixel_buffer > img(ow,oh); + const int npixels = w * h; + std::vector imgu8(npixels * 3); + // We have to convert from RGB565 to RGB each coded on uint8 because PNG doesn't support RGB565 + for (int i = 0; i < npixels; ++i) { + const uint16_t v = rgb565[i]; + // Convert and rescale to the full 0-255 range + // See http://stackoverflow.com/a/29326693 + const uint8_t red5 = (v & 0xF800) >> 11; + const uint8_t green6 = (v & 0x7E0) >> 5; + const uint8_t blue5 = (v & 0x001F); + imgu8[3 * i] = ((red5 * 255 + 15) / 31); + imgu8[3 * i + 1] = ((green6 * 255 + 31) / 63); + imgu8[3 * i + 2] = ((blue5 * 255 + 15) / 31); + } + avir :: CImageResizer<> imageResizer( 8 ); + uint8_t * Inbuf = (uint8_t *)imgu8.data(); + uint8_t * Outbuf = (uint8_t *)img.get_pixbuf().get_bytes().data(); + imageResizer.resizeImage( Inbuf, w, h, 0, Outbuf, ow, oh, 3, 0 ); + img.write(filename); + } + catch(std::exception const& error) + { + std::cerr << "png++ err: " << error.what() << std::endl; + return; + } } #define SP_SCREEN_W 320 diff --git a/src/sdl-dingux/sdl_video.cpp b/src/sdl-dingux/sdl_video.cpp index 3cbe01e49..3157d33f8 100644 --- a/src/sdl-dingux/sdl_video.cpp +++ b/src/sdl-dingux/sdl_video.cpp @@ -2065,8 +2065,7 @@ void VideoExit() free(BurnVideoBuffer); BurnVideoBuffer = NULL; BurnerVideoTrans = Blit_null; - SDL_FreeSurface(screen); -// SDL_QuitSubSystem(SDL_INIT_VIDEO); + SDL_QuitSubSystem(SDL_INIT_VIDEO); } void VideoClear()