Upload files

RPX Channel Files
This commit is contained in:
xhp-creations 2017-01-04 10:33:05 -05:00
parent 2bf59b2557
commit c7c59554c5
95 changed files with 1266 additions and 2243 deletions

View File

@ -9,6 +9,9 @@ endif
ifeq ($(strip $(DEVKITPRO)),) ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO") $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
endif endif
ifeq ($(strip $(WUT_ROOT)),)
$(error "Please ensure WUT_ROOT is in your environment.")
endif
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
export LIBOGC_INC := $(DEVKITPRO)/libogc/include export LIBOGC_INC := $(DEVKITPRO)/libogc/include
export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii export LIBOGC_LIB := $(DEVKITPRO)/libogc/lib/wii
@ -22,6 +25,8 @@ export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy export OBJCOPY := $(PREFIX)objcopy
export ELF2RPL := $(WUT_ROOT)/bin/elf2rpl
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# TARGET is the name of the output # TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed # BUILD is the directory where object files & intermediate files will be placed
@ -32,13 +37,16 @@ TARGET := gx2_template
BUILD := build BUILD := build
BUILD_DBG := $(TARGET)_dbg BUILD_DBG := $(TARGET)_dbg
SOURCES := src \ SOURCES := src \
src/common \
src/dynamic_libs \ src/dynamic_libs \
src/fs \ src/fs \
src/game \ src/game \
src/gui \ src/gui \
src/loader \
src/menu \ src/menu \
src/network \
src/patcher \
src/resources \ src/resources \
src/settings \
src/sounds \ src/sounds \
src/system \ src/system \
src/utils \ src/utils \
@ -59,7 +67,10 @@ CFLAGS := -std=gnu11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \ CXXFLAGS := -std=gnu++11 -mrvl -mcpu=750 -meabi -mhard-float -ffast-math \
-O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE) -O3 -Wall -Wextra -Wno-unused-parameter -Wno-strict-aliasing $(INCLUDE)
ASFLAGS := -mregnames ASFLAGS := -mregnames
LDFLAGS := -nostartfiles -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,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,--gc-sections LDFLAGS := -nostartfiles -T $(WUT_ROOT)/rules/rpl.ld -pie -fPIE -z common-page-size=64 -z max-page-size=64 -lcrt \
-Wl,-wrap,malloc,-wrap,free,-wrap,memalign,-wrap,calloc,-wrap,realloc,-wrap,malloc_usable_size \
-Wl,-wrap,_malloc_r,-wrap,_free_r,-wrap,_realloc_r,-wrap,_calloc_r,-wrap,_memalign_r,-wrap,_malloc_usable_size_r \
-Wl,-wrap,valloc,-wrap,_valloc_r,-wrap,_pvalloc_r,-wrap,__eabi -Wl,--gc-sections
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
Q := @ Q := @
@ -67,16 +78,16 @@ MAKEFLAGS += --no-print-directory
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project # any extra libraries we wish to link with the project
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
LIBS := -lgcc -lgd -lpng -ljpeg -lz -lfreetype -lmad -lvorbisidec LIBS := -lcrt -lcoreinit -lproc_ui -lnsysnet -lsndcore2 -lvpad -lgx2 -lsysapp -lgd -lpng -lz -lfreetype -lmad -lvorbisidec
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing # list of directories containing libraries, this must be the top level containing
# include and lib # include and lib
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
LIBDIRS := $(CURDIR) \ LIBDIRS := $(CURDIR) \
$(DEVKITPPC)/lib \ $(DEVKITPPC)/ \
$(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2 $(DEVKITPPC)/lib/gcc/powerpc-eabi/4.8.2 \
$(WUT_ROOT)/lib
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional # no real need to edit anything past this point unless you need to add additional
@ -119,14 +130,13 @@ export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
# build a list of include paths # build a list of include paths
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \ -I$(CURDIR)/$(BUILD) -I$(WUT_ROOT)/include \
-I$(CURDIR)/$(BUILD) -I$(LIBOGC_INC) \
-I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2 -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# build a list of library paths # build a list of library paths
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)) \
-L$(LIBOGC_LIB) -L$(PORTLIBS)/lib -L$(LIBOGC_LIB) -L$(PORTLIBS)/lib
export OUTPUT := $(CURDIR)/$(TARGET) export OUTPUT := $(CURDIR)/$(TARGET)
@ -135,12 +145,29 @@ export OUTPUT := $(CURDIR)/$(TARGET)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
$(BUILD): $(BUILD):
@[ -d $@ ] || mkdir -p $@ @[ -d $@ ] || mkdir -p $@
# @$(Q)$(MAKE) -C sd_loader
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
clean: clean: clean_channel
@echo clean ... @echo clean ...
@rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).bin $(BUILD_DBG).elf $(OUTPUT).rpx
# @$(MAKE) -C sd_loader clean
#---------------------------------------------------------------------------------
install_channel: $(BUILD) NUSPacker.jar encryptKeyWith
@cp $(OUTPUT).rpx channel/code/
java -jar NUSPacker.jar -in "channel" -out "install_channel"
NUSPacker.jar:
wget https://bitbucket.org/timogus/nuspacker/downloads/NUSPacker.jar
encryptKeyWith:
@echo "Missing common key file \"encryptKeyWith\"! Insert the common key as string into \"encryptKeyWith\" file in the HBL Makefile path!"
@exit 1
clean_channel:
@rm -fr install_channel NUSPacker.jar fst.bin output tmp
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
else else
@ -150,19 +177,23 @@ DEPENDS := $(OFILES:.o=.d)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# main targets # main targets
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
$(OUTPUT).rpx: $(OUTPUT).elf
$(OUTPUT).elf: $(OFILES) $(OUTPUT).elf: $(OFILES)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# This rule links in binary data with the .jpg extension # This rule links in binary data with the .jpg extension
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
%.elf: link.ld $(OFILES) %.elf: $(OFILES)
@echo "linking ... $(TARGET).elf" @echo "linking ... $(TARGET).elf"
$(Q)$(LD) -n -T $^ $(LDFLAGS) -o ../$(BUILD_DBG).elf $(LIBPATHS) $(LIBS) $(Q)$(LD) $^ $(LDFLAGS) -o $@ $(LIBPATHS) $(LIBS)
$(Q)$(OBJCOPY) -S -R .comment -R .gnu.attributes ../$(BUILD_DBG).elf $@ # $(Q)$(OBJCOPY) -S -R .comment -R .gnu.attributes ../$(BUILD_DBG).elf $@
#---------------------------------------------------------------------------------
%.rpx: %.elf
#---------------------------------------------------------------------------------
@echo "[RPX] $(notdir $@)"
@$(ELF2RPL) $^ $@
../data/loader.bin:
$(MAKE) -C ../loader clean
$(MAKE) -C ../loader
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
%.a: %.a:
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
@ -220,6 +251,11 @@ $(OUTPUT).elf: $(OFILES)
@echo $(notdir $<) @echo $(notdir $<)
@bin2s -a 32 $< | $(AS) -o $(@) @bin2s -a 32 $< | $(AS) -o $(@)
#---------------------------------------------------------------------------------
%.dsp.o : %.dsp
@echo $(notdir $<)
@bin2s -a 32 $< | $(AS) -o $(@)
-include $(DEPENDS) -include $(DEPENDS)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

11
channel/code/app.xml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<app type="complex" access="777">
<version type="unsignedInt" length="4">1</version>
<os_version type="hexBinary" length="8">000500101000400A</os_version>
<title_id type="hexBinary" length="8">0005000011999900</title_id>
<title_version type="hexBinary" length="2">0000</title_version>
<sdk_version type="unsignedInt" length="4">20811</sdk_version>
<app_type type="hexBinary" length="4">80000000</app_type>
<group_id type="hexBinary" length="4">00009999</group_id>
<os_mask type="hexBinary" length="32">0000000000000000000000000000000000000000000000000000000000000000</os_mask>
</app>

97
channel/code/cos.xml Normal file
View File

@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<app type="complex" access="777">
<version type="unsignedInt" length="4">1</version>
<cmdFlags type="unsignedInt" length="4">0</cmdFlags>
<argstr type="string" length="4096">gx2_template.rpx</argstr>
<avail_size type="hexBinary" length="4">00000000</avail_size>
<codegen_size type="hexBinary" length="4">00000000</codegen_size>
<codegen_core type="hexBinary" length="4">00000001</codegen_core>
<max_size type="hexBinary" length="4">40000000</max_size>
<max_codesize type="hexBinary" length="4">01000000</max_codesize>
<permissions type="complex">
<p0 type="complex">
<group type="unsignedInt" length="4">1</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p0>
<!--BSP-->
<p1 type="complex">
<group type="unsignedInt" length="4">3</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p1>
<!--DK -->
<p2 type="complex">
<group type="unsignedInt" length="4">9</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p2>
<!--USB CLS DRV-->
<p3 type="complex">
<group type="unsignedInt" length="4">12</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p3>
<!--UHS-->
<p4 type="complex">
<group type="unsignedInt" length="4">11</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p4>
<!--FS -->
<p5 type="complex">
<group type="unsignedInt" length="4">13</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p5>
<!--MCP-->
<p6 type="complex">
<group type="unsignedInt" length="4">14</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p6>
<!--NIM-->
<p7 type="complex">
<group type="unsignedInt" length="4">15</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p7>
<!--ACT (account)-->
<p8 type="complex">
<group type="unsignedInt" length="4">16</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p8>
<!--FPD-->
<p9 type="complex">
<group type="unsignedInt" length="4">17</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p9>
<!--BOSS-->
<p10 type="complex">
<group type="unsignedInt" length="4">18</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p10>
<!--ACP-->
<p11 type="complex">
<group type="unsignedInt" length="4">19</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p11>
<!--PDM-->
<p12 type="complex">
<group type="unsignedInt" length="4">20</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p12>
<!--AC-->
<p13 type="complex">
<group type="unsignedInt" length="4">21</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p13>
<!--NDM-->
<p14 type="complex">
<group type="unsignedInt" length="4">22</group>
<mask type="hexBinary" length="8">FFFFFFFFFFFFFFFF</mask>
</p14>
<!--NSEC-->
</permissions>
<default_stack0_size type="hexBinary" length="4">00000000</default_stack0_size>
<default_stack1_size type="hexBinary" length="4">00000000</default_stack1_size>
<default_stack2_size type="hexBinary" length="4">00000000</default_stack2_size>
<default_redzone0_size type="hexBinary" length="4">00000000</default_redzone0_size>
<default_redzone1_size type="hexBinary" length="4">00000000</default_redzone1_size>
<default_redzone2_size type="hexBinary" length="4">00000000</default_redzone2_size>
<exception_stack0_size type="hexBinary" length="4">00001000</exception_stack0_size>
<exception_stack1_size type="hexBinary" length="4">00001000</exception_stack1_size>
<exception_stack2_size type="hexBinary" length="4">00001000</exception_stack2_size>
</app>

1
channel/content/dummy Normal file
View File

@ -0,0 +1 @@
s

BIN
channel/meta/bootDrcTex.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
channel/meta/bootMovie.h264 Normal file

Binary file not shown.

Binary file not shown.

BIN
channel/meta/bootTvTex.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 MiB

BIN
channel/meta/iconTex.tga Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

140
channel/meta/meta.xml Normal file
View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="utf-8"?>
<menu type="complex" access="777">
<version type="unsignedInt" length="4">1</version>
<product_code type="string" length="32">WUP-N-GXGE</product_code>
<content_platform type="string" length="32">WUP</content_platform>
<company_code type="string" length="8">0001</company_code>
<mastering_date type="string" length="32"></mastering_date>
<logo_type type="unsignedInt" length="4">0</logo_type>
<app_launch_type type="hexBinary" length="4">00000000</app_launch_type>
<invisible_flag type="hexBinary" length="4">00000000</invisible_flag>
<no_managed_flag type="hexBinary" length="4">00000000</no_managed_flag>
<no_event_log type="hexBinary" length="4">00000000</no_event_log>
<no_icon_database type="hexBinary" length="4">00000000</no_icon_database>
<launching_flag type="hexBinary" length="4">00000004</launching_flag>
<install_flag type="hexBinary" length="4">00000000</install_flag>
<closing_msg type="unsignedInt" length="4">1</closing_msg>
<title_version type="unsignedInt" length="4">0</title_version>
<title_id type="hexBinary" length="8">0005000011999900</title_id>
<group_id type="hexBinary" length="4">00009999</group_id>
<boss_id type="hexBinary" length="8">0000000000000000</boss_id>
<os_version type="hexBinary" length="8">000500101000400A</os_version>
<app_size type="hexBinary" length="8">0000000000000000</app_size>
<common_save_size type="hexBinary" length="8">0000000001790000</common_save_size>
<account_save_size type="hexBinary" length="8">0000000000000000</account_save_size>
<common_boss_size type="hexBinary" length="8">0000000000000000</common_boss_size>
<account_boss_size type="hexBinary" length="8">0000000000000000</account_boss_size>
<save_no_rollback type="unsignedInt" length="4">0</save_no_rollback>
<join_game_id type="hexBinary" length="4">00000000</join_game_id>
<join_game_mode_mask type="hexBinary" length="8">0000000000000000</join_game_mode_mask>
<bg_daemon_enable type="unsignedInt" length="4">1</bg_daemon_enable>
<olv_accesskey type="unsignedInt" length="4">0</olv_accesskey>
<wood_tin type="unsignedInt" length="4">0</wood_tin>
<e_manual type="unsignedInt" length="4">0</e_manual>
<e_manual_version type="unsignedInt" length="4">0</e_manual_version>
<region type="hexBinary" length="4">FFFFFFFF</region>
<pc_cero type="unsignedInt" length="4">128</pc_cero>
<pc_esrb type="unsignedInt" length="4">128</pc_esrb>
<pc_bbfc type="unsignedInt" length="4">192</pc_bbfc>
<pc_usk type="unsignedInt" length="4">128</pc_usk>
<pc_pegi_gen type="unsignedInt" length="4">128</pc_pegi_gen>
<pc_pegi_fin type="unsignedInt" length="4">192</pc_pegi_fin>
<pc_pegi_prt type="unsignedInt" length="4">128</pc_pegi_prt>
<pc_pegi_bbfc type="unsignedInt" length="4">128</pc_pegi_bbfc>
<pc_cob type="unsignedInt" length="4">128</pc_cob>
<pc_grb type="unsignedInt" length="4">128</pc_grb>
<pc_cgsrr type="unsignedInt" length="4">128</pc_cgsrr>
<pc_oflc type="unsignedInt" length="4">128</pc_oflc>
<pc_reserved0 type="unsignedInt" length="4">192</pc_reserved0>
<pc_reserved1 type="unsignedInt" length="4">192</pc_reserved1>
<pc_reserved2 type="unsignedInt" length="4">192</pc_reserved2>
<pc_reserved3 type="unsignedInt" length="4">192</pc_reserved3>
<ext_dev_nunchaku type="unsignedInt" length="4">1</ext_dev_nunchaku>
<ext_dev_classic type="unsignedInt" length="4">0</ext_dev_classic>
<ext_dev_urcc type="unsignedInt" length="4">1</ext_dev_urcc>
<ext_dev_board type="unsignedInt" length="4">0</ext_dev_board>
<ext_dev_usb_keyboard type="unsignedInt" length="4">1</ext_dev_usb_keyboard>
<ext_dev_etc type="unsignedInt" length="4">0</ext_dev_etc>
<ext_dev_etc_name type="string" length="512"></ext_dev_etc_name>
<eula_version type="unsignedInt" length="4">0</eula_version>
<drc_use type="unsignedInt" length="4">1</drc_use>
<network_use type="unsignedInt" length="4">1</network_use>
<online_account_use type="unsignedInt" length="4">0</online_account_use>
<direct_boot type="unsignedInt" length="4">0</direct_boot>
<reserved_flag0 type="hexBinary" length="4">00010001</reserved_flag0>
<reserved_flag1 type="hexBinary" length="4">00000000</reserved_flag1>
<reserved_flag2 type="hexBinary" length="4">00000000</reserved_flag2>
<reserved_flag3 type="hexBinary" length="4">00000000</reserved_flag3>
<reserved_flag4 type="hexBinary" length="4">00000000</reserved_flag4>
<reserved_flag5 type="hexBinary" length="4">00000000</reserved_flag5>
<reserved_flag6 type="hexBinary" length="4">00000003</reserved_flag6>
<reserved_flag7 type="hexBinary" length="4">00000000</reserved_flag7>
<longname_ja type="string" length="512">GX2 GUI Template</longname_ja>
<longname_en type="string" length="512">GX2 GUI Template</longname_en>
<longname_fr type="string" length="512">GX2 GUI Template</longname_fr>
<longname_de type="string" length="512">GX2 GUI Template</longname_de>
<longname_it type="string" length="512">GX2 GUI Template</longname_it>
<longname_es type="string" length="512">GX2 GUI Template</longname_es>
<longname_zhs type="string" length="512">GX2 GUI Template</longname_zhs>
<longname_ko type="string" length="512">GX2 GUI Template</longname_ko>
<longname_nl type="string" length="512">GX2 GUI Template</longname_nl>
<longname_pt type="string" length="512">GX2 GUI Template</longname_pt>
<longname_ru type="string" length="512">GX2 GUI Template</longname_ru>
<longname_zht type="string" length="512">GX2 GUI Template</longname_zht>
<shortname_ja type="string" length="256">GX2 GUI Template</shortname_ja>
<shortname_en type="string" length="256">GX2 GUI Template</shortname_en>
<shortname_fr type="string" length="256">GX2 GUI Template</shortname_fr>
<shortname_de type="string" length="256">GX2 GUI Template</shortname_de>
<shortname_it type="string" length="256">GX2 GUI Template</shortname_it>
<shortname_es type="string" length="256">GX2 GUI Template</shortname_es>
<shortname_zhs type="string" length="256">GX2 GUI Template</shortname_zhs>
<shortname_ko type="string" length="256">GX2 GUI Template</shortname_ko>
<shortname_nl type="string" length="256">GX2 GUI Template</shortname_nl>
<shortname_pt type="string" length="256">GX2 GUI Template</shortname_pt>
<shortname_ru type="string" length="256">GX2 GUI Template</shortname_ru>
<shortname_zht type="string" length="256">GX2 GUI Template</shortname_zht>
<publisher_ja type="string" length="256">Maschell</publisher_ja>
<publisher_en type="string" length="256">Maschell</publisher_en>
<publisher_fr type="string" length="256">Maschell</publisher_fr>
<publisher_de type="string" length="256">Maschell</publisher_de>
<publisher_it type="string" length="256">Maschell</publisher_it>
<publisher_es type="string" length="256">Maschell</publisher_es>
<publisher_zhs type="string" length="256">Maschell</publisher_zhs>
<publisher_ko type="string" length="256">Maschell</publisher_ko>
<publisher_nl type="string" length="256">Maschell</publisher_nl>
<publisher_pt type="string" length="256">Maschell</publisher_pt>
<publisher_ru type="string" length="256">Maschell</publisher_ru>
<publisher_zht type="string" length="256">Maschell</publisher_zht>
<add_on_unique_id0 type="hexBinary" length="4">00000000</add_on_unique_id0>
<add_on_unique_id1 type="hexBinary" length="4">00000000</add_on_unique_id1>
<add_on_unique_id2 type="hexBinary" length="4">00000000</add_on_unique_id2>
<add_on_unique_id3 type="hexBinary" length="4">00000000</add_on_unique_id3>
<add_on_unique_id4 type="hexBinary" length="4">00000000</add_on_unique_id4>
<add_on_unique_id5 type="hexBinary" length="4">00000000</add_on_unique_id5>
<add_on_unique_id6 type="hexBinary" length="4">00000000</add_on_unique_id6>
<add_on_unique_id7 type="hexBinary" length="4">00000000</add_on_unique_id7>
<add_on_unique_id8 type="hexBinary" length="4">00000000</add_on_unique_id8>
<add_on_unique_id9 type="hexBinary" length="4">00000000</add_on_unique_id9>
<add_on_unique_id10 type="hexBinary" length="4">00000000</add_on_unique_id10>
<add_on_unique_id11 type="hexBinary" length="4">00000000</add_on_unique_id11>
<add_on_unique_id12 type="hexBinary" length="4">00000000</add_on_unique_id12>
<add_on_unique_id13 type="hexBinary" length="4">00000000</add_on_unique_id13>
<add_on_unique_id14 type="hexBinary" length="4">00000000</add_on_unique_id14>
<add_on_unique_id15 type="hexBinary" length="4">00000000</add_on_unique_id15>
<add_on_unique_id16 type="hexBinary" length="4">00000000</add_on_unique_id16>
<add_on_unique_id17 type="hexBinary" length="4">00000000</add_on_unique_id17>
<add_on_unique_id18 type="hexBinary" length="4">00000000</add_on_unique_id18>
<add_on_unique_id19 type="hexBinary" length="4">00000000</add_on_unique_id19>
<add_on_unique_id20 type="hexBinary" length="4">00000000</add_on_unique_id20>
<add_on_unique_id21 type="hexBinary" length="4">00000000</add_on_unique_id21>
<add_on_unique_id22 type="hexBinary" length="4">00000000</add_on_unique_id22>
<add_on_unique_id23 type="hexBinary" length="4">00000000</add_on_unique_id23>
<add_on_unique_id24 type="hexBinary" length="4">00000000</add_on_unique_id24>
<add_on_unique_id25 type="hexBinary" length="4">00000000</add_on_unique_id25>
<add_on_unique_id26 type="hexBinary" length="4">00000000</add_on_unique_id26>
<add_on_unique_id27 type="hexBinary" length="4">00000000</add_on_unique_id27>
<add_on_unique_id28 type="hexBinary" length="4">00000000</add_on_unique_id28>
<add_on_unique_id29 type="hexBinary" length="4">00000000</add_on_unique_id29>
<add_on_unique_id30 type="hexBinary" length="4">00000000</add_on_unique_id30>
<add_on_unique_id31 type="hexBinary" length="4">00000000</add_on_unique_id31>
</menu>

View File

@ -42,15 +42,13 @@ cat <<EOF > $outFile
#ifndef _FILELIST_H_ #ifndef _FILELIST_H_
#define _FILELIST_H_ #define _FILELIST_H_
#include <gctypes.h>
typedef struct _RecourceFile typedef struct _RecourceFile
{ {
const char *filename; const char *filename;
const u8 *DefaultFile; const unsigned char *DefaultFile;
const u32 &DefaultFileSize; const unsigned int &DefaultFileSize;
u8 *CustomFile; unsigned char *CustomFile;
u32 CustomFileSize; unsigned int CustomFileSize;
} RecourceFile; } RecourceFile;
EOF EOF
@ -59,8 +57,8 @@ for i in ${files[@]}
do do
filename=${i%.*} filename=${i%.*}
extension=${i##*.} extension=${i##*.}
echo 'extern const u8 '$filename'_'$extension'[];' >> $outFile echo 'extern const unsigned char '$filename'_'$extension'[];' >> $outFile
echo 'extern const u32 '$filename'_'$extension'_size;' >> $outFile echo 'extern const unsigned int '$filename'_'$extension'_size;' >> $outFile
echo '' >> $outFile echo '' >> $outFile
done done

Binary file not shown.

Binary file not shown.

View File

@ -14,24 +14,30 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include <coreinit/core.h>
#include <coreinit/foreground.h>
#include <proc_ui/procui.h>
#include <sysapp/launch.h>
#include "Application.h" #include "Application.h"
#include "common/common.h" #include "common/common.h"
#include "dynamic_libs/os_functions.h"
#include "gui/FreeTypeGX.h" #include "gui/FreeTypeGX.h"
#include "gui/VPadController.h" #include "gui/VPadController.h"
#include "gui/WPadController.h" #include "gui/WPadController.h"
#include "resources/Resources.h" #include "resources/Resources.h"
#include "sounds/SoundHandler.hpp" #include "sounds/SoundHandler.hpp"
#include "system/memory.h"
#include "utils/logger.h" #include "utils/logger.h"
Application *Application::applicationInstance = NULL; Application *Application::applicationInstance = NULL;
bool Application::exitApplication = false; bool Application::exitApplication = false;
bool Application::quitRequest = false;
Application::Application() Application::Application()
: CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x20000) : CThread(CThread::eAttributeAffCore1 | CThread::eAttributePinnedAff, 0, 0x20000)
, bgMusic(NULL) , bgMusic(NULL)
, video(NULL) , video(NULL)
, mainWindow(NULL) , mainWindow(NULL)
, fontSystem(NULL)
, exitCode(EXIT_RELAUNCH_ON_LOAD) , exitCode(EXIT_RELAUNCH_ON_LOAD)
{ {
controller[0] = new VPadController(GuiTrigger::CHANNEL_1); controller[0] = new VPadController(GuiTrigger::CHANNEL_1);
@ -39,18 +45,23 @@ Application::Application()
controller[2] = new WPadController(GuiTrigger::CHANNEL_3); controller[2] = new WPadController(GuiTrigger::CHANNEL_3);
controller[3] = new WPadController(GuiTrigger::CHANNEL_4); controller[3] = new WPadController(GuiTrigger::CHANNEL_4);
controller[4] = new WPadController(GuiTrigger::CHANNEL_5); controller[4] = new WPadController(GuiTrigger::CHANNEL_5);
//! load resources
Resources::LoadFiles("fs:/vol/content");
//! create bgMusic //! create bgMusic
/*
bgMusic = new GuiSound(Resources::GetFile("bgMusic.ogg"), Resources::GetFileSize("bgMusic.ogg")); bgMusic = new GuiSound(Resources::GetFile("bgMusic.ogg"), Resources::GetFileSize("bgMusic.ogg"));
bgMusic->SetLoop(true); bgMusic->SetLoop(true);
bgMusic->Play(); bgMusic->Play();
bgMusic->SetVolume(50);*/ bgMusic->SetVolume(50);
exitApplication = false; exitApplication = false;
ProcUIInit(OSSavesDone_ReadyToRelease);
} }
Application::~Application(){ Application::~Application()
{
log_printf("Destroy music\n"); log_printf("Destroy music\n");
delete bgMusic; delete bgMusic;
@ -61,7 +72,6 @@ Application::~Application(){
delete controller[i]; delete controller[i];
log_printf("Destroy async deleter\n"); log_printf("Destroy async deleter\n");
AsyncDeleter::triggerDeleteProcess();
AsyncDeleter::destroyInstance(); AsyncDeleter::destroyInstance();
log_printf("Clear resources\n"); log_printf("Clear resources\n");
@ -69,9 +79,12 @@ Application::~Application(){
log_printf("Stop sound handler\n"); log_printf("Stop sound handler\n");
SoundHandler::DestroyInstance(); SoundHandler::DestroyInstance();
ProcUIShutdown();
} }
int Application::exec(){ int Application::exec()
{
//! start main GX2 thread //! start main GX2 thread
resumeThread(); resumeThread();
//! now wait for thread to finish //! now wait for thread to finish
@ -80,7 +93,15 @@ int Application::exec(){
return exitCode; return exitCode;
} }
void Application::fadeOut(){ void Application::quit(int code)
{
exitCode = code;
exitApplication = true;
quitRequest = true;
}
void Application::fadeOut()
{
GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){ 0, 0, 0, 255 }); GuiImage fadeOut(video->getTvWidth(), video->getTvHeight(), (GX2Color){ 0, 0, 0, 255 });
for(int i = 0; i < 255; i += 10) for(int i = 0; i < 255; i += 10)
@ -94,9 +115,9 @@ void Application::fadeOut(){
video->prepareDrcRendering(); video->prepareDrcRendering();
mainWindow->drawDrc(video); mainWindow->drawDrc(video);
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_ALWAYS); GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_ALWAYS);
fadeOut.draw(video); fadeOut.draw(video);
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL);
video->drcDrawDone(); video->drcDrawDone();
@ -105,9 +126,9 @@ void Application::fadeOut(){
mainWindow->drawTv(video); mainWindow->drawTv(video);
GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_ALWAYS); GX2SetDepthOnlyControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_ALWAYS);
fadeOut.draw(video); fadeOut.draw(video);
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL);
video->tvDrawDone(); video->tvDrawDone();
@ -127,36 +148,101 @@ void Application::fadeOut(){
video->drcEnable(false); video->drcEnable(false);
} }
void Application::executeThread(void){ bool Application::procUI(void)
log_printf("Initialize video\n"); {
video = new CVideo(GX2_TV_SCAN_MODE_720P, GX2_DRC_SINGLE); bool executeProcess = false;
log_printf("Video size %i x %i\n", video->getTvWidth(), video->getTvHeight()); switch(ProcUIProcessMessages(true))
{
case PROCUI_STATUS_EXITING:
{
log_printf("PROCUI_STATUS_EXITING\n");
exitCode = EXIT_SUCCESS;
exitApplication = true;
break;
}
case PROCUI_STATUS_RELEASE_FOREGROUND:
{
log_printf("PROCUI_STATUS_RELEASE_FOREGROUND\n");
if(video != NULL)
{
// we can turn of the screen but we don't need to and it will display the last image
video->tvEnable(true);
video->drcEnable(true);
//! setup default Font log_printf("delete fontSystem\n");
log_printf("Initialize main font system\n"); delete fontSystem;
FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true); fontSystem = NULL;
GuiText::setPresetFont(fontSystem);
log_printf("Initialize main window\n"); log_printf("delete video\n");
delete video;
video = NULL;
mainWindow = new MainWindow(video->getTvWidth(), video->getTvHeight()); log_printf("deinitialze memory\n");
memoryRelease();
ProcUIDrawDoneRelease();
}
else
{
ProcUIDrawDoneRelease();
}
break;
}
case PROCUI_STATUS_IN_FOREGROUND:
{
if(!quitRequest)
{
if(video == NULL)
{
log_printf("PROCUI_STATUS_IN_FOREGROUND\n");
log_printf("initialze memory\n");
memoryInitialize();
log_printf("Initialize video\n");
video = new CVideo(GX2_TV_SCAN_MODE_720P, GX2_DRC_RENDER_MODE_SINGLE);
log_printf("Video size %i x %i\n", video->getTvWidth(), video->getTvHeight());
//! setup default Font
log_printf("Initialize main font system\n");
FreeTypeGX *fontSystem = new FreeTypeGX(Resources::GetFile("font.ttf"), Resources::GetFileSize("font.ttf"), true);
GuiText::setPresetFont(fontSystem);
if(mainWindow == NULL)
{
log_printf("Initialize main window\n");
mainWindow = new MainWindow(video->getTvWidth(), video->getTvHeight());
}
}
executeProcess = true;
}
break;
}
case PROCUI_STATUS_IN_BACKGROUND:
default:
break;
}
return executeProcess;
}
void Application::executeThread(void)
{
log_printf("Entering main loop\n"); log_printf("Entering main loop\n");
//! main GX2 loop (60 Hz cycle with max priority on core 1) //! main GX2 loop (60 Hz cycle with max priority on core 1)
while(!exitApplication) while(!exitApplication)
{ {
if(procUI() == false)
continue;
//! Read out inputs //! Read out inputs
for(int i = 0; i < 5; i++) for(int i = 0; i < 5; i++)
{ {
if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false) if(controller[i]->update(video->getTvWidth(), video->getTvHeight()) == false)
continue; continue;
if(controller[i]->data.buttons_d & VPAD_BUTTON_HOME){
exitApplication = true;
}
//! update controller states //! update controller states
mainWindow->update(controller[i]); mainWindow->update(controller[i]);
} }
@ -190,9 +276,23 @@ void Application::executeThread(void){
AsyncDeleter::triggerDeleteProcess(); AsyncDeleter::triggerDeleteProcess();
} }
fadeOut(); if(video)
{
fadeOut();
}
log_printf("delete mainWindow\n");
delete mainWindow; delete mainWindow;
mainWindow = NULL;
log_printf("delete fontSystem\n");
delete fontSystem; delete fontSystem;
fontSystem = NULL;
log_printf("delete video\n");
delete video; delete video;
video = NULL;
log_printf("deinitialze memory\n");
memoryRelease();
} }

View File

@ -21,6 +21,9 @@
#include "video/CVideo.h" #include "video/CVideo.h"
#include "system/CThread.h" #include "system/CThread.h"
// forward declaration
class FreeTypeGX;
class Application : public CThread class Application : public CThread
{ {
public: public:
@ -50,22 +53,24 @@ public:
int exec(void); int exec(void);
void fadeOut(void); void fadeOut(void);
void quit(int code) { void quit(int code);
exitCode = code;
exitApplication = true;
}
private: private:
Application(); Application();
virtual ~Application(); virtual ~Application();
bool procUI(void);
static Application *applicationInstance; static Application *applicationInstance;
static bool exitApplication; static bool exitApplication;
static bool quitRequest;
void executeThread(void); void executeThread(void);
GuiSound *bgMusic; GuiSound *bgMusic;
CVideo *video; CVideo *video;
MainWindow *mainWindow; MainWindow *mainWindow;
FreeTypeGX *fontSystem;
GuiController *controller[5]; GuiController *controller[5];
int exitCode; int exitCode;
}; };

View File

@ -8,7 +8,7 @@ extern "C" {
#include "os_defs.h" #include "os_defs.h"
#define CAFE_OS_SD_PATH "/vol/external01" #define CAFE_OS_SD_PATH "/vol/external01"
#define SD_PATH "sd:" #define SD_PATH "fs:"
#define WIIU_PATH "/wiiu" #define WIIU_PATH "/wiiu"
/* Macros for libs */ /* Macros for libs */

177
src/common/gx2_ext.h Normal file
View File

@ -0,0 +1,177 @@
#ifndef __GX2_EXTENSION_H
#define __GX2_EXTENSION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gx2/draw.h>
#include <gx2/enum.h>
#include <gx2/mem.h>
#include <gx2/registers.h>
#include <gx2/sampler.h>
#include <gx2/shaders.h>
#include <gx2/surface.h>
#include <gx2/texture.h>
#define GX2_FALSE 0
#define GX2_TRUE 1
#define GX2_DISABLE 0
#define GX2_ENABLE 1
#define GX2_COMMAND_BUFFER_SIZE 0x400000
#define GX2_SCAN_BUFFER_ALIGNMENT 0x1000
#define GX2_CONTEXT_STATE_ALIGNMENT 0x100
#define GX2_SHADER_ALIGNMENT 0x100
#define GX2_VERTEX_BUFFER_ALIGNMENT 0x40
#define GX2_INDEX_BUFFER_ALIGNMENT 0x20
#define GX2_AA_BUFFER_CLEAR_VALUE 0xCC
#define GX2_COMP_SEL_NONE 0x04040405
#define GX2_COMP_SEL_X001 0x00040405
#define GX2_COMP_SEL_XY01 0x00010405
#define GX2_COMP_SEL_XYZ1 0x00010205
#define GX2_COMP_SEL_XYZW 0x00010203
#define GX2_COMP_SEL_XXXX 0x00000000
#define GX2_COMP_SEL_YYYY 0x01010101
#define GX2_COMP_SEL_ZZZZ 0x02020202
#define GX2_COMP_SEL_WWWW 0x03030303
#define GX2_COMP_SEL_WZYX 0x03020100
#define GX2_COMP_SEL_WXYZ 0x03000102
static const u32 attribute_dest_comp_selector[20] = {
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_X001,
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1,
GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW
};
static const u32 texture_comp_selector[54] = {
GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_X001,
GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
GX2_COMP_SEL_WZYX, GX2_COMP_SEL_X001, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01, GX2_COMP_SEL_NONE,
GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE,
GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_WZYX, GX2_COMP_SEL_XY01, GX2_COMP_SEL_XY01,
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW,
GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_X001,
GX2_COMP_SEL_XY01, GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_NONE, GX2_COMP_SEL_XYZ1,
GX2_COMP_SEL_XYZ1, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_XYZW, GX2_COMP_SEL_X001, GX2_COMP_SEL_XY01
};
typedef struct _GX2Color {
u8 r, g, b, a;
} GX2Color;
typedef struct _GX2ColorF32 {
f32 r, g, b, a;
} GX2ColorF32;
static inline void GX2InitDepthBuffer(GX2DepthBuffer *depthBuffer, GX2SurfaceDim dim, u32 width, u32 height, u32 depth, GX2SurfaceFormat format, GX2AAMode aa)
{
depthBuffer->surface.dim = dim;
depthBuffer->surface.width = width;
depthBuffer->surface.height = height;
depthBuffer->surface.depth = depth;
depthBuffer->surface.mipLevels = 1;
depthBuffer->surface.format = format;
depthBuffer->surface.aa = aa;
depthBuffer->surface.use = (GX2SurfaceUse)(((format==GX2_SURFACE_FORMAT_UNORM_R24_X8) || (format==GX2_SURFACE_FORMAT_FLOAT_D24_S8)) ?
GX2_SURFACE_USE_DEPTH_BUFFER : (GX2_SURFACE_USE_DEPTH_BUFFER | GX2_SURFACE_USE_TEXTURE));
depthBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT;
depthBuffer->surface.swizzle = 0;
depthBuffer->viewMip = 0;
depthBuffer->viewFirstSlice = 0;
depthBuffer->viewNumSlices = depth;
depthBuffer->depthClear = 1.0f;
depthBuffer->stencilClear = 0;
depthBuffer->hiZPtr = NULL;
depthBuffer->hiZSize = 0;
GX2CalcSurfaceSizeAndAlignment(&depthBuffer->surface);
GX2InitDepthBufferRegs(depthBuffer);
}
static inline void GX2InitColorBuffer(GX2ColorBuffer *colorBuffer, GX2SurfaceDim dim, u32 width, u32 height, u32 depth, GX2SurfaceFormat format, GX2AAMode aa)
{
colorBuffer->surface.dim = dim;
colorBuffer->surface.width = width;
colorBuffer->surface.height = height;
colorBuffer->surface.depth = depth;
colorBuffer->surface.mipLevels = 1;
colorBuffer->surface.format = format;
colorBuffer->surface.aa = aa;
colorBuffer->surface.use = GX2_SURFACE_USE_TEXTURE_COLOR_BUFFER_TV;
colorBuffer->surface.imageSize = 0;
colorBuffer->surface.image = NULL;
colorBuffer->surface.mipmapSize = 0;
colorBuffer->surface.mipmaps = NULL;
colorBuffer->surface.tileMode = GX2_TILE_MODE_DEFAULT;
colorBuffer->surface.swizzle = 0;
colorBuffer->surface.alignment = 0;
colorBuffer->surface.pitch = 0;
u32 i;
for(i = 0; i < 13; i++)
colorBuffer->surface.mipLevelOffset[i] = 0;
colorBuffer->viewMip = 0;
colorBuffer->viewFirstSlice = 0;
colorBuffer->viewNumSlices = depth;
colorBuffer->aaBuffer = NULL;
colorBuffer->aaSize = 0;
for(i = 0; i < 5; i++)
colorBuffer->regs[i] = 0;
GX2CalcSurfaceSizeAndAlignment(&colorBuffer->surface);
GX2InitColorBufferRegs(colorBuffer);
}
static inline void GX2InitAttribStream(GX2AttribStream* attr, u32 location, u32 buffer, u32 offset, GX2AttribFormat format)
{
attr->location = location;
attr->buffer = buffer;
attr->offset = offset;
attr->format = format;
attr->type = GX2_ATTRIB_INDEX_PER_VERTEX;
attr->aluDivisor = 0;
attr->mask = attribute_dest_comp_selector[format & 0xff];
attr->endianSwap = GX2_ENDIAN_SWAP_DEFAULT;
}
static inline void GX2InitTexture(GX2Texture *tex, u32 width, u32 height, u32 depth, u32 mipLevels, GX2SurfaceFormat format, GX2SurfaceDim dim, GX2TileMode tile)
{
tex->surface.dim = dim;
tex->surface.width = width;
tex->surface.height = height;
tex->surface.depth = depth;
tex->surface.mipLevels = mipLevels;
tex->surface.format = format;
tex->surface.aa = GX2_AA_MODE1X;
tex->surface.use = GX2_SURFACE_USE_TEXTURE;
tex->surface.imageSize = 0;
tex->surface.image = NULL;
tex->surface.mipmapSize = 0;
tex->surface.mipmaps = NULL;
tex->surface.tileMode = tile;
tex->surface.swizzle = 0;
tex->surface.alignment = 0;
tex->surface.pitch = 0;
u32 i;
for(i = 0; i < 13; i++)
tex->surface.mipLevelOffset[i] = 0;
tex->viewFirstMip = 0;
tex->viewNumMips = mipLevels;
tex->viewFirstSlice = 0;
tex->viewNumSlices = depth;
tex->compMap = texture_comp_selector[format & 0x3f];
for(i = 0; i < 5; i++)
tex->regs[i] = 0;
GX2CalcSurfaceSizeAndAlignment(&tex->surface);
GX2InitTextureRegs(tex);
}
#ifdef __cplusplus
}
#endif
#endif /* COMMON_H */

View File

@ -1,7 +1,7 @@
#ifndef TYPES_H #ifndef TYPES_H
#define TYPES_H #define TYPES_H
#include <gctypes.h> #include <wut_types.h>
#endif /* TYPES_H */ #endif /* TYPES_H */

View File

@ -1,11 +1,10 @@
#include <string.h> #include <string.h>
#include "dynamic_libs/os_functions.h" #include <coreinit/title.h>
#include "dynamic_libs/sys_functions.h"
#include "common/common.h" #include "common/common.h"
#include "utils/utils.h" #include "utils/utils.h"
#include "main.h" #include "main.h"
int __entry_menu(int argc, char **argv) int main(int argc, char **argv)
{ {
//! ******************************************************************* //! *******************************************************************
//! * Jump to our application * //! * Jump to our application *

View File

@ -2,7 +2,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "CFile.hpp" #include "CFile.hpp"
CFile::CFile() CFile::CFile()
{ {
iFd = -1; iFd = -1;

View File

@ -4,9 +4,9 @@
#include <stdio.h> #include <stdio.h>
#include <string> #include <string>
#include <string.h> #include <string.h>
#include <fcntl.h>
#include <gctypes.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h>
#include "common/types.h"
class CFile class CFile
{ {

View File

@ -39,11 +39,12 @@ DirList::DirList()
{ {
Flags = 0; Flags = 0;
Filter = 0; Filter = 0;
Depth = 0;
} }
DirList::DirList(const std::string & path, const char *filter, u32 flags) DirList::DirList(const std::string & path, const char *filter, u32 flags, u32 maxDepth)
{ {
this->LoadPath(path, filter, flags); this->LoadPath(path, filter, flags, maxDepth);
this->SortList(); this->SortList();
} }
@ -52,12 +53,13 @@ DirList::~DirList()
ClearList(); ClearList();
} }
bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags) bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags, u32 maxDepth)
{ {
if(folder.empty()) return false; if(folder.empty()) return false;
Flags = flags; Flags = flags;
Filter = filter; Filter = filter;
Depth = maxDepth;
std::string folderpath(folder); std::string folderpath(folder);
u32 length = folderpath.size(); u32 length = folderpath.size();
@ -69,6 +71,10 @@ bool DirList::LoadPath(const std::string & folder, const char *filter, u32 flags
if(length > 0 && folderpath[length-1] == '/') if(length > 0 && folderpath[length-1] == '/')
folderpath.erase(length-1); folderpath.erase(length-1);
//! add root slash if missing
if(folderpath.find('/') == std::string::npos)
folderpath += '/';
return InternalLoadPath(folderpath); return InternalLoadPath(folderpath);
} }
@ -94,14 +100,17 @@ bool DirList::InternalLoadPath(std::string &folderpath)
if(strcmp(filename,".") == 0 || strcmp(filename,"..") == 0) if(strcmp(filename,".") == 0 || strcmp(filename,"..") == 0)
continue; continue;
if(Flags & CheckSubfolders) if((Flags & CheckSubfolders) && (Depth > 0))
{ {
int length = folderpath.size(); int length = folderpath.size();
if(length > 2 && folderpath[length-1] != '/') if(length > 2 && folderpath[length-1] != '/')
folderpath += '/'; folderpath += '/';
folderpath += filename; folderpath += filename;
Depth--;
InternalLoadPath(folderpath); InternalLoadPath(folderpath);
folderpath.erase(length); folderpath.erase(length);
Depth++;
} }
if(!(Flags & Dirs)) if(!(Flags & Dirs))

View File

@ -29,7 +29,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <gctypes.h> #include "common/types.h"
typedef struct typedef struct
{ {
@ -45,11 +45,11 @@ public:
//!\param path Path from where to load the filelist of all files //!\param path Path from where to load the filelist of all files
//!\param filter A fileext that needs to be filtered //!\param filter A fileext that needs to be filtered
//!\param flags search/filter flags from the enum //!\param flags search/filter flags from the enum
DirList(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs); DirList(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs, u32 maxDepth = 0xffffffff);
//!Destructor //!Destructor
virtual ~DirList(); virtual ~DirList();
//! Load all the files from a directory //! Load all the files from a directory
bool LoadPath(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs); bool LoadPath(const std::string & path, const char *filter = NULL, u32 flags = Files | Dirs, u32 maxDepth = 0xffffffff);
//! Get a filename of the list //! Get a filename of the list
//!\param list index //!\param list index
const char * GetFilename(int index) const; const char * GetFilename(int index) const;
@ -88,6 +88,7 @@ protected:
inline bool valid(u32 pos) const { return (pos < FileInfo.size()); }; inline bool valid(u32 pos) const { return (pos < FileInfo.size()); };
u32 Flags; u32 Flags;
u32 Depth;
const char *Filter; const char *Filter;
std::vector<DirEntry> FileInfo; std::vector<DirEntry> FileInfo;
}; };

View File

@ -3,14 +3,15 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include "dynamic_libs/fs_defs.h" #include <coreinit/filesystem.h>
#include "dynamic_libs/fs_functions.h"
#define FS_MAX_MOUNTPATH_SIZE 128
int MountFS(void *pClient, void *pCmd, char **mount_path) int MountFS(void *pClient, void *pCmd, char **mount_path)
{ {
int result = -1; int result = -1;
void *mountSrc = malloc(FS_MOUNT_SOURCE_SIZE); void *mountSrc = malloc(sizeof(FSMountSource));
if(!mountSrc) if(!mountSrc)
return -3; return -3;
@ -20,11 +21,11 @@ int MountFS(void *pClient, void *pCmd, char **mount_path)
return -4; return -4;
} }
memset(mountSrc, 0, FS_MOUNT_SOURCE_SIZE); memset(mountSrc, 0, sizeof(FSMountSource));
memset(mountPath, 0, FS_MAX_MOUNTPATH_SIZE); memset(mountPath, 0, FS_MAX_MOUNTPATH_SIZE);
// Mount sdcard // Mount sdcard
if (FSGetMountSource(pClient, pCmd, FS_SOURCETYPE_EXTERNAL, mountSrc, -1) == 0) if (FSGetMountSource(pClient, pCmd, FS_MOUNT_SOURCE_SD, mountSrc, -1) == 0)
{ {
result = FSMount(pClient, pCmd, mountSrc, mountPath, FS_MAX_MOUNTPATH_SIZE, -1); result = FSMount(pClient, pCmd, mountSrc, mountPath, FS_MAX_MOUNTPATH_SIZE, -1);
if((result == 0) && mount_path) { if((result == 0) && mount_path) {

View File

@ -5,7 +5,7 @@
extern "C" { extern "C" {
#endif #endif
#include <gctypes.h> #include "common/types.h"
int MountFS(void *pClient, void *pCmd, char **mount_path); int MountFS(void *pClient, void *pCmd, char **mount_path);
int UmountFS(void *pClient, void *pCmd, const char *mountPath); int UmountFS(void *pClient, void *pCmd, const char *mountPath);

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +0,0 @@
/***************************************************************************
* Copyright (C) 2015
* by Dimok
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any
* damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any
* purpose, including commercial applications, and to alter it and
* redistribute it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you
* must not claim that you wrote the original software. If you use
* this software in a product, an acknowledgment in the product
* documentation would be appreciated but is not required.
*
* 2. Altered source versions must be plainly marked as such, and
* must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any source
* distribution.
***************************************************************************/
#ifndef __SD_FAT_DEVOPTAB_H_
#define __SD_FAT_DEVOPTAB_H_
#ifdef __cplusplus
extern "C" {
#endif
int mount_sd_fat(const char *path);
int unmount_sd_fat(const char *path);
#ifdef __cplusplus
}
#endif
#endif // __SD_FAT_DEVOPTAB_H_

View File

@ -20,10 +20,9 @@
* along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>. * along with FreeTypeGX. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "FreeTypeGX.h"
#include "video/CVideo.h" #include "video/CVideo.h"
#include "video/shaders/Texture2DShader.h" #include "video/shaders/Texture2DShader.h"
#include "utils/logger.h" #include "FreeTypeGX.h"
using namespace std; using namespace std;
@ -36,7 +35,7 @@ FreeTypeGX::FreeTypeGX(const uint8_t* fontBuffer, FT_Long bufferSize, bool lastF
{ {
int faceIndex = 0; int faceIndex = 0;
ftPointSize = 0; ftPointSize = 0;
GX2InitSampler(&ftSampler, GX2_TEX_CLAMP_CLAMP_BORDER, GX2_TEX_XY_FILTER_BILINEAR); GX2InitSampler(&ftSampler, GX2_TEX_CLAMP_MODE_CLAMP_BORDER, GX2_TEX_XY_FILTER_MODE_LINEAR);
FT_Init_FreeType(&ftLibrary); FT_Init_FreeType(&ftLibrary);
if(lastFace) if(lastFace)
@ -163,8 +162,8 @@ void FreeTypeGX::unloadFont()
{ {
if(itr2->second.texture) if(itr2->second.texture)
{ {
if(itr2->second.texture->surface.image_data) if(itr2->second.texture->surface.image)
free(itr2->second.texture->surface.image_data); free(itr2->second.texture->surface.image);
delete itr2->second.texture; delete itr2->second.texture;
itr2->second.texture = NULL; itr2->second.texture = NULL;
@ -235,7 +234,7 @@ ftgxCharData * FreeTypeGX::cacheGlyphData(wchar_t charCode, int16_t pixelSize)
//! Initialize texture //! Initialize texture
charData->texture = new GX2Texture; charData->texture = new GX2Texture;
GX2InitTexture(charData->texture, textureWidth, textureHeight, 1, 0, GX2_SURFACE_FORMAT_TC_R5_G5_B5_A1_UNORM, GX2_SURFACE_DIM_2D, GX2_TILE_MODE_LINEAR_ALIGNED); GX2InitTexture(charData->texture, textureWidth, textureHeight, 1, 0, GX2_SURFACE_FORMAT_UNORM_R5_G5_B5_A1, GX2_SURFACE_DIM_TEXTURE_2D, GX2_TILE_MODE_LINEAR_ALIGNED);
loadGlyphData(glyphBitmap, charData); loadGlyphData(glyphBitmap, charData);
@ -277,14 +276,14 @@ uint16_t FreeTypeGX::cacheGlyphDataComplete(int16_t pixelSize)
void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData) void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData)
{ {
charData->texture->surface.image_data = (uint8_t *) memalign(charData->texture->surface.align, charData->texture->surface.image_size); charData->texture->surface.image = (uint8_t *) memalign(charData->texture->surface.alignment, charData->texture->surface.imageSize);
if(!charData->texture->surface.image_data) if(!charData->texture->surface.image)
return; return;
memset(charData->texture->surface.image_data, 0x00, charData->texture->surface.image_size); memset(charData->texture->surface.image, 0x00, charData->texture->surface.imageSize);
uint8_t *src = (uint8_t *)bmp->buffer; uint8_t *src = (uint8_t *)bmp->buffer;
uint16_t *dst = (uint16_t *)charData->texture->surface.image_data; uint16_t *dst = (uint16_t *)charData->texture->surface.image;
int32_t x, y; int32_t x, y;
for(y = 0; y < bmp->rows; y++) for(y = 0; y < bmp->rows; y++)
@ -295,7 +294,7 @@ void FreeTypeGX::loadGlyphData(FT_Bitmap *bmp, ftgxCharData *charData)
dst[y * charData->texture->surface.pitch + x] = intensity ? ((intensity << 11) | (intensity << 6) | (intensity << 1) | 1) : 0; dst[y * charData->texture->surface.pitch + x] = intensity ? ((intensity << 11) | (intensity << 6) | (intensity << 1) | 1) : 0;
} }
} }
GX2Invalidate(GX2_INVALIDATE_CPU_TEXTURE, charData->texture->surface.image_data, charData->texture->surface.image_size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, charData->texture->surface.image, charData->texture->surface.imageSize);
} }
/** /**
@ -390,6 +389,7 @@ uint16_t FreeTypeGX::drawText(CVideo *video, int16_t x, int16_t y, int16_t z, co
} }
int i = 0; int i = 0;
while (text[i]) while (text[i])
{ {
ftgxCharData* glyphData = cacheGlyphData(text[i], pixelSize); ftgxCharData* glyphData = cacheGlyphData(text[i], pixelSize);

View File

@ -23,7 +23,6 @@
#ifndef FREETYPEGX_H_ #ifndef FREETYPEGX_H_
#define FREETYPEGX_H_ #define FREETYPEGX_H_
#include <gctypes.h>
#include <string> #include <string>
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_H #include FT_FREETYPE_H
@ -37,7 +36,7 @@
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp> #include <glm/gtc/matrix_transform.hpp>
#include "dynamic_libs/gx2_functions.h" #include "common/types.h"
/*! \struct ftgxCharData_ /*! \struct ftgxCharData_
* *

View File

@ -41,12 +41,12 @@ GameIcon::GameIcon(const std::string & filename, GuiImageData *preloadImage)
if(posVtxs) if(posVtxs)
{ {
memcpy((f32*)posVtxs, cfGameIconPosVtxs, sizeof(cfGameIconPosVtxs)); memcpy((f32*)posVtxs, cfGameIconPosVtxs, sizeof(cfGameIconPosVtxs));
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, (f32*)posVtxs, sizeof(cfGameIconPosVtxs)); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, (f32*)posVtxs, sizeof(cfGameIconPosVtxs));
} }
if(texCoords) if(texCoords)
{ {
memcpy((f32*)texCoords, cfGameIconTexCoords, sizeof(cfGameIconTexCoords)); memcpy((f32*)texCoords, cfGameIconTexCoords, sizeof(cfGameIconTexCoords));
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, (f32*)texCoords, sizeof(cfGameIconTexCoords)); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, (f32*)texCoords, sizeof(cfGameIconTexCoords));
} }
//! create vertexes for the mirror frame //! create vertexes for the mirror frame
@ -59,7 +59,7 @@ GameIcon::GameIcon(const std::string & filename, GuiImageData *preloadImage)
texCoordsMirror[i*2 + 0] = texCoords[i*2 + 0] * cfIconMirrorScale - ((cfIconMirrorScale - 1.0f) - (cfIconMirrorScale - 1.0f) * 0.5f); texCoordsMirror[i*2 + 0] = texCoords[i*2 + 0] * cfIconMirrorScale - ((cfIconMirrorScale - 1.0f) - (cfIconMirrorScale - 1.0f) * 0.5f);
texCoordsMirror[i*2 + 1] = texCoords[i*2 + 1] * cfIconMirrorScale - ((cfIconMirrorScale - 1.0f) - (cfIconMirrorScale - 1.0f) * 0.5f); texCoordsMirror[i*2 + 1] = texCoords[i*2 + 1] * cfIconMirrorScale - ((cfIconMirrorScale - 1.0f) - (cfIconMirrorScale - 1.0f) * 0.5f);
} }
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, texCoordsMirror, sizeof(cfGameIconTexCoords)); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, texCoordsMirror, sizeof(cfGameIconTexCoords));
} }
//! setup stroke of the icon //! setup stroke of the icon
@ -67,7 +67,7 @@ GameIcon::GameIcon(const std::string & filename, GuiImageData *preloadImage)
if(strokePosVtxs) if(strokePosVtxs)
{ {
memcpy(strokePosVtxs, cfGameIconStrokeVtxs, sizeof(cfGameIconStrokeVtxs)); memcpy(strokePosVtxs, cfGameIconStrokeVtxs, sizeof(cfGameIconStrokeVtxs));
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, strokePosVtxs, sizeof(cfGameIconStrokeVtxs)); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, strokePosVtxs, sizeof(cfGameIconStrokeVtxs));
} }
strokeTexCoords = (f32*)memalign(GX2_VERTEX_BUFFER_ALIGNMENT, cuGameIconStrokeVtxCount * Shader::cuTexCoordAttrSize); strokeTexCoords = (f32*)memalign(GX2_VERTEX_BUFFER_ALIGNMENT, cuGameIconStrokeVtxCount * Shader::cuTexCoordAttrSize);
if(strokeTexCoords) if(strokeTexCoords)
@ -77,14 +77,14 @@ GameIcon::GameIcon(const std::string & filename, GuiImageData *preloadImage)
strokeTexCoords[n] = (1.0f + strokePosVtxs[i]) * 0.5f; strokeTexCoords[n] = (1.0f + strokePosVtxs[i]) * 0.5f;
strokeTexCoords[n+1] = 1.0f - (1.0f + strokePosVtxs[i+1]) * 0.5f; strokeTexCoords[n+1] = 1.0f - (1.0f + strokePosVtxs[i+1]) * 0.5f;
} }
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, strokeTexCoords, cuGameIconStrokeVtxCount * Shader::cuTexCoordAttrSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, strokeTexCoords, cuGameIconStrokeVtxCount * Shader::cuTexCoordAttrSize);
} }
strokeColorVtxs = (u8*)memalign(GX2_VERTEX_BUFFER_ALIGNMENT, cuGameIconStrokeVtxCount * Shader::cuColorAttrSize); strokeColorVtxs = (u8*)memalign(GX2_VERTEX_BUFFER_ALIGNMENT, cuGameIconStrokeVtxCount * Shader::cuColorAttrSize);
if(strokeColorVtxs) if(strokeColorVtxs)
{ {
for(size_t i = 0; i < (cuGameIconStrokeVtxCount * Shader::cuColorAttrSize); i++) for(size_t i = 0; i < (cuGameIconStrokeVtxCount * Shader::cuColorAttrSize); i++)
strokeColorVtxs[i] = 0xff; strokeColorVtxs[i] = 0xff;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, strokeColorVtxs, cuGameIconStrokeVtxCount * Shader::cuColorAttrSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, strokeColorVtxs, cuGameIconStrokeVtxCount * Shader::cuColorAttrSize);
} }
} }
@ -236,14 +236,14 @@ void GameIcon::draw(CVideo *pVideo, const glm::mat4 & projectionMtx, const glm::
Shader3D::instance()->setModelViewMtx(m_iconView); Shader3D::instance()->setModelViewMtx(m_iconView);
Shader3D::instance()->setColorIntensity(colorIntensity); Shader3D::instance()->setColorIntensity(colorIntensity);
Shader3D::instance()->setAttributeBuffer(vtxCount, posVtxs, texCoords); Shader3D::instance()->setAttributeBuffer(vtxCount, posVtxs, texCoords);
Shader3D::instance()->draw(GX2_PRIMITIVE_QUADS, vtxCount); Shader3D::instance()->draw(GX2_PRIMITIVE_MODE_QUADS, vtxCount);
} }
if(bSelected) if(bSelected)
{ {
strokeFractalEnable = 0; strokeFractalEnable = 0;
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_DISABLE, GX2_COMPARE_LEQUAL); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_DISABLE, GX2_COMPARE_FUNC_LEQUAL);
m_strokeView = glm::scale(m_iconView, glm::vec3(selectionBlurOuterSize, selectionBlurOuterSize, 0.0f)); m_strokeView = glm::scale(m_iconView, glm::vec3(selectionBlurOuterSize, selectionBlurOuterSize, 0.0f));
ShaderFractalColor::instance()->setShaders(); ShaderFractalColor::instance()->setShaders();
ShaderFractalColor::instance()->setProjectionMtx(projectionMtx); ShaderFractalColor::instance()->setProjectionMtx(projectionMtx);
@ -260,7 +260,7 @@ void GameIcon::draw(CVideo *pVideo, const glm::mat4 & projectionMtx, const glm::
ShaderFractalColor::instance()->setBlurBorder(selectionBlurInnerBorderSize); ShaderFractalColor::instance()->setBlurBorder(selectionBlurInnerBorderSize);
ShaderFractalColor::instance()->setColorIntensity(selectionBlurInnerColorIntensity); ShaderFractalColor::instance()->setColorIntensity(selectionBlurInnerColorIntensity);
ShaderFractalColor::instance()->draw(); ShaderFractalColor::instance()->draw();
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL);
} }
if(iDraw == RENDER_NORMAL && bRenderStroke) if(iDraw == RENDER_NORMAL && bRenderStroke)
@ -280,7 +280,7 @@ void GameIcon::draw(CVideo *pVideo, const glm::mat4 & projectionMtx, const glm::
ShaderFractalColor::instance()->setColorIntensity(colorIntensity); ShaderFractalColor::instance()->setColorIntensity(colorIntensity);
ShaderFractalColor::instance()->setAlphaFadeOut(*alphaFadeOut); ShaderFractalColor::instance()->setAlphaFadeOut(*alphaFadeOut);
ShaderFractalColor::instance()->setAttributeBuffer(cuGameIconStrokeVtxCount, strokePosVtxs, strokeTexCoords, strokeColorVtxs); ShaderFractalColor::instance()->setAttributeBuffer(cuGameIconStrokeVtxCount, strokePosVtxs, strokeTexCoords, strokeColorVtxs);
ShaderFractalColor::instance()->draw(GX2_PRIMITIVE_LINE_STRIP, cuGameIconStrokeVtxCount); ShaderFractalColor::instance()->draw(GX2_PRIMITIVE_MODE_LINE_STRIP, cuGameIconStrokeVtxCount);
} }
@ -294,7 +294,7 @@ void GameIcon::draw(CVideo *pVideo, const glm::mat4 & projectionMtx, const glm::
Shader3D::instance()->setModelViewMtx(m_mirrorView); Shader3D::instance()->setModelViewMtx(m_mirrorView);
Shader3D::instance()->setColorIntensity(colorIntensityMirror); Shader3D::instance()->setColorIntensity(colorIntensityMirror);
Shader3D::instance()->setAttributeBuffer(vtxCount, posVtxs, texCoordsMirror); Shader3D::instance()->setAttributeBuffer(vtxCount, posVtxs, texCoordsMirror);
Shader3D::instance()->draw(GX2_PRIMITIVE_QUADS, vtxCount); Shader3D::instance()->draw(GX2_PRIMITIVE_MODE_QUADS, vtxCount);
if(bIconLast) if(bIconLast)
{ {
@ -309,7 +309,7 @@ void GameIcon::draw(CVideo *pVideo, const glm::mat4 & projectionMtx, const glm::
Shader3D::instance()->setModelViewMtx(m_iconView); Shader3D::instance()->setModelViewMtx(m_iconView);
Shader3D::instance()->setColorIntensity(colorIntensity); Shader3D::instance()->setColorIntensity(colorIntensity);
Shader3D::instance()->setAttributeBuffer(vtxCount, posVtxs, texCoords); Shader3D::instance()->setAttributeBuffer(vtxCount, posVtxs, texCoords);
Shader3D::instance()->draw(GX2_PRIMITIVE_QUADS, vtxCount); Shader3D::instance()->draw(GX2_PRIMITIVE_MODE_QUADS, vtxCount);
} }
//! return back normal culling //! return back normal culling

View File

@ -25,7 +25,7 @@ GridBackground::GridBackground(GuiImageData *img)
m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = 1.0f;
m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = -1.0f; m_posVtxs[i++] = 1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = -1.0f;
m_posVtxs[i++] = -1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = -1.0f; m_posVtxs[i++] = -1.0f; m_posVtxs[i++] = 0.0f; m_posVtxs[i++] = -1.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, m_posVtxs, vtxCount * Shader3D::cuVertexAttrSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, m_posVtxs, vtxCount * Shader3D::cuVertexAttrSize);
} }
if(m_texCoords) if(m_texCoords)
@ -50,7 +50,7 @@ GridBackground::GridBackground(GuiImageData *img)
m_texCoords[i*2 + 1] = texCoordVec[i][1]; m_texCoords[i*2 + 1] = texCoordVec[i][1];
} }
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, m_texCoords, vtxCount * Shader3D::cuTexCoordAttrSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, m_texCoords, vtxCount * Shader3D::cuTexCoordAttrSize);
} }
//! assign to internal variables which are const but oh well //! assign to internal variables which are const but oh well
@ -96,5 +96,5 @@ void GridBackground::draw(CVideo *pVideo, const glm::mat4 & modelView)
Shader3D::instance()->setAlphaFadeOut(alphaFadeOut); Shader3D::instance()->setAlphaFadeOut(alphaFadeOut);
Shader3D::instance()->setColorIntensity(colorIntensity); Shader3D::instance()->setColorIntensity(colorIntensity);
Shader3D::instance()->setAttributeBuffer(vtxCount, posVtxs, texCoords); Shader3D::instance()->setAttributeBuffer(vtxCount, posVtxs, texCoords);
Shader3D::instance()->draw(GX2_PRIMITIVE_QUADS, vtxCount); Shader3D::instance()->draw(GX2_PRIMITIVE_MODE_QUADS, vtxCount);
} }

View File

@ -15,7 +15,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include "GuiButton.h" #include "GuiButton.h"
#include "GuiTrigger.h"
#include "GuiController.h" #include "GuiController.h"
/** /**
@ -162,14 +161,12 @@ void GuiButton::draw(CVideo *v)
return; return;
// draw image // draw image
if((isDrawOverOnlyWhenSelected() && (isStateSet(STATE_SELECTED) && imageOver)) || if(isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && imageOver)
(!isDrawOverOnlyWhenSelected() && (isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && imageOver)))
imageOver->draw(v); imageOver->draw(v);
else if(image) else if(image)
image->draw(v); image->draw(v);
if((isDrawOverOnlyWhenSelected() && (isStateSet(STATE_SELECTED) && iconOver)) || if(isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && iconOver)
(!isDrawOverOnlyWhenSelected() && (isStateSet(STATE_OVER | STATE_SELECTED | STATE_CLICKED | STATE_HELD) && iconOver)))
iconOver->draw(v); iconOver->draw(v);
else if(icon) else if(icon)
icon->draw(v); icon->draw(v);
@ -186,9 +183,9 @@ void GuiButton::draw(CVideo *v)
void GuiButton::update(GuiController * c) void GuiButton::update(GuiController * c)
{ {
if(!c || isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chan)) if(!c || isStateSet(STATE_DISABLED, c->chan) || isStateSet(STATE_HIDDEN, c->chan))
return; return;
else if(parentElement && (parentElement->isStateSet(STATE_DISABLED|STATE_HIDDEN|STATE_DISABLE_INPUT, c->chan))) else if(parentElement && (parentElement->isStateSet(STATE_DISABLED, c->chan) || parentElement->isStateSet(STATE_HIDDEN, c->chan)))
return; return;
if(selectable) if(selectable)
@ -239,10 +236,9 @@ void GuiButton::update(GuiController * c)
// button triggers // button triggers
if(clickable) if(clickable)
{ {
bool isClicked = trigger[i]->clicked(c);
int isClicked = trigger[i]->clicked(c); if( !clickedTrigger && isClicked
if( !clickedTrigger && (isClicked != GuiTrigger::CLICKED_NONE)
&& (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chan) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y))) && (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED | STATE_OVER, c->chan) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->data.x, c->data.y)))
{ {
if(soundClick) if(soundClick)
@ -250,23 +246,16 @@ void GuiButton::update(GuiController * c)
clickedTrigger = trigger[i]; clickedTrigger = trigger[i];
if(!isStateSet(STATE_CLICKED, c->chan)){ if(!isStateSet(STATE_CLICKED, c->chan))
if(isClicked == GuiTrigger::CLICKED_TOUCH){ setState(STATE_CLICKED, c->chan);
setState(STATE_CLICKED_TOUCH, c->chan);
}else{
setState(STATE_CLICKED, c->chan);
}
}
clicked(this, c, trigger[i]); clicked(this, c, trigger[i]);
} }
else if((isStateSet(STATE_CLICKED, c->chan) || isStateSet(STATE_CLICKED_TOUCH, c->chan)) && (clickedTrigger == trigger[i]) && !isStateSet(STATE_HELD, c->chan) && !trigger[i]->held(c) && ((isClicked == GuiTrigger::CLICKED_NONE) || trigger[i]->released(c))) else if(isStateSet(STATE_CLICKED, c->chan) && (clickedTrigger == trigger[i]) && !isStateSet(STATE_HELD, c->chan) && !trigger[i]->held(c) && (!isClicked || trigger[i]->released(c)))
{ {
if((isStateSet(STATE_CLICKED_TOUCH, c->chan) && this->isInside(c->data.x, c->data.y)) || (isStateSet(STATE_CLICKED, c->chan))){ clickedTrigger = NULL;
clickedTrigger = NULL; clearState(STATE_CLICKED, c->chan);
clearState(STATE_CLICKED, c->chan); released(this, c, trigger[i]);
released(this, c, trigger[i]);
}
} }
} }

View File

@ -85,7 +85,7 @@ class GuiButton : public GuiElement
//!Constantly called to allow the GuiButton to respond to updated input data //!Constantly called to allow the GuiButton to respond to updated input data
//!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD //!\param t Pointer to a GuiTrigger, containing the current input data from PAD/WPAD
void update(GuiController * c); void update(GuiController * c);
sigslot::signal2<GuiButton *, const GuiController *> selected; sigslot::signal2<GuiButton *, const GuiController *> selected;
sigslot::signal2<GuiButton *, const GuiController *> deSelected; sigslot::signal2<GuiButton *, const GuiController *> deSelected;
sigslot::signal2<GuiButton *, const GuiController *> pointedOn; sigslot::signal2<GuiButton *, const GuiController *> pointedOn;
@ -94,7 +94,7 @@ class GuiButton : public GuiElement
sigslot::signal3<GuiButton *, const GuiController *, GuiTrigger *> held; sigslot::signal3<GuiButton *, const GuiController *, GuiTrigger *> held;
sigslot::signal3<GuiButton *, const GuiController *, GuiTrigger *> released; sigslot::signal3<GuiButton *, const GuiController *, GuiTrigger *> released;
protected: protected:
static const int iMaxGuiTriggers = 10; static const int iMaxGuiTriggers = 7;
GuiImage * image; //!< Button image (default) GuiImage * image; //!< Button image (default)
GuiImage * imageOver; //!< Button image for STATE_SELECTED GuiImage * imageOver; //!< Button image for STATE_SELECTED

View File

@ -42,7 +42,6 @@ GuiElement::GuiElement()
selectable = false; selectable = false;
clickable = false; clickable = false;
holdable = false; holdable = false;
drawOverOnlyWhenSelected = false;
visible = true; visible = true;
yoffsetDyn = 0; yoffsetDyn = 0;
xoffsetDyn = 0; xoffsetDyn = 0;

View File

@ -19,7 +19,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <gctypes.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -28,11 +27,11 @@
#include <wchar.h> #include <wchar.h>
#include <math.h> #include <math.h>
#include "common/types.h"
#include "sigslot.h" #include "sigslot.h"
#include "glm/glm.hpp" #include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp" #include "glm/gtc/matrix_transform.hpp"
#include "dynamic_libs/gx2_types.h"
#include "resources/Resources.h" #include "resources/Resources.h"
#include "system/AsyncDeleter.h" #include "system/AsyncDeleter.h"
#include "utils/logger.h" #include "utils/logger.h"
@ -492,6 +491,8 @@ class GuiElement : public AsyncDeleter::Element
sigslot::signal3<GuiElement *, int, int> stateChanged; sigslot::signal3<GuiElement *, int, int> stateChanged;
sigslot::signal1<GuiElement *> effectFinished; sigslot::signal1<GuiElement *> effectFinished;
protected: protected:
f32 xoffset; //!< Element X offset
f32 yoffset; //!< Element Y offset
bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event bool rumble; //!< Wiimote rumble (on/off) - set to on when this element requests a rumble event
bool visible; //!< Visibility of the element. If false, Draw() is skipped bool visible; //!< Visibility of the element. If false, Draw() is skipped
bool selectable; //!< Whether or not this element selectable (can change to SELECTED state) bool selectable; //!< Whether or not this element selectable (can change to SELECTED state)
@ -500,8 +501,6 @@ class GuiElement : public AsyncDeleter::Element
bool drawOverOnlyWhenSelected; //!< Whether or not this element is holdable (can change to HELD state) bool drawOverOnlyWhenSelected; //!< Whether or not this element is holdable (can change to HELD state)
f32 width; //!< Element width f32 width; //!< Element width
f32 height; //!< Element height f32 height; //!< Element height
f32 xoffset; //!< Element X offset
f32 yoffset; //!< Element Y offset
f32 zoffset; //!< Element Z offset f32 zoffset; //!< Element Z offset
f32 alpha; //!< Element alpha value (0-255) f32 alpha; //!< Element alpha value (0-255)
f32 angle; //!< Angle of the object (0-360) f32 angle; //!< Angle of the object (0-360)

View File

@ -51,9 +51,16 @@ void GuiFrame::append(GuiElement* e)
if (e == NULL) if (e == NULL)
return; return;
remove(e); e->setParent(this);
elements.push_back(e);
e->setParent(this); ListChangeElement elem;
elem.addElement = true;
elem.position = -1;
elem.element = e;
queueMutex.lock();
listChangeQueue.push(elem);
queueMutex.unlock();
} }
void GuiFrame::insert(GuiElement* e, u32 index) void GuiFrame::insert(GuiElement* e, u32 index)
@ -61,9 +68,16 @@ void GuiFrame::insert(GuiElement* e, u32 index)
if (e == NULL || (index >= elements.size())) if (e == NULL || (index >= elements.size()))
return; return;
remove(e); e->setParent(this);
elements.insert(elements.begin()+index, e);
e->setParent(this); ListChangeElement elem;
elem.addElement = true;
elem.position = index;
elem.element = e;
queueMutex.lock();
listChangeQueue.push(elem);
queueMutex.unlock();
} }
void GuiFrame::remove(GuiElement* e) void GuiFrame::remove(GuiElement* e)
@ -71,14 +85,14 @@ void GuiFrame::remove(GuiElement* e)
if (e == NULL) if (e == NULL)
return; return;
for (u32 i = 0; i < elements.size(); ++i) ListChangeElement elem;
{ elem.addElement = false;
if(e == elements[i]) elem.position = -1;
{ elem.element = e;
elements.erase(elements.begin()+i);
break; queueMutex.lock();
} listChangeQueue.push(elem);
} queueMutex.unlock();
} }
void GuiFrame::removeAll() void GuiFrame::removeAll()
@ -185,34 +199,21 @@ void GuiFrame::draw(CVideo * v)
void GuiFrame::updateEffects() void GuiFrame::updateEffects()
{ {
if(!this->isVisible() && parentElement) if(this->isVisible() || parentElement)
return; {
GuiElement::updateEffects();
GuiElement::updateEffects(); //! render appended items next frame but allow stop of render if size is reached
u32 size = elements.size();
//! render appended items next frame but allow stop of render if size is reached for (u32 i = 0; i < size && i < elements.size(); ++i)
u32 size = elements.size(); {
elements[i]->updateEffects();
}
}
for (u32 i = 0; i < size && i < elements.size(); ++i) //! at the end of main loop which this function represents append pending elements
{ updateElementList();
elements[i]->updateEffects();
}
}
void GuiFrame::process()
{
if(!this->isVisible() && parentElement)
return;
GuiElement::process();
//! render appended items next frame but allow stop of render if size is reached
u32 size = elements.size();
for (u32 i = 0; i < size && i < elements.size(); ++i)
{
elements[i]->process();
}
} }
void GuiFrame::update(GuiController * c) void GuiFrame::update(GuiController * c)
@ -228,3 +229,39 @@ void GuiFrame::update(GuiController * c)
elements[i]->update(c); elements[i]->update(c);
} }
} }
void GuiFrame::updateElementList(void)
{
if(listChangeQueue.empty() == false)
{
queueMutex.lock();
while(!listChangeQueue.empty())
{
ListChangeElement & listChange = listChangeQueue.front();
for (u32 i = 0; i < elements.size(); ++i)
{
if(listChange.element == elements[i])
{
elements.erase(elements.begin()+i);
break;
}
}
if(listChange.addElement)
{
if(listChange.position >= 0)
{
elements.insert(elements.begin()+listChange.position, listChange.element);
}
else
{
elements.push_back(listChange.element);
}
}
listChangeQueue.pop();
}
queueMutex.unlock();
}
}

View File

@ -84,8 +84,6 @@ class GuiFrame : public GuiElement
virtual void exec() {} virtual void exec() {}
//!virtual updateEffects which is called by the main loop //!virtual updateEffects which is called by the main loop
virtual void updateEffects(); virtual void updateEffects();
//!virtual process which is called by the main loop
virtual void process();
//! Signals //! Signals
//! On Closing //! On Closing
sigslot::signal1<GuiFrame *> closing; sigslot::signal1<GuiFrame *> closing;
@ -93,6 +91,17 @@ class GuiFrame : public GuiElement
bool dim; //! Enable/disable dim of a window only bool dim; //! Enable/disable dim of a window only
GuiFrame *parent; //!< Parent Window GuiFrame *parent; //!< Parent Window
std::vector<GuiElement*> elements; //!< Contains all elements within the GuiFrame std::vector<GuiElement*> elements; //!< Contains all elements within the GuiFrame
void updateElementList(void);
struct ListChangeElement
{
bool addElement;
int position;
GuiElement *element;
};
std::queue<ListChangeElement> listChangeQueue;
CMutex queueMutex;
}; };
#endif #endif

View File

@ -92,7 +92,7 @@ void GuiImage::internalInit(int w, int h)
posVtxs = NULL; posVtxs = NULL;
texCoords = NULL; texCoords = NULL;
vtxCount = 4; vtxCount = 4;
primitive = GX2_PRIMITIVE_QUADS; primitive = GX2_PRIMITIVE_MODE_QUADS;
imageAngle = 0.0f; imageAngle = 0.0f;
blurDirection = glm::vec3(0.0f); blurDirection = glm::vec3(0.0f);
@ -120,7 +120,7 @@ GX2Color GuiImage::getPixel(int x, int y)
return (GX2Color){0, 0, 0, 0}; return (GX2Color){0, 0, 0, 0};
u32 pitch = imageData->getTexture()->surface.pitch; u32 pitch = imageData->getTexture()->surface.pitch;
u32 *imagePtr = (u32*)imageData->getTexture()->surface.image_data; u32 *imagePtr = (u32*)imageData->getTexture()->surface.image;
u32 color_u32 = imagePtr[y * pitch + x]; u32 color_u32 = imagePtr[y * pitch + x];
GX2Color color; GX2Color color;
@ -138,7 +138,7 @@ void GuiImage::setPixel(int x, int y, const GX2Color & color)
u32 pitch = imageData->getTexture()->surface.pitch; u32 pitch = imageData->getTexture()->surface.pitch;
u32 *imagePtr = (u32*)imageData->getTexture()->surface.image_data; u32 *imagePtr = (u32*)imageData->getTexture()->surface.image;
imagePtr[y * pitch + x] = (color.r << 24) | (color.g << 16) | (color.b << 8) | (color.a << 0); imagePtr[y * pitch + x] = (color.r << 24) | (color.g << 16) | (color.b << 8) | (color.a << 0);
} }
@ -260,7 +260,7 @@ void GuiImage::draw(CVideo *pVideo)
// } // }
if(colorVtxsDirty && colorVtxs) { if(colorVtxsDirty && colorVtxs) {
//! flush color vertex only on main GX2 thread //! flush color vertex only on main GX2 thread
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, colorVtxs, colorCount * ColorShader::cuColorAttrSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, colorVtxs, colorCount * ColorShader::cuColorAttrSize);
colorVtxsDirty = false; colorVtxsDirty = false;
} }

View File

@ -55,7 +55,7 @@ GuiImageAsync::~GuiImageAsync()
if (imgData) if (imgData)
delete imgData; delete imgData;
//threadExit(); threadExit();
} }
void GuiImageAsync::threadAddImage(GuiImageAsync *Image) void GuiImageAsync::threadAddImage(GuiImageAsync *Image)
@ -117,7 +117,7 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg)
int iResult = LoadFileToMem(pInUse->filename.c_str(), &buffer, &bufferSize); int iResult = LoadFileToMem(pInUse->filename.c_str(), &buffer, &bufferSize);
if(iResult > 0) if(iResult > 0)
{ {
pInUse->imgData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MIRROR); pInUse->imgData = new GuiImageData(buffer, bufferSize, GX2_TEX_CLAMP_MODE_MIRROR);
//! free original image buffer which is converted to texture now and not needed anymore //! free original image buffer which is converted to texture now and not needed anymore
free(buffer); free(buffer);
@ -138,7 +138,7 @@ void GuiImageAsync::guiImageAsyncThread(CThread *thread, void *arg)
pInUse->imgData = NULL; pInUse->imgData = NULL;
} }
} }
pInUse->imageLoaded(pInUse);
pInUse = NULL; pInUse = NULL;
} }
} }
@ -159,10 +159,9 @@ void GuiImageAsync::threadInit()
void GuiImageAsync::threadExit() void GuiImageAsync::threadExit()
{ {
if(threadRefCounter) --threadRefCounter;
--threadRefCounter;
if(/*(threadRefCounter == 0) &&*/ (pThread != NULL)) if((threadRefCounter == 0) && (pThread != NULL))
{ {
bExitRequested = true; bExitRequested = true;
delete pThread; delete pThread;

View File

@ -21,7 +21,6 @@
#include "GuiImage.h" #include "GuiImage.h"
#include "system/CThread.h" #include "system/CThread.h"
#include "system/CMutex.h" #include "system/CMutex.h"
#include "dynamic_libs/os_functions.h"
class GuiImageAsync : public GuiImage class GuiImageAsync : public GuiImage
{ {
@ -34,13 +33,9 @@ class GuiImageAsync : public GuiImage
static void removeFromQueue(GuiImageAsync * image) { static void removeFromQueue(GuiImageAsync * image) {
threadRemoveImage(image); threadRemoveImage(image);
} }
//! don't forget to LOCK GUI if using this asynchron call
sigslot::signal1<GuiImageAsync *> imageLoaded;
static void threadExit();
private: private:
static void threadInit(); static void threadInit();
static void threadExit();
GuiImageData *imgData; GuiImageData *imgData;
std::string filename; std::string filename;

View File

@ -18,6 +18,8 @@
#include <string.h> #include <string.h>
#include "GuiImageData.h" #include "GuiImageData.h"
#include "system/memory.h" #include "system/memory.h"
#include "video/CVideo.h"
#include "common/gx2_ext.h"
/** /**
* Constructor for the GuiImageData class. * Constructor for the GuiImageData class.
*/ */
@ -31,7 +33,7 @@ GuiImageData::GuiImageData()
/** /**
* Constructor for the GuiImageData class. * Constructor for the GuiImageData class.
*/ */
GuiImageData::GuiImageData(const u8 * img, int imgSize, int textureClamp, int textureFormat) GuiImageData::GuiImageData(const u8 * img, int imgSize, GX2TexClampMode textureClamp, GX2SurfaceFormat textureFormat)
{ {
texture = NULL; texture = NULL;
sampler = NULL; sampler = NULL;
@ -49,19 +51,19 @@ GuiImageData::~GuiImageData()
void GuiImageData::releaseData(void) void GuiImageData::releaseData(void)
{ {
if(texture) { if(texture) {
if(texture->surface.image_data) if(texture->surface.image)
{ {
switch(memoryType) switch(memoryType)
{ {
default: default:
case eMemTypeMEM2: case eMemTypeMEM2:
free(texture->surface.image_data); free(texture->surface.image);
break; break;
case eMemTypeMEM1: case eMemTypeMEM1:
MEM1_free(texture->surface.image_data); MEM1_free(texture->surface.image);
break; break;
case eMemTypeMEMBucket: case eMemTypeMEMBucket:
MEMBucket_free(texture->surface.image_data); MEMBucket_free(texture->surface.image);
break; break;
} }
} }
@ -74,7 +76,7 @@ void GuiImageData::releaseData(void)
} }
} }
void GuiImageData::loadImage(const u8 *img, int imgSize, int textureClamp, int textureFormat) void GuiImageData::loadImage(const u8 *img, int imgSize, GX2TexClampMode textureClamp, GX2SurfaceFormat textureFormat)
{ {
if(!img || (imgSize < 8)) if(!img || (imgSize < 8))
return; return;
@ -87,12 +89,12 @@ void GuiImageData::loadImage(const u8 *img, int imgSize, int textureClamp, int t
//! not needed for now therefore comment out to safe ELF size //! not needed for now therefore comment out to safe ELF size
//! if needed uncomment, adds 200 kb to the ELF size //! if needed uncomment, adds 200 kb to the ELF size
// IMAGE_JPEG // IMAGE_JPEG
gdImg = gdImageCreateFromJpegPtr(imgSize, (u8*) img); //gdImg = gdImageCreateFromJpegPtr(imgSize, (u8*) img);
} }
else if (img[0] == 'B' && img[1] == 'M') else if (img[0] == 'B' && img[1] == 'M')
{ {
// IMAGE_BMP // IMAGE_BMP
gdImg = gdImageCreateFromBmpPtr(imgSize, (u8*) img); //gdImg = gdImageCreateFromBmpPtr(imgSize, (u8*) img);
} }
else if (img[0] == 0x89 && img[1] == 'P' && img[2] == 'N' && img[3] == 'G') else if (img[0] == 0x89 && img[1] == 'P' && img[2] == 'N' && img[3] == 'G')
{ {
@ -103,7 +105,7 @@ void GuiImageData::loadImage(const u8 *img, int imgSize, int textureClamp, int t
else if(img[0] == 0x00) else if(img[0] == 0x00)
{ {
// Try loading TGA image // Try loading TGA image
gdImg = gdImageCreateFromTgaPtr(imgSize, (u8*) img); //gdImg = gdImageCreateFromTgaPtr(imgSize, (u8*) img);
} }
if(gdImg == 0) if(gdImg == 0)
@ -114,10 +116,10 @@ void GuiImageData::loadImage(const u8 *img, int imgSize, int textureClamp, int t
//! Initialize texture //! Initialize texture
texture = new GX2Texture; texture = new GX2Texture;
GX2InitTexture(texture, width, height, 1, 0, textureFormat, GX2_SURFACE_DIM_2D, GX2_TILE_MODE_LINEAR_ALIGNED); GX2InitTexture(texture, width, height, 1, 0, textureFormat, GX2_SURFACE_DIM_TEXTURE_2D, GX2_TILE_MODE_LINEAR_ALIGNED);
//! if this fails something went horribly wrong //! if this fails something went horribly wrong
if(texture->surface.image_size == 0) { if(texture->surface.imageSize == 0) {
delete texture; delete texture;
texture = NULL; texture = NULL;
gdImageDestroy(gdImg); gdImageDestroy(gdImg);
@ -126,35 +128,35 @@ void GuiImageData::loadImage(const u8 *img, int imgSize, int textureClamp, int t
//! allocate memory for the surface //! allocate memory for the surface
memoryType = eMemTypeMEM2; memoryType = eMemTypeMEM2;
texture->surface.image_data = memalign(texture->surface.align, texture->surface.image_size); texture->surface.image = memalign(texture->surface.alignment, texture->surface.imageSize);
//! try MEM1 on failure //! try MEM1 on failure
if(!texture->surface.image_data) { if(!texture->surface.image) {
memoryType = eMemTypeMEM1; memoryType = eMemTypeMEM1;
texture->surface.image_data = MEM1_alloc(texture->surface.image_size, texture->surface.align); texture->surface.image = MEM1_alloc(texture->surface.imageSize, texture->surface.alignment);
} }
//! try MEM bucket on failure //! try MEM bucket on failure
if(!texture->surface.image_data) { if(!texture->surface.image) {
memoryType = eMemTypeMEMBucket; memoryType = eMemTypeMEMBucket;
texture->surface.image_data = MEMBucket_alloc(texture->surface.image_size, texture->surface.align); texture->surface.image = MEMBucket_alloc(texture->surface.imageSize, texture->surface.alignment);
} }
//! check if memory is available for image //! check if memory is available for image
if(!texture->surface.image_data) { if(!texture->surface.image) {
gdImageDestroy(gdImg); gdImageDestroy(gdImg);
delete texture; delete texture;
texture = NULL; texture = NULL;
return; return;
} }
//! set mip map data pointer //! set mip map data pointer
texture->surface.mip_data = NULL; texture->surface.mipmaps = NULL;
//! convert image to texture //! convert image to texture
switch(textureFormat) switch(textureFormat)
{ {
default: default:
case GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM: case GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8:
gdImageToUnormR8G8B8A8(gdImg, (u32*)texture->surface.image_data, texture->surface.width, texture->surface.height, texture->surface.pitch); gdImageToUnormR8G8B8A8(gdImg, (u32*)texture->surface.image, texture->surface.width, texture->surface.height, texture->surface.pitch);
break; break;
case GX2_SURFACE_FORMAT_TCS_R5_G6_B5_UNORM: case GX2_SURFACE_FORMAT_UNORM_R5_G6_B5:
gdImageToUnormR5G6B5(gdImg, (u16*)texture->surface.image_data, texture->surface.width, texture->surface.height, texture->surface.pitch); gdImageToUnormR5G6B5(gdImg, (u16*)texture->surface.image, texture->surface.width, texture->surface.height, texture->surface.pitch);
break; break;
} }
@ -162,10 +164,10 @@ void GuiImageData::loadImage(const u8 *img, int imgSize, int textureClamp, int t
gdImageDestroy(gdImg); gdImageDestroy(gdImg);
//! invalidate the memory //! invalidate the memory
GX2Invalidate(GX2_INVALIDATE_CPU_TEXTURE, texture->surface.image_data, texture->surface.image_size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, texture->surface.image, texture->surface.imageSize);
//! initialize the sampler //! initialize the sampler
sampler = new GX2Sampler; sampler = new GX2Sampler;
GX2InitSampler(sampler, textureClamp, GX2_TEX_XY_FILTER_BILINEAR); GX2InitSampler(sampler, textureClamp, GX2_TEX_XY_FILTER_MODE_LINEAR);
} }
void GuiImageData::gdImageToUnormR8G8B8A8(gdImagePtr gdImg, u32 *imgBuffer, u32 width, u32 height, u32 pitch) void GuiImageData::gdImageToUnormR8G8B8A8(gdImagePtr gdImg, u32 *imgBuffer, u32 width, u32 height, u32 pitch)

View File

@ -17,9 +17,10 @@
#ifndef GUI_IMAGEDATA_H_ #ifndef GUI_IMAGEDATA_H_
#define GUI_IMAGEDATA_H_ #define GUI_IMAGEDATA_H_
#include <gctypes.h>
#include <gd.h> #include <gd.h>
#include "dynamic_libs/gx2_functions.h" #include <gx2/enum.h>
#include <gx2/texture.h>
#include <gx2/sampler.h>
#include "system/AsyncDeleter.h" #include "system/AsyncDeleter.h"
class GuiImageData : public AsyncDeleter::Element class GuiImageData : public AsyncDeleter::Element
@ -29,13 +30,13 @@ public:
GuiImageData(); GuiImageData();
//!\param img Image data //!\param img Image data
//!\param imgSize The image size //!\param imgSize The image size
GuiImageData(const u8 * img, int imgSize, int textureClamp = GX2_TEX_CLAMP_CLAMP, int textureFormat = GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM); GuiImageData(const u8 * img, int imgSize, GX2TexClampMode textureClamp = GX2_TEX_CLAMP_MODE_CLAMP, GX2SurfaceFormat textureFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8);
//!Destructor //!Destructor
virtual ~GuiImageData(); virtual ~GuiImageData();
//!Load image from buffer //!Load image from buffer
//!\param img Image data //!\param img Image data
//!\param imgSize The image size //!\param imgSize The image size
void loadImage(const u8 * img, int imgSize, int textureClamp = GX2_TEX_CLAMP_CLAMP, int textureFormat = GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM); void loadImage(const u8 * img, int imgSize, GX2TexClampMode textureClamp = GX2_TEX_CLAMP_MODE_CLAMP, GX2SurfaceFormat textureFormat = GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8);
//! getter functions //! getter functions
const GX2Texture * getTexture() const { return texture; }; const GX2Texture * getTexture() const { return texture; };
const GX2Sampler * getSampler() const { return sampler; }; const GX2Sampler * getSampler() const { return sampler; };

View File

@ -51,8 +51,8 @@ GuiParticleImage::GuiParticleImage(int w, int h, u32 particleCount)
colorVertexs[i * 4 + 2] = 0xff; colorVertexs[i * 4 + 2] = 0xff;
colorVertexs[i * 4 + 3] = 0xff; colorVertexs[i * 4 + 3] = 0xff;
} }
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, posVertexs, ColorShader::cuVertexAttrSize * CIRCLE_VERTEX_COUNT); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVertexs, ColorShader::cuVertexAttrSize * CIRCLE_VERTEX_COUNT);
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, colorVertexs, ColorShader::cuColorAttrSize * CIRCLE_VERTEX_COUNT); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, colorVertexs, ColorShader::cuColorAttrSize * CIRCLE_VERTEX_COUNT);
particles.resize(particleCount); particles.resize(particleCount);
@ -62,8 +62,8 @@ GuiParticleImage::GuiParticleImage(int w, int h, u32 particleCount)
particles[i].position.y = getRandMinusOneToOneF32() * getHeight() * 0.5f; particles[i].position.y = getRandMinusOneToOneF32() * getHeight() * 0.5f;
particles[i].position.z = 0.0f; particles[i].position.z = 0.0f;
particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f); particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f);
particles[i].radius = getRandZeroToOneF32() * 30.0f + 60.0f; particles[i].radius = getRandZeroToOneF32() * 30.0f;
particles[i].speed = (getRandZeroToOneF32() * 0.4f) + 0.6f; particles[i].speed = (getRandZeroToOneF32() * 0.6f) + 0.2f;
particles[i].direction = getRandMinusOneToOneF32(); particles[i].direction = getRandMinusOneToOneF32();
} }
} }
@ -97,8 +97,8 @@ void GuiParticleImage::draw(CVideo *pVideo)
particles[i].position.x = getRandMinusOneToOneF32() * getWidth() * 0.5f; particles[i].position.x = getRandMinusOneToOneF32() * getWidth() * 0.5f;
particles[i].position.y = -getHeight() * 0.5f - 30.0f; particles[i].position.y = -getHeight() * 0.5f - 30.0f;
particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f); particles[i].colors = glm::vec4(1.0f, 1.0f, 1.0f, (getRandZeroToOneF32() * 0.6f) + 0.05f);
particles[i].radius = getRandZeroToOneF32() * 30.0f + 60.0f; particles[i].radius = getRandZeroToOneF32() * 30.0f;
particles[i].speed = (getRandZeroToOneF32() * 0.4f) + 0.6f; particles[i].speed = (getRandZeroToOneF32() * 0.6f) + 0.2f;
particles[i].direction = getRandMinusOneToOneF32(); particles[i].direction = getRandMinusOneToOneF32();
} }
if(particles[i].position.x < (-getWidth() * 0.5f - 50.0f)) if(particles[i].position.x < (-getWidth() * 0.5f - 50.0f))
@ -123,6 +123,6 @@ void GuiParticleImage::draw(CVideo *pVideo)
ColorShader::instance()->setOffset(positionOffsets); ColorShader::instance()->setOffset(positionOffsets);
ColorShader::instance()->setScale(scaleFactor); ColorShader::instance()->setScale(scaleFactor);
ColorShader::instance()->setColorIntensity(colorIntensity * particles[i].colors); ColorShader::instance()->setColorIntensity(colorIntensity * particles[i].colors);
ColorShader::instance()->draw(GX2_PRIMITIVE_TRIANGLE_FAN, CIRCLE_VERTEX_COUNT); ColorShader::instance()->draw(GX2_PRIMITIVE_MODE_TRIANGLE_FAN, CIRCLE_VERTEX_COUNT);
} }
} }

View File

@ -16,7 +16,6 @@
****************************************************************************/ ****************************************************************************/
#include "GuiSound.h" #include "GuiSound.h"
#include "sounds/SoundHandler.hpp" #include "sounds/SoundHandler.hpp"
#include "dynamic_libs/os_functions.h"
GuiSound::GuiSound(const char * filepath) GuiSound::GuiSound(const char * filepath)
{ {

View File

@ -17,7 +17,7 @@
#ifndef GUI_SOUND_H_ #ifndef GUI_SOUND_H_
#define GUI_SOUND_H_ #define GUI_SOUND_H_
#include <gctypes.h> #include "common/types.h"
#include "system/AsyncDeleter.h" #include "system/AsyncDeleter.h"
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc //!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
@ -28,7 +28,7 @@ class GuiSound : public AsyncDeleter::Element
//!\param sound Pointer to the sound data //!\param sound Pointer to the sound data
//!\param filesize Length of sound data //!\param filesize Length of sound data
GuiSound(const char * filepath); GuiSound(const char * filepath);
GuiSound(const u8 * sound, int length); GuiSound(const u8 * sound, s32 length);
//!Destructor //!Destructor
virtual ~GuiSound(); virtual ~GuiSound();
//!Load a file and replace the old one //!Load a file and replace the old one

View File

@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include "GuiText.h"
#include "FreeTypeGX.h"
#include "video/CVideo.h" #include "video/CVideo.h"
#include "FreeTypeGX.h"
#include "GuiText.h"
FreeTypeGX * GuiText::presentFont = NULL; FreeTypeGX * GuiText::presentFont = NULL;
int GuiText::presetSize = 28; int GuiText::presetSize = 28;

View File

@ -17,6 +17,7 @@
#ifndef GUI_TEXT_H_ #ifndef GUI_TEXT_H_
#define GUI_TEXT_H_ #define GUI_TEXT_H_
#include "common/gx2_ext.h"
#include "GuiElement.h" #include "GuiElement.h"
//!Forward declaration //!Forward declaration
class FreeTypeGX; class FreeTypeGX;

View File

@ -107,22 +107,22 @@ bool GuiTrigger::down(const GuiController *controller) const
return false; return false;
} }
int GuiTrigger::clicked(const GuiController *controller) const bool GuiTrigger::clicked(const GuiController *controller) const
{ {
if((controller->chan & chan) == 0) { if((controller->chan & chan) == 0) {
return CLICKED_NONE; return false;
} }
int bResult = CLICKED_NONE; bool bResult = false;
if(controller->data.touched && controller->data.validPointer && (btns & VPAD_TOUCH) && !controller->lastData.touched) if(controller->data.touched && controller->data.validPointer && (btns & VPAD_TOUCH) && !controller->lastData.touched)
{ {
bResult = CLICKED_TOUCH; bResult = true;
} }
if(controller->data.buttons_d & btns) if(controller->data.buttons_d & btns)
{ {
bResult = CLICKED_BUTTON; bResult = true;
} }
return bResult; return bResult;
} }

View File

@ -17,18 +17,12 @@
#ifndef GUI_TRIGGER_H_ #ifndef GUI_TRIGGER_H_
#define GUI_TRIGGER_H_ #define GUI_TRIGGER_H_
#include "dynamic_libs/os_functions.h" #include "common/types.h"
//!Menu input trigger management. Determine if action is neccessary based on input data by comparing controller input data to a specific trigger element. //!Menu input trigger management. Determine if action is neccessary based on input data by comparing controller input data to a specific trigger element.
class GuiTrigger class GuiTrigger
{ {
public: public:
enum eClicked{
CLICKED_NONE = 0x00,
CLICKED_TOUCH = 0x01,
CLICKED_BUTTON = 0x02,
};
enum eChannels { enum eChannels {
CHANNEL_1 = 0x01, CHANNEL_1 = 0x01,
CHANNEL_2 = 0x02, CHANNEL_2 = 0x02,
@ -91,7 +85,7 @@ public:
bool right(const GuiController *controller) const; bool right(const GuiController *controller) const;
bool up(const GuiController *controller) const; bool up(const GuiController *controller) const;
bool down(const GuiController *controller) const; bool down(const GuiController *controller) const;
int clicked(const GuiController *controller) const; bool clicked(const GuiController *controller) const;
bool held(const GuiController *controller) const; bool held(const GuiController *controller) const;
bool released(const GuiController *controller) const; bool released(const GuiController *controller) const;
private: private:

View File

@ -17,8 +17,8 @@
#ifndef VPAD_CONTROLLER_H_ #ifndef VPAD_CONTROLLER_H_
#define VPAD_CONTROLLER_H_ #define VPAD_CONTROLLER_H_
#include <vpad/input.h>
#include "GuiController.h" #include "GuiController.h"
#include "dynamic_libs/vpad_functions.h"
class VPadController : public GuiController class VPadController : public GuiController
{ {
@ -37,27 +37,26 @@ public:
{ {
lastData = data; lastData = data;
int vpadError = -1; VPADReadError vpadError = VPAD_READ_NO_SAMPLES;
VPADRead(0, &vpad, 1, &vpadError); VPADRead(0, &vpad, 1, &vpadError);
if(vpadError == 0) if(vpadError == VPAD_READ_SUCCESS)
{ {
data.buttons_r = vpad.btns_r; data.buttons_r = vpad.release;
data.buttons_h = vpad.btns_h; data.buttons_h = vpad.hold;
data.buttons_d = vpad.btns_d; data.buttons_d = vpad.trigger;
data.validPointer = !vpad.tpdata.invalid; data.validPointer = !vpad.tpNormal.validity;
data.touched = vpad.tpdata.touched; data.touched = vpad.tpNormal.touched;
//! calculate the screen offsets //! calculate the screen offsets
data.x = -(width >> 1) + ((int)(vpad.tpdata1.x * ((width)/1211.0f)*width) >> 12)-30; data.x = -(width >> 1) + (int)((vpad.tpFiltered1.x * width) >> 12);
data.y = -(height >> 1) + ((int)(vpad.tpdata1.y * ((height)/653.0f)*height) >> 12)-35; data.y = (height >> 1) - (int)(height - ((vpad.tpFiltered1.y * height) >> 12));
return true; return true;
} }
return false; return false;
} }
private: private:
VPADData vpad; VPADStatus vpad;
}; };
#endif #endif

View File

@ -1,49 +0,0 @@
#include <string.h>
#include "common/common.h"
#include "common/kernel_defs.h"
#include "kernel/kernel_functions.h"
#include "kernel/syscalls.h"
/* our retain data */
ReducedCosAppXmlInfo cosAppXmlInfoStruct __attribute__((section(".data")));
/*
* This function is a kernel hook function. It is called directly from kernel code at position 0xFFF18558.
*/
void my_PrepareTitle(CosAppXmlInfo *xmlKernelInfo)
{
/**
* DBAT for access to our data region is setup at this point for the 0xC0000000 area.
*/
//! Copy all data from the XML info
strncpy(cosAppXmlInfoStruct.rpx_name, xmlKernelInfo->rpx_name, FS_MAX_ENTNAME_SIZE);
cosAppXmlInfoStruct.version_cos_xml = xmlKernelInfo->version_cos_xml;
cosAppXmlInfoStruct.os_version = xmlKernelInfo->os_version;
cosAppXmlInfoStruct.title_id = xmlKernelInfo->title_id;
cosAppXmlInfoStruct.app_type = xmlKernelInfo->app_type;
cosAppXmlInfoStruct.cmdFlags = xmlKernelInfo->cmdFlags;
cosAppXmlInfoStruct.max_size = xmlKernelInfo->max_size;
cosAppXmlInfoStruct.avail_size = xmlKernelInfo->avail_size;
cosAppXmlInfoStruct.codegen_size = xmlKernelInfo->codegen_size;
cosAppXmlInfoStruct.codegen_core = xmlKernelInfo->codegen_core;
cosAppXmlInfoStruct.max_codesize = xmlKernelInfo->max_codesize;
cosAppXmlInfoStruct.overlay_arena = xmlKernelInfo->overlay_arena;
cosAppXmlInfoStruct.default_stack0_size = xmlKernelInfo->default_stack0_size;
cosAppXmlInfoStruct.default_stack1_size = xmlKernelInfo->default_stack1_size;
cosAppXmlInfoStruct.default_stack2_size = xmlKernelInfo->default_stack2_size;
cosAppXmlInfoStruct.default_redzone0_size = xmlKernelInfo->default_redzone0_size;
cosAppXmlInfoStruct.default_redzone1_size = xmlKernelInfo->default_redzone1_size;
cosAppXmlInfoStruct.default_redzone2_size = xmlKernelInfo->default_redzone2_size;
cosAppXmlInfoStruct.exception_stack0_size = xmlKernelInfo->exception_stack0_size;
cosAppXmlInfoStruct.exception_stack1_size = xmlKernelInfo->exception_stack1_size;
cosAppXmlInfoStruct.exception_stack2_size = xmlKernelInfo->exception_stack2_size;
cosAppXmlInfoStruct.sdk_version = xmlKernelInfo->sdk_version;
cosAppXmlInfoStruct.title_version = xmlKernelInfo->title_version;
}
void SetupKernelCallback(void)
{
KernelSetupSyscalls();
}

View File

@ -1,19 +0,0 @@
#ifndef __KERNEL_FUNCTIONS_H_
#define __KERNEL_FUNCTIONS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "common/kernel_defs.h"
#include "syscalls.h"
void SetupKernelCallback(void);
extern ReducedCosAppXmlInfo cosAppXmlInfoStruct;
#ifdef __cplusplus
}
#endif
#endif // __KERNEL_FUNCTIONS_H_

View File

@ -1,136 +0,0 @@
# Created by dimok
# This stuff may need a change in different kernel versions
# This is only needed when launched directly through browser and not SD card.
.section ".kernel_code"
.globl SaveAndResetDataBATs_And_SRs_hook
SaveAndResetDataBATs_And_SRs_hook:
# setup CTR to the position we need to return to
mflr r5
mtctr r5
# set link register to its original value
mtlr r7
# setup us a nice DBAT for our code data with same region as our code
mfspr r5, 560
mtspr 570, r5
mfspr r5, 561
mtspr 571, r5
# restore the original kernel instructions that we replaced
lwz r5, 0x34(r3)
lwz r6, 0x38(r3)
lwz r7, 0x3C(r3)
lwz r8, 0x40(r3)
lwz r9, 0x44(r3)
lwz r10, 0x48(r3)
lwz r11, 0x4C(r3)
lwz r3, 0x50(r3)
isync
mtsr 7, r5
# jump back to the position in kernel after our patch (from LR)
bctr
.extern my_PrepareTitle
.globl my_PrepareTitle_hook
my_PrepareTitle_hook:
# store all registers on stack to avoid issues with the call to C functions
stwu r1, -0x90(r1)
# registers for our own usage
# only need r31 and rest is from tests before, just leaving it for later tests
stw r28, 0x20(r1)
stw r29, 0x24(r1)
stw r30, 0x28(r1)
stw r31, 0x2C(r1)
stw r3, 0x30(r1)
stw r4, 0x34(r1)
stw r5, 0x38(r1)
stw r6, 0x3C(r1)
stw r7, 0x40(r1)
stw r8, 0x44(r1)
stw r9, 0x48(r1)
stw r10, 0x4C(r1)
stw r11, 0x50(r1)
stw r12, 0x54(r1)
stw r13, 0x58(r1)
stw r14, 0x5C(r1)
stw r15, 0x60(r1)
stw r16, 0x64(r1)
stw r17, 0x68(r1)
stw r18, 0x6C(r1)
stw r19, 0x70(r1)
stw r20, 0x74(r1)
stw r21, 0x78(r1)
stw r22, 0x7C(r1)
# save original DBAT registers
mfdbatu r28, 0
mfdbatl r29, 0
# setup access to our data memory range
lis r3, 0xC000
ori r3, r3, 0x1FFF
mtdbatu 0, r3
lis r3, 0x3000
ori r3, r3, 0x0012
mtdbatl 0, r3
# memory barrier
eieio
isync
# save the LR from where we came
mflr r31
# the cos.xml/app.xml structure is at the location 0x68 of r11
# there are actually many places that can be hooked for it
# e.g. 0xFFF16130 and r27 points to this structure
addi r3, r11, 0x68
bl my_PrepareTitle
# restore original DBAT registers
mtdbatu 0, r28
mtdbatl 0, r29
# memory barrier
eieio
isync
# setup LR to jump back to kernel code
mtlr r31
# restore all original values of registers from stack
lwz r28, 0x20(r1)
lwz r29, 0x24(r1)
lwz r30, 0x28(r1)
lwz r31, 0x2C(r1)
lwz r3, 0x30(r1)
lwz r4, 0x34(r1)
lwz r5, 0x38(r1)
lwz r6, 0x3C(r1)
lwz r7, 0x40(r1)
lwz r8, 0x44(r1)
lwz r9, 0x48(r1)
lwz r10, 0x4C(r1)
lwz r11, 0x50(r1)
lwz r12, 0x54(r1)
lwz r13, 0x58(r1)
lwz r14, 0x5C(r1)
lwz r15, 0x60(r1)
lwz r16, 0x64(r1)
lwz r17, 0x68(r1)
lwz r18, 0x6C(r1)
lwz r19, 0x70(r1)
lwz r20, 0x74(r1)
lwz r21, 0x78(r1)
lwz r22, 0x7C(r1)
# restore the stack
addi r1, r1, 0x90
# restore original instruction that we replaced in the kernel
clrlwi r7, r12, 0
# jump back
blr

View File

@ -1,255 +0,0 @@
#include "common/os_defs.h"
#include "common/kernel_defs.h"
#include "common/common.h"
#include "dynamic_libs/os_functions.h"
#include "utils/utils.h"
#include "syscalls.h"
extern void my_PrepareTitle_hook(void);
static unsigned int origPrepareTitleInstr __attribute__((section(".data"))) = 0;
static void KernelCopyData(unsigned int addr, unsigned int src, unsigned int len)
{
/*
* Setup a DBAT access with cache inhibited to write through and read directly from memory
*/
unsigned int dbatu0, dbatl0, dbatu1, dbatl1;
// save the original DBAT value
asm volatile("mfdbatu %0, 0" : "=r" (dbatu0));
asm volatile("mfdbatl %0, 0" : "=r" (dbatl0));
asm volatile("mfdbatu %0, 1" : "=r" (dbatu1));
asm volatile("mfdbatl %0, 1" : "=r" (dbatl1));
unsigned int target_dbatu0 = 0;
unsigned int target_dbatl0 = 0;
unsigned int target_dbatu1 = 0;
unsigned int target_dbatl1 = 0;
unsigned char *dst_p = (unsigned char*)addr;
unsigned char *src_p = (unsigned char*)src;
// we only need DBAT modification for addresses out of our own DBAT range
// as our own DBAT is available everywhere for user and supervisor
// since our own DBAT is on DBAT5 position we don't collide here
if(addr < 0x00800000 || addr >= 0x01000000)
{
target_dbatu0 = (addr & 0x00F00000) | 0xC0000000 | 0x1F;
target_dbatl0 = (addr & 0xFFF00000) | 0x32;
asm volatile("mtdbatu 0, %0" : : "r" (target_dbatu0));
asm volatile("mtdbatl 0, %0" : : "r" (target_dbatl0));
dst_p = (unsigned char*)((addr & 0xFFFFFF) | 0xC0000000);
}
if(src < 0x00800000 || src >= 0x01000000)
{
target_dbatu1 = (src & 0x00F00000) | 0xB0000000 | 0x1F;
target_dbatl1 = (src & 0xFFF00000) | 0x32;
asm volatile("mtdbatu 1, %0" : : "r" (target_dbatu1));
asm volatile("mtdbatl 1, %0" : : "r" (target_dbatl1));
src_p = (unsigned char*)((src & 0xFFFFFF) | 0xB0000000);
}
asm volatile("eieio; isync");
unsigned int i;
for(i = 0; i < len; i++)
{
// if we are on the edge to next chunk
if((target_dbatu0 != 0) && (((unsigned int)dst_p & 0x00F00000) != (target_dbatu0 & 0x00F00000)))
{
target_dbatu0 = ((addr + i) & 0x00F00000) | 0xC0000000 | 0x1F;
target_dbatl0 = ((addr + i) & 0xFFF00000) | 0x32;
dst_p = (unsigned char*)(((addr + i) & 0xFFFFFF) | 0xC0000000);
asm volatile("eieio; isync");
asm volatile("mtdbatu 0, %0" : : "r" (target_dbatu0));
asm volatile("mtdbatl 0, %0" : : "r" (target_dbatl0));
asm volatile("eieio; isync");
}
if((target_dbatu1 != 0) && (((unsigned int)src_p & 0x00F00000) != (target_dbatu1 & 0x00F00000)))
{
target_dbatu1 = ((src + i) & 0x00F00000) | 0xB0000000 | 0x1F;
target_dbatl1 = ((src + i) & 0xFFF00000) | 0x32;
src_p = (unsigned char*)(((src + i) & 0xFFFFFF) | 0xB0000000);
asm volatile("eieio; isync");
asm volatile("mtdbatu 1, %0" : : "r" (target_dbatu1));
asm volatile("mtdbatl 1, %0" : : "r" (target_dbatl1));
asm volatile("eieio; isync");
}
*dst_p = *src_p;
++dst_p;
++src_p;
}
/*
* Restore original DBAT value
*/
asm volatile("eieio; isync");
asm volatile("mtdbatu 0, %0" : : "r" (dbatu0));
asm volatile("mtdbatl 0, %0" : : "r" (dbatl0));
asm volatile("mtdbatu 1, %0" : : "r" (dbatu1));
asm volatile("mtdbatl 1, %0" : : "r" (dbatl1));
asm volatile("eieio; isync");
}
static void KernelReadDBATs(bat_table_t * table)
{
u32 i = 0;
asm volatile("eieio; isync");
asm volatile("mfspr %0, 536" : "=r" (table->bat[i].h));
asm volatile("mfspr %0, 537" : "=r" (table->bat[i].l));
i++;
asm volatile("mfspr %0, 538" : "=r" (table->bat[i].h));
asm volatile("mfspr %0, 539" : "=r" (table->bat[i].l));
i++;
asm volatile("mfspr %0, 540" : "=r" (table->bat[i].h));
asm volatile("mfspr %0, 541" : "=r" (table->bat[i].l));
i++;
asm volatile("mfspr %0, 542" : "=r" (table->bat[i].h));
asm volatile("mfspr %0, 543" : "=r" (table->bat[i].l));
i++;
asm volatile("mfspr %0, 568" : "=r" (table->bat[i].h));
asm volatile("mfspr %0, 569" : "=r" (table->bat[i].l));
i++;
asm volatile("mfspr %0, 570" : "=r" (table->bat[i].h));
asm volatile("mfspr %0, 571" : "=r" (table->bat[i].l));
i++;
asm volatile("mfspr %0, 572" : "=r" (table->bat[i].h));
asm volatile("mfspr %0, 573" : "=r" (table->bat[i].l));
i++;
asm volatile("mfspr %0, 574" : "=r" (table->bat[i].h));
asm volatile("mfspr %0, 575" : "=r" (table->bat[i].l));
}
static void KernelWriteDBATs(bat_table_t * table)
{
u32 i = 0;
asm volatile("eieio; isync");
asm volatile("mtspr 536, %0" : : "r" (table->bat[i].h));
asm volatile("mtspr 537, %0" : : "r" (table->bat[i].l));
i++;
asm volatile("mtspr 538, %0" : : "r" (table->bat[i].h));
asm volatile("mtspr 539, %0" : : "r" (table->bat[i].l));
i++;
asm volatile("mtspr 540, %0" : : "r" (table->bat[i].h));
asm volatile("mtspr 541, %0" : : "r" (table->bat[i].l));
i++;
asm volatile("mtspr 542, %0" : : "r" (table->bat[i].h));
asm volatile("mtspr 543, %0" : : "r" (table->bat[i].l));
i++;
asm volatile("mtspr 568, %0" : : "r" (table->bat[i].h));
asm volatile("mtspr 569, %0" : : "r" (table->bat[i].l));
i++;
asm volatile("mtspr 570, %0" : : "r" (table->bat[i].h));
asm volatile("mtspr 571, %0" : : "r" (table->bat[i].l));
i++;
asm volatile("mtspr 572, %0" : : "r" (table->bat[i].h));
asm volatile("mtspr 573, %0" : : "r" (table->bat[i].l));
i++;
asm volatile("mtspr 574, %0" : : "r" (table->bat[i].h));
asm volatile("mtspr 575, %0" : : "r" (table->bat[i].l));
asm volatile("eieio; isync");
}
/* Read a 32-bit word with kernel permissions */
uint32_t __attribute__ ((noinline)) kern_read(const void *addr)
{
uint32_t result;
asm volatile (
"li 3,1\n"
"li 4,0\n"
"li 5,0\n"
"li 6,0\n"
"li 7,0\n"
"lis 8,1\n"
"mr 9,%1\n"
"li 0,0x3400\n"
"mr %0,1\n"
"sc\n"
"nop\n"
"mr 1,%0\n"
"mr %0,3\n"
: "=r"(result)
: "b"(addr)
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12"
);
return result;
}
/* Write a 32-bit word with kernel permissions */
void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value)
{
asm volatile (
"li 3,1\n"
"li 4,0\n"
"mr 5,%1\n"
"li 6,0\n"
"li 7,0\n"
"lis 8,1\n"
"mr 9,%0\n"
"mr %1,1\n"
"li 0,0x3500\n"
"sc\n"
"nop\n"
"mr 1,%1\n"
:
: "r"(addr), "r"(value)
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12"
);
}
void KernelSetupSyscalls(void)
{
//! assign 1 so that this variable gets into the retained .data section
static uint8_t ucSyscallsSetupRequired = 1;
if(!ucSyscallsSetupRequired)
return;
ucSyscallsSetupRequired = 0;
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x36 * 4)), (unsigned int)KernelReadDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x36 * 4)), (unsigned int)KernelReadDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x36 * 4)), (unsigned int)KernelReadDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x36 * 4)), (unsigned int)KernelReadDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x36 * 4)), (unsigned int)KernelReadDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x37 * 4)), (unsigned int)KernelWriteDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x37 * 4)), (unsigned int)KernelWriteDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x37 * 4)), (unsigned int)KernelWriteDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x37 * 4)), (unsigned int)KernelWriteDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x37 * 4)), (unsigned int)KernelWriteDBATs);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl1 + (0x25 * 4)), (unsigned int)KernelCopyData);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl2 + (0x25 * 4)), (unsigned int)KernelCopyData);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl3 + (0x25 * 4)), (unsigned int)KernelCopyData);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl4 + (0x25 * 4)), (unsigned int)KernelCopyData);
kern_write((void*)(OS_SPECIFICS->addr_KernSyscallTbl5 + (0x25 * 4)), (unsigned int)KernelCopyData);
//! write our hook to the
u32 addr_my_PrepareTitle_hook = ((u32)my_PrepareTitle_hook) | 0x48000003;
DCFlushRange(&addr_my_PrepareTitle_hook, sizeof(addr_my_PrepareTitle_hook));
SC0x25_KernelCopyData((u32)&origPrepareTitleInstr, (u32)addr_PrepareTitle_hook, 4);
SC0x25_KernelCopyData((u32)addr_PrepareTitle_hook, (u32)OSEffectiveToPhysical(&addr_my_PrepareTitle_hook), 4);
}
void KernelRestoreInstructions(void)
{
if(origPrepareTitleInstr != 0)
SC0x25_KernelCopyData((u32)addr_PrepareTitle_hook, (u32)&origPrepareTitleInstr, 4);
}

View File

@ -1,26 +0,0 @@
#ifndef __SYSCALLS_H_
#define __SYSCALLS_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <gctypes.h>
#include "common/kernel_defs.h"
void KernelSetupSyscalls(void);
void KernelRestoreInstructions(void);
void SC0x25_KernelCopyData(unsigned int addr, unsigned int src, unsigned int len);
void SC0x36_KernelReadDBATs(bat_table_t * table);
void SC0x37_KernelWriteDBATs(bat_table_t * table);
uint32_t __attribute__ ((noinline)) kern_read(const void *addr);
void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value);
#ifdef __cplusplus
}
#endif
#endif // __KERNEL_FUNCTIONS_H_

View File

@ -1,20 +0,0 @@
# Created by dimok
# Syscalls for kernel that we use
.globl SC0x36_KernelReadDBATs
SC0x36_KernelReadDBATs:
li r0, 0x3600
sc
blr
.globl SC0x37_KernelWriteDBATs
SC0x37_KernelWriteDBATs:
li r0, 0x3700
sc
blr
.globl SC0x25_KernelCopyData
SC0x25_KernelCopyData:
li r0, 0x2500
sc
blr

View File

@ -1,26 +1,12 @@
#include <nsysnet/socket.h>
#include "Application.h" #include "Application.h"
#include "dynamic_libs/os_functions.h"
#include "dynamic_libs/gx2_functions.h"
#include "dynamic_libs/syshid_functions.h"
#include "dynamic_libs/vpad_functions.h"
#include "dynamic_libs/padscore_functions.h" #include "dynamic_libs/padscore_functions.h"
#include "dynamic_libs/socket_functions.h"
#include "dynamic_libs/sys_functions.h"
#include "dynamic_libs/ax_functions.h"
#include "dynamic_libs/fs_functions.h"
#include "fs/fs_utils.h"
#include "fs/sd_fat_devoptab.h"
#include "system/memory.h" #include "system/memory.h"
#include "utils/logger.h" #include "utils/logger.h"
#include "utils/utils.h" #include "utils/utils.h"
#include "common/common.h" #include "common/common.h"
#include "main.h" #include "main.h"
#include "common/common.h"
#include "utils/logger.h"
#include "system/memory.h"
/* Entry point */ /* Entry point */
extern "C" int Menu_Main(void){ extern "C" int Menu_Main(void){
@ -28,14 +14,7 @@ extern "C" int Menu_Main(void){
//! Initialize function pointers * //! Initialize function pointers *
//!******************************************************************* //!*******************************************************************
//! do OS (for acquire) and sockets first so we got logging //! do OS (for acquire) and sockets first so we got logging
InitOSFunctionPointers();
InitSocketFunctionPointers();
InitGX2FunctionPointers();
InitSysFunctionPointers();
InitVPadFunctionPointers();
InitPadScoreFunctionPointers(); InitPadScoreFunctionPointers();
InitAXFunctionPointers();
InitFSFunctionPointers();
log_init("192.168.0.181"); log_init("192.168.0.181");
@ -48,18 +27,14 @@ extern "C" int Menu_Main(void){
log_print("Initialize memory management\n"); log_print("Initialize memory management\n");
memoryInitialize(); memoryInitialize();
log_printf("Mount SD partition\n");
mount_sd_fat("sd");
log_printf("Start main application\n"); log_printf("Start main application\n");
Application::instance()->exec(); Application::instance()->exec();
Application::destroyInstance(); Application::destroyInstance();
log_printf("Unmount SD\n");
unmount_sd_fat("sd");
memoryRelease(); memoryRelease();
log_print("Going back to the Homebrew launcher\n"); log_print("Going back to the Homebrew launcher\n");
log_deinit();
log_deinit();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View File

@ -2,7 +2,6 @@
#define _MAIN_H_ #define _MAIN_H_
#include "common/types.h" #include "common/types.h"
#include "dynamic_libs/os_functions.h"
/* Main */ /* Main */
#ifdef __cplusplus #ifdef __cplusplus
@ -11,7 +10,7 @@ extern "C" {
//! C wrapper for our C++ functions //! C wrapper for our C++ functions
int Menu_Main(void); int Menu_Main(void);
void deInit(void);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -17,8 +17,6 @@
****************************************************************************/ ****************************************************************************/
#include "MainWindow.h" #include "MainWindow.h"
#include "MainWindowTV.h" #include "MainWindowTV.h"
#include "dynamic_libs/os_functions.h"
#include "dynamic_libs/socket_functions.h"
#include "Application.h" #include "Application.h"
#include "utils/StringTools.h" #include "utils/StringTools.h"
#include "utils/logger.h" #include "utils/logger.h"

View File

@ -1,4 +1,3 @@
#include <gctypes.h>
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include "Resources.h" #include "Resources.h"

View File

@ -1,8 +1,8 @@
#ifndef RECOURCES_H_ #ifndef RECOURCES_H_
#define RECOURCES_H_ #define RECOURCES_H_
#include <map> #include <map>
#include "common/types.h"
//! forward declaration //! forward declaration
class GuiImageData; class GuiImageData;

View File

@ -9,8 +9,6 @@
#ifndef _FILELIST_H_ #ifndef _FILELIST_H_
#define _FILELIST_H_ #define _FILELIST_H_
#include <gctypes.h>
typedef struct _RecourceFile typedef struct _RecourceFile
{ {
const char *filename; const char *filename;

View File

@ -23,6 +23,7 @@
* *
* for WiiXplorer 2010 * for WiiXplorer 2010
***************************************************************************/ ***************************************************************************/
#include <unistd.h>
#include <malloc.h> #include <malloc.h>
#include "utils/utils.h" #include "utils/utils.h"
#include "BufferCircle.hpp" #include "BufferCircle.hpp"

View File

@ -27,7 +27,7 @@
#define BUFFER_CIRCLE_HPP_ #define BUFFER_CIRCLE_HPP_
#include <vector> #include <vector>
#include <gctypes.h> #include "common/types.h"
class BufferCircle class BufferCircle
{ {

View File

@ -29,7 +29,7 @@
#include <unistd.h> #include <unistd.h>
#include <malloc.h> #include <malloc.h>
#include <math.h> #include <math.h>
#include "dynamic_libs/os_functions.h" #include "common/types.h"
#include "Mp3Decoder.hpp" #include "Mp3Decoder.hpp"
Mp3Decoder::Mp3Decoder(const char * filepath) Mp3Decoder::Mp3Decoder(const char * filepath)

View File

@ -25,7 +25,6 @@
***************************************************************************/ ***************************************************************************/
#include <unistd.h> #include <unistd.h>
#include <malloc.h> #include <malloc.h>
#include "dynamic_libs/os_functions.h"
#include "OggDecoder.hpp" #include "OggDecoder.hpp"
static int ogg_read(void * punt, int bytes, int blocks, int *f) static int ogg_read(void * punt, int bytes, int blocks, int *f)

View File

@ -14,11 +14,10 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/ ****************************************************************************/
#include <gctypes.h>
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include "dynamic_libs/os_functions.h" #include <coreinit/cache.h>
#include "SoundDecoder.hpp" #include "SoundDecoder.hpp"
static const u32 FixedPointShift = 15; static const u32 FixedPointShift = 15;

View File

@ -26,7 +26,6 @@
#include <unistd.h> #include <unistd.h>
#include <malloc.h> #include <malloc.h>
#include "common/common.h" #include "common/common.h"
#include "dynamic_libs/ax_functions.h"
#include "fs/CFile.hpp" #include "fs/CFile.hpp"
#include "SoundHandler.hpp" #include "SoundHandler.hpp"
#include "WavDecoder.hpp" #include "WavDecoder.hpp"
@ -95,7 +94,11 @@ void SoundHandler::RemoveDecoder(int voice)
if(voiceList[voice]->getState() != Voice::STATE_STOP) if(voiceList[voice]->getState() != Voice::STATE_STOP)
voiceList[voice]->setState(Voice::STATE_STOP); voiceList[voice]->setState(Voice::STATE_STOP);
while(voiceList[voice]->getState() != Voice::STATE_STOPPED) // it shouldn't take longer than 3 ms actually but we wait up to 20
// on application quit the AX frame callback is not called anymore
// therefore this would end in endless loop if no timeout is defined
int timeOut = 20;
while(--timeOut && (voiceList[voice]->getState() != Voice::STATE_STOPPED))
usleep(1000); usleep(1000);
} }
SoundDecoder *decoder = DecoderList[voice]; SoundDecoder *decoder = DecoderList[voice];
@ -216,19 +219,16 @@ SoundDecoder * SoundHandler::GetSoundDecoder(const u8 * sound, int length)
void SoundHandler::executeThread() void SoundHandler::executeThread()
{ {
// v2 sound lib can not properly end transition audio on old firmwares
if (OS_FIRMWARE >= 400 && OS_FIRMWARE <= 410)
{
ProperlyEndTransitionAudio();
}
//! initialize 48 kHz renderer //! initialize 48 kHz renderer
u32 params[3] = { 1, 0, 0 }; AXInitParams params;
memset(&params, 0, sizeof(params));
params.renderer = AX_INIT_RENDERER_48KHZ;
if(AXInitWithParams != 0) // TODO: handle support for 3.1.0 with dynamic libs instead of static linking it
AXInitWithParams(params); //if(AXInitWithParams != 0)
else AXInitWithParams(&params);
AXInit(); //else
// AXInit();
// The problem with last voice on 500 was caused by it having priority 0 // The problem with last voice on 500 was caused by it having priority 0
// We would need to change this priority distribution if for some reason // We would need to change this priority distribution if for some reason
@ -239,7 +239,7 @@ void SoundHandler::executeThread()
voiceList[i] = new Voice(priority); // allocate voice 0 with highest priority voiceList[i] = new Voice(priority); // allocate voice 0 with highest priority
} }
AXRegisterFrameCallback((void*)&axFrameCallback); AXRegisterAppFrameCallback(SoundHandler::axFrameCallback);
u16 i = 0; u16 i = 0;
@ -266,7 +266,7 @@ void SoundHandler::executeThread()
for(u32 i = 0; i < MAX_DECODERS; ++i) for(u32 i = 0; i < MAX_DECODERS; ++i)
voiceList[i]->stop(); voiceList[i]->stop();
AXRegisterFrameCallback(NULL); AXRegisterAppFrameCallback(NULL);
AXQuit(); AXQuit();
for(u32 i = 0; i < MAX_DECODERS; ++i) for(u32 i = 0; i < MAX_DECODERS; ++i)

View File

@ -27,7 +27,7 @@
#define SOUNDHANDLER_H_ #define SOUNDHANDLER_H_
#include <vector> #include <vector>
#include <gctypes.h> #include "common/types.h"
#include "system/CThread.h" #include "system/CThread.h"
#include "SoundDecoder.hpp" #include "SoundDecoder.hpp"
#include "Voice.h" #include "Voice.h"

View File

@ -17,8 +17,8 @@
#ifndef _AXSOUND_H_ #ifndef _AXSOUND_H_
#define _AXSOUND_H_ #define _AXSOUND_H_
#include "dynamic_libs/os_functions.h" #include <sndcore2/core.h>
#include "dynamic_libs/ax_functions.h" #include <sndcore2/voice.h>
class Voice class Voice
{ {
@ -47,19 +47,18 @@ public:
voice = AXAcquireVoice(prio, 0, 0); voice = AXAcquireVoice(prio, 0, 0);
if(voice) if(voice)
{ {
AXVoiceBegin(voice);
AXSetVoiceType(voice, 0); AXSetVoiceType(voice, 0);
setVolume(0x80000000); setVolume(0x80000000);
u32 mix[24]; AXVoiceDeviceMixData mix[6];
memset(mix, 0, sizeof(mix)); memset(mix, 0, sizeof(mix));
mix[0] = 0x80000000; mix[0].bus[0].volume = 0x8000;
mix[4] = 0x80000000; mix[0].bus[0].delta = 0;
mix[1].bus[0].volume = 0x8000;
mix[1].bus[0].delta = 0;
AXSetVoiceDeviceMix(voice, 0, 0, mix); AXSetVoiceDeviceMix(voice, 0, 0, mix);
AXSetVoiceDeviceMix(voice, 1, 0, mix); AXSetVoiceDeviceMix(voice, 1, 0, mix);
AXVoiceEnd(voice);
} }
} }
@ -78,23 +77,23 @@ public:
memset(&voiceBuffer, 0, sizeof(voiceBuffer)); memset(&voiceBuffer, 0, sizeof(voiceBuffer));
voiceBuffer.samples = buffer; voiceBuffer.data = buffer;
voiceBuffer.format = format; voiceBuffer.dataType = format;
voiceBuffer.loop = (nextBuffer == NULL) ? 0 : 1; voiceBuffer.loopingEnabled = (nextBuffer == NULL) ? 0 : 1;
voiceBuffer.cur_pos = 0; voiceBuffer.currentOffset = 0;
voiceBuffer.end_pos = bufferSize >> 1; voiceBuffer.endOffset = (bufferSize >> 1) - 1;
voiceBuffer.loop_offset = ((nextBuffer - buffer) >> 1); voiceBuffer.loopOffset = ((nextBuffer - buffer) >> 1);
nextBufferSize = nextBufSize; nextBufferSize = nextBufSize;
u32 samplesPerSec = (AXGetInputSamplesPerSec != 0) ? AXGetInputSamplesPerSec() : 32000; // TODO: handle support for 3.1.0 with dynamic libs instead of static linking it
//u32 samplesPerSec = (AXGetInputSamplesPerSec != 0) ? AXGetInputSamplesPerSec() : 32000;
u32 samplesPerSec = AXGetInputSamplesPerSec();
ratioBits[0] = (u32)(0x00010000 * ((f32)sampleRate / (f32)samplesPerSec)); memset(&ratioBits, 0, sizeof(ratioBits));
ratioBits[1] = 0; ratioBits.ratio = (u32)(0x00010000 * ((f32)sampleRate / (f32)samplesPerSec));
ratioBits[2] = 0;
ratioBits[3] = 0;
AXSetVoiceOffsets(voice, &voiceBuffer); AXSetVoiceOffsets(voice, &voiceBuffer);
AXSetVoiceSrc(voice, ratioBits); AXSetVoiceSrc(voice, &ratioBits);
AXSetVoiceSrcType(voice, 1); AXSetVoiceSrcType(voice, 1);
AXSetVoiceState(voice, 1); AXSetVoiceState(voice, 1);
} }
@ -108,16 +107,21 @@ public:
void setVolume(u32 vol) void setVolume(u32 vol)
{ {
if(voice) if(voice)
AXSetVoiceVe(voice, &vol); {
AXVoiceVeData data;
data.volume = vol >> 16;
data.delta = vol & 0xFFFF;
AXSetVoiceVe(voice, &data);
}
} }
void setNextBuffer(const u8 *buffer, u32 bufferSize) void setNextBuffer(const u8 *buffer, u32 bufferSize)
{ {
voiceBuffer.loop_offset = ((buffer - voiceBuffer.samples) >> 1); voiceBuffer.loopOffset = ((buffer - (const u8*)voiceBuffer.data) >> 1);
nextBufferSize = bufferSize; nextBufferSize = bufferSize;
AXSetVoiceLoopOffset(voice, voiceBuffer.loop_offset); AXSetVoiceLoopOffset(voice, voiceBuffer.loopOffset);
} }
bool isBufferSwitched() bool isBufferSwitched()
@ -126,7 +130,7 @@ public:
if(lastLoopCounter != loopCounter) if(lastLoopCounter != loopCounter)
{ {
lastLoopCounter = loopCounter; lastLoopCounter = loopCounter;
AXSetVoiceEndOffset(voice, voiceBuffer.loop_offset + (nextBufferSize >> 1)); AXSetVoiceEndOffset(voice, voiceBuffer.loopOffset + (nextBufferSize >> 1) - 1);
return true; return true;
} }
return false; return false;
@ -149,19 +153,9 @@ public:
} }
private: private:
void *voice; AXVoice *voice;
u32 ratioBits[4]; AXVoiceSrc ratioBits;
AXVoiceOffsets voiceBuffer;
typedef struct _ax_buffer_t {
u16 format;
u16 loop;
u32 loop_offset;
u32 end_pos;
u32 cur_pos;
const unsigned char *samples;
} ax_buffer_t;
ax_buffer_t voiceBuffer;
u32 state; u32 state;
u32 nextBufferSize; u32 nextBufferSize;
u32 lastLoopCounter; u32 lastLoopCounter;

View File

@ -54,7 +54,7 @@ void AsyncDeleter::executeThread(void)
while(!exitApplication) while(!exitApplication)
{ {
suspendThread(); suspendThread();
log_printf("AsyncDeleter thread running\n");
//! delete elements that require post process deleting //! delete elements that require post process deleting
//! because otherwise they would block or do invalid access on GUI thread //! because otherwise they would block or do invalid access on GUI thread
while(!realDeleteElements.empty()) while(!realDeleteElements.empty())

View File

@ -26,10 +26,8 @@ class AsyncDeleter : public CThread
public: public:
static void destroyInstance() static void destroyInstance()
{ {
if(deleterInstance != NULL){ delete deleterInstance;
delete deleterInstance; deleterInstance = NULL;
deleterInstance = NULL;
}
} }
class Element class Element
@ -43,6 +41,7 @@ public:
{ {
if(!deleterInstance) if(!deleterInstance)
deleterInstance = new AsyncDeleter; deleterInstance = new AsyncDeleter;
deleterInstance->deleteElements.push(e); deleterInstance->deleteElements.push(e);
} }

View File

@ -18,13 +18,13 @@
#define _CMUTEX_H_ #define _CMUTEX_H_
#include <malloc.h> #include <malloc.h>
#include "dynamic_libs/os_functions.h" #include <coreinit/mutex.h>
class CMutex class CMutex
{ {
public: public:
CMutex() { CMutex() {
pMutex = malloc(OS_MUTEX_SIZE); pMutex = (OSMutex*) malloc(sizeof(OSMutex));
if(!pMutex) if(!pMutex)
return; return;
@ -50,7 +50,7 @@ public:
return (OSTryLockMutex(pMutex) != 0); return (OSTryLockMutex(pMutex) != 0);
} }
private: private:
void *pMutex; OSMutex *pMutex;
}; };
class CMutexLock class CMutexLock

View File

@ -17,11 +17,9 @@
#ifndef CTHREAD_H_ #ifndef CTHREAD_H_
#define CTHREAD_H_ #define CTHREAD_H_
#include <gctypes.h>
#include <malloc.h> #include <malloc.h>
#include <unistd.h> #include <unistd.h>
#include "dynamic_libs/os_functions.h" #include <coreinit/thread.h>
#include "utils/logger.h"
class CThread class CThread
{ {
@ -38,12 +36,12 @@ public:
//! save attribute assignment //! save attribute assignment
iAttributes = iAttr; iAttributes = iAttr;
//! allocate the thread //! allocate the thread
pThread = memalign(8, 0x1000); pThread = (OSThread*)memalign(8, sizeof(OSThread));
//! allocate the stack //! allocate the stack
pThreadStack = (u8 *) memalign(0x20, iStackSize); pThreadStack = (u8 *) memalign(0x20, iStackSize);
//! create the thread //! create the thread
if(pThread && pThreadStack) if(pThread && pThreadStack)
OSCreateThread(pThread, &CThread::threadCallback, 1, this, (u32)pThreadStack+iStackSize, iStackSize, iPriority, iAttributes); OSCreateThread(pThread, &CThread::threadCallback, 1, (char*)this, pThreadStack+iStackSize, iStackSize, iPriority, iAttributes);
} }
//! destructor //! destructor
@ -80,17 +78,17 @@ public:
//! wait for thread to finish //! wait for thread to finish
if(pThread && !(iAttributes & eAttributeDetach)) if(pThread && !(iAttributes & eAttributeDetach))
{ {
while(isThreadSuspended()){ if(isThreadSuspended())
resumeThread(); resumeThread();
}
OSJoinThread(pThread, NULL); OSJoinThread(pThread, NULL);
} }
//! free the thread stack buffer //! free the thread stack buffer
if(pThreadStack){ if(pThreadStack)
free(pThreadStack); free(pThreadStack);
}
if(pThread) if(pThread)
free(pThread); free(pThread);
pThread = NULL; pThread = NULL;
pThreadStack = NULL; pThreadStack = NULL;
} }
@ -105,14 +103,14 @@ public:
eAttributePinnedAff = 0x10 eAttributePinnedAff = 0x10
}; };
private: private:
static int threadCallback(int argc, void *arg) static int threadCallback(int argc, const char **argv)
{ {
//! After call to start() continue with the internal function //! After call to start() continue with the internal function
((CThread *) arg)->executeThread(); ((CThread *) argv)->executeThread();
return 0; return 0;
} }
int iAttributes; int iAttributes;
void *pThread; OSThread *pThread;
u8 *pThreadStack; u8 *pThreadStack;
Callback pCallback; Callback pCallback;
void *pCallbackArg; void *pCallbackArg;

View File

@ -1,6 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include "dynamic_libs/os_functions.h" #include "common/types.h"
#include "utils/logger.h"
#include "exception_handler.h" #include "exception_handler.h"
#define OS_EXCEPTION_MODE_GLOBAL_ALL_CORES 4 #define OS_EXCEPTION_MODE_GLOBAL_ALL_CORES 4
@ -36,6 +35,9 @@ typedef struct OSContext
/* There is actually a lot more here but we don't need the rest*/ /* There is actually a lot more here but we don't need the rest*/
} OSContext; } OSContext;
#include <coreinit/exception.h>
#include <coreinit/debug.h>
#define CPU_STACK_TRACE_DEPTH 10 #define CPU_STACK_TRACE_DEPTH 10
#define __stringify(rn) #rn #define __stringify(rn) #rn
@ -78,11 +80,9 @@ static const char exception_print_formats[18][45] = {
"%p: %08X %08X %08X %08X\n", // 17 "%p: %08X %08X %08X %08X\n", // 17
}; };
static unsigned char exception_cb(void * c, unsigned char exception_type) { static unsigned char exception_cb(OSContext * context, unsigned char exception_type) {
char buf[850]; char buf[850];
int pos = 0; int pos = 0;
OSContext *context = (OSContext *) c;
/* /*
* This part is mostly from libogc. Thanks to the devs over there. * This part is mostly from libogc. Thanks to the devs over there.
*/ */
@ -147,7 +147,7 @@ static unsigned char exception_cb(void * c, unsigned char exception_type) {
for (i = 0; i < 8; i += 4) for (i = 0; i < 8; i += 4)
pos += sprintf(buf + pos, exception_print_formats[17], &(pAdd[i]),pAdd[i], pAdd[i+1], pAdd[i+2], pAdd[i+3]); pos += sprintf(buf + pos, exception_print_formats[17], &(pAdd[i]),pAdd[i], pAdd[i+1], pAdd[i+2], pAdd[i+3]);
//} //}
log_print(buf);
OSFatal(buf); OSFatal(buf);
return 1; return 1;
} }
@ -163,7 +163,7 @@ static unsigned char program_exception_cb(void * context) {
} }
void setup_os_exceptions(void) { void setup_os_exceptions(void) {
OSSetExceptionCallback(OS_EXCEPTION_DSI, &dsi_exception_cb); OSSetExceptionCallback(OS_EXCEPTION_DSI, (OSExceptionCallbackFn)dsi_exception_cb);
OSSetExceptionCallback(OS_EXCEPTION_ISI, &isi_exception_cb); OSSetExceptionCallback(OS_EXCEPTION_ISI, (OSExceptionCallbackFn)isi_exception_cb);
OSSetExceptionCallback(OS_EXCEPTION_PROGRAM, &program_exception_cb); OSSetExceptionCallback(OS_EXCEPTION_PROGRAM, (OSExceptionCallbackFn)program_exception_cb);
} }

View File

@ -16,7 +16,10 @@
****************************************************************************/ ****************************************************************************/
#include <malloc.h> #include <malloc.h>
#include <string.h> #include <string.h>
#include "dynamic_libs/os_functions.h" #include <coreinit/memheap.h>
#include <coreinit/baseheap.h>
#include <coreinit/expandedheap.h>
#include <coreinit/frameheap.h>
#include "common/common.h" #include "common/common.h"
#include "memory.h" #include "memory.h"
@ -34,48 +37,46 @@
//! Memory functions //! Memory functions
//! This is the only place where those are needed so lets keep them more or less private //! This is the only place where those are needed so lets keep them more or less private
//!---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- //!----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
extern unsigned int * pMEMAllocFromDefaultHeapEx; static MEMExpandedHeap * mem1_heap = NULL;
extern unsigned int * pMEMAllocFromDefaultHeap; static MEMExpandedHeap * bucket_heap = NULL;
extern unsigned int * pMEMFreeToDefaultHeap;
extern int (* MEMGetBaseHeapHandle)(int mem_arena);
extern unsigned int (* MEMGetAllocatableSizeForFrmHeapEx)(int heap, int align);
extern void *(* MEMAllocFromFrmHeapEx)(int heap, unsigned int size, int align);
extern void (* MEMFreeToFrmHeap)(int heap, int mode);
extern void *(* MEMAllocFromExpHeapEx)(int heap, unsigned int size, int align);
extern int (* MEMCreateExpHeapEx)(void* address, unsigned int size, unsigned short flags);
extern void *(* MEMDestroyExpHeap)(int heap);
extern void (* MEMFreeToExpHeap)(int heap, void* ptr);
static int mem1_heap = -1;
static int bucket_heap = -1;
void memoryInitialize(void) void memoryInitialize(void)
{ {
int mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1); if(!mem1_heap)
unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4); {
void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4); MEMFrameHeap * mem1_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_1);
if(mem1_memory) unsigned int mem1_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(mem1_heap_handle, 4);
mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0); void *mem1_memory = MEMAllocFromFrmHeapEx(mem1_heap_handle, mem1_allocatable_size, 4);
if(mem1_memory)
mem1_heap = MEMCreateExpHeapEx(mem1_memory, mem1_allocatable_size, 0);
}
int bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET); if(!bucket_heap)
unsigned int bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4); {
void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4); MEMFrameHeap * bucket_heap_handle = MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET);
if(bucket_memory) unsigned int bucket_allocatable_size = MEMGetAllocatableSizeForFrmHeapEx(bucket_heap_handle, 4);
bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0); void *bucket_memory = MEMAllocFromFrmHeapEx(bucket_heap_handle, bucket_allocatable_size, 4);
if(bucket_memory)
bucket_heap = MEMCreateExpHeapEx(bucket_memory, bucket_allocatable_size, 0);
}
} }
void memoryRelease(void) void memoryRelease(void)
{ {
MEMDestroyExpHeap(mem1_heap); if(mem1_heap)
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_1), 3); {
mem1_heap = -1; MEMDestroyExpHeap(mem1_heap);
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_1), 3);
MEMDestroyExpHeap(bucket_heap); mem1_heap = NULL;
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET), 3); }
bucket_heap = -1; if(bucket_heap)
{
MEMDestroyExpHeap(bucket_heap);
MEMFreeToFrmHeap(MEMGetBaseHeapHandle(MEMORY_ARENA_FG_BUCKET), 3);
bucket_heap = NULL;
}
} }
/*
//!------------------------------------------------------------------------------------------- //!-------------------------------------------------------------------------------------------
//! wraps //! wraps
//!------------------------------------------------------------------------------------------- //!-------------------------------------------------------------------------------------------
@ -159,18 +160,18 @@ void *__wrap__realloc_r(struct _reent *r, void *p, size_t size)
{ {
return __wrap_realloc(p, size); return __wrap_realloc(p, size);
} }
*/
//!------------------------------------------------------------------------------------------- //!-------------------------------------------------------------------------------------------
//! some wrappers //! some wrappers
//!------------------------------------------------------------------------------------------- //!-------------------------------------------------------------------------------------------
void * MEM2_alloc(unsigned int size, unsigned int align) void * MEM2_alloc(unsigned int size, unsigned int align)
{ {
return __wrap_memalign(align, size); return memalign(align, size);
} }
void MEM2_free(void *ptr) void MEM2_free(void *ptr)
{ {
__wrap_free(ptr); free(ptr);
} }
void * MEM1_alloc(unsigned int size, unsigned int align) void * MEM1_alloc(unsigned int size, unsigned int align)

View File

@ -30,7 +30,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <wchar.h> #include <wchar.h>
#include <gctypes.h> #include "common/types.h"
const char * fmt(const char * format, ...) const char * fmt(const char * format, ...)
{ {

View File

@ -26,9 +26,9 @@
#ifndef __STRING_TOOLS_H #ifndef __STRING_TOOLS_H
#define __STRING_TOOLS_H #define __STRING_TOOLS_H
#include <gctypes.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include "common/types.h"
const char * fmt(const char * format, ...); const char * fmt(const char * format, ...);
const wchar_t * wfmt(const char * format, ...); const wchar_t * wfmt(const char * format, ...);

View File

@ -1,17 +1,17 @@
#include <unistd.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include "dynamic_libs/os_functions.h" #include <nsysnet/socket.h>
#include "dynamic_libs/socket_functions.h" #include "common/common.h"
#include "logger.h" #include "logger.h"
#ifdef DEBUG_LOGGER #ifdef DEBUG_LOGGER
static int log_socket = -1; static int log_socket = -1;
static volatile int log_lock = 0; static volatile int log_lock = 0;
void log_init(const char * ipString) void log_init(const char * ipString)
{ {
log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); log_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);

17
src/utils/utils.c Normal file
View File

@ -0,0 +1,17 @@
#include <coreinit/thread.h>
#define BUS_SPEED 248625000
#define SECS_TO_TICKS(sec) (((unsigned long long)(sec)) * (BUS_SPEED/4))
#define MILLISECS_TO_TICKS(msec) (SECS_TO_TICKS(msec) / 1000)
#define MICROSECS_TO_TICKS(usec) (SECS_TO_TICKS(usec) / 1000000)
void usleep(unsigned int microsecs)
{
OSSleepTicks(MICROSECS_TO_TICKS(microsecs));
}
void sleep(unsigned int secs)
{
OSSleepTicks(SECS_TO_TICKS(secs));
}

View File

@ -23,7 +23,6 @@
#include "shaders/Shader3D.h" #include "shaders/Shader3D.h"
#include "shaders/ShaderFractalColor.h" #include "shaders/ShaderFractalColor.h"
#include "shaders/FXAAShader.h" #include "shaders/FXAAShader.h"
#include "dynamic_libs/os_functions.h"
CVideo::CVideo(s32 forceTvScanMode, s32 forceDrcScanMode) CVideo::CVideo(s32 forceTvScanMode, s32 forceDrcScanMode)
{ {
@ -35,25 +34,22 @@ CVideo::CVideo(s32 forceTvScanMode, s32 forceDrcScanMode)
//! initialize GX2 command buffer //! initialize GX2 command buffer
u32 gx2_init_attributes[9]; u32 gx2_init_attributes[9];
gx2_init_attributes[0] = GX2_INIT_ATTRIB_CB_BASE; gx2_init_attributes[0] = GX2_INIT_CMD_BUF_BASE;
gx2_init_attributes[1] = (u32)gx2CommandBuffer; gx2_init_attributes[1] = (u32)gx2CommandBuffer;
gx2_init_attributes[2] = GX2_INIT_ATTRIB_CB_SIZE; gx2_init_attributes[2] = GX2_INIT_CMD_BUF_POOL_SIZE;
gx2_init_attributes[3] = GX2_COMMAND_BUFFER_SIZE; gx2_init_attributes[3] = GX2_COMMAND_BUFFER_SIZE;
gx2_init_attributes[4] = GX2_INIT_ATTRIB_ARGC; gx2_init_attributes[4] = GX2_INIT_ARGC;
gx2_init_attributes[5] = 0; gx2_init_attributes[5] = 0;
gx2_init_attributes[6] = GX2_INIT_ATTRIB_ARGV; gx2_init_attributes[6] = GX2_INIT_ARGV;
gx2_init_attributes[7] = 0; gx2_init_attributes[7] = 0;
gx2_init_attributes[8] = GX2_INIT_ATTRIB_NULL; gx2_init_attributes[8] = GX2_INIT_END;
GX2Init(gx2_init_attributes); GX2Init(gx2_init_attributes);
//! GX2 resources are not used in this application but if needed, the allocator is setup
GX2RSetAllocator(&CVideo::GX2RAlloc, &CVideo::GX2RFree);
u32 scanBufferSize = 0; u32 scanBufferSize = 0;
s32 scaleNeeded = 0; u32 scaleNeeded = 0;
s32 tvScanMode = (forceTvScanMode >= 0) ? forceTvScanMode : GX2GetSystemTVScanMode(); s32 tvScanMode = ((forceTvScanMode >= 0) ? forceTvScanMode : (s32)GX2GetSystemTVScanMode());
s32 drcScanMode = (forceDrcScanMode >= 0) ? forceDrcScanMode : GX2GetSystemDRCScanMode(); s32 drcScanMode = ((forceDrcScanMode >= 0) ? forceDrcScanMode : (s32)GX2GetSystemDRCScanMode());
s32 tvRenderMode; s32 tvRenderMode;
u32 tvWidth = 0; u32 tvWidth = 0;
@ -65,24 +61,24 @@ CVideo::CVideo(s32 forceTvScanMode, s32 forceDrcScanMode)
case GX2_TV_SCAN_MODE_480P: case GX2_TV_SCAN_MODE_480P:
tvWidth = 854; tvWidth = 854;
tvHeight = 480; tvHeight = 480;
tvRenderMode = GX2_TV_RENDER_480_WIDE; tvRenderMode = GX2_TV_RENDER_MODE_WIDE_480P;
break; break;
case GX2_TV_SCAN_MODE_1080I: case GX2_TV_SCAN_MODE_1080I:
case GX2_TV_SCAN_MODE_1080P: case GX2_TV_SCAN_MODE_1080P:
tvWidth = 1920; tvWidth = 1920;
tvHeight = 1080; tvHeight = 1080;
tvRenderMode = GX2_TV_RENDER_1080; tvRenderMode = GX2_TV_RENDER_MODE_WIDE_1080P;
break; break;
case GX2_TV_SCAN_MODE_720P: case GX2_TV_SCAN_MODE_720P:
default: default:
tvWidth = 1280; tvWidth = 1280;
tvHeight = 720; tvHeight = 720;
tvRenderMode = GX2_TV_RENDER_720; tvRenderMode = GX2_TV_RENDER_MODE_WIDE_720P;
break; break;
} }
s32 tvAAMode = GX2_AA_MODE_1X; s32 tvAAMode = GX2_AA_MODE1X;
s32 drcAAMode = GX2_AA_MODE_4X; s32 drcAAMode = GX2_AA_MODE4X;
//! calculate the scale factor for later texture resize //! calculate the scale factor for later texture resize
widthScaleFactor = 1.0f / (f32)tvWidth; widthScaleFactor = 1.0f / (f32)tvWidth;
@ -90,51 +86,51 @@ CVideo::CVideo(s32 forceTvScanMode, s32 forceDrcScanMode)
depthScaleFactor = widthScaleFactor; depthScaleFactor = widthScaleFactor;
//! calculate the size needed for the TV scan buffer and allocate the buffer from bucket memory //! calculate the size needed for the TV scan buffer and allocate the buffer from bucket memory
GX2CalcTVSize(tvRenderMode, GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM, GX2_BUFFERING_DOUBLE, &scanBufferSize, &scaleNeeded); GX2CalcTVSize((GX2TVRenderMode)tvRenderMode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE, &scanBufferSize, &scaleNeeded);
tvScanBuffer = MEMBucket_alloc(scanBufferSize, GX2_SCAN_BUFFER_ALIGNMENT); tvScanBuffer = MEMBucket_alloc(scanBufferSize, GX2_SCAN_BUFFER_ALIGNMENT);
GX2Invalidate(GX2_INVALIDATE_CPU, tvScanBuffer, scanBufferSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, tvScanBuffer, scanBufferSize);
GX2SetTVBuffer(tvScanBuffer, scanBufferSize, tvRenderMode, GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM, GX2_BUFFERING_DOUBLE); GX2SetTVBuffer(tvScanBuffer, scanBufferSize, (GX2TVRenderMode)tvRenderMode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE);
//! calculate the size needed for the DRC scan buffer and allocate the buffer from bucket memory //! calculate the size needed for the DRC scan buffer and allocate the buffer from bucket memory
GX2CalcDRCSize(drcScanMode, GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM, GX2_BUFFERING_DOUBLE, &scanBufferSize, &scaleNeeded); GX2CalcDRCSize((GX2DrcRenderMode)drcScanMode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE, &scanBufferSize, &scaleNeeded);
drcScanBuffer = MEMBucket_alloc(scanBufferSize, GX2_SCAN_BUFFER_ALIGNMENT); drcScanBuffer = MEMBucket_alloc(scanBufferSize, GX2_SCAN_BUFFER_ALIGNMENT);
GX2Invalidate(GX2_INVALIDATE_CPU, drcScanBuffer, scanBufferSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, drcScanBuffer, scanBufferSize);
GX2SetDRCBuffer(drcScanBuffer, scanBufferSize, drcScanMode, GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM, GX2_BUFFERING_DOUBLE); GX2SetDRCBuffer(drcScanBuffer, scanBufferSize, (GX2DrcRenderMode)drcScanMode, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_BUFFERING_MODE_DOUBLE);
//! Setup color buffer for TV rendering //! Setup color buffer for TV rendering
GX2InitColorBuffer(&tvColorBuffer, GX2_SURFACE_DIM_2D, tvWidth, tvHeight, 1, GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM, tvAAMode); GX2InitColorBuffer(&tvColorBuffer, GX2_SURFACE_DIM_TEXTURE_2D, tvWidth, tvHeight, 1, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, (GX2AAMode)tvAAMode);
tvColorBuffer.surface.image_data = MEM1_alloc(tvColorBuffer.surface.image_size, tvColorBuffer.surface.align); tvColorBuffer.surface.image = MEM1_alloc(tvColorBuffer.surface.imageSize, tvColorBuffer.surface.alignment);
GX2Invalidate(GX2_INVALIDATE_CPU, tvColorBuffer.surface.image_data, tvColorBuffer.surface.image_size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, tvColorBuffer.surface.image, tvColorBuffer.surface.imageSize);
//! due to AA we can only use 16 bit depth buffer in MEM1 otherwise we would have to switch to mem2 for depth buffer //! due to AA we can only use 16 bit depth buffer in MEM1 otherwise we would have to switch to mem2 for depth buffer
//! this should be ok for our purpose i guess //! this should be ok for our purpose i guess
//! Setup TV depth buffer (can be the same for both if rendered one after another) //! Setup TV depth buffer (can be the same for both if rendered one after another)
u32 size, align; u32 size, align;
GX2InitDepthBuffer(&tvDepthBuffer, GX2_SURFACE_DIM_2D, tvColorBuffer.surface.width, tvColorBuffer.surface.height, 1, GX2_SURFACE_FORMAT_TCD_R32_FLOAT, tvAAMode); GX2InitDepthBuffer(&tvDepthBuffer, GX2_SURFACE_DIM_TEXTURE_2D, tvColorBuffer.surface.width, tvColorBuffer.surface.height, 1, GX2_SURFACE_FORMAT_FLOAT_R32, (GX2AAMode)tvAAMode);
tvDepthBuffer.surface.image_data = MEM1_alloc(tvDepthBuffer.surface.image_size, tvDepthBuffer.surface.align); tvDepthBuffer.surface.image = MEM1_alloc(tvDepthBuffer.surface.imageSize, tvDepthBuffer.surface.alignment);
GX2Invalidate(GX2_INVALIDATE_CPU, tvDepthBuffer.surface.image_data, tvDepthBuffer.surface.image_size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, tvDepthBuffer.surface.image, tvDepthBuffer.surface.imageSize);
//! Setup TV HiZ buffer //! Setup TV HiZ buffer
GX2CalcDepthBufferHiZInfo(&tvDepthBuffer, &size, &align); GX2CalcDepthBufferHiZInfo(&tvDepthBuffer, &size, &align);
tvDepthBuffer.hiZ_data = MEM1_alloc(size, align); tvDepthBuffer.hiZPtr = MEM1_alloc(size, align);
GX2Invalidate(GX2_INVALIDATE_CPU, tvDepthBuffer.hiZ_data, size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, tvDepthBuffer.hiZPtr, size);
GX2InitDepthBufferHiZEnable(&tvDepthBuffer, GX2_ENABLE); GX2InitDepthBufferHiZEnable(&tvDepthBuffer, GX2_ENABLE);
//! Setup color buffer for DRC rendering //! Setup color buffer for DRC rendering
GX2InitColorBuffer(&drcColorBuffer, GX2_SURFACE_DIM_2D, 854, 480, 1, GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM, drcAAMode); GX2InitColorBuffer(&drcColorBuffer, GX2_SURFACE_DIM_TEXTURE_2D, 854, 480, 1, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, (GX2AAMode)drcAAMode);
drcColorBuffer.surface.image_data = MEM1_alloc(drcColorBuffer.surface.image_size, drcColorBuffer.surface.align); drcColorBuffer.surface.image = MEM1_alloc(drcColorBuffer.surface.imageSize, drcColorBuffer.surface.alignment);
GX2Invalidate(GX2_INVALIDATE_CPU, drcColorBuffer.surface.image_data, drcColorBuffer.surface.image_size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, drcColorBuffer.surface.image, drcColorBuffer.surface.imageSize);
//! Setup DRC depth buffer (can be the same for both if rendered one after another) //! Setup DRC depth buffer (can be the same for both if rendered one after another)
GX2InitDepthBuffer(&drcDepthBuffer, GX2_SURFACE_DIM_2D, drcColorBuffer.surface.width, drcColorBuffer.surface.height, 1, GX2_SURFACE_FORMAT_TCD_R32_FLOAT, drcAAMode); GX2InitDepthBuffer(&drcDepthBuffer, GX2_SURFACE_DIM_TEXTURE_2D, drcColorBuffer.surface.width, drcColorBuffer.surface.height, 1, GX2_SURFACE_FORMAT_FLOAT_R32, (GX2AAMode)drcAAMode);
drcDepthBuffer.surface.image_data = MEM1_alloc(drcDepthBuffer.surface.image_size, drcDepthBuffer.surface.align); drcDepthBuffer.surface.image = MEM1_alloc(drcDepthBuffer.surface.imageSize, drcDepthBuffer.surface.alignment);
GX2Invalidate(GX2_INVALIDATE_CPU, drcDepthBuffer.surface.image_data, drcDepthBuffer.surface.image_size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, drcDepthBuffer.surface.image, drcDepthBuffer.surface.imageSize);
//! Setup DRC HiZ buffer //! Setup DRC HiZ buffer
GX2CalcDepthBufferHiZInfo(&drcDepthBuffer, &size, &align); GX2CalcDepthBufferHiZInfo(&drcDepthBuffer, &size, &align);
drcDepthBuffer.hiZ_data = MEM1_alloc(size, align); drcDepthBuffer.hiZPtr = MEM1_alloc(size, align);
GX2Invalidate(GX2_INVALIDATE_CPU, drcDepthBuffer.hiZ_data, size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, drcDepthBuffer.hiZPtr, size);
GX2InitDepthBufferHiZEnable(&drcDepthBuffer, GX2_ENABLE); GX2InitDepthBufferHiZEnable(&drcDepthBuffer, GX2_ENABLE);
@ -143,25 +139,25 @@ CVideo::CVideo(s32 forceTvScanMode, s32 forceDrcScanMode)
{ {
u32 auxSize, auxAlign; u32 auxSize, auxAlign;
GX2CalcColorBufferAuxInfo(&tvColorBuffer, &auxSize, &auxAlign); GX2CalcColorBufferAuxInfo(&tvColorBuffer, &auxSize, &auxAlign);
tvColorBuffer.aux_data = MEM1_alloc(auxSize, auxAlign); tvColorBuffer.aaBuffer = MEM1_alloc(auxSize, auxAlign);
if(!tvColorBuffer.aux_data) if(!tvColorBuffer.aaBuffer)
tvColorBuffer.aux_data = MEM2_alloc(auxSize, auxAlign); tvColorBuffer.aaBuffer = MEM2_alloc(auxSize, auxAlign);
tvColorBuffer.aux_size = auxSize; tvColorBuffer.aaSize = auxSize;
memset(tvColorBuffer.aux_data, GX2_AUX_BUFFER_CLEAR_VALUE, auxSize); memset(tvColorBuffer.aaBuffer, GX2_AA_BUFFER_CLEAR_VALUE, auxSize);
GX2Invalidate(GX2_INVALIDATE_CPU, tvColorBuffer.aux_data, auxSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, tvColorBuffer.aaBuffer, auxSize);
} }
if (drcColorBuffer.surface.aa) if (drcColorBuffer.surface.aa)
{ {
u32 auxSize, auxAlign; u32 auxSize, auxAlign;
GX2CalcColorBufferAuxInfo(&drcColorBuffer, &auxSize, &auxAlign); GX2CalcColorBufferAuxInfo(&drcColorBuffer, &auxSize, &auxAlign);
drcColorBuffer.aux_data = MEM1_alloc(auxSize, auxAlign); drcColorBuffer.aaBuffer = MEM1_alloc(auxSize, auxAlign);
if(!drcColorBuffer.aux_data) if(!drcColorBuffer.aaBuffer)
drcColorBuffer.aux_data = MEM2_alloc(auxSize, auxAlign); drcColorBuffer.aaBuffer = MEM2_alloc(auxSize, auxAlign);
drcColorBuffer.aux_size = auxSize; drcColorBuffer.aaSize = auxSize;
memset(drcColorBuffer.aux_data, GX2_AUX_BUFFER_CLEAR_VALUE, auxSize); memset(drcColorBuffer.aaBuffer, GX2_AA_BUFFER_CLEAR_VALUE, auxSize);
GX2Invalidate(GX2_INVALIDATE_CPU, drcColorBuffer.aux_data, auxSize ); GX2Invalidate(GX2_INVALIDATE_MODE_CPU, drcColorBuffer.aaBuffer, auxSize);
} }
//! allocate memory and setup context state TV //! allocate memory and setup context state TV
@ -200,11 +196,11 @@ CVideo::CVideo(s32 forceTvScanMode, s32 forceDrcScanMode)
viewMtx = glm::translate(viewMtx, glm::vec3(0.0f, 0.0f, -2.5f)); viewMtx = glm::translate(viewMtx, glm::vec3(0.0f, 0.0f, -2.5f));
viewMtx = glm::rotate(viewMtx, DegToRad(cam_X_rot), glm::vec3(1.0f, 0.0f, 0.0f)); viewMtx = glm::rotate(viewMtx, DegToRad(cam_X_rot), glm::vec3(1.0f, 0.0f, 0.0f));
GX2InitSampler(&aaSampler, GX2_TEX_CLAMP_CLAMP, GX2_TEX_XY_FILTER_BILINEAR); GX2InitSampler(&aaSampler, GX2_TEX_CLAMP_MODE_CLAMP, GX2_TEX_XY_FILTER_MODE_LINEAR);
GX2InitTexture(&tvAaTexture, tvColorBuffer.surface.width, tvColorBuffer.surface.height, 1, 0, GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM, GX2_SURFACE_DIM_2D, GX2_TILE_MODE_DEFAULT); GX2InitTexture(&tvAaTexture, tvColorBuffer.surface.width, tvColorBuffer.surface.height, 1, 0, GX2_SURFACE_FORMAT_UNORM_R8_G8_B8_A8, GX2_SURFACE_DIM_TEXTURE_2D, GX2_TILE_MODE_DEFAULT);
tvAaTexture.surface.image_data = tvColorBuffer.surface.image_data; tvAaTexture.surface.image = tvColorBuffer.surface.image;
tvAaTexture.surface.image_size = tvColorBuffer.surface.image_size; tvAaTexture.surface.imageSize = tvColorBuffer.surface.imageSize;
tvAaTexture.surface.mip_data = tvColorBuffer.surface.mip_data; tvAaTexture.surface.mipmaps = tvColorBuffer.surface.mipmaps;
} }
CVideo::~CVideo() CVideo::~CVideo()
@ -220,30 +216,30 @@ CVideo::~CVideo()
MEMBucket_free(tvScanBuffer); MEMBucket_free(tvScanBuffer);
MEMBucket_free(drcScanBuffer); MEMBucket_free(drcScanBuffer);
//! free color buffers //! free color buffers
MEM1_free(tvColorBuffer.surface.image_data); MEM1_free(tvColorBuffer.surface.image);
MEM1_free(drcColorBuffer.surface.image_data); MEM1_free(drcColorBuffer.surface.image);
//! free depth buffers //! free depth buffers
MEM1_free(tvDepthBuffer.surface.image_data); MEM1_free(tvDepthBuffer.surface.image);
MEM1_free(tvDepthBuffer.hiZ_data); MEM1_free(tvDepthBuffer.hiZPtr);
MEM1_free(drcDepthBuffer.surface.image_data); MEM1_free(drcDepthBuffer.surface.image);
MEM1_free(drcDepthBuffer.hiZ_data); MEM1_free(drcDepthBuffer.hiZPtr);
//! free context buffers //! free context buffers
MEM2_free(tvContextState); MEM2_free(tvContextState);
MEM2_free(drcContextState); MEM2_free(drcContextState);
//! free aux buffer //! free aux buffer
if(tvColorBuffer.aux_data) if(tvColorBuffer.aaBuffer)
{ {
if(((u32)tvColorBuffer.aux_data & 0xF0000000) == 0xF0000000) if(((u32)tvColorBuffer.aaBuffer & 0xF0000000) == 0xF0000000)
MEM1_free(tvColorBuffer.aux_data); MEM1_free(tvColorBuffer.aaBuffer);
else else
MEM2_free(tvColorBuffer.aux_data); MEM2_free(tvColorBuffer.aaBuffer);
} }
if(drcColorBuffer.aux_data) if(drcColorBuffer.aaBuffer)
{ {
if(((u32)drcColorBuffer.aux_data & 0xF0000000) == 0xF0000000) if(((u32)drcColorBuffer.aaBuffer & 0xF0000000) == 0xF0000000)
MEM1_free(drcColorBuffer.aux_data); MEM1_free(drcColorBuffer.aaBuffer);
else else
MEM2_free(drcColorBuffer.aux_data); MEM2_free(drcColorBuffer.aaBuffer);
} }
//! destroy shaders //! destroy shaders
ColorShader::destroyInstance(); ColorShader::destroyInstance();
@ -258,15 +254,15 @@ void CVideo::renderFXAA(const GX2Texture * texture, const GX2Sampler *sampler)
resolution[0] = texture->surface.width; resolution[0] = texture->surface.width;
resolution[1] = texture->surface.height; resolution[1] = texture->surface.height;
GX2Invalidate(GX2_INVALIDATE_COLOR_BUFFER | GX2_INVALIDATE_TEXTURE, texture->surface.image_data, texture->surface.image_size); GX2Invalidate((GX2InvalidateMode)(GX2_INVALIDATE_MODE_COLOR_BUFFER | GX2_INVALIDATE_MODE_TEXTURE), texture->surface.image, texture->surface.imageSize);
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_ALWAYS); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_ALWAYS);
FXAAShader::instance()->setShaders(); FXAAShader::instance()->setShaders();
FXAAShader::instance()->setAttributeBuffer(); FXAAShader::instance()->setAttributeBuffer();
FXAAShader::instance()->setResolution(resolution); FXAAShader::instance()->setResolution(resolution);
FXAAShader::instance()->setTextureAndSampler(texture, sampler); FXAAShader::instance()->setTextureAndSampler(texture, sampler);
FXAAShader::instance()->draw(); FXAAShader::instance()->draw();
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL);
} }
void* CVideo::GX2RAlloc(u32 flags, u32 size, u32 align) void* CVideo::GX2RAlloc(u32 flags, u32 size, u32 align)

