Version 2.2

Solved issues # 20, 21,23, 25, 29.

Added the possibility to show a smaller screen (so also the borders are shown), the preferences are saved manually and not automatically on exit, when a gameshot is saved also some preferences (key bindings, game name, 1541 emulation, screen dimension) related to the game are saved.
This commit is contained in:
fabio.olimpieri 2011-06-02 20:50:48 +00:00
parent 17d70cc3ef
commit 8085fee39c
17 changed files with 3617 additions and 3457 deletions

View File

@ -25,9 +25,9 @@ INCLUDES :=
# options for code generation
#---------------------------------------------------------------------------------
PCFLAGS = -DPRECISE_CPU_CYCLES=1 -DPRECISE_CIA_CYCLES=1 -DPC_IS_POINTER=0
PCFLAGS = -DPRECISE_CPU_CYCLES=1 -DPRECISE_CIA_CYCLES=1 -DPC_IS_POINTER=0 -DWII_PORT
SCFLAGS = $(PCFLAGS) -DFRODO_SC
CFLAGS = -O3 -g -Wall $(MACHDEP) $(INCLUDE) -U__unix -DHAVE_SDL $(SCFLAGS) -I$(LIBOGC_INC)/SDL -I$(PWD)/Src/
CFLAGS = -O3 -g -Wall $(MACHDEP) $(INCLUDE) -DHAVE_SDL $(SCFLAGS) -I$(LIBOGC_INC)/SDL
CXXFLAGS = $(CFLAGS)
LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map
@ -41,7 +41,7 @@ LIBS := -lSDL_ttf -lSDL_image -lpng -ljpeg -lz -lSDL -lfreetype -lfat -lwiiuse -
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS :=
LIBDIRS := $(PORTLIBS)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
@ -92,7 +92,9 @@ export OFILES := $(addsuffix .o,$(BINFILES)) \
export INCLUDE := $(foreach dir,$(INCLUDES), -iquote $(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD) \
-I$(LIBOGC_INC)
-I$(LIBOGC_INC) \
-I$(CURDIR)/Src \
-I$(PORTLIBS)/include
#---------------------------------------------------------------------------------
# build a list of library paths

View File

@ -702,6 +702,7 @@ void C64::Resume(void)
{
this->have_a_break = false;
TheSID->ResumeSound();
//SDL_FillRect(real_screen, NULL, 0);
}
#include "C64_SDL.h"

View File

@ -303,8 +303,8 @@ void C64::VBlank(bool draw_frame)
Gui::gui->runLogic();
if (this->quit_thyself)
ThePrefs.Save(ThePrefs.PrefsPath);
//if (this->quit_thyself)
// ThePrefs.Save(ThePrefs.PrefsPath);
#if defined(GEKKO)
if (this->quit_thyself && Network::networking_started == true)
SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);

View File

