diff --git a/Makefile b/Makefile index e6555dc..bed0329 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ LDFLAGS = -L$(DEVKITPRO)/SDL/lib -g $(MACHDEP) -Wl,-Map,$(notdir $@).map #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- -LIBS := -lSDL_ttf -lSDL_mixer -lSDL_image -ljpeg -lpng -lz -lSDL -lfreetype -lfat -lwiiuse -lbte -logc -lm +LIBS := -lSDL_image -ljpeg -lpng -lz -lSDL -lfat -lwiiuse -lbte -logc -lm #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing diff --git a/Src/C64.h b/Src/C64.h index 57331a4..c218a2f 100644 --- a/Src/C64.h +++ b/Src/C64.h @@ -146,7 +146,6 @@ private: #ifdef GEKKO double speed_index; - int joystick_key_binding[5]; /* A, B, Plus, Minus, 1 */ #endif #ifdef __unix @@ -167,8 +166,6 @@ public: void select_disc(); void bind_key(); void display_options(); - - int display_type; #endif #ifdef WIN32 diff --git a/Src/C64_SDL.i b/Src/C64_SDL.i index 126ffb5..4956e34 100644 --- a/Src/C64_SDL.i +++ b/Src/C64_SDL.i @@ -68,7 +68,7 @@ void C64::c64_ctor1(void) this->fake_key_keytime = 5; this->fake_key_type = 0; - this->menu_font = new Font("/apps/frodo/fonts.png"); + this->menu_font = new Font("/apps/frodo/fonts.bmp"); if (!this->menu_font) { fprintf(stderr, "Unable to open font\n" ); @@ -195,7 +195,7 @@ void C64::bind_key() int key = menu_select(screen, &key_menu, ~0, NULL); #if defined(GEKKO) - this->joystick_key_binding[opt] = kcs[key]; + ThePrefs.JoystickKeyBinding[opt] = kcs[key]; #endif } menu_fini(&bind_key_menu); @@ -210,7 +210,7 @@ void C64::display_options() 0, 0, DISPLAY_X, DISPLAY_Y); int opt = menu_select(screen, &display_menu, ~0, NULL); if (opt >= 0) - this->display_type = opt; + ThePrefs.DisplayOption = opt; menu_fini(&display_menu); } @@ -372,21 +372,23 @@ uint8 C64::poll_joystick(int port) j &= 0xef; // Button if (held & WPAD_BUTTON_HOME) this->enter_menu(); + if (held & WPAD_BUTTON_A) + exit(1); - if ( (held & WPAD_BUTTON_A) && this->joystick_key_binding[0]) - TheDisplay->FakeKeyPress(this->joystick_key_binding[0], + if ( (held & WPAD_BUTTON_A) && ThePrefs.JoystickKeyBinding[0]) + TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[0], false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL); - if ( (held & WPAD_BUTTON_B) && this->joystick_key_binding[1]) - TheDisplay->FakeKeyPress(this->joystick_key_binding[1], + if ( (held & WPAD_BUTTON_B) && ThePrefs.JoystickKeyBinding[1]) + TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[1], false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL); - if ( (held & WPAD_BUTTON_PLUS) && this->joystick_key_binding[2]) - TheDisplay->FakeKeyPress(this->joystick_key_binding[2], + if ( (held & WPAD_BUTTON_PLUS) && ThePrefs.JoystickKeyBinding[2]) + TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[2], false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL); - if ( (held & WPAD_BUTTON_MINUS) && this->joystick_key_binding[3]) - TheDisplay->FakeKeyPress(this->joystick_key_binding[3], + if ( (held & WPAD_BUTTON_MINUS) && ThePrefs.JoystickKeyBinding[3]) + TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[3], false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL); - if ( (held & WPAD_BUTTON_1) && this->joystick_key_binding[4]) - TheDisplay->FakeKeyPress(this->joystick_key_binding[4], + if ( (held & WPAD_BUTTON_1) && ThePrefs.JoystickKeyBinding[4]) + TheDisplay->FakeKeyPress(ThePrefs.JoystickKeyBinding[4], false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL); diff --git a/Src/Display_SDL.i b/Src/Display_SDL.i index cc6c488..4059f0a 100644 --- a/Src/Display_SDL.i +++ b/Src/Display_SDL.i @@ -111,7 +111,6 @@ C64Display::C64Display(C64 *the_c64) : TheC64(the_c64) C64Display::~C64Display() { SDL_Quit(); - TTF_Quit(); } @@ -404,6 +403,8 @@ static void translate_key(SDLKey key, bool key_up, uint8 *key_matrix, uint8 *rev case SDLK_KP_DIVIDE: c64_key = MATRIX(6,7); break; case SDLK_KP_ENTER: c64_key = MATRIX(0,1); break; + + default: break; } if (c64_key < 0) diff --git a/Src/Prefs.cpp b/Src/Prefs.cpp index cd960ac..a1e089d 100644 --- a/Src/Prefs.cpp +++ b/Src/Prefs.cpp @@ -78,6 +78,9 @@ Prefs::Prefs() this->JoystickKeyBinding[1] = 0; this->JoystickKeyBinding[2] = 0; this->JoystickKeyBinding[3] = 0; + this->JoystickKeyBinding[4] = 0; + + this->DisplayOption = 0; #endif } @@ -138,6 +141,8 @@ bool Prefs::operator==(const Prefs &rhs) const && this->JoystickKeyBinding[1] == rhs.JoystickKeyBinding[1] && this->JoystickKeyBinding[2] == rhs.JoystickKeyBinding[2] && this->JoystickKeyBinding[3] == rhs.JoystickKeyBinding[3] + && this->JoystickKeyBinding[4] == rhs.JoystickKeyBinding[4] + && this->DisplayOption == rhs.DisplayOption #endif ); } @@ -312,6 +317,10 @@ void Prefs::Load(char *filename) JoystickKeyBinding[2] = atoi(value); else if (!strcmp(keyword, "JoystickKeyBinding3")) JoystickKeyBinding[3] = atoi(value); + else if (!strcmp(keyword, "JoystickKeyBinding4")) + JoystickKeyBinding[4] = atoi(value); + else if (!strcmp(keyword, "DisplayOption")) + DisplayOption = atoi(value); #endif } } @@ -414,6 +423,9 @@ bool Prefs::Save(char *filename) fprintf(file, "JoystickKeyBinding1 = %d\n", JoystickKeyBinding[1]); fprintf(file, "JoystickKeyBinding2 = %d\n", JoystickKeyBinding[2]); fprintf(file, "JoystickKeyBinding3 = %d\n", JoystickKeyBinding[3]); + fprintf(file, "JoystickKeyBinding4 = %d\n", JoystickKeyBinding[4]); + + fprintf(file, "DisplayOption = %d\n", DisplayOption); #endif fclose(file); ThePrefsOnDisk = *this; diff --git a/Src/Prefs.h b/Src/Prefs.h index a5f8064..48f4b10 100644 --- a/Src/Prefs.h +++ b/Src/Prefs.h @@ -116,7 +116,8 @@ private: #endif #ifdef GEKKO - int JoystickKeyBinding[4]; + int JoystickKeyBinding[5]; + int DisplayOption; #endif }; diff --git a/Src/bitmap-font.cpp b/Src/bitmap-font.cpp index 429357c..e03c982 100644 --- a/Src/bitmap-font.cpp +++ b/Src/bitmap-font.cpp @@ -1,11 +1,42 @@ #include #include +#include +#include #include "bitmap-font.h" Font::Font(std::string src_file) { - m_pFontList = SDL_DisplayFormatAlpha(IMG_Load(src_file.c_str())); + Uint8 *data = (Uint8*)malloc(2 * 1024*1024); + FILE *fp = fopen(src_file.c_str(), "r"); + SDL_RWops *rw; + + if (!fp) { + fprintf(stderr, "Could not open fonts\n"); + SDL_Delay(1000); + free(data); + exit(1); + } + else + fprintf(stderr, "I could open fonts manually\n"); + fread(data, 1, 2 * 1024 * 1024, fp); + rw = SDL_RWFromMem(data, 2 * 1024 * 1024); + if (!rw) { + fprintf(stderr, "Could not create RW: %s\n", SDL_GetError()); + exit(1); + } + + SDL_Surface *surf = IMG_Load_RW(rw, 0); + + if (!surf) { + fprintf(stderr, "Could not load %s\n", src_file.c_str()); + SDL_Delay(1000); + exit(1); + } + m_pFontList = surf; + + SDL_FreeRW(rw); + free(data); } Font::~Font(void) diff --git a/Src/main_wii.i b/Src/main_wii.i index aef28df..836bc0d 100644 --- a/Src/main_wii.i +++ b/Src/main_wii.i @@ -33,19 +33,13 @@ extern "C" int main(int argc, char **argv) return 0; } fflush(stdout); + fatInitDefault(); // Init SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { fprintf(stderr, "Couldn't initialize SDL (%s)\n", SDL_GetError()); return 0; } - if (TTF_Init() < 0) - { - fprintf(stderr, "Unable to init TTF: %s\n", TTF_GetError() ); - return 0; - } - - fatInitDefault(); if (WPAD_Init() != WPAD_ERR_NONE) { fprintf(stderr, "Failed initializing controllers\n");