mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 16:09:47 +00:00
preliminary port to the wiiu platform
This commit is contained in:
parent
eb416ce478
commit
a4d745a471
166
Makefile.wiiu
Normal file
166
Makefile.wiiu
Normal file
@ -0,0 +1,166 @@
|
||||
TARGET := retroarch_wiiu
|
||||
DEBUG = 0
|
||||
GRIFFIN_BUILD = 0
|
||||
WHOLE_ARCHIVE_LINK = 0
|
||||
|
||||
OBJ :=
|
||||
OBJ += wiiu/dynamic_libs/ax_functions.o
|
||||
OBJ += wiiu/dynamic_libs/os_functions.o
|
||||
OBJ += wiiu/dynamic_libs/sys_functions.o
|
||||
OBJ += wiiu/fs/sd_fat_devoptab.o
|
||||
OBJ += wiiu/dynamic_libs/fs_functions.o
|
||||
OBJ += wiiu/dynamic_libs/padscore_functions.o
|
||||
OBJ += wiiu/dynamic_libs/vpad_functions.o
|
||||
OBJ += wiiu/system/memory.o
|
||||
OBJ += wiiu/dynamic_libs/gx2_functions.o
|
||||
OBJ += wiiu/dynamic_libs/socket_functions.o
|
||||
OBJ += wiiu/fs/fs_utils.o
|
||||
|
||||
DEFINES :=
|
||||
|
||||
ifeq ($(GRIFFIN_BUILD), 1)
|
||||
OBJ += griffin/griffin.o
|
||||
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_RGUI -DHAVE_LIBRETRODB
|
||||
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DWANT_ZLIB
|
||||
# DEFINES += -DHAVE_XMB -DHAVE_MATERIALUI
|
||||
else
|
||||
HAVE_MENU_COMMON = 1
|
||||
HAVE_RTGA = 1
|
||||
HAVE_RPNG = 1
|
||||
HAVE_RJPEG = 1
|
||||
HAVE_RBMP = 1
|
||||
HAVE_RGUI = 1
|
||||
HAVE_ZLIB = 1
|
||||
HAVE_7ZIP = 1
|
||||
HAVE_BUILTINZLIB = 1
|
||||
HAVE_LIBRETRODB = 1
|
||||
HAVE_ZARCH = 0
|
||||
HAVE_MATERIALUI = 0
|
||||
HAVE_XMB = 0
|
||||
|
||||
include Makefile.common
|
||||
BLACKLIST :=
|
||||
BLACKLIST += input/input_overlay.o
|
||||
BLACKLIST += tasks/task_overlay.o
|
||||
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
|
||||
|
||||
OBJ += gfx/drivers/wiiu_gfx.o
|
||||
# OBJ += gfx/drivers_font/wiiu_font.o
|
||||
# OBJ += menu/drivers_display/menu_display_wiiu.o
|
||||
OBJ += input/drivers/wiiu_input.o
|
||||
OBJ += input/drivers_joypad/wiiu_joypad.o
|
||||
# OBJ += audio/drivers/wiiu_audio.o
|
||||
OBJ += frontend/drivers/platform_wiiu.o
|
||||
OBJ += gfx/video_filters/2xsai.o
|
||||
OBJ += gfx/video_filters/super2xsai.o
|
||||
OBJ += gfx/video_filters/supereagle.o
|
||||
OBJ += gfx/video_filters/2xbr.o
|
||||
OBJ += gfx/video_filters/darken.o
|
||||
OBJ += gfx/video_filters/epx.o
|
||||
OBJ += gfx/video_filters/scale2x.o
|
||||
OBJ += gfx/video_filters/blargg_ntsc_snes.o
|
||||
OBJ += gfx/video_filters/lq2x.o
|
||||
OBJ += gfx/video_filters/phosphor2x.o
|
||||
OBJ += audio/audio_filters/echo.o
|
||||
OBJ += audio/audio_filters/eq.o
|
||||
OBJ += audio/audio_filters/chorus.o
|
||||
OBJ += audio/audio_filters/iir.o
|
||||
OBJ += audio/audio_filters/panning.o
|
||||
OBJ += audio/audio_filters/phaser.o
|
||||
OBJ += audio/audio_filters/reverb.o
|
||||
OBJ += audio/audio_filters/wahwah.o
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(strip $(DEVKITPPC)),)
|
||||
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
|
||||
endif
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
|
||||
endif
|
||||
export PATH := $(PATH):$(DEVKITPPC)/bin:$(PORTLIBS)/bin
|
||||
export LIBOGC_INC := $(DEVKITPRO)/libogc/include
|
||||
export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
CC := $(PREFIX)gcc
|
||||
CXX := $(PREFIX)g++
|
||||
AS := $(PREFIX)as
|
||||
AR := $(PREFIX)ar
|
||||
OBJCOPY := $(PREFIX)objcopy
|
||||
STRIP := $(PREFIX)strip
|
||||
NM := $(PREFIX)nm
|
||||
LD := $(CXX)
|
||||
|
||||
|
||||
INCDIRS := -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include -Iwiiu -I$(LIBOGC_INC)
|
||||
LIBDIRS := -L.
|
||||
|
||||
CFLAGS := -mrvl -mcpu=750 -meabi -mhard-float
|
||||
LDFLAGS :=
|
||||
#LDFLAGS := $(CFLAGS)
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -g
|
||||
else
|
||||
CFLAGS += -O3
|
||||
endif
|
||||
|
||||
ASFLAGS := $(CFLAGS) -mregnames
|
||||
|
||||
CFLAGS += -ffast-math -Werror=implicit-function-declaration
|
||||
#CFLAGS += -fomit-frame-pointer -mword-relocations
|
||||
#CFLAGS += -Wall
|
||||
CFLAGS += -DWIIU
|
||||
CFLAGS += -DHAVE_MAIN
|
||||
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY
|
||||
CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES)
|
||||
|
||||
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
|
||||
WHOLE_START := -Wl,--whole-archive
|
||||
WHOLE_END := -Wl,--no-whole-archive
|
||||
endif
|
||||
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
LDFLAGS += -nostartfiles -Wl,-Map,$(notdir $@).map,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc
|
||||
LDFLAGS += -Wl,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r
|
||||
LDFLAGS += -Wl,-wrap,_malloc_usable_size_r,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections
|
||||
|
||||
CFLAGS += -std=gnu99
|
||||
|
||||
LIBS := $(WHOLE_START) -lretro_wiiu $(WHOLE_END) -lm
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(TARGET).elf
|
||||
|
||||
$(TARGET).elf: $(OBJ) libretro_wiiu.a
|
||||
|
||||
%.o: %.cpp
|
||||
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
|
||||
|
||||
%.o: %.s
|
||||
$(CC) -c -o $@ $< $(ASFLAGS)
|
||||
|
||||
%.o: %.S
|
||||
$(CC) -c -o $@ $< $(ASFLAGS)
|
||||
|
||||
%.a:
|
||||
$(AR) -rc $@ $^
|
||||
|
||||
$(TARGET).elf: wiiu/link.ld $(OBJ)
|
||||
# $(LD) -T wiiu/link.ld $(OBJ) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
|
||||
$(LD) -n -T wiiu/link.ld $(OBJ) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ)
|
||||
rm -f $(TARGET).elf
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
@ -34,6 +34,7 @@ enum
|
||||
VIDEO_SDL2,
|
||||
VIDEO_EXT,
|
||||
VIDEO_WII,
|
||||
VIDEO_WIIU,
|
||||
VIDEO_XENON360,
|
||||
VIDEO_XDK_D3D,
|
||||
VIDEO_PSP1,
|
||||
@ -85,6 +86,7 @@ enum
|
||||
INPUT_CTR,
|
||||
INPUT_XENON360,
|
||||
INPUT_WII,
|
||||
INPUT_WIIU,
|
||||
INPUT_XINPUT,
|
||||
INPUT_UDEV,
|
||||
INPUT_LINUXRAW,
|
||||
@ -96,6 +98,7 @@ enum
|
||||
JOYPAD_PS3,
|
||||
JOYPAD_XINPUT,
|
||||
JOYPAD_GX,
|
||||
JOYPAD_WIIU,
|
||||
JOYPAD_XDK,
|
||||
JOYPAD_PSP,
|
||||
JOYPAD_CTR,
|
||||
@ -146,6 +149,8 @@ enum
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_GL
|
||||
#elif defined(GEKKO)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_WII
|
||||
#elif defined(WIIU)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_WIIU
|
||||
#elif defined(XENON)
|
||||
#define VIDEO_DEFAULT_DRIVER VIDEO_XENON360
|
||||
#elif (defined(_XBOX1) || defined(_XBOX360)) && (defined(HAVE_D3D8) || defined(HAVE_D3D9))
|
||||
@ -250,6 +255,8 @@ enum
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_CTR
|
||||
#elif defined(GEKKO)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_WII
|
||||
#elif defined(WIIU)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_WIIU
|
||||
#elif defined(HAVE_UDEV)
|
||||
#define INPUT_DEFAULT_DRIVER INPUT_UDEV
|
||||
#elif defined(__linux__) && !defined(ANDROID)
|
||||
@ -276,6 +283,8 @@ enum
|
||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_XINPUT
|
||||
#elif defined(GEKKO)
|
||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_GX
|
||||
#elif defined(WIIU)
|
||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_WIIU
|
||||
#elif defined(_XBOX)
|
||||
#define JOYPAD_DEFAULT_DRIVER JOYPAD_XDK
|
||||
#elif defined(PSP) || defined(VITA)
|
||||
|
@ -265,6 +265,8 @@ const char *config_get_default_video(void)
|
||||
return "drm";
|
||||
case VIDEO_WII:
|
||||
return "gx";
|
||||
case VIDEO_WIIU:
|
||||
return "gx2";
|
||||
case VIDEO_XENON360:
|
||||
return "xenon360";
|
||||
case VIDEO_XDK_D3D:
|
||||
@ -340,6 +342,8 @@ const char *config_get_default_input(void)
|
||||
return "xinput";
|
||||
case INPUT_WII:
|
||||
return "gx";
|
||||
case INPUT_WIIU:
|
||||
return "wiiu";
|
||||
case INPUT_LINUXRAW:
|
||||
return "linuxraw";
|
||||
case INPUT_UDEV:
|
||||
@ -374,6 +378,8 @@ const char *config_get_default_joypad(void)
|
||||
return "xinput";
|
||||
case JOYPAD_GX:
|
||||
return "gx";
|
||||
case JOYPAD_WIIU:
|
||||
return "wiiu";
|
||||
case JOYPAD_XDK:
|
||||
return "xdk";
|
||||
case JOYPAD_PSP:
|
||||
|
309
frontend/drivers/platform_wiiu.c
Normal file
309
frontend/drivers/platform_wiiu.c
Normal file
@ -0,0 +1,309 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2014-2016 - Ali Bouhlel
|
||||
*
|
||||
* 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 <stddef.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <boolean.h>
|
||||
|
||||
#include <file/file_path.h>
|
||||
|
||||
#include <lists/file_list.h>
|
||||
|
||||
#include "../frontend_driver.h"
|
||||
#include "../frontend.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../verbosity.h"
|
||||
#include "../../defaults.h"
|
||||
#include "../../paths.h"
|
||||
#include "retroarch.h"
|
||||
#include "file_path_special.h"
|
||||
#include "audio/audio_driver.h"
|
||||
|
||||
|
||||
#include "tasks/tasks_internal.h"
|
||||
#include "runloop.h"
|
||||
#include "dynamic_libs/os_functions.h"
|
||||
#include "dynamic_libs/fs_functions.h"
|
||||
#include "dynamic_libs/gx2_functions.h"
|
||||
#include "dynamic_libs/sys_functions.h"
|
||||
#include "dynamic_libs/vpad_functions.h"
|
||||
#include "dynamic_libs/padscore_functions.h"
|
||||
#include "dynamic_libs/socket_functions.h"
|
||||
#include "dynamic_libs/ax_functions.h"
|
||||
#include "fs/fs_utils.h"
|
||||
#include "fs/sd_fat_devoptab.h"
|
||||
#include "system/memory.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/utils.h"
|
||||
#include "common/common.h"
|
||||
#include <sys/iosupport.h>
|
||||
|
||||
#include "wiiu_dbg.h"
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
#include "../../menu/menu_driver.h"
|
||||
#endif
|
||||
|
||||
static enum frontend_fork wiiu_fork_mode = FRONTEND_FORK_NONE;
|
||||
static const char* elf_path_cst = "sd:/retroarch/retroarch.elf";
|
||||
|
||||
static void frontend_wiiu_get_environment_settings(int *argc, char *argv[],
|
||||
void *args, void *params_data)
|
||||
{
|
||||
(void)args;
|
||||
DEBUG_LINE();
|
||||
|
||||
fill_pathname_basedir(g_defaults.dir.port, elf_path_cst, sizeof(g_defaults.dir.port));
|
||||
DEBUG_LINE();
|
||||
RARCH_LOG("port dir: [%s]\n", g_defaults.dir.port);
|
||||
|
||||
fill_pathname_join(g_defaults.dir.core_assets, g_defaults.dir.port,
|
||||
"downloads", sizeof(g_defaults.dir.core_assets));
|
||||
fill_pathname_join(g_defaults.dir.assets, g_defaults.dir.port,
|
||||
"media", sizeof(g_defaults.dir.assets));
|
||||
fill_pathname_join(g_defaults.dir.core, g_defaults.dir.port,
|
||||
"cores", sizeof(g_defaults.dir.core));
|
||||
fill_pathname_join(g_defaults.dir.core_info, g_defaults.dir.core,
|
||||
"info", sizeof(g_defaults.dir.core_info));
|
||||
fill_pathname_join(g_defaults.dir.savestate, g_defaults.dir.core,
|
||||
"savestates", sizeof(g_defaults.dir.savestate));
|
||||
fill_pathname_join(g_defaults.dir.sram, g_defaults.dir.core,
|
||||
"savefiles", sizeof(g_defaults.dir.sram));
|
||||
fill_pathname_join(g_defaults.dir.system, g_defaults.dir.core,
|
||||
"system", sizeof(g_defaults.dir.system));
|
||||
fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core,
|
||||
"playlists", sizeof(g_defaults.dir.playlist));
|
||||
fill_pathname_join(g_defaults.dir.menu_config, g_defaults.dir.port,
|
||||
"config", sizeof(g_defaults.dir.menu_config));
|
||||
fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.port,
|
||||
"config/remaps", sizeof(g_defaults.dir.remap));
|
||||
fill_pathname_join(g_defaults.dir.video_filter, g_defaults.dir.port,
|
||||
"filters", sizeof(g_defaults.dir.remap));
|
||||
fill_pathname_join(g_defaults.dir.database, g_defaults.dir.port,
|
||||
"database/rdb", sizeof(g_defaults.dir.database));
|
||||
fill_pathname_join(g_defaults.dir.cursor, g_defaults.dir.port,
|
||||
"database/cursors", sizeof(g_defaults.dir.cursor));
|
||||
fill_pathname_join(g_defaults.path.config, g_defaults.dir.port,
|
||||
file_path_str(FILE_PATH_MAIN_CONFIG), sizeof(g_defaults.path.config));
|
||||
}
|
||||
|
||||
static void frontend_wiiu_deinit(void *data)
|
||||
{
|
||||
(void)data;
|
||||
}
|
||||
|
||||
static void frontend_wiiu_shutdown(bool unused)
|
||||
{
|
||||
(void)unused;
|
||||
}
|
||||
|
||||
static void frontend_wiiu_init(void *data)
|
||||
{
|
||||
(void)data;
|
||||
DEBUG_LINE();
|
||||
verbosity_enable();
|
||||
DEBUG_LINE();
|
||||
}
|
||||
|
||||
|
||||
static int frontend_wiiu_get_rating(void)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
enum frontend_architecture frontend_wiiu_get_architecture(void)
|
||||
{
|
||||
return FRONTEND_ARCH_PPC;
|
||||
}
|
||||
|
||||
static int frontend_wiiu_parse_drive_list(void *data)
|
||||
{
|
||||
file_list_t *list = (file_list_t*)data;
|
||||
|
||||
if (!list)
|
||||
return -1;
|
||||
|
||||
menu_entries_append_enum(list,
|
||||
"sd:/", "", MSG_UNKNOWN, FILE_TYPE_DIRECTORY, 0, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
frontend_ctx_driver_t frontend_ctx_wiiu = {
|
||||
frontend_wiiu_get_environment_settings,
|
||||
frontend_wiiu_init,
|
||||
frontend_wiiu_deinit,
|
||||
NULL, /* exitspawn */
|
||||
NULL, /* process_args */
|
||||
NULL, /* exec */
|
||||
NULL, /* set_fork */
|
||||
frontend_wiiu_shutdown,
|
||||
NULL, /* get_name */
|
||||
NULL, /* get_os */
|
||||
frontend_wiiu_get_rating,
|
||||
NULL, /* load_content */
|
||||
frontend_wiiu_get_architecture,
|
||||
NULL, /* get_powerstate */
|
||||
frontend_wiiu_parse_drive_list,
|
||||
NULL, /* get_mem_total */
|
||||
NULL, /* get_mem_free */
|
||||
NULL, /* install_signal_handler */
|
||||
NULL, /* get_signal_handler_state */
|
||||
NULL, /* set_signal_handler_state */
|
||||
NULL, /* destroy_signal_handler_state */
|
||||
NULL, /* attach_console */
|
||||
NULL, /* detach_console */
|
||||
"wiiu",
|
||||
};
|
||||
|
||||
static int log_socket = -1;
|
||||
static volatile int log_lock = 0;
|
||||
|
||||
void log_init(const char * ipString)
|
||||
{
|
||||
log_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
if (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 = 4405;
|
||||
inet_aton(ipString, &connect_addr.sin_addr);
|
||||
|
||||
if(connect(log_socket, (struct sockaddr*)&connect_addr, sizeof(connect_addr)) < 0)
|
||||
{
|
||||
socketclose(log_socket);
|
||||
log_socket = -1;
|
||||
}
|
||||
}
|
||||
|
||||
void log_deinit(void)
|
||||
{
|
||||
if(log_socket >= 0)
|
||||
{
|
||||
socketclose(log_socket);
|
||||
log_socket = -1;
|
||||
}
|
||||
}
|
||||
static int log_write(struct _reent *r, int fd, const char *ptr, size_t len)
|
||||
{
|
||||
if(log_socket < 0)
|
||||
return len;
|
||||
|
||||
while(log_lock)
|
||||
OSSleepTicks(((BUS_SPEED/4)) / 1000);
|
||||
log_lock = 1;
|
||||
|
||||
int ret;
|
||||
while (len > 0) {
|
||||
int block = len < 1400 ? len : 1400; // take max 1400 bytes per UDP packet
|
||||
ret = send(log_socket, ptr, block, 0);
|
||||
if(ret < 0)
|
||||
break;
|
||||
|
||||
len -= ret;
|
||||
ptr += ret;
|
||||
}
|
||||
|
||||
log_lock = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static devoptab_t dotab_stdout = {
|
||||
"stdout", // device name
|
||||
0, // size of file structure
|
||||
NULL, // device open
|
||||
NULL, // device close
|
||||
log_write, // device write
|
||||
NULL, // device read
|
||||
NULL, // device seek
|
||||
NULL, // device fstat
|
||||
NULL, // device stat
|
||||
NULL, // device link
|
||||
NULL, // device unlink
|
||||
NULL, // device chdir
|
||||
NULL, // device rename
|
||||
NULL, // device mkdir
|
||||
0, // dirStateSize
|
||||
NULL, // device diropen_r
|
||||
NULL, // device dirreset_r
|
||||
NULL, // device dirnext_r
|
||||
NULL, // device dirclose_r
|
||||
NULL, // device statvfs_r
|
||||
NULL, // device ftrunctate_r
|
||||
NULL, // device fsync_r
|
||||
NULL, // deviceData;
|
||||
};
|
||||
|
||||
int __entry_menu(int argc, char **argv)
|
||||
{
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
|
||||
log_init("10.42.0.1");
|
||||
|
||||
devoptab_list[STD_OUT] = &dotab_stdout;
|
||||
devoptab_list[STD_ERR] = &dotab_stdout;
|
||||
InitFSFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
memoryInitialize();
|
||||
mount_sd_fat("sd");
|
||||
VPADInit();
|
||||
OSScreenInit();
|
||||
|
||||
int vpadError = -1;
|
||||
VPADData vpad;
|
||||
|
||||
verbosity_enable();
|
||||
DEBUG_VAR(argc);
|
||||
DEBUG_STR(argv[0]);
|
||||
DEBUG_STR(argv[1]);
|
||||
#if 0
|
||||
int argc_ = 2;
|
||||
char* argv_[] = {"retroarch.elf", "sd:/zz.gb"};
|
||||
rarch_main(argc_, argv_, NULL);
|
||||
#else
|
||||
rarch_main(argc, argv, NULL);
|
||||
#endif
|
||||
int frames = 0;
|
||||
do
|
||||
{
|
||||
unsigned sleep_ms = 0;
|
||||
int ret = runloop_iterate(&sleep_ms);
|
||||
|
||||
if (ret == 1 && sleep_ms > 0)
|
||||
retro_sleep(sleep_ms);
|
||||
task_queue_ctl(TASK_QUEUE_CTL_CHECK, NULL);
|
||||
if (ret == -1)
|
||||
break;
|
||||
|
||||
}while(1);
|
||||
// }while(frames++ < 300);
|
||||
|
||||
main_exit(NULL);
|
||||
|
||||
|
||||
printf("Unmount SD\n");
|
||||
unmount_sd_fat("sd");
|
||||
printf("Release memory\n");
|
||||
memoryRelease();
|
||||
log_deinit();
|
||||
|
||||
return 0;
|
||||
}
|
368
gfx/drivers/wiiu_gfx.c
Normal file
368
gfx/drivers/wiiu_gfx.c
Normal file
@ -0,0 +1,368 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2014-2016 - Ali Bouhlel
|
||||
*
|
||||
* 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 "../../driver.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../verbosity.h"
|
||||
|
||||
#include "dynamic_libs/os_functions.h"
|
||||
#include "system/memory.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "wiiu_dbg.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void* screen_buffer0;
|
||||
int screen_buffer0_size;
|
||||
void* screen_buffer1;
|
||||
int screen_buffer1_size;
|
||||
int screen_buffer0_id;
|
||||
int screen_buffer1_id;
|
||||
struct
|
||||
{
|
||||
void* texture;
|
||||
int tex_width;
|
||||
int tex_height;
|
||||
int width;
|
||||
int height;
|
||||
bool enable;
|
||||
}menu;
|
||||
|
||||
void* texture;
|
||||
int tex_width;
|
||||
int tex_height;
|
||||
|
||||
}wiiu_video_t;
|
||||
|
||||
static void *wiiu_gfx_init(const video_info_t *video,
|
||||
const input_driver_t **input, void **input_data)
|
||||
{
|
||||
*input = NULL;
|
||||
*input_data = NULL;
|
||||
|
||||
wiiu_video_t* wiiu = calloc(1, sizeof(*wiiu));
|
||||
if(!wiiu)
|
||||
return NULL;
|
||||
|
||||
wiiu->screen_buffer0_size = OSScreenGetBufferSizeEx(0);
|
||||
wiiu->screen_buffer0 = MEM1_alloc(wiiu->screen_buffer0_size, 0x40);
|
||||
wiiu->screen_buffer1_size = OSScreenGetBufferSizeEx(1);
|
||||
wiiu->screen_buffer1 = MEM1_alloc(wiiu->screen_buffer1_size, 0x40);
|
||||
|
||||
DEBUG_INT(wiiu->screen_buffer0_size);
|
||||
DEBUG_INT(wiiu->screen_buffer1_size);
|
||||
|
||||
OSScreenSetBufferEx(0, wiiu->screen_buffer0);
|
||||
OSScreenSetBufferEx(1, wiiu->screen_buffer1);
|
||||
OSScreenEnableEx(0, 1);
|
||||
OSScreenEnableEx(1, 1);
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
|
||||
DCFlushRange(wiiu->screen_buffer0, wiiu->screen_buffer0_size);
|
||||
DCFlushRange(wiiu->screen_buffer1, wiiu->screen_buffer1_size);
|
||||
|
||||
OSScreenFlipBuffersEx(0);
|
||||
wiiu->screen_buffer0_id = 0;
|
||||
OSScreenFlipBuffersEx(1);
|
||||
wiiu->screen_buffer1_id = 0;
|
||||
|
||||
wiiu->menu.tex_width = 512;
|
||||
wiiu->menu.tex_height = 512;
|
||||
wiiu->menu.texture = malloc(wiiu->menu.tex_width * wiiu->menu.tex_height * sizeof(uint16_t));
|
||||
|
||||
wiiu->tex_width = video->input_scale * RARCH_SCALE_BASE;;
|
||||
wiiu->tex_height = video->input_scale * RARCH_SCALE_BASE;;
|
||||
wiiu->texture = malloc(wiiu->tex_width * wiiu->tex_height * sizeof(uint16_t));
|
||||
|
||||
|
||||
if (input && input_data)
|
||||
{
|
||||
void* wiiuinput = NULL;
|
||||
wiiuinput = input_wiiu.init();
|
||||
*input = wiiuinput ? &input_wiiu : NULL;
|
||||
*input_data = wiiuinput;
|
||||
}
|
||||
|
||||
DEBUG_LINE();
|
||||
|
||||
return wiiu;
|
||||
}
|
||||
static void wiiu_gfx_free(void *data)
|
||||
{
|
||||
wiiu_video_t* wiiu = (wiiu_video_t*) data;
|
||||
|
||||
if(!wiiu)
|
||||
return;
|
||||
|
||||
MEM1_free(wiiu->screen_buffer0);
|
||||
MEM1_free(wiiu->screen_buffer1);
|
||||
free(wiiu->menu.texture);
|
||||
free(wiiu->texture);
|
||||
free(wiiu);
|
||||
DEBUG_LINE();
|
||||
|
||||
}
|
||||
|
||||
static bool wiiu_gfx_frame(void *data, const void *frame,
|
||||
unsigned width, unsigned height, uint64_t frame_count,
|
||||
unsigned pitch, const char *msg)
|
||||
{
|
||||
(void)frame;
|
||||
(void)width;
|
||||
(void)height;
|
||||
(void)pitch;
|
||||
(void)msg;
|
||||
int i;
|
||||
|
||||
wiiu_video_t* wiiu = (wiiu_video_t*) data;
|
||||
|
||||
static int frames = 0;
|
||||
char frames_str [512];
|
||||
snprintf(frames_str, sizeof(frames_str), "frames : %i", frames++);
|
||||
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
// OSScreenPutFontEx(1, 0, 0, "Hello world on DRC!!!");
|
||||
|
||||
const uint16_t* src = (uint16_t*)wiiu->menu.texture;
|
||||
uint32_t* dst = (uint32_t*)((uint8_t*)wiiu->screen_buffer1 + wiiu->screen_buffer1_id * wiiu->screen_buffer1_size / 2);
|
||||
// for (i = 0; i < wiiu->menu.height; i++)
|
||||
// {
|
||||
// memcpy(dst, src, wiiu->menu.width * sizeof(uint16_t));
|
||||
// dst += 896;
|
||||
// src += wiiu->menu.tex_width;
|
||||
// }
|
||||
|
||||
dst += 896 * (480 - wiiu->menu.height) / 2 + (896 - wiiu->menu.width) / 2;
|
||||
int x, y;
|
||||
for(y = 0; y < wiiu->menu.height; y++)
|
||||
{
|
||||
for(x = 0; x < wiiu->menu.width; x++)
|
||||
{
|
||||
int r = ((src[x] >> 12) & 0xF) << 4;
|
||||
int g = ((src[x] >> 8) & 0xF) << 4;
|
||||
int b = ((src[x] >> 4) & 0xF) << 4;
|
||||
// r = 0;
|
||||
// g = 0;
|
||||
// b = 0;
|
||||
dst[x] = (r << 0) | (b << 8) | (g << 16);
|
||||
}
|
||||
src += wiiu->menu.tex_width;
|
||||
dst += 896;
|
||||
}
|
||||
|
||||
|
||||
|
||||
OSScreenPutFontEx(1, 0, 16, frames_str);
|
||||
DCFlushRange(((uint8_t*)wiiu->screen_buffer1 + wiiu->screen_buffer1_id * wiiu->screen_buffer1_size / 2)
|
||||
, wiiu->screen_buffer1_size / 2);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
wiiu->screen_buffer1_id ^= 1;
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void wiiu_gfx_set_nonblock_state(void *data, bool toggle)
|
||||
{
|
||||
(void)data;
|
||||
(void)toggle;
|
||||
}
|
||||
|
||||
static bool wiiu_gfx_alive(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool wiiu_gfx_focus(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool wiiu_gfx_suppress_screensaver(void *data, bool enable)
|
||||
{
|
||||
(void)data;
|
||||
(void)enable;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool wiiu_gfx_has_windowed(void *data)
|
||||
{
|
||||
(void)data;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool wiiu_gfx_set_shader(void *data,
|
||||
enum rarch_shader_type type, const char *path)
|
||||
{
|
||||
(void)data;
|
||||
(void)type;
|
||||
(void)path;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void wiiu_gfx_set_rotation(void *data,
|
||||
unsigned rotation)
|
||||
{
|
||||
(void)data;
|
||||
(void)rotation;
|
||||
}
|
||||
|
||||
static void wiiu_gfx_viewport_info(void *data,
|
||||
struct video_viewport *vp)
|
||||
{
|
||||
(void)data;
|
||||
(void)vp;
|
||||
}
|
||||
|
||||
static bool wiiu_gfx_read_viewport(void *data, uint8_t *buffer)
|
||||
{
|
||||
(void)data;
|
||||
(void)buffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static uintptr_t wiiu_load_texture(void *video_data, void *data,
|
||||
bool threaded, enum texture_filter_type filter_type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static void wiiu_unload_texture(void *data, uintptr_t handle)
|
||||
{
|
||||
|
||||
}
|
||||
static void wiiu_set_filtering(void* data, unsigned index, bool smooth)
|
||||
{
|
||||
}
|
||||
static void wiiu_set_aspect_ratio(void* data, unsigned aspect_ratio_idx)
|
||||
{
|
||||
|
||||
}
|
||||
static void wiiu_apply_state_changes(void* data)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void wiiu_viewport_info(void* data, struct video_viewport* vp)
|
||||
{
|
||||
vp->full_width = 800;
|
||||
vp->full_height = 480;
|
||||
vp->width = 800;
|
||||
vp->height = 480;
|
||||
vp->x = 0;
|
||||
vp->y = 0;
|
||||
}
|
||||
static void wiiu_set_texture_frame(void* data, const void* frame, bool rgb32,
|
||||
unsigned width, unsigned height, float alpha)
|
||||
{
|
||||
int i;
|
||||
wiiu_video_t* wiiu = (wiiu_video_t*) data;
|
||||
if(!wiiu)
|
||||
return;
|
||||
|
||||
if(!frame || !width || !height)
|
||||
return;
|
||||
|
||||
if(width > wiiu->menu.tex_width)
|
||||
width = wiiu->menu.tex_width;
|
||||
if(height > wiiu->menu.tex_height)
|
||||
height = wiiu->menu.tex_height;
|
||||
|
||||
wiiu->menu.width = width;
|
||||
wiiu->menu.height = height;
|
||||
|
||||
const uint16_t* src = frame;
|
||||
uint16_t* dst = (uint16_t*)wiiu->menu.texture;
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
memcpy(dst, src, width * sizeof(uint16_t));
|
||||
dst += wiiu->menu.tex_width;
|
||||
src += width;
|
||||
}
|
||||
}
|
||||
|
||||
static void wiiu_set_texture_enable(void* data, bool state, bool full_screen)
|
||||
{
|
||||
(void) full_screen;
|
||||
wiiu_video_t* wiiu = (wiiu_video_t*) data;
|
||||
wiiu->menu.enable = state;
|
||||
|
||||
}
|
||||
|
||||
static void wiiu_set_osd_msg(void *data, const char *msg,
|
||||
const struct font_params *params, void *font)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
static const video_poke_interface_t wiiu_poke_interface =
|
||||
{
|
||||
wiiu_load_texture,
|
||||
wiiu_unload_texture,
|
||||
NULL,
|
||||
wiiu_set_filtering,
|
||||
NULL, /* get_video_output_size */
|
||||
NULL, /* get_video_output_prev */
|
||||
NULL, /* get_video_output_next */
|
||||
NULL, /* get_current_framebuffer */
|
||||
NULL,
|
||||
wiiu_set_aspect_ratio,
|
||||
wiiu_apply_state_changes,
|
||||
#ifdef HAVE_MENU
|
||||
wiiu_set_texture_frame,
|
||||
wiiu_set_texture_enable,
|
||||
wiiu_set_osd_msg,
|
||||
#endif
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
static void wiiu_gfx_get_poke_interface(void *data,
|
||||
const video_poke_interface_t **iface)
|
||||
{
|
||||
(void)data;
|
||||
*iface = &wiiu_poke_interface;
|
||||
}
|
||||
|
||||
video_driver_t video_wiiu =
|
||||
{
|
||||
wiiu_gfx_init,
|
||||
wiiu_gfx_frame,
|
||||
wiiu_gfx_set_nonblock_state,
|
||||
wiiu_gfx_alive,
|
||||
wiiu_gfx_focus,
|
||||
wiiu_gfx_suppress_screensaver,
|
||||
wiiu_gfx_has_windowed,
|
||||
wiiu_gfx_set_shader,
|
||||
wiiu_gfx_free,
|
||||
"gx2",
|
||||
NULL, /* set_viewport */
|
||||
wiiu_gfx_set_rotation,
|
||||
wiiu_gfx_viewport_info,
|
||||
wiiu_gfx_read_viewport,
|
||||
NULL, /* read_frame_raw */
|
||||
#ifdef HAVE_OVERLAY
|
||||
NULL, /* overlay_interface */
|
||||
#endif
|
||||
wiiu_gfx_get_poke_interface,
|
||||
};
|
@ -185,6 +185,9 @@ static const video_driver_t *video_drivers[] = {
|
||||
#ifdef GEKKO
|
||||
&video_gx,
|
||||
#endif
|
||||
#ifdef WIIU
|
||||
&video_wiiu,
|
||||
#endif
|
||||
#ifdef HAVE_VG
|
||||
&video_vg,
|
||||
#endif
|
||||
|
@ -498,6 +498,7 @@ extern video_driver_t video_vita2d;
|
||||
extern video_driver_t video_ctr;
|
||||
extern video_driver_t video_d3d;
|
||||
extern video_driver_t video_gx;
|
||||
extern video_driver_t video_wiiu;
|
||||
extern video_driver_t video_xenon360;
|
||||
extern video_driver_t video_xvideo;
|
||||
extern video_driver_t video_xdk_d3d;
|
||||
|
@ -95,6 +95,14 @@ static bool nullinput_set_rumble(void *data, unsigned port,
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool nullinput_keyboard_mapping_is_blocked(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
input_driver_t input_null = {
|
||||
nullinput_input_init,
|
||||
nullinput_input_poll,
|
||||
@ -111,5 +119,6 @@ input_driver_t input_null = {
|
||||
nullinput_set_rumble,
|
||||
NULL,
|
||||
NULL,
|
||||
nullinput_keyboard_mapping_is_blocked,
|
||||
NULL,
|
||||
};
|
||||
|
192
input/drivers/wiiu_input.c
Normal file
192
input/drivers/wiiu_input.c
Normal file
@ -0,0 +1,192 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2014-2015 - Ali Bouhlel
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
|
||||
#include <boolean.h>
|
||||
#include <libretro.h>
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
#include "../../configuration.h"
|
||||
#include "../input_config.h"
|
||||
#include "../input_joypad_driver.h"
|
||||
|
||||
#include "wiiu_dbg.h"
|
||||
|
||||
#define MAX_PADS 1
|
||||
|
||||
typedef struct wiiu_input
|
||||
{
|
||||
bool blocked;
|
||||
const input_device_driver_t *joypad;
|
||||
} wiiu_input_t;
|
||||
|
||||
uint64_t lifecycle_state;
|
||||
|
||||
static void wiiu_input_poll(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
|
||||
if (wiiu->joypad)
|
||||
wiiu->joypad->poll();
|
||||
}
|
||||
|
||||
static int16_t wiiu_input_state(void *data, const struct retro_keybind **binds,
|
||||
unsigned port, unsigned device,
|
||||
unsigned idx, unsigned id)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
|
||||
if (port > 0)
|
||||
return 0;
|
||||
|
||||
switch (device)
|
||||
{
|
||||
case RETRO_DEVICE_JOYPAD:
|
||||
if (binds[port][id].valid)
|
||||
return input_joypad_pressed(wiiu->joypad, port, binds[port], id);
|
||||
break;
|
||||
case RETRO_DEVICE_ANALOG:
|
||||
return input_joypad_analog(wiiu->joypad, port, idx, id, binds[port]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wiiu_input_free_input(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
|
||||
if (wiiu && wiiu->joypad)
|
||||
wiiu->joypad->destroy();
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
static void* wiiu_input_initialize(void)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)calloc(1, sizeof(*wiiu));
|
||||
if (!wiiu)
|
||||
return NULL;
|
||||
|
||||
DEBUG_STR(settings->input.joypad_driver);
|
||||
wiiu->joypad = input_joypad_init_driver(settings->input.joypad_driver, wiiu);
|
||||
|
||||
return wiiu;
|
||||
}
|
||||
|
||||
static bool wiiu_input_key_pressed(void *data, int key)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
int port = 0;
|
||||
|
||||
if (settings->input.all_users_control_menu)
|
||||
{
|
||||
for (port = 0; port < MAX_USERS; port++)
|
||||
if (settings->input.binds[0][key].valid &&
|
||||
input_joypad_pressed(wiiu->joypad,
|
||||
port, settings->input.binds[0], key))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
if (settings->input.binds[0][key].valid &&
|
||||
input_joypad_pressed(wiiu->joypad,
|
||||
0, settings->input.binds[0], key))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool wiiu_input_meta_key_pressed(void *data, int key)
|
||||
{
|
||||
if (BIT64_GET(lifecycle_state, key))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static uint64_t wiiu_input_get_capabilities(void *data)
|
||||
{
|
||||
(void)data;
|
||||
|
||||
return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG);
|
||||
}
|
||||
|
||||
static const input_device_driver_t *wiiu_input_get_joypad_driver(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
if (wiiu)
|
||||
return wiiu->joypad;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void wiiu_input_grab_mouse(void *data, bool state)
|
||||
{
|
||||
(void)data;
|
||||
(void)state;
|
||||
}
|
||||
|
||||
static bool wiiu_input_set_rumble(void *data, unsigned port,
|
||||
enum retro_rumble_effect effect, uint16_t strength)
|
||||
{
|
||||
(void)data;
|
||||
(void)port;
|
||||
(void)effect;
|
||||
(void)strength;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool wiiu_input_keyboard_mapping_is_blocked(void *data)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
if (!wiiu)
|
||||
return false;
|
||||
return wiiu->blocked;
|
||||
}
|
||||
|
||||
static void wiiu_input_keyboard_mapping_set_block(void *data, bool value)
|
||||
{
|
||||
wiiu_input_t *wiiu = (wiiu_input_t*)data;
|
||||
if (!wiiu)
|
||||
return;
|
||||
wiiu->blocked = value;
|
||||
}
|
||||
|
||||
input_driver_t input_wiiu = {
|
||||
wiiu_input_initialize,
|
||||
wiiu_input_poll,
|
||||
wiiu_input_state,
|
||||
wiiu_input_key_pressed,
|
||||
wiiu_input_meta_key_pressed,
|
||||
wiiu_input_free_input,
|
||||
NULL,
|
||||
NULL,
|
||||
wiiu_input_get_capabilities,
|
||||
"wiiu",
|
||||
wiiu_input_grab_mouse,
|
||||
NULL,
|
||||
wiiu_input_set_rumble,
|
||||
wiiu_input_get_joypad_driver,
|
||||
NULL,
|
||||
wiiu_input_keyboard_mapping_is_blocked,
|
||||
wiiu_input_keyboard_mapping_set_block,
|
||||
};
|
194
input/drivers_joypad/wiiu_joypad.c
Normal file
194
input/drivers_joypad/wiiu_joypad.c
Normal file
@ -0,0 +1,194 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2011-2016 - Daniel De Matteis
|
||||
* Copyright (C) 2014-2015 - Ali Bouhlel
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "../../config.h"
|
||||
#endif
|
||||
|
||||
#include "../input_joypad_driver.h"
|
||||
#include "../input_driver.h"
|
||||
#include "../input_autodetect.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../runloop.h"
|
||||
#include "../../configuration.h"
|
||||
#include "../../retroarch.h"
|
||||
#include "../../command.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "dynamic_libs/vpad_functions.h"
|
||||
|
||||
#ifndef MAX_PADS
|
||||
#define MAX_PADS 1
|
||||
#endif
|
||||
|
||||
static uint64_t pad_state;
|
||||
static int16_t analog_state[1][2][2];
|
||||
extern uint64_t lifecycle_state;
|
||||
|
||||
static const char *wiiu_joypad_name(unsigned pad)
|
||||
{
|
||||
return "WIIU Controller";
|
||||
}
|
||||
|
||||
static void wiiu_joypad_autodetect_add(unsigned autoconf_pad)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
autoconfig_params_t params = {{0}};
|
||||
|
||||
strlcpy(settings->input.device_names[autoconf_pad],
|
||||
wiiu_joypad_name(autoconf_pad),
|
||||
sizeof(settings->input.device_names[autoconf_pad]));
|
||||
|
||||
/* TODO - implement VID/PID? */
|
||||
params.idx = autoconf_pad;
|
||||
strlcpy(params.name, wiiu_joypad_name(autoconf_pad), sizeof(params.name));
|
||||
strlcpy(params.driver, wiiu_joypad.ident, sizeof(params.driver));
|
||||
input_config_autoconfigure_joypad(¶ms);
|
||||
}
|
||||
|
||||
static bool wiiu_joypad_init(void *data)
|
||||
{
|
||||
wiiu_joypad_autodetect_add(0);
|
||||
|
||||
(void)data;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool wiiu_joypad_button(unsigned port_num, uint16_t key)
|
||||
{
|
||||
if (port_num >= MAX_PADS)
|
||||
return false;
|
||||
|
||||
return (pad_state & (UINT64_C(1) << key));
|
||||
}
|
||||
|
||||
static uint64_t wiiu_joypad_get_buttons(unsigned port_num)
|
||||
{
|
||||
return pad_state;
|
||||
}
|
||||
|
||||
static int16_t wiiu_joypad_axis(unsigned port_num, uint32_t joyaxis)
|
||||
{
|
||||
int val = 0;
|
||||
int axis = -1;
|
||||
bool is_neg = false;
|
||||
bool is_pos = false;
|
||||
|
||||
if (joyaxis == AXIS_NONE || port_num >= MAX_PADS)
|
||||
return 0;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_NEG_GET(joyaxis);
|
||||
is_neg = true;
|
||||
}
|
||||
else if (AXIS_POS_GET(joyaxis) < 4)
|
||||
{
|
||||
axis = AXIS_POS_GET(joyaxis);
|
||||
is_pos = true;
|
||||
}
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case 0:
|
||||
val = analog_state[port_num][0][0];
|
||||
break;
|
||||
case 1:
|
||||
val = analog_state[port_num][0][1];
|
||||
break;
|
||||
case 2:
|
||||
val = analog_state[port_num][1][0];
|
||||
break;
|
||||
case 3:
|
||||
val = analog_state[port_num][1][1];
|
||||
break;
|
||||
}
|
||||
|
||||
if (is_neg && val > 0)
|
||||
val = 0;
|
||||
else if (is_pos && val < 0)
|
||||
val = 0;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static void wiiu_joypad_poll(void)
|
||||
{
|
||||
VPADData vpad;
|
||||
int vpadError = -1;
|
||||
VPADRead(0, &vpad, 1, &vpadError);
|
||||
|
||||
pad_state = 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_LEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_DOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_RIGHT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_UP) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_PLUS) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_MINUS) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_X) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_Y) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_B) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_A) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_R) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_L) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_ZR) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_ZL) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_STICK_R) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0;
|
||||
pad_state |= (vpad.btns_h & VPAD_BUTTON_STICK_L) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0;
|
||||
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = vpad.lstick.x * 0x7FF0;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = -vpad.lstick.y * 0x7FF0;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = vpad.rstick.x * 0x7FF0;
|
||||
analog_state[0][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = -vpad.rstick.y * 0x7FF0;
|
||||
|
||||
BIT64_CLEAR(lifecycle_state, RARCH_MENU_TOGGLE);
|
||||
|
||||
if((vpad.tpdata.touched) && (vpad.tpdata.x > 200))
|
||||
BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE);
|
||||
|
||||
/* panic button */
|
||||
if((vpad.btns_h & VPAD_BUTTON_R) &&
|
||||
(vpad.btns_h & VPAD_BUTTON_L) &&
|
||||
(vpad.btns_h & VPAD_BUTTON_STICK_R) &&
|
||||
(vpad.btns_h & VPAD_BUTTON_STICK_L))
|
||||
command_event(CMD_EVENT_QUIT, NULL);
|
||||
|
||||
}
|
||||
|
||||
static bool wiiu_joypad_query_pad(unsigned pad)
|
||||
{
|
||||
/* FIXME */
|
||||
return pad < MAX_USERS && pad_state;
|
||||
}
|
||||
|
||||
|
||||
static void wiiu_joypad_destroy(void)
|
||||
{
|
||||
}
|
||||
|
||||
input_device_driver_t wiiu_joypad = {
|
||||
wiiu_joypad_init,
|
||||
wiiu_joypad_query_pad,
|
||||
wiiu_joypad_destroy,
|
||||
wiiu_joypad_button,
|
||||
wiiu_joypad_get_buttons,
|
||||
wiiu_joypad_axis,
|
||||
wiiu_joypad_poll,
|
||||
NULL,
|
||||
wiiu_joypad_name,
|
||||
"wiiu",
|
||||
};
|
@ -103,6 +103,30 @@ DECL_AXIS(r_x_minus, -2) \
|
||||
DECL_AXIS(r_y_plus, -3) \
|
||||
DECL_AXIS(r_y_minus, +3)
|
||||
|
||||
#define WIIUINPUT_DEFAULT_BINDS \
|
||||
DECL_BTN(a, 8) \
|
||||
DECL_BTN(b, 0) \
|
||||
DECL_BTN(x, 9) \
|
||||
DECL_BTN(y, 1) \
|
||||
DECL_BTN(start, 3) \
|
||||
DECL_BTN(select, 2) \
|
||||
DECL_BTN(up, 4) \
|
||||
DECL_BTN(down, 5) \
|
||||
DECL_BTN(left, 6) \
|
||||
DECL_BTN(right, 7) \
|
||||
DECL_BTN(l, 10) \
|
||||
DECL_BTN(r, 11) \
|
||||
DECL_BTN(l2, 12) \
|
||||
DECL_BTN(r2, 13) \
|
||||
DECL_AXIS(l_x_plus, +0) \
|
||||
DECL_AXIS(l_x_minus, -0) \
|
||||
DECL_AXIS(l_y_plus, +1) \
|
||||
DECL_AXIS(l_y_minus, -1) \
|
||||
DECL_AXIS(r_x_plus, +2) \
|
||||
DECL_AXIS(r_x_minus, -2) \
|
||||
DECL_AXIS(r_y_plus, -3) \
|
||||
DECL_AXIS(r_y_minus, +3)
|
||||
|
||||
#define GXINPUT_GAMECUBE_DEFAULT_BINDS \
|
||||
DECL_BTN(a, 0) \
|
||||
DECL_BTN(b, 1) \
|
||||
@ -291,6 +315,9 @@ const char* const input_builtin_autoconfs[] =
|
||||
DECL_AUTOCONF_DEVICE("Classic Controller", "gx", GXINPUT_CLASSIC_DEFAULT_BINDS),
|
||||
#endif
|
||||
#endif
|
||||
#ifdef WIIU
|
||||
DECL_AUTOCONF_DEVICE("WIIU Controller", "wiiu", WIIUINPUT_DEFAULT_BINDS),
|
||||
#endif
|
||||
#ifdef __CELLOS_LV2__
|
||||
DECL_AUTOCONF_DEVICE("SixAxis Controller", "ps3", PS3INPUT_DEFAULT_BINDS),
|
||||
#endif
|
||||
|
@ -65,6 +65,9 @@ static const input_driver_t *input_drivers[] = {
|
||||
#ifdef GEKKO
|
||||
&input_gx,
|
||||
#endif
|
||||
#ifdef WIIU
|
||||
&input_wiiu,
|
||||
#endif
|
||||
#ifdef ANDROID
|
||||
&input_android,
|
||||
#endif
|
||||
@ -512,8 +515,8 @@ static bool check_input_driver_block_hotkey(bool enable_hotkey)
|
||||
&settings->input.binds[0][RARCH_ENABLE_HOTKEY];
|
||||
const struct retro_keybind *autoconf_bind =
|
||||
&settings->input.autoconf_binds[0][RARCH_ENABLE_HOTKEY];
|
||||
bool kb_mapping_is_blocked = current_input->keyboard_mapping_is_blocked(
|
||||
current_input_data);
|
||||
bool kb_mapping_is_blocked = current_input->keyboard_mapping_is_blocked &&
|
||||
current_input->keyboard_mapping_is_blocked(current_input_data);
|
||||
|
||||
/* Don't block the check to RARCH_ENABLE_HOTKEY
|
||||
* unless we're really supposed to. */
|
||||
|
@ -314,6 +314,7 @@ extern input_driver_t input_psp;
|
||||
extern input_driver_t input_ctr;
|
||||
extern input_driver_t input_xenon360;
|
||||
extern input_driver_t input_gx;
|
||||
extern input_driver_t input_wiiu;
|
||||
extern input_driver_t input_xinput;
|
||||
extern input_driver_t input_linuxraw;
|
||||
extern input_driver_t input_udev;
|
||||
|
@ -39,6 +39,9 @@ static input_device_driver_t *joypad_drivers[] = {
|
||||
#ifdef GEKKO
|
||||
&gx_joypad,
|
||||
#endif
|
||||
#ifdef WIIU
|
||||
&wiiu_joypad,
|
||||
#endif
|
||||
#ifdef _XBOX
|
||||
&xdk_joypad,
|
||||
#endif
|
||||
|
@ -219,6 +219,7 @@ extern input_device_driver_t psp_joypad;
|
||||
extern input_device_driver_t ctr_joypad;
|
||||
extern input_device_driver_t xdk_joypad;
|
||||
extern input_device_driver_t gx_joypad;
|
||||
extern input_device_driver_t wiiu_joypad;
|
||||
extern input_device_driver_t hid_joypad;
|
||||
extern input_device_driver_t android_joypad;
|
||||
extern input_device_driver_t qnx_joypad;
|
||||
|
@ -168,6 +168,8 @@ retro_perf_tick_t cpu_features_get_perf_counter(void)
|
||||
sceRtcGetCurrentTick((SceRtcTick*)&time_ticks);
|
||||
#elif defined(_3DS)
|
||||
time_ticks = svcGetSystemTick();
|
||||
#elif defined(WIIU)
|
||||
time_ticks = 0;
|
||||
#elif defined(__mips__)
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv,NULL);
|
||||
@ -216,6 +218,8 @@ retro_time_t cpu_features_get_time_usec(void)
|
||||
return osGetTime() * 1000;
|
||||
#elif defined(VITA)
|
||||
return sceKernelGetProcessTimeWide();
|
||||
#elif defined(WIIU)
|
||||
return 0;
|
||||
#else
|
||||
#error "Your platform does not have a timer function implemented in cpu_features_get_time_usec(). Cannot continue."
|
||||
#endif
|
||||
@ -459,6 +463,8 @@ unsigned cpu_features_get_core_amount(void)
|
||||
return 4;
|
||||
#elif defined(_3DS)
|
||||
return 1;
|
||||
#elif defined(WIIU)
|
||||
return 3;
|
||||
#elif defined(_SC_NPROCESSORS_ONLN)
|
||||
/* Linux, most UNIX-likes. */
|
||||
long ret = sysconf(_SC_NPROCESSORS_ONLN);
|
||||
|
@ -23,7 +23,7 @@
|
||||
#ifndef _LIBRETRO_MEMMAP_H
|
||||
#define _LIBRETRO_MEMMAP_H
|
||||
|
||||
#if defined(__CELLOS_LV2__) || defined(PSP) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS)
|
||||
#if defined(__CELLOS_LV2__) || defined(PSP) || defined(GEKKO) || defined(VITA) || defined(_XBOX) || defined(_3DS) || defined(WIIU)
|
||||
/* No mman available */
|
||||
#elif defined(_WIN32) && !defined(_XBOX)
|
||||
#include <windows.h>
|
||||
|
@ -32,6 +32,8 @@
|
||||
#include <time/time.h>
|
||||
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
||||
#include <unistd.h>
|
||||
#elif defined(WIIU)
|
||||
#include <wiiu/dynamic_libs/os_functions.h>
|
||||
#elif defined(PSP)
|
||||
#include <pspthreadman.h>
|
||||
#elif defined(VITA)
|
||||
@ -58,7 +60,7 @@
|
||||
#include <retro_inline.h>
|
||||
|
||||
#ifndef PATH_MAX_LENGTH
|
||||
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)
|
||||
#if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)|| defined(WIIU)
|
||||
#define PATH_MAX_LENGTH 512
|
||||
#else
|
||||
#define PATH_MAX_LENGTH 4096
|
||||
@ -100,6 +102,8 @@ static INLINE void retro_sleep(unsigned msec)
|
||||
udelay(1000 * msec);
|
||||
#elif defined(GEKKO) || defined(__PSL1GHT__) || defined(__QNX__)
|
||||
usleep(1000 * msec);
|
||||
#elif defined(WIIU)
|
||||
OSSleepTicks(((uint64_t)msec * BUS_SPEED)/4000000);
|
||||
#else
|
||||
struct timespec tv = {0};
|
||||
tv.tv_sec = msec / 1000;
|
||||
|
36
wiiu/common/common.h
Normal file
36
wiiu/common/common.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "os_defs.h"
|
||||
|
||||
#define CAFE_OS_SD_PATH "/vol/external01"
|
||||
#define SD_PATH "sd:"
|
||||
#define WIIU_PATH "/wiiu"
|
||||
|
||||
#ifndef MEM_BASE
|
||||
#define MEM_BASE (0x00800000)
|
||||
#endif
|
||||
|
||||
#define ELF_DATA_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x00))
|
||||
#define ELF_DATA_SIZE (*(volatile unsigned int*)(MEM_BASE + 0x1300 + 0x04))
|
||||
#define MAIN_ENTRY_ADDR (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x00))
|
||||
#define OS_FIRMWARE (*(volatile unsigned int*)(MEM_BASE + 0x1400 + 0x04))
|
||||
|
||||
#define OS_SPECIFICS ((OsSpecifics*)(MEM_BASE + 0x1500))
|
||||
|
||||
#ifndef EXIT_SUCCESS
|
||||
#define EXIT_SUCCESS 0
|
||||
#endif
|
||||
#define EXIT_HBL_EXIT 0xFFFFFFFE
|
||||
#define EXIT_RELAUNCH_ON_LOAD 0xFFFFFFFD
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* COMMON_H */
|
||||
|
62
wiiu/common/fs_defs.h
Normal file
62
wiiu/common/fs_defs.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef FS_DEFS_H
|
||||
#define FS_DEFS_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* FS defines and types */
|
||||
#define FS_MAX_LOCALPATH_SIZE 511
|
||||
#define FS_MAX_MOUNTPATH_SIZE 128
|
||||
#define FS_MAX_FULLPATH_SIZE (FS_MAX_LOCALPATH_SIZE + FS_MAX_MOUNTPATH_SIZE)
|
||||
#define FS_MAX_ARGPATH_SIZE FS_MAX_FULLPATH_SIZE
|
||||
|
||||
#define FS_STATUS_OK 0
|
||||
#define FS_RET_UNSUPPORTED_CMD 0x0400
|
||||
#define FS_RET_NO_ERROR 0x0000
|
||||
#define FS_RET_ALL_ERROR (unsigned int)(-1)
|
||||
|
||||
#define FS_STAT_FLAG_IS_DIRECTORY 0x80000000
|
||||
|
||||
/* max length of file/dir name */
|
||||
#define FS_MAX_ENTNAME_SIZE 256
|
||||
|
||||
#define FS_SOURCETYPE_EXTERNAL 0
|
||||
#define FS_SOURCETYPE_HFIO 1
|
||||
#define FS_SOURCETYPE_HFIO 1
|
||||
|
||||
#define FS_MOUNT_SOURCE_SIZE 0x300
|
||||
#define FS_CLIENT_SIZE 0x1700
|
||||
#define FS_CMD_BLOCK_SIZE 0xA80
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t flag;
|
||||
uint32_t permission;
|
||||
uint32_t owner_id;
|
||||
uint32_t group_id;
|
||||
uint32_t size;
|
||||
uint32_t alloc_size;
|
||||
uint64_t quota_size;
|
||||
uint32_t ent_id;
|
||||
uint64_t ctime;
|
||||
uint64_t mtime;
|
||||
uint8_t attributes[48];
|
||||
} __attribute__((packed)) FSStat;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FSStat stat;
|
||||
char name[FS_MAX_ENTNAME_SIZE];
|
||||
} FSDirEntry;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* FS_DEFS_H */
|
||||
|
25
wiiu/common/os_defs.h
Normal file
25
wiiu/common/os_defs.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __OS_DEFS_H_
|
||||
#define __OS_DEFS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _OsSpecifics
|
||||
{
|
||||
unsigned int addr_OSDynLoad_Acquire;
|
||||
unsigned int addr_OSDynLoad_FindExport;
|
||||
unsigned int addr_OSTitle_main_entry;
|
||||
|
||||
unsigned int addr_KernSyscallTbl1;
|
||||
unsigned int addr_KernSyscallTbl2;
|
||||
unsigned int addr_KernSyscallTbl3;
|
||||
unsigned int addr_KernSyscallTbl4;
|
||||
unsigned int addr_KernSyscallTbl5;
|
||||
} OsSpecifics;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __OS_DEFS_H_
|
7
wiiu/common/types.h
Normal file
7
wiiu/common/types.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef TYPES_H
|
||||
#define TYPES_H
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#endif /* TYPES_H */
|
||||
|
74
wiiu/dynamic_libs/ax_functions.c
Normal file
74
wiiu/dynamic_libs/ax_functions.c
Normal file
@ -0,0 +1,74 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "os_functions.h"
|
||||
#include "ax_functions.h"
|
||||
|
||||
EXPORT_DECL(void, AXInitWithParams, u32 * params);
|
||||
EXPORT_DECL(void, AXQuit, void);
|
||||
EXPORT_DECL(u32, AXGetInputSamplesPerSec, void);
|
||||
EXPORT_DECL(u32, AXGetInputSamplesPerFrame, void);
|
||||
EXPORT_DECL(s32, AXVoiceBegin, void *v);
|
||||
EXPORT_DECL(s32, AXVoiceEnd, void *v);
|
||||
EXPORT_DECL(void, AXSetVoiceType, void *v, u16 type);
|
||||
EXPORT_DECL(void, AXSetVoiceOffsets, void *v, const void *buf);
|
||||
EXPORT_DECL(void, AXSetVoiceSrcType, void *v, u32 type);
|
||||
EXPORT_DECL(void, AXSetVoiceVe, void *v, const void *vol);
|
||||
EXPORT_DECL(s32, AXSetVoiceDeviceMix, void *v, s32 device, u32 id, void *mix);
|
||||
EXPORT_DECL(void, AXSetVoiceState, void *v, u16 state);
|
||||
EXPORT_DECL(void, AXSetVoiceSrc, void *v, const void *src);
|
||||
EXPORT_DECL(s32, AXSetVoiceSrcRatio, void *v,f32 ratio)
|
||||
EXPORT_DECL(void *, AXAcquireVoice, u32 prio, void * callback, u32 arg);
|
||||
EXPORT_DECL(void, AXFreeVoice, void *v);
|
||||
EXPORT_DECL(void, AXRegisterFrameCallback, void * callback);
|
||||
EXPORT_DECL(u32, AXGetVoiceLoopCount, void *v);
|
||||
EXPORT_DECL(void, AXSetVoiceEndOffset, void *v, u32 offset);
|
||||
EXPORT_DECL(void, AXSetVoiceLoopOffset, void *v, u32 offset);
|
||||
|
||||
void InitAXFunctionPointers(void)
|
||||
{
|
||||
unsigned int *funcPointer = 0;
|
||||
unsigned int sound_handle;
|
||||
OSDynLoad_Acquire("sndcore2.rpl", &sound_handle);
|
||||
|
||||
OS_FIND_EXPORT(sound_handle, AXInitWithParams);
|
||||
OS_FIND_EXPORT(sound_handle, AXQuit);
|
||||
OS_FIND_EXPORT(sound_handle, AXGetInputSamplesPerSec);
|
||||
OS_FIND_EXPORT(sound_handle, AXVoiceBegin);
|
||||
OS_FIND_EXPORT(sound_handle, AXVoiceEnd);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceType);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceOffsets);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceSrcType);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceVe);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceDeviceMix);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceState);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceSrc);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceSrcRatio);
|
||||
OS_FIND_EXPORT(sound_handle, AXAcquireVoice);
|
||||
OS_FIND_EXPORT(sound_handle, AXFreeVoice);
|
||||
OS_FIND_EXPORT(sound_handle, AXRegisterFrameCallback);
|
||||
OS_FIND_EXPORT(sound_handle, AXGetVoiceLoopCount);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceEndOffset);
|
||||
OS_FIND_EXPORT(sound_handle, AXSetVoiceLoopOffset);
|
||||
}
|
||||
|
59
wiiu/dynamic_libs/ax_functions.h
Normal file
59
wiiu/dynamic_libs/ax_functions.h
Normal file
@ -0,0 +1,59 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __AX_FUNCTIONS_H_
|
||||
#define __AX_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
void InitAXFunctionPointers(void);
|
||||
|
||||
extern void (* AXInitWithParams)(u32 * params);
|
||||
extern void (* AXQuit)(void);
|
||||
extern u32 (* AXGetInputSamplesPerSec)(void);
|
||||
extern s32 (* AXVoiceBegin)(void *v);
|
||||
extern s32 (* AXVoiceEnd)(void *v);
|
||||
extern void (* AXSetVoiceType)(void *v, u16 type);
|
||||
extern void (* AXSetVoiceOffsets)(void *v, const void *buf);
|
||||
extern void (* AXSetVoiceSrcType)(void *v, u32 type);
|
||||
extern void (* AXSetVoiceVe)(void *v, const void *vol);
|
||||
extern s32 (* AXSetVoiceDeviceMix)(void *v, s32 device, u32 id, void *mix);
|
||||
extern void (* AXSetVoiceState)(void *v, u16 state);
|
||||
extern void (* AXSetVoiceSrc)(void *v, const void *src);
|
||||
extern s32 (* AXSetVoiceSrcRatio)(void *v, f32 ratio);
|
||||
extern void * (* AXAcquireVoice)(u32 prio, void * callback, u32 arg);
|
||||
extern void (* AXFreeVoice)(void *v);
|
||||
extern void (* AXRegisterFrameCallback)(void * callback);
|
||||
extern u32 (* AXGetVoiceLoopCount)(void * v);
|
||||
extern void (* AXSetVoiceEndOffset)(void * v, u32 offset);
|
||||
extern void (* AXSetVoiceLoopOffset)(void * v, u32 offset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __VPAD_FUNCTIONS_H_
|
120
wiiu/dynamic_libs/fs_functions.c
Normal file
120
wiiu/dynamic_libs/fs_functions.c
Normal file
@ -0,0 +1,120 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "fs_functions.h"
|
||||
#include "os_functions.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
EXPORT_DECL(int, FSInit, void);
|
||||
EXPORT_DECL(int, FSShutdown, void);
|
||||
EXPORT_DECL(int, FSAddClientEx, void *pClient, int unk_zero_param, int errHandling);
|
||||
EXPORT_DECL(int, FSDelClient, void *pClient);
|
||||
EXPORT_DECL(void, FSInitCmdBlock, void *pCmd);
|
||||
EXPORT_DECL(int, FSGetMountSource, void *pClient, void *pCmd, int type, void *source, int errHandling);
|
||||
|
||||
EXPORT_DECL(int, FSMount, void *pClient, void *pCmd, void *source, char *target, uint32_t bytes, int errHandling);
|
||||
EXPORT_DECL(int, FSUnmount, void *pClient, void *pCmd, const char *target, int errHandling);
|
||||
|
||||
EXPORT_DECL(int, FSGetStat, void *pClient, void *pCmd, const char *path, FSStat *stats, int errHandling);
|
||||
EXPORT_DECL(int, FSGetStatAsync, void *pClient, void *pCmd, const char *path, void *stats, int error, void *asyncParams);
|
||||
EXPORT_DECL(int, FSRename, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error);
|
||||
EXPORT_DECL(int, FSRenameAsync, void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams);
|
||||
EXPORT_DECL(int, FSRemove, void *pClient, void *pCmd, const char *path, int error);
|
||||
EXPORT_DECL(int, FSRemoveAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
EXPORT_DECL(int, FSFlushQuota, void *pClient, void *pCmd, const char* path, int error);
|
||||
EXPORT_DECL(int, FSFlushQuotaAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
EXPORT_DECL(int, FSGetFreeSpaceSize, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error);
|
||||
EXPORT_DECL(int, FSGetFreeSpaceSizeAsync, void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error, void *asyncParams);
|
||||
EXPORT_DECL(int, FSRollbackQuota, void *pClient, void *pCmd, const char *path, int error);
|
||||
EXPORT_DECL(int, FSRollbackQuotaAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
|
||||
EXPORT_DECL(int, FSOpenDir, void *pClient, void *pCmd, const char *path, int *dh, int errHandling);
|
||||
EXPORT_DECL(int, FSOpenDirAsync, void *pClient, void* pCmd, const char *path, int *handle, int error, void *asyncParams);
|
||||
EXPORT_DECL(int, FSReadDir, void *pClient, void *pCmd, int dh, FSDirEntry *dir_entry, int errHandling);
|
||||
EXPORT_DECL(int, FSRewindDir, void *pClient, void *pCmd, int dh, int errHandling);
|
||||
EXPORT_DECL(int, FSCloseDir, void *pClient, void *pCmd, int dh, int errHandling);
|
||||
EXPORT_DECL(int, FSChangeDir, void *pClient, void *pCmd, const char *path, int errHandling);
|
||||
EXPORT_DECL(int, FSChangeDirAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
EXPORT_DECL(int, FSMakeDir, void *pClient, void *pCmd, const char *path, int errHandling);
|
||||
EXPORT_DECL(int, FSMakeDirAsync, void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
|
||||
EXPORT_DECL(int, FSOpenFile, void *pClient, void *pCmd, const char *path, const char *mode, int *fd, int errHandling);
|
||||
EXPORT_DECL(int, FSOpenFileAsync, void *pClient, void *pCmd, const char *path, const char *mode, int *handle, int error, const void *asyncParams);
|
||||
EXPORT_DECL(int, FSReadFile, void *pClient, void *pCmd, void *buffer, int size, int count, int fd, int flag, int errHandling);
|
||||
EXPORT_DECL(int, FSCloseFile, void *pClient, void *pCmd, int fd, int errHandling);
|
||||
|
||||
EXPORT_DECL(int, FSFlushFile, void *pClient, void *pCmd, int fd, int error);
|
||||
EXPORT_DECL(int, FSTruncateFile, void *pClient, void *pCmd, int fd, int error);
|
||||
EXPORT_DECL(int, FSGetStatFile, void *pClient, void *pCmd, int fd, void *buffer, int error);
|
||||
EXPORT_DECL(int, FSSetPosFile, void *pClient, void *pCmd, int fd, int pos, int error);
|
||||
EXPORT_DECL(int, FSWriteFile, void *pClient, void *pCmd, const void *source, int block_size, int block_count, int fd, int flag, int error);
|
||||
|
||||
void InitFSFunctionPointers(void)
|
||||
{
|
||||
unsigned int *funcPointer = 0;
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSInit);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSShutdown);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSAddClientEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSDelClient);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSInitCmdBlock);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetMountSource);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSMount);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSUnmount);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetStat);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetStatAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRename);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRenameAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRemove);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRemoveAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSFlushQuota);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSFlushQuotaAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSize);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetFreeSpaceSizeAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRollbackQuota);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRollbackQuotaAsync);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSOpenDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSOpenDirAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSReadDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSRewindDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSCloseDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSChangeDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSChangeDirAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSMakeDir);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSMakeDirAsync);
|
||||
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSOpenFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSOpenFileAsync);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSReadFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSCloseFile);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, FSFlushFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSTruncateFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSGetStatFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSSetPosFile);
|
||||
OS_FIND_EXPORT(coreinit_handle, FSWriteFile);
|
||||
}
|
87
wiiu/dynamic_libs/fs_functions.h
Normal file
87
wiiu/dynamic_libs/fs_functions.h
Normal file
@ -0,0 +1,87 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __FS_FUNCTIONS_H_
|
||||
#define __FS_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "common/fs_defs.h"
|
||||
|
||||
void InitFSFunctionPointers(void);
|
||||
|
||||
extern int (* FSInit)(void);
|
||||
extern int (* FSShutdown)(void);
|
||||
extern int (* FSAddClientEx)(void *pClient, int unk_zero_param, int errHandling);
|
||||
extern int (* FSDelClient)(void *pClient);
|
||||
extern void (* FSInitCmdBlock)(void *pCmd);
|
||||
extern int (* FSGetMountSource)(void *pClient, void *pCmd, int type, void *source, int errHandling);
|
||||
|
||||
extern int (* FSMount)(void *pClient, void *pCmd, void *source, char *target, uint32_t bytes, int errHandling);
|
||||
extern int (* FSUnmount)(void *pClient, void *pCmd, const char *target, int errHandling);
|
||||
extern int (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error);
|
||||
extern int (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams);
|
||||
extern int (* FSRemove)(void *pClient, void *pCmd, const char *path, int error);
|
||||
extern int (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
|
||||
extern int (* FSGetStat)(void *pClient, void *pCmd, const char *path, FSStat *stats, int errHandling);
|
||||
extern int (* FSGetStatAsync)(void *pClient, void *pCmd, const char *path, void *stats, int error, void *asyncParams);
|
||||
extern int (* FSRename)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error);
|
||||
extern int (* FSRenameAsync)(void *pClient, void *pCmd, const char *oldPath, const char *newPath, int error, void *asyncParams);
|
||||
extern int (* FSRemove)(void *pClient, void *pCmd, const char *path, int error);
|
||||
extern int (* FSRemoveAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
extern int (* FSFlushQuota)(void *pClient, void *pCmd, const char* path, int error);
|
||||
extern int (* FSFlushQuotaAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
extern int (* FSGetFreeSpaceSize)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error);
|
||||
extern int (* FSGetFreeSpaceSizeAsync)(void *pClient, void *pCmd, const char *path, uint64_t *returnedFreeSize, int error, void *asyncParams);
|
||||
extern int (* FSRollbackQuota)(void *pClient, void *pCmd, const char *path, int error);
|
||||
extern int (* FSRollbackQuotaAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
|
||||
extern int (* FSOpenDir)(void *pClient, void *pCmd, const char *path, int *dh, int errHandling);
|
||||
extern int (* FSOpenDirAsync)(void *pClient, void* pCmd, const char *path, int *handle, int error, void *asyncParams);
|
||||
extern int (* FSReadDir)(void *pClient, void *pCmd, int dh, FSDirEntry *dir_entry, int errHandling);
|
||||
extern int (* FSRewindDir)(void *pClient, void *pCmd, int dh, int errHandling);
|
||||
extern int (* FSCloseDir)(void *pClient, void *pCmd, int dh, int errHandling);
|
||||
extern int (* FSChangeDir)(void *pClient, void *pCmd, const char *path, int errHandling);
|
||||
extern int (* FSChangeDirAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
extern int (* FSMakeDir)(void *pClient, void *pCmd, const char *path, int errHandling);
|
||||
extern int (* FSMakeDirAsync)(void *pClient, void *pCmd, const char *path, int error, void *asyncParams);
|
||||
|
||||
extern int (* FSOpenFile)(void *pClient, void *pCmd, const char *path, const char *mode, int *fd, int errHandling);
|
||||
extern int (* FSOpenFileAsync)(void *pClient, void *pCmd, const char *path, const char *mode, int *handle, int error, const void *asyncParams);
|
||||
extern int (* FSReadFile)(void *pClient, void *pCmd, void *buffer, int size, int count, int fd, int flag, int errHandling);
|
||||
extern int (* FSCloseFile)(void *pClient, void *pCmd, int fd, int errHandling);
|
||||
|
||||
extern int (* FSFlushFile)(void *pClient, void *pCmd, int fd, int error);
|
||||
extern int (* FSTruncateFile)(void *pClient, void *pCmd, int fd, int error);
|
||||
extern int (* FSGetStatFile)(void *pClient, void *pCmd, int fd, void *buffer, int error);
|
||||
extern int (* FSSetPosFile)(void *pClient, void *pCmd, int fd, int pos, int error);
|
||||
extern int (* FSWriteFile)(void *pClient, void *pCmd, const void *source, int block_size, int block_count, int fd, int flag, int error);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __FS_FUNCTIONS_H_
|
162
wiiu/dynamic_libs/gx2_functions.c
Normal file
162
wiiu/dynamic_libs/gx2_functions.c
Normal file
@ -0,0 +1,162 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "os_functions.h"
|
||||
#include "gx2_types.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
EXPORT_DECL(void, GX2Init, u32 * init_attribs);
|
||||
EXPORT_DECL(void, GX2Shutdown, void);
|
||||
EXPORT_DECL(void, GX2Flush, void);
|
||||
EXPORT_DECL(s32, GX2GetMainCoreId, void) ;
|
||||
EXPORT_DECL(s32, GX2DrawDone, void);
|
||||
EXPORT_DECL(void, GX2ClearColor, GX2ColorBuffer *colorBuffer, f32 r, f32 g, f32 b, f32 a);
|
||||
EXPORT_DECL(void, GX2SetViewport, f32 x, f32 y, f32 w, f32 h, f32 nearZ, f32 farZ);
|
||||
EXPORT_DECL(void, GX2SetScissor, u32 x_orig, u32 y_orig, u32 wd, u32 ht);
|
||||
EXPORT_DECL(void, GX2SetContextState, const GX2ContextState* state);
|
||||
EXPORT_DECL(void, GX2DrawEx, s32 primitive_type, u32 count, u32 first_vertex, u32 instances_count);
|
||||
EXPORT_DECL(void, GX2DrawIndexedEx, s32 primitive_type, u32 count, s32 index_format, const void* idx, u32 first_vertex, u32 instances_count);
|
||||
EXPORT_DECL(void, GX2ClearDepthStencilEx, GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value, s32 clear_mode);
|
||||
EXPORT_DECL(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, s32 scan_target);
|
||||
EXPORT_DECL(void, GX2SwapScanBuffers, void);
|
||||
EXPORT_DECL(void, GX2SetTVEnable, s32 enable);
|
||||
EXPORT_DECL(void, GX2SetSwapInterval, u32 swap_interval);
|
||||
EXPORT_DECL(u32, GX2GetSwapInterval, void);
|
||||
EXPORT_DECL(void, GX2WaitForVsync, void);
|
||||
EXPORT_DECL(void, GX2CalcTVSize, s32 tv_render_mode, s32 format, s32 buffering_mode, u32 * size, s32 * scale_needed);
|
||||
EXPORT_DECL(void, GX2Invalidate, s32 invalidate_type, void * ptr, u32 buffer_size);
|
||||
EXPORT_DECL(void, GX2SetTVBuffer, void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode);
|
||||
EXPORT_DECL(void, GX2CalcSurfaceSizeAndAlignment, GX2Surface *surface);
|
||||
EXPORT_DECL(void, GX2InitDepthBufferRegs, GX2DepthBuffer *depthBuffer);
|
||||
EXPORT_DECL(void, GX2InitColorBufferRegs, GX2ColorBuffer *colorBuffer);
|
||||
EXPORT_DECL(void, GX2CalcColorBufferAuxInfo, GX2ColorBuffer *colorBuffer, u32 *size, u32 *align);
|
||||
EXPORT_DECL(void, GX2CalcDepthBufferHiZInfo, GX2DepthBuffer *depthBuffer, u32 *size, u32 *align);
|
||||
EXPORT_DECL(void, GX2InitDepthBufferHiZEnable, GX2DepthBuffer *depthBuffer, s32 hiZ_enable);
|
||||
EXPORT_DECL(void, GX2SetupContextStateEx, GX2ContextState* state, s32 enable_profiling);
|
||||
EXPORT_DECL(void, GX2SetColorBuffer, const GX2ColorBuffer *colorBuffer, s32 target);
|
||||
EXPORT_DECL(void, GX2SetDepthBuffer, const GX2DepthBuffer *depthBuffer);
|
||||
EXPORT_DECL(void, GX2SetAttribBuffer, u32 attr_index, u32 attr_size, u32 stride, const void* attr);
|
||||
EXPORT_DECL(void, GX2InitTextureRegs, GX2Texture *texture);
|
||||
EXPORT_DECL(void, GX2InitSampler, GX2Sampler *sampler, s32 tex_clamp, s32 min_mag_filter);
|
||||
EXPORT_DECL(u32, GX2CalcFetchShaderSizeEx, u32 num_attrib, s32 fetch_shader_type, s32 tessellation_mode);
|
||||
EXPORT_DECL(void, GX2InitFetchShaderEx, GX2FetchShader* fs, void* fs_buffer, u32 count, const GX2AttribStream* attribs, s32 fetch_shader_type, s32 tessellation_mode);
|
||||
EXPORT_DECL(void, GX2SetFetchShader, const GX2FetchShader* fs);
|
||||
EXPORT_DECL(void, GX2SetVertexUniformReg, u32 offset, u32 count, const void *values);
|
||||
EXPORT_DECL(void, GX2SetPixelUniformReg, u32 offset, u32 count, const void *values);
|
||||
EXPORT_DECL(void, GX2SetPixelTexture, const GX2Texture *texture, u32 texture_hw_location);
|
||||
EXPORT_DECL(void, GX2SetVertexTexture, const GX2Texture *texture, u32 texture_hw_location);
|
||||
EXPORT_DECL(void, GX2SetPixelSampler, const GX2Sampler *sampler, u32 sampler_hw_location);
|
||||
EXPORT_DECL(void, GX2SetVertexSampler, const GX2Sampler *sampler, u32 sampler_hw_location);
|
||||
EXPORT_DECL(void, GX2SetPixelShader, const GX2PixelShader* pixelShader);
|
||||
EXPORT_DECL(void, GX2SetVertexShader, const GX2VertexShader* vertexShader);
|
||||
EXPORT_DECL(void, GX2InitSamplerZMFilter, GX2Sampler *sampler, s32 z_filter, s32 mip_filter);
|
||||
EXPORT_DECL(void, GX2SetColorControl, s32 lop, u8 blend_enable_mask, s32 enable_multi_write, s32 enable_color_buffer);
|
||||
EXPORT_DECL(void, GX2SetDepthOnlyControl, s32 enable_depth, s32 enable_depth_write, s32 depth_comp_function);
|
||||
EXPORT_DECL(void, GX2SetBlendControl, s32 target, s32 color_src_blend, s32 color_dst_blend, s32 color_combine, s32 separate_alpha_blend, s32 alpha_src_blend, s32 alpha_dst_blend, s32 alpha_combine);
|
||||
EXPORT_DECL(void, GX2CalcDRCSize, s32 drc_mode, s32 format, s32 buffering_mode, u32 *size, s32 *scale_needed);
|
||||
EXPORT_DECL(void, GX2SetDRCBuffer, void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode);
|
||||
EXPORT_DECL(void, GX2SetDRCScale, u32 width, u32 height);
|
||||
EXPORT_DECL(void, GX2SetDRCEnable, s32 enable);
|
||||
EXPORT_DECL(void, GX2SetPolygonControl, s32 front_face_mode, s32 cull_front, s32 cull_back, s32 enable_mode, s32 mode_font, s32 mode_back, s32 poly_offset_front, s32 poly_offset_back, s32 point_line_offset);
|
||||
EXPORT_DECL(void, GX2SetCullOnlyControl, s32 front_face_mode, s32 cull_front, s32 cull_back);
|
||||
EXPORT_DECL(void, GX2SetDepthStencilControl, s32 enable_depth_test, s32 enable_depth_write, s32 depth_comp_function, s32 stencil_test_enable, s32 back_stencil_enable,
|
||||
s32 font_stencil_func, s32 front_stencil_z_pass, s32 front_stencil_z_fail, s32 front_stencil_fail,
|
||||
s32 back_stencil_func, s32 back_stencil_z_pass, s32 back_stencil_z_fail, s32 back_stencil_fail);
|
||||
EXPORT_DECL(void, GX2SetStencilMask, u8 mask_front, u8 write_mask_front, u8 ref_front, u8 mask_back, u8 write_mask_back, u8 ref_back);
|
||||
EXPORT_DECL(void, GX2SetLineWidth, f32 width);
|
||||
EXPORT_DECL(void, GX2SetTVGamma, f32 val);
|
||||
EXPORT_DECL(void, GX2SetDRCGamma, f32 gam);
|
||||
EXPORT_DECL(s32, GX2GetSystemTVScanMode, void);
|
||||
EXPORT_DECL(s32, GX2GetSystemDRCScanMode, void);
|
||||
EXPORT_DECL(void, GX2RSetAllocator, void * (* allocFunc)(u32, u32, u32), void (* freeFunc)(u32, void*));
|
||||
|
||||
|
||||
void InitGX2FunctionPointers(void)
|
||||
{
|
||||
unsigned int *funcPointer = 0;
|
||||
unsigned int gx2_handle;
|
||||
OSDynLoad_Acquire("gx2.rpl", &gx2_handle);
|
||||
|
||||
OS_FIND_EXPORT(gx2_handle, GX2Init);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2Shutdown);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2Flush);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetMainCoreId);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2DrawDone);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2ClearColor);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetViewport);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetScissor);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetContextState);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2DrawEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2DrawIndexedEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2ClearDepthStencilEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CopyColorBufferToScanBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SwapScanBuffers);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetTVEnable);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetSwapInterval);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetSwapInterval);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2WaitForVsync);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcTVSize);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2Invalidate);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetTVBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcSurfaceSizeAndAlignment);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferRegs);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitColorBufferRegs);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcColorBufferAuxInfo);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcDepthBufferHiZInfo);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitDepthBufferHiZEnable);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetupContextStateEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetColorBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDepthBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetAttribBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitTextureRegs);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitSampler);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcFetchShaderSizeEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitFetchShaderEx);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetFetchShader);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetVertexUniformReg);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPixelUniformReg);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPixelTexture);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetVertexTexture);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPixelSampler);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetVertexSampler);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPixelShader);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetVertexShader);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2InitSamplerZMFilter);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetColorControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDepthOnlyControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetBlendControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2CalcDRCSize);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDRCBuffer);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDRCScale);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDRCEnable);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetPolygonControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetCullOnlyControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDepthStencilControl);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetStencilMask);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetLineWidth);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetDRCGamma);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2SetTVGamma);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetSystemTVScanMode);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2GetSystemDRCScanMode);
|
||||
OS_FIND_EXPORT(gx2_handle, GX2RSetAllocator);
|
||||
}
|
205
wiiu/dynamic_libs/gx2_functions.h
Normal file
205
wiiu/dynamic_libs/gx2_functions.h
Normal file
@ -0,0 +1,205 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __GX2_FUNCTIONS_H_
|
||||
#define __GX2_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "gx2_types.h"
|
||||
|
||||
void InitGX2FunctionPointers(void);
|
||||
|
||||
extern void (* GX2Init)(u32 * init_attribs);
|
||||
extern void (* GX2Shutdown)(void);
|
||||
extern void (* GX2Flush)(void);
|
||||
extern s32 (* GX2GetMainCoreId)(void) ;
|
||||
extern s32 (* GX2DrawDone)(void);
|
||||
extern void (* GX2ClearColor)(GX2ColorBuffer *colorBuffer, f32 r, f32 g, f32 b, f32 a);
|
||||
extern void (* GX2SetViewport)(f32 x, f32 y, f32 w, f32 h, f32 nearZ, f32 farZ);
|
||||
extern void (* GX2SetScissor)(u32 x_orig, u32 y_orig, u32 wd, u32 ht);
|
||||
extern void (* GX2SetContextState)(const GX2ContextState* state);
|
||||
extern void (* GX2DrawEx)(s32 primitive_type, u32 count, u32 first_vertex, u32 instances_count);
|
||||
extern void (* GX2DrawIndexedEx)(s32 primitive_type, u32 count, s32 index_format, const void* idx, u32 first_vertex, u32 instances_count);
|
||||
extern void (* GX2ClearDepthStencilEx)(GX2DepthBuffer *depthBuffer, f32 depth_value, u8 stencil_value, s32 clear_mode);
|
||||
extern void (* GX2CopyColorBufferToScanBuffer)(const GX2ColorBuffer *colorBuffer, s32 scan_target);
|
||||
extern void (* GX2SwapScanBuffers)(void);
|
||||
extern void (* GX2SetTVEnable)(s32 enable);
|
||||
extern void (* GX2SetSwapInterval)(u32 swap_interval);
|
||||
extern u32 (* GX2GetSwapInterval)(void);
|
||||
extern void (* GX2WaitForVsync)(void);
|
||||
extern void (* GX2CalcTVSize)(s32 tv_render_mode, s32 format, s32 buffering_mode, u32 * size, s32 * scale_needed);
|
||||
extern void (* GX2Invalidate)(s32 invalidate_type, void * ptr, u32 buffer_size);
|
||||
extern void (* GX2SetTVBuffer)(void *buffer, u32 buffer_size, s32 tv_render_mode, s32 format, s32 buffering_mode);
|
||||
extern void (* GX2CalcSurfaceSizeAndAlignment)(GX2Surface *surface);
|
||||
extern void (* GX2InitDepthBufferRegs)(GX2DepthBuffer *depthBuffer);
|
||||
extern void (* GX2InitColorBufferRegs)(GX2ColorBuffer *colorBuffer);
|
||||
extern void (* GX2CalcColorBufferAuxInfo)(GX2ColorBuffer *colorBuffer, u32 *size, u32 *align);
|
||||
extern void (* GX2CalcDepthBufferHiZInfo)(GX2DepthBuffer *depthBuffer, u32 *size, u32 *align);
|
||||
extern void (* GX2InitDepthBufferHiZEnable)(GX2DepthBuffer *depthBuffer, s32 hiZ_enable);
|
||||
extern void (* GX2SetupContextStateEx)(GX2ContextState* state, s32 enable_profiling);
|
||||
extern void (* GX2SetColorBuffer)(const GX2ColorBuffer *colorBuffer, s32 target);
|
||||
extern void (* GX2SetDepthBuffer)(const GX2DepthBuffer *depthBuffer);
|
||||
extern void (* GX2SetAttribBuffer)(u32 attr_index, u32 attr_size, u32 stride, const void* attr);
|
||||
extern void (* GX2InitTextureRegs)(GX2Texture *texture);
|
||||
extern void (* GX2InitSampler)(GX2Sampler *sampler, s32 tex_clamp, s32 min_mag_filter);
|
||||
extern u32 (* GX2CalcFetchShaderSizeEx)(u32 num_attrib, s32 fetch_shader_type, s32 tessellation_mode);
|
||||
extern void (* GX2InitFetchShaderEx)(GX2FetchShader* fs, void* fs_buffer, u32 count, const GX2AttribStream* attribs, s32 fetch_shader_type, s32 tessellation_mode);
|
||||
extern void (* GX2SetFetchShader)(const GX2FetchShader* fs);
|
||||
extern void (* GX2SetVertexUniformReg)(u32 offset, u32 count, const void *values);
|
||||
extern void (* GX2SetPixelUniformReg)(u32 offset, u32 count, const void *values);
|
||||
extern void (* GX2SetPixelTexture)(const GX2Texture *texture, u32 texture_hw_location);
|
||||
extern void (* GX2SetVertexTexture)(const GX2Texture *texture, u32 texture_hw_location);
|
||||
extern void (* GX2SetPixelSampler)(const GX2Sampler *sampler, u32 sampler_hw_location);
|
||||
extern void (* GX2SetVertexSampler)(const GX2Sampler *sampler, u32 sampler_hw_location);
|
||||
extern void (* GX2SetPixelShader)(const GX2PixelShader* pixelShader);
|
||||
extern void (* GX2SetVertexShader)(const GX2VertexShader* vertexShader);
|
||||
extern void (* GX2InitSamplerZMFilter)(GX2Sampler *sampler, s32 z_filter, s32 mip_filter);
|
||||
extern void (* GX2SetColorControl)(s32 lop, u8 blend_enable_mask, s32 enable_multi_write, s32 enable_color_buffer);
|
||||
extern void (* GX2SetDepthOnlyControl)(s32 enable_depth, s32 enable_depth_write, s32 depth_comp_function);
|
||||
extern void (* GX2SetBlendControl)(s32 target, s32 color_src_blend, s32 color_dst_blend, s32 color_combine, s32 separate_alpha_blend, s32 alpha_src_blend, s32 alpha_dst_blend, s32 alpha_combine);
|
||||
extern void (* GX2CalcDRCSize)(s32 drc_mode, s32 format, s32 buffering_mode, u32 *size, s32 *scale_needed);
|
||||
extern void (* GX2SetDRCBuffer)(void *buffer, u32 buffer_size, s32 drc_mode, s32 surface_format, s32 buffering_mode);
|
||||
extern void (* GX2SetDRCScale)(u32 width, u32 height);
|
||||
extern void (* GX2SetDRCEnable)(s32 enable);
|
||||
extern void (* GX2SetPolygonControl)(s32 front_face_mode, s32 cull_front, s32 cull_back, s32 enable_mode, s32 mode_font, s32 mode_back, s32 poly_offset_front, s32 poly_offset_back, s32 point_line_offset);
|
||||
extern void (* GX2SetCullOnlyControl)(s32 front_face_mode, s32 cull_front, s32 cull_back);
|
||||
extern void (* GX2SetDepthStencilControl)(s32 enable_depth_test, s32 enable_depth_write, s32 depth_comp_function, s32 stencil_test_enable, s32 back_stencil_enable,
|
||||
s32 font_stencil_func, s32 front_stencil_z_pass, s32 front_stencil_z_fail, s32 front_stencil_fail,
|
||||
s32 back_stencil_func, s32 back_stencil_z_pass, s32 back_stencil_z_fail, s32 back_stencil_fail);
|
||||
extern void (* GX2SetStencilMask)(u8 mask_front, u8 write_mask_front, u8 ref_front, u8 mask_back, u8 write_mask_back, u8 ref_back);
|
||||
extern void (* GX2SetLineWidth)(f32 width);
|
||||
extern void (* GX2SetTVGamma)(f32 val);
|
||||
extern void (* GX2SetDRCGamma)(f32 val);
|
||||
extern s32 (* GX2GetSystemTVScanMode)(void);
|
||||
extern s32 (* GX2GetSystemDRCScanMode)(void);
|
||||
extern void (* GX2RSetAllocator)(void * (*allocFunc)(u32, u32, u32), void (*freeFunc)(u32, void*));
|
||||
|
||||
static inline void GX2InitDepthBuffer(GX2DepthBuffer *depthBuffer, s32 dimension, u32 width, u32 height, u32 depth, s32 format, s32 aa)
|
||||
{
|
||||
depthBuffer->surface.dimension = dimension;
|
||||
depthBuffer->surface.width = width;
|
||||
depthBuffer->surface.height = height;
|
||||
depthBuffer->surface.depth = depth;
|
||||
depthBuffer->surface.num_mips = 1;
|
||||
depthBuffer->surface.format = format;
|
||||
depthBuffer->surface.aa = aa;
|
||||
depthBuffer->surface.use = ((format==GX2_SURFACE_FORMAT_D_D24_S8_UNORM) || (format==GX2_SURFACE_FORMAT_D_D24_S8_FLOAT)) ? GX2_SURFACE_USE_DEPTH_BUFFER : GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE;
|
||||
depthBuffer->surface.tile = GX2_TILE_MODE_DEFAULT;
|
||||
depthBuffer->surface.swizzle = 0;
|
||||
depthBuffer->view_mip = 0;
|
||||
depthBuffer->view_first_slice = 0;
|
||||
depthBuffer->view_slices_count = depth;
|
||||
depthBuffer->clear_depth = 1.0f;
|
||||
depthBuffer->clear_stencil = 0;
|
||||
depthBuffer->hiZ_data = NULL;
|
||||
depthBuffer->hiZ_size = 0;
|
||||
GX2CalcSurfaceSizeAndAlignment(&depthBuffer->surface);
|
||||
GX2InitDepthBufferRegs(depthBuffer);
|
||||
}
|
||||
|
||||
static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, s32 dimension, u32 width, u32 height, u32 depth, s32 format, s32 aa)
|
||||
{
|
||||
colorBuffer->surface.dimension = dimension;
|
||||
colorBuffer->surface.width = width;
|
||||
colorBuffer->surface.height = height;
|
||||
colorBuffer->surface.depth = depth;
|
||||
colorBuffer->surface.num_mips = 1;
|
||||
colorBuffer->surface.format = format;
|
||||
colorBuffer->surface.aa = aa;
|
||||
colorBuffer->surface.use = GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV;
|
||||
colorBuffer->surface.image_size = 0;
|
||||
colorBuffer->surface.image_data = NULL;
|
||||
colorBuffer->surface.mip_size = 0;
|
||||
colorBuffer->surface.mip_data = NULL;
|
||||
colorBuffer->surface.tile = GX2_TILE_MODE_DEFAULT;
|
||||
colorBuffer->surface.swizzle = 0;
|
||||
colorBuffer->surface.align = 0;
|
||||
colorBuffer->surface.pitch = 0;
|
||||
u32 i;
|
||||
for(i = 0; i < 13; i++)
|
||||
colorBuffer->surface.mip_offset[i] = 0;
|
||||
colorBuffer->view_mip = 0;
|
||||
colorBuffer->view_first_slice = 0;
|
||||
colorBuffer->view_slices_count = depth;
|
||||
colorBuffer->aux_data = NULL;
|
||||
colorBuffer->aux_size = 0;
|
||||
for(i = 0; i < 5; i++)
|
||||
colorBuffer->regs[i] = 0;
|
||||
|
||||
GX2CalcSurfaceSizeAndAlignment(&colorBuffer->surface);
|
||||
GX2InitColorBufferRegs(colorBuffer);
|
||||
}
|
||||
|
||||
static inline void GX2InitAttribStream(GX2AttribStream* attr, u32 location, u32 buffer, u32 offset, s32 format)
|
||||
{
|
||||
attr->location = location;
|
||||
attr->buffer = buffer;
|
||||
attr->offset = offset;
|
||||
attr->format = format;
|
||||
attr->index_type = 0;
|
||||
attr->divisor = 0;
|
||||
attr->destination_selector = attribute_dest_comp_selector[format & 0xff];
|
||||
attr->endian_swap = GX2_ENDIANSWAP_DEFAULT;
|
||||
}
|
||||
|
||||
static inline void GX2InitTexture(GX2Texture *tex, u32 width, u32 height, u32 depth, u32 num_mips, s32 format, s32 dimension, s32 tile)
|
||||
{
|
||||
tex->surface.dimension = dimension;
|
||||
tex->surface.width = width;
|
||||
tex->surface.height = height;
|
||||
tex->surface.depth = depth;
|
||||
tex->surface.num_mips = num_mips;
|
||||
tex->surface.format = format;
|
||||
tex->surface.aa = GX2_AA_MODE_1X;
|
||||
tex->surface.use = GX2_SURFACE_USE_TEXTURE;
|
||||
tex->surface.image_size = 0;
|
||||
tex->surface.image_data = NULL;
|
||||
tex->surface.mip_size = 0;
|
||||
tex->surface.mip_data = NULL;
|
||||
tex->surface.tile = tile;
|
||||
tex->surface.swizzle = 0;
|
||||
tex->surface.align = 0;
|
||||
tex->surface.pitch = 0;
|
||||
u32 i;
|
||||
for(i = 0; i < 13; i++)
|
||||
tex->surface.mip_offset[i] = 0;
|
||||
tex->view_first_mip = 0;
|
||||
tex->view_mips_count = num_mips;
|
||||
tex->view_first_slice = 0;
|
||||
tex->view_slices_count = depth;
|
||||
tex->component_selector = texture_comp_selector[format & 0x3f];
|
||||
for(i = 0; i < 5; i++)
|
||||
tex->regs[i] = 0;
|
||||
|
||||
GX2CalcSurfaceSizeAndAlignment(&tex->surface);
|
||||
GX2InitTextureRegs(tex);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __GX2_FUNCTIONS_H_
|
699
wiiu/dynamic_libs/gx2_types.h
Normal file
699
wiiu/dynamic_libs/gx2_types.h
Normal file
@ -0,0 +1,699 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef _GX2_TYPES_H_
|
||||
#define _GX2_TYPES_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! Constants
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_COMMAND_BUFFER_SIZE 0x400000
|
||||
#define GX2_SCAN_BUFFER_ALIGNMENT 0x1000
|
||||
#define GX2_SHADER_ALIGNMENT 0x100
|
||||
#define GX2_CONTEXT_STATE_ALIGNMENT 0x100
|
||||
#define GX2_DISPLAY_LIST_ALIGNMENT 0x20
|
||||
#define GX2_VERTEX_BUFFER_ALIGNMENT 0x40
|
||||
#define GX2_INDEX_BUFFER_ALIGNMENT 0x20
|
||||
|
||||
#define GX2_CONTEXT_STATE_SIZE 0xA100
|
||||
|
||||
#define GX2_AUX_BUFFER_CLEAR_VALUE 0xCC
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! Common
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_FALSE 0
|
||||
#define GX2_TRUE 1
|
||||
#define GX2_DISABLE 0
|
||||
#define GX2_ENABLE 1
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2InitAttrib
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_INIT_ATTRIB_NULL 0
|
||||
#define GX2_INIT_ATTRIB_CB_BASE 1
|
||||
#define GX2_INIT_ATTRIB_CB_SIZE 2
|
||||
#define GX2_INIT_ATTRIB_ARGC 7
|
||||
#define GX2_INIT_ATTRIB_ARGV 8
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 compare functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_COMPARE_NEVER 0
|
||||
#define GX2_COMPARE_LESS 1
|
||||
#define GX2_COMPARE_EQUAL 2
|
||||
#define GX2_COMPARE_LEQUAL 3
|
||||
#define GX2_COMPARE_GREATER 4
|
||||
#define GX2_COMPARE_NOTEQUAL 5
|
||||
#define GX2_COMPARE_GEQUAL 6
|
||||
#define GX2_COMPARE_ALWAYS 7
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 stencil functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_STENCIL_KEEP 0
|
||||
#define GX2_STENCIL_ZERO 1
|
||||
#define GX2_STENCIL_REPLACE 2
|
||||
#define GX2_STENCIL_INCR 3
|
||||
#define GX2_STENCIL_DECR 4
|
||||
#define GX2_STENCIL_INVERT 5
|
||||
#define GX2_STENCIL_INCR_WRAP 6
|
||||
#define GX2_STENCIL_DECR_WRAP 7
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 logic op functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_LOGIC_OP_CLEAR 0x00
|
||||
#define GX2_LOGIC_OP_NOR 0x11
|
||||
#define GX2_LOGIC_OP_INVAND 0x22
|
||||
#define GX2_LOGIC_OP_INVCOPY 0x33
|
||||
#define GX2_LOGIC_OP_REVAND 0x44
|
||||
#define GX2_LOGIC_OP_INV 0x55
|
||||
#define GX2_LOGIC_OP_XOR 0x66
|
||||
#define GX2_LOGIC_OP_NAND 0x77
|
||||
#define GX2_LOGIC_OP_AND 0x88
|
||||
#define GX2_LOGIC_OP_EQUIV 0x99
|
||||
#define GX2_LOGIC_OP_NOOP 0xAA
|
||||
#define GX2_LOGIC_OP_INVOR 0xBB
|
||||
#define GX2_LOGIC_OP_COPY 0xCC
|
||||
#define GX2_LOGIC_OP_REVOR 0xDD
|
||||
#define GX2_LOGIC_OP_OR 0xEE
|
||||
#define GX2_LOGIC_OP_SET 0xFF
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 blend combination functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_BLEND_COMBINE_ADD 0x00
|
||||
#define GX2_BLEND_COMBINE_SRC_MINUS_DST 0x01
|
||||
#define GX2_BLEND_COMBINE_MIN 0x02
|
||||
#define GX2_BLEND_COMBINE_MAX 0x03
|
||||
#define GX2_BLEND_COMBINE_DST_MINUS_SRC 0x04
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 blend functions
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_BLEND_ZERO 0x00
|
||||
#define GX2_BLEND_ONE 0x01
|
||||
#define GX2_BLEND_SRC_ALPHA 0x04
|
||||
#define GX2_BLEND_ONE_MINUS_SRC_ALPHA 0x05
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 render targets
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_RENDER_TARGET_0 0
|
||||
#define GX2_RENDER_TARGET_1 1
|
||||
#define GX2_RENDER_TARGET_2 2
|
||||
#define GX2_RENDER_TARGET_3 3
|
||||
#define GX2_RENDER_TARGET_4 4
|
||||
#define GX2_RENDER_TARGET_5 5
|
||||
#define GX2_RENDER_TARGET_6 6
|
||||
#define GX2_RENDER_TARGET_7 7
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 cull modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_FRONT_FACE_CCW 0
|
||||
#define GX2_FRONT_FACE_CW 1
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 polygon modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_POLYGON_MODE_POINT 0
|
||||
#define GX2_POLYGON_MODE_LINE 1
|
||||
#define GX2_POLYGON_MODE_TRIANGLE 2
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 special states
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SPECIAL_STATE_CLEAR 0
|
||||
#define GX2_SPECIAL_STATE_CLEAR_HIZ 1
|
||||
#define GX2_SPECIAL_STATE_COPY 2
|
||||
#define GX2_SPECIAL_STATE_EXPAND_COLOR 3
|
||||
#define GX2_SPECIAL_STATE_EXPAND_DEPTH 4
|
||||
#define GX2_SPECIAL_STATE_CONVERT_DEPTH 5
|
||||
#define GX2_SPECIAL_STATE_CONVERT_AADEPTH 6
|
||||
#define GX2_SPECIAL_STATE_RESOLVE_COLOR 7
|
||||
#define GX2_SPECIAL_STATE_CLEAR_COLOR_AS_DEPTH 8
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 attribute formats
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_ATTRIB_FORMAT_8_UNORM 0x00000000
|
||||
#define GX2_ATTRIB_FORMAT_4_4_UNORM 0x00000001
|
||||
#define GX2_ATTRIB_FORMAT_16_UNORM 0x00000002
|
||||
#define GX2_ATTRIB_FORMAT_8_8_UNORM 0x00000004
|
||||
#define GX2_ATTRIB_FORMAT_16_16_UNORM 0x00000007
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_UNORM 0x0000000A
|
||||
#define GX2_ATTRIB_FORMAT_10_10_10_2_UNORM 0x0000000B
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_UNORM 0x0000000E
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_UINT 0x00000100
|
||||
#define GX2_ATTRIB_FORMAT_16_UINT 0x00000102
|
||||
#define GX2_ATTRIB_FORMAT_8_8_UINT 0x00000104
|
||||
#define GX2_ATTRIB_FORMAT_32_UINT 0x00000105
|
||||
#define GX2_ATTRIB_FORMAT_16_16_UINT 0x00000107
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT 0x0000010A
|
||||
#define GX2_ATTRIB_FORMAT_10_10_10_2_UINT 0x0000010B
|
||||
#define GX2_ATTRIB_FORMAT_32_32_UINT 0x0000010C
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT 0x0000010E
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_UINT 0x00000110
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_32_UINT 0x00000112
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_SNORM 0x00000200
|
||||
#define GX2_ATTRIB_FORMAT_16_SNORM 0x00000202
|
||||
#define GX2_ATTRIB_FORMAT_8_8_SNORM 0x00000204
|
||||
#define GX2_ATTRIB_FORMAT_16_16_SNORM 0x00000207
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_SNORM 0x0000020A
|
||||
#define GX2_ATTRIB_FORMAT_10_10_10_2_SNORM 0x0000020B
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_SNORM 0x0000020E
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_SINT 0x00000300
|
||||
#define GX2_ATTRIB_FORMAT_16_SINT 0x00000303
|
||||
#define GX2_ATTRIB_FORMAT_8_8_SINT 0x00000304
|
||||
#define GX2_ATTRIB_FORMAT_32_SINT 0x00000305
|
||||
#define GX2_ATTRIB_FORMAT_16_16_SINT 0x00000307
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT 0x0000030A
|
||||
#define GX2_ATTRIB_FORMAT_10_10_10_2_SINT 0x0000030B
|
||||
#define GX2_ATTRIB_FORMAT_32_32_SINT 0x0000030C
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT 0x0000030E
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_SINT 0x00000310
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_32_SINT 0x00000312
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_UINT_TO_FLOAT 0x00000800
|
||||
#define GX2_ATTRIB_FORMAT_16_UINT_TO_FLOAT 0x00000802
|
||||
#define GX2_ATTRIB_FORMAT_16_FLOAT 0x00000803
|
||||
#define GX2_ATTRIB_FORMAT_8_8_UINT_TO_FLOAT 0x00000804
|
||||
#define GX2_ATTRIB_FORMAT_32_FLOAT 0x00000806
|
||||
#define GX2_ATTRIB_FORMAT_16_16_UINT_TO_FLOAT 0x00000807
|
||||
#define GX2_ATTRIB_FORMAT_16_16_FLOAT 0x00000808
|
||||
#define GX2_ATTRIB_FORMAT_10_11_11_FLOAT 0x00000809
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_UINT_TO_FLOAT 0x0000080A
|
||||
#define GX2_ATTRIB_FORMAT_32_32_FLOAT 0x0000080D
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_UINT_TO_FLOAT 0x0000080E
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_FLOAT 0x0000080F
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_FLOAT 0x00000811
|
||||
#define GX2_ATTRIB_FORMAT_32_32_32_32_FLOAT 0x00000813
|
||||
|
||||
#define GX2_ATTRIB_FORMAT_8_SINT_TO_FLOAT 0x00000A00
|
||||
#define GX2_ATTRIB_FORMAT_16_SINT_TO_FLOAT 0x00000A02
|
||||
#define GX2_ATTRIB_FORMAT_8_8_SINT_TO_FLOAT 0x00000A04
|
||||
#define GX2_ATTRIB_FORMAT_16_16_SINT_TO_FLOAT 0x00000A07
|
||||
#define GX2_ATTRIB_FORMAT_8_8_8_8_SINT_TO_FLOAT 0x00000A0A
|
||||
#define GX2_ATTRIB_FORMAT_16_16_16_16_SINT_TO_FLOAT 0x00000A0E
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 shader modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SHADER_MODE_UNIFORM_REGISTER 0
|
||||
#define GX2_SHADER_MODE_UNIFORM_BLOCK 1
|
||||
#define GX2_SHADER_MODE_GEOMETRY_SHADER 2
|
||||
#define GX2_SHADER_MODE_COMPUTE_SHADER 3
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 shader modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_COMP_SEL_NONE 0x04040405
|
||||
#define GX2_COMP_SEL_X001 0x00040405
|
||||
#define GX2_COMP_SEL_XY01 0x00010405
|
||||
#define GX2_COMP_SEL_XYZ1 0x00010205
|
||||
#define GX2_COMP_SEL_XYZW 0x00010203
|
||||
#define GX2_COMP_SEL_XXXX 0x00000000
|
||||
#define GX2_COMP_SEL_YYYY 0x01010101
|
||||
#define GX2_COMP_SEL_ZZZZ 0x02020202
|
||||
#define GX2_COMP_SEL_WWWW 0x03030303
|
||||
#define GX2_COMP_SEL_WZYX 0x03020100
|
||||
#define GX2_COMP_SEL_WXYZ 0x03000102
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 variable types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_VAR_TYPE_VOID 0
|
||||
#define GX2_VAR_TYPE_BOOL 1
|
||||
#define GX2_VAR_TYPE_INT 2
|
||||
#define GX2_VAR_TYPE_UINT 3
|
||||
#define GX2_VAR_TYPE_FLOAT 4
|
||||
#define GX2_VAR_TYPE_DOUBLE 5
|
||||
#define GX2_VAR_TYPE_VEC2 9
|
||||
#define GX2_VAR_TYPE_VEC3 10
|
||||
#define GX2_VAR_TYPE_VEC4 11
|
||||
#define GX2_VAR_TYPE_MAT2 21
|
||||
#define GX2_VAR_TYPE_MAT3 25
|
||||
#define GX2_VAR_TYPE_MAT4 29
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 sample types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SAMPLER_TYPE_2D 1
|
||||
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 index formats
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_INDEX_FORMAT_U16 4
|
||||
#define GX2_INDEX_FORMAT_U32 9
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 primitive types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_PRIMITIVE_POINTS 0x01
|
||||
#define GX2_PRIMITIVE_LINES 0x02
|
||||
#define GX2_PRIMITIVE_LINE_STRIP 0x03
|
||||
#define GX2_PRIMITIVE_TRIANGLES 0x04
|
||||
#define GX2_PRIMITIVE_TRIANGLE_FAN 0x05
|
||||
#define GX2_PRIMITIVE_TRIANGLE_STRIP 0x06
|
||||
#define GX2_PRIMITIVE_RECTS 0x11
|
||||
#define GX2_PRIMITIVE_QUADS 0x13
|
||||
#define GX2_PRIMITIVE_QUAD_STRIP 0x14
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 clear modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_CLEAR_DEPTH 0x01
|
||||
#define GX2_CLEAR_STENCIL 0x02
|
||||
#define GX2_CLEAR_BOTH (GX2_CLEAR_DEPTH | GX2_CLEAR_STENCIL)
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 surface formats
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_UNORM 0x00000001
|
||||
#define GX2_SURFACE_FORMAT_T_R4_G4_UNORM 0x00000002
|
||||
#define GX2_SURFACE_FORMAT_TCD_R16_UNORM 0x00000005
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_UNORM 0x00000007
|
||||
#define GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM 0x00000008
|
||||
#define GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM 0x0000000a
|
||||
#define GX2_SURFACE_FORMAT_TC_R4_G4_B4_A4_UNORM 0x0000000b
|
||||
#define GX2_SURFACE_FORMAT_TC_A1_B5_G5_R5_UNORM 0x0000000c
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_UNORM 0x0000000f
|
||||
#define GX2_SURFACE_FORMAT_D_D24_S8_UNORM 0x00000011
|
||||
#define GX2_SURFACE_FORMAT_T_R24_UNORM_X8 0x00000011
|
||||
#define GX2_SURFACE_FORMAT_TCS_R10_G10_B10_A2_UNORM 0x00000019
|
||||
#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM 0x0000001a
|
||||
#define GX2_SURFACE_FORMAT_TCS_A2_B10_G10_R10_UNORM 0x0000001b
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UNORM 0x0000001f
|
||||
#define GX2_SURFACE_FORMAT_T_BC1_UNORM 0x00000031
|
||||
#define GX2_SURFACE_FORMAT_T_BC2_UNORM 0x00000032
|
||||
#define GX2_SURFACE_FORMAT_T_BC3_UNORM 0x00000033
|
||||
#define GX2_SURFACE_FORMAT_T_BC4_UNORM 0x00000034
|
||||
#define GX2_SURFACE_FORMAT_T_BC5_UNORM 0x00000035
|
||||
#define GX2_SURFACE_FORMAT_T_NV12_UNORM 0x00000081
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_UINT 0x00000101
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_UINT 0x00000105
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_UINT 0x00000107
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_UINT 0x0000010d
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_UINT 0x0000010f
|
||||
#define GX2_SURFACE_FORMAT_T_X24_G8_UINT 0x00000111
|
||||
#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_UINT 0x00000119
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_UINT 0x0000011a
|
||||
#define GX2_SURFACE_FORMAT_TC_A2_B10_G10_R10_UINT 0x0000011b
|
||||
#define GX2_SURFACE_FORMAT_T_X32_G8_UINT_X24 0x0000011c
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_UINT 0x0000011d
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_UINT 0x0000011f
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_UINT 0x00000122
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_SNORM 0x00000201
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_SNORM 0x00000205
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_SNORM 0x00000207
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_SNORM 0x0000020f
|
||||
#define GX2_SURFACE_FORMAT_T_R10_G10_B10_A2_SNORM 0x00000219
|
||||
#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SNORM 0x00000219
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SNORM 0x0000021a
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SNORM 0x0000021f
|
||||
#define GX2_SURFACE_FORMAT_T_BC4_SNORM 0x00000234
|
||||
#define GX2_SURFACE_FORMAT_T_BC5_SNORM 0x00000235
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_SINT 0x00000301
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_SINT 0x00000305
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_SINT 0x00000307
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_SINT 0x0000030d
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_SINT 0x0000030f
|
||||
#define GX2_SURFACE_FORMAT_TC_R10_G10_B10_A2_SINT 0x00000319
|
||||
#define GX2_SURFACE_FORMAT_TC_R8_G8_B8_A8_SINT 0x0000031a
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_SINT 0x0000031d
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_SINT 0x0000031f
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_SINT 0x00000322
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB 0x0000041a
|
||||
#define GX2_SURFACE_FORMAT_T_BC1_SRGB 0x00000431
|
||||
#define GX2_SURFACE_FORMAT_T_BC2_SRGB 0x00000432
|
||||
#define GX2_SURFACE_FORMAT_T_BC3_SRGB 0x00000433
|
||||
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_FLOAT 0x00000806
|
||||
#define GX2_SURFACE_FORMAT_TCD_R32_FLOAT 0x0000080e
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_FLOAT 0x00000810
|
||||
#define GX2_SURFACE_FORMAT_D_D24_S8_FLOAT 0x00000811
|
||||
#define GX2_SURFACE_FORMAT_TC_R11_G11_B10_FLOAT 0x00000816
|
||||
#define GX2_SURFACE_FORMAT_D_D32_FLOAT_S8_UINT_X24 0x0000081c
|
||||
#define GX2_SURFACE_FORMAT_T_R32_FLOAT_X8_X24 0x0000081c
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_FLOAT 0x0000081e
|
||||
#define GX2_SURFACE_FORMAT_TC_R16_G16_B16_A16_FLOAT 0x00000820
|
||||
#define GX2_SURFACE_FORMAT_TC_R32_G32_B32_A32_FLOAT 0x00000823
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 tile modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TILE_MODE_DEFAULT 0x00000000
|
||||
#define GX2_TILE_MODE_LINEAR_ALIGNED 0x00000001
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 surface use
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SURFACE_USE_TEXTURE 0x00000001
|
||||
#define GX2_SURFACE_USE_COLOR_BUFFER 0x00000002
|
||||
#define GX2_SURFACE_USE_DEPTH_BUFFER 0x00000004
|
||||
#define GX2_SURFACE_USE_SCAN_BUFFER 0x00000008
|
||||
#define GX2_SURFACE_USE_FTV 0x80000000
|
||||
#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_TEXTURE)
|
||||
#define GX2_SURFACE_USE_DEPTH_BUFFER_TEXTURE (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE)
|
||||
#define GX2_SURFACE_USE_COLOR_BUFFER_FTV (GX2_SURFACE_USE_COLOR_BUFFER | GX2_SURFACE_USE_FTV)
|
||||
#define GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE_FTV (GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE | GX2_SURFACE_USE_FTV)
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 surface dim
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SURFACE_DIM_1D 0x00000000
|
||||
#define GX2_SURFACE_DIM_2D 0x00000001
|
||||
#define GX2_SURFACE_DIM_3D 0x00000002
|
||||
#define GX2_SURFACE_DIM_CUBE 0x00000003
|
||||
#define GX2_SURFACE_DIM_1D_ARRAY 0x00000004
|
||||
#define GX2_SURFACE_DIM_2D_ARRAY 0x00000005
|
||||
#define GX2_SURFACE_DIM_2D_MSAA 0x00000006
|
||||
#define GX2_SURFACE_DIM_2D_MSAA_ARRAY 0x00000007
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 AA modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_AA_MODE_1X 0x00000000
|
||||
#define GX2_AA_MODE_2X 0x00000001
|
||||
#define GX2_AA_MODE_4X 0x00000002
|
||||
#define GX2_AA_MODE_8X 0x00000003
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 texture clamp
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TEX_CLAMP_WRAP 0x00000000
|
||||
#define GX2_TEX_CLAMP_MIRROR 0x00000001
|
||||
#define GX2_TEX_CLAMP_CLAMP 0x00000002
|
||||
#define GX2_TEX_CLAMP_MIRROR_ONCE 0x00000003
|
||||
#define GX2_TEX_CLAMP_CLAMP_HALF_BORDER 0x00000004
|
||||
#define GX2_TEX_CLAMP_MIRROR_ONCE_HALF_BORDER 0x00000005
|
||||
#define GX2_TEX_CLAMP_CLAMP_BORDER 0x00000006
|
||||
#define GX2_TEX_CLAMP_MIRROR_ONCE_BORDER 0x00000007
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 texture filter
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TEX_XY_FILTER_POINT 0x00000000
|
||||
#define GX2_TEX_XY_FILTER_BILINEAR 0x00000001
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 TV scan modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TV_SCAN_MODE_NONE 0x00000000
|
||||
#define GX2_TV_SCAN_MODE_576I 0x00000001
|
||||
#define GX2_TV_SCAN_MODE_480I 0x00000002
|
||||
#define GX2_TV_SCAN_MODE_480P 0x00000003
|
||||
#define GX2_TV_SCAN_MODE_720P 0x00000004
|
||||
#define GX2_TV_SCAN_MODE_1080I 0x00000006
|
||||
#define GX2_TV_SCAN_MODE_1080P 0x00000007
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 TV render modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TV_RENDER_480_NARROW 0x00000001
|
||||
#define GX2_TV_RENDER_480_WIDE 0x00000002
|
||||
#define GX2_TV_RENDER_720 0x00000003
|
||||
#define GX2_TV_RENDER_1080 0x00000005
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 DRC render modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_DRC_NONE 0x00000000
|
||||
#define GX2_DRC_SINGLE 0x00000001
|
||||
#define GX2_DRC_DOUBLE 0x00000002
|
||||
#define GX2_DRC_SINGLE_30HZ 0x00000004
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 buffering mode
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_BUFFERING_SINGLE 0x00000001
|
||||
#define GX2_BUFFERING_DOUBLE 0x00000002
|
||||
#define GX2_BUFFERING_TRIPLE 0x00000003
|
||||
#define GX2_BUFFERING_QUAD
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 scan targets
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_SCAN_TARGET_TV 0x00000001
|
||||
#define GX2_SCAN_TARGET_DRC_FIRST 0x00000004
|
||||
#define GX2_SCAN_TARGET_DRC_SECOND 0x00000008
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 invalidate types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_INVALIDATE_ATTRIB_BUFFER 0x00000001
|
||||
#define GX2_INVALIDATE_TEXTURE 0x00000002
|
||||
#define GX2_INVALIDATE_UNIFORM_BLOCK 0x00000004
|
||||
#define GX2_INVALIDATE_SHADER 0x00000008
|
||||
#define GX2_INVALIDATE_COLOR_BUFFER 0x00000010
|
||||
#define GX2_INVALIDATE_DEPTH_BUFFER 0x00000020
|
||||
#define GX2_INVALIDATE_CPU 0x00000040
|
||||
#define GX2_INVALIDATE_CPU_ATTRIB_BUFFER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_ATTRIB_BUFFER)
|
||||
#define GX2_INVALIDATE_CPU_TEXTURE (GX2_INVALIDATE_CPU | GX2_INVALIDATE_TEXTURE)
|
||||
#define GX2_INVALIDATE_CPU_UNIFORM_BLOCK (GX2_INVALIDATE_CPU | GX2_INVALIDATE_UNIFORM_BLOCK)
|
||||
#define GX2_INVALIDATE_CPU_SHADER (GX2_INVALIDATE_CPU | GX2_INVALIDATE_SHADER)
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 swap modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_ENDIANSWAP_DEFAULT 0x00000003
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 tessellation modes
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_TESSELLATION_MODE_DISCRETE 0x00000000
|
||||
#define GX2_TESSELLATION_MODE_CONTINUOUS 0x00000001
|
||||
#define GX2_TESSELLATION_MODE_ADAPTIVE 0x00000002
|
||||
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
//! GX2 fetch shader types
|
||||
//!-----------------------------------------------------------------------------------------------------------------------
|
||||
#define GX2_FETCH_SHADER_TESSELATION_NONE 0x00000000
|
||||
#define GX2_FETCH_SHADER_TESSELATION_LINES 0x00000001
|
||||
#define GX2_FETCH_SHADER_TESSELATION_TRIANGLES 0x00000002
|
||||
#define GX2_FETCH_SHADER_TESSELATION_QUADS 0x00000003
|
||||
|
||||
|
||||
typedef struct _GX2ContextState {
|
||||
u8 data[GX2_CONTEXT_STATE_SIZE];
|
||||
} GX2ContextState;
|
||||
|
||||
typedef struct _GX2Surface {
|
||||
s32 dimension;
|
||||
u32 width;
|
||||
u32 height;
|
||||
u32 depth;
|
||||
u32 num_mips;
|
||||
s32 format;
|
||||
s32 aa;
|
||||
s32 use;
|
||||
u32 image_size;
|
||||
void *image_data;
|
||||
u32 mip_size;
|
||||
void *mip_data;
|
||||
s32 tile;
|
||||
u32 swizzle;
|
||||
u32 align;
|
||||
u32 pitch;
|
||||
u32 mip_offset[13];
|
||||
} GX2Surface;
|
||||
|
||||
typedef struct _GX2ColorBuffer {
|
||||
GX2Surface surface;
|
||||
u32 view_mip;
|
||||
u32 view_first_slice;
|
||||
u32 view_slices_count;
|
||||
void *aux_data;
|
||||
u32 aux_size;
|
||||
u32 regs[5];
|
||||
} GX2ColorBuffer;
|
||||
|
||||
typedef struct _GX2DepthBuffer {
|
||||
GX2Surface surface;
|
||||
u32 view_mip;
|
||||
u32 view_first_slice;
|
||||
u32 view_slices_count;
|
||||
void *hiZ_data;
|
||||
u32 hiZ_size;
|
||||
f32 clear_depth;
|
||||
u32 clear_stencil;
|
||||
u32 regs[7];
|
||||
} GX2DepthBuffer;
|
||||
|
||||
|
||||
typedef struct _GX2Texture {
|
||||
GX2Surface surface;
|
||||
u32 view_first_mip;
|
||||
u32 view_mips_count;
|
||||
u32 view_first_slice;
|
||||
u32 view_slices_count;
|
||||
u32 component_selector;
|
||||
u32 regs[5];
|
||||
} GX2Texture;
|
||||
|
||||
|
||||
typedef struct _GX2Sampler {
|
||||
u32 regs[3];
|
||||
} GX2Sampler;
|
||||
|
||||
typedef struct _GX2AttribStream {
|
||||
u32 location;
|
||||
u32 buffer;
|
||||
u32 offset;
|
||||
s32 format;
|
||||
s32 index_type;
|
||||
u32 divisor;
|
||||
u32 destination_selector;
|
||||
s32 endian_swap;
|
||||
} GX2AttribStream;
|
||||
|
||||
typedef struct _GX2FetchShader {
|
||||
s32 type;
|
||||
u32 reg;
|
||||
u32 shader_size;
|
||||
void *shader_program;
|
||||
u32 attributes_count;
|
||||
u32 divisor[3];
|
||||
} GX2FetchShader;
|
||||
|
||||
typedef struct _GX2AttribVar
|
||||
{
|
||||
const char *name;
|
||||
s32 var_type;
|
||||
u32 array_count;
|
||||
u32 location;
|
||||
} GX2AttribVar;
|
||||
|
||||
|
||||
typedef struct _GX2UniformBlock {
|
||||
const char *name;
|
||||
u32 location;
|
||||
u32 block_size;
|
||||
} GX2UniformBlock;
|
||||
|
||||
typedef struct _GX2UniformInitialValue {
|
||||
f32 value[4];
|
||||
u32 offset;
|
||||
} GX2UniformInitialValue;
|
||||
|
||||
typedef struct _GX2SamplerVar
|
||||
{
|
||||
const char *name;
|
||||
s32 sampler_type;
|
||||
u32 location;
|
||||
} GX2SamplerVar;
|
||||
|
||||
typedef struct _GX2UniformVar
|
||||
{
|
||||
const char *name;
|
||||
s32 var_type;
|
||||
u32 array_count;
|
||||
u32 offset;
|
||||
u32 block_index;
|
||||
} GX2UniformVar;
|
||||
|
||||
typedef struct _GX2VertexShader {
|
||||
u32 regs[52];
|
||||
u32 shader_size;
|
||||
void *shader_data;
|
||||
s32 shader_mode;
|
||||
u32 uniform_blocks_count;
|
||||
GX2UniformBlock *uniform_block;
|
||||
u32 uniform_vars_count;
|
||||
GX2UniformVar *uniform_var;
|
||||
u32 initial_values_count;
|
||||
GX2UniformInitialValue *initial_value;
|
||||
u32 loops_count;
|
||||
void *loops_data;
|
||||
u32 sampler_vars_count;
|
||||
GX2SamplerVar *sampler_var;
|
||||
u32 attribute_vars_count;
|
||||
GX2AttribVar *attribute_var;
|
||||
u32 data[6];
|
||||
u32 shader_program_buffer[16];
|
||||
} GX2VertexShader;
|
||||
|
||||
typedef struct _GX2PixelShader {
|
||||
u32 regs[41];
|
||||
u32 shader_size;
|
||||
void *shader_data;
|
||||
s32 shader_mode;
|
||||
u32 uniform_blocks_count;
|
||||
GX2UniformBlock *uniform_block;
|
||||
u32 uniform_vars_count;
|
||||
GX2UniformVar *uniform_var;
|
||||
u32 initial_values_count;
|
||||
GX2UniformInitialValue *initial_value;
|
||||
u32 loops_count;
|
||||
void *loops_data;
|
||||
u32 sampler_vars_count;
|
||||
GX2SamplerVar *sampler_var;
|
||||
u32 shader_program_buffer[16];
|
||||
} GX2PixelShader;
|
||||
|
||||
static const u32 attribute_dest_comp_selector[20] = {
|
||||
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001,
|
||||
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
|
||||
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1,
|
||||
GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW
|
||||
};
|
||||
|
||||
static const u32 texture_comp_selector[54] = {
|
||||
GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001,
|
||||
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
|
||||
GX2_COMP_SEL_WZYX, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE,
|
||||
GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE,
|
||||
GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_WZYX, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01,
|
||||
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
|
||||
GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001,
|
||||
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1,
|
||||
GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01
|
||||
};
|
||||
|
||||
typedef struct _GX2Color {
|
||||
u8 r, g, b, a;
|
||||
} GX2Color;
|
||||
|
||||
typedef struct _GX2ColorF32 {
|
||||
f32 r, g, b, a;
|
||||
} GX2ColorF32;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
166
wiiu/dynamic_libs/os_functions.c
Normal file
166
wiiu/dynamic_libs/os_functions.c
Normal file
@ -0,0 +1,166 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "common/common.h"
|
||||
#include "os_functions.h"
|
||||
|
||||
unsigned int coreinit_handle = 0;
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Lib handle functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
EXPORT_DECL(int, OSDynLoad_Acquire, const char* rpl, u32 *handle);
|
||||
EXPORT_DECL(int, OSDynLoad_FindExport, u32 handle, int isdata, const char *symbol, void *address);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Thread functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
EXPORT_DECL(int, OSCreateThread, void *thread, s32 (*callback)(s32, void*), s32 argc, void *args, u32 stack, u32 stack_size, s32 priority, u32 attr);
|
||||
EXPORT_DECL(int, OSResumeThread, void *thread);
|
||||
EXPORT_DECL(int, OSSuspendThread, void *thread);
|
||||
EXPORT_DECL(int, OSIsThreadTerminated, void *thread);
|
||||
EXPORT_DECL(int, OSIsThreadSuspended, void *thread);
|
||||
EXPORT_DECL(int, OSSetThreadPriority, void * thread, int priority);
|
||||
EXPORT_DECL(int, OSJoinThread, void * thread, int * ret_val);
|
||||
EXPORT_DECL(void, OSDetachThread, void * thread);
|
||||
EXPORT_DECL(void, OSSleepTicks, u64 ticks);
|
||||
EXPORT_DECL(u64, OSGetTick, void);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Mutex functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
EXPORT_DECL(void, OSInitMutex, void* mutex);
|
||||
EXPORT_DECL(void, OSLockMutex, void* mutex);
|
||||
EXPORT_DECL(void, OSUnlockMutex, void* mutex);
|
||||
EXPORT_DECL(int, OSTryLockMutex, void* mutex);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! System functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
EXPORT_DECL(u64, OSGetTitleID, void);
|
||||
EXPORT_DECL(void, __Exit, void);
|
||||
EXPORT_DECL(void, OSFatal, const char* msg);
|
||||
EXPORT_DECL(void, OSSetExceptionCallback, u8 exceptionType, exception_callback newCallback);
|
||||
EXPORT_DECL(void, DCFlushRange, const void *addr, u32 length);
|
||||
EXPORT_DECL(void, ICInvalidateRange, const void *addr, u32 length);
|
||||
EXPORT_DECL(void*, OSEffectiveToPhysical, const void*);
|
||||
EXPORT_DECL(int, __os_snprintf, char* s, int n, const char * format, ...);
|
||||
|
||||
EXPORT_DECL(void, OSScreenInit, void);
|
||||
EXPORT_DECL(unsigned int, OSScreenGetBufferSizeEx, unsigned int bufferNum);
|
||||
EXPORT_DECL(int, OSScreenSetBufferEx, unsigned int bufferNum, void * addr);
|
||||
EXPORT_DECL(int, OSScreenClearBufferEx, unsigned int bufferNum, unsigned int temp);
|
||||
EXPORT_DECL(int, OSScreenFlipBuffersEx, unsigned int bufferNum);
|
||||
EXPORT_DECL(int, OSScreenPutFontEx, unsigned int bufferNum, unsigned int posX, unsigned int posY, const char * buffer);
|
||||
EXPORT_DECL(int, OSScreenEnableEx, unsigned int bufferNum, int enable);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Memory functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
EXPORT_VAR(unsigned int *, pMEMAllocFromDefaultHeapEx);
|
||||
EXPORT_VAR(unsigned int *, pMEMAllocFromDefaultHeap);
|
||||
EXPORT_VAR(unsigned int *, pMEMFreeToDefaultHeap);
|
||||
|
||||
EXPORT_DECL(int, MEMGetBaseHeapHandle, int mem_arena);
|
||||
EXPORT_DECL(unsigned int, MEMGetAllocatableSizeForFrmHeapEx, int heap, int align);
|
||||
EXPORT_DECL(void *, MEMAllocFromFrmHeapEx, int heap, unsigned int size, int align);
|
||||
EXPORT_DECL(void, MEMFreeToFrmHeap, int heap, int mode);
|
||||
EXPORT_DECL(void *, MEMAllocFromExpHeapEx, int heap, unsigned int size, int align);
|
||||
EXPORT_DECL(int , MEMCreateExpHeapEx, void* address, unsigned int size, unsigned short flags);
|
||||
EXPORT_DECL(void *, MEMDestroyExpHeap, int heap);
|
||||
EXPORT_DECL(void, MEMFreeToExpHeap, int heap, void* ptr);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Loader functions (not real rpl)
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
EXPORT_DECL(int, LiWaitIopComplete, int unknown_syscall_arg_r3, int * remaining_bytes);
|
||||
EXPORT_DECL(int, LiWaitIopCompleteWithInterrupts, int unknown_syscall_arg_r3, int * remaining_bytes);
|
||||
|
||||
void InitOSFunctionPointers(void)
|
||||
{
|
||||
unsigned int *funcPointer = 0;
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Lib handle functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
EXPORT_FUNC_WRITE(OSDynLoad_Acquire, (int (*)(const char*, unsigned *))OS_SPECIFICS->addr_OSDynLoad_Acquire);
|
||||
EXPORT_FUNC_WRITE(OSDynLoad_FindExport, (int (*)(u32, int, const char *, void *))OS_SPECIFICS->addr_OSDynLoad_FindExport);
|
||||
|
||||
OSDynLoad_Acquire("coreinit.rpl", &coreinit_handle);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! System functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
OS_FIND_EXPORT(coreinit_handle, OSFatal);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetTitleID);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSSetExceptionCallback);
|
||||
OS_FIND_EXPORT(coreinit_handle, DCFlushRange);
|
||||
OS_FIND_EXPORT(coreinit_handle, ICInvalidateRange);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSEffectiveToPhysical);
|
||||
OS_FIND_EXPORT(coreinit_handle, __os_snprintf);
|
||||
OSDynLoad_FindExport(coreinit_handle, 0, "_Exit", &__Exit);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenInit);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenGetBufferSizeEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenSetBufferEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenClearBufferEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenFlipBuffersEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenPutFontEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSScreenEnableEx);
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Thread functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
OS_FIND_EXPORT(coreinit_handle, OSCreateThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSResumeThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSSuspendThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSIsThreadTerminated);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSIsThreadSuspended);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSJoinThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSSetThreadPriority);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSDetachThread);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSSleepTicks);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSGetTick);
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Mutex functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
OS_FIND_EXPORT(coreinit_handle, OSInitMutex);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSLockMutex);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSUnlockMutex);
|
||||
OS_FIND_EXPORT(coreinit_handle, OSTryLockMutex);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Memory functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeapEx", &pMEMAllocFromDefaultHeapEx);
|
||||
OSDynLoad_FindExport(coreinit_handle, 1, "MEMAllocFromDefaultHeap", &pMEMAllocFromDefaultHeap);
|
||||
OSDynLoad_FindExport(coreinit_handle, 1, "MEMFreeToDefaultHeap", &pMEMFreeToDefaultHeap);
|
||||
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMGetBaseHeapHandle);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMGetAllocatableSizeForFrmHeapEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMAllocFromFrmHeapEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMFreeToFrmHeap);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMAllocFromExpHeapEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMCreateExpHeapEx);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMDestroyExpHeap);
|
||||
OS_FIND_EXPORT(coreinit_handle, MEMFreeToExpHeap);
|
||||
}
|
||||
|
130
wiiu/dynamic_libs/os_functions.h
Normal file
130
wiiu/dynamic_libs/os_functions.h
Normal file
@ -0,0 +1,130 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __OS_FUNCTIONS_H_
|
||||
#define __OS_FUNCTIONS_H_
|
||||
|
||||
#include <gctypes.h>
|
||||
#include "common/os_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BUS_SPEED 248625000
|
||||
//#define SECS_TO_TICKS(sec) (((unsigned long long)(sec)) * (BUS_SPEED/4))
|
||||
#define SECS_TO_TICKS(sec) sec
|
||||
#define MILLISECS_TO_TICKS(msec) (SECS_TO_TICKS(msec) / 1000)
|
||||
//#define MICROSECS_TO_TICKS(usec) (SECS_TO_TICKS(usec) / 1000000)
|
||||
#define MICROSECS_TO_TICKS(usec) usec
|
||||
|
||||
//#define usleep(usecs) OSSleepTicks(MICROSECS_TO_TICKS(usecs))
|
||||
//#define sleep(secs) OSSleepTicks(SECS_TO_TICKS(secs))
|
||||
|
||||
#define FLUSH_DATA_BLOCK(addr) asm volatile("dcbf 0, %0; sync" : : "r"(((addr) & ~31)))
|
||||
#define INVAL_DATA_BLOCK(addr) asm volatile("dcbi 0, %0; sync" : : "r"(((addr) & ~31)))
|
||||
|
||||
#define EXPORT_DECL(res, func, ...) res (* func)(__VA_ARGS__) __attribute__((section(".data"))) = 0;
|
||||
#define EXPORT_VAR(type, var) type var __attribute__((section(".data")));
|
||||
|
||||
|
||||
#define EXPORT_FUNC_WRITE(func, val) *(u32*)(((u32)&func) + 0) = (u32)val
|
||||
|
||||
#define OS_FIND_EXPORT(handle, func) funcPointer = 0; \
|
||||
OSDynLoad_FindExport(handle, 0, # func, &funcPointer); \
|
||||
if(!funcPointer) \
|
||||
OSFatal("Function " # func " is NULL"); \
|
||||
EXPORT_FUNC_WRITE(func, funcPointer);
|
||||
|
||||
#define OS_FIND_EXPORT_EX(handle, func, func_p) \
|
||||
funcPointer = 0; \
|
||||
OSDynLoad_FindExport(handle, 0, # func, &funcPointer); \
|
||||
if(!funcPointer) \
|
||||
OSFatal("Function " # func " is NULL"); \
|
||||
EXPORT_FUNC_WRITE(func_p, funcPointer);
|
||||
|
||||
#define OS_MUTEX_SIZE 44
|
||||
|
||||
/* Handle for coreinit */
|
||||
extern unsigned int coreinit_handle;
|
||||
void InitOSFunctionPointers(void);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Lib handle functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
extern int (* OSDynLoad_Acquire)(const char* rpl, u32 *handle);
|
||||
extern int (* OSDynLoad_FindExport)(u32 handle, int isdata, const char *symbol, void *address);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Thread functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
extern int (* OSCreateThread)(void *thread, s32 (*callback)(s32, void*), s32 argc, void *args, u32 stack, u32 stack_size, s32 priority, u32 attr);
|
||||
extern int (* OSResumeThread)(void *thread);
|
||||
extern int (* OSSuspendThread)(void *thread);
|
||||
extern int (* OSIsThreadTerminated)(void *thread);
|
||||
extern int (* OSIsThreadSuspended)(void *thread);
|
||||
extern int (* OSJoinThread)(void * thread, int * ret_val);
|
||||
extern int (* OSSetThreadPriority)(void * thread, int priority);
|
||||
extern void (* OSDetachThread)(void * thread);
|
||||
extern void (* OSSleepTicks)(u64 ticks);
|
||||
extern u64 (* OSGetTick)(void);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Mutex functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
extern void (* OSInitMutex)(void* mutex);
|
||||
extern void (* OSLockMutex)(void* mutex);
|
||||
extern void (* OSUnlockMutex)(void* mutex);
|
||||
extern int (* OSTryLockMutex)(void* mutex);
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! System functions
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
extern u64 (* OSGetTitleID)(void);
|
||||
extern void (* __Exit)(void);
|
||||
extern void (* OSFatal)(const char* msg);
|
||||
extern void (* DCFlushRange)(const void *addr, u32 length);
|
||||
extern void (* ICInvalidateRange)(const void *addr, u32 length);
|
||||
extern void* (* OSEffectiveToPhysical)(const void*);
|
||||
extern int (* __os_snprintf)(char* s, int n, const char * format, ...);
|
||||
|
||||
extern void (*OSScreenInit)(void);
|
||||
extern unsigned int (*OSScreenGetBufferSizeEx)(unsigned int bufferNum);
|
||||
extern int (*OSScreenSetBufferEx)(unsigned int bufferNum, void * addr);
|
||||
extern int (*OSScreenClearBufferEx)(unsigned int bufferNum, unsigned int temp);
|
||||
extern int (*OSScreenFlipBuffersEx)(unsigned int bufferNum);
|
||||
extern int (*OSScreenPutFontEx)(unsigned int bufferNum, unsigned int posX, unsigned int posY, const char * buffer);
|
||||
extern int (*OSScreenEnableEx)(unsigned int bufferNum, int enable);
|
||||
|
||||
typedef unsigned char (*exception_callback)(void * interruptedContext);
|
||||
extern void (* OSSetExceptionCallback)(u8 exceptionType, exception_callback newCallback);
|
||||
|
||||
extern int (* LiWaitIopComplete)(int unknown_syscall_arg_r3, int * remaining_bytes);
|
||||
extern int (* LiWaitIopCompleteWithInterrupts)(int unknown_syscall_arg_r3, int * remaining_bytes);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __OS_FUNCTIONS_H_
|
50
wiiu/dynamic_libs/padscore_functions.c
Normal file
50
wiiu/dynamic_libs/padscore_functions.c
Normal file
@ -0,0 +1,50 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "os_functions.h"
|
||||
#include "padscore_functions.h"
|
||||
|
||||
EXPORT_DECL(void, KPADInit, void);
|
||||
EXPORT_DECL(s32, WPADProbe, s32 chan, u32 * pad_type);
|
||||
EXPORT_DECL(s32, WPADSetDataFormat, s32 chan, s32 format);
|
||||
EXPORT_DECL(void, WPADEnableURCC, s32 enable);
|
||||
EXPORT_DECL(void, WPADRead, s32 chan, void * data);
|
||||
EXPORT_DECL(s32, KPADRead, s32 chan, void * data, u32 size);
|
||||
|
||||
void InitPadScoreFunctionPointers(void)
|
||||
{
|
||||
unsigned int *funcPointer = 0;
|
||||
unsigned int padscore_handle;
|
||||
OSDynLoad_Acquire("padscore.rpl", &padscore_handle);
|
||||
|
||||
OS_FIND_EXPORT(padscore_handle, KPADInit);
|
||||
OS_FIND_EXPORT(padscore_handle, WPADProbe);
|
||||
OS_FIND_EXPORT(padscore_handle, WPADSetDataFormat);
|
||||
OS_FIND_EXPORT(padscore_handle, WPADEnableURCC);
|
||||
OS_FIND_EXPORT(padscore_handle, WPADRead);
|
||||
OS_FIND_EXPORT(padscore_handle, KPADRead);
|
||||
|
||||
KPADInit();
|
||||
WPADEnableURCC(1);
|
||||
}
|
||||
|
122
wiiu/dynamic_libs/padscore_functions.h
Normal file
122
wiiu/dynamic_libs/padscore_functions.h
Normal file
@ -0,0 +1,122 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __PAD_SCORE_FUNCTIONS_H_
|
||||
#define __PAD_SCORE_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define WPAD_BUTTON_LEFT 0x0001
|
||||
#define WPAD_BUTTON_RIGHT 0x0002
|
||||
#define WPAD_BUTTON_DOWN 0x0004
|
||||
#define WPAD_BUTTON_UP 0x0008
|
||||
#define WPAD_BUTTON_PLUS 0x0010
|
||||
#define WPAD_BUTTON_2 0x0100
|
||||
#define WPAD_BUTTON_1 0x0200
|
||||
#define WPAD_BUTTON_B 0x0400
|
||||
#define WPAD_BUTTON_A 0x0800
|
||||
#define WPAD_BUTTON_MINUS 0x1000
|
||||
#define WPAD_BUTTON_Z 0x2000
|
||||
#define WPAD_BUTTON_C 0x4000
|
||||
#define WPAD_BUTTON_HOME 0x8000
|
||||
|
||||
#define WPAD_CLASSIC_BUTTON_UP 0x0001
|
||||
#define WPAD_CLASSIC_BUTTON_LEFT 0x0002
|
||||
#define WPAD_CLASSIC_BUTTON_ZR 0x0004
|
||||
#define WPAD_CLASSIC_BUTTON_X 0x0008
|
||||
#define WPAD_CLASSIC_BUTTON_A 0x0010
|
||||
#define WPAD_CLASSIC_BUTTON_Y 0x0020
|
||||
#define WPAD_CLASSIC_BUTTON_B 0x0040
|
||||
#define WPAD_CLASSIC_BUTTON_ZL 0x0080
|
||||
#define WPAD_CLASSIC_BUTTON_R 0x0200
|
||||
#define WPAD_CLASSIC_BUTTON_PLUS 0x0400
|
||||
#define WPAD_CLASSIC_BUTTON_HOME 0x0800
|
||||
#define WPAD_CLASSIC_BUTTON_MINUS 0x1000
|
||||
#define WPAD_CLASSIC_BUTTON_L 0x2000
|
||||
#define WPAD_CLASSIC_BUTTON_DOWN 0x4000
|
||||
#define WPAD_CLASSIC_BUTTON_RIGHT 0x8000
|
||||
|
||||
void InitPadScoreFunctionPointers(void);
|
||||
|
||||
|
||||
typedef struct _KPADData
|
||||
{
|
||||
u32 btns_h;
|
||||
u32 btns_d;
|
||||
u32 btns_r;
|
||||
u32 unused_1[5];
|
||||
f32 pos_x;
|
||||
f32 pos_y;
|
||||
u32 unused_2[3];
|
||||
f32 angle_x;
|
||||
f32 angle_y;
|
||||
u32 unused_3[8];
|
||||
u8 device_type;
|
||||
u8 wpad_error;
|
||||
u8 pos_valid;
|
||||
u8 unused_4[1];
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
f32 stick_x;
|
||||
f32 stick_y;
|
||||
} nunchuck;
|
||||
|
||||
struct
|
||||
{
|
||||
u32 btns_h;
|
||||
u32 btns_d;
|
||||
u32 btns_r;
|
||||
f32 lstick_x;
|
||||
f32 lstick_y;
|
||||
f32 rstick_x;
|
||||
f32 rstick_y;
|
||||
f32 ltrigger;
|
||||
f32 rtrigger;
|
||||
} classic;
|
||||
|
||||
u32 unused_6[20];
|
||||
};
|
||||
u32 unused_7[16];
|
||||
} KPADData;
|
||||
|
||||
typedef void (* wpad_connect_callback_t)(s32 chan, s32 status);
|
||||
|
||||
extern void (* KPADInit)(void);
|
||||
extern s32 (* WPADProbe)(s32 chan, u32 * pad_type);
|
||||
extern s32 (* WPADSetDataFormat)(s32 chan, s32 format);
|
||||
extern void (* WPADEnableURCC)(s32 enable);
|
||||
extern void (* WPADRead)(s32 chan, void * data);
|
||||
extern s32 (* KPADRead)(s32 chan, void * data, u32 size);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __PAD_SCORE_FUNCTIONS_H_
|
82
wiiu/dynamic_libs/socket_functions.c
Normal file
82
wiiu/dynamic_libs/socket_functions.c
Normal file
@ -0,0 +1,82 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "os_functions.h"
|
||||
#include "socket_functions.h"
|
||||
|
||||
u32 hostIpAddress = 0;
|
||||
|
||||
EXPORT_DECL(void, socket_lib_init, void);
|
||||
EXPORT_DECL(int, socket, int domain, int type, int protocol);
|
||||
EXPORT_DECL(int, socketclose, int s);
|
||||
EXPORT_DECL(int, connect, int s, void *addr, int addrlen);
|
||||
EXPORT_DECL(int, bind, s32 s,struct sockaddr *name,s32 namelen);
|
||||
EXPORT_DECL(int, listen, s32 s,u32 backlog);
|
||||
EXPORT_DECL(int, accept, s32 s,struct sockaddr *addr,s32 *addrlen);
|
||||
EXPORT_DECL(int, send, int s, const void *buffer, int size, int flags);
|
||||
EXPORT_DECL(int, recv, int s, void *buffer, int size, int flags);
|
||||
EXPORT_DECL(int, sendto, int s, const void *buffer, int size, int flags, const struct sockaddr *dest, int dest_len);
|
||||
EXPORT_DECL(int, setsockopt, int s, int level, int optname, void *optval, int optlen);
|
||||
EXPORT_DECL(char *, inet_ntoa, struct in_addr in);
|
||||
EXPORT_DECL(int, inet_aton, const char *cp, struct in_addr *inp);
|
||||
|
||||
void InitSocketFunctionPointers(void)
|
||||
{
|
||||
unsigned int nsysnet_handle;
|
||||
unsigned int *funcPointer = 0;
|
||||
OSDynLoad_Acquire("nsysnet.rpl", &nsysnet_handle);
|
||||
|
||||
unsigned int nn_ac_handle;
|
||||
int(*ACInitialize)();
|
||||
int(*ACGetStartupId) (unsigned int *id);
|
||||
int(*ACConnectWithConfigId) (unsigned int id);
|
||||
int(*ACGetAssignedAddress) (u32 * ip);
|
||||
OSDynLoad_Acquire("nn_ac.rpl", &nn_ac_handle);
|
||||
OSDynLoad_FindExport(nn_ac_handle, 0, "ACInitialize", &ACInitialize);
|
||||
OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetStartupId", &ACGetStartupId);
|
||||
OSDynLoad_FindExport(nn_ac_handle, 0, "ACConnectWithConfigId",&ACConnectWithConfigId);
|
||||
OSDynLoad_FindExport(nn_ac_handle, 0, "ACGetAssignedAddress",&ACGetAssignedAddress);
|
||||
|
||||
OS_FIND_EXPORT(nsysnet_handle, socket_lib_init);
|
||||
OS_FIND_EXPORT(nsysnet_handle, socket);
|
||||
OS_FIND_EXPORT(nsysnet_handle, socketclose);
|
||||
OS_FIND_EXPORT(nsysnet_handle, connect);
|
||||
OS_FIND_EXPORT(nsysnet_handle, bind);
|
||||
OS_FIND_EXPORT(nsysnet_handle, listen);
|
||||
OS_FIND_EXPORT(nsysnet_handle, accept);
|
||||
OS_FIND_EXPORT(nsysnet_handle, send);
|
||||
OS_FIND_EXPORT(nsysnet_handle, recv);
|
||||
OS_FIND_EXPORT(nsysnet_handle, sendto);
|
||||
OS_FIND_EXPORT(nsysnet_handle, setsockopt);
|
||||
OS_FIND_EXPORT(nsysnet_handle, inet_ntoa);
|
||||
OS_FIND_EXPORT(nsysnet_handle, inet_aton);
|
||||
|
||||
unsigned int nn_startupid;
|
||||
ACInitialize();
|
||||
ACGetStartupId(&nn_startupid);
|
||||
ACConnectWithConfigId(nn_startupid);
|
||||
ACGetAssignedAddress(&hostIpAddress);
|
||||
|
||||
socket_lib_init();
|
||||
}
|
||||
|
95
wiiu/dynamic_libs/socket_functions.h
Normal file
95
wiiu/dynamic_libs/socket_functions.h
Normal file
@ -0,0 +1,95 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __SOCKET_FUNCTIONS_H_
|
||||
#define __SOCKET_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define INADDR_ANY 0
|
||||
|
||||
#define AF_INET 2
|
||||
|
||||
#define SOCK_STREAM 1
|
||||
#define SOCK_DGRAM 2
|
||||
|
||||
#define IPPROTO_IP 0
|
||||
#define IPPROTO_TCP 6
|
||||
#define IPPROTO_UDP 17
|
||||
|
||||
#define TCP_NODELAY 0x2004
|
||||
|
||||
#define SOL_SOCKET -1
|
||||
#define SO_REUSEADDR 0x0004
|
||||
#define SO_NONBLOCK 0x1016
|
||||
#define SO_MYADDR 0x1013
|
||||
|
||||
#define htonl(x) x
|
||||
#define htons(x) x
|
||||
#define ntohl(x) x
|
||||
#define ntohs(x) x
|
||||
|
||||
|
||||
struct in_addr {
|
||||
unsigned int s_addr;
|
||||
};
|
||||
struct sockaddr_in {
|
||||
short sin_family;
|
||||
unsigned short sin_port;
|
||||
struct in_addr sin_addr;
|
||||
char sin_zero[8];
|
||||
};
|
||||
|
||||
struct sockaddr
|
||||
{
|
||||
unsigned short sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
|
||||
void InitSocketFunctionPointers(void);
|
||||
|
||||
extern void (*socket_lib_init)(void);
|
||||
extern int (*socket)(int domain, int type, int protocol);
|
||||
extern int (*socketclose)(int s);
|
||||
extern int (*connect)(int s, void *addr, int addrlen);
|
||||
extern int (*bind)(s32 s,struct sockaddr *name,s32 namelen);
|
||||
extern int (*listen)(s32 s,u32 backlog);
|
||||
extern int (*accept)(s32 s,struct sockaddr *addr,s32 *addrlen);
|
||||
extern int (*send)(int s, const void *buffer, int size, int flags);
|
||||
extern int (*recv)(int s, void *buffer, int size, int flags);
|
||||
extern int (*sendto)(int s, const void *buffer, int size, int flags, const struct sockaddr *dest, int dest_len);
|
||||
extern int (*setsockopt)(int s, int level, int optname, void *optval, int optlen);
|
||||
|
||||
extern char * (*inet_ntoa)(struct in_addr in);
|
||||
extern int (*inet_aton)(const char *cp, struct in_addr *inp);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __SOCKET_FUNCTIONS_H_
|
40
wiiu/dynamic_libs/sys_functions.c
Normal file
40
wiiu/dynamic_libs/sys_functions.c
Normal file
@ -0,0 +1,40 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "os_functions.h"
|
||||
|
||||
EXPORT_DECL(void, _SYSLaunchTitleByPathFromLauncher, const char* path, int len, int zero);
|
||||
EXPORT_DECL(int, SYSRelaunchTitle, int argc, char* argv);
|
||||
EXPORT_DECL(int, SYSLaunchMenu, void);
|
||||
|
||||
void InitSysFunctionPointers(void)
|
||||
{
|
||||
unsigned int *funcPointer = 0;
|
||||
unsigned int sysapp_handle;
|
||||
OSDynLoad_Acquire("sysapp.rpl", &sysapp_handle);
|
||||
|
||||
OS_FIND_EXPORT(sysapp_handle, _SYSLaunchTitleByPathFromLauncher);
|
||||
OS_FIND_EXPORT(sysapp_handle, SYSRelaunchTitle);
|
||||
OS_FIND_EXPORT(sysapp_handle, SYSLaunchMenu);
|
||||
}
|
||||
|
42
wiiu/dynamic_libs/sys_functions.h
Normal file
42
wiiu/dynamic_libs/sys_functions.h
Normal file
@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __SYS_FUNCTIONS_H_
|
||||
#define __SYS_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void InitSysFunctionPointers(void);
|
||||
|
||||
extern void(*_SYSLaunchTitleByPathFromLauncher)(const char* path, int len, int zero);
|
||||
extern int (* SYSRelaunchTitle)(int argc, char* argv);
|
||||
extern int (* SYSLaunchMenu)(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __SYS_FUNCTIONS_H_
|
39
wiiu/dynamic_libs/vpad_functions.c
Normal file
39
wiiu/dynamic_libs/vpad_functions.c
Normal file
@ -0,0 +1,39 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#include "os_functions.h"
|
||||
#include "vpad_functions.h"
|
||||
|
||||
EXPORT_DECL(void, VPADInit, void);
|
||||
EXPORT_DECL(void, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error);
|
||||
|
||||
void InitVPadFunctionPointers(void)
|
||||
{
|
||||
unsigned int *funcPointer = 0;
|
||||
unsigned int vpad_handle;
|
||||
OSDynLoad_Acquire("vpad.rpl", &vpad_handle);
|
||||
|
||||
OS_FIND_EXPORT(vpad_handle, VPADInit);
|
||||
OS_FIND_EXPORT(vpad_handle, VPADRead);
|
||||
}
|
||||
|
102
wiiu/dynamic_libs/vpad_functions.h
Normal file
102
wiiu/dynamic_libs/vpad_functions.h
Normal file
@ -0,0 +1,102 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __VPAD_FUNCTIONS_H_
|
||||
#define __VPAD_FUNCTIONS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
#define VPAD_BUTTON_A 0x8000
|
||||
#define VPAD_BUTTON_B 0x4000
|
||||
#define VPAD_BUTTON_X 0x2000
|
||||
#define VPAD_BUTTON_Y 0x1000
|
||||
#define VPAD_BUTTON_LEFT 0x0800
|
||||
#define VPAD_BUTTON_RIGHT 0x0400
|
||||
#define VPAD_BUTTON_UP 0x0200
|
||||
#define VPAD_BUTTON_DOWN 0x0100
|
||||
#define VPAD_BUTTON_ZL 0x0080
|
||||
#define VPAD_BUTTON_ZR 0x0040
|
||||
#define VPAD_BUTTON_L 0x0020
|
||||
#define VPAD_BUTTON_R 0x0010
|
||||
#define VPAD_BUTTON_PLUS 0x0008
|
||||
#define VPAD_BUTTON_MINUS 0x0004
|
||||
#define VPAD_BUTTON_HOME 0x0002
|
||||
#define VPAD_BUTTON_SYNC 0x0001
|
||||
#define VPAD_BUTTON_STICK_R 0x00020000
|
||||
#define VPAD_BUTTON_STICK_L 0x00040000
|
||||
#define VPAD_BUTTON_TV 0x00010000
|
||||
|
||||
#define VPAD_STICK_R_EMULATION_LEFT 0x04000000
|
||||
#define VPAD_STICK_R_EMULATION_RIGHT 0x02000000
|
||||
#define VPAD_STICK_R_EMULATION_UP 0x01000000
|
||||
#define VPAD_STICK_R_EMULATION_DOWN 0x00800000
|
||||
|
||||
#define VPAD_STICK_L_EMULATION_LEFT 0x40000000
|
||||
#define VPAD_STICK_L_EMULATION_RIGHT 0x20000000
|
||||
#define VPAD_STICK_L_EMULATION_UP 0x10000000
|
||||
#define VPAD_STICK_L_EMULATION_DOWN 0x08000000
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
f32 x,y;
|
||||
} Vec2D;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u16 x, y; /* Touch coordinates */
|
||||
u16 touched; /* 1 = Touched, 0 = Not touched */
|
||||
u16 invalid; /* 0 = All valid, 1 = X invalid, 2 = Y invalid, 3 = Both invalid? */
|
||||
} VPADTPData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 btns_h; /* Held buttons */
|
||||
u32 btns_d; /* Buttons that are pressed at that instant */
|
||||
u32 btns_r; /* Released buttons */
|
||||
Vec2D lstick, rstick; /* Each contains 4-byte X and Y components */
|
||||
char unknown1c[0x52 - 0x1c]; /* Contains accelerometer and gyroscope data somewhere */
|
||||
VPADTPData tpdata; /* Normal touchscreen data */
|
||||
VPADTPData tpdata1; /* Modified touchscreen data 1 */
|
||||
VPADTPData tpdata2; /* Modified touchscreen data 2 */
|
||||
char unknown6a[0xa0 - 0x6a];
|
||||
uint8_t volume;
|
||||
uint8_t battery; /* 0 to 6 */
|
||||
uint8_t unk_volume; /* One less than volume */
|
||||
char unknowna4[0xac - 0xa4];
|
||||
} VPADData;
|
||||
|
||||
void InitVPadFunctionPointers(void);
|
||||
|
||||
extern void (* VPADInit)(void);
|
||||
extern void (* VPADRead)(int chan, VPADData *buffer, u32 buffer_size, s32 *error);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __VPAD_FUNCTIONS_H_
|
182
wiiu/fs/fs_utils.c
Normal file
182
wiiu/fs/fs_utils.c
Normal file
@ -0,0 +1,182 @@
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include "common/fs_defs.h"
|
||||
#include "dynamic_libs/fs_functions.h"
|
||||
|
||||
|
||||
int MountFS(void *pClient, void *pCmd, char **mount_path)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
void *mountSrc = malloc(FS_MOUNT_SOURCE_SIZE);
|
||||
if(!mountSrc)
|
||||
return -3;
|
||||
|
||||
char* mountPath = (char*) malloc(FS_MAX_MOUNTPATH_SIZE);
|
||||
if(!mountPath) {
|
||||
free(mountSrc);
|
||||
return -4;
|
||||
}
|
||||
|
||||
memset(mountSrc, 0, FS_MOUNT_SOURCE_SIZE);
|
||||
memset(mountPath, 0, FS_MAX_MOUNTPATH_SIZE);
|
||||
|
||||
// Mount sdcard
|
||||
if (FSGetMountSource(pClient, pCmd, FS_SOURCETYPE_EXTERNAL, mountSrc, -1) == 0)
|
||||
{
|
||||
result = FSMount(pClient, pCmd, mountSrc, mountPath, FS_MAX_MOUNTPATH_SIZE, -1);
|
||||
if((result == 0) && mount_path) {
|
||||
*mount_path = (char*)malloc(strlen(mountPath) + 1);
|
||||
if(*mount_path)
|
||||
strcpy(*mount_path, mountPath);
|
||||
}
|
||||
}
|
||||
|
||||
free(mountPath);
|
||||
free(mountSrc);
|
||||
return result;
|
||||
}
|
||||
|
||||
int UmountFS(void *pClient, void *pCmd, const char *mountPath)
|
||||
{
|
||||
int result = -1;
|
||||
result = FSUnmount(pClient, pCmd, mountPath, -1);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size)
|
||||
{
|
||||
//! always initialze input
|
||||
*inbuffer = NULL;
|
||||
if(size)
|
||||
*size = 0;
|
||||
|
||||
int iFd = open(filepath, O_RDONLY);
|
||||
if (iFd < 0)
|
||||
return -1;
|
||||
|
||||
u32 filesize = lseek(iFd, 0, SEEK_END);
|
||||
lseek(iFd, 0, SEEK_SET);
|
||||
|
||||
u8 *buffer = (u8 *) malloc(filesize);
|
||||
if (buffer == NULL)
|
||||
{
|
||||
close(iFd);
|
||||
return -2;
|
||||
}
|
||||
|
||||
u32 blocksize = 0x4000;
|
||||
u32 done = 0;
|
||||
int readBytes = 0;
|
||||
|
||||
while(done < filesize)
|
||||
{
|
||||
if(done + blocksize > filesize) {
|
||||
blocksize = filesize - done;
|
||||
}
|
||||
readBytes = read(iFd, buffer + done, blocksize);
|
||||
if(readBytes <= 0)
|
||||
break;
|
||||
done += readBytes;
|
||||
}
|
||||
|
||||
close(iFd);
|
||||
|
||||
if (done != filesize)
|
||||
{
|
||||
free(buffer);
|
||||
return -3;
|
||||
}
|
||||
|
||||
*inbuffer = buffer;
|
||||
|
||||
//! sign is optional input
|
||||
if(size)
|
||||
*size = filesize;
|
||||
|
||||
return filesize;
|
||||
}
|
||||
|
||||
int CheckFile(const char * filepath)
|
||||
{
|
||||
if(!filepath)
|
||||
return 0;
|
||||
|
||||
struct stat filestat;
|
||||
|
||||
char dirnoslash[strlen(filepath)+2];
|
||||
snprintf(dirnoslash, sizeof(dirnoslash), "%s", filepath);
|
||||
|
||||
while(dirnoslash[strlen(dirnoslash)-1] == '/')
|
||||
dirnoslash[strlen(dirnoslash)-1] = '\0';
|
||||
|
||||
char * notRoot = strrchr(dirnoslash, '/');
|
||||
if(!notRoot)
|
||||
{
|
||||
strcat(dirnoslash, "/");
|
||||
}
|
||||
|
||||
if (stat(dirnoslash, &filestat) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CreateSubfolder(const char * fullpath)
|
||||
{
|
||||
if(!fullpath)
|
||||
return 0;
|
||||
|
||||
int result = 0;
|
||||
|
||||
char dirnoslash[strlen(fullpath)+1];
|
||||
strcpy(dirnoslash, fullpath);
|
||||
|
||||
int pos = strlen(dirnoslash)-1;
|
||||
while(dirnoslash[pos] == '/')
|
||||
{
|
||||
dirnoslash[pos] = '\0';
|
||||
pos--;
|
||||
}
|
||||
|
||||
if(CheckFile(dirnoslash))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
char parentpath[strlen(dirnoslash)+2];
|
||||
strcpy(parentpath, dirnoslash);
|
||||
char * ptr = strrchr(parentpath, '/');
|
||||
|
||||
if(!ptr)
|
||||
{
|
||||
//!Device root directory (must be with '/')
|
||||
strcat(parentpath, "/");
|
||||
struct stat filestat;
|
||||
if (stat(parentpath, &filestat) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ptr++;
|
||||
ptr[0] = '\0';
|
||||
|
||||
result = CreateSubfolder(parentpath);
|
||||
}
|
||||
|
||||
if(!result)
|
||||
return 0;
|
||||
|
||||
if (mkdir(dirnoslash, 0777) == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
23
wiiu/fs/fs_utils.h
Normal file
23
wiiu/fs/fs_utils.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef __FS_UTILS_H_
|
||||
#define __FS_UTILS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <gctypes.h>
|
||||
|
||||
int MountFS(void *pClient, void *pCmd, char **mount_path);
|
||||
int UmountFS(void *pClient, void *pCmd, const char *mountPath);
|
||||
|
||||
int LoadFileToMem(const char *filepath, u8 **inbuffer, u32 *size);
|
||||
|
||||
//! todo: C++ class
|
||||
int CreateSubfolder(const char * fullpath);
|
||||
int CheckFile(const char * filepath);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __FS_UTILS_H_
|
1019
wiiu/fs/sd_fat_devoptab.c
Normal file
1019
wiiu/fs/sd_fat_devoptab.c
Normal file
File diff suppressed because it is too large
Load Diff
38
wiiu/fs/sd_fat_devoptab.h
Normal file
38
wiiu/fs/sd_fat_devoptab.h
Normal file
@ -0,0 +1,38 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2015
|
||||
* by Dimok
|
||||
*
|
||||
* This software is provided 'as-is', without any express or implied
|
||||
* warranty. In no event will the authors be held liable for any
|
||||
* damages arising from the use of this software.
|
||||
*
|
||||
* Permission is granted to anyone to use this software for any
|
||||
* purpose, including commercial applications, and to alter it and
|
||||
* redistribute it freely, subject to the following restrictions:
|
||||
*
|
||||
* 1. The origin of this software must not be misrepresented; you
|
||||
* must not claim that you wrote the original software. If you use
|
||||
* this software in a product, an acknowledgment in the product
|
||||
* documentation would be appreciated but is not required.
|
||||
*
|
||||
* 2. Altered source versions must be plainly marked as such, and
|
||||
* must not be misrepresented as being the original software.
|
||||
*
|
||||
* 3. This notice may not be removed or altered from any source
|
||||
* distribution.
|
||||
***************************************************************************/
|
||||
#ifndef __SD_FAT_DEVOPTAB_H_
|
||||
#define __SD_FAT_DEVOPTAB_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int mount_sd_fat(const char *path);
|
||||
int unmount_sd_fat(const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __SD_FAT_DEVOPTAB_H_
|
40
wiiu/link.ld
Normal file
40
wiiu/link.ld
Normal file
@ -0,0 +1,40 @@
|
||||
OUTPUT(ftpiiu.elf);
|
||||
|
||||
/* Tell linker where our application entry is so the garbage collect can work correct */
|
||||
ENTRY(__entry_menu);
|
||||
|
||||
SECTIONS {
|
||||
. = 0x00802000;
|
||||
.text : {
|
||||
*(.text*);
|
||||
}
|
||||
.rodata : {
|
||||
*(.rodata*);
|
||||
}
|
||||
.data : {
|
||||
*(.data*);
|
||||
|
||||
__sdata_start = .;
|
||||
*(.sdata*);
|
||||
__sdata_end = .;
|
||||
|
||||
__sdata2_start = .;
|
||||
*(.sdata2*);
|
||||
__sdata2_end = .;
|
||||
}
|
||||
.bss : {
|
||||
__bss_start = .;
|
||||
*(.bss*);
|
||||
*(.sbss*);
|
||||
*(COMMON);
|
||||
__bss_end = .;
|
||||
}
|
||||
__CODE_END = .;
|
||||
|
||||
/DISCARD/ : {
|
||||
*(*);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************** FS ********************************************************/
|
||||
/* coreinit.rpl difference in addresses 0xFE3C00 */
|
2
wiiu/net.sh
Executable file
2
wiiu/net.sh
Executable file
@ -0,0 +1,2 @@
|
||||
python2 wiiu/wiiload.py retroarch_wiiu.elf sd:/zz.gb
|
||||
netcat -p 4405 -l 10.42.0.170
|
198
wiiu/system/memory.c
Normal file
198
wiiu/system/memory.c
Normal file
@ -0,0 +1,198 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* This program 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 Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include "dynamic_libs/os_functions.h"
|
||||
#include "common/common.h"
|
||||
#include "memory.h"
|
||||
|
||||
#define MEMORY_ARENA_1 0
|
||||
#define MEMORY_ARENA_2 1
|
||||
#define MEMORY_ARENA_3 2
|
||||
#define MEMORY_ARENA_4 3
|
||||
#define MEMORY_ARENA_5 4
|
||||
#define MEMORY_ARENA_6 5
|
||||
#define MEMORY_ARENA_7 6
|
||||
#define MEMORY_ARENA_8 7
|
||||
#define MEMORY_ARENA_FG_BUCKET 8
|
||||
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
//! Memory functions
|
||||
//! This is the only place where those are needed so lets keep them more or less private
|
||||
//!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
extern unsigned int * pMEMAllocFromDefaultHeapEx;
|
||||
extern unsigned int * pMEMAllocFromDefaultHeap;
|
||||
extern unsigned int * pMEMFreeToDefaultHeap;
|
||||
|
||||
extern int (* MEMGetBaseHeapHandle)(int mem_arena);
|
||||
extern unsigned int (* MEMGetAllocatableSizeForFrmHeapEx)(int heap, int align);
|
||||
extern void *(* MEMAllocFromFrmHeapEx)(int heap, unsigned int size, int align);
|
||||
extern void (* MEMFreeToFrmHeap)(int heap, int mode);
|
||||
extern void *(* MEMAllocFromExpHeapEx)(int heap, unsigned int size, int align);
|
||||
extern int (* MEMCreateExpHeapEx)(void* address, unsigned int size, unsigned short flags);
|
||||
extern void *(* MEMDestroyExpHeap)(int heap);
|
||||
extern void (* MEMFreeToExpHeap)(int heap, void* ptr);
|
||||
|
||||
static int mem1_heap = -1;
|
||||
static int bucket_heap = -1;
|
||||
|
||||
void memoryInitialize(void)
|
||||
{
|
||||
int mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1);
|
||||
unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4);
|
||||
void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4);
|
||||
if(mem1_memory)
|
||||
mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0);
|
||||
|
||||
int bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET);
|
||||
unsigned int bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4);
|
||||
void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4);
|
||||
if(bucket_memory)
|
||||
bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0);
|
||||
}
|
||||
|
||||
void memoryRelease(void)
|
||||
{
|
||||
MEMDestroyExpHeap(mem1_heap);
|
||||
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_1), 3);
|
||||
mem1_heap = -1;
|
||||
|
||||
MEMDestroyExpHeap(bucket_heap);
|
||||
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET), 3);
|
||||
bucket_heap = -1;
|
||||
}
|
||||
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
//! wraps
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
void *__wrap_malloc(size_t size)
|
||||
{
|
||||
// pointer to a function resolve
|
||||
return ((void * (*)(size_t))(*pMEMAllocFromDefaultHeap))(size);
|
||||
}
|
||||
|
||||
void *__wrap_memalign(size_t align, size_t size)
|
||||
{
|
||||
if (align < 4)
|
||||
align = 4;
|
||||
|
||||
// pointer to a function resolve
|
||||
return ((void * (*)(size_t, size_t))(*pMEMAllocFromDefaultHeapEx))(size, align);
|
||||
}
|
||||
|
||||
void __wrap_free(void *p)
|
||||
{
|
||||
// pointer to a function resolve
|
||||
if(p != 0)
|
||||
((void (*)(void *))(*pMEMFreeToDefaultHeap))(p);
|
||||
}
|
||||
|
||||
void *__wrap_calloc(size_t n, size_t size)
|
||||
{
|
||||
void *p = __wrap_malloc(n * size);
|
||||
if (p != 0) {
|
||||
memset(p, 0, n * size);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
size_t __wrap_malloc_usable_size(void *p)
|
||||
{
|
||||
//! TODO: this is totally wrong and needs to be addressed
|
||||
return 0x7FFFFFFF;
|
||||
}
|
||||
|
||||
void *__wrap_realloc(void *p, size_t size)
|
||||
{
|
||||
void *new_ptr = __wrap_malloc(size);
|
||||
if (p != 0 && new_ptr != 0)
|
||||
{
|
||||
memcpy(new_ptr, p, __wrap_malloc_usable_size(p) < size ? __wrap_malloc_usable_size(p) : size);
|
||||
__wrap_free(p);
|
||||
}
|
||||
return new_ptr;
|
||||
}
|
||||
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
//! reent versions
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
void *__wrap__malloc_r(struct _reent *r, size_t size)
|
||||
{
|
||||
return __wrap_malloc(size);
|
||||
}
|
||||
|
||||
void *__wrap__calloc_r(struct _reent *r, size_t n, size_t size)
|
||||
{
|
||||
return __wrap_calloc(n, size);
|
||||
}
|
||||
|
||||
void *__wrap__memalign_r(struct _reent *r, size_t align, size_t size)
|
||||
{
|
||||
return __wrap_memalign(align, size);
|
||||
}
|
||||
|
||||
void __wrap__free_r(struct _reent *r, void *p)
|
||||
{
|
||||
__wrap_free(p);
|
||||
}
|
||||
|
||||
size_t __wrap__malloc_usable_size_r(struct _reent *r, void *p)
|
||||
{
|
||||
return __wrap_malloc_usable_size(p);
|
||||
}
|
||||
|
||||
void *__wrap__realloc_r(struct _reent *r, void *p, size_t size)
|
||||
{
|
||||
return __wrap_realloc(p, size);
|
||||
}
|
||||
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
//! some wrappers
|
||||
//!-------------------------------------------------------------------------------------------
|
||||
void * MEM2_alloc(unsigned int size, unsigned int align)
|
||||
{
|
||||
return __wrap_memalign(align, size);
|
||||
}
|
||||
|
||||
void MEM2_free(void *ptr)
|
||||
{
|
||||
__wrap_free(ptr);
|
||||
}
|
||||
|
||||
void * MEM1_alloc(unsigned int size, unsigned int align)
|
||||
{
|
||||
if (align < 4)
|
||||
align = 4;
|
||||
return MEMAllocFromExpHeapEx(mem1_heap, size, align);
|
||||
}
|
||||
|
||||
void MEM1_free(void *ptr)
|
||||
{
|
||||
MEMFreeToExpHeap(mem1_heap, ptr);
|
||||
}
|
||||
|
||||
void * MEMBucket_alloc(unsigned int size, unsigned int align)
|
||||
{
|
||||
if (align < 4)
|
||||
align = 4;
|
||||
return MEMAllocFromExpHeapEx(bucket_heap, size, align);
|
||||
}
|
||||
|
||||
void MEMBucket_free(void *ptr)
|
||||
{
|
||||
MEMFreeToExpHeap(bucket_heap, ptr);
|
||||
}
|
42
wiiu/system/memory.h
Normal file
42
wiiu/system/memory.h
Normal file
@ -0,0 +1,42 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2015 Dimok
|
||||
*
|
||||
* This program 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 Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
#ifndef __MEMORY_H_
|
||||
#define __MEMORY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <malloc.h>
|
||||
|
||||
void memoryInitialize(void);
|
||||
void memoryRelease(void);
|
||||
|
||||
void * MEM2_alloc(unsigned int size, unsigned int align);
|
||||
void MEM2_free(void *ptr);
|
||||
|
||||
void * MEM1_alloc(unsigned int size, unsigned int align);
|
||||
void MEM1_free(void *ptr);
|
||||
|
||||
void * MEMBucket_alloc(unsigned int size, unsigned int align);
|
||||
void MEMBucket_free(void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __MEMORY_H_
|
47
wiiu/utils/utils.h
Normal file
47
wiiu/utils/utils.h
Normal file
@ -0,0 +1,47 @@
|
||||
#ifndef __UTILS_H_
|
||||
#define __UTILS_H_
|
||||
|
||||
#include <malloc.h>
|
||||
#include "../common/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define FlushBlock(addr) asm volatile("dcbf %0, %1\n" \
|
||||
"icbi %0, %1\n" \
|
||||
"sync\n" \
|
||||
"eieio\n" \
|
||||
"isync\n" \
|
||||
: \
|
||||
:"r"(0), "r"(((addr) & ~31)) \
|
||||
:"memory", "ctr", "lr", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" \
|
||||
);
|
||||
|
||||
#define LIMIT(x, min, max) \
|
||||
({ \
|
||||
typeof( x ) _x = x; \
|
||||
typeof( min ) _min = min; \
|
||||
typeof( max ) _max = max; \
|
||||
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \
|
||||
})
|
||||
|
||||
#define DegToRad(a) ( (a) * 0.01745329252f )
|
||||
#define RadToDeg(a) ( (a) * 57.29577951f )
|
||||
|
||||
#define ALIGN4(x) (((x) + 3) & ~3)
|
||||
#define ALIGN32(x) (((x) + 31) & ~31)
|
||||
|
||||
// those work only in powers of 2
|
||||
#define ROUNDDOWN(val, align) ((val) & ~(align-1))
|
||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align-1)), align)
|
||||
|
||||
#define le16(i) ((((u16) ((i) & 0xFF)) << 8) | ((u16) (((i) & 0xFF00) >> 8)))
|
||||
#define le32(i) ((((u32)le16((i) & 0xFFFF)) << 16) | ((u32)le16(((i) & 0xFFFF0000) >> 16)))
|
||||
#define le64(i) ((((u64)le32((i) & 0xFFFFFFFFLL)) << 32) | ((u64)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __UTILS_H_
|
43
wiiu/wiiload.py
Executable file
43
wiiu/wiiload.py
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os, sys, zlib, socket, struct
|
||||
|
||||
#ip = os.getenv("WIILOAD")
|
||||
ip = "tcp:10.42.0.170"
|
||||
assert ip.startswith("tcp:")
|
||||
wii_ip = (ip[4:], 4299)
|
||||
|
||||
filename = sys.argv[1]
|
||||
|
||||
WIILOAD_VERSION_MAJOR=0
|
||||
WIILOAD_VERSION_MINOR=5
|
||||
|
||||
len_uncompressed = os.path.getsize(filename)
|
||||
c_data = zlib.compress(open(filename).read(), 6)
|
||||
|
||||
chunk_size = 1024*128
|
||||
chunks = [c_data[i:i+chunk_size] for i in range(0, len(c_data), chunk_size)]
|
||||
|
||||
args = [os.path.basename(filename)]+sys.argv[2:]
|
||||
args = "\x00".join(args) + "\x00"
|
||||
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
s.connect(wii_ip)
|
||||
|
||||
s.send("HAXX")
|
||||
s.send(struct.pack("B", WIILOAD_VERSION_MAJOR)) # one byte, unsigned
|
||||
s.send(struct.pack("B", WIILOAD_VERSION_MINOR)) # one byte, unsigned
|
||||
s.send(struct.pack(">H",len(args))) # bigendian, 2 bytes, unsigned
|
||||
s.send(struct.pack(">L",len(c_data))) # bigendian, 4 bytes, unsigned
|
||||
s.send(struct.pack(">L",len_uncompressed)) # bigendian, 4 bytes, unsigned
|
||||
|
||||
print len(chunks),"chunks to send"
|
||||
for piece in chunks:
|
||||
s.send(piece)
|
||||
sys.stdout.write("."); sys.stdout.flush()
|
||||
sys.stdout.write("\n")
|
||||
|
||||
s.send(args)
|
||||
|
||||
s.close()
|
||||
print "done"
|
26
wiiu/wiiu_dbg.h
Normal file
26
wiiu/wiiu_dbg.h
Normal file
@ -0,0 +1,26 @@
|
||||
#ifndef WIIU_DBG_H
|
||||
#define WIIU_DBG_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
//void wait_for_input(void);
|
||||
//void dump_result_value(Result val);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
//#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
|
||||
#define DEBUG_LINE() do{printf("%s:%d.\n",__FUNCTION__, __LINE__);fflush(stdout);}while(0)
|
||||
#define DEBUG_STR(X) printf( "%s: %s\n", #X, (char*)(X))
|
||||
#define DEBUG_VAR(X) printf( "%-20s: 0x%08X\n", #X, (u32)(X))
|
||||
#define DEBUG_INT(X) printf( "%-20s: %10i\n", #X, (s32)(X))
|
||||
#define DEBUG_VAR64(X) printf( #X"\r\t\t\t\t : 0x%016llX\n", (u64)(X))
|
||||
//#define DEBUG_ERROR(X) do{if(X)dump_result_value(X);}while(0)
|
||||
#define PRINTFPOS(X,Y) "\x1b["#X";"#Y"H"
|
||||
#define PRINTFPOS_STR(X,Y) "\x1b["X";"Y"H"
|
||||
#define PRINTF_LINE(X) "\x1b["X";0H"
|
||||
|
||||
#endif // WIIU_DBG_H
|
Loading…
Reference in New Issue
Block a user