Skip to content

Commit

Permalink
Restore code for missing libraries and calls to SDL_QuitSubsystem
Browse files Browse the repository at this point in the history
  • Loading branch information
plrguez committed Jul 27, 2021
1 parent 7a636ac commit e45aee4
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 59 deletions.
1 change: 1 addition & 0 deletions Makefile.dingux
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
\
Expand Down
44 changes: 21 additions & 23 deletions src/sdl-dingux/gui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <libgen.h>

#include <algorithm>
#include <map>
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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);
Expand Down
67 changes: 33 additions & 34 deletions src/sdl-dingux/sdl_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
#include <unistd.h>
#include <vector>
#include <fstream>
#include <iostream>
//#include <avir.h>
//#include <png++/png.hpp>
#include <avir.h>
#include <png++/png.hpp>

#include "version.h"
#include "burner.h"
Expand Down Expand Up @@ -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<png::rgb_pixel> > img(ow,oh);
// const int npixels = w * h;
// std::vector<uint8_t> 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<png::rgb_pixel> > img(ow,oh);
const int npixels = w * h;
std::vector<uint8_t> 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
Expand Down
3 changes: 1 addition & 2 deletions src/sdl-dingux/sdl_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit e45aee4

Please sign in to comment.