Commit 01b63a62 authored by CeRiAl's avatar CeRiAl

GUI-SDL: Added support for 4 drives, disks & roms in subdirectories, general cleanup

parent 7732d3fa
...@@ -5,7 +5,7 @@ AM_CFLAGS += @SDL_CFLAGS@ ...@@ -5,7 +5,7 @@ AM_CFLAGS += @SDL_CFLAGS@
noinst_LIBRARIES = libguidep.a noinst_LIBRARIES = libguidep.a
libguidep_a_SOURCES = inputmode.c menu.c menu_load.c menu_prefs.c menu_tweak.c vkbd.cpp volumecontrol.c libguidep_a_SOURCES = inputmode.c menu.c menu_roms.c menu_disks.c menu_prefs.c menu_tweak.c vkbd.cpp volumecontrol.c
noinst_HEADERS = inputmode.h menu.h vkbd.h volumecontrol.h noinst_HEADERS = inputmode.h menu.h vkbd.h volumecontrol.h
#include <SDL.h> #include <SDL.h>
#include "inputmode.h" #include "inputmode.h"
extern char launchDir [256]; extern char launchDir[MAX_PATH];
extern SDL_Surface *prSDLScreen; extern SDL_Surface *prSDLScreen;
static SDL_Surface *ksur; static SDL_Surface *ksur;
static SDL_Surface *inputMode[3]; static SDL_Surface *inputMode[3];
int show_inputmode = 0; int show_inputmode = 0;
int inputmode_init(void) { int inputmode_init (void) {
int i; int i;
char tmpchar[256]; char tmpchar[MAX_PATH];
SDL_Surface* tmp; SDL_Surface* tmp;
sprintf(tmpchar, "%s/images/joystick.bmp", launchDir); sprintf(tmpchar, "%s/images/joystick.bmp", launchDir);
tmp = SDL_LoadBMP(tmpchar); tmp = SDL_LoadBMP(tmpchar);
if (tmp) { if (tmp) {
...@@ -33,14 +32,14 @@ int inputmode_init(void) { ...@@ -33,14 +32,14 @@ int inputmode_init(void) {
} }
void inputmode_redraw(void) { void inputmode_redraw (void) {
SDL_Rect r; SDL_Rect r;
SDL_Surface* surface; SDL_Surface* surface;
r.x=80; r.x = 80;
r.y=60; r.y = 60;
r.w=160; r.w = 160;
r.h=120; r.h = 120;
if (inputMode[0] && inputMode[1]) { if (inputMode[0] && inputMode[1]) {
// if (gp2xMouseEmuOn) { // if (gp2xMouseEmuOn) {
...@@ -50,6 +49,6 @@ void inputmode_redraw(void) { ...@@ -50,6 +49,6 @@ void inputmode_redraw(void) {
surface = inputMode[0]; surface = inputMode[0];
} }
SDL_BlitSurface(surface,NULL,prSDLScreen,&r); SDL_BlitSurface(surface, NULL, prSDLScreen, &r);
} }
} }
int inputmode_init(void); int inputmode_init (void);
void inputmode_redraw(void); void inputmode_redraw (void);
extern int show_inputmode; extern int show_inputmode;
This diff is collapsed.
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "SDL.h"
#include "SDL_image.h"
#include "SDL_ttf.h"
#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#ifdef TOUCHUI
#include <SDL_TouchUI.h>
#endif
extern void write_text(int x, int y, char* txt);
extern void blit_image(SDL_Surface* img, int x, int y);
extern int pushdir (char *directory);
extern char *popdir (void);
extern int getdirstackcount (void);
extern void freedirstack (void);
extern int getdirectory (char **filez, char *directory, bool hide_parent);
extern SDL_Surface* display;
extern SDL_Surface* tmpSDLScreen;
extern SDL_Surface* pMenu_Surface;
extern SDL_Color text_color;
#define MAX_FILES 1024
extern char msg[];
extern char msg_status[];
char disksSubDir[MAX_PATH];
int diskz (void);
void changeDisk (int drive);
int diskz (void) {
SDL_Event event;
pMenu_Surface = SDL_LoadBMP("images/menu_load.bmp");
int drivesloopdone = 0;
int menuSelection = 0;
int currLine;
int kright = 0;
int kb = 0;
char* drives[] = {"df0:", "df1:", "df2:", "df3:"};
char *tmp;
tmp = (char*)malloc(MAX_PATH);
if (display == NULL) {
gui_init();
}
sprintf(msg, "%s", "Select Disk Drive");
sprintf(msg_status, "%s", "[RIGHT] to eject disk");
while (!drivesloopdone) {
while (SDL_PollEvent(&event)) {
#ifdef TOUCHUI
SDL_TUI_HandleEvent(&event);
#endif
if (event.type == SDL_QUIT) { drivesloopdone = 1; }
#if GP2X
if (event.type == SDL_JOYBUTTONDOWN) {
switch (event.jbutton.button) {
case GP2X_BUTTON_UP: menuSelection--; break;
case GP2X_BUTTON_DOWN: menuSelection++; break;
case GP2X_BUTTON_RIGHT: kright = 1; break;
case GP2X_BUTTON_SELECT: drivesloopdone = 1; break;
case GP2X_BUTTON_B: kb =1; break;
}
}
#endif
if (event.type == SDL_KEYDOWN) {
switch (event.key.keysym.sym) {
case SDLK_ESCAPE: drivesloopdone = 1; break;
case SDLK_UP: menuSelection--; break;
case SDLK_DOWN: menuSelection++; break;
case SDLK_RIGHT: kright = 1; break;
case SDLK_RETURN: kb = 1; break;
default: break;
}
}
}
if (kright == 1) {
// eject diskimage
disk_eject(menuSelection);
kright = 0;
}
if (kb == 1) {
// select disk image
changeDisk(menuSelection);
kb = 0;
}
if (menuSelection < 0) { menuSelection = 3; }
if (menuSelection > 3) { menuSelection = 0; }
// background
SDL_BlitSurface(pMenu_Surface, NULL, tmpSDLScreen, NULL);
// texts
for (currLine = 0; currLine < 4; currLine++) {
if (menuSelection == currLine) {
text_color.r = 255; text_color.g = 100; text_color.b = 100;
}
write_text(10, (currLine*10) + 25, drives[currLine] );
sprintf(tmp, "%s", changed_prefs.floppyslots[currLine].df);
write_text(50, (currLine*10) + 25, tmp);
if (menuSelection == currLine) {
text_color.r = 0; text_color.g = 0; text_color.b = 0;
}
}
write_text(25, 5, msg);
write_text(15, 230, msg_status);
SDL_BlitSurface(tmpSDLScreen, NULL, display, NULL);
#ifdef TOUCHUI
SDL_TUI_UpdateAll();
#endif
redraw_frame();
} //while done
freedirstack();
strcpy(disksSubDir, "disks");
pMenu_Surface = SDL_LoadBMP("images/menu.bmp");
return 0;
}
void changeDisk (int drive) {
char launchDir[MAX_PATH];
SDL_Event event;
int getdir = 1;
bool hide_parent = false;
pMenu_Surface = SDL_LoadBMP("images/menu_load.bmp");
int loadloopdone = 0;
int num_of_files = 0;
int menuSelection = 0;
int currLine;
int bas = 0;
int kb = 0;
char **filez = (char **)malloc(MAX_FILES * sizeof(char *));
if (display == NULL) {
gui_init();
}
sprintf(msg, "%s", "Select Disk Image");
sprintf(msg_status, "%s", " ");
getcwd(launchDir, MAX_PATH);
int paging = 18;
if (strcmp(disksSubDir, "\0") == 0) {
strcpy(disksSubDir, "disks");
}
if (strcasecmp(disksSubDir, "disks") == 0) {
hide_parent = true;
}
num_of_files = getdirectory(filez, disksSubDir, hide_parent);
if (num_of_files < 18) {
paging = num_of_files;
}
while (!loadloopdone) {
while (SDL_PollEvent(&event)) {
#ifdef TOUCHUI
SDL_TUI_HandleEvent(&event);
#endif
if (event.type == SDL_QUIT) {
loadloopdone = 1;
}
#if GP2X
if (event.type == SDL_JOYBUTTONDOWN) {
switch (event.jbutton.button) {
case GP2X_BUTTON_UP: menuSelection -= 1; break;
case GP2X_BUTTON_DOWN: menuSelection += 1; break;
case GP2X_BUTTON_B: kb = 1; break;
case GP2X_BUTTON_SELECT: loadloopdone = 1; break;
}
}
#endif
if (event.type == SDL_KEYDOWN) {
switch (event.key.keysym.sym) {
case SDLK_ESCAPE: loadloopdone = 1; break;
case SDLK_UP: menuSelection -= 1; break;
case SDLK_DOWN: menuSelection += 1; break;
case SDLK_RETURN: kb = 1; break;
default: break;
}
}
}
if (kb == 1) {
// Check if a directory was selected
struct stat sstat;
char *tmp = (char *)calloc(1, MAX_PATH);
strcpy(tmp, disksSubDir);
strcat(tmp, "/");
strcat(tmp, filez[menuSelection]);
if (stat(tmp, &sstat) != -1) {
if (sstat.st_mode & S_IFDIR) {
// Select subdirectory
if (strcasecmp(filez[menuSelection], "..") == 0) {
// Back to parent
char *tmp2 = NULL;
tmp2 = popdir();
if (tmp2) {
menuSelection = 0;
paging = 18;
strcpy(disksSubDir, tmp2);
int i;
hide_parent = false;
if (getdirstackcount() == 0) {
hide_parent = true;
}
for (i=0; i < num_of_files; i++) {
free(filez[i]);
}
num_of_files = getdirectory(filez, disksSubDir, hide_parent);
if (num_of_files < 18) {
paging = num_of_files;
}
}
free(tmp2);
} else {
// go into subdirectory
pushdir(disksSubDir);
menuSelection = 0;
paging = 18;
strcpy(disksSubDir, tmp);
int i;
for (i=0; i < num_of_files; i++) {
free(filez[i]);
}
num_of_files = getdirectory(filez, disksSubDir, false);
if (num_of_files < 18) {
paging = num_of_files;
}
}
} else {
// Select diskimage
write_log ("Old Disk Image: %s\n", changed_prefs.floppyslots[drive].df);
strncpy(changed_prefs.floppyslots[drive].df, tmp, 255);
write_log ("Selected Disk Image: %s\n", changed_prefs.floppyslots[drive].df);
loadloopdone = 1;
}
}
free(tmp);
kb = 0;
}
if (menuSelection < 0) { menuSelection = 0; }
if (menuSelection >= num_of_files) { menuSelection = num_of_files-1; }
if (menuSelection > (bas + paging - 1)) { bas += 1; }
if (menuSelection < bas) { bas -= 1; }
if ((bas + paging) > num_of_files) { bas = (num_of_files - paging); }
// background
SDL_BlitSurface (pMenu_Surface, NULL, tmpSDLScreen, NULL);
// texts
int lineOffset = 0;
for (currLine = bas; currLine < (bas + paging); currLine++) {
if (menuSelection == currLine) {
text_color.r = 255; text_color.g = 100; text_color.b = 100;
}
write_text (10, (lineOffset*10) + 25, filez[currLine]);
if (menuSelection == currLine) {
text_color.r = 0; text_color.g = 0; text_color.b = 0;
}
lineOffset++;
}
write_text (25, 5, msg);
write_text (15, 238, msg_status);
SDL_BlitSurface (tmpSDLScreen, NULL, display, NULL);
#ifdef TOUCHUI
SDL_TUI_UpdateAll();
#endif
redraw_frame();
} //while done
free(filez);
pMenu_Surface = SDL_LoadBMP("images/menu_load.bmp");
return;
}
...@@ -18,12 +18,15 @@ extern SDL_Color text_color; ...@@ -18,12 +18,15 @@ extern SDL_Color text_color;
extern char msg[50]; extern char msg[50];
extern char msg_status[50]; extern char msg_status[50];
int prefz (int parametre) { int prefz (void) {
SDL_Event event; SDL_Event event;
if (display == NULL) { if (display == NULL) {
gui_init(); gui_init();
} }
sprintf(msg, "%s", " ");
sprintf(msg_status, "%s", " ");
pMenu_Surface = SDL_LoadBMP("images/menu_tweak.bmp"); pMenu_Surface = SDL_LoadBMP("images/menu_tweak.bmp");
int prefsloopdone = 0; int prefsloopdone = 0;
...@@ -55,15 +58,13 @@ int prefz (int parametre) { ...@@ -55,15 +58,13 @@ int prefz (int parametre) {
char* p_floppy[]= {"0","100","200","300"}; //3 char* p_floppy[]= {"0","100","200","300"}; //3
int defaults[] = {0,0,0,0,0,0,0,0}; int defaults[] = {0,0,0,0,0,0,0,0};
// defaults[0] = changed_prefs.cpu_level;
defaults[0] = changed_prefs.cpu_model; defaults[0] = changed_prefs.cpu_model;
if (changed_prefs.address_space_24 != 0) { if (changed_prefs.address_space_24 != 0) {
// if (changed_prefs.cpu_level == 2) { defaults[0] = 4; }
// if (changed_prefs.cpu_level == 3) { defaults[0] = 5; }
if (changed_prefs.cpu_model == 2) { defaults[0] = 4; } if (changed_prefs.cpu_model == 2) { defaults[0] = 4; }
if (changed_prefs.cpu_model == 3) { defaults[0] = 5; } if (changed_prefs.cpu_model == 3) { defaults[0] = 5; }
} }
defaults[1] = changed_prefs.m68k_speed; //defaults[1] = changed_prefs.m68k_speed;
defaults[1] = 0;
defaults[2] = changed_prefs.chipset_mask; defaults[2] = changed_prefs.chipset_mask;
defaults[3] = changed_prefs.chipmem_size; defaults[3] = changed_prefs.chipmem_size;
defaults[4] = changed_prefs.fastmem_size; defaults[4] = changed_prefs.fastmem_size;
...@@ -83,26 +84,26 @@ int prefz (int parametre) { ...@@ -83,26 +84,26 @@ int prefz (int parametre) {
if (event.type == SDL_QUIT) { if (event.type == SDL_QUIT) {
prefsloopdone = 1; prefsloopdone = 1;
} }
#if GP2X
if (event.type == SDL_JOYBUTTONDOWN) { if (event.type == SDL_JOYBUTTONDOWN) {
switch (event.jbutton.button) { switch (event.jbutton.button) {
#if 0
case GP2X_BUTTON_UP: menuSelection--; break; case GP2X_BUTTON_UP: menuSelection--; break;
case GP2X_BUTTON_DOWN: menuSelection++; break; case GP2X_BUTTON_DOWN: menuSelection++; break;
case GP2X_BUTTON_LEFT: kleft = 1; break; case GP2X_BUTTON_LEFT: kleft = 1; break;
case GP2X_BUTTON_RIGHT: kright = 1; break; case GP2X_BUTTON_RIGHT: kright = 1; break;
case GP2X_BUTTON_SELECT: prefsloopdone = 1; break; case GP2X_BUTTON_SELECT: prefsloopdone = 1; break;
case GP2X_BUTTON_B: prefsloopdone = 1; break; case GP2X_BUTTON_B: prefsloopdone = 1; break;
#endif
} }
} }
if (event.type == SDL_KEYDOWN) { #endif
switch (event.key.keysym.sym) { if (event.type == SDL_KEYDOWN) {
switch (event.key.keysym.sym) {
case SDLK_ESCAPE: prefsloopdone = 1; break; case SDLK_ESCAPE: prefsloopdone = 1; break;
case SDLK_UP: menuSelection--; break; case SDLK_UP: menuSelection--; break;
case SDLK_DOWN: menuSelection++; break; case SDLK_DOWN: menuSelection++; break;
case SDLK_LEFT: kleft = 1; break; case SDLK_LEFT: kleft = 1; break;
case SDLK_RIGHT: kright = 1; break; case SDLK_RIGHT: kright = 1; break;
case SDLK_b: prefsloopdone = 1; break; case SDLK_RETURN: prefsloopdone = 1; break;
default: break; default: break;
} }
} }
...@@ -158,17 +159,18 @@ int prefz (int parametre) { ...@@ -158,17 +159,18 @@ int prefz (int parametre) {
if (menuSelection < 0) { menuSelection = 8; } if (menuSelection < 0) { menuSelection = 8; }
if (menuSelection > 8) { menuSelection = 0; } if (menuSelection > 8) { menuSelection = 0; }
// background
// background
SDL_BlitSurface (pMenu_Surface,NULL,tmpSDLScreen,NULL); SDL_BlitSurface (pMenu_Surface,NULL,tmpSDLScreen,NULL);
// texts // texts
int sira = 0; int sira = 0;
int skipper = 0; int skipper = 0;
for (q=0; q<9; q++) { for (q=0; q<8; q++) {
if (menuSelection == q) { if (menuSelection == q) {
text_color.r = 150; text_color.g = 50; text_color.b = 50; text_color.r = 150; text_color.g = 50; text_color.b = 50;
} }
write_text (10,skipper+25+(sira*10),prefs[q]); // write_text (10, skipper+25+(sira*10), prefs[q]); //
if (q == 0) { write_text (130, skipper+25+(sira*10), p_cpu[defaults[q]]); } if (q == 0) { write_text (130, skipper+25+(sira*10), p_cpu[defaults[q]]); }
if (q == 1) { if (q == 1) {
...@@ -194,10 +196,10 @@ int prefz (int parametre) { ...@@ -194,10 +196,10 @@ int prefz (int parametre) {
sira++; sira++;
} }
write_text (25,6,msg); // write_text (25, 5, msg); //
write_text (25,240,msg_status); // write_text (25, 230, msg_status); //
SDL_BlitSurface (tmpSDLScreen,NULL,display,NULL); SDL_BlitSurface (tmpSDLScreen, NULL, display, NULL);
#ifdef TOUCHUI #ifdef TOUCHUI
SDL_TUI_UpdateAll(); SDL_TUI_UpdateAll();
#endif #endif
......
#include "sysconfig.h" #include "sysconfig.h"
#include "sysdeps.h" #include "sysdeps.h"
#include "options.h" #include "options.h"
#include "SDL.h" #include "SDL.h"
#include "SDL_image.h" #include "SDL_image.h"
#include "SDL_ttf.h" #include "SDL_ttf.h"
...@@ -16,62 +16,48 @@ ...@@ -16,62 +16,48 @@
extern void write_text(int x, int y, char* txt); extern void write_text(int x, int y, char* txt);
extern void blit_image(SDL_Surface* img, int x, int y); extern void blit_image(SDL_Surface* img, int x, int y);
extern int pushdir (char *directory);
extern char *popdir (void);
extern int getdirstackcount (void);
extern void freedirstack (void);
extern int getdirectory (char **filez, char *directory, bool hide_parent);
extern SDL_Surface* display; extern SDL_Surface* display;
extern SDL_Surface* tmpSDLScreen; extern SDL_Surface* tmpSDLScreen;
extern SDL_Surface* pMenu_Surface; extern SDL_Surface* pMenu_Surface;
extern SDL_Color text_color; extern SDL_Color text_color;
#define MAX_FILES 1024 #define MAX_FILES 1024
extern char yol[];
extern char msg[]; extern char msg[];
extern char msg_status[]; extern char msg_status[];
int dirz (int parametre) { int romz (void) {
char launchDir[256]; char subDir[MAX_PATH];
char launchDir[MAX_PATH];
SDL_Event event; SDL_Event event;
int getdir = 1; int getdir = 1;
pMenu_Surface = SDL_LoadBMP("images/menu_load.bmp"); pMenu_Surface = SDL_LoadBMP("images/menu_load.bmp");
int loadloopdone = 0; int loadloopdone = 0;
int num_of_files = 0; int num_of_files = 0;
int menuSelection = 0; int menuSelection = 0;
int q; int currLine;
int bas = 0; int bas = 0;
int ka = 0;
int kb = 0; int kb = 0;
char **filez = (char **)malloc(MAX_FILES*sizeof(char *)); char **filez = (char **)malloc(MAX_FILES * sizeof(char *));
if (display == NULL) { if (display == NULL) {
gui_init(); gui_init();
} }
sprintf(msg, "%s", "Select Kickstart ROM");
sprintf(msg_status, "%s", " ");
getcwd(launchDir, MAX_PATH);
int i;
int paging = 18; int paging = 18;
DIR *d=opendir(yol); strcpy(subDir, "roms");
struct dirent *ep;
num_of_files = getdirectory(filez, subDir, true);
getcwd(launchDir,256); if (num_of_files < 18) {
if (d != NULL) {
for(i=0;i<MAX_FILES;i++) {
ep = readdir(d);
if (ep == NULL) {
break;
} else {
struct stat sstat;
char *tmp=(char *)calloc(1,256);
strcpy(tmp,launchDir);
strcat(tmp,"/");
strcat(tmp,ep->d_name);
filez[i]=(char*)malloc(64);
strncpy(filez[i],ep->d_name,64);
num_of_files++;
free(tmp);
}
}
closedir(d);
}
if (num_of_files<18) {
paging = num_of_files; paging = num_of_files;
} }
...@@ -83,75 +69,82 @@ int dirz (int parametre) { ...@@ -83,75 +69,82 @@ int dirz (int parametre) {
if (event.type == SDL_QUIT) { if (event.type == SDL_QUIT) {
loadloopdone = 1; loadloopdone = 1;
} }
#if GP2X
if (event.type == SDL_JOYBUTTONDOWN) { if (event.type == SDL_JOYBUTTONDOWN) {
switch (event.jbutton.button) { switch (event.jbutton.button) {
#if 0
case GP2X_BUTTON_UP: menuSelection -= 1; break; case GP2X_BUTTON_UP: menuSelection -= 1; break;
case GP2X_BUTTON_DOWN: menuSelection += 1; break; case GP2X_BUTTON_DOWN: menuSelection += 1; break;
case GP2X_BUTTON_A: ka = 1; break;
case GP2X_BUTTON_B: kb = 1; break; case GP2X_BUTTON_B: kb = 1; break;
case GP2X_BUTTON_SELECT: loadloopdone = 1; break; case GP2X_BUTTON_SELECT: loadloopdone = 1; break;
#endif
} }
} }
if (event.type == SDL_KEYDOWN) { #endif
switch (event.key.keysym.sym) { if (event.type == SDL_KEYDOWN) {
case SDLK_ESCAPE: loadloopdone = 1; break; switch (event.key.keysym.sym) {
case SDLK_UP: menuSelection -= 1; break; case SDLK_ESCAPE: loadloopdone = 1; break;
case SDLK_DOWN: menuSelection += 1; break; case SDLK_UP: menuSelection -= 1; break;
case SDLK_a: ka = 1; break; case SDLK_DOWN: menuSelection += 1; break;
case SDLK_b: kb = 1; break; case SDLK_RETURN: kb = 1; break;
default: break; default: break;
} }
} }
} }
if (parametre == 0) { if (kb == 1) {
if (ka == 1) { //df1 // Check if a directory was selected
// Select Disk Image struct stat sstat;
char *tmp=(char *)calloc(1,256); char *tmp = (char *)calloc(1, MAX_PATH);
//strcpy(tmp,launchDir); strcpy(tmp, subDir);
strcat(tmp,"disks/"); strcat(tmp, "/");
strcat(tmp,filez[menuSelection]); strcat(tmp, filez[menuSelection]);
//strcpy(changed_prefs.floppyslots[1].df,tmp); if (stat(tmp, &sstat) != -1) {
write_log ("Old Disk Image: %s\n", changed_prefs.floppyslots[1].df); if (sstat.st_mode & S_IFDIR) {
strncpy(changed_prefs.floppyslots[1].df, tmp, 255); // Select subdirectory
write_log ("Selected Disk Image: %s\n", changed_prefs.floppyslots[1].df); if (strcasecmp(filez[menuSelection], "..") == 0) {
free(tmp); // Back to parent
char *tmp2 = NULL;
loadloopdone = 1; tmp2 = popdir();
ka = 0; if (tmp2) {
} menuSelection = 0;
if (kb == 1) { //df0; paging = 18;
// Select Disk Image strcpy(subDir, tmp2);
char *tmp=(char *)calloc(1,256); int i;
//strcpy(tmp,launchDir); bool hide_parent = false;
strcat(tmp,"disks/"); if (getdirstackcount() == 0) {
strcat(tmp,filez[menuSelection]); hide_parent = true;
//strcpy(changed_prefs.floppyslots[0].df,tmp); }
write_log ("Old Disk Image: %s\n", changed_prefs.floppyslots[0].df); for (i=0; i < num_of_files; i++) {
strncpy(changed_prefs.floppyslots[0].df, tmp, 255); free(filez[i]);
write_log ("Selected Disk Image: %s\n", changed_prefs.floppyslots[0].df); }
free(tmp); num_of_files = getdirectory(filez, subDir, hide_parent);
if (num_of_files < 18) {
loadloopdone = 1; paging = num_of_files;
kb = 0; }
} }
} else { free(tmp2);
if (kb == 1) { } else {
// Select KickStart ROM // go into subdirectory
char *tmp=(char *)calloc(1,256); pushdir(subDir);
//strcpy(tmp,launchDir); menuSelection = 0;
strcat(tmp,"roms/"); paging = 18;
strcat(tmp,filez[menuSelection]); strcpy(subDir, tmp);
//strcpy(changed_prefs.romfile,tmp); int i;
write_log ("Old KickStart ROM: %s\n", changed_prefs.romfile); for (i=0; i < num_of_files; i++) {
strncpy(changed_prefs.romfile, tmp, 255); free(filez[i]);
write_log ("Selected KickStart ROM: %s\n", changed_prefs.romfile); }
free(tmp); num_of_files = getdirectory(filez, subDir, false);
if (num_of_files < 18) {
loadloopdone = 1; paging = num_of_files;
}
}
} else {
// Select kickstart rom
write_log ("Old KickStart ROM: %s\n", changed_prefs.romfile);
strncpy(changed_prefs.romfile, tmp, 255);
write_log ("Selected KickStart ROM: %s\n", changed_prefs.romfile);
loadloopdone = 1;
}
} }
ka = 0; free(tmp);
kb = 0; kb = 0;
} }
...@@ -161,24 +154,24 @@ int dirz (int parametre) { ...@@ -161,24 +154,24 @@ int dirz (int parametre) {
if (menuSelection < bas) { bas -= 1; } if (menuSelection < bas) { bas -= 1; }
if ((bas+paging) > num_of_files) { bas = (num_of_files - paging); } if ((bas+paging) > num_of_files) { bas = (num_of_files - paging); }
// background // background
SDL_BlitSurface (pMenu_Surface,NULL,tmpSDLScreen,NULL); SDL_BlitSurface (pMenu_Surface, NULL, tmpSDLScreen, NULL);
// texts // texts
int sira = 0; int lineOffset = 0;
for (q=bas; q<(bas+paging); q++) { for (currLine = bas; currLine < (bas + paging); currLine++) {
if (menuSelection == q) { if (menuSelection == currLine) {
text_color.r = 255; text_color.g = 100; text_color.b = 100; text_color.r = 255; text_color.g = 100; text_color.b = 100;
} }
write_text (10,25+(sira*10),filez[q]); // write_text (10, (lineOffset * 10) + 25, filez[currLine]);
if (menuSelection == q) { if (menuSelection == currLine) {
text_color.r = 0; text_color.g = 0; text_color.b = 0; text_color.r = 0; text_color.g = 0; text_color.b = 0;
} }
sira++; lineOffset++;
} }
write_text (25,3,msg); write_text (25, 5, msg);
write_text (15,228,msg_status); write_text (15, 238, msg_status);
SDL_BlitSurface (tmpSDLScreen,NULL,display,NULL); SDL_BlitSurface (tmpSDLScreen,NULL,display,NULL);
#ifdef TOUCHUI #ifdef TOUCHUI
...@@ -188,6 +181,7 @@ int dirz (int parametre) { ...@@ -188,6 +181,7 @@ int dirz (int parametre) {
} //while done } //while done
free(filez); free(filez);
freedirstack();
pMenu_Surface = SDL_LoadBMP("images/menu.bmp"); pMenu_Surface = SDL_LoadBMP("images/menu.bmp");
return 0; return 0;
......
#include "sysconfig.h" #include "sysconfig.h"
#include "sysdeps.h" #include "sysdeps.h"
#include "options.h" #include "options.h"
#include "SDL.h" #include "SDL.h"
...@@ -10,8 +9,8 @@ ...@@ -10,8 +9,8 @@
#include <SDL_TouchUI.h> #include <SDL_TouchUI.h>
#endif #endif
extern void write_text(int x, int y, char* txt); extern void write_text (int x, int y, char* txt);
extern void blit_image(SDL_Surface* img, int x, int y); extern void blit_image (SDL_Surface* img, int x, int y);
extern SDL_Surface* display; extern SDL_Surface* display;
extern SDL_Surface* tmpSDLScreen; extern SDL_Surface* tmpSDLScreen;
extern SDL_Surface* pMenu_Surface; extern SDL_Surface* pMenu_Surface;
...@@ -19,10 +18,11 @@ extern SDL_Color text_color; ...@@ -19,10 +18,11 @@ extern SDL_Color text_color;
extern char msg[50]; extern char msg[50];
extern char msg_status[50]; extern char msg_status[50];
int tweakz (int parametre) { int tweakz (void) {
#ifdef GP2X
SDL_Event event; SDL_Event event;
pMenu_Surface = SDL_LoadBMP("images/menu_tweak.bmp"); pMenu_Surface = SDL_LoadBMP("images/menu_tweak.bmp");
int tweakloopdone = 0; int tweakloopdone = 0;
int kup = 0; int kup = 0;
int kdown = 0; int kdown = 0;
...@@ -30,26 +30,42 @@ int tweakz (int parametre) { ...@@ -30,26 +30,42 @@ int tweakz (int parametre) {
int kright = 0; int kright = 0;
int kb = 0; int kb = 0;
int menuSelection = 0; int menuSelection = 0;
int q; int currLine;
char* tweaks[] = {"CPU Mhz","tRC","tRAS","tWR","tMRD","tRFC","tRP","tRCD","PLL","Timing","Default (200mhz)","Default (266mhz)","Evil Dragon (266mhz)"}; char* tweaks[] = {
int defaults[] = {200,8,16,3,8,8,8,8,1,1}; "CPU Mhz",
int def_slow_tweak[] = {200,8,16,3,8,8,8,8,1,1}; "tRC",
int def_fast_tweak[] = {266,8,16,3,8,8,8,8,1,1}; "tRAS",
int evil_tweak[] = {266,6,4,1,1,1,2,2,1,1}; "tWR",
"tMRD",
"tRFC",
"tRP",
"tRCD",
"PLL",
"Timing",
"Default (200mhz)",
"Default (266mhz)",
"Evil Dragon (266mhz)"
};
int defaults[] = {200, 8, 16, 3, 8, 8, 8, 8, 1, 1};
int def_slow_tweak[] = {200, 8, 16, 3, 8, 8, 8, 8, 1, 1};
int def_fast_tweak[] = {266, 8, 16, 3, 8, 8, 8, 8, 1, 1};
int evil_tweak[] = {266, 6, 4, 1, 1, 1, 2, 2, 1, 1};
char *tmp; char *tmp;
tmp=(char*)malloc(5); tmp = (char*)malloc(5);
if (display == NULL) { if (display == NULL) {
gui_init(); gui_init();
} }
sprintf(msg, "%s", "Tweaks");
sprintf(msg_status, "%s", "L/R = -/+ B: Apply");
#ifdef GP2X unsigned sysfreq = 0;
unsigned sysfreq=0;
int cpufreq; int cpufreq;
sysfreq = get_freq_920_CLK(); sysfreq = get_freq_920_CLK();
sysfreq*= get_920_Div()+1; sysfreq* = get_920_Div() + 1;
cpufreq = sysfreq/1000000; cpufreq = sysfreq / 1000000;
defaults[0] = cpufreq; defaults[0] = cpufreq;
defaults[1] = get_tRC(); defaults[1] = get_tRC();
...@@ -59,66 +75,58 @@ int tweakz (int parametre) { ...@@ -59,66 +75,58 @@ int tweakz (int parametre) {
defaults[5] = get_tRFC(); defaults[5] = get_tRFC();
defaults[6] = get_tRP(); defaults[6] = get_tRP();
defaults[7] = get_tRCD(); defaults[7] = get_tRCD();
#endif
while (!tweakloopdone) { while (!tweakloopdone) {
while (SDL_PollEvent(&event)) { while (SDL_PollEvent(&event)) {
#ifdef TOUCHUI
SDL_TUI_HandleEvent(&event);
#endif
if (event.type == SDL_QUIT) { tweakloopdone = 1; } if (event.type == SDL_QUIT) { tweakloopdone = 1; }
if (event.type == SDL_JOYBUTTONDOWN) { if (event.type == SDL_JOYBUTTONDOWN) {
switch (event.jbutton.button) { switch (event.jbutton.button) {
#if 0
case GP2X_BUTTON_UP: menuSelection--; break; case GP2X_BUTTON_UP: menuSelection--; break;
case GP2X_BUTTON_DOWN: menuSelection++; break; case GP2X_BUTTON_DOWN: menuSelection++; break;
case GP2X_BUTTON_LEFT: kleft = 1; break; case GP2X_BUTTON_LEFT: kleft = 1; break;
case GP2X_BUTTON_RIGHT: kright = 1; break; case GP2X_BUTTON_RIGHT: kright = 1; break;
case GP2X_BUTTON_SELECT: tweakloopdone = 1; break; case GP2X_BUTTON_SELECT: tweakloopdone = 1; break;
case GP2X_BUTTON_B: kb =1; break; case GP2X_BUTTON_B: kb = 1; break;
#endif
} }
} }
if (event.type == SDL_KEYDOWN) { if (event.type == SDL_KEYDOWN) {
switch (event.key.keysym.sym) { switch (event.key.keysym.sym) {
case SDLK_ESCAPE: tweakloopdone = 1; break; case SDLK_ESCAPE: tweakloopdone = 1; break;
case SDLK_UP: menuSelection--; break; case SDLK_UP: menuSelection--; break;
case SDLK_DOWN: menuSelection++; break; case SDLK_DOWN: menuSelection++; break;
case SDLK_LEFT: kleft = 1; break; case SDLK_LEFT: kleft = 1; break;
case SDLK_RIGHT: kright = 1; break; case SDLK_RIGHT: kright = 1; break;
case SDLK_b: kb = 1; break; case SDLK_RETURN: kb = 1; break;
default: break; default: break;
} }
} }
} }
if (kb == 1) { if (kb == 1) {
if (menuSelection == 10) { if (menuSelection == 10) {
for (q=0; q<10;q++) { defaults[q] = def_slow_tweak[q]; } for (currLine = 0; currLine < 10; currLine++) { defaults[currLine] = def_slow_tweak[currLine]; }
} }
if (menuSelection == 11) { if (menuSelection == 11) {
for (q=0; q<10;q++) { defaults[q] = def_fast_tweak[q]; } for (currLine = 0; currLine < 10; currLine++) { defaults[currLine] = def_fast_tweak[currLine]; }
} }
if (menuSelection == 12) { if (menuSelection == 12) {
for (q=0; q<10;q++) { defaults[q] = evil_tweak[q]; } for (currLine = 0; currLine < 10; currLine++) { defaults[currLine] = evil_tweak[currLine]; }
} }
if (menuSelection < 10) { if (menuSelection < 10) {
#if 0
//apply //apply
//printf("FLCK: %d",0); set_CAS(0); //printf("FLCK: %d",0); set_CAS(0);
printf("FLCK: %d",defaults[0]); set_FCLK(defaults[0]); printf("FLCK: %d", defaults[0]); set_FCLK(defaults[0]);
printf("tRC : %d",defaults[1]); set_tRC(defaults[1]-1); printf("tRC : %d", defaults[1]); set_tRC(defaults[1] - 1);
printf("tRAS: %d",defaults[2]); set_tRAS(defaults[2]-1); printf("tRAS: %d", defaults[2]); set_tRAS(defaults[2] - 1);
printf("tWR : %d",defaults[3]); set_tWR(defaults[3]-1); printf("tWR : %d", defaults[3]); set_tWR(defaults[3] - 1);
printf("tMRD: %d",defaults[4]); set_tMRD(defaults[4]-1); printf("tMRD: %d", defaults[4]); set_tMRD(defaults[4] - 1);
printf("tRFC: %d",defaults[5]); set_tRFC(defaults[5]-1); printf("tRFC: %d", defaults[5]); set_tRFC(defaults[5] - 1);
printf("tRP : %d",defaults[6]); set_tRP(defaults[6]-1); printf("tRP : %d", defaults[6]); set_tRP(defaults[6] - 1);
printf("tRCD: %d",defaults[7]); set_tRCD(defaults[7]-1); printf("tRCD: %d", defaults[7]); set_tRCD(defaults[7] - 1);
if (defaults[8] == 0) { if (defaults[8] == 0) {
printf("FLCD: %d",defaults[9]); set_add_FLCDCLK(defaults[9]-1); printf("FLCD: %d", defaults[9]); set_add_FLCDCLK(defaults[9] - 1);
} else { } else {
printf("ULCD: %d",defaults[9]); set_add_ULCDCLK(defaults[9]-1); printf("ULCD: %d", defaults[9]); set_add_ULCDCLK(defaults[9] - 1);
} }
#endif
tweakloopdone = 1; tweakloopdone = 1;
} }
kb = 0; kb = 0;
...@@ -156,46 +164,44 @@ int tweakz (int parametre) { ...@@ -156,46 +164,44 @@ int tweakz (int parametre) {
if (menuSelection < 0) { menuSelection = 12; } if (menuSelection < 0) { menuSelection = 12; }
if (menuSelection > 12) { menuSelection = 0; } if (menuSelection > 12) { menuSelection = 0; }
// background // background
SDL_BlitSurface (pMenu_Surface,NULL,tmpSDLScreen,NULL); SDL_BlitSurface(pMenu_Surface, NULL, tmpSDLScreen, NULL);
// texts // texts
int sira = 0; int lineOffset = 0;
int skipper = 0; int skipper = 0;
for (q=0; q<13; q++) { for (currLine = 0; currLine < 13; currLine++) {
if (q == 10) { skipper = 30; } if (currLine == 10) { skipper = 30; }
if (menuSelection == q) { if (menuSelection == currLine) {
text_color.r = 255; text_color.g = 100; text_color.b = 100; text_color.r = 255; text_color.g = 100; text_color.b = 100;
} }
write_text (10,skipper+25+(sira*10),tweaks[q]); // write_text(10, skipper + 25 + (lineOffset*10), tweaks[currLine]);
if (q <10) { if (currLine < 10) {
if (q == 8) { if (currLine == 8) {
if (defaults[8] == 0) { if (defaults[8] == 0) {
sprintf(tmp,"%s","FPLL"); sprintf(tmp, "%s", "FPLL");
} else { } else {
sprintf(tmp,"%s","UPLL"); sprintf(tmp, "%s", "UPLL");
} }
} else { } else {
sprintf(tmp,"%d",defaults[q]); sprintf(tmp, "%d", defaults[currLine]);
} }
write_text (100,skipper+25+(sira*10),tmp); write_text(100, skipper + 25 + (lineOffset*10), tmp);
} }
if (menuSelection == q) { if (menuSelection == currLine) {
text_color.r = 0; text_color.g = 0; text_color.b = 0; text_color.r = 0; text_color.g = 0; text_color.b = 0;
} }
sira++; lineOffset++;
} }
write_text (25,3,msg); write_text(25, 5, msg);
write_text (15,228,msg_status); write_text(15, 238, msg_status);
SDL_BlitSurface (tmpSDLScreen,NULL,display,NULL); SDL_BlitSurface(tmpSDLScreen, NULL, display, NULL);
#ifdef TOUCHUI
SDL_TUI_UpdateAll();
#endif
redraw_frame(); redraw_frame();
} //while done } //while done
pMenu_Surface = SDL_LoadBMP("images/menu.bmp"); pMenu_Surface = SDL_LoadBMP("images/menu.bmp");
#endif
return 0; return 0;
} }
...@@ -3,18 +3,18 @@ ...@@ -3,18 +3,18 @@
#define VKBD_X 20 #define VKBD_X 20
#define VKBD_Y 200 #define VKBD_Y 200
#define VKBD_LEFT 1 #define VKBD_LEFT 1
#define VKBD_RIGHT 2 #define VKBD_RIGHT 2
#define VKBD_UP 4 #define VKBD_UP 4
#define VKBD_DOWN 8 #define VKBD_DOWN 8
#define VKBD_BUTTON 16 #define VKBD_BUTTON 16
#define VKBD_BUTTON2 32 #define VKBD_BUTTON2 32
int vkbd_init(void); int vkbd_init (void);
void vkbd_quit(void); void vkbd_quit (void);
void vkbd_redraw(void); void vkbd_redraw (void);
SDLKey vkbd_process(void); SDLKey vkbd_process (void);
void vkbd_init_button2(void); void vkbd_init_button2 (void);
extern int vkbd_mode; extern int vkbd_mode;
extern int vkbd_move; extern int vkbd_move;
......
#include <SDL.h> #include <SDL.h>
#include "volumecontrol.h" #include "volumecontrol.h"
extern SDL_Surface *prSDLScreen; extern SDL_Surface *prSDLScreen;
static SDL_Surface *ksur; static SDL_Surface *ksur;
//int show_volumecontrol = 0; int show_volumecontrol = 0;
int volumecontrol_init(void) int volumecontrol_init (void) {
{
// don't know if we'll ever need anything here. // don't know if we'll ever need anything here.
return 0; return 0;
} }
void volumecontrol_redraw(void) void volumecontrol_redraw (void) {
{
/*
SDL_Rect r; SDL_Rect r;
SDL_Surface* surface; SDL_Surface* surface;
int i; int i;
Uint32 green = SDL_MapRGB(prSDLScreen->format, 250,250,0); Uint32 green = SDL_MapRGB(prSDLScreen->format, 250, 250, 0);
r.x = 110; r.x = 110;
r.y = prSDLScreen->h-30; r.y = prSDLScreen->h-30;
r.w = soundVolume; //r.w = soundVolume;
r.w = 50;
r.h = 15; r.h = 15;
// draw the blocks now // draw the blocks now
SDL_FillRect(prSDLScreen, &r, green); SDL_FillRect(prSDLScreen, &r, green);
SDL_BlitSurface(surface,NULL,prSDLScreen,&r); SDL_BlitSurface(surface, NULL, prSDLScreen, &r);
*/
} }
int volumecontrol_init(void); int volumecontrol_init (void);
void volumecontrol_redraw(void); void volumecontrol_redraw (void);
extern int show_volumecontrol; extern int show_volumecontrol;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment