From 603f95cbf4a11241fc8a5eeb785d46d059cb1043 Mon Sep 17 00:00:00 2001 From: twinaphex <libretro@gmail.com> Date: Fri, 4 Sep 2015 20:45:02 +0200 Subject: [PATCH] Remove frontend_xenon.c - implement platform_xenon.c instead --- frontend/drivers/platform_xenon.c | 87 ++++++++++++ frontend/frontend_driver.c | 3 + frontend/frontend_driver.h | 1 + frontend/frontend_xenon.c | 229 ------------------------------ griffin/griffin.c | 6 +- 5 files changed, 93 insertions(+), 233 deletions(-) create mode 100644 frontend/drivers/platform_xenon.c delete mode 100644 frontend/frontend_xenon.c diff --git a/frontend/drivers/platform_xenon.c b/frontend/drivers/platform_xenon.c new file mode 100644 index 0000000000..21337841b6 --- /dev/null +++ b/frontend/drivers/platform_xenon.c @@ -0,0 +1,87 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2015 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see <http://www.gnu.org/licenses/>. + */ + +#include <stdint.h> +#include <boolean.h> +#include <stddef.h> +#include <string.h> + +#include <debug.h> +#include <xenos/xenos.h> +#include <diskio/ata.h> +#include <input/input.h> +#include <console/console.h> +#include <usb/usbmain.h> +#include <time/time.h> +#include <ppc/timebase.h> +#include <xenon_soc/xenon_power.h> +#include <elf/elf.h> + +#include "../../dynamic.h" +#include "../../libretro_private.h" + +static void frontend_xenon_init(void *data) +{ + (void)data; + xenos_init(VIDEO_MODE_AUTO); + console_init(); + xenon_make_it_faster(XENON_SPEED_FULL); + usb_init(); + usb_do_poll(); + xenon_ata_init(); +#if 0 + dvd_init(); +#endif +} + +static void frontend_xenon_shutdown(bool unused) +{ + (void)unused; +} + +static int frontend_xenon_get_rating(void) +{ + return -1; +} + +static void frontend_xenon_get_environment_settings(int *argc, char *argv[], + void *data, void *params_data) +{ +} + +enum frontend_architecture frontend_xenon_get_architecture(void) +{ + return FRONTEND_ARCH_PPC; +} + +frontend_ctx_driver_t frontend_ctx_qnx = { + frontend_xenon_get_environment_settings, + frontend_xenon_init, + NULL, /* deinit */ + NULL, /* exitspawn */ + NULL, /* process_args */ + NULL, /* exec */ + NULL, /* set_fork */ + frontend_xenon_shutdown, + NULL, /* get_name */ + NULL, /* get_os */ + frontend_xenon_get_rating, + NULL, /* load_content */ + frontend_xenon_get_architecture, + NULL, /* get_powerstate */ + NULL, /* parse_drive_list */ + "xenon", +}; diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index 4046425925..ba8c1ef707 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -52,6 +52,9 @@ static frontend_ctx_driver_t *frontend_ctx_drivers[] = { #endif #if defined(_WIN32) && !defined(_XBOX) &frontend_ctx_win32, +#endif +#ifdef XENON + &frontend_ctx_xenon, #endif &frontend_ctx_null, NULL diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index 30f5870467..bcf16f382a 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -86,6 +86,7 @@ extern frontend_ctx_driver_t frontend_ctx_linux; extern frontend_ctx_driver_t frontend_ctx_psp; extern frontend_ctx_driver_t frontend_ctx_ctr; extern frontend_ctx_driver_t frontend_ctx_win32; +extern frontend_ctx_driver_t frontend_ctx_xenon; extern frontend_ctx_driver_t frontend_ctx_null; /** diff --git a/frontend/frontend_xenon.c b/frontend/frontend_xenon.c deleted file mode 100644 index a5bce83e71..0000000000 --- a/frontend/frontend_xenon.c +++ /dev/null @@ -1,229 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2015 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see <http://www.gnu.org/licenses/>. - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <debug.h> -#include <xenos/xenos.h> -//#include <diskio/dvd.h> -#include <diskio/ata.h> -#include <input/input.h> -#include <console/console.h> -//#include <diskio/diskio.h> -#include <usb/usbmain.h> -#include <time/time.h> -#include <ppc/timebase.h> -#include <xenon_soc/xenon_power.h> -#include <elf/elf.h> -#include <dirent.h> -#include "../compat/strl.h" - -#define FG_COL -1 -#define BG_COL 0 - -#define MAX_FILES 1000 -#define STICK_THRESHOLD 25000 -#define MAX_DISPLAYED_ENTRIES 20 - -//#define MAX(a, b) (((a) > (b)) ? (a) : (b)) -//#define MIN(a, b) (((a) < (b)) ? (a) : (b)) - -static struct dirent entries[MAX_FILES]; -static int entrycount; - -static void load_dir(const char *path) -{ - DIR *d = opendir(path); - entrycount = 0; - - if (!d) - return; - - for (struct dirent *de = readdir(d); de; de = readdir(d)) - { - if (strcmp(de->d_name, ".")) - { - memcpy(&entries[entrycount], de, sizeof(struct dirent)); - entrycount++; - } - } - - closedir(d); -} - -static void append_dir_to_path(char *path, const char *dir) -{ - if (!strcmp(dir, "..")) - { - int i = strlen(path); - int delimcount = 0; - - while (i >= 0 && delimcount < 2) - { - if (path[i] == '/') - { - delimcount++; - - if (delimcount > 1) - path[i + 1]= '\0'; - } - i--; - } - } - else if (!strcmp(dir, ".")) - return; - else - { - strlcat(path, dir, sizeof(path)); - strlcat(path, "/", sizeof(path)); - } -} - -int main(void) -{ - const char *s = NULL; - char path[256]; - - int handle; - struct controller_data_s pad; - int pos = 0, ppos = -1; - - xenos_init(VIDEO_MODE_AUTO); - console_init(); - xenon_make_it_faster(XENON_SPEED_FULL); - usb_init(); - usb_do_poll(); - xenon_ata_init(); - //dvd_init(); - - handle = -1; - handle = bdev_enum(handle, &s); - if (handle < 0) - return 0; - - strlcpy(path, s, sizeof(path)); - strlcat(path, ":/", sizeof(path)); - - load_dir(path); - - for (;;) - { - usb_do_poll(); - get_controller_data(&pad, 0); - - if (pad.s1_y > STICK_THRESHOLD || pad.up) - pos--; - if (pad.s1_y < -STICK_THRESHOLD || pad.down) - pos++; - - if (entrycount && (pos < 0 || pos >= entrycount)) - { - pos = ppos; - continue; - } - - if (pad.logo) - return 0; - - if (pad.a) - { - if (entries[pos].d_type & DT_DIR) - { - append_dir_to_path(path,entries[pos].d_name); - load_dir(path); - ppos = -1; - pos = 0; - } - else - { - char fn[256]; - strlcpy(fn, path, sizeof(fn)); - strlcat(fn, entries[pos].d_name, sizeof(fn)); - - printf("%s\n", fn); - } - } - - if (pad.back) - { - append_dir_to_path(path, ".."); - load_dir(path); - ppos = -1; - pos = 0; - } - - if (pad.b) - { - do - { - handle = bdev_enum(handle, &s); - } while (handle < 0); - - strlcpy(path, s, sizeof(path)); - strlcat(path, ":/", sizeof(path)); - load_dir(path); - ppos = -1; - pos = 0; - } - - if (ppos == pos) - continue; - - memset(&pad, 0, sizeof(pad)); - - console_set_colors(BG_COL, FG_COL); - console_clrscr(); - printf("A: select, B: change disk, Back: parent dir, Logo: reload Xell\n\n%s\n\n", path); - - int start = MAX(0, pos - MAX_DISPLAYED_ENTRIES / 2); - int count = MIN(MAX_DISPLAYED_ENTRIES, entrycount - start); - - for (int i = start; i < start + count; i++) - { - struct dirent *de = &entries[i]; - - if (i == pos) - console_set_colors(FG_COL, BG_COL); - else - console_set_colors(BG_COL, FG_COL); - - if (de->d_type & DT_DIR) - console_putch('['); - - s = de->d_name; - while (*s) - console_putch(*s++); - - if (de->d_type & DT_DIR) - console_putch(']'); - - console_putch('\r'); - console_putch('\n'); - } - - ppos = pos; - - do - { - usb_do_poll(); - get_controller_data(&pad, 0); - } while (pad.a || pad.b || pad.back || pad.s1_y > STICK_THRESHOLD || pad.s1_y < -STICK_THRESHOLD); - } - - return 0; -} diff --git a/griffin/griffin.c b/griffin/griffin.c index 30cdf96a80..704633fb86 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -634,6 +634,8 @@ FRONTEND #include "../frontend/drivers/platform_psp.c" #elif defined(_3DS) #include "../frontend/drivers/platform_ctr.c" +#elif defined(XENON) +#include "../frontend/drivers/platform_xenon.c" #elif defined(__QNX__) #include "../frontend/drivers/platform_qnx.c" #elif defined(ANDROID) @@ -659,11 +661,7 @@ UI /*============================================================ MAIN ============================================================ */ -#if defined(XENON) -#include "../frontend/frontend_xenon.c" -#else #include "../frontend/frontend.c" -#endif /*============================================================ GIT