diff --git a/.gitignore b/.gitignore index 359f538..8418054 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ loader/WiiUPluginLoader.cscope_file_list loader/WiiUPluginLoader.layout *.mod +*.cbp diff --git a/.travis.yml b/.travis.yml index 35e54e4..ecba2d8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,6 +48,7 @@ script: - (cd example_plugin && make) - (cd plugins/padcon && make) - (cd plugins/sdcafiine && make) +- (cd plugins/swapdrc && make) before_deploy: - mkdir -p "wiiu/apps/wiiupluginloader" @@ -58,6 +59,7 @@ before_deploy: - (cd loader && make) - cp example_plugin/example_plugin.mod wiiu/plugins - cp plugins/padcon/padcon.mod wiiu/plugins +- cp plugins/swapdrc/swapdrc.mod wiiu/plugins - cp plugins/sdcafiine/sdcafiine.mod wiiu/plugins - cp loader/meta/* wiiu/apps/wiiupluginloader - cp loader/wiiupluginloader.elf wiiu/apps/wiiupluginloader diff --git a/loader/src/main.cpp b/loader/src/main.cpp index 09aef6b..d36a9c0 100644 --- a/loader/src/main.cpp +++ b/loader/src/main.cpp @@ -154,6 +154,7 @@ bool loadSamplePlugin(){ loadElf("sd:/wiiu/plugins/example_plugin.mod"); loadElf("sd:/wiiu/plugins/sdcafiine.mod"); loadElf("sd:/wiiu/plugins/padcon.mod"); + loadElf("sd:/wiiu/plugins/swapdrc.mod"); if(module_list_count == 0){ DEBUG_FUNCTION_LINE("Found no valid modules! =( Exiting\n"); return false; diff --git a/plugins/swapdrc/Makefile b/plugins/swapdrc/Makefile new file mode 100644 index 0000000..d4f778c --- /dev/null +++ b/plugins/swapdrc/Makefile @@ -0,0 +1,291 @@ +DO_LOGGING := 1 + +#--------------------------------------------------------------------------------- +# Clear the implicit built in rules +#--------------------------------------------------------------------------------- +.SUFFIXES: +#--------------------------------------------------------------------------------- +ifeq ($(strip $(DEVKITPPC)),) +$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=devkitPPC") +endif +ifeq ($(strip $(DEVKITPRO)),) +$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPRO") +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 +SOURCES := src \ + src/common \ + src/utils + +DATA := + +INCLUDES := src + +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 +# -fshort-wchar: use 16 bit whcar_t type in keeping with Wii executables +# -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__ -mrvl -mcpu=750 -meabi -mhard-float -fshort-wchar -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=c11 + +# -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 + +ASFLAGS := -mregnames +# --relocatable: make sure ld doesn't remove relocations wups will need +# -s: strip local symbols to speed linking +# -u: keep certain sections +# -wrap: wrap function +# --gc-sections: remove unneeded symbols +# -T: use the linker script specified (to force certain wups sections together) +# -Map: generate a map file + +LDFLAG_COMMON += -u wups_load -u wups_meta -u wups_hooks -T $(WUPSDIR)/wups.ld \ + -Wl,-Map,$(notdir $@).map,-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,--gc-sections + +LDFLAGS_MOD += $(LDFLAG_COMMON),--relocatable +LDFLAGS_ELF += --relocatable -s -T $(WUPSDIR)/wups_elf.ld + +#--------------------------------------------------------------------------------- +Q := @ +MAKEFLAGS += --no-print-directory +#--------------------------------------------------------------------------------- +# any extra libraries we wish to link with the project +#--------------------------------------------------------------------------------- +LIBS := -lutils -ldynamiclibs +# + +#--------------------------------------------------------------------------------- +# list of directories containing libraries, this must be the top level containing +# include and lib +#--------------------------------------------------------------------------------- +LIBDIRS := $(DEVKITPPC) + +#--------------------------------------------------------------------------------- +# 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 := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ + $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ + -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include \ + -I$(PORTLIBS)/include/libutils -I$(WUPSDIR)/include + +#--------------------------------------------------------------------------------- +# build a list of library paths +#--------------------------------------------------------------------------------- +export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ + -L$(PORTLIBS)/lib + +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) $(LIBS) $(LIBPATHS) -o check_linking.elf + @echo "linking ..." $@ + @$(LD_MOD) ../$(BUILD)/output.elf $(LDFLAGS_MOD) $(LIBS) $(LIBPATHS) -o $@ + +# Rule to make the module file. +output.elf : $(OFILES) + @echo "linking ... output.elf" + + + @$(LD) $(OFILES) $(LDFLAGS_ELF) $(LIBS) $(LIBPATHS) -o $@ + +############################################################################### +# Standard build rules +#--------------------------------------------------------------------------------- +%.a: +#--------------------------------------------------------------------------------- + @echo $(notdir $@) + @rm -f $@ + @$(AR) -rc $@ $^ + +#--------------------------------------------------------------------------------- +%.o: %.cpp + @echo $(notdir $<) + @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(INCLUDE) -c $< -o $@ $(ERROR_FILTER) + +#--------------------------------------------------------------------------------- +%.o: %.c + @echo $(notdir $<) + @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(INCLUDE) -c $< -o $@ $(ERROR_FILTER) + +#--------------------------------------------------------------------------------- +%.o: %.S + @echo $(notdir $<) + @$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -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 +#--------------------------------------------------------------------------------- diff --git a/plugins/swapdrc/src/common/c_retain_vars.cpp b/plugins/swapdrc/src/common/c_retain_vars.cpp new file mode 100644 index 0000000..2c13da6 --- /dev/null +++ b/plugins/swapdrc/src/common/c_retain_vars.cpp @@ -0,0 +1,24 @@ +/**************************************************************************** + * 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 . + ****************************************************************************/ +#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"))); diff --git a/plugins/swapdrc/src/common/c_retain_vars.h b/plugins/swapdrc/src/common/c_retain_vars.h new file mode 100644 index 0000000..4af09dc --- /dev/null +++ b/plugins/swapdrc/src/common/c_retain_vars.h @@ -0,0 +1,27 @@ +/**************************************************************************** + * 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 . + ****************************************************************************/ +#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_ diff --git a/plugins/swapdrc/src/function_patcher.c b/plugins/swapdrc/src/function_patcher.c new file mode 100644 index 0000000..166320f --- /dev/null +++ b/plugins/swapdrc/src/function_patcher.c @@ -0,0 +1,128 @@ +/**************************************************************************** + * 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 . + ****************************************************************************/ +#include +#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 0 && ((buffer[0].btns_h & gButtonCombo) == gButtonCombo) && gCallbackCooldown == 0 ){ + gCallbackCooldown = 0x3C; + gSwap = !gSwap; + if(!gAppStatus){ + swapVoices(); + } + } + if(gCallbackCooldown > 0) gCallbackCooldown--; + + return result; +} + +DECL_FUNCTION(u32, ProcUIProcessMessages, u32 u){ + u32 res = real_ProcUIProcessMessages(u); + if(res != gAppStatus){ + log_printf("App status changed from %d to %d \n",gAppStatus,res); + gAppStatus = res; + } + + return res; +} + +WUPS_MUST_REPLACE(ProcUIProcessMessages, WUPS_LOADER_LIBRARY_PROC_UI, ProcUIProcessMessages); +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); diff --git a/plugins/swapdrc/src/main.c b/plugins/swapdrc/src/main.c new file mode 100644 index 0000000..e0c47e8 --- /dev/null +++ b/plugins/swapdrc/src/main.c @@ -0,0 +1,145 @@ +/**************************************************************************** + * 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 . + ****************************************************************************/ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +WUPS_MODULE_NAME("SwapDRC"); +WUPS_MODULE_VERSION("v1.0"); +WUPS_MODULE_AUTHOR("Maschell"); +WUPS_MODULE_LICENSE("GPL"); + +u8 isFirstBoot __attribute__((section(".data"))) = 1; + +u32 SplashScreen(s32 time,s32 combotime); + +/* Entry point */ +INITIALIZE(){ + if(gAppStatus == 2){ + log_printf("No, we don't want to patch stuff again."); + return; + } + gAppStatus = 0; + + InitOSFunctionPointers(); + InitSocketFunctionPointers(); //For logging + + + InitSysFunctionPointers(); // For SYSLaunchMenu() + InitProcUIFunctionPointers(); + + //For patching + InitVPadFunctionPointers(); + InitPadScoreFunctionPointers(); + InitAXFunctionPointers(); + InitGX2FunctionPointers(); + + memset(gVoiceInfos,0,sizeof(gVoiceInfos)); + + if(isFirstBoot){ // First boot back to SysMenu + u32 res = SplashScreen(10,2); + gButtonCombo = res; + isFirstBoot = 0; + } +} + +#define FPS 60 +u32 SplashScreen(s32 time,s32 combotime){ + u32 result = VPAD_BUTTON_TV; + // Prepare screen + s32 screen_buf0_size = 0; + + // Init screen and screen buffers + OSScreenInit(); + screen_buf0_size = OSScreenGetBufferSizeEx(0); + OSScreenSetBufferEx(0, (void *)0xF4000000); + OSScreenSetBufferEx(1, (void *)(0xF4000000 + screen_buf0_size)); + + OSScreenEnableEx(0, 1); + OSScreenEnableEx(1, 1); + + // Clear screens + OSScreenClearBufferEx(0, 0); + OSScreenClearBufferEx(1, 0); + + // Flip buffers + OSScreenFlipBuffersEx(0); + OSScreenFlipBuffersEx(1); + + u8 pos = 0; + OSScreenPutFontEx(0, 0, pos++,"SwipSwapMe 0.2 - by Maschell."); + OSScreenPutFontEx(1, 0, pos,"SwipSwapMe 0.2 - by Maschell."); + OSScreenPutFontEx(0, 0, pos,""); + OSScreenPutFontEx(1, 0, pos++,""); + OSScreenPutFontEx(0, 0, pos,""); + OSScreenPutFontEx(1, 0, pos++,""); + OSScreenPutFontEx(0, 0, pos,"Press the combo you want to use for swapping now for 2 seconds."); + OSScreenPutFontEx(1, 0, pos++,"Press the combo you want to use for swapping now for 2 seconds."); + OSScreenPutFontEx(0, 0, pos,"Pressing the TV button will return directly."); + OSScreenPutFontEx(1, 0, pos++,"Pressing the TV button will return directly."); + OSScreenPutFontEx(0, 0, pos,""); + OSScreenPutFontEx(1, 0, pos++,""); + OSScreenPutFontEx(0, 0, pos,"Otherwise the default combo (TV button) will be used in 10 seconds."); + OSScreenPutFontEx(1, 0, pos++,"Otherwise the default combo (TV button) will be used in 10 seconds."); + + 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= combotime*FPS){ + result = vpad_data.btns_h; + break; + } + i++; + os_usleep(sleepingtime*1000); + } + return result; +} diff --git a/plugins/swapdrc/src/utils/voice_info.h b/plugins/swapdrc/src/utils/voice_info.h new file mode 100644 index 0000000..5c40300 --- /dev/null +++ b/plugins/swapdrc/src/utils/voice_info.h @@ -0,0 +1,30 @@ +/**************************************************************************** + * 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 . + ****************************************************************************/ +#ifndef _VOICE_INFO_H_ +#define _VOICE_INFO_H_ + +#include + +#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_ diff --git a/plugins/swapdrc/src/utils/voice_swapper.c b/plugins/swapdrc/src/utils/voice_swapper.c new file mode 100644 index 0000000..1a218f2 --- /dev/null +++ b/plugins/swapdrc/src/utils/voice_swapper.c @@ -0,0 +1,64 @@ +/**************************************************************************** + * 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 . + ****************************************************************************/ + +#include "voice_info.h" +#include "voice_swapper.h" + +void VoiceSwapper_acquireVoice(void * voice){ + for(int i = 0;i. + ****************************************************************************/ +#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 +#include + +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_