mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-12-23 16:42:00 +01:00
- Remove plugins from the repository (Will be re-uploaded to different reposistories)
- Updated the codeblocks template
This commit is contained in:
parent
0bb7c44feb
commit
545ef11ac8
14
.travis.yml
14
.travis.yml
@ -6,8 +6,7 @@ dist: trusty
|
||||
|
||||
env:
|
||||
global:
|
||||
- DEVKITPRO=/opt/devkitpro
|
||||
- WUT_ROOT=/opt/devkitpro/wut
|
||||
- DEVKITPRO=/opt/devkitpro
|
||||
- DEVKITPPC=/opt/devkitpro/devkitPPC
|
||||
- DEVKITARM=/opt/devkitpro/devkitARM
|
||||
- PORTLIBREPOS=$HOME/portlibrepos
|
||||
@ -32,27 +31,21 @@ before_install:
|
||||
- yes | sudo dkp-pacman -Syu devkitPPC --needed
|
||||
- yes | sudo dkp-pacman -Syu devkitARM --needed
|
||||
- yes | sudo dkp-pacman -Syu general-tools --needed
|
||||
- wget $(curl -s https://api.github.com/repos/decaf-emu/wut/releases/latest | grep 'browser_' | grep 'linux' | cut -d\" -f4)
|
||||
|
||||
install:
|
||||
- 7z x -y $(ls | grep "linux") -o${WUT_ROOT}
|
||||
- cd $PORTLIBREPOS
|
||||
- ((git clone https://github.com/Maschell/dynamic_libs.git -b lib && (7z x -y ./dynamic_libs/libs/portlibs.zip -o${DEVKITPRO})) || (cd dynamic_libs && git pull))
|
||||
- (git clone https://github.com/dimok789/libiosuhax.git || (cd libiosuhax && git pull))
|
||||
- (git clone https://github.com/Maschell/libfat.git || (cd libfat && git pull))
|
||||
- (git clone https://github.com/Maschell/libntfs-wiiu.git || (cd libntfs-wiiu && git pull))
|
||||
- (git clone https://github.com/Maschell/libutils.git || (cd libutils && git pull))
|
||||
- ((git clone https://github.com/Maschell/libgui.git && (7z x -y ./libgui/libs/portlibs.zip -o${DEVKITPRO})) || (cd libgui && git pull))
|
||||
- (git clone https://github.com/Maschell/fs_wrapper.git || (cd fs_wrapper && git pull))
|
||||
- (git clone https://github.com/Maschell/controller_patcher.git || (cd controller_patcher && git pull))
|
||||
- ((git clone https://github.com/Maschell/libgui.git && (7z x -y ./libgui/libs/portlibs.zip -o${DEVKITPRO})) || (cd libgui && git pull))
|
||||
- (cd dynamic_libs && ((make -j8 | grep -c "built ... ") && make install && echo "installed" ) || (echo "no need for make install" && make))
|
||||
- (cd libiosuhax && make -j8 && make install)
|
||||
- (cd libfat && make wiiu-release && make wiiu-install)
|
||||
- (cd libntfs-wiiu && make wiiu-install)
|
||||
- (cd libutils && ((make -j8 | grep -c "built ... ") && make install && echo "installed" ) || (echo "no need for make install" && make))
|
||||
- (cd libgui && ((make -j8 | grep -c "built ... ") && make install) || echo "no need for make install")
|
||||
- (cd fs_wrapper && ((make -j8 | grep -c "built ... ") && make install && echo "installed" ) || (echo "no need for make install" && make))
|
||||
- (cd controller_patcher && ((make -j8 | grep -c "built ... ") && make install && echo "installed" ) || (echo "no need for make install" && make))
|
||||
|
||||
before_script:
|
||||
- cd $TRAVIS_BUILD_DIR/
|
||||
@ -60,17 +53,14 @@ before_script:
|
||||
script:
|
||||
- make && make install
|
||||
- (cd loader && make)
|
||||
- (cd plugins && make)
|
||||
|
||||
before_deploy:
|
||||
- cd $TRAVIS_BUILD_DIR/
|
||||
- mkdir -p "wiiu/apps/wiiupluginloader"
|
||||
- mkdir -p "wiiu/plugins"
|
||||
- commit="$(git rev-parse --short=7 HEAD)"
|
||||
- chmod +x gitrev.sh
|
||||
- versiontag="$(./gitrev.sh)"
|
||||
- (cd loader && make)
|
||||
- find plugins -type f -name "*.mod" | xargs -i cp {} wiiu/plugins
|
||||
- cp loader/meta/* wiiu/apps/wiiupluginloader
|
||||
- cp loader/wiiupluginloader.elf wiiu/apps/wiiupluginloader
|
||||
- zip -r WiiUPluginLoader_$versiontag.zip wiiu
|
||||
|
10
README.MD
10
README.MD
@ -46,7 +46,6 @@ For building the loader you need:
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
- [libgui](https://github.com/Maschell/libgui) for the gui elements.
|
||||
- [wut] (https://github.com/decaf-emu/wut) for the wut support.
|
||||
|
||||
Install the according to their readmes. Don't forget to install their dependencies.
|
||||
|
||||
@ -68,16 +67,11 @@ make
|
||||
This should create an "wiiupluginloader.elf" which can be loaded with the Homebrew Launcher.
|
||||
|
||||
### Plugins
|
||||
|
||||
Last but not least you need to build the plugins that should be loaded.
|
||||
Plugins depend on the "WUPS library" installed in build step one, other dependencies are optional.
|
||||
In the folder "plugins" you can find serveral example plugins. In their READMEs are information about needed dependencies.
|
||||
|
||||
You can build them all with the following command in the "plugins" folder (when all dependencies are installed).
|
||||
```
|
||||
make
|
||||
```
|
||||
|
||||
You can also check out the travis script for needed dependencies of the library, loader and example plugins.
|
||||
Example plugins can be found here: (TODO)
|
||||
|
||||
# Logging
|
||||
For logging (for example of the loader) you need to start the UdpDebugReader on a computer in the same network.
|
||||
|
@ -12,9 +12,6 @@ endif
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
|
||||
endif
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
@ -56,8 +53,7 @@ include $(WUPSDIR)/plugin_makefile.mk
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -D__wiiu__: define the symbol __wiiu__ (used in some headers)
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
@ -66,7 +62,7 @@ include $(WUPSDIR)/plugin_makefile.mk
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
@ -81,6 +77,40 @@ ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ADD_NO_WHOLE_ARCHIVE := 0
|
||||
|
||||
ifeq ($(WUT_ENABLE_CPP), 1)
|
||||
WUT_ENABLE_NEWLIB := 1
|
||||
|
||||
LD_FLAGS_ELF += -whole-archive -lwutstdc++
|
||||
ADD_NO_WHOLE_ARCHIVE := 1
|
||||
NEEDS_WUT := 1
|
||||
endif
|
||||
|
||||
ifeq ($(WUT_ENABLE_NEWLIB), 1)
|
||||
LD_FLAGS_ELF += -whole-archive -lwutnewlib
|
||||
ADD_NO_WHOLE_ARCHIVE := 1
|
||||
NEEDS_WUT := 1
|
||||
endif
|
||||
|
||||
ifeq ($(WUT_DEFAULT_MALLOC), 1)
|
||||
LD_FLAGS_ELF += -whole-archive -lwutmalloc
|
||||
ADD_NO_WHOLE_ARCHIVE := 1
|
||||
NEEDS_WUT := 1
|
||||
endif
|
||||
|
||||
ifeq ($(ADD_NO_WHOLE_ARCHIVE), 1)
|
||||
LD_FLAGS_ELF += -no-whole-archive
|
||||
endif
|
||||
|
||||
ifeq ($(NEEDS_WUT), 1)
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
@ -106,7 +136,7 @@ ALL_LIBS := $(LIBS)
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
LIBDIRS +=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
|
@ -2,7 +2,24 @@
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
WRAP_MALLOC := 0
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Links against the wut implementation of newlib, this is useful for using any function
|
||||
# from the C standard library
|
||||
WUT_ENABLE_NEWLIB := 0
|
||||
|
||||
# Links against the wut implementation of stdcpp, this is useful for using any function
|
||||
# from the C++ standard library. This will enable WUT_ENABLE_NEWLIB if you have not already done so.
|
||||
WUT_ENABLE_CPP := 0
|
||||
|
||||
# By default newlib will allocate 90% of the default heap for use with sbrk & malloc,
|
||||
# if this is unacceptable to you then you should use this as it replaces the newlib
|
||||
# malloc functions which ones which redirect to the CafeOS default heap functions
|
||||
# such as MEMAllocFromDefaultHeap.
|
||||
WUT_DEFAULT_MALLOC := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
@ -39,7 +56,7 @@ LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lutils -ldynamiclibs
|
||||
LIBS := -lwups
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
@ -52,4 +69,4 @@ EXTERNAL_LIBPATHS :=
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
||||
EXTERNAL_INCLUDE :=
|
||||
|
@ -1,54 +1,65 @@
|
||||
#include <wups.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <dynamic_libs/fs_functions.h>
|
||||
#include <utils/logger.h>
|
||||
|
||||
/**
|
||||
https://github.com/Maschell/WiiUPluginSystem/wiki/How-to-develope-a-new-plugin#meta-information
|
||||
**/
|
||||
|
||||
// Mandatory plugin information.
|
||||
WUPS_PLUGIN_NAME("Plugin template");
|
||||
WUPS_PLUGIN_DESCRIPTION("Description");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("USERNAME");
|
||||
WUPS_PLUGIN_AUTHOR("(USER)NAME");
|
||||
WUPS_PLUGIN_LICENSE("BSD");
|
||||
|
||||
// FS Access
|
||||
/**
|
||||
Hooks:
|
||||
https://github.com/Maschell/WiiUPluginSystem/wiki/Using-hooks
|
||||
**/
|
||||
|
||||
// FS Access (replaces open/close/write/read etc. functions)
|
||||
WUPS_FS_ACCESS()
|
||||
// Overlay access
|
||||
WUPS_ALLOW_OVERLAY()
|
||||
//WUPS_ALLOW_OVERLAY()
|
||||
|
||||
// Gets called once the loader exists.
|
||||
// Gets called once when the loader exits.
|
||||
INITIALIZE_PLUGIN(){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
|
||||
log_init();
|
||||
DEBUG_FUNCTION_LINE("INITIALIZE_PLUGIN\n");
|
||||
}
|
||||
|
||||
// Called whenever an application was started.
|
||||
ON_APPLICATION_START(){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
}
|
||||
|
||||
log_init();
|
||||
// Called whenever functions where patched by the loader
|
||||
ON_FUNCTIONS_PATCHED(){
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("ON_APPLICATION_START\n");
|
||||
// Get called when ever GX2_VSYNC() was called (on each frame)
|
||||
ON_VYSNC(){
|
||||
}
|
||||
|
||||
// Gets called whenever the status of the running application changes.
|
||||
ON_APP_STATUS_CHANGED(status){
|
||||
}
|
||||
|
||||
// Called whenever an application is ending
|
||||
ON_APPLICATION_ENDING(){
|
||||
DEBUG_FUNCTION_LINE("ON_APPLICATION_ENDING\n");
|
||||
}
|
||||
|
||||
// Lets replace FSOpenFile
|
||||
DECL_FUNCTION(int, FSOpenFile, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error) {
|
||||
int result = real_FSOpenFile(pClient, pCmd, path, mode, handle, error);
|
||||
// Gets called once when the loader is loaded again at the plugins will be unloaded
|
||||
DEINITIALIZE_PLUGIN(){
|
||||
}
|
||||
|
||||
log_printf("FSOpenFile called for folder %s! Result %d\n",path,result);
|
||||
return result;
|
||||
/**
|
||||
Function replacing.
|
||||
https://github.com/Maschell/WiiUPluginSystem/wiki/Function-replacing
|
||||
**/
|
||||
|
||||
// Lets replace OSIsHomeButtonMenuEnabled to allows the home button anywhere. (Not a great idea.)
|
||||
DECL_FUNCTION(bool, OSIsHomeButtonMenuEnabled) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Replace it.
|
||||
WUPS_MUST_REPLACE(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile);
|
||||
WUPS_MUST_REPLACE(OSIsHomeButtonMenuEnabled, WUPS_LOADER_LIBRARY_COREINIT, OSIsHomeButtonMenuEnabled);
|
||||
|
@ -1,13 +0,0 @@
|
||||
SUBDIRS = $(shell ls -d */)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all:
|
||||
for dir in $(SUBDIRS); do \
|
||||
$(MAKE) -C $$dir -f Makefile; \
|
||||
done
|
||||
|
||||
clean:
|
||||
for dir in $(SUBDIRS); do \
|
||||
$(MAKE) -C $$dir -f Makefile clean; \
|
||||
done
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,12 +0,0 @@
|
||||
# Example plugin
|
||||
|
||||
This is just a simple example plugin which can be used as a template.
|
||||
|
||||
## Building
|
||||
|
||||
For building you need:
|
||||
- [wups](https://github.com/Maschell/WiiUPluginSystem)
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
@ -1,58 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lutils -ldynamiclibs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
@ -1,146 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include "dynamic_libs/os_functions.h"
|
||||
#include "dynamic_libs/socket_functions.h"
|
||||
#include "dynamic_libs/fs_functions.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
/**
|
||||
Mandatory plugin information.
|
||||
If not set correctly, the loader will refuse to use the plugin.
|
||||
**/
|
||||
WUPS_PLUGIN_NAME("Example plugin");
|
||||
WUPS_PLUGIN_DESCRIPTION("This is just an example plugin and will log the FSOpenFile function.");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("BSD");
|
||||
|
||||
/**
|
||||
Add this to one of your projects file to have access to SD/USB.
|
||||
**/
|
||||
WUPS_FS_ACCESS()
|
||||
/**
|
||||
Add this to one of your projects file to be able to create overlays.
|
||||
**/
|
||||
WUPS_ALLOW_OVERLAY()
|
||||
|
||||
/**
|
||||
All of this defines can be used in ANY file.
|
||||
It's possible to split it up into multiple files.
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
Get's called ONCE when the loader exits, but BEFORE the ON_APPLICATION_START gets called or functions are overridden.
|
||||
**/
|
||||
INITIALIZE_PLUGIN(){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
|
||||
log_init();
|
||||
DEBUG_FUNCTION_LINE("INITIALIZE_PLUGIN of example_plugin!\n");
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called when the plugin loader is re-entered => when the plugin is unloaded.
|
||||
The overridden functions are restored before this is getting called.
|
||||
**/
|
||||
DEINITIALIZE_PLUGIN(){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
|
||||
log_init();
|
||||
DEBUG_FUNCTION_LINE("DEINITIALIZE_PLUGIN of example_plugin!\n");
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called when an application starts.
|
||||
This is called BEFORE the functions are overridden.
|
||||
Make sure to initialize all functions you're using in the overridden functions!
|
||||
**/
|
||||
ON_APPLICATION_START(){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
|
||||
log_init();
|
||||
|
||||
DEBUG_FUNCTION_LINE("ON_APPLICATION_START of example_plugin!\n");
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called when an application ends. A good place for freeing memory.
|
||||
**/
|
||||
ON_APPLICATION_ENDING(){
|
||||
DEBUG_FUNCTION_LINE("ON_APPLICATION_ENDING of example_plugin!\n");
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called on each frame.
|
||||
**/
|
||||
ON_VYSNC(){
|
||||
DEBUG_FUNCTION_LINE("ON_VYSNC of example_plugin!\n");
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called whenever the application status changes.
|
||||
|
||||
Possible values of "status":
|
||||
WUPS_APP_STATUS_FOREGROUND, App is now running in foreground
|
||||
WUPS_APP_STATUS_BACKGROUND App is now running in background
|
||||
WUPS_APP_STATUS_CLOSED App is going to be closed
|
||||
**/
|
||||
ON_APP_STATUS_CHANGED(status){
|
||||
if(status == WUPS_APP_STATUS_FOREGROUND){
|
||||
DEBUG_FUNCTION_LINE("ON_APP_STATUS_CHANGED of example_plugin! App is now in foreground\n");
|
||||
} else if(status == WUPS_APP_STATUS_BACKGROUND){
|
||||
DEBUG_FUNCTION_LINE("ON_APP_STATUS_CHANGED of example_plugin! App is now in background\n");
|
||||
} else if(status == WUPS_APP_STATUS_CLOSED){
|
||||
DEBUG_FUNCTION_LINE("ON_APP_STATUS_CHANGED of example_plugin! App is now going to be closed\n");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
This defines a function replacement.
|
||||
It allows to replace the system function with an own function.
|
||||
So whenever a game / application calles an overridden function, your function gets called instead.
|
||||
|
||||
Currently it's only possible to override functions that are loaded from .rpl files of OSv10 (00050010-1000400A).
|
||||
|
||||
Signature of this macro:
|
||||
DECL_FUNCTION( RETURN_TYPE, ARBITRARY_NAME_OF_FUNCTION , ARGS_SEPERATED_BY_COMMA){
|
||||
//Your code goes here.
|
||||
}
|
||||
|
||||
Within this macro, two more function get declare you can use.
|
||||
my_ARBITRARY_NAME_OF_FUNCTION and real_FSOpenFile
|
||||
|
||||
RETURN_TYPE my_ARBITRARY_NAME_OF_FUNCTION(ARGS_SEPERATED_BY_COMMA):
|
||||
is just name of the function that gets declared in this macro.
|
||||
It has the same effect as calling the overridden function directly.
|
||||
|
||||
RETURN_TYPE real_ARBITRARY_NAME_OF_FUNCTION(ARGS_SEPERATED_BY_COMMA):
|
||||
is the name of the function, that leads to function that was overridden.
|
||||
Use this to call the original function that will be overridden.
|
||||
CAUTION: Other plugins may already have manipulated the the return value or arguments.
|
||||
|
||||
|
||||
Use this macro for each function you want to override
|
||||
|
||||
**/
|
||||
DECL_FUNCTION(int, FSOpenFile, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error) {
|
||||
int result = real_FSOpenFile(pClient, pCmd, path, mode, handle, error);
|
||||
|
||||
log_printf("FSOpenFile called for folder %s! Result %d\n",path,result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
This tells the loader which functions from which library (.rpl) should be replaced with which function from this file.
|
||||
The list of possible libraries can be found in the wiki. (In general it's WUPS_LOADER_LIBRARY_ + the name of the RPL in caps lock)
|
||||
|
||||
WUPS_MUST_REPLACE(FUNCTION_NAME_IN_THIS_FILE, NAME_OF_LIB_WHICH_CONTAINS_THIS_FUNCTION, NAME_OF_FUNCTION_TO_OVERRIDE)
|
||||
|
||||
Define this for each function you want to override.
|
||||
**/
|
||||
WUPS_MUST_REPLACE(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile);
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,11 +0,0 @@
|
||||
# Example plugin
|
||||
|
||||
This is just a simple example plugin which can be used as a template.
|
||||
|
||||
## Building
|
||||
|
||||
For building you need:
|
||||
- [wups](https://github.com/Maschell/WiiUPluginSystem)
|
||||
- [wut](https://github.com/decaf-emu/wut)
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
@ -1,58 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 0
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 1
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lwhb -lwutstdc++ -lwutnewlib -lwutmalloc -lcoreinit -lnsysnet -lnn_ac
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE :=
|
@ -1,136 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <whb/log.h>
|
||||
#include <whb/log_udp.h>
|
||||
#include <coreinit/filesystem.h>
|
||||
/**
|
||||
Mandatory plugin information.
|
||||
If not set correctly, the loader will refuse to use the plugin.
|
||||
**/
|
||||
WUPS_PLUGIN_NAME("Example plugin");
|
||||
WUPS_PLUGIN_DESCRIPTION("This is just an example plugin and will log the FSOpenFile function.");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("BSD");
|
||||
|
||||
/**
|
||||
Add this to one of your projects file to have access to SD/USB.
|
||||
**/
|
||||
WUPS_FS_ACCESS()
|
||||
/**
|
||||
Add this to one of your projects file to be able to create overlays.
|
||||
**/
|
||||
WUPS_ALLOW_OVERLAY()
|
||||
|
||||
/**
|
||||
All of this defines can be used in ANY file.
|
||||
It's possible to split it up into multiple files.
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
Get's called ONCE when the loader exits, but BEFORE the ON_APPLICATION_START gets called or functions are overridden.
|
||||
**/
|
||||
INITIALIZE_PLUGIN(){
|
||||
WHBLogUdpInit();
|
||||
WHBLogPrintf("INITIALIZE_PLUGIN");
|
||||
WHBLogUdpDeinit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Gets called when the plugin loader is re-entered => when the plugin is unloaded.
|
||||
The overridden functions are restored before this is getting called.
|
||||
**/
|
||||
DEINITIALIZE_PLUGIN(){
|
||||
WHBLogPrintf("DEINITIALIZE_PLUGIN");
|
||||
WHBLogUdpDeinit();
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called when an application starts.
|
||||
This is called BEFORE the functions are overridden.
|
||||
Make sure to initialize all functions you're using in the overridden functions!
|
||||
**/
|
||||
ON_APPLICATION_START(){
|
||||
WHBLogUdpInit();
|
||||
WHBLogPrintf("ON_APPLICATION_START of example_plugin!");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called when an application ends. A good place for freeing memory.
|
||||
**/
|
||||
ON_APPLICATION_ENDING(){
|
||||
WHBLogPrintf("ON_APPLICATION_ENDING of example_plugin!");
|
||||
WHBLogUdpDeinit();
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called on each frame.
|
||||
**/
|
||||
ON_VYSNC(){
|
||||
WHBLogPrintf("ON_VYSNC of example_plugin!\n");
|
||||
}
|
||||
|
||||
/**
|
||||
Gets called whenever the application status changes.
|
||||
|
||||
Possible values of "status":
|
||||
WUPS_APP_STATUS_FOREGROUND, App is now running in foreground
|
||||
WUPS_APP_STATUS_BACKGROUND App is now running in background
|
||||
WUPS_APP_STATUS_CLOSED App is going to be closed
|
||||
**/
|
||||
ON_APP_STATUS_CHANGED(status){
|
||||
if(status == WUPS_APP_STATUS_FOREGROUND){
|
||||
WHBLogPrintf("ON_APP_STATUS_CHANGED of example_plugin! App is now in foreground");
|
||||
} else if(status == WUPS_APP_STATUS_BACKGROUND){
|
||||
WHBLogPrintf("ON_APP_STATUS_CHANGED of example_plugin! App is now in background");
|
||||
} else if(status == WUPS_APP_STATUS_CLOSED){
|
||||
WHBLogPrintf("ON_APP_STATUS_CHANGED of example_plugin! App is now going to be closed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
This defines a function replacement.
|
||||
It allows to replace the system function with an own function.
|
||||
So whenever a game / application calles an overridden function, your function gets called instead.
|
||||
|
||||
Currently it's only possible to override functions that are loaded from .rpl files of OSv10 (00050010-1000400A).
|
||||
|
||||
Signature of this macro:
|
||||
DECL_FUNCTION( RETURN_TYPE, ARBITRARY_NAME_OF_FUNCTION , ARGS_SEPERATED_BY_COMMA){
|
||||
//Your code goes here.
|
||||
}
|
||||
|
||||
Within this macro, two more function get declare you can use.
|
||||
my_ARBITRARY_NAME_OF_FUNCTION and real_FSOpenFile
|
||||
|
||||
RETURN_TYPE my_ARBITRARY_NAME_OF_FUNCTION(ARGS_SEPERATED_BY_COMMA):
|
||||
is just name of the function that gets declared in this macro.
|
||||
It has the same effect as calling the overridden function directly.
|
||||
|
||||
RETURN_TYPE real_ARBITRARY_NAME_OF_FUNCTION(ARGS_SEPERATED_BY_COMMA):
|
||||
is the name of the function, that leads to function that was overridden.
|
||||
Use this to call the original function that will be overridden.
|
||||
CAUTION: Other plugins may already have manipulated the the return value or arguments.
|
||||
|
||||
|
||||
Use this macro for each function you want to override
|
||||
|
||||
**/
|
||||
DECL_FUNCTION(int, FSOpenFile, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error) {
|
||||
int result = real_FSOpenFile(pClient, pCmd, path, mode, handle, error);
|
||||
|
||||
WHBLogPrintf("FSOpenFile called for folder %s! Result %d",path,result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
This tells the loader which functions from which library (.rpl) should be replaced with which function from this file.
|
||||
The list of possible libraries can be found in the wiki. (In general it's WUPS_LOADER_LIBRARY_ + the name of the RPL in caps lock)
|
||||
|
||||
WUPS_MUST_REPLACE(FUNCTION_NAME_IN_THIS_FILE, NAME_OF_LIB_WHICH_CONTAINS_THIS_FUNCTION, NAME_OF_FUNCTION_TO_OVERRIDE)
|
||||
|
||||
Define this for each function you want to override.
|
||||
**/
|
||||
WUPS_MUST_REPLACE(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile);
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,25 +0,0 @@
|
||||
# HIDtoVPAD Plugin for the Wii U Plugin System
|
||||
|
||||
See https://github.com/Maschell/hid_to_vpad for more information.
|
||||
|
||||
# Currently supported
|
||||
|
||||
- Support for Controller with built in support.
|
||||
- Network Client support
|
||||
- All attached devices are mapped automatically to the Gamepad
|
||||
- Loading configuration files (to extend controller support or change configs)
|
||||
|
||||
Whats NOT working:
|
||||
|
||||
- Mapping the controllers individually (No GUI for this)
|
||||
|
||||
## Building
|
||||
|
||||
For building you need:
|
||||
- [wups](https://github.com/Maschell/WiiUPluginSystem)
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
- [controller_patcher](https://github.com/Maschell/controller_patcher) to emulate the controllers.
|
||||
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
@ -1,58 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lcontrollerpatcher -lutils -ldynamiclibs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
@ -1,92 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <string.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/padscore_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <dynamic_libs/proc_ui_functions.h>
|
||||
#include <controller_patcher/ControllerPatcher.hpp>
|
||||
#include <utils/logger.h>
|
||||
#include <fs/sd_fat_devoptab.h>
|
||||
|
||||
WUPS_PLUGIN_NAME("HID to VPAD lite");
|
||||
WUPS_PLUGIN_DESCRIPTION("Enables HID devices as controllers on your Wii U");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("GPL");
|
||||
|
||||
// We want access to the SDCard!
|
||||
WUPS_FS_ACCESS()
|
||||
|
||||
#define SD_PATH "sd:"
|
||||
#define WIIU_PATH "/wiiu"
|
||||
#define DEFAULT_HID_TO_VPAD_PATH SD_PATH WIIU_PATH "/apps/hidtovpad"
|
||||
|
||||
DEINITIALIZE_PLUGIN(){
|
||||
//CursorDrawer::destroyInstance();
|
||||
ControllerPatcher::DeInit();
|
||||
ControllerPatcher::stopNetworkServer();
|
||||
}
|
||||
|
||||
ON_APPLICATION_START(args){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
InitProcUIFunctionPointers();
|
||||
InitPadScoreFunctionPointers();
|
||||
|
||||
log_init();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Initializing the controller data\n");
|
||||
ControllerPatcher::Init(CONTROLLER_PATCHER_PATH);
|
||||
ControllerPatcher::disableControllerMapping();
|
||||
DEBUG_FUNCTION_LINE("Starting HID to VPAD network server\n");
|
||||
ControllerPatcher::startNetworkServer();
|
||||
}
|
||||
|
||||
ON_APP_STATUS_CHANGED(status){
|
||||
if(status == WUPS_APP_STATUS_CLOSED){
|
||||
//CursorDrawer::destroyInstance();
|
||||
DEBUG_FUNCTION_LINE("ON_APPLICATION_ENDING\n");
|
||||
ControllerPatcher::destroyConfigHelper();
|
||||
DEBUG_FUNCTION_LINE("Calling stopNetworkServer\n");
|
||||
ControllerPatcher::stopNetworkServer();
|
||||
DEBUG_FUNCTION_LINE("Calling resetCallbackData\n");
|
||||
ControllerPatcher::resetCallbackData();
|
||||
}
|
||||
}
|
||||
|
||||
DECL_FUNCTION(s32, VPADRead, s32 chan, VPADData *buffer, u32 buffer_size, s32 *error) {
|
||||
s32 result = real_VPADRead(chan, buffer, buffer_size, error);
|
||||
//A keyboard only sends data when the state changes. We force it to call the sampling callback on each frame!
|
||||
ControllerPatcher::sampleKeyboardData();
|
||||
|
||||
bool do_callback = (result > 0 && (buffer[0].btns_h & VPAD_BUTTON_TV));
|
||||
ControllerPatcher::handleCallbackData(do_callback);
|
||||
|
||||
if(ControllerPatcher::areControllersConnected() && buffer_size > 0){
|
||||
ControllerPatcher::setRumble(UController_Type_Gamepad,!!VPADBASEGetMotorOnRemainingCount(0));
|
||||
|
||||
if(ControllerPatcher::setControllerDataFromHID(buffer) == CONTROLLER_PATCHER_ERROR_NONE){
|
||||
|
||||
if(buffer[0].btns_h & VPAD_BUTTON_HOME){
|
||||
//You can open the home menu this way, but not close it. Need a proper way to close it using the same button...
|
||||
//OSSendAppSwitchRequest(5,0,0); //Open the home menu!
|
||||
}
|
||||
|
||||
if(error != NULL){
|
||||
*error = 0;
|
||||
}
|
||||
result = 1; // We want the WiiU to ignore everything else.
|
||||
}
|
||||
}
|
||||
|
||||
if(ControllerPatcher::isButtonRemappingDone()){
|
||||
ControllerPatcher::buttonRemapping(buffer,result);
|
||||
//ControllerPatcher::printVPADButtons(buffer); //Leads to random crashes on app transitions.
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
WUPS_MUST_REPLACE(VPADRead, WUPS_LOADER_LIBRARY_VPAD, VPADRead);
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,13 +0,0 @@
|
||||
# Memory info for the Wii U Plugin System
|
||||
|
||||
Prints information about the current memory usage when pressing L+R+X+Y+A+B via the UDPReader
|
||||
|
||||
## Building
|
||||
|
||||
For building you need:
|
||||
- [wups](https://github.com/Maschell/WiiUPluginSystem)
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
@ -1,58 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lutils -ldynamiclibs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
@ -1,27 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* 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 "c_retain_vars.h"
|
||||
|
||||
memHeapInfo expHeapPointer[MAX_EXP_HEAP_INFOS] __attribute__((section(".data")));
|
||||
memHeapInfo frmHeapPointer[MAX_FRM_HEAP_INFOS] __attribute__((section(".data")));
|
||||
memUnitHeapInfo unitHeapPointer[MAX_UNIT_HEAP_INFOS] __attribute__((section(".data")));
|
||||
|
||||
baseHeapInfo baseHeaphandles[MAX_BASE_HEAP_INFOS] __attribute__((section(".data")));
|
||||
blockHeapInfo blockHeapInfos[MAX_BLOCK_HEAP_INFOS] __attribute__((section(".data")));
|
||||
memHeapInfo userHeapInfos[MAX_USER_HEAP_INFOS] __attribute__((section(".data")));
|
||||
|
||||
u8 gButtonComboCooldown __attribute__((section(".data"))) = 0;
|
@ -1,32 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* 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 C_RETAINS_VARS_H_
|
||||
#define C_RETAINS_VARS_H_
|
||||
|
||||
#include "memory_defs.h"
|
||||
|
||||
extern memHeapInfo expHeapPointer[MAX_EXP_HEAP_INFOS];
|
||||
extern memHeapInfo frmHeapPointer[MAX_FRM_HEAP_INFOS];
|
||||
extern memUnitHeapInfo unitHeapPointer[MAX_UNIT_HEAP_INFOS];
|
||||
|
||||
extern baseHeapInfo baseHeaphandles[MAX_BASE_HEAP_INFOS];
|
||||
extern blockHeapInfo blockHeapInfos[MAX_BLOCK_HEAP_INFOS];
|
||||
extern memHeapInfo userHeapInfos[MAX_USER_HEAP_INFOS];
|
||||
|
||||
extern u8 gButtonComboCooldown;
|
||||
|
||||
#endif // C_RETAINS_VARS_H_
|
@ -1,34 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <string.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <utils/logger.h>
|
||||
#include "main.h"
|
||||
|
||||
DECL_FUNCTION(void, __PPCExit, void) {
|
||||
// We reset them at ende, in case at application even uses the functions
|
||||
// BEFORE with have our init hook.
|
||||
memset(expHeapPointer,0,sizeof(expHeapPointer));
|
||||
memset(unitHeapPointer,0,sizeof(unitHeapPointer));
|
||||
memset(frmHeapPointer,0,sizeof(frmHeapPointer));
|
||||
memset(baseHeaphandles,0,sizeof(baseHeaphandles));
|
||||
memset(userHeapInfos,0,sizeof(userHeapInfos));
|
||||
real___PPCExit();
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) {
|
||||
int result = real_VPADRead(chan, buffer, buffer_size, error);
|
||||
|
||||
int btns = VPAD_BUTTON_R | VPAD_BUTTON_L | VPAD_BUTTON_A | VPAD_BUTTON_B | VPAD_BUTTON_X | VPAD_BUTTON_Y;
|
||||
if(result > 0 && ((buffer[0].btns_h & (btns)) == btns) && gButtonComboCooldown == 0 && OSIsHomeButtonMenuEnabled()) {
|
||||
print_memory_info();
|
||||
gButtonComboCooldown = 0x3C;
|
||||
}
|
||||
if(gButtonComboCooldown > 0) {
|
||||
gButtonComboCooldown--;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
WUPS_MUST_REPLACE(__PPCExit, WUPS_LOADER_LIBRARY_COREINIT, __PPCExit);
|
||||
WUPS_MUST_REPLACE(VPADRead, WUPS_LOADER_LIBRARY_VPAD, VPADRead);
|
@ -1,105 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <string.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <utils/logger.h>
|
||||
#include "main.h"
|
||||
|
||||
WUPS_PLUGIN_NAME("Memory Info");
|
||||
WUPS_PLUGIN_DESCRIPTION("Prints information about the current memory usage when pressing L+R+X+Y+A+B.");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("GPL");
|
||||
|
||||
ON_APPLICATION_START(args) {
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
log_init();
|
||||
//InitVPadFunctionPointers();
|
||||
}
|
||||
|
||||
void printMemHeapInfo(memHeapInfo * listStart, u32 listLength, const char * listname) {
|
||||
for(int i = 0; i<listLength; i++) {
|
||||
if(listStart[i].handle != 0) {
|
||||
s32 parent = MEMFindParentHeap(listStart[i].handle);
|
||||
DEBUG_FUNCTION_LINE("%s:", listname);
|
||||
if(parent == 0) {
|
||||
log_print(" parent: <NONE> ");
|
||||
} else {
|
||||
log_printf(" parent: 0x%08X ", parent);
|
||||
}
|
||||
log_printf(" address 0x%08X handle 0x%08X size %07d kb old size %07d kb flags 0x%04X\n",listStart[i].address,listStart[i].handle,listStart[i].size/1024,listStart[i].oldSize/1024,listStart[i].flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void print_memory_info() {
|
||||
DEBUG_FUNCTION_LINE("Print expanded heap infos\n");
|
||||
printMemHeapInfo(expHeapPointer,MAX_EXP_HEAP_INFOS, "Expanded heap:");
|
||||
|
||||
DEBUG_FUNCTION_LINE("Print frmHeap\n");
|
||||
printMemHeapInfo(frmHeapPointer,MAX_FRM_HEAP_INFOS, "Frame heap:");
|
||||
|
||||
DEBUG_FUNCTION_LINE("Print unitHeap\n");
|
||||
for(int i = 0; i<MAX_UNIT_HEAP_INFOS; i++) {
|
||||
if(unitHeapPointer[i].handle != 0) {
|
||||
DEBUG_FUNCTION_LINE("unitHeap: address 0x%08X handle 0x%08X heapSize %07d kb memSize %07d kb align 0x%08X flags 0x%04X\n",unitHeapPointer[i].address,unitHeapPointer[i].handle,unitHeapPointer[i].heapSize/1024,unitHeapPointer[i].memSize/1024,unitHeapPointer[i].align,unitHeapPointer[i].flags);
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("Print set base heap info\n");
|
||||
for(int i = 0; i<MAX_BASE_HEAP_INFOS; i++) {
|
||||
if(baseHeaphandles[i].newHandle != 0) {
|
||||
DEBUG_FUNCTION_LINE("MEMSetBaseHeapHandle was called: oldHandle 0x%08X newHandle 0x%08X arena %d\n",baseHeaphandles[i].oldHandle,baseHeaphandles[i].newHandle,baseHeaphandles[i].memArena);
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Print set block heap info\n");
|
||||
for(int i = 0; i<MAX_BLOCK_HEAP_INFOS; i++) {
|
||||
if(blockHeapInfos[i].startAddress != 0) {
|
||||
DEBUG_FUNCTION_LINE("MEMInitBlockHeap was called: handle 0x%08X tracking 0x%08X\n",blockHeapInfos[i].handle,blockHeapInfos[i].tracking);
|
||||
}
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Print set user heap info\n");
|
||||
printMemHeapInfo(userHeapInfos,MAX_USER_HEAP_INFOS, "User heap:");
|
||||
|
||||
DEBUG_FUNCTION_LINE("Testing malloc\n");
|
||||
u32 size = 0x1000;
|
||||
bool success = false;
|
||||
do {
|
||||
void * result = malloc(size);
|
||||
if(result != NULL) {
|
||||
//DEBUG_FUNCTION_LINE("Allocated %d kb from default heap\n",size/1024);
|
||||
free(result);
|
||||
result = NULL;
|
||||
success = true;
|
||||
} else {
|
||||
//DEBUG_FUNCTION_LINE("Failed to allocate %d kb from default heap\n",size/1024);
|
||||
success = false;
|
||||
}
|
||||
size += 0x1000;
|
||||
} while(success);
|
||||
DEBUG_FUNCTION_LINE("I was able to allocate %07d kb from default heap (alignment 4)\n",size/1024);
|
||||
|
||||
for(int i = 0; i<2; i++) {
|
||||
s32 defaultHeap = MEMGetBaseHeapHandle(i);
|
||||
if(defaultHeap != 0) {
|
||||
u32 start = 0;
|
||||
u32 size_bytes = 0;
|
||||
OSGetMemBound(i+1,&start,&size_bytes);
|
||||
DEBUG_FUNCTION_LINE("Memory Bound MEM%d: startAddress 0x%08X size 0x%08X\n",i+1,start,size_bytes);
|
||||
|
||||
s32 size = MEMGetAllocatableSizeForExpHeapEx(defaultHeap, 4);
|
||||
s32 totalSize = MEMGetTotalFreeSizeForExpHeap(defaultHeap);
|
||||
DEBUG_FUNCTION_LINE("BaseHandle address 0x%08X: MEM%d with %07d kb memory free in one block, %07d kb in total.\n",defaultHeap,i+1,size/1024,totalSize/1024);
|
||||
|
||||
s32 parent = MEMFindParentHeap(defaultHeap);
|
||||
if(parent != 0) {
|
||||
size = MEMGetAllocatableSizeForExpHeapEx(parent, 4);
|
||||
s32 totalSize = MEMGetTotalFreeSizeForExpHeap(parent);
|
||||
DEBUG_FUNCTION_LINE("It's parent heap is 0x%08X: With %07d kb memory free in one block, %07d kb in total.\n",parent,size/1024,totalSize/1024);
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("No parent found =(\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* 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 MAIN_H_
|
||||
#define MAIN_H_
|
||||
|
||||
#include "memory_defs.h"
|
||||
#include "c_retain_vars.h"
|
||||
|
||||
void print_memory_info();
|
||||
|
||||
#endif // MAIN_H_
|
@ -1,64 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* 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_DEFS_H_
|
||||
#define _MEMORY_DEFS_H_
|
||||
|
||||
#include <dynamic_libs/os_types.h>
|
||||
|
||||
#define MAX_USER_HEAP_INFOS 50
|
||||
#define MAX_FRM_HEAP_INFOS 50
|
||||
#define MAX_EXP_HEAP_INFOS 50
|
||||
#define MAX_UNIT_HEAP_INFOS 50
|
||||
#define MAX_ALLOCATOR_EXP_INFOS 50
|
||||
#define MAX_BASE_HEAP_INFOS 50
|
||||
#define MAX_BLOCK_HEAP_INFOS 50
|
||||
|
||||
typedef struct memHeapInfo_ {
|
||||
s32 handle;
|
||||
void * address;
|
||||
u32 size;
|
||||
u32 oldSize;
|
||||
u16 flags;
|
||||
} memHeapInfo;
|
||||
|
||||
typedef struct memUnitHeapInfo_ {
|
||||
s32 handle;
|
||||
void * address;
|
||||
u32 heapSize;
|
||||
u32 memSize;
|
||||
u32 align;
|
||||
u16 flags;
|
||||
} memUnitHeapInfo;
|
||||
|
||||
typedef struct baseHeapInfo_ {
|
||||
s32 oldHandle;
|
||||
s32 newHandle;
|
||||
s32 memArena;
|
||||
} baseHeapInfo;
|
||||
|
||||
typedef struct blockHeapInfo_ {
|
||||
s32 handle;
|
||||
void * tracking;
|
||||
void * startAddress;
|
||||
void * endAddress;
|
||||
void * initTrackMem;
|
||||
u32 initTrackMemBytes;
|
||||
u16 flags;
|
||||
} blockHeapInfo;
|
||||
|
||||
#endif
|
@ -1,244 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <dynamic_libs/os_types.h>
|
||||
#include "memory_defs.h"
|
||||
#include "c_retain_vars.h"
|
||||
|
||||
DECL_FUNCTION(s32, MEMCreateFrmHeapEx, void* address, u32 size, u16 flags) {
|
||||
s32 result = real_MEMCreateFrmHeapEx(address,size,flags);
|
||||
for(int i = 0; i<MAX_FRM_HEAP_INFOS; i++) {
|
||||
if(frmHeapPointer[i].handle == 0) {
|
||||
frmHeapPointer[i].handle = result;
|
||||
frmHeapPointer[i].address = address;
|
||||
frmHeapPointer[i].size = size;
|
||||
frmHeapPointer[i].flags = flags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(s32, MEMCreateUserHeapHandle, void* startAddress, u32 size) {
|
||||
s32 result = real_MEMCreateUserHeapHandle(startAddress,size);
|
||||
for(int i = 0; i<MAX_USER_HEAP_INFOS; i++) {
|
||||
if(userHeapInfos[i].handle == 0) {
|
||||
userHeapInfos[i].handle = result;
|
||||
userHeapInfos[i].address = startAddress;
|
||||
userHeapInfos[i].size = size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(s32, MEMCreateExpHeapEx, void* address, u32 size, u16 flags) {
|
||||
u32 oldSize = size;
|
||||
s32 result = 0;
|
||||
bool allocated = false;
|
||||
|
||||
/*
|
||||
real_MEMCreateExpHeapEx Just accepts ALL sizes... so.. well..
|
||||
if(size > 0x3B600000 && (u32) address < 0x11000000){
|
||||
//We are pretty sure this the MEM2 default heap.
|
||||
//Let's try to increase it's capacity.
|
||||
//u32 maximumSize = 0x50000000 - (u32) address;
|
||||
u32 maximumSize = 0x80000000;
|
||||
//u32 maximumSize = size + 0x500000;
|
||||
maximumSize -= 0x500000; // remove 5MB, just to leave at least _some_ space.
|
||||
|
||||
u32 curSizeTest = maximumSize;
|
||||
|
||||
do{
|
||||
if(curSizeTest < oldSize){
|
||||
break;
|
||||
}
|
||||
result = real_MEMCreateExpHeapEx(address,curSizeTest,flags);
|
||||
if(result == 0){ // On failure:
|
||||
maximumSize -= 0x100000; // reduce by 1MB and try again.
|
||||
}else{
|
||||
allocated = true;
|
||||
break;
|
||||
}
|
||||
}while(!allocated); // Until the allocation was successful, or we are below default size.
|
||||
}*/
|
||||
if(!allocated || result == 0) {
|
||||
result = real_MEMCreateExpHeapEx(address,size,flags);
|
||||
}
|
||||
|
||||
for(int i = 0; i<MAX_EXP_HEAP_INFOS; i++) {
|
||||
if(expHeapPointer[i].handle == 0) {
|
||||
expHeapPointer[i].handle = result;
|
||||
expHeapPointer[i].address = address;
|
||||
expHeapPointer[i].size = size;
|
||||
expHeapPointer[i].oldSize = oldSize;
|
||||
expHeapPointer[i].flags = flags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(s32, MEMCreateUnitHeapEx, void* address, u32 heapSize, u32 memSize, u32 align, u16 flags) {
|
||||
s32 result = real_MEMCreateUnitHeapEx(address,heapSize,memSize,align,flags);
|
||||
|
||||
for(int i = 0; i<MAX_UNIT_HEAP_INFOS; i++) {
|
||||
if(unitHeapPointer[i].handle == 0) {
|
||||
unitHeapPointer[i].handle = result;
|
||||
unitHeapPointer[i].address = address;
|
||||
unitHeapPointer[i].heapSize = heapSize;
|
||||
unitHeapPointer[i].memSize = memSize;
|
||||
unitHeapPointer[i].align = align;
|
||||
unitHeapPointer[i].flags = flags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void *, MEMDestroyExpHeap, s32 heap) {
|
||||
void * result = real_MEMDestroyExpHeap(heap);
|
||||
|
||||
for(int i = 0; i<MAX_EXP_HEAP_INFOS; i++) {
|
||||
if(expHeapPointer[i].handle == heap) {
|
||||
expHeapPointer[i].handle = 0;
|
||||
expHeapPointer[i].address = 0;
|
||||
expHeapPointer[i].size = 0;
|
||||
expHeapPointer[i].flags = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void *, MEMDestroyFrmHeap, s32 heap) {
|
||||
void * result = real_MEMDestroyFrmHeap(heap);
|
||||
|
||||
for(int i = 0; i<MAX_FRM_HEAP_INFOS; i++) {
|
||||
if(frmHeapPointer[i].handle == heap) {
|
||||
frmHeapPointer[i].handle = 0;
|
||||
frmHeapPointer[i].address = 0;
|
||||
frmHeapPointer[i].size = 0;
|
||||
frmHeapPointer[i].flags = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void *, MEMDestroyUnitHeap, s32 heap) {
|
||||
void * result = real_MEMDestroyUnitHeap(heap);
|
||||
|
||||
for(int i = 0; i<MAX_UNIT_HEAP_INFOS; i++) {
|
||||
if(unitHeapPointer[i].handle == heap) {
|
||||
unitHeapPointer[i].handle = 0;
|
||||
unitHeapPointer[i].address = 0;
|
||||
unitHeapPointer[i].heapSize = 0;
|
||||
unitHeapPointer[i].memSize = 0;
|
||||
unitHeapPointer[i].align = 0;
|
||||
unitHeapPointer[i].flags = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(s32, MEMSetBaseHeapHandle, s32 arena, s32 heap) {
|
||||
s32 result = real_MEMSetBaseHeapHandle(arena,heap);
|
||||
for(int i = 0; i<MAX_BASE_HEAP_INFOS; i++) {
|
||||
if(baseHeaphandles[i].newHandle == 0) {
|
||||
baseHeaphandles[i].oldHandle = result;
|
||||
baseHeaphandles[i].newHandle = heap;
|
||||
baseHeaphandles[i].memArena = arena;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(s32, MEMInitBlockHeap,void * tracking, void * startAddress,void * endAddress, void * initTrackMemory, u32 initTrackMemoryBytes, u16 flags) {
|
||||
s32 result = real_MEMInitBlockHeap(tracking,startAddress,endAddress,initTrackMemory,initTrackMemoryBytes,flags);
|
||||
for(int i = 0; i<MAX_BLOCK_HEAP_INFOS; i++) {
|
||||
if(blockHeapInfos[i].startAddress == NULL) {
|
||||
blockHeapInfos[i].handle = result;
|
||||
blockHeapInfos[i].tracking = tracking;
|
||||
blockHeapInfos[i].startAddress = startAddress;
|
||||
blockHeapInfos[i].endAddress = endAddress;
|
||||
blockHeapInfos[i].initTrackMem = initTrackMemory;
|
||||
blockHeapInfos[i].initTrackMemBytes = initTrackMemoryBytes;
|
||||
blockHeapInfos[i].flags = flags;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
WUPS_MUST_REPLACE(MEMInitBlockHeap, WUPS_LOADER_LIBRARY_COREINIT, MEMInitBlockHeap);
|
||||
WUPS_MUST_REPLACE(MEMSetBaseHeapHandle, WUPS_LOADER_LIBRARY_COREINIT, MEMSetBaseHeapHandle);
|
||||
WUPS_MUST_REPLACE(MEMDestroyUnitHeap, WUPS_LOADER_LIBRARY_COREINIT, MEMDestroyUnitHeap);
|
||||
WUPS_MUST_REPLACE(MEMDestroyFrmHeap, WUPS_LOADER_LIBRARY_COREINIT, MEMDestroyFrmHeap);
|
||||
WUPS_MUST_REPLACE(MEMDestroyExpHeap, WUPS_LOADER_LIBRARY_COREINIT, MEMDestroyExpHeap);
|
||||
WUPS_MUST_REPLACE(MEMCreateUnitHeapEx, WUPS_LOADER_LIBRARY_COREINIT, MEMCreateUnitHeapEx);
|
||||
WUPS_MUST_REPLACE(MEMCreateExpHeapEx, WUPS_LOADER_LIBRARY_COREINIT, MEMCreateExpHeapEx);
|
||||
WUPS_MUST_REPLACE(MEMCreateUserHeapHandle, WUPS_LOADER_LIBRARY_COREINIT, MEMCreateUserHeapHandle);
|
||||
WUPS_MUST_REPLACE(MEMCreateFrmHeapEx, WUPS_LOADER_LIBRARY_COREINIT, MEMCreateFrmHeapEx);
|
||||
|
||||
/*
|
||||
Unused stuff that might get useful in the future.
|
||||
|
||||
void * allocateFromExpHeap(s32 * usedHandle, u32 size, u32 align){
|
||||
void * result = NULL;
|
||||
for(int i = 0;i<MAX_EXP_HEAP_INFOS;i++){
|
||||
if(expHeapPointer[i].handle != 0){
|
||||
result = MEMAllocFromExpHeapEx(expHeapPointer[i].handle, size, align);
|
||||
if(result != NULL){
|
||||
*usedHandle = expHeapPointer[i].handle;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void * allocateFromFrmHeap(s32 * usedHandle, u32 size, u32 align){
|
||||
void * result = NULL;
|
||||
for(int i = 0;i<MAX_FRM_HEAP_INFOS;i++){
|
||||
if(frmHeapPointer[i].handle != 0){
|
||||
result = MEMAllocFromFrmHeapEx(frmHeapPointer[i].handle, size, align);
|
||||
if(result != NULL){
|
||||
*usedHandle = frmHeapPointer[i].handle;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void freeToExpHeap(s32 usedHandle, void * addr){
|
||||
MEMFreeToExpHeap(usedHandle, addr);
|
||||
}
|
||||
allocatorExpInfo allocatorExpPointer[MAX_ALLOCATOR_EXP_INFOS] __attribute__((section(".data")));
|
||||
|
||||
typedef struct allocatorExpInfo_{
|
||||
void * allocator;
|
||||
s32 heap;
|
||||
s32 align;
|
||||
} allocatorExpInfo;
|
||||
|
||||
DECL(void , MEMInitAllocatorForExpHeap, void* allocator, s32 heap, s32 align){
|
||||
for(int i = 0;i<MAX_ALLOCATOR_EXP_INFOS;i++){
|
||||
if(allocatorExpPointer[i].allocator == 0){
|
||||
allocatorExpPointer[i].allocator = (void*)allocator;
|
||||
allocatorExpPointer[i].heap = heap;
|
||||
allocatorExpPointer[i].align = align;
|
||||
break;
|
||||
}
|
||||
}
|
||||
real_MEMInitAllocatorForExpHeap(allocator,heap,align);
|
||||
return;
|
||||
}
|
||||
*/
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,58 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lutils -ldynamiclibs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
@ -1,14 +0,0 @@
|
||||
#include <wups.h>
|
||||
|
||||
WUPS_PLUGIN_NAME("NNU Patcher");
|
||||
WUPS_PLUGIN_DESCRIPTION("Enables eshop access on lower firmware versions.");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("BSD");
|
||||
|
||||
DECL_FUNCTION(int, NeedsNetworkUpdate__Q2_2nn3nimFPb, bool * result){
|
||||
*result = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
WUPS_MUST_REPLACE(NeedsNetworkUpdate__Q2_2nn3nimFPb,WUPS_LOADER_LIBRARY_NN_NIM, NeedsNetworkUpdate__Q2_2nn3nimFPb);
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,58 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lutils -ldynamiclibs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
@ -1,61 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* 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 <wups.h>
|
||||
#include "main.h"
|
||||
#include <utils/logger.h>
|
||||
#include <utils/StringTools.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
|
||||
void SplashScreen_callback(wups_overlay_options_type_t screen){
|
||||
s32 i=0;
|
||||
|
||||
while(i<100){
|
||||
WUPS_Overlay_OSScreenClear(screen);
|
||||
|
||||
WUPS_Overlay_PrintTextOnScreen(screen, 0,0,"This could be something cool.");
|
||||
WUPS_Overlay_PrintTextOnScreen(screen, 0,5,"Testing changing text: %d",i);
|
||||
|
||||
WUPS_Overlay_FlipBuffers(screen);
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
u8 gCallbackCooldown __attribute__((section(".data"))) = 0;
|
||||
|
||||
DECL_FUNCTION(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) {
|
||||
int result = real_VPADRead(chan, buffer, buffer_size, error);
|
||||
u32 btns = VPAD_BUTTON_Y | VPAD_BUTTON_X | VPAD_BUTTON_A | VPAD_BUTTON_B;
|
||||
if(result > 0 && ((buffer[0].btns_h & (btns)) == btns) && gCallbackCooldown == 0 ){
|
||||
gCallbackCooldown = 0x3C;
|
||||
|
||||
//WUPS_OpenOverlay(WUPS_OVERLAY_DRC_ONLY ,SplashScreen_callback);
|
||||
//WUPS_OpenOverlay(WUPS_OVERLAY_DRC_ONLY ,SplashScreen_callback);
|
||||
//WUPS_OpenOverlay(WUPS_OVERLAY_TV_ONLY ,SplashScreen_callback);
|
||||
WUPS_OpenOverlay(WUPS_OVERLAY_DRC_AND_TV ,SplashScreen_callback);
|
||||
//WUPS_OpenOverlay(WUPS_OVERLAY_DRC_AND_TV_WITH_DRC_PRIO ,SplashScreen_callback);
|
||||
}
|
||||
if(gCallbackCooldown > 0){
|
||||
gCallbackCooldown--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
WUPS_MUST_REPLACE(VPADRead, WUPS_LOADER_LIBRARY_VPAD, VPADRead);
|
@ -1,57 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* 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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <wups.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/fs_functions.h>
|
||||
#include <dynamic_libs/gx2_functions.h>
|
||||
#include <dynamic_libs/gx2_types.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <utils/logger.h>
|
||||
#include "main.h"
|
||||
|
||||
WUPS_PLUGIN_NAME("Overlay test");
|
||||
WUPS_PLUGIN_DESCRIPTION("Just an overlay test. Press A,B,X and Y and a text should appear.");
|
||||
WUPS_PLUGIN_VERSION("v0.1");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("GPL");
|
||||
|
||||
/*
|
||||
To be able to create overlays
|
||||
*/
|
||||
WUPS_ALLOW_OVERLAY()
|
||||
|
||||
/* Entry point */
|
||||
ON_APPLICATION_START(args){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers(); //For logging
|
||||
InitVPadFunctionPointers();
|
||||
InitFSFunctionPointers();
|
||||
|
||||
InitGX2FunctionPointers();
|
||||
|
||||
log_init();
|
||||
|
||||
DEBUG_FUNCTION_LINE("OVERLAYTEST INIT DONE.\n");
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
*
|
||||
* 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 _MAIN_H_
|
||||
#define _MAIN_H_
|
||||
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/os_types.h>
|
||||
|
||||
/* Main */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,11 +0,0 @@
|
||||
# Padcon Plugin for the Wii U Plugin System
|
||||
|
||||
## Building
|
||||
|
||||
For building you need:
|
||||
- [wups](https://github.com/Maschell/WiiUPluginSystem)
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
@ -1,59 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lutils -ldynamiclibs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
@ -1,39 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <string.h>
|
||||
#include "dynamic_libs/os_functions.h"
|
||||
#include "dynamic_libs/vpad_functions.h"
|
||||
#include "dynamic_libs/socket_functions.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
WUPS_PLUGIN_NAME("Padcon");
|
||||
WUPS_PLUGIN_DESCRIPTION("Turns the gamepad screen on/off when pressing the right stick.");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("GPL");
|
||||
|
||||
ON_APPLICATION_START(args){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
|
||||
log_init();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Init of padcon!\n");
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) {
|
||||
int result = real_VPADRead(chan, buffer, buffer_size, error);
|
||||
if(buffer->btns_r&VPAD_BUTTON_STICK_R) {
|
||||
int mode;
|
||||
VPADGetLcdMode(0, (s32*)&mode); // Get current display mode
|
||||
if(mode != 1) {
|
||||
VPADSetLcdMode(0, 1); // Turn it off
|
||||
}
|
||||
else {
|
||||
VPADSetLcdMode(0, 0xFF); // Turn it on
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
WUPS_MUST_REPLACE(VPADRead ,WUPS_LOADER_LIBRARY_VPAD, VPADRead);
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,20 +0,0 @@
|
||||
# Screenshot tool
|
||||
|
||||
This is just a simple plugin that takes screenshot of the TV and DRC screen. The screenshot will saved on the sd card.
|
||||
|
||||
## Building
|
||||
|
||||
For building you need:
|
||||
- [wups](https://github.com/Maschell/WiiUPluginSystem)
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
||||
|
||||
You also need some other, external libraries.
|
||||
|
||||
All needed dependencies are in the "libs" folder of this plugin. Extract the "portlibs.zip" archive into your devkitPro directory.
|
||||
The archive includes:
|
||||
|
||||
- gd
|
||||
- libjpeg
|
Binary file not shown.
@ -1,58 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lutils -ldynamiclibs -lgd -ljpeg
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
@ -1,6 +0,0 @@
|
||||
#ifndef COMMON_H_
|
||||
#define COMMON_H_
|
||||
|
||||
#define WIIU_SCREENSHOT_PATH "sd:/wiiu/screenshots/"
|
||||
|
||||
#endif // COMMON_H_
|
@ -1,63 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <utils/logger.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/os_types.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/gx2_functions.h>
|
||||
#include <utils/StringTools.h>
|
||||
#include <fs/FSUtils.h>
|
||||
#include "common.h"
|
||||
#include "function_patcher.h"
|
||||
#include "screenshot_utils.h"
|
||||
#include "retain_vars.hpp"
|
||||
|
||||
static bool takeScreenshotTV __attribute__((section(".data"))) = false;
|
||||
static bool takeScreenshotDRC __attribute__((section(".data"))) = false;
|
||||
static u8 screenshotCooldown __attribute__((section(".data"))) = 0;
|
||||
static u32 counter __attribute__((section(".data"))) = 0;
|
||||
|
||||
DECL_FUNCTION(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) {
|
||||
int result = real_VPADRead(chan, buffer, buffer_size, error);
|
||||
|
||||
if(result > 0 && (buffer[0].btns_h == gButtonCombo) && screenshotCooldown == 0 && OSIsHomeButtonMenuEnabled()) {
|
||||
counter++;
|
||||
takeScreenshotTV = true;
|
||||
takeScreenshotDRC = true;
|
||||
|
||||
screenshotCooldown = 0x3C;
|
||||
}
|
||||
if(screenshotCooldown > 0) {
|
||||
screenshotCooldown--;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, GX2CopyColorBufferToScanBuffer, const GX2ColorBuffer *colorBuffer, s32 scan_target) {
|
||||
if((takeScreenshotTV || takeScreenshotDRC) && gAppStatus == WUPS_APP_STATUS_FOREGROUND) {
|
||||
OSCalendarTime output;
|
||||
OSTicksToCalendarTime(OSGetTime(), &output);
|
||||
char buffer[255] = {0};
|
||||
snprintf(buffer,254,"%s%04i-%02i-%02i/",WIIU_SCREENSHOT_PATH,output.year,output.mon,output.mday);
|
||||
|
||||
FSUtils::CreateSubfolder(buffer);
|
||||
|
||||
snprintf(buffer,254,"%s%04i-%02i-%02i/%04i-%02i-%02i_%02i.%02i.%02i_",
|
||||
WIIU_SCREENSHOT_PATH,output.year,output.mon,output.mday,output.year,output.mon,output.mday,output.hour,output.min,output.sec);
|
||||
|
||||
if(scan_target == 1 && colorBuffer != NULL && takeScreenshotTV && gAppStatus == WUPS_APP_STATUS_FOREGROUND) {
|
||||
DEBUG_FUNCTION_LINE("Lets take a screenshot from TV. Source format: %d \n",colorBuffer->surface.format);
|
||||
takeScreenshot((GX2ColorBuffer *)colorBuffer, StringTools::strfmt("%sTV.jpg",buffer).c_str());
|
||||
takeScreenshotTV = false;
|
||||
}
|
||||
if(scan_target == 4 && colorBuffer != NULL && takeScreenshotDRC && gAppStatus == WUPS_APP_STATUS_FOREGROUND) {
|
||||
DEBUG_FUNCTION_LINE("Lets take a screenshot from DRC. Source format: %d \n",colorBuffer->surface.format);
|
||||
takeScreenshot((GX2ColorBuffer *)colorBuffer, StringTools::strfmt("%sDRC.jpg",buffer).c_str());
|
||||
takeScreenshotDRC = false;
|
||||
}
|
||||
}
|
||||
real_GX2CopyColorBufferToScanBuffer(colorBuffer,scan_target);
|
||||
}
|
||||
|
||||
WUPS_MUST_REPLACE(VPADRead, WUPS_LOADER_LIBRARY_VPAD, VPADRead);
|
||||
WUPS_MUST_REPLACE(GX2CopyColorBufferToScanBuffer, WUPS_LOADER_LIBRARY_GX2, GX2CopyColorBufferToScanBuffer);
|
@ -1,160 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <malloc.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <dynamic_libs/fs_functions.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/gx2_functions.h>
|
||||
#include <utils/logger.h>
|
||||
#include "retain_vars.hpp"
|
||||
|
||||
// Mandatory plugin information.
|
||||
WUPS_PLUGIN_NAME("Screenshot tool");
|
||||
WUPS_PLUGIN_DESCRIPTION("This plugin allows you to make screenshots that will be saved to the sd card");
|
||||
WUPS_PLUGIN_VERSION("v0.1");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("GPL");
|
||||
|
||||
// FS Access
|
||||
WUPS_FS_ACCESS()
|
||||
|
||||
u32 SplashScreen(s32 time,s32 combotime);
|
||||
|
||||
// Gets called once the loader exists.
|
||||
INITIALIZE_PLUGIN() {
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
InitGX2FunctionPointers();
|
||||
|
||||
log_init();
|
||||
|
||||
InitOSFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
u32 res = SplashScreen(10,2);
|
||||
|
||||
gButtonCombo = res;
|
||||
ICInvalidateRange((void*)(&gButtonCombo), 4);
|
||||
DCFlushRange((void*)(&gButtonCombo), 4);
|
||||
}
|
||||
|
||||
// Called whenever an application was started.
|
||||
ON_APPLICATION_START(my_args) {
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers();
|
||||
InitFSFunctionPointers();
|
||||
|
||||
gAppStatus = WUPS_APP_STATUS_FOREGROUND;
|
||||
|
||||
log_init();
|
||||
}
|
||||
|
||||
ON_APP_STATUS_CHANGED(status) {
|
||||
gAppStatus = status;
|
||||
}
|
||||
|
||||
|
||||
#define FPS 60
|
||||
u32 SplashScreen(s32 time,s32 combotime) {
|
||||
u32 result = VPAD_BUTTON_R | VPAD_BUTTON_L | VPAD_BUTTON_ZR | VPAD_BUTTON_ZL;
|
||||
|
||||
// Init screen
|
||||
OSScreenInit();
|
||||
|
||||
u32 screen_buf0_size = OSScreenGetBufferSizeEx(0);
|
||||
u32 screen_buf1_size = OSScreenGetBufferSizeEx(1);
|
||||
|
||||
u32 * screenbuffer0 = (u32*)memalign(0x100, screen_buf0_size);
|
||||
u32 * screenbuffer1 = (u32*)memalign(0x100, screen_buf1_size);
|
||||
|
||||
if(screenbuffer0 == NULL || screenbuffer1 == NULL) {
|
||||
if(screenbuffer0 != NULL) {
|
||||
free(screenbuffer0);
|
||||
}
|
||||
if(screenbuffer1 != NULL) {
|
||||
free(screenbuffer1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
OSScreenSetBufferEx(0, (void *)screenbuffer0);
|
||||
OSScreenSetBufferEx(1, (void *)screenbuffer1);
|
||||
|
||||
OSScreenEnableEx(0, 1);
|
||||
OSScreenEnableEx(1, 1);
|
||||
|
||||
// Clear screens
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
|
||||
// Flip buffers
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back("Screenshot tool 0.1 - by Maschell.");
|
||||
strings.push_back("");
|
||||
strings.push_back("");
|
||||
strings.push_back("Press the combo you want to use for making screenshots now");
|
||||
strings.push_back("for 2 seconds.");
|
||||
strings.push_back(" ");
|
||||
strings.push_back("Otherwise the default combo (L+R+ZR+ZL button) will be used");
|
||||
strings.push_back("in 10 seconds.");
|
||||
strings.push_back(" ");
|
||||
strings.push_back("Press the TV buttons to exit with the default combo.");
|
||||
|
||||
u8 pos = 0;
|
||||
for (std::vector<std::string>::iterator it = strings.begin() ; it != strings.end(); ++it) {
|
||||
OSScreenPutFontEx(0, 0, pos, (*it).c_str());
|
||||
OSScreenPutFontEx(1, 0, pos, (*it).c_str());
|
||||
pos++;
|
||||
}
|
||||
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
s32 tickswait = time * FPS * 16;
|
||||
|
||||
s32 sleepingtime = 16;
|
||||
s32 times = tickswait/16;
|
||||
s32 i=0;
|
||||
|
||||
VPADData vpad_data;
|
||||
s32 error;
|
||||
u32 last = 0xFFFFFFFF;
|
||||
s32 timer = 0;
|
||||
while(i<times) {
|
||||
VPADRead(0, &vpad_data, 1, &error);
|
||||
if(vpad_data.btns_h == VPAD_BUTTON_TV) {
|
||||
break;
|
||||
}
|
||||
if(last == vpad_data.btns_h && last != 0) {
|
||||
timer++;
|
||||
} else {
|
||||
last = vpad_data.btns_h;
|
||||
timer = 0;
|
||||
}
|
||||
if(timer >= combotime*FPS) {
|
||||
result = vpad_data.btns_h;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
os_usleep(sleepingtime*1000);
|
||||
}
|
||||
|
||||
if(screenbuffer0 != NULL) {
|
||||
free(screenbuffer0);
|
||||
}
|
||||
if(screenbuffer1 != NULL) {
|
||||
free(screenbuffer1);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
#include "retain_vars.hpp"
|
||||
wups_loader_app_status_t gAppStatus __attribute__((section(".data"))) = WUPS_APP_STATUS_UNKNOWN;
|
||||
u32 gButtonCombo __attribute__((section(".data"))) = 0;
|
@ -1,10 +0,0 @@
|
||||
#ifndef _RETAINS_VARS_H_
|
||||
#define _RETAINS_VARS_H_
|
||||
|
||||
#include <wups.h>
|
||||
#include <dynamic_libs/os_types.h>
|
||||
|
||||
extern wups_loader_app_status_t gAppStatus;
|
||||
extern u32 gButtonCombo;
|
||||
|
||||
#endif // _RETAINS_VARS_H_
|
@ -1,224 +0,0 @@
|
||||
#include "screenshot_utils.h"
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <fs/FSUtils.h>
|
||||
#include <malloc.h>
|
||||
|
||||
bool UnormR8G8B8A8TogdImage(gdImagePtr *gdImgTmp, void *image_data, u32 width, u32 rows, u32 pitch) {
|
||||
*gdImgTmp = gdImageCreateTrueColor(width , rows );
|
||||
if(*gdImgTmp != NULL){
|
||||
R8G8B8A8_COLOR *buffer = (R8G8B8A8_COLOR *) image_data;
|
||||
R8G8B8A8_COLOR val;
|
||||
for (u32 row = 0; row < rows; ++row) {
|
||||
for (u32 x = 0; x < width; ++x) {
|
||||
val = buffer[row * pitch + x];
|
||||
gdImageSetPixel(*gdImgTmp, x , row , gdTrueColor(val.R, val.G, val.B));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool saveAsJPEG(const char * path, u8 * sourceBuffer, u32 width, u32 height, u32 pitch, u32 format) {
|
||||
if(path == NULL || sourceBuffer == NULL) {
|
||||
DEBUG_FUNCTION_LINE("path or buffer NULL\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(( format != GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB &&
|
||||
format != GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM)) {
|
||||
DEBUG_FUNCTION_LINE("Format not supported\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
gdImagePtr gdImagePtr = 0;
|
||||
bool result = false;
|
||||
|
||||
if(!UnormR8G8B8A8TogdImage(&gdImagePtr, sourceBuffer, width, height, pitch)){
|
||||
DEBUG_FUNCTION_LINE("Setting up the GD buffer failed\n");
|
||||
if(gdImagePtr != NULL){
|
||||
gdImageDestroy(gdImagePtr);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int imd_size = 0;
|
||||
void *data = gdImageJpegPtr(gdImagePtr, &imd_size, 95);
|
||||
if (data) {
|
||||
DEBUG_FUNCTION_LINE("Encoded file as JPEG. size = %d.\n",imd_size);
|
||||
DCFlushRange(data,imd_size);
|
||||
//FSUtils::CreateSubfolder("sd:/screenshots);
|
||||
result = FSUtils::saveBufferToFile(path,data,imd_size);
|
||||
if(!result){
|
||||
DEBUG_FUNCTION_LINE("Failed to save buffer to %s \n",path);
|
||||
}
|
||||
}
|
||||
gdFree(data);
|
||||
gdImageDestroy(gdImagePtr);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool copyBuffer(GX2ColorBuffer * sourceBuffer, GX2ColorBuffer * targetBuffer, u32 targetWidth, u32 targetHeight) {
|
||||
// Making sure the buffers are not NULL
|
||||
if (sourceBuffer != NULL && targetBuffer != NULL) {
|
||||
GX2InitColorBuffer(targetBuffer, GX2_SURFACE_DIM_2D, targetWidth, targetHeight, 1, GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM, GX2_AA_MODE_1X);
|
||||
|
||||
// We need to override some values.
|
||||
targetBuffer->surface.tile = GX2_TILE_MODE_LINEAR_ALIGNED;
|
||||
targetBuffer->surface.use = GX2_SURFACE_USE_COLOR_BUFFER_TEXTURE;
|
||||
targetBuffer->view_mip = 0;
|
||||
targetBuffer->view_first_slice = 0;
|
||||
targetBuffer->view_slices_count = 1;
|
||||
GX2CalcSurfaceSizeAndAlignment(&targetBuffer->surface);
|
||||
GX2InitColorBufferRegs(targetBuffer);
|
||||
|
||||
// Let's allocate the memory.
|
||||
targetBuffer->surface.image_data = memalign(targetBuffer->surface.align,targetBuffer->surface.image_size);
|
||||
if(targetBuffer->surface.image_data == NULL) {
|
||||
DEBUG_FUNCTION_LINE("failed to allocate memory.\n");
|
||||
return false;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Allocated image data buffer. data %08X size %08X \n",targetBuffer->surface.image_data,targetBuffer->surface.image_size);
|
||||
|
||||
GX2Invalidate(GX2_INVALIDATE_CPU, targetBuffer->surface.image_data, targetBuffer->surface.image_size);
|
||||
if (sourceBuffer->surface.aa == GX2_AA_MODE_1X) {
|
||||
// If AA is disabled, we can simply use GX2CopySurface.
|
||||
GX2CopySurface(&sourceBuffer->surface,
|
||||
sourceBuffer->view_mip,
|
||||
sourceBuffer->view_first_slice,
|
||||
&targetBuffer->surface, 0, 0);
|
||||
} else {
|
||||
// If AA is enabled, we need to resolve the AA buffer.
|
||||
GX2Surface tempSurface;
|
||||
tempSurface = sourceBuffer->surface;
|
||||
tempSurface.aa = GX2_AA_MODE_1X;
|
||||
GX2CalcSurfaceSizeAndAlignment(&tempSurface);
|
||||
|
||||
tempSurface.image_data = memalign(tempSurface.align,tempSurface.image_size);
|
||||
if(tempSurface.image_data == NULL) {
|
||||
DEBUG_FUNCTION_LINE("failed to allocate data AA.\n");
|
||||
if(targetBuffer->surface.image_data != NULL) {
|
||||
free(targetBuffer->surface.image_data);
|
||||
targetBuffer->surface.image_data = NULL;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
GX2ResolveAAColorBuffer(sourceBuffer,&tempSurface, 0, 0);
|
||||
GX2CopySurface(&tempSurface, 0, 0,&targetBuffer->surface, 0, 0);
|
||||
|
||||
// Sync CPU and GPU
|
||||
GX2DrawDone();
|
||||
|
||||
if(tempSurface.image_data != NULL) {
|
||||
free(tempSurface.image_data);
|
||||
tempSurface.image_data = NULL;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
DEBUG_FUNCTION_LINE("Couldn't copy buffer, pointer was NULL\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool takeScreenshot(GX2ColorBuffer *srcBuffer,const char * path) {
|
||||
if(srcBuffer == NULL) {
|
||||
return false;
|
||||
}
|
||||
DEBUG_FUNCTION_LINE("Taking screenshot. %s\n",path);
|
||||
|
||||
GX2ColorBuffer colorBuffer;
|
||||
GX2ColorBuffer * saveBuffer = NULL;
|
||||
|
||||
// keep dimensions
|
||||
u32 width = srcBuffer->surface.width;
|
||||
u32 height = srcBuffer->surface.height;
|
||||
|
||||
bool valid = false;
|
||||
bool cancel = false;
|
||||
bool low_memory = false;
|
||||
do {
|
||||
// At first we need to copy the buffer to fit our resolution.
|
||||
if(saveBuffer == NULL) {
|
||||
do {
|
||||
valid = copyBuffer(srcBuffer,&colorBuffer,width,height);
|
||||
// If the copying failed, we don't have enough memory. Let's decrease the resolution.
|
||||
if(!valid) {
|
||||
low_memory = true;
|
||||
|
||||
if(height >= 1080) {
|
||||
width = 1280;
|
||||
height = 720;
|
||||
DEBUG_FUNCTION_LINE("Switching to 720p.\n");
|
||||
} else if(height >= 720) {
|
||||
width = 854;
|
||||
height = 480;
|
||||
DEBUG_FUNCTION_LINE("Switching to 480p.\n");
|
||||
} else if(height >= 480) {
|
||||
width = 640;
|
||||
height = 360;
|
||||
DEBUG_FUNCTION_LINE("Switching to 360p.\n");
|
||||
} else {
|
||||
// Cancel the screenshot if the resolution would be too low.
|
||||
cancel = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// On success save the pointer.
|
||||
saveBuffer = &colorBuffer;
|
||||
}
|
||||
} while(!valid);
|
||||
}
|
||||
|
||||
// Check if we should proceed
|
||||
if(cancel) {
|
||||
// Free the memory on error.
|
||||
if(colorBuffer.surface.image_data != NULL) {
|
||||
free(colorBuffer.surface.image_data);
|
||||
colorBuffer.surface.image_data = NULL;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Flush out destinations caches
|
||||
GX2Invalidate(GX2_INVALIDATE_COLOR_BUFFER, colorBuffer.surface.image_data,colorBuffer.surface.image_size);
|
||||
|
||||
// Wait for GPU to finish
|
||||
GX2DrawDone();
|
||||
|
||||
DEBUG_FUNCTION_LINE("Trying to save.\n");
|
||||
|
||||
// Trying to save as JPEG.
|
||||
valid = saveAsJPEG(path,(u8*) saveBuffer->surface.image_data,width,height,saveBuffer->surface.pitch,saveBuffer->surface.format);
|
||||
|
||||
// Free the colorbuffer copy.
|
||||
if(colorBuffer.surface.image_data != NULL) {
|
||||
free(colorBuffer.surface.image_data);
|
||||
colorBuffer.surface.image_data = NULL;
|
||||
saveBuffer = NULL;
|
||||
}
|
||||
|
||||
// When taking the screenshot failed, decrease the resolution again ~.
|
||||
if(!valid) {
|
||||
low_memory = true;
|
||||
if(height >= 1080) {
|
||||
width = 1280;
|
||||
height = 720;
|
||||
DEBUG_FUNCTION_LINE("Switching to 720p.\n");
|
||||
} else if(height >= 720) {
|
||||
width = 854;
|
||||
height = 480;
|
||||
DEBUG_FUNCTION_LINE("Switching to 480p.\n");
|
||||
} else if(height >= 480) {
|
||||
width = 640;
|
||||
height = 360;
|
||||
DEBUG_FUNCTION_LINE("Switching to 360p.\n");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} while(!valid);
|
||||
|
||||
return true;
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
#ifndef _SCREENSHOT_UTILS_H_
|
||||
#define _SCREENSHOT_UTILS_H_
|
||||
|
||||
#include <dynamic_libs/gx2_functions.h>
|
||||
#include <gd.h>
|
||||
#include <utils/logger.h>
|
||||
|
||||
typedef struct _R8G8B8A8_COLOR {
|
||||
u8 R, G, B, A;
|
||||
} R8G8B8A8_COLOR;
|
||||
|
||||
bool UnormR8G8B8A8TogdImage(gdImagePtr *gdImgTmp, void *image_data, u32 width, u32 rows, u32 pitch);
|
||||
|
||||
bool saveAsJPEG(const char * path, u8 * sourceBuffer, u32 width, u32 height, u32 pitch, u32 format);
|
||||
|
||||
bool copyBuffer(GX2ColorBuffer * sourceBuffer, GX2ColorBuffer * targetBuffer, u32 targetWidth, u32 targetHeight);
|
||||
|
||||
bool takeScreenshot(GX2ColorBuffer *srcBuffer,const char * path);
|
||||
|
||||
#endif
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,23 +0,0 @@
|
||||
# SDCafiine Plugin for the Wii U Plugin System
|
||||
|
||||
See https://github.com/Maschell/SDCafiine for more information.
|
||||
|
||||
# Currently supported
|
||||
|
||||
- Modpack selector
|
||||
- FAT32 support for SD and USB
|
||||
|
||||
Whats NOT working:
|
||||
|
||||
- NTFS support
|
||||
|
||||
## Building
|
||||
|
||||
For building you need:
|
||||
- [wups](https://github.com/Maschell/WiiUPluginSystem)
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
- [libfswrapper](https://github.com/Maschell/fs_wrapper) to replace the fs functions.
|
||||
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
@ -1,61 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src \
|
||||
src/common \
|
||||
src/myfs
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS := -D_GNU_SOURCE
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lfswrapper -lutils -ldynamiclibs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils \
|
||||
-I$(PORTLIBS)/include/libfswrapper
|
@ -1,59 +0,0 @@
|
||||
#ifndef COMMON_H
|
||||
#define COMMON_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <dynamic_libs/os_defs.h>
|
||||
|
||||
#define CAFE_OS_SD_PATH "/vol/external01"
|
||||
#define GAME_MOD_FOLDER "/sdcafiine"
|
||||
#define SD_PATH "sd:"
|
||||
#define USB_PATH "usb:"
|
||||
#define DEFAULT_NAME_PACKAGE "DEFAULT"
|
||||
#define NAME_PREFIX_SD "sd: "
|
||||
#define NAME_PREFIX_USB "usb:"
|
||||
#define WIIU_PATH "/wiiu"
|
||||
#define IP_TXT "ip.txt"
|
||||
|
||||
#define CONTENT_FOLDER "content"
|
||||
#define AOC_FOLDER "aoc"
|
||||
#define META_FOLDER "meta"
|
||||
|
||||
#define BOOT_TV_TEX_TGA "bootTvTex.tga"
|
||||
#define BOOT_DRC_TEX_TGA "bootDrcTex.tga"
|
||||
#define BOOT_SOUND_BTSND "bootSound.btsnd"
|
||||
|
||||
#define GAME_PATH_TYPE_CONTENT 1
|
||||
#define GAME_PATH_TYPE_AOC 2
|
||||
#define GAME_PATH_TYPE_STRIPPED_CONTENT 3
|
||||
|
||||
#define SDUSB_MOUNTED_NONE 0
|
||||
#define SDUSB_MOUNTED_FAKE (1<<0)
|
||||
#define SDUSB_MOUNTED_OS_SD (1<<1)
|
||||
#define SDUSB_LIBIOSU_LOADED (1<<2)
|
||||
#define SD_MOUNTED_LIBFAT (1<<3)
|
||||
#define USB_MOUNTED_LIBFAT (1<<4)
|
||||
#define USB_MOUNTED_LIBNTFS (1<<5)
|
||||
|
||||
#define FILELIST_NAME "filelist.txt"
|
||||
#define DIR_IDENTIFY "?" /* maximum length = 1*/
|
||||
#define PARENT_DIR_IDENTIFY "?.."
|
||||
|
||||
#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))
|
||||
|
||||
#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 */
|
||||
|
@ -1,9 +0,0 @@
|
||||
#include "retain_vars.h"
|
||||
|
||||
u8 gAppStatus __attribute__((section(".data"))) = 0;
|
||||
|
||||
volatile bool gSDInitDone __attribute__((section(".data"))) = false;
|
||||
volatile bool gUSBInitDone __attribute__((section(".data"))) = false;
|
||||
|
||||
char gModFolder[FS_MAX_ENTNAME_SIZE] __attribute__((section(".data")));
|
||||
//char gLastMetaPath[FS_MAX_ENTNAME_SIZE] __attribute__((section(".data")));
|
@ -1,15 +0,0 @@
|
||||
#ifndef RETAINS_VARS_H_
|
||||
#define RETAINS_VARS_H_
|
||||
#include <dynamic_libs/fs_defs.h>
|
||||
#include <dynamic_libs/os_types.h>
|
||||
|
||||
#define ASYNC_RESULT_CACHE_SIZE 50
|
||||
#define FS_QUEUE_MESSAGE_COUNT 5
|
||||
|
||||
extern u8 gAppStatus;
|
||||
extern volatile bool gSDInitDone;
|
||||
extern volatile bool gUSBInitDone;
|
||||
|
||||
extern char gModFolder[FS_MAX_ENTNAME_SIZE];
|
||||
|
||||
#endif // RETAINS_VARS_H_
|
@ -1,129 +0,0 @@
|
||||
#include <utils/logger.h>
|
||||
#include "controllers.h"
|
||||
|
||||
VPADData vpad;
|
||||
s32 vpadError;
|
||||
|
||||
KPADData pads[4];
|
||||
s32 padErrors[4];
|
||||
u32 padTypes[4];
|
||||
|
||||
void initControllers() {
|
||||
KPADInit();
|
||||
}
|
||||
|
||||
void releaseControllers() {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
padErrors[i] = WPADProbe(i, &padTypes[i]);
|
||||
if(padErrors[i] == 0) {
|
||||
WPADDisconnect(i);
|
||||
}
|
||||
}
|
||||
|
||||
//Clear buffers so future launches of SDCafiine don't read old data
|
||||
memset(&vpad, 0, sizeof(VPADData));
|
||||
vpadError = 0;
|
||||
|
||||
memset(pads, 0, sizeof(KPADData) * 4);
|
||||
memset(padErrors, 0, sizeof(s32) * 4);
|
||||
memset(padTypes, 0, sizeof(u32) * 4);
|
||||
}
|
||||
|
||||
void pollControllers() {
|
||||
VPADRead(0, &vpad, 1, &vpadError);
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
padErrors[i] = WPADProbe(i, &padTypes[i]);
|
||||
if(padErrors[i] == 0) {
|
||||
KPADRead(i, &pads[i], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isButtonPressed(enum PadButton btn) {
|
||||
if(vpadError == 0) {
|
||||
switch (btn) {
|
||||
case PAD_BTN_A:
|
||||
if (vpad.btns_d & VPAD_BUTTON_A) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_UP:
|
||||
if (vpad.btns_d & VPAD_BUTTON_UP) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_DOWN:
|
||||
if (vpad.btns_d & VPAD_BUTTON_DOWN) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_L:
|
||||
if (vpad.btns_d & VPAD_BUTTON_L) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_R:
|
||||
if (vpad.btns_d & VPAD_BUTTON_R) return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < 4; i++) {
|
||||
if(padErrors[i] == 0) {
|
||||
if(pads[i].device_type < 2) {
|
||||
switch(btn) {
|
||||
case PAD_BTN_A:
|
||||
if (pads[i].btns_d & WPAD_BUTTON_A) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_UP:
|
||||
if (pads[i].btns_d & WPAD_BUTTON_UP) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_DOWN:
|
||||
if (pads[i].btns_d & WPAD_BUTTON_DOWN) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_L:
|
||||
if (pads[i].btns_d & WPAD_BUTTON_1) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_R:
|
||||
if (pads[i].btns_d & WPAD_BUTTON_2) return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch(btn) {
|
||||
case PAD_BTN_A:
|
||||
if (pads[i].classic.btns_d & WPAD_CLASSIC_BUTTON_A) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_UP:
|
||||
if (pads[i].classic.btns_d & WPAD_CLASSIC_BUTTON_UP) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_DOWN:
|
||||
if (pads[i].classic.btns_d & WPAD_CLASSIC_BUTTON_DOWN) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_L:
|
||||
if (pads[i].classic.btns_d & WPAD_CLASSIC_BUTTON_L) return true;
|
||||
break;
|
||||
|
||||
case PAD_BTN_R:
|
||||
if (pads[i].classic.btns_d & WPAD_CLASSIC_BUTTON_R) return true;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/padscore_functions.h>
|
||||
|
||||
enum PadButton {
|
||||
PAD_BTN_A,
|
||||
PAD_BTN_UP,
|
||||
PAD_BTN_DOWN,
|
||||
PAD_BTN_L,
|
||||
PAD_BTN_R
|
||||
};
|
||||
|
||||
void initControllers();
|
||||
void releaseControllers();
|
||||
void pollControllers();
|
||||
bool isButtonPressed(enum PadButton btn);
|
@ -1,56 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <string.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/padscore_functions.h>
|
||||
#include <dynamic_libs/sys_functions.h>
|
||||
#include <dynamic_libs/fs_functions.h>
|
||||
#include <dynamic_libs/proc_ui_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <utils/logger.h>
|
||||
#include "common/retain_vars.h"
|
||||
#include <fswrapper/fs_retain_vars.h>
|
||||
#include <fswrapper/FileReplacerUtils.h>
|
||||
#include "common/common.h"
|
||||
#include "main.h"
|
||||
#include "modpackSelector.h"
|
||||
|
||||
WUPS_PLUGIN_NAME("SDCaffiine");
|
||||
WUPS_PLUGIN_DESCRIPTION("Replaces the game files on the fly. Can be used for gamemods");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("GPL");
|
||||
|
||||
WUPS_FS_ACCESS()
|
||||
|
||||
ON_APPLICATION_START(args) {
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers(); //For logging
|
||||
InitVPadFunctionPointers(); //For logging
|
||||
InitPadScoreFunctionPointers();
|
||||
|
||||
log_init();
|
||||
|
||||
if(FileReplacerUtils::setGroupAndOwnerID()) {
|
||||
//DEBUG_FUNCTION_LINE("SUCCESS\n");
|
||||
}
|
||||
|
||||
DEBUG_FUNCTION_LINE("SD mounted? %d\n",args.sd_mounted);
|
||||
DEBUG_FUNCTION_LINE("USB mounted? %d\n",args.usb_mounted);
|
||||
|
||||
gSDInitDone = args.sd_mounted;
|
||||
gUSBInitDone = args.usb_mounted;
|
||||
|
||||
HandleMultiModPacks(OSGetTitleID());
|
||||
|
||||
log_print("Init of SDCafiine!\n");
|
||||
}
|
||||
|
||||
ON_APPLICATION_ENDING() {
|
||||
FileReplacerUtils::getInstance()->StopAsyncThread();
|
||||
FileReplacerUtils::destroyInstance();
|
||||
}
|
||||
|
||||
ON_APP_STATUS_CHANGED(status) {
|
||||
gAppStatus = status;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef _MAIN_H_
|
||||
#define _MAIN_H_
|
||||
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/os_types.h>
|
||||
|
||||
/* Main */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void deInitApplication();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,212 +0,0 @@
|
||||
#include <string>
|
||||
|
||||
#include <map>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include "modpackSelector.h"
|
||||
#include "common/common.h"
|
||||
#include "controllers.h"
|
||||
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <utils/logger.h>
|
||||
#include <utils/StringTools.h>
|
||||
#include <fs/FSUtils.h>
|
||||
#include <fs/CFile.hpp>
|
||||
#include <fs/DirList.h>
|
||||
#include "common/retain_vars.h"
|
||||
|
||||
#define TEXT_SEL(x, text1, text2) ((x) ? (text1) : (text2))
|
||||
|
||||
void HandleMultiModPacks(u64 titleID/*,bool showMenu*/) {
|
||||
gModFolder[0] = 0;
|
||||
|
||||
char TitleIDString[FS_MAX_FULLPATH_SIZE];
|
||||
snprintf(TitleIDString,FS_MAX_FULLPATH_SIZE,"%016llX",titleID);
|
||||
|
||||
std::map<std::string,std::string> modTitlePath;
|
||||
|
||||
std::map<std::string,std::string> mounting_points;
|
||||
if(gSDInitDone){ mounting_points[std::string(SD_PATH)] = std::string(NAME_PREFIX_SD); }
|
||||
if(gUSBInitDone){ mounting_points[std::string(USB_PATH)] = std::string(NAME_PREFIX_USB); }
|
||||
//int i = 0;
|
||||
|
||||
//for (i = 0; i < ntfs_mount_count; i++){
|
||||
//mounting_points[std::string(((ntfs_md *)ntfs_mounts)[i].name) + ":"] = StringTools::strfmt("%s:(%s)",((ntfs_md *)ntfs_mounts)[i].name, ntfsGetVolumeName(((ntfs_md *)ntfs_mounts)[i].name));
|
||||
//}
|
||||
|
||||
for (std::map<std::string,std::string>::iterator it=mounting_points.begin(); it!=mounting_points.end(); ++it){
|
||||
|
||||
std::string curMount = it->first;
|
||||
std::string curMountName = it->second;
|
||||
//DEBUG_FUNCTION_LINE("%s %s \n",curMount.c_str(),curMountName.c_str());
|
||||
std::string modTitleIDPath = curMount + GAME_MOD_FOLDER + "/" + TitleIDString;
|
||||
//DEBUG_FUNCTION_LINE("modTitleIDPath %s \n",modTitleIDPath.c_str());
|
||||
DirList modTitleDirList(modTitleIDPath.c_str(), NULL, DirList::Dirs);
|
||||
|
||||
modTitleDirList.SortList();
|
||||
|
||||
for(int i = 0; i < modTitleDirList.GetFilecount(); i++) {
|
||||
std::string curFile = modTitleDirList.GetFilename(i);
|
||||
//DEBUG_FUNCTION_LINE("curFile %s \n",curFile.c_str());
|
||||
if(curFile.compare(".") == 0 || curFile.compare("..") == 0)
|
||||
continue;
|
||||
|
||||
if(curFile.compare(CONTENT_FOLDER) == 0 || curFile.compare(AOC_FOLDER) == 0/* || curFile.compare(META_FOLDER) == 0*/) {
|
||||
std::string packageName = curMountName + " " + DEFAULT_NAME_PACKAGE;
|
||||
modTitlePath[packageName] = modTitleIDPath;
|
||||
DEBUG_FUNCTION_LINE("found %s \n",packageName.c_str());
|
||||
}else{
|
||||
std::string packageName = curMountName + " " + curFile;
|
||||
modTitlePath[packageName] = modTitleIDPath + "/" + curFile;
|
||||
DEBUG_FUNCTION_LINE("found %s \n",packageName.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//DEBUG_FUNCTION_LINE("Iteration done\n");
|
||||
|
||||
int modPackListSize =modTitlePath.size();
|
||||
|
||||
if(modPackListSize == 0) return;
|
||||
if(modPackListSize == 1/* || !showMenu*/){
|
||||
for (std::map<std::string,std::string>::iterator it=modTitlePath.begin(); it!=modTitlePath.end(); ++it){
|
||||
snprintf(gModFolder, FS_MAX_ENTNAME_SIZE, "%s", it->second.c_str());
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int selected = 0;
|
||||
int initScreen = 1;
|
||||
int x_offset = -2;
|
||||
|
||||
initControllers();
|
||||
|
||||
OSScreenInit();
|
||||
u32 screen_buf0_size = OSScreenGetBufferSizeEx(0);
|
||||
u32 screen_buf1_size = OSScreenGetBufferSizeEx(1);
|
||||
u32 * screenbuffers = (u32*)memalign(0x100, screen_buf0_size + screen_buf1_size);
|
||||
OSScreenSetBufferEx(0, (void *)screenbuffers);
|
||||
OSScreenSetBufferEx(1, (void *)(screenbuffers + screen_buf0_size));
|
||||
|
||||
OSScreenEnableEx(0, 1);
|
||||
OSScreenEnableEx(1, 1);
|
||||
|
||||
// Clear screens
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
|
||||
// Flip buffers
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
int wantToExit = 0;
|
||||
int page = 0;
|
||||
int per_page = 13;
|
||||
int max_pages = (modPackListSize / per_page) + 1;
|
||||
|
||||
while(1){
|
||||
|
||||
pollControllers();
|
||||
|
||||
if (isButtonPressed(PAD_BTN_A)) {
|
||||
wantToExit = 1;
|
||||
initScreen = 1;
|
||||
}
|
||||
else if (isButtonPressed(PAD_BTN_DOWN)) {
|
||||
selected++;
|
||||
initScreen = 1;
|
||||
}
|
||||
else if (isButtonPressed(PAD_BTN_UP)) {
|
||||
selected--;
|
||||
initScreen = 1;
|
||||
}
|
||||
else if (isButtonPressed(PAD_BTN_L)) {
|
||||
selected -= per_page;
|
||||
initScreen = 1;
|
||||
}
|
||||
else if (isButtonPressed(PAD_BTN_R)) {
|
||||
selected += per_page;
|
||||
initScreen = 1;
|
||||
}
|
||||
|
||||
if (selected < 0) selected = 0;
|
||||
if (selected >= modPackListSize) selected = modPackListSize - 1;
|
||||
page = selected / per_page;
|
||||
|
||||
if(initScreen) {
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
console_print_pos(x_offset, -1, " -- SDCafiine lite by Maschell --");
|
||||
console_print_pos(x_offset, 1, "Select your options and press A to launch.");
|
||||
int y_offset = 3;
|
||||
int cur_ = 0;
|
||||
|
||||
for (std::map<std::string,std::string>::iterator it=modTitlePath.begin(); it!=modTitlePath.end(); ++it){
|
||||
std::string key = it->first;
|
||||
std::string value = it->second;
|
||||
|
||||
if(wantToExit && cur_ == selected){
|
||||
snprintf(gModFolder, FS_MAX_ENTNAME_SIZE, "%s", value.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
if(cur_ >= (page*per_page) && cur_ < ((page+1)*per_page)){
|
||||
console_print_pos(x_offset, y_offset++, "%s %s",TEXT_SEL((selected == cur_), "--->", " "), key.c_str());
|
||||
}
|
||||
cur_++;
|
||||
}
|
||||
|
||||
if(wantToExit){ //just in case.
|
||||
break;
|
||||
}
|
||||
|
||||
if(max_pages > 0) {
|
||||
console_print_pos(x_offset, 17, "Page %02d/%02d. Press L/R to change page.", page + 1,max_pages);
|
||||
}
|
||||
|
||||
// Flip buffers
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
initScreen = 0;
|
||||
}
|
||||
os_usleep(20000);
|
||||
}
|
||||
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
|
||||
// Flip buffers
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
releaseControllers();
|
||||
|
||||
free(screenbuffers);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void console_print_pos(int x, int y, const char *format, ...){
|
||||
char * tmp = NULL;
|
||||
|
||||
va_list va;
|
||||
va_start(va, format);
|
||||
if((vasprintf(&tmp, format, va) >= 0) && tmp)
|
||||
{
|
||||
if(strlen(tmp) > 79)
|
||||
tmp[79] = 0;
|
||||
|
||||
OSScreenPutFontEx(0, x, y, tmp);
|
||||
OSScreenPutFontEx(1, x, y, tmp);
|
||||
|
||||
}
|
||||
va_end(va);
|
||||
|
||||
if(tmp)
|
||||
free(tmp);
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
#ifndef _MODPACK_SELECTOR_H_
|
||||
#define _MODPACK_SELECTOR_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <dynamic_libs/os_types.h>
|
||||
|
||||
void HandleMultiModPacks(u64 titleid/*,bool showMenu = true*/);
|
||||
void console_print_pos(int x, int y, const char *format, ...);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //_MODPACK_SELECTOR_H_
|
@ -1,147 +0,0 @@
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <utils/logger.h>
|
||||
#include <utils/StringTools.h>
|
||||
|
||||
#include "fs_utils.h"
|
||||
#include "common/common.h"
|
||||
#include "common/retain_vars.h"
|
||||
|
||||
int is_gamefile(const char *path) {
|
||||
if(path == NULL) return 0;
|
||||
if(strncmp(path,"CAFE/",5) == 0) return GAME_PATH_TYPE_STRIPPED_CONTENT; //Workaround for NSMBU
|
||||
|
||||
// In case the path starts by "//" and not "/" (some games do that ... ...)
|
||||
if (path[0] == '/' && path[1] == '/')
|
||||
path = &path[1];
|
||||
|
||||
// In case the path does not start with "/" (some games do that too ...)
|
||||
int len = 0;
|
||||
char new_path[16];
|
||||
if(path[0] != '/') {
|
||||
new_path[0] = '/';
|
||||
len++;
|
||||
}
|
||||
|
||||
while(*path && len < (int)(sizeof(new_path) - 1)) {
|
||||
new_path[len++] = *path++;
|
||||
}
|
||||
new_path[len++] = 0;
|
||||
|
||||
if(strncmp(new_path,"/vol/content",12) == 0) return GAME_PATH_TYPE_CONTENT;
|
||||
//dlc support
|
||||
if(strncmp(new_path,"/vol/aoc",8) == 0) return GAME_PATH_TYPE_AOC;
|
||||
|
||||
return 0;
|
||||
}
|
||||
char * getPathWithNewBase(const char * inPath, const char * newBase){
|
||||
if(inPath == NULL || *inPath == 0 || newBase == NULL || *newBase == 0) return NULL;
|
||||
char * relativePath = getRelativePath(inPath);
|
||||
char * result = NULL;
|
||||
|
||||
if(relativePath == NULL){
|
||||
/*
|
||||
if(strlen(gModFolder) > 0){
|
||||
int file = 0;
|
||||
if(endsWith(inPath,BOOT_TV_TEX_TGA,-1,-1)){ file = 1;}
|
||||
else if(endsWith(inPath,BOOT_DRC_TEX_TGA,-1,-1)){ file = 2;}
|
||||
else if(endsWith(inPath,BOOT_SOUND_BTSND,-1,-1)){ file = 3;}
|
||||
if(file == 0){ return NULL;}
|
||||
|
||||
result = (char*)malloc((sizeof(char) * (strlen(newBase) +1 + strlen(META_FOLDER) + 1 + 20) + 1));
|
||||
if(result == NULL){
|
||||
DEBUG_FUNCTION_LINE("malloc for result failed.\n");
|
||||
return NULL;
|
||||
}
|
||||
if(file == 1){sprintf(result,"%s/%s/%s",newBase,META_FOLDER,BOOT_TV_TEX_TGA);}
|
||||
if(file == 2){sprintf(result,"%s/%s/%s",newBase,META_FOLDER,BOOT_DRC_TEX_TGA);}
|
||||
if(file == 3){sprintf(result,"%s/%s/%s",newBase,META_FOLDER,BOOT_SOUND_BTSND);}
|
||||
return result;
|
||||
}*/
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = (char*)malloc((sizeof(char) * (strlen(newBase) +1+ strlen(relativePath))) + 1);
|
||||
if(result == NULL){
|
||||
DEBUG_FUNCTION_LINE("malloc for result failed.\n");
|
||||
OSFATAL_FUNCTION_LINE("malloc for result failed.\n");
|
||||
return NULL;
|
||||
}
|
||||
sprintf(result,"%s/%s",newBase,relativePath);
|
||||
|
||||
free(relativePath);
|
||||
relativePath = NULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
char * getRelativePath(const char *path){
|
||||
if(path == NULL) return NULL;
|
||||
char * pathForCheck = NULL;
|
||||
|
||||
int gameFile = is_gamefile(path);
|
||||
if(gameFile > 0) {
|
||||
//if(DEBUG_LOG) log_printf("getNewPath %s\n", path);
|
||||
int path_offset = 0;
|
||||
|
||||
// In case the path starts by "//" and not "/" (some games do that ... ...)
|
||||
if (path[0] == '/' && path[1] == '/')
|
||||
path = &path[1];
|
||||
|
||||
// In case the path does not start with "/" set an offset for all the accesses
|
||||
if(path[0] != '/')
|
||||
path_offset = -1;
|
||||
|
||||
|
||||
if(gameFile == GAME_PATH_TYPE_CONTENT) { // is content
|
||||
//content
|
||||
|
||||
// some games are doing /vol/content/./....
|
||||
if(path[13 + path_offset] == '.' && path[14 + path_offset] == '/') {
|
||||
path_offset += 2;
|
||||
}
|
||||
char * pathForCheckInternal = (char*)path + 13 + path_offset;
|
||||
if(pathForCheckInternal[0] == '/') pathForCheckInternal++; //Skip double slash
|
||||
|
||||
pathForCheck = (char*)malloc(sizeof(CONTENT_FOLDER) + 1 + (sizeof(char) * (strlen(pathForCheckInternal) + 1)));
|
||||
if(pathForCheck == NULL){
|
||||
DEBUG_FUNCTION_LINE("malloc failed\n");
|
||||
OSFATAL_FUNCTION_LINE("malloc failed\n");
|
||||
return NULL;
|
||||
}
|
||||
sprintf(pathForCheck,"%s/%s",CONTENT_FOLDER,pathForCheckInternal);
|
||||
} else if (gameFile == GAME_PATH_TYPE_AOC) { // is aoc
|
||||
//aoc
|
||||
int aocFolderLength = 1;
|
||||
char * aocFolderLengthCheck = (char*)path + 5 + path_offset;
|
||||
while (aocFolderLengthCheck[0] != '/') {
|
||||
aocFolderLength++;
|
||||
aocFolderLengthCheck++;
|
||||
}
|
||||
char * pathForCheckInternal = (char*)path + 5 + aocFolderLength + path_offset;
|
||||
if(pathForCheckInternal[0] == '/') pathForCheckInternal++; //Skip double slash
|
||||
|
||||
pathForCheck = (char*)malloc(sizeof(AOC_FOLDER) + 1 + (sizeof(char) * (strlen(pathForCheckInternal) + 1)));
|
||||
if(pathForCheck == NULL){
|
||||
DEBUG_FUNCTION_LINE("malloc failed\n");
|
||||
OSFATAL_FUNCTION_LINE("malloc failed\n");
|
||||
return NULL;
|
||||
}
|
||||
sprintf(pathForCheck,"%s/%s",AOC_FOLDER,pathForCheckInternal);
|
||||
} else if (gameFile == GAME_PATH_TYPE_STRIPPED_CONTENT) { // is stripped content
|
||||
pathForCheck = (char*)malloc(sizeof(CONTENT_FOLDER) + 1 + (sizeof(char) * (strlen(path) + 1)));
|
||||
if(pathForCheck == NULL){
|
||||
DEBUG_FUNCTION_LINE("malloc failed\n");
|
||||
OSFATAL_FUNCTION_LINE("malloc failed\n");
|
||||
return NULL;
|
||||
}
|
||||
sprintf(pathForCheck,"%s/%s",CONTENT_FOLDER,path);
|
||||
}
|
||||
}
|
||||
|
||||
return pathForCheck;
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef __SDCAFIINE_FS_UTILS_H_
|
||||
#define __SDCAFIINE_FS_UTILS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <dynamic_libs/os_types.h>
|
||||
|
||||
int is_gamefile(const char *path);
|
||||
char * getPathWithNewBase(const char * inPath, const char * newBase);
|
||||
char * getRelativePath(const char *path);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __FS_UTILS_H_
|
@ -1,271 +0,0 @@
|
||||
#include <wups.h>
|
||||
#include <string.h>
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/sys_functions.h>
|
||||
#include <dynamic_libs/proc_ui_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <fswrapper/FileReplacerUtils.h>
|
||||
#include <fswrapper/fs_default_os_wrapper.h>
|
||||
#include <utils/logger.h>
|
||||
#include "myfs/fs_utils.h"
|
||||
#include "common/retain_vars.h"
|
||||
#include "common/common.h"
|
||||
#include "main.h"
|
||||
|
||||
#define DEBUG_LOG 0
|
||||
|
||||
DECL_FUNCTION(int, FSCloseFile, FSClient *pClient, FSCmdBlock *pCmd, int fd, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)){ return real_FSCloseFile(pClient, pCmd, fd, error); }
|
||||
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
if((result = fs_wrapper_FSCloseFile(fd)) != USE_OS_FS_FUNCTION){
|
||||
return result;
|
||||
}
|
||||
|
||||
return real_FSCloseFile(pClient, pCmd, fd, setErrorFlag(error));
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSGetPosFile, FSClient *pClient, FSCmdBlock *pCmd, int fd, int *pos, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)){ return real_FSGetPosFile(pClient, pCmd, fd, pos, error); }
|
||||
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
if((result = fs_wrapper_FSGetPosFile(fd,pos)) != USE_OS_FS_FUNCTION){
|
||||
return result;
|
||||
}
|
||||
|
||||
return real_FSGetPosFile(pClient, pCmd, fd, pos, setErrorFlag(error));
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSGetStat, FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSStat *stats, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)){ return real_FSGetStat(pClient, pCmd, path, stats, error); }
|
||||
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
|
||||
if(DEBUG_LOG){ DEBUG_FUNCTION_LINE("for path %s\n",path); }
|
||||
char * newPath = getPathWithNewBase(path,gModFolder);
|
||||
if(newPath != NULL){
|
||||
if((result = fs_wrapper_FSGetStat(newPath,stats)) != USE_OS_FS_FUNCTION){
|
||||
if(newPath){ free(newPath); newPath = NULL;}
|
||||
return result;
|
||||
}
|
||||
if(newPath){ free(newPath); newPath = NULL;} //Should be dead code...
|
||||
}
|
||||
|
||||
return real_FSGetStat(pClient, pCmd, path, stats, setErrorFlag(error));
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSGetStatFile, FSClient *pClient, FSCmdBlock *pCmd, int fd, FSStat * stats, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)){ return real_FSGetStatFile(pClient, pCmd, fd, stats, error); }
|
||||
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
if((result = fs_wrapper_FSGetStatFile(fd,stats)) != USE_OS_FS_FUNCTION){
|
||||
return result;
|
||||
}
|
||||
|
||||
return real_FSGetStatFile(pClient, pCmd, fd, stats, setErrorFlag(error));
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSIsEof, FSClient *pClient, FSCmdBlock *pCmd, int fd, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)) return real_FSIsEof(pClient, pCmd, fd, error);
|
||||
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
if((result = fs_wrapper_FSIsEof(fd)) != USE_OS_FS_FUNCTION){
|
||||
return result;
|
||||
}
|
||||
|
||||
return real_FSIsEof(pClient, pCmd, fd, setErrorFlag(error));
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSOpenFile, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)){ return real_FSOpenFile(pClient, pCmd, path, mode, handle, error); }
|
||||
|
||||
/*if(endsWith(path,BOOT_TV_TEX_TGA,-1,-1)){ //Mario Party 10 crashes when pressing the home button.
|
||||
if(startsWith("/vol/storage_mlc01/usr/title/",path)){
|
||||
u64 tID = getTitleIDFromPath(path);
|
||||
HandleMultiModPacks(tID,false);
|
||||
}else if(strlen(gLastMetaPath) > 0){
|
||||
DEBUG_FUNCTION_LINE("gLastMetaPath %s\n",gLastMetaPath);
|
||||
if(startsWith("/vol/storage_usb01/usr/title/",gLastMetaPath) ||
|
||||
startsWith("/vol/storage_mlc01/usr/title/",gLastMetaPath)
|
||||
){
|
||||
u64 tID = getTitleIDFromPath(gLastMetaPath);
|
||||
HandleMultiModPacks(tID,false);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if(DEBUG_LOG){ DEBUG_FUNCTION_LINE("for path %s\n",path); }
|
||||
char * newPath = getPathWithNewBase(path,gModFolder);
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
|
||||
if(newPath != NULL){
|
||||
if((result = fs_wrapper_FSOpenFile(newPath,mode,handle)) != USE_OS_FS_FUNCTION){
|
||||
if(newPath){ free(newPath); newPath = NULL;}
|
||||
return result;
|
||||
}
|
||||
if(newPath){ free(newPath); newPath = NULL;} //Should be dead code...
|
||||
}
|
||||
|
||||
return real_FSOpenFile(pClient, pCmd, path, mode, handle, setErrorFlag(error));
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSReadFile, FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, int handle, int flag, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)){ return real_FSReadFile(pClient, pCmd, buffer, size, count, handle, flag, error); }
|
||||
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
if((result = fs_wrapper_FSReadFile(handle,buffer,size,count)) != USE_OS_FS_FUNCTION){
|
||||
return result;
|
||||
}
|
||||
|
||||
return real_FSReadFile(pClient, pCmd, buffer, size, count, handle, flag, setErrorFlag(error));
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSSetPosFile, FSClient *pClient, FSCmdBlock *pCmd, int fd, u32 pos, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)) return real_FSSetPosFile(pClient, pCmd, fd, pos, error);
|
||||
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
if((result = fs_wrapper_FSSetPosFile(fd,pos)) != USE_OS_FS_FUNCTION){
|
||||
return result;
|
||||
}
|
||||
|
||||
return real_FSSetPosFile(pClient, pCmd, fd, pos, setErrorFlag(error));
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSReadFileWithPos, FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, u32 pos, int fd, int flag, int error) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || !(gUSBInitDone || gSDInitDone)){ return real_FSReadFileWithPos(pClient, pCmd, buffer, size, count, pos, fd, flag, error); }
|
||||
|
||||
int result = USE_OS_FS_FUNCTION;
|
||||
if((result = fs_wrapper_FSReadFileWithPos(buffer,size,count,pos,fd)) != USE_OS_FS_FUNCTION){
|
||||
return result;
|
||||
}
|
||||
|
||||
return real_FSReadFileWithPos(pClient, pCmd, buffer, size, count, pos, fd, flag, setErrorFlag(error));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
In theory it would be enough just to patch the "async" versions of the function.
|
||||
The non-async functions internally use the async function anyway.
|
||||
However this my be a bit faster/robust, when we handle the async functions async.
|
||||
**/
|
||||
|
||||
DECL_FUNCTION(int, FSCloseFileAsync, FSClient *pClient, FSCmdBlock *pCmd, int fd, int error, FSAsyncParams * asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSCloseFileAsync(pClient, pCmd, fd, error, asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSCloseFileAsync(pClient, pCmd, fd, error, asyncParams,(void*) real_FSCloseFileAsync);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSGetPosFileAsync, FSClient *pClient, FSCmdBlock *pCmd, int fd, int *pos, int error, FSAsyncParams * asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSGetPosFileAsync(pClient, pCmd, fd, pos, error, asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSGetPosFileAsync(pClient, pCmd, fd, pos, error, asyncParams,(void*) real_FSGetPosFileAsync);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSGetStatAsync, FSClient *pClient, FSCmdBlock *pCmd, const char *path, FSStat *stats, int error, FSAsyncParams * asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSGetStatAsync(pClient, pCmd, path, stats, error, asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSGetStatAsync(getPathWithNewBase((char*)path,gModFolder),pClient, pCmd, path, stats, error, asyncParams,(void*) real_FSGetStatAsync);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSGetStatFileAsync, FSClient *pClient, FSCmdBlock *pCmd, int fd, FSStat * stats, int error, FSAsyncParams * asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSGetStatFileAsync(pClient, pCmd, fd, stats, error, asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSGetStatFileAsync(pClient, pCmd, fd, stats, error, asyncParams,(void*) real_FSGetStatFileAsync);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSIsEofAsync, FSClient *pClient, FSCmdBlock *pCmd, int fd, int error, FSAsyncParams *asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSIsEofAsync(pClient, pCmd, fd, error,asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSIsEofAsync(pClient, pCmd, fd, error,asyncParams,(void*) real_FSIsEofAsync);
|
||||
}
|
||||
/*
|
||||
u64 getTitleIDFromPath(const char * path){
|
||||
if(path == NULL || strlen(path) < 46) return 0;
|
||||
char titleID[0x11];
|
||||
char titleIDHigh[0x09];
|
||||
char titleIDLow[0x09];
|
||||
char * test = (char * )&path[29];
|
||||
snprintf(titleIDHigh,0x09,"%s",test);
|
||||
test = (char * ) &path[38];
|
||||
snprintf(titleIDLow,0x09,"%s",test);
|
||||
snprintf(titleID,0x11,"%s%s",titleIDHigh,titleIDLow);
|
||||
u64 tID = strtoll(titleID, NULL, 16);
|
||||
tID &= ~ 0x0000000E00000000; // remove update flag
|
||||
return tID;
|
||||
}*/
|
||||
|
||||
DECL_FUNCTION(int, FSOpenFileAsync, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error, FSAsyncParams *asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSOpenFileAsync(pClient, pCmd, path, mode, handle,error, asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSOpenFileAsync(getPathWithNewBase((char*)path,gModFolder), pClient, pCmd, path, mode, handle,error, asyncParams,(void*) real_FSOpenFileAsync);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSReadFileAsync, FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, int fd, int flag, int error, FSAsyncParams *asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSReadFileAsync(pClient, pCmd, buffer, size, count, fd, flag, error, asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSReadFileAsync(pClient, pCmd, buffer, size, count, fd, flag, error, asyncParams, (void*) real_FSReadFileAsync);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSReadFileWithPosAsync, FSClient *pClient, FSCmdBlock *pCmd, void *buffer, int size, int count, u32 pos, int fd, int flag, int error, FSAsyncParams *asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSReadFileWithPosAsync(pClient, pCmd, buffer, size, count, pos, fd, flag, error, asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSReadFileWithPosAsync(pClient, pCmd, buffer, size, count, pos, fd, flag, error, asyncParams, (void*) real_FSReadFileWithPosAsync);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, FSSetPosFileAsync, FSClient *pClient, FSCmdBlock *pCmd, int handle, u32 pos, int error, FSAsyncParams *asyncParams) {
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND || checkErrorFlag(&error) || !(gUSBInitDone || gSDInitDone)){ // Use the real implementation if the app is not in foreground or we already checked it.
|
||||
return real_FSSetPosFileAsync(pClient, pCmd, handle, pos, error,asyncParams);
|
||||
}
|
||||
|
||||
return fs_default_os_wrapper_FSSetPosFileAsync(pClient, pCmd, handle, pos, error,asyncParams, (void*) real_FSSetPosFileAsync);
|
||||
}
|
||||
|
||||
/*
|
||||
DECL_FUNCTION(int, FSBindMount, void *pClient, void *pCmd, char *source, char *target, int error){
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND) return real_FSBindMount(pClient,pCmd,source,target,error);
|
||||
memcpy(gLastMetaPath,source,strlen(source) + 1);
|
||||
return real_FSBindMount(pClient,pCmd,source,target,error);
|
||||
}
|
||||
DECL_FUNCTION(int, FSBindUnmount, void *pClient, void *pCmd, char *target, int error){
|
||||
if(gAppStatus == WUPS_APP_STATUS_BACKGROUND) real_FSBindUnmount(pClient,pCmd,target,error);
|
||||
gLastMetaPath[0] = 0;
|
||||
return real_FSBindUnmount(pClient,pCmd,target,error);
|
||||
}*/
|
||||
|
||||
|
||||
WUPS_MUST_REPLACE(FSCloseFile, WUPS_LOADER_LIBRARY_COREINIT, FSCloseFile);
|
||||
WUPS_MUST_REPLACE(FSGetPosFile, WUPS_LOADER_LIBRARY_COREINIT, FSGetPosFile);
|
||||
WUPS_MUST_REPLACE(FSGetStat, WUPS_LOADER_LIBRARY_COREINIT, FSGetStat);
|
||||
WUPS_MUST_REPLACE(FSGetStatFile, WUPS_LOADER_LIBRARY_COREINIT, FSGetStatFile);
|
||||
WUPS_MUST_REPLACE(FSIsEof, WUPS_LOADER_LIBRARY_COREINIT, FSIsEof);
|
||||
WUPS_MUST_REPLACE(FSOpenFile, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFile);
|
||||
WUPS_MUST_REPLACE(FSReadFile, WUPS_LOADER_LIBRARY_COREINIT, FSReadFile);
|
||||
WUPS_MUST_REPLACE(FSReadFileWithPos, WUPS_LOADER_LIBRARY_COREINIT, FSReadFileWithPos);
|
||||
WUPS_MUST_REPLACE(FSSetPosFile, WUPS_LOADER_LIBRARY_COREINIT, FSSetPosFile);
|
||||
|
||||
WUPS_MUST_REPLACE(FSCloseFileAsync, WUPS_LOADER_LIBRARY_COREINIT, FSCloseFileAsync);
|
||||
WUPS_MUST_REPLACE(FSGetPosFileAsync, WUPS_LOADER_LIBRARY_COREINIT, FSGetPosFileAsync);
|
||||
WUPS_MUST_REPLACE(FSGetStatAsync, WUPS_LOADER_LIBRARY_COREINIT, FSGetStatAsync);
|
||||
WUPS_MUST_REPLACE(FSGetStatFileAsync, WUPS_LOADER_LIBRARY_COREINIT, FSGetStatFileAsync);
|
||||
WUPS_MUST_REPLACE(FSIsEofAsync, WUPS_LOADER_LIBRARY_COREINIT, FSIsEofAsync);
|
||||
WUPS_MUST_REPLACE(FSOpenFileAsync, WUPS_LOADER_LIBRARY_COREINIT, FSOpenFileAsync);
|
||||
WUPS_MUST_REPLACE(FSReadFileAsync, WUPS_LOADER_LIBRARY_COREINIT, FSReadFileAsync);
|
||||
WUPS_MUST_REPLACE(FSReadFileWithPosAsync, WUPS_LOADER_LIBRARY_COREINIT, FSReadFileWithPosAsync);
|
||||
WUPS_MUST_REPLACE(FSSetPosFileAsync, WUPS_LOADER_LIBRARY_COREINIT, FSSetPosFileAsync);
|
@ -1,295 +0,0 @@
|
||||
# You probably never need to adjust this Makefile.
|
||||
# All changes can be done in the makefile.mk
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Clear the implicit built in rules
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
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
|
||||
ifeq ($(strip $(WUT_ROOT)),)
|
||||
$(error "Please set WUT_ROOT in your environment. export WUT_ROOT=<path to>wut)
|
||||
endif
|
||||
|
||||
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
|
||||
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
|
||||
export WUPSDIR := $(DEVKITPRO)/wups
|
||||
export GCC_VER := $(shell $(DEVKITPPC)/bin/powerpc-eabi-gcc -dumpversion)
|
||||
|
||||
PREFIX := powerpc-eabi-
|
||||
|
||||
export AS := $(PREFIX)as
|
||||
export CC := $(PREFIX)gcc
|
||||
export CXX := $(PREFIX)g++
|
||||
export LD := $(PREFIX)ld
|
||||
export AR := $(PREFIX)ar
|
||||
export OBJCOPY := $(PREFIX)objcopy
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# INCLUDES is a list of directories containing extra header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
BUILD := build
|
||||
|
||||
ifeq ($(notdir $(CURDIR)),$(BUILD))
|
||||
include ../makefile.mk
|
||||
else
|
||||
include makefile.mk
|
||||
endif
|
||||
|
||||
include $(WUPSDIR)/plugin_makefile.mk
|
||||
|
||||
#MAP ?= $(TARGET:.mod=.map)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
# -Os: optimise size
|
||||
# -Wall: generate lots of warnings
|
||||
# -DGEKKO_U: define the symbol GEKKO (used in some headers)
|
||||
# -D__wiiu__: define the symbol __wii__ (used in some headers)
|
||||
# -mrvl: enable wii/gamecube compilation
|
||||
# -mcpu=750: enable processor specific compilation
|
||||
# -meabi: enable eabi specific compilation
|
||||
# -mhard-float: enable hardware floating point instructions
|
||||
# -fno-common: stop common variables which the loader can't understand
|
||||
# -msdata-none: do not use r2 or r13 as small data areas
|
||||
# -memb: enable embedded application specific compilation
|
||||
# -ffunction-sections: split up functions so linker can garbage collect
|
||||
# -fdata-sections: split up data so linker can garbage collect
|
||||
COMMON_CFLAGS += -Os -Wall -DGEKKO_U -D__wiiu__ -D__WIIU__ -mrvl -mcpu=750 -meabi -mhard-float -fno-common -msdata=none -memb -ffunction-sections -fdata-sections
|
||||
|
||||
|
||||
# -x c: compile as c code
|
||||
# -std=c11: use the c11 standard
|
||||
CFLAGS += $(COMMON_CFLAGS) -x c -std=gnu11
|
||||
|
||||
# -x c: compile as c++ code
|
||||
# -std=gnu++11: use the c++11 standard
|
||||
CXXFLAGS += $(COMMON_CFLAGS) -x c++ -std=gnu++11
|
||||
|
||||
ifeq ($(DO_LOGGING), 1)
|
||||
CFLAGS += -D__LOGGING__
|
||||
CXXFLAGS += -D__LOGGING__
|
||||
endif
|
||||
|
||||
ifeq ($(USE_WUT), 1)
|
||||
CFLAGS += -D__WUT__
|
||||
CXXFLAGS += -D__WUT__
|
||||
endif
|
||||
|
||||
ASFLAGS +=
|
||||
|
||||
LDFLAG_COMMON +=
|
||||
|
||||
ifeq ($(WRAP_MALLOC), 1)
|
||||
LDFLAG_COMMON += -Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r
|
||||
endif
|
||||
|
||||
LDFLAGS_MOD += $(LD_FLAGS_MOD)
|
||||
LDFLAGS_ELF += $(LD_FLAGS_ELF)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
Q := @
|
||||
MAKEFLAGS += --no-print-directory
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
ALL_LIBS := $(LIBS)
|
||||
#
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS += $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
export PROJECTDIR := $(CURDIR)
|
||||
export OUTPUT := $(CURDIR)/$(TARGETDIR)/$(TARGET)
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# automatically build a list of object files for our project
|
||||
#---------------------------------------------------------------------------------
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
|
||||
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
export LD_MOD := $(CC)
|
||||
else
|
||||
export LD_MOD := $(CXX)
|
||||
endif
|
||||
|
||||
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
|
||||
$(sFILES:.s=.o) $(SFILES:.S=.o) \
|
||||
$(PNGFILES:.png=.png.o) $(addsuffix .o,$(BINFILES))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of include paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export INCLUDE_FULL += $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
$(EXTERNAL_INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# build a list of library paths
|
||||
#---------------------------------------------------------------------------------
|
||||
export LIBPATHS_FULL += $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
|
||||
$(EXTERNAL_LIBPATHS)
|
||||
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
.PHONY: $(BUILD) clean install
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
THIS_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
###############################################################################
|
||||
# Rule to make everything.
|
||||
PHONY += all
|
||||
|
||||
all : $(OUTPUT)
|
||||
###############################################################################
|
||||
# Special build rules
|
||||
|
||||
# Rule to make the module file.
|
||||
$(OUTPUT) : output.elf
|
||||
@echo "checking for missing symbols ..."
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LD_FLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o check_linking.elf
|
||||
@echo "linking ..." $@
|
||||
@$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAG_COMMON) $(LDFLAGS_MOD) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
# Rule to make the module file.
|
||||
output.elf : $(OFILES)
|
||||
@echo "linking ... output.elf"
|
||||
@$(LD) $(OFILES) $(LDFLAGS_ELF) $(ALL_LIBS) $(LIBPATHS_FULL) -o $@
|
||||
|
||||
###############################################################################
|
||||
# Standard build rules
|
||||
#---------------------------------------------------------------------------------
|
||||
%.a:
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $@)
|
||||
@rm -f $@
|
||||
@$(AR) -rc $@ $^
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.cpp
|
||||
@echo $(notdir $<)
|
||||
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.c
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.o: %.S
|
||||
@echo $(notdir $<)
|
||||
@$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(INCLUDE_FULL) -c $< -o $@ $(ERROR_FILTER)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.png.o : %.png
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.jpg.o : %.jpg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ttf.o : %.ttf
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.wav.o : %.wav
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.mp3.o : %.mp3
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.ogg.o : %.ogg
|
||||
@echo $(notdir $<)
|
||||
@bin2s -a 32 $< | $(AS) -o $(@)
|
||||
|
||||
###############################################################################
|
||||
# Assembly listing rules
|
||||
|
||||
# Rule to make assembly listing.
|
||||
PHONY += list
|
||||
list : $(LIST)
|
||||
|
||||
# Rule to make the listing file.
|
||||
%.list : $(TARGET)
|
||||
$(LOG)
|
||||
-$Qmkdir -p $(dir $@)
|
||||
$Q$(OBJDUMP) -d $< > $@
|
||||
|
||||
###############################################################################
|
||||
# Clean rule
|
||||
|
||||
# Rule to clean files.
|
||||
PHONY += clean
|
||||
clean :
|
||||
$Qrm -rf $(wildcard $(BUILD) $(BIN))
|
||||
|
||||
###############################################################################
|
||||
# Phony targets
|
||||
|
||||
.PHONY : $(PHONY)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
@ -1,20 +0,0 @@
|
||||
# SwipSwapMe Plugin for the Wii U Plugin System
|
||||
|
||||
This little app can be used to swap the TV and DRC screen.
|
||||
|
||||
# Usage
|
||||
|
||||
When starting the app, you have the option to set your own button combo. Just press the button combo you want for 2 seconds.
|
||||
Otherwise it will use the default settings (TV button).
|
||||
|
||||
Press the TV button (or your button combo) on the Gamepad to swap the screens. Thats all.
|
||||
|
||||
## Building
|
||||
|
||||
For building you need:
|
||||
- [wups](https://github.com/Maschell/WiiUPluginSystem)
|
||||
- [dynamic_libs](https://github.com/Maschell/dynamic_libs/tree/lib) for access to the functions.
|
||||
- [libutils](https://github.com/Maschell/libutils) for common functions.
|
||||
|
||||
|
||||
Install them (in this order) according to their README's. Don't forget the dependencies of the libs itself.
|
@ -1,60 +0,0 @@
|
||||
# Compiling the projects with libutils logging code?
|
||||
DO_LOGGING := 1
|
||||
|
||||
# Non WUT plugins need to wrap the malloc functions.
|
||||
WRAP_MALLOC := 1
|
||||
|
||||
# Sets the "-D__WUT__" compiling flag
|
||||
USE_WUT := 0
|
||||
|
||||
# Target filename
|
||||
TARGET := $(notdir $(CURDIR)).mod
|
||||
|
||||
# Source directories
|
||||
SOURCES := src \
|
||||
src/common \
|
||||
src/utils \
|
||||
|
||||
# Data directories
|
||||
DATA :=
|
||||
|
||||
# Include directories
|
||||
INCLUDES := src
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation and linking
|
||||
#---------------------------------------------------------------------------------
|
||||
# Extra C compiler flags
|
||||
CFLAGS :=
|
||||
# Extra C++ compiler flags
|
||||
CXXFLAGS :=
|
||||
# Extra linking flags for all linking steps
|
||||
LD_FLAGS :=
|
||||
# extra linking flags for linking the temporarily elf file (using ld)
|
||||
LD_FLAGS_ELF :=
|
||||
# extra linking flags for linking the final mod file (using gcc/g++)
|
||||
LD_FLAGS_MOD :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(WUPSDIR) $(PORTLIBS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lwups -lutils -ldynamiclibs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final lib paths
|
||||
# example:
|
||||
# -L$C:/library1/lib
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_LIBPATHS :=
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# Will be added to the final include paths
|
||||
# -IC:/library1/include
|
||||
#---------------------------------------------------------------------------------
|
||||
EXTERNAL_INCLUDE := -I$(PORTLIBS)/include/libutils
|
@ -1,24 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017,2018 Maschell
|
||||
*
|
||||
* 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 "common/c_retain_vars.h"
|
||||
|
||||
u8 gSwap __attribute__((section(".data"))) = 0;
|
||||
u8 gCallbackCooldown __attribute__((section(".data"))) = 0;
|
||||
u8 gAppStatus __attribute__((section(".data"))) = 0;
|
||||
u32 gButtonCombo __attribute__((section(".data"))) = 0;
|
||||
|
||||
VoiceInfo gVoiceInfos[VOICE_INFO_MAX] __attribute__((section(".data")));
|
@ -1,27 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017,2018 Maschell
|
||||
*
|
||||
* 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 C_RETAINS_VARS_H_
|
||||
#define C_RETAINS_VARS_H_
|
||||
#include "dynamic_libs/gx2_functions.h"
|
||||
#include "utils/voice_info.h"
|
||||
extern u8 gSwap;
|
||||
extern u8 gCallbackCooldown;
|
||||
extern u8 gAppStatus;
|
||||
extern u32 gButtonCombo;
|
||||
extern VoiceInfo gVoiceInfos[VOICE_INFO_MAX];
|
||||
|
||||
#endif // C_RETAINS_VARS_H_
|
@ -1,118 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017,2018 Maschell
|
||||
*
|
||||
* 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 <wups.h>
|
||||
#include "utils/logger.h"
|
||||
#include "utils/voice_swapper.h"
|
||||
#include "common/c_retain_vars.h"
|
||||
#include "dynamic_libs/proc_ui_functions.h"
|
||||
#include "dynamic_libs/vpad_functions.h"
|
||||
|
||||
DECL_FUNCTION(s32, AXSetVoiceDeviceMixOld, void *v, s32 device, u32 id, void *mix){
|
||||
if(gSwap){ device = !device;}
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("AXSetVoiceDeviceMixOld voice: %08X device: %d, mix: %08X\n",v,device,mix);}
|
||||
VoiceSwapper_setMix(v,device,mix);
|
||||
return real_AXSetVoiceDeviceMixOld(v,device,id,mix);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(s32, AXSetVoiceDeviceMix, void *v, s32 device, u32 id, void *mix){
|
||||
if(gSwap){ device = !device;}
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("AXSetVoiceDeviceMix voice: %08X device: %d, mix: %08X\n",v,device,mix);}
|
||||
VoiceSwapper_setMix(v,device,mix);
|
||||
return real_AXSetVoiceDeviceMix(v,device,id,mix);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void *, AXAcquireVoiceExOld, u32 prio, void * callback, u32 arg){
|
||||
void * result = real_AXAcquireVoiceExOld(prio,callback,arg);
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("AXAcquireVoiceExOld result: %08X \n",result);}
|
||||
VoiceSwapper_acquireVoice(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void *, AXAcquireVoiceEx, u32 prio, void * callback, u32 arg){
|
||||
void * result = real_AXAcquireVoiceEx(prio,callback,arg);
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("AXAcquireVoiceEx result: %08X \n",result);}
|
||||
VoiceSwapper_acquireVoice(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, AXFreeVoiceOld, void *v){
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("AXFreeVoiceOld v: %08X \n",v);}
|
||||
VoiceSwapper_freeVoice(v);
|
||||
real_AXFreeVoiceOld(v);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, AXFreeVoice, void *v){
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("AXFreeVoice v: %08X \n",v);}
|
||||
VoiceSwapper_freeVoice(v);
|
||||
real_AXFreeVoice(v);
|
||||
}
|
||||
|
||||
DECL_FUNCTION(void, GX2CopyColorBufferToScanBuffer, GX2ColorBuffer *colorBuffer, s32 scan_target){
|
||||
if(gSwap){
|
||||
if(scan_target == 1){
|
||||
scan_target = 4;
|
||||
}else{
|
||||
scan_target = 1;
|
||||
}
|
||||
}
|
||||
real_GX2CopyColorBufferToScanBuffer(colorBuffer,scan_target);
|
||||
}
|
||||
|
||||
/*
|
||||
DECL(s32, AXSetDefaultMixerSelectOld, u32 s){
|
||||
s32 result = real_AXSetDefaultMixerSelectOld(s);
|
||||
return result;
|
||||
}*/
|
||||
|
||||
|
||||
void swapVoices(){
|
||||
VoiceSwapper_swapAll();
|
||||
for(int i = 0;i<VOICE_INFO_MAX;i++){
|
||||
if(gVoiceInfos[i].voice == NULL) continue;
|
||||
|
||||
real_AXSetVoiceDeviceMix(gVoiceInfos[i].voice,0,0,gVoiceInfos[i].mixTV);
|
||||
real_AXSetVoiceDeviceMix(gVoiceInfos[i].voice,1,0,gVoiceInfos[i].mixDRC);
|
||||
real_AXSetVoiceDeviceMixOld(gVoiceInfos[i].voice,0,0,gVoiceInfos[i].mixTV);
|
||||
real_AXSetVoiceDeviceMixOld(gVoiceInfos[i].voice,1,0,gVoiceInfos[i].mixDRC);
|
||||
}
|
||||
}
|
||||
|
||||
DECL_FUNCTION(int, VPADRead, int chan, VPADData *buffer, u32 buffer_size, s32 *error) {
|
||||
int result = real_VPADRead(chan, buffer, buffer_size, error);
|
||||
|
||||
if(result > 0 && ((buffer[0].btns_h & gButtonCombo) == gButtonCombo) && gCallbackCooldown == 0 ){
|
||||
gCallbackCooldown = 0x3C;
|
||||
if(gAppStatus == WUPS_APP_STATUS_FOREGROUND){
|
||||
gSwap = !gSwap;
|
||||
swapVoices();
|
||||
}
|
||||
}
|
||||
if(gCallbackCooldown > 0) gCallbackCooldown--;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
WUPS_MUST_REPLACE(GX2CopyColorBufferToScanBuffer, WUPS_LOADER_LIBRARY_GX2, GX2CopyColorBufferToScanBuffer);
|
||||
WUPS_MUST_REPLACE(VPADRead, WUPS_LOADER_LIBRARY_VPAD, VPADRead);
|
||||
WUPS_MUST_REPLACE(AXAcquireVoiceExOld, WUPS_LOADER_LIBRARY_SND_CORE, AXAcquireVoiceEx);
|
||||
WUPS_MUST_REPLACE(AXFreeVoiceOld, WUPS_LOADER_LIBRARY_SND_CORE, AXFreeVoice);
|
||||
WUPS_MUST_REPLACE(AXSetVoiceDeviceMixOld, WUPS_LOADER_LIBRARY_SND_CORE, AXSetVoiceDeviceMix);
|
||||
//WUPS_MUST_REPLACE(AXSetDefaultMixerSelectOld, , WUPS_LOADER_LIBRARY_SND_CORE, AXSetDefaultMixerSelect),
|
||||
WUPS_MUST_REPLACE(AXAcquireVoiceEx, WUPS_LOADER_LIBRARY_SNDCORE2, AXAcquireVoiceEx);
|
||||
WUPS_MUST_REPLACE(AXFreeVoice, WUPS_LOADER_LIBRARY_SNDCORE2, AXFreeVoice);
|
||||
WUPS_MUST_REPLACE(AXSetVoiceDeviceMix, WUPS_LOADER_LIBRARY_SNDCORE2, AXSetVoiceDeviceMix);
|
@ -1,161 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017,2018 Maschell
|
||||
*
|
||||
* 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 <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <wups.h>
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#include <dynamic_libs/os_functions.h>
|
||||
#include <dynamic_libs/gx2_functions.h>
|
||||
#include <dynamic_libs/gx2_types.h>
|
||||
#include <dynamic_libs/syshid_functions.h>
|
||||
#include <dynamic_libs/ax_functions.h>
|
||||
#include <dynamic_libs/vpad_functions.h>
|
||||
#include <dynamic_libs/padscore_functions.h>
|
||||
#include <dynamic_libs/socket_functions.h>
|
||||
#include <dynamic_libs/sys_functions.h>
|
||||
#include <dynamic_libs/proc_ui_functions.h>
|
||||
#include <utils/logger.h>
|
||||
#include <common/c_retain_vars.h>
|
||||
|
||||
WUPS_PLUGIN_NAME("SwipSwapMe");
|
||||
WUPS_PLUGIN_DESCRIPTION("Swaps the gamepad and tv screen when pressing a certain button (TV is default)");
|
||||
WUPS_PLUGIN_VERSION("v1.0");
|
||||
WUPS_PLUGIN_AUTHOR("Maschell");
|
||||
WUPS_PLUGIN_LICENSE("GPL");
|
||||
|
||||
WUPS_FS_ACCESS()
|
||||
|
||||
u32 SplashScreen(s32 time,s32 combotime);
|
||||
|
||||
/* Entry point */
|
||||
ON_APPLICATION_START(args){
|
||||
InitOSFunctionPointers();
|
||||
InitSocketFunctionPointers(); //For logging
|
||||
|
||||
InitSysFunctionPointers(); // For SYSLaunchMenu()
|
||||
|
||||
//For patching
|
||||
InitVPadFunctionPointers();
|
||||
InitPadScoreFunctionPointers();
|
||||
InitAXFunctionPointers();
|
||||
|
||||
memset(gVoiceInfos,0,sizeof(gVoiceInfos));
|
||||
}
|
||||
|
||||
ON_APP_STATUS_CHANGED(status) {
|
||||
gAppStatus = status;
|
||||
}
|
||||
|
||||
INITIALIZE_PLUGIN(){
|
||||
InitOSFunctionPointers();
|
||||
InitVPadFunctionPointers();
|
||||
u32 res = SplashScreen(10,2);
|
||||
gButtonCombo = res;
|
||||
}
|
||||
|
||||
#define FPS 60
|
||||
u32 SplashScreen(s32 time,s32 combotime){
|
||||
u32 result = VPAD_BUTTON_TV;
|
||||
|
||||
// Init screen
|
||||
OSScreenInit();
|
||||
|
||||
u32 screen_buf0_size = OSScreenGetBufferSizeEx(0);
|
||||
u32 screen_buf1_size = OSScreenGetBufferSizeEx(1);
|
||||
|
||||
u32 * screenbuffer0 = (u32*)memalign(0x100, screen_buf0_size);
|
||||
u32 * screenbuffer1 = (u32*)memalign(0x100, screen_buf1_size);
|
||||
|
||||
if(screenbuffer0 == NULL || screenbuffer1 == NULL){
|
||||
if(screenbuffer0 != NULL){ free(screenbuffer0); }
|
||||
if(screenbuffer1 != NULL){ free(screenbuffer1); }
|
||||
return result;
|
||||
}
|
||||
|
||||
OSScreenSetBufferEx(0, (void *)screenbuffer0);
|
||||
OSScreenSetBufferEx(1, (void *)screenbuffer1);
|
||||
|
||||
OSScreenEnableEx(0, 1);
|
||||
OSScreenEnableEx(1, 1);
|
||||
|
||||
// Clear screens
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
|
||||
// Flip buffers
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
OSScreenClearBufferEx(0, 0);
|
||||
OSScreenClearBufferEx(1, 0);
|
||||
|
||||
std::vector<std::string> strings;
|
||||
strings.push_back("SwipSwapMe 0.2 - by Maschell.");
|
||||
strings.push_back("");
|
||||
strings.push_back("");
|
||||
strings.push_back("Press the combo you want to use for swapping now for 2 seconds.");
|
||||
strings.push_back("Pressing the TV button will return directly.");
|
||||
strings.push_back("");
|
||||
strings.push_back("Otherwise the default combo (TV button) will be used in 10 seconds.");
|
||||
u8 pos = 0;
|
||||
for (std::vector<std::string>::iterator it = strings.begin() ; it != strings.end(); ++it){
|
||||
OSScreenPutFontEx(0, 0, pos, (*it).c_str());
|
||||
OSScreenPutFontEx(1, 0, pos, (*it).c_str());
|
||||
pos++;
|
||||
}
|
||||
|
||||
OSScreenFlipBuffersEx(0);
|
||||
OSScreenFlipBuffersEx(1);
|
||||
|
||||
s32 tickswait = time * FPS * 16;
|
||||
|
||||
s32 sleepingtime = 16;
|
||||
s32 times = tickswait/16;
|
||||
s32 i=0;
|
||||
|
||||
VPADData vpad_data;
|
||||
s32 error;
|
||||
u32 last = 0xFFFFFFFF;
|
||||
s32 timer = 0;
|
||||
while(i<times){
|
||||
VPADRead(0, &vpad_data, 1, &error);
|
||||
if(vpad_data.btns_h == VPAD_BUTTON_TV) break;
|
||||
if(last == vpad_data.btns_h && last != 0){
|
||||
timer++;
|
||||
}else{
|
||||
last = vpad_data.btns_h;
|
||||
timer = 0;
|
||||
}
|
||||
if(timer >= combotime*FPS){
|
||||
result = vpad_data.btns_h;
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
os_usleep(sleepingtime*1000);
|
||||
}
|
||||
|
||||
if(screenbuffer0 != NULL){ free(screenbuffer0); }
|
||||
if(screenbuffer1 != NULL){ free(screenbuffer1); }
|
||||
|
||||
return result;
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017,2018 Maschell
|
||||
*
|
||||
* 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 _VOICE_INFO_H_
|
||||
#define _VOICE_INFO_H_
|
||||
|
||||
#include <dynamic_libs/os_types.h>
|
||||
|
||||
#define VOICE_INFO_MAX 100
|
||||
|
||||
typedef struct _VoiceInfo {
|
||||
void* voice; /**< Pointer to the voice */
|
||||
u32 mixTV[24]; /**< Mix to the TV */
|
||||
u32 mixDRC[24]; /**< Mix of the DRC */
|
||||
} VoiceInfo;
|
||||
|
||||
#endif //_VOICE_INFO_H_
|
@ -1,64 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017,2018 Maschell
|
||||
*
|
||||
* 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 "voice_info.h"
|
||||
#include "voice_swapper.h"
|
||||
|
||||
void VoiceSwapper_acquireVoice(void * voice){
|
||||
for(int i = 0;i<VOICE_INFO_MAX;i++){
|
||||
if(gVoiceInfos[i].voice == NULL){
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("[VoiceSwapper] acquireVoice in slot %d for %08X!\n",i,voice);}
|
||||
gVoiceInfos[i].voice = voice;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VoiceSwapper_freeVoice(void * voice){
|
||||
for(int i = 0;i<VOICE_INFO_MAX;i++){
|
||||
if(gVoiceInfos[i].voice == voice){
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("[VoiceSwapper] freeVoice in slot %d for %08X!\n",i,voice);}
|
||||
gVoiceInfos[i].voice = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VoiceSwapper_setMix(void * voice,u32 device, void* mix){
|
||||
for(int i = 0;i<VOICE_INFO_MAX;i++){
|
||||
if(gVoiceInfos[i].voice == voice){
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("[VoiceSwapper] setMix in slot %d for %08X!\n",i,voice);}
|
||||
if(device == 0){
|
||||
memcpy(gVoiceInfos[i].mixTV,mix,sizeof(gVoiceInfos[i].mixTV));
|
||||
}else if(device == 1){
|
||||
memcpy(gVoiceInfos[i].mixDRC,mix,sizeof(gVoiceInfos[i].mixDRC));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VoiceSwapper_swapAll(){
|
||||
for(int i = 0;i<VOICE_INFO_MAX;i++){
|
||||
if(gVoiceInfos[i].voice == NULL) continue;
|
||||
if(VOICE_SWAP_LOG == 1){log_printf("[VoiceSwapper] swapping slot %d, voice %08X!\n",i,gVoiceInfos[i].voice);}
|
||||
u32 buffer[24];
|
||||
memcpy(buffer,gVoiceInfos[i].mixTV,sizeof(gVoiceInfos[i].mixTV));
|
||||
memcpy(gVoiceInfos[i].mixTV,gVoiceInfos[i].mixDRC,sizeof(gVoiceInfos[i].mixTV));
|
||||
memcpy(gVoiceInfos[i].mixDRC,buffer,sizeof(gVoiceInfos[i].mixTV));
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2017,2018 Maschell
|
||||
*
|
||||
* 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 _VOICE_SWAPPER_H_
|
||||
#define _VOICE_SWAPPER_H_
|
||||
#define VOICE_SWAP_LOG 0
|
||||
#include "voice_info.h"
|
||||
#include "common/c_retain_vars.h"
|
||||
|
||||
#include "utils/logger.h"
|
||||
|
||||
#include "dynamic_libs/os_functions.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void VoiceSwapper_acquireVoice(void * voice);
|
||||
|
||||
void VoiceSwapper_freeVoice(void * voice);
|
||||
|
||||
void VoiceSwapper_setMix(void * voice,u32 device, void* mix);
|
||||
|
||||
void VoiceSwapper_swapAll();
|
||||
|
||||
#endif //_VOICE_SWAPPER_H_
|
Loading…
Reference in New Issue
Block a user