mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-04 17:06:48 +00:00
More code re-organization
=== DETAILS Since @aliaspider wants the `wiiu/` to be something of a mini-SDK, I've reorganized the code I put in there: - `wiiu/main.c` now only has the ELF/RPX entrypoints, and the code used by those entrypoints, with RA code removed (e.g. swapped retro_sleep() for usleep()). These entrypoints then call main() ... - Moved `main()` and its support functions back into `frontend/drivers/platform_wiiu.c` I also renamed some of the support functions I wrote, and better organized them within the code. - Moved `wiiu/input/` into the `input/` hierarchy: * The joypad drivers now live in `input/drivers_joypad/wiiu/` * The HID driver now lives in `input/drivers_hid/` * The Wii U specific headers now live in `input/include/wiiu` * I added `input/include` into the include search path to avoid using really ugly relative includes
This commit is contained in:
parent
04cefd27d1
commit
7448fd3157
@ -30,9 +30,9 @@ endif
|
||||
|
||||
OBJ :=
|
||||
OBJ += wiiu/main.o
|
||||
OBJ += wiiu/input/wpad_driver.o
|
||||
OBJ += wiiu/input/kpad_driver.o
|
||||
OBJ += wiiu/input/pad_functions.o
|
||||
OBJ += input/drivers_joypad/wiiu/wpad_driver.o
|
||||
OBJ += input/drivers_joypad/wiiu/kpad_driver.o
|
||||
OBJ += input/drivers_joypad/wiiu/pad_functions.o
|
||||
OBJ += wiiu/system/memory.o
|
||||
OBJ += wiiu/system/atomic.o
|
||||
OBJ += wiiu/system/exception_handler.o
|
||||
@ -48,8 +48,8 @@ endif
|
||||
|
||||
ifeq ($(WIIU_HID),1)
|
||||
DEFINES += -DWIIU_HID
|
||||
OBJ += wiiu/input/hidpad_driver.o
|
||||
OBJ += wiiu/input/wiiu_hid.o
|
||||
OBJ += input/drivers_joypad/wiiu/hidpad_driver.o
|
||||
OBJ += input/drivers_hid/wiiu_hid.o
|
||||
OBJ += input/connect/joypad_connection.o \
|
||||
input/common/hid/hid_device_driver.o \
|
||||
input/common/hid/device_wiiu_gca.o \
|
||||
@ -198,7 +198,16 @@ else
|
||||
ELF2RPL := $(ELF2RPL).exe
|
||||
endif
|
||||
|
||||
INCDIRS := -I. -Ideps -Ideps/stb -Ideps/libz -Ideps/7zip -Ilibretro-common/include -Iwiiu -Iwiiu/include -I$(DEVKITPRO)/portlibs/ppc/include
|
||||
INCDIRS := -I.
|
||||
INCDIRS += -Ideps
|
||||
INCDIRS += -Ideps/stb
|
||||
INCDIRS += -Ideps/libz
|
||||
INCDIRS += -Ideps/7zip
|
||||
INCDIRS += -Ilibretro-common/include
|
||||
INCDIRS += -Iinput/include
|
||||
INCDIRS += -Iwiiu
|
||||
INCDIRS += -Iwiiu/include
|
||||
INCDIRS += -I$(DEVKITPRO)/portlibs/ppc/include
|
||||
LIBDIRS := -L. -L$(DEVKITPRO)/portlibs/ppc/lib
|
||||
|
||||
CFLAGS := -mwup -mcpu=750 -meabi -mhard-float
|
||||
|
@ -14,6 +14,14 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/iosupport.h>
|
||||
#include <net/net_compat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <wiiu/types.h>
|
||||
#include <file/file_path.h>
|
||||
|
||||
@ -23,15 +31,27 @@
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include <wiiu/gx2.h>
|
||||
#include <wiiu/kpad.h>
|
||||
#include <wiiu/ios.h>
|
||||
#include <wiiu/os.h>
|
||||
#include <wiiu/procui.h>
|
||||
#include <wiiu/sysapp.h>
|
||||
|
||||
#include "file_path_special.h"
|
||||
|
||||
#include "../frontend.h"
|
||||
#include "../frontend_driver.h"
|
||||
#include "../../defaults.h"
|
||||
#include "../../paths.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../gfx/video_driver.h"
|
||||
|
||||
|
||||
#include "hbl.h"
|
||||
#include "wiiu_dbg.h"
|
||||
#include "system/exception_handler.h"
|
||||
#include "tasks/tasks_internal.h"
|
||||
|
||||
#ifndef IS_SALAMANDER
|
||||
@ -44,10 +64,7 @@
|
||||
#define WIIU_USB_PATH "usb:/"
|
||||
|
||||
/**
|
||||
* The Wii U frontend driver.
|
||||
*
|
||||
* If you're looking for main() and friends, they've been moved to
|
||||
* wiiu/main.c
|
||||
* The Wii U frontend driver, along with the main() method.
|
||||
*/
|
||||
|
||||
static enum frontend_fork wiiu_fork_mode = FRONTEND_FORK_NONE;
|
||||
@ -287,3 +304,272 @@ frontend_ctx_driver_t frontend_ctx_wiiu =
|
||||
"wiiu",
|
||||
NULL, /* get_video_driver */
|
||||
};
|
||||
|
||||
/* main() and its supporting functions */
|
||||
|
||||
static void main_setup(void);
|
||||
static void get_arguments(int *argc, char ***argv);
|
||||
static void do_rarch_main(int argc, char **argv);
|
||||
static void main_loop(void);
|
||||
static void main_teardown(void);
|
||||
|
||||
static void init_network(void);
|
||||
static void init_logging(void);
|
||||
static void deinit_logging(void);
|
||||
static void wiiu_log_init(const char *ipString, int port);
|
||||
static void wiiu_log_deinit(void);
|
||||
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len);
|
||||
static void init_pad_libraries(void);
|
||||
static void deinit_pad_libraries(void);
|
||||
static void SaveCallback(void);
|
||||
static bool swap_is_pending(void *start_time);
|
||||
|
||||
static int wiiu_log_socket = -1;
|
||||
static volatile int wiiu_log_lock = 0;
|
||||
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
static devoptab_t dotab_stdout =
|
||||
{
|
||||
"stdout_net", /* device name */
|
||||
0, /* size of file structure */
|
||||
NULL, /* device open */
|
||||
NULL, /* device close */
|
||||
wiiu_log_write, /* device write */
|
||||
NULL, /* ... */
|
||||
};
|
||||
#endif /* defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT) */
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
main_setup();
|
||||
get_arguments(&argc, &argv);
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
int salamander_main(argc, argv);
|
||||
salamander_main(argc, argv);
|
||||
#else
|
||||
do_rarch_main(argc, argv);
|
||||
main_loop();
|
||||
main_exit(NULL);
|
||||
#endif /* IS_SALAMANDER */
|
||||
main_teardown();
|
||||
|
||||
/* We always return 0 because if we don't, it can prevent loading a
|
||||
* different RPX/ELF in HBL. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void get_arguments(int *argc, char ***argv)
|
||||
{
|
||||
DEBUG_VAR(ARGV_PTR);
|
||||
if(ARGV_PTR && ((u32)ARGV_PTR < 0x01000000))
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 magic;
|
||||
u32 argc;
|
||||
char *argv[3];
|
||||
} *param = ARGV_PTR;
|
||||
if(param->magic == ARGV_MAGIC)
|
||||
{
|
||||
*argc = param->argc;
|
||||
*argv = param->argv;
|
||||
}
|
||||
ARGV_PTR = NULL;
|
||||
}
|
||||
|
||||
DEBUG_VAR(argc);
|
||||
DEBUG_VAR(argv[0]);
|
||||
DEBUG_VAR(argv[1]);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void main_setup(void)
|
||||
{
|
||||
setup_os_exceptions();
|
||||
ProcUIInit(&SaveCallback);
|
||||
init_network();
|
||||
init_logging();
|
||||
init_pad_libraries();
|
||||
verbosity_enable();
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void main_teardown(void)
|
||||
{
|
||||
deinit_pad_libraries();
|
||||
ProcUIShutdown();
|
||||
deinit_logging();
|
||||
}
|
||||
|
||||
static void main_loop(void)
|
||||
{
|
||||
unsigned sleep_ms = 0;
|
||||
OSTime start_time;
|
||||
int status;
|
||||
|
||||
do
|
||||
{
|
||||
if(video_driver_get_ptr(false))
|
||||
{
|
||||
start_time = OSGetSystemTime();
|
||||
task_queue_wait(swap_is_pending, &start_time);
|
||||
}
|
||||
else
|
||||
task_queue_wait(NULL, NULL);
|
||||
|
||||
status = runloop_iterate(&sleep_ms);
|
||||
|
||||
if(status == 1 && sleep_ms > 0)
|
||||
usleep(sleep_ms);
|
||||
|
||||
if(status == -1)
|
||||
break;
|
||||
} while(true);
|
||||
}
|
||||
|
||||
static void do_rarch_main(int argc, char **argv)
|
||||
{
|
||||
#if 0
|
||||
int argc_ = 2;
|
||||
char *argv_[] = { WIIU_SD_PATH "retroarch/retroarch.elf",
|
||||
WIIU_SD_PATH "rom.sfc",
|
||||
NULL };
|
||||
rarch_main(argc_, argv_, NULL);
|
||||
#else
|
||||
rarch_main(argc, argv, NULL);
|
||||
#endif /* if 0 */
|
||||
}
|
||||
|
||||
static void SaveCallback(void)
|
||||
{
|
||||
OSSavesDone_ReadyToRelease();
|
||||
}
|
||||
|
||||
static bool swap_is_pending(void *start_time)
|
||||
{
|
||||
uint32_t swap_count, flip_count;
|
||||
OSTime last_flip, last_vsync;
|
||||
|
||||
GX2GetSwapStatus(&swap_count, &flip_count, &last_flip, &last_vsync);
|
||||
return last_vsync < *(OSTime *)start_time;
|
||||
}
|
||||
|
||||
static void init_network(void)
|
||||
{
|
||||
#ifdef IS_SALAMANDER
|
||||
socket_lib_init();
|
||||
#else
|
||||
network_init();
|
||||
#endif /* IS_SALAMANDER */
|
||||
}
|
||||
|
||||
static void init_logging(void)
|
||||
{
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
wiiu_log_init(PC_DEVELOPMENT_IP_ADDRESS, PC_DEVELOPMENT_TCP_PORT);
|
||||
devoptab_list[STD_OUT] = &dotab_stdout;
|
||||
devoptab_list[STD_ERR] = &dotab_stdout;
|
||||
#endif /* defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT) */
|
||||
}
|
||||
|
||||
static void deinit_logging(void)
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
wiiu_log_deinit();
|
||||
#endif /* defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT) */
|
||||
}
|
||||
|
||||
|
||||
static void wiiu_log_init(const char *ipString, int port)
|
||||
{
|
||||
wiiu_log_lock = 0;
|
||||
wiiu_log_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if(wiiu_log_socket < 0)
|
||||
return;
|
||||
|
||||
struct sockaddr_in connect_addr;
|
||||
memset(&connect_addr, 0, sizeof(connect_addr));
|
||||
connect_addr.sin_family = AF_INET;
|
||||
connect_addr.sin_port = port;
|
||||
inet_aton(ipString, &connect_addr.sin_addr);
|
||||
|
||||
if(connect(wiiu_log_socket,
|
||||
(struct sockaddr *)&connect_addr,
|
||||
sizeof(connect_addr)) < 0)
|
||||
{
|
||||
socketclose(wiiu_log_socket);
|
||||
wiiu_log_socket = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void wiiu_log_deinit(void)
|
||||
{
|
||||
if(wiiu_log_socket >= 0)
|
||||
{
|
||||
socketclose(wiiu_log_socket);
|
||||
wiiu_log_socket = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void init_pad_libraries(void)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
KPADInit();
|
||||
WPADEnableURCC(true);
|
||||
WPADEnableWiiRemote(true);
|
||||
#endif /* IS_SALAMANDER */
|
||||
}
|
||||
|
||||
static void deinit_pad_libraries(void)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
KPADShutdown();
|
||||
#endif /* IS_SALAMANDER */
|
||||
}
|
||||
|
||||
/* logging routines */
|
||||
|
||||
void net_print(const char *str)
|
||||
{
|
||||
wiiu_log_write(NULL, 0, str, strlen(str));
|
||||
}
|
||||
|
||||
void net_print_exp(const char *str)
|
||||
{
|
||||
send(wiiu_log_socket, str, strlen(str), 0);
|
||||
}
|
||||
|
||||
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len)
|
||||
{
|
||||
if( wiiu_log_socket < 0)
|
||||
return len;
|
||||
|
||||
while(wiiu_log_lock)
|
||||
OSSleepTicks(((248625000 / 4)) / 1000);
|
||||
|
||||
wiiu_log_lock = 1;
|
||||
|
||||
int ret;
|
||||
int remaining = len;
|
||||
|
||||
while(remaining > 0)
|
||||
{
|
||||
int block = remaining < 1400 ? remaining : 1400;
|
||||
ret = send(wiiu_log_socket, ptr, block, 0);
|
||||
|
||||
if(ret < 0)
|
||||
break;
|
||||
|
||||
remaining -= ret;
|
||||
ptr += ret;
|
||||
}
|
||||
|
||||
wiiu_log_lock = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wiiu_hid.h"
|
||||
#include <wiiu/hid.h>
|
||||
#include <wiiu/os/atomic.h>
|
||||
|
||||
static wiiu_event_list events;
|
@ -14,8 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include "wiiu_hid.h"
|
||||
#include <wiiu/input.h>
|
||||
|
||||
static bool hidpad_init(void *data);
|
||||
static bool hidpad_query_pad(unsigned pad);
|
@ -20,7 +20,7 @@
|
||||
* controllers.
|
||||
*/
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include <wiiu/input.h>
|
||||
|
||||
static bool kpad_init(void *data);
|
||||
static bool kpad_query_pad(unsigned pad);
|
@ -14,7 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include <wiiu/input.h>
|
||||
|
||||
enum wiiu_pad_axes {
|
||||
AXIS_LEFT_ANALOG_X,
|
@ -21,7 +21,7 @@
|
||||
* - For HID controllers, see hid_driver.c
|
||||
*/
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include <wiiu/input.h>
|
||||
|
||||
#define PANIC_BUTTON_MASK (VPAD_BUTTON_R | VPAD_BUTTON_L | VPAD_BUTTON_STICK_R | VPAD_BUTTON_STICK_L)
|
||||
|
@ -14,7 +14,7 @@
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "../../wiiu/input/wiiu_input.h"
|
||||
#include <wiiu/input.h>
|
||||
|
||||
#include "wiiu_dbg.h"
|
||||
|
||||
|
@ -17,9 +17,8 @@
|
||||
#ifndef __WIIU_HID__H
|
||||
#define __WIIU_HID__H
|
||||
|
||||
#include "wiiu_hid_types.h"
|
||||
|
||||
#include "wiiu_input.h"
|
||||
#include <wiiu/hid_types.h>
|
||||
#include <wiiu/input.h>
|
||||
|
||||
#define DEVICE_UNUSED 0
|
||||
#define DEVICE_USED 1
|
@ -17,8 +17,8 @@
|
||||
#ifndef __WIIU_INPUT__H
|
||||
#define __WIIU_INPUT__H
|
||||
|
||||
#include "wiiu_hid_types.h"
|
||||
#include "../../input/include/gamepad.h"
|
||||
#include <wiiu/hid_types.h>
|
||||
#include <gamepad.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
@ -33,15 +33,15 @@
|
||||
#include <wiiu/kpad.h>
|
||||
#include <wiiu/pad_strings.h>
|
||||
|
||||
#include "../../input/input_driver.h"
|
||||
#include "../../input/common/hid/hid_device_driver.h"
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#include "../../input/connect/joypad_connection.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../../command.h"
|
||||
#include "../../gfx/video_driver.h"
|
||||
#include "wiiu_hid.h"
|
||||
#include <input/input_driver.h>
|
||||
#include "../../common/hid/hid_device_driver.h"
|
||||
#include <tasks/tasks_internal.h>
|
||||
#include <input/connect/joypad_connection.h>
|
||||
#include <retroarch.h>
|
||||
#include <verbosity.h>
|
||||
#include <command.h>
|
||||
#include <gfx/video_driver.h>
|
||||
#include <wiiu/hid.h>
|
||||
|
||||
#define WIIMOTE_TYPE_WIIPLUS 0x00
|
||||
#define WIIMOTE_TYPE_NUNCHUK 0x01
|
273
wiiu/main.c
273
wiiu/main.c
@ -17,15 +17,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <net/net_compat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <retro_timers.h>
|
||||
|
||||
#include <fat.h>
|
||||
#include <iosuhax.h>
|
||||
#include <sys/iosupport.h>
|
||||
#include <unistd.h>
|
||||
#include <wiiu/gx2.h>
|
||||
#include <wiiu/ios.h>
|
||||
#include <wiiu/kpad.h>
|
||||
@ -36,17 +32,15 @@
|
||||
#include "main.h"
|
||||
|
||||
/**
|
||||
* This file contains the main entrypoints for the Wii U executable.
|
||||
* This file contains the main entrypoints for the Wii U executable that
|
||||
* set up the call to main().
|
||||
*/
|
||||
|
||||
static void fsdev_init(void);
|
||||
static void fsdev_exit(void);
|
||||
|
||||
#define WIIU_SD_PATH "sd:/"
|
||||
#define WIIU_USB_PATH "usb:/"
|
||||
|
||||
static int wiiu_log_socket = -1;
|
||||
static volatile int wiiu_log_lock = 0;
|
||||
static int iosuhaxMount = 0;
|
||||
static int mcp_hook_fd = -1;
|
||||
|
||||
/* HBL elf entry point */
|
||||
int __entry_menu(int argc, char **argv)
|
||||
@ -86,251 +80,6 @@ void _start(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
void wiiu_log_init(const char *ipString, int port)
|
||||
{
|
||||
wiiu_log_lock = 0;
|
||||
|
||||
wiiu_log_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
|
||||
if (wiiu_log_socket < 0)
|
||||
return;
|
||||
|
||||
struct sockaddr_in connect_addr;
|
||||
memset(&connect_addr, 0, sizeof(connect_addr));
|
||||
connect_addr.sin_family = AF_INET;
|
||||
connect_addr.sin_port = port;
|
||||
inet_aton(ipString, &connect_addr.sin_addr);
|
||||
|
||||
if (connect(wiiu_log_socket, (struct sockaddr *)&connect_addr, sizeof(connect_addr)) < 0)
|
||||
{
|
||||
socketclose(wiiu_log_socket);
|
||||
wiiu_log_socket = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void wiiu_log_deinit(void)
|
||||
{
|
||||
if (wiiu_log_socket >= 0)
|
||||
{
|
||||
socketclose(wiiu_log_socket);
|
||||
wiiu_log_socket = -1;
|
||||
}
|
||||
}
|
||||
static ssize_t wiiu_log_write(struct _reent *r, void *fd, const char *ptr, size_t len)
|
||||
{
|
||||
if (wiiu_log_socket < 0)
|
||||
return len;
|
||||
|
||||
while (wiiu_log_lock)
|
||||
OSSleepTicks(((248625000 / 4)) / 1000);
|
||||
|
||||
wiiu_log_lock = 1;
|
||||
|
||||
int ret;
|
||||
int remaining = len;
|
||||
|
||||
while (remaining > 0)
|
||||
{
|
||||
int block = remaining < 1400 ? remaining : 1400; // take max 1400 bytes per UDP packet
|
||||
ret = send(wiiu_log_socket, ptr, block, 0);
|
||||
|
||||
if (ret < 0)
|
||||
break;
|
||||
|
||||
remaining -= ret;
|
||||
ptr += ret;
|
||||
}
|
||||
|
||||
wiiu_log_lock = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
void net_print(const char *str)
|
||||
{
|
||||
wiiu_log_write(NULL, 0, str, strlen(str));
|
||||
}
|
||||
|
||||
void net_print_exp(const char *str)
|
||||
{
|
||||
send(wiiu_log_socket, str, strlen(str), 0);
|
||||
}
|
||||
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
static devoptab_t dotab_stdout =
|
||||
{
|
||||
"stdout_net", // device name
|
||||
0, // size of file structure
|
||||
NULL, // device open
|
||||
NULL, // device close
|
||||
wiiu_log_write, // device write
|
||||
NULL,
|
||||
/* ... */
|
||||
};
|
||||
#endif
|
||||
|
||||
void SaveCallback(void)
|
||||
{
|
||||
OSSavesDone_ReadyToRelease();
|
||||
}
|
||||
|
||||
static bool swap_is_pending(void* start_time)
|
||||
{
|
||||
uint32_t swap_count, flip_count;
|
||||
OSTime last_flip , last_vsync;
|
||||
|
||||
GX2GetSwapStatus(&swap_count, &flip_count, &last_flip, &last_vsync);
|
||||
|
||||
return last_vsync < *(OSTime*)start_time;
|
||||
}
|
||||
|
||||
static void do_network_init(void)
|
||||
{
|
||||
#ifdef IS_SALAMANDER
|
||||
socket_lib_init();
|
||||
#else
|
||||
network_init();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void init_pad_libraries(void)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
KPADInit();
|
||||
WPADEnableURCC(true);
|
||||
WPADEnableWiiRemote(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void deinit_pad_libraries(void)
|
||||
{
|
||||
#ifndef IS_SALAMANDER
|
||||
KPADShutdown();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void do_logging_init(void)
|
||||
{
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
wiiu_log_init(PC_DEVELOPMENT_IP_ADDRESS, PC_DEVELOPMENT_TCP_PORT);
|
||||
devoptab_list[STD_OUT] = &dotab_stdout;
|
||||
devoptab_list[STD_ERR] = &dotab_stdout;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void do_logging_deinit(void)
|
||||
{
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
#if defined(PC_DEVELOPMENT_IP_ADDRESS) && defined(PC_DEVELOPMENT_TCP_PORT)
|
||||
wiiu_log_deinit();
|
||||
#endif
|
||||
}
|
||||
|
||||
static void do_rarch_main(int argc, char **argv)
|
||||
{
|
||||
#if 0
|
||||
int argc_ = 2;
|
||||
// char* argv_[] = {WIIU_SD_PATH "retroarch/retroarch.elf", WIIU_SD_PATH "rom.nes", NULL};
|
||||
char *argv_[] = {WIIU_SD_PATH "retroarch/retroarch.elf", WIIU_SD_PATH "rom.sfc", NULL};
|
||||
|
||||
rarch_main(argc_, argv_, NULL);
|
||||
#else /* #if 0 */
|
||||
rarch_main(argc, argv, NULL);
|
||||
#endif /* #if 0 */
|
||||
}
|
||||
|
||||
static void main_loop(void)
|
||||
{
|
||||
unsigned sleep_ms = 0;
|
||||
OSTime start_time;
|
||||
int status;
|
||||
|
||||
do
|
||||
{
|
||||
if(video_driver_get_ptr(false))
|
||||
{
|
||||
start_time = OSGetSystemTime();
|
||||
task_queue_wait(swap_is_pending, &start_time);
|
||||
}
|
||||
else
|
||||
task_queue_wait(NULL, NULL);
|
||||
|
||||
status = runloop_iterate(&sleep_ms);
|
||||
|
||||
if (status == 1 && sleep_ms > 0)
|
||||
retro_sleep(sleep_ms);
|
||||
|
||||
if (status == -1)
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
}
|
||||
|
||||
static void main_init(void)
|
||||
{
|
||||
setup_os_exceptions();
|
||||
ProcUIInit(&SaveCallback);
|
||||
do_network_init();
|
||||
do_logging_init();
|
||||
init_pad_libraries();
|
||||
verbosity_enable();
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void main_deinit(void)
|
||||
{
|
||||
deinit_pad_libraries();
|
||||
ProcUIShutdown();
|
||||
|
||||
do_logging_deinit();
|
||||
}
|
||||
|
||||
static void read_argc_argv(int *argc, char ***argv)
|
||||
{
|
||||
DEBUG_VAR(ARGV_PTR);
|
||||
if(ARGV_PTR && ((u32)ARGV_PTR < 0x01000000))
|
||||
{
|
||||
struct
|
||||
{
|
||||
u32 magic;
|
||||
u32 argc;
|
||||
char * argv[3];
|
||||
}*param = ARGV_PTR;
|
||||
if(param->magic == ARGV_MAGIC)
|
||||
{
|
||||
*argc = param->argc;
|
||||
*argv = param->argv;
|
||||
}
|
||||
ARGV_PTR = NULL;
|
||||
}
|
||||
|
||||
DEBUG_VAR(argc);
|
||||
DEBUG_STR(argv[0]);
|
||||
DEBUG_STR(argv[1]);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
main_init();
|
||||
read_argc_argv(&argc, &argv);
|
||||
|
||||
#ifdef IS_SALAMANDER
|
||||
int salamander_main(int, char **);
|
||||
salamander_main(argc, argv);
|
||||
#else
|
||||
do_rarch_main(argc, argv);
|
||||
main_loop();
|
||||
main_exit(NULL);
|
||||
#endif /* IS_SALAMANDER */
|
||||
main_deinit();
|
||||
|
||||
/* returning non 0 here can prevent loading a different rpx/elf in the HBL
|
||||
environment */
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __eabi(void)
|
||||
{
|
||||
|
||||
@ -368,8 +117,6 @@ void someFunc(void *arg)
|
||||
(void)arg;
|
||||
}
|
||||
|
||||
static int mcp_hook_fd = -1;
|
||||
|
||||
int MCPHookOpen(void)
|
||||
{
|
||||
//take over mcp thread
|
||||
@ -380,7 +127,7 @@ int MCPHookOpen(void)
|
||||
|
||||
IOS_IoctlAsync(mcp_hook_fd, 0x62, (void *)0, 0, (void *)0, 0, someFunc, (void *)0);
|
||||
//let wupserver start up
|
||||
retro_sleep(1000);
|
||||
usleep(1000);
|
||||
|
||||
if (IOSUHAX_Open("/dev/mcp") < 0)
|
||||
{
|
||||
@ -400,14 +147,11 @@ void MCPHookClose(void)
|
||||
//close down wupserver, return control to mcp
|
||||
IOSUHAX_Close();
|
||||
//wait for mcp to return
|
||||
retro_sleep(1000);
|
||||
usleep(1000);
|
||||
IOS_Close(mcp_hook_fd);
|
||||
mcp_hook_fd = -1;
|
||||
}
|
||||
|
||||
|
||||
static int iosuhaxMount = 0;
|
||||
|
||||
static void fsdev_init(void)
|
||||
{
|
||||
iosuhaxMount = 0;
|
||||
@ -424,6 +168,7 @@ static void fsdev_init(void)
|
||||
fatInitDefault();
|
||||
}
|
||||
}
|
||||
|
||||
static void fsdev_exit(void)
|
||||
{
|
||||
if (iosuhaxMount)
|
||||
@ -438,6 +183,4 @@ static void fsdev_exit(void)
|
||||
}
|
||||
else
|
||||
unmount_sd_fat("sd");
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,14 +10,9 @@
|
||||
#include "system/memory.h"
|
||||
#include "system/exception_handler.h"
|
||||
|
||||
#include "../retroarch.h"
|
||||
#include "../verbosity.h"
|
||||
#include "../frontend/frontend.h"
|
||||
#include "../gfx/video_driver.h"
|
||||
#include "../tasks/tasks_internal.h"
|
||||
|
||||
void __init(void);
|
||||
void __fini(void);
|
||||
|
||||
int main(int argc, char **argv);
|
||||
|
||||
#endif /* WIIU_MAIN_H */
|
||||
|
Loading…
Reference in New Issue
Block a user