@ -96,8 +96,8 @@ void C64Display::UpdateLEDs(int l0, int l1, int l2, int l3)
// Display surface
static Uint8 screen[DISPLAY_X * DISPLAY_Y];
static Uint16 *screen_16;
static Uint32 *screen_32;
//static Uint16 *screen_16;
//static Uint32 *screen_32;
static int screen_bits_per_pixel;
static SDL_Surface *sdl_screen;
@ -158,16 +158,22 @@ int init_graphics(void)
SDL_ShowCursor(SDL_DISABLE);
SDL_FreeSurface(sdl_screen);
sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, DISPLAY_X, DISPLAY_Y + 17, 8,
rmask, gmask, bmask, amask);
//sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, DISPLAY_X, DISPLAY_Y + 17, 8, rmask, gmask, bmask, amask);
screen_bits_per_pixel = info->vfmt->BitsPerPixel;
sdl_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, DISPLAY_X, DISPLAY_Y, screen_bits_per_pixel, rmask, gmask, bmask, amask);
if (!sdl_screen)
{
fprintf(stderr, "Cannot allocate surface to draw on: %s\n",
SDL_GetError());
exit(1);
}
#ifndef WII_PORT
if (ThePrefs.DisplayType == DISPTYPE_SCREEN)
flags |= SDL_FULLSCREEN;
#endif
screen_bits_per_pixel = info->vfmt->BitsPerPixel;
SDL_FreeSurface(real_screen);
real_screen = SDL_SetVideoMode(FULL_DISPLAY_X, FULL_DISPLAY_Y, screen_bits_per_pixel,
@ -177,16 +183,19 @@ int init_graphics(void)
fprintf(stderr, "\n\nCannot initialize video: %s\n", SDL_GetError());
exit(1);
}
//this part of code seems useless
/*
free(screen_16);
free(screen_32);
switch (screen_bits_per_pixel)
{
case 8:
/* Default, no need to do anything further */
Default, no need to do anything further
break;
case 16:
/* Allocate a 16 bit screen */
Allocate a 16 bit screen
screen_16 = (Uint16*)calloc(real_screen->pitch * FULL_DISPLAY_Y, sizeof(Uint16) );
break;
case 24:
@ -197,6 +206,7 @@ int init_graphics(void)
printf("What is this???\n");
break;
}
*/
return 1;
}
@ -271,6 +281,38 @@ void C64Display::Update_32(uint8 *src_pixels)
void C64Display::Update_16(uint8 *src_pixels)
{
const Uint16 src_pitch = DISPLAY_X;
#ifdef WII_PORT
if (ThePrefs.DisplayType == DISPTYPE_WINDOW)
{
SDL_Rect srcrect = {0, 0, DISPLAY_X, DISPLAY_Y};
SDL_Rect dstrect = {0, 8, FULL_DISPLAY_X, FULL_DISPLAY_Y-16};
Uint16 *dst_pixels = (Uint16*)sdl_screen->pixels ;
const Uint16 src_pitch = DISPLAY_X;
const Uint16 dst_pitch = sdl_screen->pitch / sizeof(Uint16);
/* 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 = y * dst_pitch + x;
Uint16 v = palette_16[src_pixels[src_off]];
dst_pixels[ dst_off ] = v;
}
}
/* Stretch */
SDL_SoftStretch(sdl_screen, &srcrect, real_screen, &dstrect);
}
else
#endif
{
const int x_border = (DISPLAY_X - FULL_DISPLAY_X / 2) / 2;
const int y_border = (DISPLAY_Y - FULL_DISPLAY_Y / 2) / 2;
Uint16 *dst_pixels = (Uint16*)real_screen->pixels;
@ -291,6 +333,8 @@ void C64Display::Update_16(uint8 *src_pixels)
dst_pixels[ dst_off + dst_pitch + 1] = v;
}
}
}
}
void C64Display::Update_8(uint8 *src_pixels)

View File

@ -120,7 +120,7 @@ Prefs::Prefs()
this->NetworkRegion = REGION_UNKNOWN;
this->CursorKeysForJoystick = true;
strcpy(this->Theme, "default");
strcpy(this->Theme, "DEFAULT");
}
@ -348,6 +348,23 @@ void Prefs::Check(void)
DisplayType = DISPTYPE_WINDOW;
}
// Introduced to fix the file names with spaces
void search_name(char* line, char* value)
{
char* ptrstr;
int length=0;
if (!(ptrstr = strchr(line,'='))) return;
ptrstr= ptrstr + 2;
while (ptrstr [length] != '\n') length++;
ptrstr [length] = '\0';
strncpy (value, ptrstr, length+1);
}
/*
* Load preferences from file
@ -360,6 +377,7 @@ void Prefs::Load(const char *filename)
if ((file = fopen(filename, "r")) != NULL) {
while(fgets(line, 255, file)) {
// if the file name contains spaces sscanf cuts the name in DrivePath[8-11]
if (sscanf(line, "%s = %s\n", keyword, value) == 2) {
if (!strcmp(keyword, "NormalCycles"))
NormalCycles = atoi(value);
@ -381,14 +399,15 @@ void Prefs::Load(const char *filename)
ScalingNumerator = atoi(value);
else if (!strcmp(keyword, "ScalingDenominator"))
ScalingDenominator = atoi(value);
else if (!strcmp(keyword, "DrivePath8"))
strcpy(DrivePath[0], value);
else if (!strcmp(keyword, "DrivePath9"))
strcpy(DrivePath[1], value);
else if (!strcmp(keyword, "DrivePath10"))
strcpy(DrivePath[2], value);
else if (!strcmp(keyword, "DrivePath11"))
strcpy(DrivePath[3], value);
//Work arround to fix the problem for files with spaces in the name
else if (!strcmp(keyword, "DrivePath8")) {search_name(line, value);
strcpy(DrivePath[0], value); }
else if (!strcmp(keyword, "DrivePath9")) { search_name(line, value);
strcpy(DrivePath[1], value);}
else if (!strcmp(keyword, "DrivePath10")) { search_name(line, value);
strcpy(DrivePath[2], value);}
else if (!strcmp(keyword, "DrivePath11")) { search_name(line, value);
strcpy(DrivePath[3], value);}
else if (!strcmp(keyword, "ViewPort"))
strcpy(ViewPort, value);
else if (!strcmp(keyword, "DisplayMode"))
@ -627,3 +646,36 @@ bool Prefs::Save(const char *filename)
}
return false;
}
/*
* Save game preferences to file
* true: success, false: error
* Save only drivepath, displaytype, joystikswap, emule 1541, joystickbutton, cursorkeys for joystick
*/
bool Prefs::Save_game(const char *filename)
{
FILE *file;
Check();
if ((file = fopen(filename, "w")) != NULL) {
for (int i=0; i<4; i++)
maybe_write(file, strcmp(DrivePath[i], TheDefaultPrefs.DrivePath[i]) != 0, "DrivePath%d = %s\n", i+8, DrivePath[i]);
maybe_write(file, true, "DisplayType = %s\n", DisplayType == DISPTYPE_WINDOW ? "WINDOW" : "SCREEN");
maybe_write(file, true, "JoystickSwap = %s\n", JoystickSwap ? "TRUE" : "FALSE");
maybe_write(file, true, "Emul1541Proc = %s\n", Emul1541Proc ? "TRUE" : "FALSE");
for (int i = 0; i < MAX_JOYSTICK_BUTTONS; i++)
maybe_write(file, true, "JoystickButtons%d = %d\n", i, JoystickButtons[i]);
maybe_write(file, true, "CursorKeysForJoystick = %s\n", CursorKeysForJoystick ? "TRUE" : "FALSE");
fclose(file);
ThePrefsOnDisk = *this;
return true;
}
return false;
}

