Snapshot of stuff as of now

This commit is contained in:
simon.kagstrom 2009-01-01 16:54:17 +00:00
parent b9ba2096fd
commit 6b627c2d68
5 changed files with 75 additions and 57 deletions

View File

@ -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 -lz -lSDL -lfreetype -lfat -lwiiuse -lbte -logc -lm
LIBS := -lSDL_ttf -lSDL_mixer -lSDL_image -ljpeg -lpng -lz -lSDL -lfreetype -lfat -lwiiuse -lbte -logc -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing

View File

@ -36,6 +36,10 @@ static char *bind_key_messages[] = {
NULL,
};
#define FONT_PATH "FreeMono.ttf"
#if defined(GEKKO)
#define FONT_PATH "/apps/frodo/FreeMono.ttf"
#endif
/*
* Constructor, system-dependent things
*/
@ -48,21 +52,43 @@ void C64::c64_ctor1(void)
joy_maxx = joy_maxy = -32768;
#endif
#if defined(GEKKO)
this->base_dir = "/apps/frodo/images";
#else
this->base_dir = ".";
#endif
this->fake_key_sequence = false;
this->fake_key_index = 0;
this->fake_key_keytime = 5;
this->fake_key_type = 0;
this->menu_font = TTF_OpenFont("FreeMono.ttf", 20);
FILE *f = fopen(FONT_PATH, "r");
if (!f)
fprintf(stderr, "Cannot open %s\n", FONT_PATH);
else {
fprintf(stderr, "Could open %s!!!\n", FONT_PATH);
fclose(f);
}
f = fopen("/FreeMono.ttf", "r");
if (!f)
fprintf(stderr, "Cannot open %s\n", "/Free...");
else {
fprintf(stderr, "Could open %s!!!\n", "/Free...");
fclose(f);
}
this->menu_font = TTF_OpenFont(FONT_PATH, 20);
if (!this->menu_font)
{
fprintf(stderr, "Unable to open font: %s\n", TTF_GetError() );
exit(1);
SDL_Delay(1000);
//exit(1);
}
#if 0
menu_init(&this->main_menu, this->menu_font, main_menu_messages,
0, 0, DISPLAY_X, DISPLAY_Y);
#endif
}
void C64::c64_ctor2(void)
@ -275,30 +301,16 @@ void C64::VBlank(bool draw_frame)
TheCIA2->CountTOD();
// Update window if needed
static uint64_t lastFrame;
if (draw_frame) {
TheDisplay->Update();
// Calculate time between VBlanks, display speedometer
struct timeval tv;
gettimeofday(&tv, NULL);
if ((tv.tv_usec -= tv_start.tv_usec) < 0) {
tv.tv_usec += 1000000;
tv.tv_sec -= 1;
}
tv.tv_sec -= tv_start.tv_sec;
double elapsed_time = (double)tv.tv_sec * 1000000 + tv.tv_usec;
speed_index = 20000 / (elapsed_time + 1) * ThePrefs.SkipFrames * 100;
uint32_t now = SDL_GetTicks();
// Limit speed to 100% if desired
if ((speed_index > 100) && ThePrefs.LimitSpeed) {
usleep((unsigned long)(ThePrefs.SkipFrames * 20000 - elapsed_time));
speed_index = 100;
}
gettimeofday(&tv_start, NULL);
TheDisplay->Speedometer((int)speed_index);
if ( (now - lastFrame) < 30 ) {
SDL_Delay( 30 - (now - lastFrame) );
}
lastFrame = now;
}
@ -360,7 +372,20 @@ uint8 C64::poll_joystick(int port)
if (held & WPAD_BUTTON_2)
j &= 0xef; // Button
if (held & WPAD_BUTTON_HOME)
this->enter_menu();
exit(1);
//this->enter_menu();
if (held & WPAD_BUTTON_A) {
Prefs *np = Frodo::reload_prefs();
strncpy(np->DrivePath[0], "/apps/frodo/images/spy_vs_spy.d64", 255);
np->DriveType[0] = DRVTYPE_D64;
np->LimitSpeed = true;
NewPrefs(np);
ThePrefs = *np;
this->fake_key_sequence = true;
}
//this->enter_menu();
if ( (held & WPAD_BUTTON_A) && this->joystick_key_binding[0])
TheDisplay->FakeKeyPress(this->joystick_key_binding[0],
false, TheCIA1->KeyMatrix, TheCIA1->RevMatrix, NULL);

View File

@ -60,20 +60,16 @@ enum {
int init_graphics(void)
{
// 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;
}
// Open window
SDL_WM_SetCaption(VERSION_STRING, "Frodo");
screen = SDL_SetVideoMode(DISPLAY_X, DISPLAY_Y + 17, 8, SDL_DOUBLEBUF);
SDL_ShowCursor(SDL_DISABLE);
screen = SDL_SetVideoMode(640, 480, 8,
SDL_DOUBLEBUF | SDL_FULLSCREEN);
#if 0
screen = SDL_SetVideoMode(DISPLAY_X, DISPLAY_Y + 17, 8,
SDL_DOUBLEBUF | SDL_FULLSCREEN);
#endif
return 1;
}

View File

@ -63,8 +63,8 @@ void DigitalRenderer::init_sound(void)
/* Set the audio format */
this->spec.freq = 44100;
this->spec.format = AUDIO_S16LSB;
this->spec.channels = 1; /* 1 = mono, 2 = stereo */
this->spec.format = AUDIO_S16MSB;
this->spec.channels = 2; /* 1 = mono, 2 = stereo */
this->spec.samples = 512;
this->spec.callback = this->fill_audio_helper;
this->spec.userdata = (void*)this;

View File

@ -12,10 +12,7 @@
extern int init_graphics(void);
// Global variables
char Frodo::prefs_path[256] = "";
#define PREFS_PATH "/apps/frodo/frodorc"
/*
* Create application object and start it
@ -37,6 +34,17 @@ extern "C" int main(int argc, char **argv)
}
fflush(stdout);
// 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)
{
@ -69,8 +77,6 @@ Frodo::Frodo()
void Frodo::ArgvReceived(int argc, char **argv)
{
if (argc == 2)
strncpy(prefs_path, argv[1], 255);
}
@ -82,16 +88,7 @@ void Frodo::ReadyToRun(void)
{
getcwd(AppDirPath, 256);
// Load preferences
if (!prefs_path[0]) {
char *home = getenv("HOME");
if (home != NULL && strlen(home) < 240) {
strncpy(prefs_path, home, 200);
strcat(prefs_path, "/");
}
strcat(prefs_path, ".frodorc");
}
ThePrefs.Load(prefs_path);
ThePrefs.Load((char*)PREFS_PATH);
// Create and start C64
TheC64 = new C64;
@ -104,6 +101,6 @@ void Frodo::ReadyToRun(void)
Prefs *Frodo::reload_prefs(void)
{
static Prefs newprefs;
newprefs.Load(prefs_path);
newprefs.Load((char*)PREFS_PATH);
return &newprefs;
}