Code cleanup

Removed unneeded code
This commit is contained in:
Dimitris Panokostas 2017-01-21 23:56:00 +01:00
parent ccd65acb1f
commit e5c5eddda6
7 changed files with 107 additions and 235 deletions

1
.gitignore vendored
View file

@ -26,3 +26,4 @@ Amiberry/VisualGDB/Release/Amiberry
*.TMP
VisualGDB/VisualGDB/Release/Amiberry
VisualGDB/VisualGDB/Debug/Amiberry
*.npa00-a6b8830a

View file

@ -641,7 +641,8 @@ static int real_main2 (int argc, TCHAR **argv)
{
printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
abort();
};
}
;
sdlWindow = SDL_CreateWindow("Amiberry v2",
SDL_WINDOWPOS_UNDEFINED,
@ -666,57 +667,57 @@ static int real_main2 (int argc, TCHAR **argv)
keyboard_settrans();
if (restart_config[0]) {
default_prefs (&currprefs, 0);
fixup_prefs (&currprefs);
}
if (restart_config[0]) {
default_prefs(&currprefs, 0);
fixup_prefs(&currprefs);
}
if (! graphics_setup ()) {
abort();
}
if (!graphics_setup()) {
abort();
}
if (restart_config[0])
parse_cmdline_and_init_file (argc, argv);
else
currprefs = changed_prefs;
if (restart_config[0])
parse_cmdline_and_init_file(argc, argv);
else
currprefs = changed_prefs;
if (!machdep_init ()) {
restart_program = 0;
return -1;
}
if (!machdep_init()) {
restart_program = 0;
return -1;
}
if (! setup_sound ()) {
write_log (_T("Sound driver unavailable: Sound output disabled\n"));
currprefs.produce_sound = 0;
}
if (!setup_sound()) {
write_log(_T("Sound driver unavailable: Sound output disabled\n"));
currprefs.produce_sound = 0;
}
inputdevice_init();
inputdevice_init();
changed_prefs = currprefs;
changed_prefs = currprefs;
no_gui = ! currprefs.start_gui;
if (restart_program == 2)
no_gui = 1;
else if (restart_program == 3)
no_gui = 0;
restart_program = 0;
if (! no_gui) {
int err = gui_init ();
currprefs = changed_prefs;
if (err == -1) {
write_log (_T("Failed to initialize the GUI\n"));
return -1;
} else if (err == -2) {
return 1;
}
}
else
{
setCpuSpeed();
update_display(&currprefs);
}
no_gui = !currprefs.start_gui;
if (restart_program == 2)
no_gui = 1;
else if (restart_program == 3)
no_gui = 0;
restart_program = 0;
if (!no_gui) {
int err = gui_init();
currprefs = changed_prefs;
if (err == -1) {
write_log(_T("Failed to initialize the GUI\n"));
return -1;
}
else if (err == -2) {
return 1;
}
}
else
{
update_display(&currprefs);
}
memset (&gui_data, 0, sizeof gui_data);
memset(&gui_data, 0, sizeof gui_data);
gui_data.cd = -1;
gui_data.hd = -1;
@ -724,41 +725,41 @@ static int real_main2 (int argc, TCHAR **argv)
picasso_reset ();
#endif
fixup_prefs (&currprefs);
changed_prefs = currprefs;
target_run ();
fixup_prefs(&currprefs);
changed_prefs = currprefs;
target_run();
/* force sound settings change */
currprefs.produce_sound = 0;
currprefs.produce_sound = 0;
keybuf_init (); /* Must come after init_joystick */
keybuf_init(); /* Must come after init_joystick */
memory_hardreset (2);
memory_reset ();
memory_hardreset(2);
memory_reset();
#ifdef AUTOCONFIG
native2amiga_install ();
native2amiga_install();
#endif
custom_init (); /* Must come after memory_init */
DISK_init ();
custom_init(); /* Must come after memory_init */
DISK_init();
reset_frame_rate_hack ();
init_m68k(); /* must come after reset_frame_rate_hack (); */
reset_frame_rate_hack();
init_m68k(); /* must come after reset_frame_rate_hack (); */
gui_update ();
gui_update();
if (graphics_init (true)) {
if (graphics_init(true)) {
if(!init_audio ()) {
if (sound_available && currprefs.produce_sound > 1) {
write_log (_T("Sound driver unavailable: Sound output disabled\n"));
}
currprefs.produce_sound = 0;
}
if (!init_audio()) {
if (sound_available && currprefs.produce_sound > 1) {
write_log(_T("Sound driver unavailable: Sound output disabled\n"));
}
currprefs.produce_sound = 0;
}
gui_flicker_led(LED_POWER, 0, 1);
start_program ();
start_program();
}
return 0;
return 0;
}
void real_main (int argc, TCHAR **argv)

View file

@ -128,44 +128,6 @@ void RegisterRefreshFunc(void (*func)(void))
namespace sdl
{
void gui_init()
// {
// //-------------------------------------------------
// // Set layer for GUI screen
// //-------------------------------------------------
// char tmp[20];
// snprintf(tmp, 20, "%dx%d", GUI_WIDTH, GUI_HEIGHT);
// setenv("SDL_OMAP_LAYER_SIZE", tmp, 1);
// snprintf(tmp, 20, "0,0,0,0");
// setenv("SDL_OMAP_BORDER_CUT", tmp, 1);
//
// //-------------------------------------------------
// // Create new screen for GUI
// //-------------------------------------------------
// #if defined (RASPBERRY)
// const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
//#ifdef DEBUG
// printf("Current resolution: %d x %d %d bpp\n",videoInfo->current_w, videoInfo->current_h, videoInfo->vfmt->BitsPerPixel);
//#endif
// gui_screen = SDL_SetVideoMode(videoInfo->current_w, videoInfo->current_h, videoInfo->vfmt->BitsPerPixel, SDL_SWSURFACE | SDL_FULLSCREEN);
// #else
// gui_screen = SDL_SetVideoMode(GUI_WIDTH, GUI_HEIGHT, 16, SDL_SWSURFACE);
// #endif
// SDL_EnableUNICODE(1);
// SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
// SDL_ShowCursor(SDL_ENABLE);
//
// //-------------------------------------------------
// // Create helpers for guisan
// //-------------------------------------------------
// gui_imageLoader = new gcn::SDLImageLoader();
// gcn::Image::setImageLoader(gui_imageLoader);
// gui_graphics = new gcn::SDLGraphics();
// gui_graphics->setTarget(gui_screen);
// gui_input = new gcn::SDLInput();
// uae_gui = new gcn::Gui();
// uae_gui->setGraphics(gui_graphics);
// uae_gui->setInput(gui_input);
// }
{
//-------------------------------------------------
// Create new screen for GUI
@ -308,8 +270,6 @@ namespace sdl
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
// wait_for_vsync();
// SDL_Flip(gui_screen);
// Update the texture from the surface
SDL_UpdateTexture(texture, NULL, gui_screen->pixels, gui_screen->pitch);
@ -528,7 +488,6 @@ void gui_init()
//--------------------------------------------------
gui_top->add(cmdReset, DISTANCE_BORDER, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
gui_top->add(cmdQuit, DISTANCE_BORDER + BUTTON_WIDTH + DISTANCE_NEXT_X, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
// gui_top->add(cmdRestart, DISTANCE_BORDER + 2 * BUTTON_WIDTH + 2 * DISTANCE_NEXT_X, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
gui_top->add(cmdStart, GUI_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
gui_top->add(selectors, DISTANCE_BORDER + 1, DISTANCE_BORDER + 1);

View file

@ -71,10 +71,6 @@ static char rom_path[MAX_DPATH];
static char rp9_path[MAX_DPATH];
char last_loaded_config[MAX_DPATH] = { '\0' };
static bool cpuSpeedChanged = false;
static int lastCpuSpeed = 600;
int defaultCpuSpeed = 600;
int max_uae_width;
int max_uae_height;
@ -255,7 +251,6 @@ void target_default_options (struct uae_prefs *p, int type)
{
p->pandora_horizontal_offset = 0;
p->pandora_vertical_offset = 0;
p->pandora_cpu_speed = defaultCpuSpeed;
p->pandora_hide_idle_led = 0;
p->pandora_tapDelay = 10;
@ -685,78 +680,6 @@ bool SetVSyncRate(int hz)
return false;
}
void setCpuSpeed()
{
#ifdef PANDORA_SPECIFIC
char speedCmd[128];
currprefs.pandora_cpu_speed = changed_prefs.pandora_cpu_speed;
if(currprefs.pandora_cpu_speed != lastCpuSpeed)
{
snprintf((char*)speedCmd, 128, "unset DISPLAY; echo y | sudo -n /usr/pandora/scripts/op_cpuspeed.sh %d", currprefs.pandora_cpu_speed);
system(speedCmd);
lastCpuSpeed = currprefs.pandora_cpu_speed;
cpuSpeedChanged = true;
}
if(changed_prefs.ntscmode != currprefs.ntscmode)
{
if(changed_prefs.ntscmode)
SetVSyncRate(60);
else
SetVSyncRate(50);
}
#else
return;
#endif
}
int getDefaultCpuSpeed(void)
{
#ifdef PANDORA_SPECIFIC
int speed = 600;
FILE* f = fopen ("/etc/pandora/conf/cpu.conf", "rt");
if(f)
{
char line[128];
for(int i=0; i<6; ++i)
{
fscanf(f, "%s\n", &line);
if(strncmp(line, "default:", 8) == 0)
{
int value = 0;
sscanf(line, "default:%d", &value);
if(value > 500 && value < 1200)
{
speed = value;
}
}
}
fclose(f);
}
return speed;
#else
return 0;
#endif
}
void resetCpuSpeed(void)
{
#ifdef PANDORA_SPECIFIC
if(cpuSpeedChanged)
{
lastCpuSpeed = defaultCpuSpeed - 10;
currprefs.pandora_cpu_speed = changed_prefs.pandora_cpu_speed = defaultCpuSpeed;
setCpuSpeed();
}
#else
return;
#endif
}
void target_reset (void)
{
}
@ -787,8 +710,6 @@ int main (int argc, char *argv[])
max_uae_width = 768;
max_uae_height = 270;
defaultCpuSpeed = getDefaultCpuSpeed();
// Get startup path
getcwd(start_path_data, MAX_DPATH);
loadAdfDir();
@ -850,9 +771,6 @@ int main (int argc, char *argv[])
logging_cleanup();
// printf("Threads at exit:\n");
// dbg_list_threads();
return 0;
}

View file

@ -465,7 +465,7 @@ int gui_init (void)
if (quit_program == UAE_QUIT)
ret = -2; // Quit without start of emulator
setCpuSpeed();
// setCpuSpeed();
update_display(&changed_prefs);
after_leave_gui();
@ -476,7 +476,7 @@ int gui_init (void)
void gui_exit(void)
{
resetCpuSpeed();
// resetCpuSpeed();
sync();
pandora_stop_sound();
saveAdfDir();
@ -544,34 +544,30 @@ void gui_display (int shortcut)
{
if (quit_program != 0)
return;
emulating=1;
emulating = 1;
pause_sound();
blkdev_entergui();
blkdev_entergui();
if(lstAvailableROMs.size() == 0)
RescanROMs();
graphics_subshutdown();
prefs_to_gui();
run_gui();
gui_to_prefs();
setCpuSpeed();
// if(quit_program)
// screen_is_picasso = 0;
update_display(&changed_prefs);
if (lstAvailableROMs.size() == 0)
RescanROMs();
graphics_subshutdown();
prefs_to_gui();
run_gui();
gui_to_prefs();
update_display(&changed_prefs);
/* Clear menu garbage at the bottom of the screen */
black_screen_now();
reset_sound();
resume_sound();
blkdev_exitgui();
blkdev_exitgui();
after_leave_gui();
after_leave_gui();
gui_update ();
gui_update();
gui_purge_events();
fpscounter_reset();
gui_purge_events();
fpscounter_reset();
}
@ -589,7 +585,6 @@ extern char keyboard_type;
void gui_handle_events (void)
{
// Uint8 *keystate = SDL_GetKeyState(NULL);
const Uint8 *keystate = SDL_GetKeyboardState(NULL);
if (keystate[SDL_SCANCODE_LCTRL] && keystate[SDL_SCANCODE_LGUI] && (keystate[SDL_SCANCODE_RGUI] || keystate[SDL_SCANCODE_MENU]))

View file

@ -273,31 +273,30 @@ static int get_joystick_num (void)
static int init_joystick (void)
{
//This function is called too many times... we can filter if number of joy is good...
if (nr_joysticks == SDL_NumJoysticks ())
return 1;
if (nr_joysticks == SDL_NumJoysticks())
return 1;
nr_joysticks = SDL_NumJoysticks ();
if (nr_joysticks > MAX_INPUT_DEVICES)
nr_joysticks = MAX_INPUT_DEVICES;
for (int cpt; cpt < nr_joysticks; cpt++)
{
Joysticktable[cpt] = SDL_JoystickOpen (cpt);
// strncpy(JoystickName[cpt],SDL_JoystickName(cpt),80);
strncpy(JoystickName[cpt], SDL_JoystickNameForIndex(cpt), 80);
printf("Joystick %i : %s\n",cpt,JoystickName[cpt]);
printf(" Buttons: %i Axis: %i Hats: %i\n",SDL_JoystickNumButtons(Joysticktable[cpt]),SDL_JoystickNumAxes(Joysticktable[cpt]),SDL_JoystickNumHats(Joysticktable[cpt]));
nr_joysticks = SDL_NumJoysticks();
if (nr_joysticks > MAX_INPUT_DEVICES)
nr_joysticks = MAX_INPUT_DEVICES;
for (int cpt; cpt < nr_joysticks; cpt++)
{
Joysticktable[cpt] = SDL_JoystickOpen(cpt);
strncpy(JoystickName[cpt], SDL_JoystickNameForIndex(cpt), 80);
printf("Joystick %i : %s\n", cpt, JoystickName[cpt]);
printf(" Buttons: %i Axis: %i Hats: %i\n", SDL_JoystickNumButtons(Joysticktable[cpt]), SDL_JoystickNumAxes(Joysticktable[cpt]), SDL_JoystickNumHats(Joysticktable[cpt]));
if (strcmp(JoystickName[cpt],"Sony PLAYSTATION(R)3 Controller") == 0 ||
strcmp(JoystickName[cpt],"PLAYSTATION(R)3 Controller") == 0)
{
printf(" Found a dualshock controller: Activating workaround.\n");
IsPS3Controller[cpt] = 1;
}
else
IsPS3Controller[cpt] = 0;
}
if (strcmp(JoystickName[cpt], "Sony PLAYSTATION(R)3 Controller") == 0 ||
strcmp(JoystickName[cpt], "PLAYSTATION(R)3 Controller") == 0)
{
printf(" Found a dualshock controller: Activating workaround.\n");
IsPS3Controller[cpt] = 1;
}
else
IsPS3Controller[cpt] = 0;
}
return 1;
return 1;
}
static void close_joystick (void)
@ -422,7 +421,6 @@ static void read_joystick (void)
// First handle fake joystick from pandora...
if(currprefs.jports[joyid].id == JSEM_JOYS)
{
//// Uint8 *keystate = SDL_GetKeyState(NULL);
// const Uint8 *keystate = SDL_GetKeyboardState(NULL);
//
// if(!keystate[VK_R])

View file

@ -27,8 +27,8 @@ void wait_for_vsync(void);
void saveAdfDir(void);
bool SetVSyncRate(int hz);
void setCpuSpeed(void);
void resetCpuSpeed(void);
//void setCpuSpeed(void);
//void resetCpuSpeed(void);
void update_display(struct uae_prefs *);
void black_screen_now(void);
void graphics_subshutdown (void);