View File

@ -17,7 +17,14 @@
#ifndef __CVIDEO_H_ #ifndef __CVIDEO_H_
#define __CVIDEO_H_ #define __CVIDEO_H_
#include "dynamic_libs/gx2_functions.h" #include <gx2/context.h>
#include <gx2/clear.h>
#include <gx2/display.h>
#include <gx2/event.h>
#include <gx2/state.h>
#include <gx2/surface.h>
#include <gx2/swap.h>
#include "shaders/Shader.h" #include "shaders/Shader.h"
class CVideo class CVideo
@ -42,15 +49,15 @@ public:
void prepareRendering(void) { void prepareRendering(void) {
GX2ClearColor(currColorBuffer, 0.0f, 0.0f, 0.0f, 1.0f); GX2ClearColor(currColorBuffer, 0.0f, 0.0f, 0.0f, 1.0f);
GX2ClearDepthStencilEx(currDepthBuffer, currDepthBuffer->clear_depth, currDepthBuffer->clear_stencil, GX2_CLEAR_BOTH); GX2ClearDepthStencilEx(currDepthBuffer, currDepthBuffer->depthClear, currDepthBuffer->stencilClear, GX2_CLEAR_FLAGS_BOTH);
GX2SetContextState(currContextState); GX2SetContextState(currContextState);
GX2SetViewport(0.0f, 0.0f, currColorBuffer->surface.width, currColorBuffer->surface.height, 0.0f, 1.0f); GX2SetViewport(0.0f, 0.0f, currColorBuffer->surface.width, currColorBuffer->surface.height, 0.0f, 1.0f);
GX2SetScissor(0, 0, currColorBuffer->surface.width, currColorBuffer->surface.height); GX2SetScissor(0, 0, currColorBuffer->surface.width, currColorBuffer->surface.height);
GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL); GX2SetDepthOnlyControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL);
GX2SetColorControl(GX2_LOGIC_OP_COPY, 1, GX2_DISABLE, GX2_ENABLE); GX2SetColorControl(GX2_LOGIC_OP_COPY, 1, GX2_DISABLE, GX2_ENABLE);
GX2SetBlendControl(GX2_RENDER_TARGET_0, GX2_BLEND_SRC_ALPHA, GX2_BLEND_ONE_MINUS_SRC_ALPHA, GX2_BLEND_COMBINE_ADD, GX2_ENABLE, GX2_BLEND_SRC_ALPHA, GX2_BLEND_ONE_MINUS_SRC_ALPHA, GX2_BLEND_COMBINE_ADD); GX2SetBlendControl(GX2_RENDER_TARGET_0, GX2_BLEND_MODE_SRC_ALPHA, GX2_BLEND_MODE_INV_SRC_ALPHA, GX2_BLEND_COMBINE_MODE_ADD, GX2_ENABLE, GX2_BLEND_MODE_SRC_ALPHA, GX2_BLEND_MODE_INV_SRC_ALPHA, GX2_BLEND_COMBINE_MODE_ADD);
GX2SetCullOnlyControl(GX2_FRONT_FACE_CCW, GX2_DISABLE, GX2_ENABLE); GX2SetCullOnlyControl(GX2_FRONT_FACE_CCW, GX2_DISABLE, GX2_ENABLE);
} }
@ -59,21 +66,21 @@ public:
if(bEnable) if(bEnable)
{ {
GX2SetStencilMask(0xff, 0xff, 0x01, 0xff, 0xff, 0x01); GX2SetStencilMask(0xff, 0xff, 0x01, 0xff, 0xff, 0x01);
GX2SetDepthStencilControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_LEQUAL, GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_ALWAYS, GX2_STENCIL_KEEP, GX2_STENCIL_KEEP, GX2_STENCIL_REPLACE, GX2SetDepthStencilControl(GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_LEQUAL, GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_ALWAYS, GX2_STENCIL_FUNCTION_KEEP, GX2_STENCIL_FUNCTION_KEEP, GX2_STENCIL_FUNCTION_REPLACE,
GX2_COMPARE_ALWAYS, GX2_STENCIL_KEEP, GX2_STENCIL_KEEP, GX2_STENCIL_REPLACE); GX2_COMPARE_FUNC_ALWAYS, GX2_STENCIL_FUNCTION_KEEP, GX2_STENCIL_FUNCTION_KEEP, GX2_STENCIL_FUNCTION_REPLACE);
} }
else else
{ {
GX2SetStencilMask(0xff, 0xff, 0xff, 0xff, 0xff, 0xff); GX2SetStencilMask(0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
GX2SetDepthStencilControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_LEQUAL, GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_NEVER, GX2_STENCIL_KEEP, GX2_STENCIL_KEEP, GX2_STENCIL_KEEP, GX2SetDepthStencilControl(GX2_ENABLE, GX2_ENABLE, GX2_COMPARE_FUNC_LEQUAL, GX2_DISABLE, GX2_DISABLE, GX2_COMPARE_FUNC_NEVER, GX2_STENCIL_FUNCTION_KEEP, GX2_STENCIL_FUNCTION_KEEP, GX2_STENCIL_FUNCTION_KEEP,
GX2_COMPARE_NEVER, GX2_STENCIL_KEEP, GX2_STENCIL_KEEP, GX2_STENCIL_KEEP); GX2_COMPARE_FUNC_NEVER, GX2_STENCIL_FUNCTION_KEEP, GX2_STENCIL_FUNCTION_KEEP, GX2_STENCIL_FUNCTION_KEEP);
} }
} }
void drcDrawDone(void) { void drcDrawDone(void) {
//! on DRC we do a hardware AA because FXAA does not look good //! on DRC we do a hardware AA because FXAA does not look good
//renderFXAA(&drcAaTexture, &aaSampler); //renderFXAA(&drcAaTexture, &aaSampler);
GX2CopyColorBufferToScanBuffer(&drcColorBuffer, GX2_SCAN_TARGET_DRC_FIRST); GX2CopyColorBufferToScanBuffer(&drcColorBuffer, GX2_SCAN_TARGET_DRC);
} }
void tvDrawDone(void) { void tvDrawDone(void) {

View File

@ -116,7 +116,7 @@ ColorShader::ColorShader()
pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs)); pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs));
colorIntensityLocation = 0; colorIntensityLocation = 0;
pixelShader.addUniformVar((GX2UniformVar){ "unf_color_intensity", GX2_VAR_TYPE_VEC4, 1, colorIntensityLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1 });
//! create vertex shader //! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
@ -124,18 +124,18 @@ ColorShader::ColorShader()
angleLocation = 0; angleLocation = 0;
offsetLocation = 4; offsetLocation = 4;
scaleLocation = 8; scaleLocation = 8;
vertexShader.addUniformVar((GX2UniformVar){ "unf_angle", GX2_VAR_TYPE_FLOAT, 1, angleLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1 });
vertexShader.addUniformVar((GX2UniformVar){ "unf_offset", GX2_VAR_TYPE_VEC3, 1, offsetLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1 });
vertexShader.addUniformVar((GX2UniformVar){ "unf_scale", GX2_VAR_TYPE_VEC3, 1, scaleLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1 });
colorLocation = 1; colorLocation = 1;
positionLocation = 0; positionLocation = 0;
vertexShader.addAttribVar((GX2AttribVar){ "attr_color", GX2_VAR_TYPE_VEC4, 0, colorLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_color", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation });
vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_VAR_TYPE_VEC3, 0, positionLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation });
//! setup attribute streams //! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_32_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
GX2InitAttribStream(vertexShader.getAttributeBuffer(1), colorLocation, 1, 0, GX2_ATTRIB_FORMAT_8_8_8_8_UNORM); GX2InitAttribStream(vertexShader.getAttributeBuffer(1), colorLocation, 1, 0, GX2_ATTRIB_FORMAT_UNORM_8_8_8_8);
//! create fetch shader //! create fetch shader
fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount()); fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount());
@ -150,7 +150,7 @@ ColorShader::ColorShader()
positionVtxs[i++] = 1.0f; positionVtxs[i++] = -1.0f; positionVtxs[i++] = 0.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = -1.0f; positionVtxs[i++] = 0.0f;
positionVtxs[i++] = 1.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = 0.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = 0.0f;
positionVtxs[i++] = -1.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = 0.0f; positionVtxs[i++] = -1.0f; positionVtxs[i++] = 1.0f; positionVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, positionVtxs, cuPositionVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, positionVtxs, cuPositionVtxsSize);
} }
} }

View File

@ -172,22 +172,22 @@ FXAAShader::FXAAShader()
pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs)); pixelShader.setProgram(cpPixelShaderProgram, sizeof(cpPixelShaderProgram), cpPixelShaderRegs, sizeof(cpPixelShaderRegs));
resolutionLocation = 0; resolutionLocation = 0;
pixelShader.addUniformVar((GX2UniformVar){ "unf_resolution", GX2_VAR_TYPE_VEC2, 1, resolutionLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_resolution", GX2_SHADER_VAR_TYPE_FLOAT2, 1, resolutionLocation, -1 });
samplerLocation = 0; samplerLocation = 0;
pixelShader.addSamplerVar((GX2SamplerVar){ "sampl_texture", GX2_SAMPLER_TYPE_2D, samplerLocation }); pixelShader.addSamplerVar((GX2SamplerVar){ "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation });
//! create vertex shader //! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
positionLocation = 0; positionLocation = 0;
texCoordLocation = 1; texCoordLocation = 1;
vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_VAR_TYPE_VEC3, 0, positionLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation });
vertexShader.addAttribVar((GX2AttribVar){ "attr_texture_coord", GX2_VAR_TYPE_VEC2, 0, texCoordLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation });
//! setup attribute streams //! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_32_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
GX2InitAttribStream(vertexShader.getAttributeBuffer(1), texCoordLocation, 1, 0, GX2_ATTRIB_FORMAT_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(1), texCoordLocation, 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
//! create fetch shader //! create fetch shader
fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount()); fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount());
@ -202,14 +202,14 @@ FXAAShader::FXAAShader()
posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f;
posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;
posVtxs[i++] = -1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, posVtxs, ciPositionVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize);
i = 0; i = 0;
texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 0.0f;
texCoords[i++] = 0.0f; texCoords[i++] = 0.0f; texCoords[i++] = 0.0f; texCoords[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, texCoords, ciTexCoordsVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, texCoords, ciTexCoordsVtxsSize);
} }
FXAAShader::~FXAAShader() FXAAShader::~FXAAShader()

View File

@ -56,8 +56,8 @@ public:
} }
void setTextureAndSampler(const GX2Texture *texture, const GX2Sampler *sampler) const { void setTextureAndSampler(const GX2Texture *texture, const GX2Sampler *sampler) const {
GX2SetPixelTexture(texture, samplerLocation); GX2SetPixelTexture((GX2Texture*)texture, samplerLocation);
GX2SetPixelSampler(sampler, samplerLocation); GX2SetPixelSampler((GX2Sampler*)sampler, samplerLocation);
} }
private: private:

View File

@ -22,17 +22,17 @@
class FetchShader : public Shader class FetchShader : public Shader
{ {
public: public:
FetchShader(GX2AttribStream * attributes, u32 attrCount, s32 type = GX2_FETCH_SHADER_TESSELATION_NONE, s32 tess = GX2_TESSELLATION_MODE_DISCRETE) FetchShader(GX2AttribStream * attributes, u32 attrCount, GX2FetchShaderType type = GX2_FETCH_SHADER_TESSELLATION_NONE, GX2TessellationMode tess = GX2_TESSELLATION_MODE_DISCRETE)
: fetchShader(NULL) : fetchShader(NULL)
, fetchShaderProgramm(NULL) , fetchShaderProgramm(NULL)
{ {
u32 shaderSize = GX2CalcFetchShaderSizeEx(attrCount, type, tess); u32 shaderSize = GX2CalcFetchShaderSizeEx(attrCount, type, tess);
fetchShaderProgramm = memalign(GX2_SHADER_ALIGNMENT, shaderSize); fetchShaderProgramm = (uint8_t*)memalign(GX2_SHADER_ALIGNMENT, shaderSize);
if(fetchShaderProgramm) if(fetchShaderProgramm)
{ {
fetchShader = new GX2FetchShader; fetchShader = new GX2FetchShader;
GX2InitFetchShaderEx(fetchShader, fetchShaderProgramm, attrCount, attributes, type, tess); GX2InitFetchShaderEx(fetchShader, fetchShaderProgramm, attrCount, attributes, type, tess);
GX2Invalidate(GX2_INVALIDATE_CPU_SHADER, fetchShaderProgramm, shaderSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, fetchShaderProgramm, shaderSize);
} }
} }
virtual ~FetchShader() { virtual ~FetchShader() {
@ -52,7 +52,7 @@ public:
protected: protected:
GX2FetchShader *fetchShader; GX2FetchShader *fetchShader;
void *fetchShaderProgramm; uint8_t *fetchShaderProgramm;
}; };
#endif // FETCH_SHADER_H #endif // FETCH_SHADER_H

View File

@ -28,39 +28,39 @@ public:
if(pixelShader) if(pixelShader)
{ {
memset(pixelShader, 0, sizeof(GX2PixelShader)); memset(pixelShader, 0, sizeof(GX2PixelShader));
pixelShader->shader_mode = GX2_SHADER_MODE_UNIFORM_REGISTER; pixelShader->mode = GX2_SHADER_MODE_UNIFORM_REGISTER;
} }
} }
virtual ~PixelShader() virtual ~PixelShader()
{ {
if(pixelShader) if(pixelShader)
{ {
if(pixelShader->shader_data) if(pixelShader->program)
free(pixelShader->shader_data); free(pixelShader->program);
for(u32 i = 0; i < pixelShader->uniform_blocks_count; i++) for(u32 i = 0; i < pixelShader->uniformBlockCount; i++)
free((void*)pixelShader->uniform_block[i].name); free((void*)pixelShader->uniformBlocks[i].name);
if(pixelShader->uniform_block) if(pixelShader->uniformBlocks)
free((void*)pixelShader->uniform_block); free((void*)pixelShader->uniformBlocks);
for(u32 i = 0; i < pixelShader->uniform_vars_count; i++) for(u32 i = 0; i < pixelShader->uniformVarCount; i++)
free((void*)pixelShader->uniform_var[i].name); free((void*)pixelShader->uniformVars[i].name);
if(pixelShader->uniform_var) if(pixelShader->uniformVars)
free((void*)pixelShader->uniform_var); free((void*)pixelShader->uniformVars);
if(pixelShader->initial_value) if(pixelShader->initialValues)
free((void*)pixelShader->initial_value); free((void*)pixelShader->initialValues);
for(u32 i = 0; i < pixelShader->sampler_vars_count; i++) for(u32 i = 0; i < pixelShader->samplerVarCount; i++)
free((void*)pixelShader->sampler_var[i].name); free((void*)pixelShader->samplerVars[i].name);
if(pixelShader->sampler_var) if(pixelShader->samplerVars)
free((void*)pixelShader->sampler_var); free((void*)pixelShader->samplerVars);
if(pixelShader->loops_data) if(pixelShader->loopVars)
free((void*)pixelShader->loops_data); free((void*)pixelShader->loopVars);
free(pixelShader); free(pixelShader);
} }
@ -72,15 +72,15 @@ public:
return; return;
//! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100 //! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100
pixelShader->shader_size = programSize; pixelShader->size = programSize;
pixelShader->shader_data = memalign(GX2_SHADER_ALIGNMENT, pixelShader->shader_size); pixelShader->program = (u8*)memalign(GX2_SHADER_ALIGNMENT, pixelShader->size);
if(pixelShader->shader_data) if(pixelShader->program)
{ {
memcpy(pixelShader->shader_data, program, pixelShader->shader_size); memcpy(pixelShader->program, program, pixelShader->size);
GX2Invalidate(GX2_INVALIDATE_CPU_SHADER, pixelShader->shader_data, pixelShader->shader_size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, pixelShader->program, pixelShader->size);
} }
memcpy(pixelShader->regs, regs, regsSize); memcpy(&pixelShader->regs, regs, regsSize);
} }
void addUniformVar(const GX2UniformVar & var) void addUniformVar(const GX2UniformVar & var)
@ -88,23 +88,23 @@ public:
if(!pixelShader) if(!pixelShader)
return; return;
u32 idx = pixelShader->uniform_vars_count; u32 idx = pixelShader->uniformVarCount;
GX2UniformVar* newVar = (GX2UniformVar*) malloc((pixelShader->uniform_vars_count + 1) * sizeof(GX2UniformVar)); GX2UniformVar* newVar = (GX2UniformVar*) malloc((pixelShader->uniformVarCount + 1) * sizeof(GX2UniformVar));
if(newVar) if(newVar)
{ {
if(pixelShader->uniform_var) if(pixelShader->uniformVars)
{ {
memcpy(newVar, pixelShader->uniform_var, pixelShader->uniform_vars_count * sizeof(GX2UniformVar)); memcpy(newVar, pixelShader->uniformVars, pixelShader->uniformVarCount * sizeof(GX2UniformVar));
free(pixelShader->uniform_var); free(pixelShader->uniformVars);
} }
pixelShader->uniform_var = newVar; pixelShader->uniformVars = newVar;
memcpy(pixelShader->uniform_var + idx, &var, sizeof(GX2UniformVar)); memcpy(pixelShader->uniformVars + idx, &var, sizeof(GX2UniformVar));
pixelShader->uniform_var[idx].name = (char*) malloc(strlen(var.name) + 1); pixelShader->uniformVars[idx].name = (char*) malloc(strlen(var.name) + 1);
strcpy((char*)pixelShader->uniform_var[idx].name, var.name); strcpy((char*)pixelShader->uniformVars[idx].name, var.name);
pixelShader->uniform_vars_count++; pixelShader->uniformVarCount++;
} }
} }
@ -113,23 +113,23 @@ public:
if(!pixelShader) if(!pixelShader)
return; return;
u32 idx = pixelShader->sampler_vars_count; u32 idx = pixelShader->samplerVarCount;
GX2SamplerVar* newVar = (GX2SamplerVar*) malloc((pixelShader->sampler_vars_count + 1) * sizeof(GX2SamplerVar)); GX2SamplerVar* newVar = (GX2SamplerVar*) malloc((pixelShader->samplerVarCount + 1) * sizeof(GX2SamplerVar));
if(newVar) if(newVar)
{ {
if(pixelShader->sampler_var) if(pixelShader->samplerVars)
{ {
memcpy(newVar, pixelShader->sampler_var, pixelShader->sampler_vars_count * sizeof(GX2SamplerVar)); memcpy(newVar, pixelShader->samplerVars, pixelShader->samplerVarCount * sizeof(GX2SamplerVar));
free(pixelShader->sampler_var); free(pixelShader->samplerVars);
} }
pixelShader->sampler_var = newVar; pixelShader->samplerVars = newVar;
memcpy(pixelShader->sampler_var + idx, &var, sizeof(GX2SamplerVar)); memcpy(pixelShader->samplerVars + idx, &var, sizeof(GX2SamplerVar));
pixelShader->sampler_var[idx].name = (char*) malloc(strlen(var.name) + 1); pixelShader->samplerVars[idx].name = (char*) malloc(strlen(var.name) + 1);
strcpy((char*)pixelShader->sampler_var[idx].name, var.name); strcpy((char*)pixelShader->samplerVars[idx].name, var.name);
pixelShader->sampler_vars_count++; pixelShader->samplerVarCount++;
} }
} }
GX2PixelShader * getPixelShader() const { GX2PixelShader * getPixelShader() const {
@ -141,7 +141,7 @@ public:
} }
static inline void setUniformReg(u32 location, u32 size, const void * reg) { static inline void setUniformReg(u32 location, u32 size, const void * reg) {
GX2SetPixelUniformReg(location, size, reg); GX2SetPixelUniformReg(location, size, (uint32_t *)reg);
} }
protected: protected:
GX2PixelShader *pixelShader; GX2PixelShader *pixelShader;

