mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2025-01-11 09:09:06 +01:00
[Plugin] Added a port of SwapDRC (SwipSwapMe)
This commit is contained in:
parent
38e045e41d
commit
8c0a3c965b
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@ loader/WiiUPluginLoader.cscope_file_list
|
||||
loader/WiiUPluginLoader.layout
|
||||
|
||||
*.mod
|
||||
*.cbp
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
291
plugins/swapdrc/Makefile
Normal file
291
plugins/swapdrc/Makefile
Normal file
@ -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=<path to>devkitPPC")
|
||||
endif
|
||||
ifeq ($(strip $(DEVKITPRO)),)
|
||||
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>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
|
||||
#---------------------------------------------------------------------------------
|
24
plugins/swapdrc/src/common/c_retain_vars.cpp
Normal file
24
plugins/swapdrc/src/common/c_retain_vars.cpp
Normal file
@ -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 <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")));
|
27
plugins/swapdrc/src/common/c_retain_vars.h
Normal file
27
plugins/swapdrc/src/common/c_retain_vars.h
Normal file
@ -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 <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_
|
128
plugins/swapdrc/src/function_patcher.c
Normal file
128
plugins/swapdrc/src/function_patcher.c
Normal file
@ -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 <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;
|
||||
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);
|
145
plugins/swapdrc/src/main.c
Normal file
145
plugins/swapdrc/src/main.c
Normal file
@ -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 <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <wups.h>
|
||||
|
||||
#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_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<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);
|
||||
}
|
||||
return result;
|
||||
}
|
30
plugins/swapdrc/src/utils/voice_info.h
Normal file
30
plugins/swapdrc/src/utils/voice_info.h
Normal file
@ -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 <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_
|
64
plugins/swapdrc/src/utils/voice_swapper.c
Normal file
64
plugins/swapdrc/src/utils/voice_swapper.c
Normal file
@ -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 <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));
|
||||
}
|
||||
}
|
37
plugins/swapdrc/src/utils/voice_swapper.h
Normal file
37
plugins/swapdrc/src/utils/voice_swapper.h
Normal file
@ -0,0 +1,37 @@
|
||||
/****************************************************************************
|
||||
* 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…
x
Reference in New Issue
Block a user