View File

@ -104,6 +104,7 @@ public:
void Check(void);
void Load(const char *filename);
bool Save(const char *filename);
bool Save_game(const char *filename);
bool operator==(const Prefs &rhs) const;
bool operator!=(const Prefs &rhs) const;

View File

@ -420,7 +420,7 @@ public:
SDL_BlitSurface(Gui::gui->bind_key_box, NULL, where, &dst);
this->menu->draw(where, 50, 70, 300, 400);
this->help->draw(where, 358, 28, 264, 210);
this->help->draw(where, 358, 28, 264, 230);
}
protected:

View File

@ -72,6 +72,7 @@ class StartGameListener : public TimeoutHandler
public:
StartGameListener()
{
Gui::gui->status_bar->queueMessage("Resetting the C64");
TheC64->Reset();
TimerController::controller->arm(this, 4500);

View File

@ -228,7 +228,8 @@ GameInfo::GameInfo(GameInfo *gi)
this->genre = gi->genre;
if (gi->screenshot)
this->screenshot = SDL_DisplayFormat(gi->screenshot);
// this->screenshot = SDL_DisplayFormat(gi->screenshot);
this->screenshot = sdl_surface_8bit_copy(gi->screenshot);
}
GameInfo::~GameInfo()

View File

@ -355,8 +355,8 @@ void Gui::exitMenu()
prefs_changed = ThePrefs != *this->np;
ThePrefs = *this->np;
if (prefs_changed)
ThePrefs.Save(ThePrefs.PrefsPath);
//if (prefs_changed)
// ThePrefs.Save(ThePrefs.PrefsPath);
this->saveGameInfo(this->metadata_base_path, this->cur_gameInfo->filename);
}

View File

@ -115,6 +115,11 @@ public:
case 9: /* Options */
Gui::gui->pushView(Gui::gui->ov);
break;
case 10: /* Save Prefs */
ThePrefs = *Gui::gui->np;
ThePrefs.Save(ThePrefs.PrefsPath);
Gui::gui->pushDialogueBox(new DialogueBox(save_prefs_done));
break;
case 11: /* Exit */
DialogueBox *exit_dialogue = new DialogueBox(exit_dialogue_messages);
exit_dialogue->registerListener(new ExitListener());

View File