View File

@ -19,9 +19,18 @@
#include "glm/glm.hpp" #include "glm/glm.hpp"
#include "glm/gtc/matrix_transform.hpp" #include "glm/gtc/matrix_transform.hpp"
#include "dynamic_libs/gx2_functions.h"
#include "utils/utils.h" #include "utils/utils.h"
#include <gx2/draw.h>
#include <gx2/enum.h>
#include <gx2/mem.h>
#include <gx2/registers.h>
#include <gx2/sampler.h>
#include <gx2/shaders.h>
#include <gx2/surface.h>
#include <gx2/texture.h>
#include "common/gx2_ext.h"
class Shader class Shader
{ {
protected: protected:
@ -36,34 +45,34 @@ public:
GX2SetLineWidth(width); GX2SetLineWidth(width);
} }
static void draw(s32 primitive = GX2_PRIMITIVE_QUADS, u32 vtxCount = 4) static void draw(s32 primitive = GX2_PRIMITIVE_MODE_QUADS, u32 vtxCount = 4)
{ {
switch(primitive) switch(primitive)
{ {
default: default:
case GX2_PRIMITIVE_QUADS: case GX2_PRIMITIVE_MODE_QUADS:
{ {
GX2DrawEx(GX2_PRIMITIVE_QUADS, vtxCount, 0, 1); GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, vtxCount, 0, 1);
break; break;
} }
case GX2_PRIMITIVE_TRIANGLES: case GX2_PRIMITIVE_MODE_TRIANGLES:
{ {
GX2DrawEx(GX2_PRIMITIVE_TRIANGLES, vtxCount, 0, 1); GX2DrawEx(GX2_PRIMITIVE_MODE_TRIANGLES, vtxCount, 0, 1);
break; break;
} }
case GX2_PRIMITIVE_TRIANGLE_FAN: case GX2_PRIMITIVE_MODE_TRIANGLE_FAN:
{ {
GX2DrawEx(GX2_PRIMITIVE_TRIANGLE_FAN, vtxCount, 0, 1); GX2DrawEx(GX2_PRIMITIVE_MODE_TRIANGLE_FAN, vtxCount, 0, 1);
break; break;
} }
case GX2_PRIMITIVE_LINES: case GX2_PRIMITIVE_MODE_LINES:
{ {
GX2DrawEx(GX2_PRIMITIVE_LINES, vtxCount, 0, 1); GX2DrawEx(GX2_PRIMITIVE_MODE_LINES, vtxCount, 0, 1);
break; break;
} }
case GX2_PRIMITIVE_LINE_STRIP: case GX2_PRIMITIVE_MODE_LINE_STRIP:
{ {
GX2DrawEx(GX2_PRIMITIVE_LINE_STRIP, vtxCount, 0, 1); GX2DrawEx(GX2_PRIMITIVE_MODE_LINE_STRIP, vtxCount, 0, 1);
break; break;
} }
//! TODO: add other primitives later //! TODO: add other primitives later

View File

@ -198,12 +198,12 @@ Shader3D::Shader3D()
colorIntensityLocation = 0; colorIntensityLocation = 0;
fadeDistanceLocation = 4; fadeDistanceLocation = 4;
fadeOutLocation = 8; fadeOutLocation = 8;
pixelShader.addUniformVar((GX2UniformVar){ "unf_color_intensity", GX2_VAR_TYPE_VEC4, 1, colorIntensityLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1 });
pixelShader.addUniformVar((GX2UniformVar){ "unf_fade_distance", GX2_VAR_TYPE_FLOAT, 1, fadeDistanceLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_fade_distance", GX2_SHADER_VAR_TYPE_FLOAT, 1, fadeDistanceLocation, -1 });
pixelShader.addUniformVar((GX2UniformVar){ "unf_fade_out_alpha", GX2_VAR_TYPE_VEC4, 1, fadeOutLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1 });
samplerLocation = 0; samplerLocation = 0;
pixelShader.addSamplerVar((GX2SamplerVar){ "sampl_texture", GX2_SAMPLER_TYPE_2D, samplerLocation }); pixelShader.addSamplerVar((GX2SamplerVar){ "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation });
//! create vertex shader //! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
@ -211,18 +211,18 @@ Shader3D::Shader3D()
modelMatrixLocation = 0; modelMatrixLocation = 0;
projectionMatrixLocation = 16; projectionMatrixLocation = 16;
viewMatrixLocation = 32; viewMatrixLocation = 32;
vertexShader.addUniformVar((GX2UniformVar){ "modelMatrix", GX2_VAR_TYPE_MAT4, 1, modelMatrixLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "modelMatrix", GX2_SHADER_VAR_TYPE_MATRIX4X4, 1, modelMatrixLocation, -1 });
vertexShader.addUniformVar((GX2UniformVar){ "viewMatrix", GX2_VAR_TYPE_MAT4, 1, projectionMatrixLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "viewMatrix", GX2_SHADER_VAR_TYPE_MATRIX4X4, 1, projectionMatrixLocation, -1 });
vertexShader.addUniformVar((GX2UniformVar){ "projectionMatrix", GX2_VAR_TYPE_MAT4, 1, viewMatrixLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "projectionMatrix", GX2_SHADER_VAR_TYPE_MATRIX4X4, 1, viewMatrixLocation, -1 });
positionLocation = 0; positionLocation = 0;
texCoordLocation = 1; texCoordLocation = 1;
vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_VAR_TYPE_VEC3, 0, positionLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_SHADER_VAR_TYPE_FLOAT4, 0, positionLocation });
vertexShader.addAttribVar((GX2AttribVar){ "attr_texture_coord", GX2_VAR_TYPE_VEC2, 0, texCoordLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation });
//! setup attribute streams //! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_32_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
GX2InitAttribStream(vertexShader.getAttributeBuffer(1), texCoordLocation, 1, 0, GX2_ATTRIB_FORMAT_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(1), texCoordLocation, 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
//! create fetch shader //! create fetch shader
fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount()); fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount());
@ -238,14 +238,14 @@ Shader3D::Shader3D()
posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f;
posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;
posVtxs[i++] = -1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, posVtxs, ciPositionVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize);
i = 0; i = 0;
texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 0.0f;
texCoords[i++] = 0.0f; texCoords[i++] = 0.0f; texCoords[i++] = 0.0f; texCoords[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, texCoords, ciTexCoordsVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, texCoords, ciTexCoordsVtxsSize);
} }
Shader3D::~Shader3D() Shader3D::~Shader3D()

View File

@ -111,8 +111,8 @@ public:
} }
void setTextureAndSampler(const GX2Texture *texture, const GX2Sampler *sampler) const { void setTextureAndSampler(const GX2Texture *texture, const GX2Sampler *sampler) const {
GX2SetPixelTexture(texture, samplerLocation); GX2SetPixelTexture((GX2Texture*)texture, samplerLocation);
GX2SetPixelSampler(sampler, samplerLocation); GX2SetPixelSampler((GX2Sampler*)sampler, samplerLocation);
} }
}; };

View File

@ -292,10 +292,10 @@ ShaderFractalColor::ShaderFractalColor()
colorIntensityLocation = 4; colorIntensityLocation = 4;
fadeOutLocation = 8; fadeOutLocation = 8;
fractalLocation = 12; fractalLocation = 12;
pixelShader.addUniformVar((GX2UniformVar){ "unf_blur_border", GX2_VAR_TYPE_FLOAT, 1, blurLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_blur_border", GX2_SHADER_VAR_TYPE_FLOAT, 1, blurLocation, -1 });
pixelShader.addUniformVar((GX2UniformVar){ "unf_color_intensity", GX2_VAR_TYPE_VEC4, 1, colorIntensityLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1 });
pixelShader.addUniformVar((GX2UniformVar){ "unf_fade_out_alpha", GX2_VAR_TYPE_VEC4, 1, fadeOutLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_fade_out_alpha", GX2_SHADER_VAR_TYPE_FLOAT4, 1, fadeOutLocation, -1 });
pixelShader.addUniformVar((GX2UniformVar){ "unf_fract_alpha", GX2_VAR_TYPE_INT, 1, fractalLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_fract_alpha", GX2_SHADER_VAR_TYPE_INT, 1, fractalLocation, -1 });
//! create vertex shader //! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
@ -303,21 +303,21 @@ ShaderFractalColor::ShaderFractalColor()
modelMatrixLocation = 0; modelMatrixLocation = 0;
projectionMatrixLocation = 16; projectionMatrixLocation = 16;
viewMatrixLocation = 32; viewMatrixLocation = 32;
vertexShader.addUniformVar((GX2UniformVar){ "modelMatrix", GX2_VAR_TYPE_MAT4, 1, modelMatrixLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "modelMatrix", GX2_SHADER_VAR_TYPE_MATRIX4X4, 1, modelMatrixLocation, -1 });
vertexShader.addUniformVar((GX2UniformVar){ "projectionMatrix", GX2_VAR_TYPE_MAT4, 1, projectionMatrixLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "projectionMatrix", GX2_SHADER_VAR_TYPE_MATRIX4X4, 1, projectionMatrixLocation, -1 });
vertexShader.addUniformVar((GX2UniformVar){ "viewMatrix", GX2_VAR_TYPE_MAT4, 1, viewMatrixLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "viewMatrix", GX2_SHADER_VAR_TYPE_MATRIX4X4, 1, viewMatrixLocation, -1 });
positionLocation = 0; positionLocation = 0;
colorLocation = 1; colorLocation = 1;
texCoordLocation = 2; texCoordLocation = 2;
vertexShader.addAttribVar((GX2AttribVar){ "attr_colors", GX2_VAR_TYPE_VEC4, 0, colorLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_colors", GX2_SHADER_VAR_TYPE_FLOAT4, 0, colorLocation });
vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_VAR_TYPE_VEC3, 0, positionLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation });
vertexShader.addAttribVar((GX2AttribVar){ "attr_texture_coord", GX2_VAR_TYPE_VEC2, 0, texCoordLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation });
//! setup attribute streams //! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_32_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
GX2InitAttribStream(vertexShader.getAttributeBuffer(1), texCoordLocation, 1, 0, GX2_ATTRIB_FORMAT_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(1), texCoordLocation, 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
GX2InitAttribStream(vertexShader.getAttributeBuffer(2), colorLocation, 2, 0, GX2_ATTRIB_FORMAT_8_8_8_8_UNORM); GX2InitAttribStream(vertexShader.getAttributeBuffer(2), colorLocation, 2, 0, GX2_ATTRIB_FORMAT_UNORM_8_8_8_8);
//! create fetch shader //! create fetch shader
fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount()); fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount());
@ -334,20 +334,20 @@ ShaderFractalColor::ShaderFractalColor()
posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f;
posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;
posVtxs[i++] = -1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, posVtxs, ciPositionVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize);
i = 0; i = 0;
texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 0.0f;
texCoords[i++] = 0.0f; texCoords[i++] = 0.0f; texCoords[i++] = 0.0f; texCoords[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, texCoords, ciTexCoordsVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, texCoords, ciTexCoordsVtxsSize);
for(i = 0; i < (int)ciColorVtxsSize; i++) for(i = 0; i < (int)ciColorVtxsSize; i++)
colorVtxs[i] = 0xff; colorVtxs[i] = 0xff;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, colorVtxs, ciColorVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, colorVtxs, ciColorVtxsSize);
} }
ShaderFractalColor::~ShaderFractalColor() ShaderFractalColor::~ShaderFractalColor()

View File

@ -204,11 +204,11 @@ Texture2DShader::Texture2DShader()
blurLocation = 0; blurLocation = 0;
colorIntensityLocation = 4; colorIntensityLocation = 4;
pixelShader.addUniformVar((GX2UniformVar){ "unf_blur_texture_direction", GX2_VAR_TYPE_VEC3, 1, blurLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_blur_texture_direction", GX2_SHADER_VAR_TYPE_FLOAT3, 1, blurLocation, -1 });
pixelShader.addUniformVar((GX2UniformVar){ "unf_color_intensity", GX2_VAR_TYPE_VEC4, 1, colorIntensityLocation, 0xffffffff }); pixelShader.addUniformVar((GX2UniformVar){ "unf_color_intensity", GX2_SHADER_VAR_TYPE_FLOAT4, 1, colorIntensityLocation, -1 });
samplerLocation = 0; samplerLocation = 0;
pixelShader.addSamplerVar((GX2SamplerVar){ "sampl_texture", GX2_SAMPLER_TYPE_2D, samplerLocation }); pixelShader.addSamplerVar((GX2SamplerVar){ "sampl_texture", GX2_SAMPLER_VAR_TYPE_SAMPLER_2D, samplerLocation });
//! create vertex shader //! create vertex shader
vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs)); vertexShader.setProgram(cpVertexShaderProgram, sizeof(cpVertexShaderProgram), cpVertexShaderRegs, sizeof(cpVertexShaderRegs));
@ -216,18 +216,18 @@ Texture2DShader::Texture2DShader()
angleLocation = 0; angleLocation = 0;
offsetLocation = 4; offsetLocation = 4;
scaleLocation = 8; scaleLocation = 8;
vertexShader.addUniformVar((GX2UniformVar){ "unf_angle", GX2_VAR_TYPE_FLOAT, 1, angleLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "unf_angle", GX2_SHADER_VAR_TYPE_FLOAT, 1, angleLocation, -1 });
vertexShader.addUniformVar((GX2UniformVar){ "unf_offset", GX2_VAR_TYPE_VEC3, 1, offsetLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "unf_offset", GX2_SHADER_VAR_TYPE_FLOAT3, 1, offsetLocation, -1 });
vertexShader.addUniformVar((GX2UniformVar){ "unf_scale", GX2_VAR_TYPE_VEC3, 1, scaleLocation, 0xffffffff }); vertexShader.addUniformVar((GX2UniformVar){ "unf_scale", GX2_SHADER_VAR_TYPE_FLOAT3, 1, scaleLocation, -1 });
positionLocation = 0; positionLocation = 0;
texCoordLocation = 1; texCoordLocation = 1;
vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_VAR_TYPE_VEC3, 0, positionLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_position", GX2_SHADER_VAR_TYPE_FLOAT3, 0, positionLocation });
vertexShader.addAttribVar((GX2AttribVar){ "attr_texture_coord", GX2_VAR_TYPE_VEC2, 0, texCoordLocation }); vertexShader.addAttribVar((GX2AttribVar){ "attr_texture_coord", GX2_SHADER_VAR_TYPE_FLOAT2, 0, texCoordLocation });
//! setup attribute streams //! setup attribute streams
GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_32_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(0), positionLocation, 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
GX2InitAttribStream(vertexShader.getAttributeBuffer(1), texCoordLocation, 1, 0, GX2_ATTRIB_FORMAT_32_32_FLOAT); GX2InitAttribStream(vertexShader.getAttributeBuffer(1), texCoordLocation, 1, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32);
//! create fetch shader //! create fetch shader
fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount()); fetchShader = new FetchShader(vertexShader.getAttributeBuffer(), vertexShader.getAttributesCount());
@ -243,14 +243,14 @@ Texture2DShader::Texture2DShader()
posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 0.0f;
posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;
posVtxs[i++] = -1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f; posVtxs[i++] = -1.0f; posVtxs[i++] = 1.0f; posVtxs[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, posVtxs, ciPositionVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, posVtxs, ciPositionVtxsSize);
i = 0; i = 0;
texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f; texCoords[i++] = 1.0f;
texCoords[i++] = 1.0f; texCoords[i++] = 0.0f; texCoords[i++] = 1.0f; texCoords[i++] = 0.0f;
texCoords[i++] = 0.0f; texCoords[i++] = 0.0f; texCoords[i++] = 0.0f; texCoords[i++] = 0.0f;
GX2Invalidate(GX2_INVALIDATE_CPU_ATTRIB_BUFFER, texCoords, ciTexCoordsVtxsSize); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_ATTRIBUTE_BUFFER, texCoords, ciTexCoordsVtxsSize);
} }
Texture2DShader::~Texture2DShader() Texture2DShader::~Texture2DShader()

View File

@ -104,8 +104,8 @@ public:
} }
void setTextureAndSampler(const GX2Texture *texture, const GX2Sampler *sampler) const { void setTextureAndSampler(const GX2Texture *texture, const GX2Sampler *sampler) const {
GX2SetPixelTexture(texture, samplerLocation); GX2SetPixelTexture((GX2Texture*)texture, samplerLocation);
GX2SetPixelSampler(sampler, samplerLocation); GX2SetPixelSampler((GX2Sampler*)sampler, samplerLocation);
} }
}; };

View File

@ -31,7 +31,7 @@ public:
if(vertexShader) if(vertexShader)
{ {
memset(vertexShader, 0, sizeof(GX2VertexShader)); memset(vertexShader, 0, sizeof(GX2VertexShader));
vertexShader->shader_mode = GX2_SHADER_MODE_UNIFORM_REGISTER; vertexShader->mode = GX2_SHADER_MODE_UNIFORM_REGISTER;
} }
} }
@ -40,38 +40,38 @@ public:
if(vertexShader) if(vertexShader)
{ {
if(vertexShader->shader_data) if(vertexShader->program)
free(vertexShader->shader_data); free(vertexShader->program);
for(u32 i = 0; i < vertexShader->uniform_blocks_count; i++) for(u32 i = 0; i < vertexShader->uniformBlockCount; i++)
free((void*)vertexShader->uniform_block[i].name); free((void*)vertexShader->uniformBlocks[i].name);
if(vertexShader->uniform_block) if(vertexShader->uniformBlocks)
free((void*)vertexShader->uniform_block); free((void*)vertexShader->uniformBlocks);
for(u32 i = 0; i < vertexShader->uniform_vars_count; i++) for(u32 i = 0; i < vertexShader->uniformVarCount; i++)
free((void*)vertexShader->uniform_var[i].name); free((void*)vertexShader->uniformVars[i].name);
if(vertexShader->uniform_var) if(vertexShader->uniformVars)
free((void*)vertexShader->uniform_var); free((void*)vertexShader->uniformVars);
if(vertexShader->initial_value) if(vertexShader->initialValues)
free((void*)vertexShader->initial_value); free((void*)vertexShader->initialValues);
for(u32 i = 0; i < vertexShader->sampler_vars_count; i++) for(u32 i = 0; i < vertexShader->samplerVarCount; i++)
free((void*)vertexShader->sampler_var[i].name); free((void*)vertexShader->samplerVars[i].name);
if(vertexShader->sampler_var) if(vertexShader->samplerVars)
free((void*)vertexShader->sampler_var); free((void*)vertexShader->samplerVars);
for(u32 i = 0; i < vertexShader->attribute_vars_count; i++) for(u32 i = 0; i < vertexShader->attribVarCount; i++)
free((void*)vertexShader->attribute_var[i].name); free((void*)vertexShader->attribVars[i].name);
if(vertexShader->attribute_var) if(vertexShader->attribVars)
free((void*)vertexShader->attribute_var); free((void*)vertexShader->attribVars);
if(vertexShader->loops_data) if(vertexShader->loopVars)
free((void*)vertexShader->loops_data); free((void*)vertexShader->loopVars);
free(vertexShader); free(vertexShader);
} }
@ -83,15 +83,15 @@ public:
return; return;
//! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100 //! this must be moved into an area where the graphic engine has access to and must be aligned to 0x100
vertexShader->shader_size = programSize; vertexShader->size = programSize;
vertexShader->shader_data = memalign(GX2_SHADER_ALIGNMENT, vertexShader->shader_size); vertexShader->program = (u8*) memalign(GX2_SHADER_ALIGNMENT, vertexShader->size);
if(vertexShader->shader_data) if(vertexShader->program)
{ {
memcpy(vertexShader->shader_data, program, vertexShader->shader_size); memcpy(vertexShader->program, program, vertexShader->size);
GX2Invalidate(GX2_INVALIDATE_CPU_SHADER, vertexShader->shader_data, vertexShader->shader_size); GX2Invalidate(GX2_INVALIDATE_MODE_CPU_SHADER, vertexShader->program, vertexShader->size);
} }
memcpy(vertexShader->regs, regs, regsSize); memcpy(&vertexShader->regs, regs, regsSize);
} }
void addUniformVar(const GX2UniformVar & var) void addUniformVar(const GX2UniformVar & var)
@ -99,23 +99,23 @@ public:
if(!vertexShader) if(!vertexShader)
return; return;
u32 idx = vertexShader->uniform_vars_count; u32 idx = vertexShader->uniformVarCount;
GX2UniformVar* newVar = (GX2UniformVar*) malloc((vertexShader->uniform_vars_count + 1) * sizeof(GX2UniformVar)); GX2UniformVar* newVar = (GX2UniformVar*) malloc((vertexShader->uniformVarCount + 1) * sizeof(GX2UniformVar));
if(newVar) if(newVar)
{ {
if(vertexShader->uniform_vars_count > 0) if(vertexShader->uniformVarCount > 0)
{ {
memcpy(newVar, vertexShader->uniform_var, vertexShader->uniform_vars_count * sizeof(GX2UniformVar)); memcpy(newVar, vertexShader->uniformVars, vertexShader->uniformVarCount * sizeof(GX2UniformVar));
free(vertexShader->uniform_var); free(vertexShader->uniformVars);
} }
vertexShader->uniform_var = newVar; vertexShader->uniformVars = newVar;
memcpy(vertexShader->uniform_var + idx, &var, sizeof(GX2UniformVar)); memcpy(vertexShader->uniformVars + idx, &var, sizeof(GX2UniformVar));
vertexShader->uniform_var[idx].name = (char*) malloc(strlen(var.name) + 1); vertexShader->uniformVars[idx].name = (char*) malloc(strlen(var.name) + 1);
strcpy((char*)vertexShader->uniform_var[idx].name, var.name); strcpy((char*)vertexShader->uniformVars[idx].name, var.name);
vertexShader->uniform_vars_count++; vertexShader->uniformVarCount++;
} }
} }
@ -124,28 +124,28 @@ public:
if(!vertexShader) if(!vertexShader)
return; return;
u32 idx = vertexShader->attribute_vars_count; u32 idx = vertexShader->attribVarCount;
GX2AttribVar* newVar = (GX2AttribVar*) malloc((vertexShader->attribute_vars_count + 1) * sizeof(GX2AttribVar)); GX2AttribVar* newVar = (GX2AttribVar*) malloc((vertexShader->attribVarCount + 1) * sizeof(GX2AttribVar));
if(newVar) if(newVar)
{ {
if(vertexShader->attribute_vars_count > 0) if(vertexShader->attribVarCount > 0)
{ {
memcpy(newVar, vertexShader->attribute_var, vertexShader->attribute_vars_count * sizeof(GX2AttribVar)); memcpy(newVar, vertexShader->attribVars, vertexShader->attribVarCount * sizeof(GX2AttribVar));
free(vertexShader->attribute_var); free(vertexShader->attribVars);
} }
vertexShader->attribute_var = newVar; vertexShader->attribVars = newVar;
memcpy(vertexShader->attribute_var + idx, &var, sizeof(GX2AttribVar)); memcpy(vertexShader->attribVars + idx, &var, sizeof(GX2AttribVar));
vertexShader->attribute_var[idx].name = (char*) malloc(strlen(var.name) + 1); vertexShader->attribVars[idx].name = (char*) malloc(strlen(var.name) + 1);
strcpy((char*)vertexShader->attribute_var[idx].name, var.name); strcpy((char*)vertexShader->attribVars[idx].name, var.name);
vertexShader->attribute_vars_count++; vertexShader->attribVarCount++;
} }
} }
static inline void setAttributeBuffer(u32 bufferIdx, u32 bufferSize, u32 stride, const void * buffer) { static inline void setAttributeBuffer(u32 bufferIdx, u32 bufferSize, u32 stride, const void * buffer) {
GX2SetAttribBuffer(bufferIdx, bufferSize, stride, buffer); GX2SetAttribBuffer(bufferIdx, bufferSize, stride, (void*)buffer);
} }
GX2VertexShader *getVertexShader() const { GX2VertexShader *getVertexShader() const {
@ -167,7 +167,7 @@ public:
} }
static void setUniformReg(u32 location, u32 size, const void * reg) { static void setUniformReg(u32 location, u32 size, const void * reg) {
GX2SetVertexUniformReg(location, size, reg); GX2SetVertexUniformReg(location, size, (uint32_t*)reg);
} }
protected: protected:
u32 attributesCount; u32 attributesCount;