mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2025-02-21 06:42:02 +01:00
Store screenshot when game info is edited
This commit is contained in:
parent
8577acdc0c
commit
c718e1aead
@ -89,6 +89,7 @@ public:
|
|||||||
void Update_16(uint8 *src_pixels);
|
void Update_16(uint8 *src_pixels);
|
||||||
void Update_32(uint8 *src_pixels);
|
void Update_32(uint8 *src_pixels);
|
||||||
void Update_stretched(uint8 *src_pixels);
|
void Update_stretched(uint8 *src_pixels);
|
||||||
|
SDL_Surface *SurfaceFromC64Display();
|
||||||
char *GetTextMessage();
|
char *GetTextMessage();
|
||||||
#endif
|
#endif
|
||||||
bool NumLock(void);
|
bool NumLock(void);
|
||||||
|
@ -66,6 +66,7 @@ enum {
|
|||||||
};
|
};
|
||||||
static Uint16 palette_16[PALETTE_SIZE];
|
static Uint16 palette_16[PALETTE_SIZE];
|
||||||
static Uint32 palette_32[PALETTE_SIZE];
|
static Uint32 palette_32[PALETTE_SIZE];
|
||||||
|
SDL_Color sdl_palette[PALETTE_SIZE];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
C64 keyboard matrix:
|
C64 keyboard matrix:
|
||||||
@ -337,6 +338,48 @@ void C64Display::Update()
|
|||||||
this->Update((Uint8*)screen);
|
this->Update((Uint8*)screen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_Surface *C64Display::SurfaceFromC64Display()
|
||||||
|
{
|
||||||
|
Uint32 rmask,gmask,bmask,amask;
|
||||||
|
SDL_Surface *out;
|
||||||
|
|
||||||
|
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||||
|
rmask = 0xff000000;
|
||||||
|
gmask = 0x00ff0000;
|
||||||
|
bmask = 0x0000ff00;
|
||||||
|
amask = 0x000000ff;
|
||||||
|
#else
|
||||||
|
rmask = 0x000000ff;
|
||||||
|
gmask = 0x0000ff00;
|
||||||
|
bmask = 0x00ff0000;
|
||||||
|
amask = 0xff000000;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
out = SDL_CreateRGBSurface(SDL_SWSURFACE, DISPLAY_X, DISPLAY_Y, 8,
|
||||||
|
rmask,gmask,bmask,amask);
|
||||||
|
if (!out)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Uint8 *dst_pixels = (Uint8*)out->pixels;
|
||||||
|
const Uint16 src_pitch = DISPLAY_X;
|
||||||
|
|
||||||
|
/* Draw 1-1 */
|
||||||
|
for (int y = 0; y < DISPLAY_Y; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < DISPLAY_X; x++)
|
||||||
|
{
|
||||||
|
int src_off = y * src_pitch + x;
|
||||||
|
int dst_off = src_off;
|
||||||
|
Uint8 v = screen[src_off];
|
||||||
|
|
||||||
|
dst_pixels[ dst_off ] = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SDL_SetPalette(out, SDL_LOGPAL | SDL_PHYSPAL, sdl_palette, 0, PALETTE_SIZE);
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
void C64Display::display_status_string(char *str, int seconds)
|
void C64Display::display_status_string(char *str, int seconds)
|
||||||
{
|
{
|
||||||
Uint32 time_now = SDL_GetTicks();
|
Uint32 time_now = SDL_GetTicks();
|
||||||
@ -931,22 +974,21 @@ uint8 C64::poll_joystick(int port)
|
|||||||
|
|
||||||
void C64Display::InitColors(uint8 *colors)
|
void C64Display::InitColors(uint8 *colors)
|
||||||
{
|
{
|
||||||
SDL_Color palette[PALETTE_SIZE];
|
|
||||||
for (int i=0; i<16; i++) {
|
for (int i=0; i<16; i++) {
|
||||||
palette[i].r = palette_red[i];
|
sdl_palette[i].r = palette_red[i];
|
||||||
palette[i].g = palette_green[i];
|
sdl_palette[i].g = palette_green[i];
|
||||||
palette[i].b = palette_blue[i];
|
sdl_palette[i].b = palette_blue[i];
|
||||||
}
|
}
|
||||||
palette[fill_gray].r = palette[fill_gray].g = palette[fill_gray].b = 0xd0;
|
sdl_palette[fill_gray].r = sdl_palette[fill_gray].g = sdl_palette[fill_gray].b = 0xd0;
|
||||||
palette[shine_gray].r = palette[shine_gray].g = palette[shine_gray].b = 0xf0;
|
sdl_palette[shine_gray].r = sdl_palette[shine_gray].g = sdl_palette[shine_gray].b = 0xf0;
|
||||||
palette[shadow_gray].r = palette[shadow_gray].g = palette[shadow_gray].b = 0x80;
|
sdl_palette[shadow_gray].r = sdl_palette[shadow_gray].g = sdl_palette[shadow_gray].b = 0x80;
|
||||||
palette[red].r = 0xf0;
|
sdl_palette[red].r = 0xf0;
|
||||||
palette[red].g = palette[red].b = 0;
|
sdl_palette[red].g = sdl_palette[red].b = 0;
|
||||||
palette[green].g = 0xf0;
|
sdl_palette[green].g = 0xf0;
|
||||||
palette[green].r = palette[green].b = 0;
|
sdl_palette[green].r = sdl_palette[green].b = 0;
|
||||||
|
|
||||||
if (real_screen->format->BitsPerPixel == 8)
|
if (real_screen->format->BitsPerPixel == 8)
|
||||||
SDL_SetColors(real_screen, palette, 0, PALETTE_SIZE);
|
SDL_SetColors(real_screen, sdl_palette, 0, PALETTE_SIZE);
|
||||||
for (int i = 0; i < PALETTE_SIZE; i++) {
|
for (int i = 0; i < PALETTE_SIZE; i++) {
|
||||||
int rs = real_screen->format->Rshift;
|
int rs = real_screen->format->Rshift;
|
||||||
int gs = real_screen->format->Gshift;
|
int gs = real_screen->format->Gshift;
|
||||||
|
@ -17,21 +17,12 @@ public:
|
|||||||
void setGameInfo(GameInfo *gi)
|
void setGameInfo(GameInfo *gi)
|
||||||
{
|
{
|
||||||
/* Make a copy */
|
/* Make a copy */
|
||||||
if (this->gi)
|
this->gi = gi;
|
||||||
delete this->gi;
|
|
||||||
this->gi = new GameInfo(gi);
|
|
||||||
this->updateMessages();
|
this->updateMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadGameInfo(const char *what)
|
void loadGameInfo(const char *what)
|
||||||
{
|
{
|
||||||
/* Reset the current game info */
|
|
||||||
if (this->gi)
|
|
||||||
{
|
|
||||||
delete this->gi;
|
|
||||||
this->gi = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No need to do this for directories or the special "None" field */
|
/* No need to do this for directories or the special "None" field */
|
||||||
if ( !(strcmp(what, "None") == 0 ||
|
if ( !(strcmp(what, "None") == 0 ||
|
||||||
what[0] == '[') )
|
what[0] == '[') )
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
#include <Display.h>
|
||||||
|
#include <C64.h>
|
||||||
|
|
||||||
#include "gui.hh"
|
#include "gui.hh"
|
||||||
#include "menu.hh"
|
#include "menu.hh"
|
||||||
#include "game_info_box.hh"
|
#include "game_info_box.hh"
|
||||||
@ -56,6 +59,13 @@ public:
|
|||||||
|
|
||||||
virtual void escapeCallback(int which)
|
virtual void escapeCallback(int which)
|
||||||
{
|
{
|
||||||
|
/* If we haven't' saved a screenshot, save it anyway */
|
||||||
|
if (!this->box->gi->screenshot)
|
||||||
|
{
|
||||||
|
SDL_Surface *p = TheC64->TheDisplay->SurfaceFromC64Display();
|
||||||
|
|
||||||
|
this->box->gi->screenshot = p;
|
||||||
|
}
|
||||||
Gui::gui->popView();
|
Gui::gui->popView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,6 +104,11 @@ public:
|
|||||||
this->gameInfo->setGameInfo(Gui::gui->cur_gameInfo);
|
this->gameInfo->setGameInfo(Gui::gui->cur_gameInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void viewPopCallback()
|
||||||
|
{
|
||||||
|
Gui::gui->cur_gameInfo = this->gameInfo->gi;
|
||||||
|
}
|
||||||
|
|
||||||
void draw(SDL_Surface *where)
|
void draw(SDL_Surface *where)
|
||||||
{
|
{
|
||||||
SDL_Rect dst;
|
SDL_Rect dst;
|
||||||
|
@ -185,7 +185,6 @@ static void png_user_error(png_structp ctx, png_const_charp str)
|
|||||||
fprintf(stderr, "libpng: error: %s\n", str);
|
fprintf(stderr, "libpng: error: %s\n", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This is taken from http://encelo.netsons.org/programming/sdl (GPLed) */
|
/* This is taken from http://encelo.netsons.org/programming/sdl (GPLed) */
|
||||||
void *sdl_surface_to_png(SDL_Surface *surf, size_t *out_sz)
|
void *sdl_surface_to_png(SDL_Surface *surf, size_t *out_sz)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user