@ -13,6 +13,17 @@ const char *exit_dialogue_messages[8] = {
NULL
};
const char *save_prefs_done[8] = {
/*00*/ "Preferences saved!",
/*01*/ "#",
/*02*/ "#", /* Empty line */
/*03*/ "#",
/*04*/ "#",
/*05*/ "#",
/*06*/ "^|OK",
NULL
};
const char *save_state_done[8] = {
/*00*/ "Game state saved!",
/*01*/ "#",
@ -138,7 +149,7 @@ const char *main_menu_messages[14] = {
/*07*/ "Game info",
/*08*/ "Networking",
/*09*/ "Options",
/*10*/ " ",
/*10*/ "Save prefs",
/*11*/ "Quit",
NULL
};
@ -182,7 +193,10 @@ const char **main_menu_help[14] = {
"Configure Frodo",
NULL,
},
(const char*[]){
"Save general preferences",
NULL,
},
(const char*[]){
"Quit Frodo",
NULL,
@ -244,13 +258,9 @@ const char **options_menu_help[14] = {
NULL,
(const char*[]){
"Select display settings.",
"Fullscreen attemts to run",
"in fullscreen mode, while.",
"windowed uses a window.",
"Activated on next restart.",
" ",
"On the Wii, fullscreen is",
"always used",
"Fullscreen runs in",
"double size mode, while",
"window in streched mode.",
NULL,
},
NULL,
@ -262,7 +272,10 @@ const char **options_menu_help[14] = {
NULL,
},
NULL,
(const char*[]){
"Reset the c64.",
NULL,
},
NULL,
(const char*[]){
"Setup theme for the Frodo",
@ -320,6 +333,7 @@ const char **network_menu_help[9] = {
};
const char *game_info_menu_messages[11] = {
/*00*/ "Capture game screenshot",
/*01*/ " ",
@ -334,6 +348,8 @@ const char *game_info_menu_messages[11] = {
NULL
};
const char *genre_dlg[8] = {
/*00*/ "Action",
/*01*/ "Adventure",

View File

@ -26,5 +26,6 @@ extern const char *game_info_bad_number_dlg[];
extern const char *genre_dlg[];
extern const char *players_dlg[];
extern const char *save_state_done[];
extern const char *save_prefs_done[];
#endif

View File

@ -2,7 +2,7 @@
#define NETWORK_USER_MENU_HH
#include <SDL.h>
#include <Network.h>
#include "../Network.h"
class GuiView;
class NetworkUserMenu;

View File

@ -77,15 +77,16 @@ public:
if (this->loadSnapshot)
{
int display_type = Gui::gui->np->DisplayType;
//int display_type = Gui::gui->np->DisplayType;
TheC64->Reset();
TheC64->LoadSnapshot(new_path);
this->updateGameInfo(fileName);
Gui::gui->updateGameInfo(Gui::gui->sgv->gameInfo->gi);
Gui::gui->np->Load(prefs_path);
/* Don't change display type */
Gui::gui->np->DisplayType = display_type;
//Gui::gui->np->DisplayType = display_type;
} else
unlink(new_path);
free(prefs_path);
@ -162,6 +163,7 @@ void SaveGameView::saveSnapshot()
char *prefs_name;
char *save;
/*
if (strlen(Gui::gui->np->DrivePath[0]) != 0)
name = Gui::gui->np->DrivePath[0];
out_name = strrchr(name, '/');
@ -169,6 +171,12 @@ void SaveGameView::saveSnapshot()
out_name = name;
else
out_name++;
*/
//take the filename from gameinfo instead from drivepath
out_name = Gui::gui->cur_gameInfo->filename;
if (!out_name)
out_name = name;
save = (char*)xmalloc( strlen(Gui::gui->save_game_path) + strlen(out_name) + 6 );
prefs_name = (char*)xmalloc( strlen(Gui::gui->save_game_path) + strlen(out_name) + 12 );
@ -182,9 +190,12 @@ void SaveGameView::saveSnapshot()
if (!was_paused)
TheC64->Resume();
//Take the screenshot from the one saved when the gui was activacted
Gui::gui->cur_gameInfo->setScreenshot(sdl_surface_8bit_copy(Gui::gui->screenshot));
Gui::gui->saveGameInfo(Gui::gui->save_game_path, out_name);
ThePrefs.Save(prefs_name);
ThePrefs = *Gui::gui->np;
ThePrefs.Save_game(prefs_name);
Gui::gui->pushDialogueBox(new DialogueBox(save_state_done));

View File

@ -30,6 +30,7 @@
#include "gui/gui.hh"
#include "data_store.hh"
#include "utils.hh"
#include <fat.h>
#if defined(GEKKO)
#include "fat.h"
@ -109,6 +110,7 @@ void Frodo::load_rom_files()
extern "C" int main(int argc, char **argv)
{
DIR_ITER *dir_tmp;
timeval tv;
gettimeofday(&tv, NULL);
srand(tv.tv_usec);
@ -126,11 +128,34 @@ extern "C" int main(int argc, char **argv)
fflush(stdout);
#ifdef WII_PORT
printf("\x1b[2;0H");
//initialize libfat library
if (!fatInitDefault())
{
printf("Couldn't initialize fat subsytem\n");
sleep(3);
exit(0);
}
//create tmp directory if it does not exist
dir_tmp = diropen("/frodo/tmp");
if (!dir_tmp) {mkdir("/frodo/tmp",0777);printf("Making tmp directory\n");sleep(3);} else dirclose(dir_tmp);
#endif
Frodo *the_app = new Frodo();
the_app->ArgvReceived(argc, argv);
the_app->ReadyToRun();
delete the_app;
#ifdef WII_PORT
fatUnmount(0);
#endif
return 0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB