diff --git a/.gitignore b/.gitignore index 08f3f14c..97102a42 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ orig/*/* *.dol *.rel *.elf +*.app *.o *.map *.MAP diff --git a/config/43E/build.sha1 b/config/43E/build.sha1 index cc09adc7..fb76151d 100644 --- a/config/43E/build.sha1 +++ b/config/43E/build.sha1 @@ -1 +1 @@ -CBBF437BA9508A842B27C833323C960FD42435D8 build/43E/main.app \ No newline at end of file +cbbf437ba9508a842b27c833323c960fd42435d8 build/43E/main.app \ No newline at end of file diff --git a/config/43E/config.yml b/config/43E/config.yml index eeaf7611..cc1f5f38 100644 --- a/config/43E/config.yml +++ b/config/43E/config.yml @@ -5,7 +5,8 @@ splits: 'config/43E/splits.txt' ldscript_template: ldscript_ipl2.lcf -export_all: true +symbols_known: false +quick_analysis: true fill_gaps: false extract: diff --git a/config/43E/splits.txt b/config/43E/splits.txt index 6f0f8670..1e4806a4 100644 --- a/config/43E/splits.txt +++ b/config/43E/splits.txt @@ -286,11 +286,11 @@ src/utility/iplESMisc.cpp: .sdata start:0x81698140 end:0x81698160 src/utility/iplCSFlags.cpp: - .text start:0x8136836C end:0x813689C0 + .text start:0x8136836C end:0x81368800 .data start:0x816426A0 end:0x816429D0 src/layout/GUIManager.cpp: - .text start:0x813689C0 end:0x81369B64 + .text start:0x81368800 end:0x81369B64 .data start:0x816429D0 end:0x81642B50 .sdata2 start:0x81696518 end:0x81696528 .sbss start:0x8169A620 end:0x8169A628 diff --git a/config/43E/symbols.txt b/config/43E/symbols.txt index 8f403eff..1166cc9b 100644 --- a/config/43E/symbols.txt +++ b/config/43E/symbols.txt @@ -2315,7 +2315,7 @@ ReadFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x8136851 WriteFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81368608; // type:function size:0xF0 UpdateFlagsFile__Q33ipl7utility7CSFlagsFv = .text:0x813686F8; // type:function size:0xB8 SetEULAFlag__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x813687B0; // type:function size:0x50 -iplCSFlags_81368758 = .text:0x81368800; // type:function size:0x1C0 scope:local +GuiMgr_81368758 = .text:0x81368800; // type:function size:0x1C0 scope:local update__Q23gui9ComponentFiffUlUlUlPv = .text:0x813689C0; // type:function size:0x2C0 isVisible__Q23gui9ComponentFv = .text:0x81368C80; // type:function size:0x8 isPointed__Q23gui9ComponentFi = .text:0x81368C88; // type:function size:0xC @@ -14232,7 +14232,7 @@ lbl_81635040 = .data:0x81635040; // type:object size:0x16 data:string lbl_81635056 = .data:0x81635056; // type:object size:0x12 data:string __vt__Q33ipl4nand10SharedFile = .data:0x81635068; // type:object size:0x54 lbl_816350C0 = .data:0x816350C0; // type:object size:0x1A data:string -lbl_816350DA = .data:0x816350DA; // type:object size:0x12 +lbl_816350DA = .data:0x816350DA; // type:object size:0x10 data:string __vt__Q33ipl4nand8MetaFile = .data:0x816350EC; // type:object size:0x54 lbl_81635140 = .data:0x81635140; // type:object size:0x13 data:string lbl_81635153 = .data:0x81635153; // type:object size:0x55 @@ -14243,7 +14243,7 @@ sRMO_Pal50_640x456IntDf__3ipl = .data:0x816352D0; // type:object size:0x3C scope sRMO_Pal60_640x456IntDf__3ipl = .data:0x8163530C; // type:object size:0x3C scope:local sRMO_Pal60_640x456Prog__3ipl = .data:0x81635348; // type:object size:0x3C scope:local jumptable_81635388 = .data:0x81635388; // type:object size:0x28 scope:local -lbl_816353B0 = .data:0x816353B0; // type:object size:0x18 +lbl_816353B0 = .data:0x816353B0; // type:object size:0x13 data:string lbl_816353C8 = .data:0x816353C8; // type:object size:0x14 jumptable_816353DC = .data:0x816353DC; // type:object size:0x94 scope:local lbl_81635470 = .data:0x81635470; // type:object size:0xD data:string diff --git a/config/43J/build.sha1 b/config/43J/build.sha1 index 5808a2cb..110f9cb3 100644 --- a/config/43J/build.sha1 +++ b/config/43J/build.sha1 @@ -1 +1 @@ -F944B6F05F25EC50992F25B39655314BDF566201 build/43J/main.app \ No newline at end of file +f944b6f05f25ec50992f25b39655314bdf566201 build/43J/main.app \ No newline at end of file diff --git a/config/43J/config.yml b/config/43J/config.yml index 02134a1b..56147a11 100644 --- a/config/43J/config.yml +++ b/config/43J/config.yml @@ -5,7 +5,8 @@ splits: 'config/43J/splits.txt' ldscript_template: ldscript_ipl2.lcf -export_all: true +symbols_known: false +quick_analysis: true fill_gaps: false extract: diff --git a/config/43J/splits.txt b/config/43J/splits.txt index 94c58165..c9c59e7f 100644 --- a/config/43J/splits.txt +++ b/config/43J/splits.txt @@ -286,11 +286,11 @@ src/utility/iplESMisc.cpp: .sdata start:0x816C59A0 end:0x816C59C0 src/utility/iplCSFlags.cpp: - .text start:0x81367778 end:0x81367DCC + .text start:0x81367778 end:0x81367C0C .data start:0x81672CC0 end:0x81672FF0 src/layout/GUIManager.cpp: - .text start:0x81367DCC end:0x81368F70 + .text start:0x81367C0C end:0x81368F70 .data start:0x81672FF0 end:0x81673170 .sdata2 start:0x816C3D78 end:0x816C3D88 .sbss start:0x816C7E80 end:0x816C7E88 diff --git a/config/43J/symbols.txt b/config/43J/symbols.txt index c21f9ad3..267d7bd4 100644 --- a/config/43J/symbols.txt +++ b/config/43J/symbols.txt @@ -2088,7 +2088,7 @@ ReadFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x8136791 WriteFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81367A14; // type:function size:0xF0 UpdateFlagsFile__Q33ipl7utility7CSFlagsFv = .text:0x81367B04; // type:function size:0xB8 SetEULAFlag__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81367BBC; // type:function size:0x50 -iplCSFlags_81368758 = .text:0x81367C0C; // type:function size:0x1C0 scope:local +GuiMgr_81368758 = .text:0x81367C0C; // type:function size:0x1C0 scope:local update__Q23gui9ComponentFiffUlUlUlPv = .text:0x81367DCC; // type:function size:0x2C0 isVisible__Q23gui9ComponentFv = .text:0x8136808C; // type:function size:0x8 isPointed__Q23gui9ComponentFi = .text:0x81368094; // type:function size:0xC @@ -14321,7 +14321,7 @@ lbl_816656E0 = .data:0x816656E0; // type:object size:0x16 data:string lbl_816656F6 = .data:0x816656F6; // type:object size:0x12 data:string __vt__Q33ipl4nand10SharedFile = .data:0x81665708; // type:object size:0x54 lbl_81665760 = .data:0x81665760; // type:object size:0x1A data:string -lbl_8166577A = .data:0x8166577A; // type:object size:0x12 +lbl_8166577A = .data:0x8166577A; // type:object size:0x10 data:string __vt__Q33ipl4nand8MetaFile = .data:0x8166578C; // type:object size:0x54 lbl_816657E0 = .data:0x816657E0; // type:object size:0x13 data:string lbl_816657F3 = .data:0x816657F3; // type:object size:0x55 @@ -14332,7 +14332,7 @@ sRMO_Pal50_640x456IntDf__3ipl = .data:0x81665970; // type:object size:0x3C scope sRMO_Pal60_640x456IntDf__3ipl = .data:0x816659AC; // type:object size:0x3C scope:local sRMO_Pal60_640x456Prog__3ipl = .data:0x816659E8; // type:object size:0x3C scope:local jumptable_81665A28 = .data:0x81665A28; // type:object size:0x28 scope:local -lbl_81665A50 = .data:0x81665A50; // type:object size:0x18 +lbl_81665A50 = .data:0x81665A50; // type:object size:0x13 data:string lbl_81665A68 = .data:0x81665A68; // type:object size:0x14 jumptable_81665A7C = .data:0x81665A7C; // type:object size:0x94 scope:local lbl_81665B10 = .data:0x81665B10; // type:object size:0xD data:string diff --git a/config/43K/build.sha1 b/config/43K/build.sha1 index f796e4f6..6d773662 100644 --- a/config/43K/build.sha1 +++ b/config/43K/build.sha1 @@ -1 +1 @@ -B055733997FBE8D0C531E3E105C6AAFAC18E7C66 build/43K/main.app \ No newline at end of file +b055733997fbe8d0c531e3e105c6aafac18e7c66 build/43K/main.app \ No newline at end of file diff --git a/config/43K/config.yml b/config/43K/config.yml index 5be9b750..e197a5a8 100644 --- a/config/43K/config.yml +++ b/config/43K/config.yml @@ -5,7 +5,8 @@ splits: 'config/43K/splits.txt' ldscript_template: ldscript_ipl2.lcf -export_all: true +symbols_known: false +quick_analysis: true fill_gaps: false extract: diff --git a/config/43K/splits.txt b/config/43K/splits.txt index 6ffbb54b..a5838ede 100644 --- a/config/43K/splits.txt +++ b/config/43K/splits.txt @@ -286,11 +286,11 @@ src/utility/iplESMisc.cpp: .sdata start:0x8166A8C0 end:0x8166A8E0 src/utility/iplCSFlags.cpp: - .text start:0x81367658 end:0x81367CAC + .text start:0x81367658 end:0x81367AEC .data start:0x81617298 end:0x816175C8 src/layout/GUIManager.cpp: - .text start:0x81367CAC end:0x81368E50 + .text start:0x81367AEC end:0x81368E50 .data start:0x816175C8 end:0x81617748 .sdata2 start:0x81668CD8 end:0x81668CE8 .sbss start:0x8166CD98 end:0x8166CDA0 diff --git a/config/43K/symbols.txt b/config/43K/symbols.txt index 7653c0aa..6bca0933 100644 --- a/config/43K/symbols.txt +++ b/config/43K/symbols.txt @@ -2071,7 +2071,7 @@ ReadFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x813677F WriteFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x813678F4; // type:function size:0xF0 UpdateFlagsFile__Q33ipl7utility7CSFlagsFv = .text:0x813679E4; // type:function size:0xB8 SetEULAFlag__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81367A9C; // type:function size:0x50 -iplCSFlags_81368758 = .text:0x81367AEC; // type:function size:0x1C0 scope:local +GuiMgr_81368758 = .text:0x81367AEC; // type:function size:0x1C0 scope:local update__Q23gui9ComponentFiffUlUlUlPv = .text:0x81367CAC; // type:function size:0x2C0 isVisible__Q23gui9ComponentFv = .text:0x81367F6C; // type:function size:0x8 isPointed__Q23gui9ComponentFi = .text:0x81367F74; // type:function size:0xC @@ -13815,18 +13815,18 @@ lbl_8160CF80 = .data:0x8160CF80; // type:object size:0x16 data:string lbl_8160CF96 = .data:0x8160CF96; // type:object size:0x12 data:string __vt__Q33ipl4nand10SharedFile = .data:0x8160CFA8; // type:object size:0x54 lbl_8160D000 = .data:0x8160D000; // type:object size:0x1A data:string -lbl_8160D01A = .data:0x8160D01A; // type:object size:0x12 +lbl_8160D01A = .data:0x8160D01A; // type:object size:0x10 data:string __vt__Q33ipl4nand8MetaFile = .data:0x8160D02C; // type:object size:0x54 lbl_8160D080 = .data:0x8160D080; // type:object size:0x13 data:string lbl_8160D093 = .data:0x8160D093; // type:object size:0x55 lbl_8160D0E8 = .data:0x8160D0E8; // type:object size:0xB0 -sRMO_Ntsc_640x456IntDf__3ipl = .data:0x8160D198; // type:object size:0x3C -sRMO_Ntsc_640x456Prog__3ipl = .data:0x8160D1D4; // type:object size:0x3C -sRMO_Pal50_640x456IntDf__3ipl = .data:0x8160D210; // type:object size:0x3C -sRMO_Pal60_640x456IntDf__3ipl = .data:0x8160D24C; // type:object size:0x3C -sRMO_Pal60_640x456Prog__3ipl = .data:0x8160D288; // type:object size:0x3C +sRMO_Ntsc_640x456IntDf__3ipl = .data:0x8160D198; // type:object size:0x3C scope:local +sRMO_Ntsc_640x456Prog__3ipl = .data:0x8160D1D4; // type:object size:0x3C scope:local +sRMO_Pal50_640x456IntDf__3ipl = .data:0x8160D210; // type:object size:0x3C scope:local +sRMO_Pal60_640x456IntDf__3ipl = .data:0x8160D24C; // type:object size:0x3C scope:local +sRMO_Pal60_640x456Prog__3ipl = .data:0x8160D288; // type:object size:0x3C scope:local jumptable_8160D2C8 = .data:0x8160D2C8; // type:object size:0x28 scope:local -lbl_8160D2F0 = .data:0x8160D2F0; // type:object size:0x18 +lbl_8160D2F0 = .data:0x8160D2F0; // type:object size:0x13 data:string lbl_8160D308 = .data:0x8160D308; // type:object size:0x14 jumptable_8160D31C = .data:0x8160D31C; // type:object size:0x94 scope:local lbl_8160D3B0 = .data:0x8160D3B0; // type:object size:0xD data:string diff --git a/config/43U/build.sha1 b/config/43U/build.sha1 index 33d26bd0..55c9be14 100644 --- a/config/43U/build.sha1 +++ b/config/43U/build.sha1 @@ -1 +1 @@ -9BD9ABBEC9007889ACB852A4B2E6E115C0A299F5 build/43U/main.app \ No newline at end of file +9bd9abbec9007889acb852a4b2e6e115c0a299f5 build/43U/main.app \ No newline at end of file diff --git a/config/43U/config.yml b/config/43U/config.yml index 42fe8345..bd39599a 100644 --- a/config/43U/config.yml +++ b/config/43U/config.yml @@ -5,7 +5,8 @@ splits: 'config/43U/splits.txt' ldscript_template: ldscript_ipl2.lcf -export_all: true +symbols_known: false +quick_analysis: true fill_gaps: false extract: diff --git a/config/43U/splits.txt b/config/43U/splits.txt index bd044bad..b03e63b7 100644 --- a/config/43U/splits.txt +++ b/config/43U/splits.txt @@ -286,11 +286,11 @@ src/utility/iplESMisc.cpp: .sdata start:0x816962A0 end:0x816962C0 src/utility/iplCSFlags.cpp: - .text start:0x813682C4 end:0x81368918 + .text start:0x813682C4 end:0x81368758 .data start:0x816423E0 end:0x81642710 src/layout/GUIManager.cpp: - .text start:0x81368918 end:0x81369ABC + .text start:0x81368758 end:0x81369ABC .data start:0x81642710 end:0x81642890 .sdata2 start:0x81694678 end:0x81694688 .sbss start:0x81698780 end:0x81698788 diff --git a/config/43U/symbols.txt b/config/43U/symbols.txt index fa58db35..5e1c9ec7 100644 --- a/config/43U/symbols.txt +++ b/config/43U/symbols.txt @@ -1,4 +1,4 @@ -work = .bss:0x81080000; // type:object size:0x9008 scope:local +work = .bss:0x81080000; // type:object size:0x9008 scope:local data:4byte smArg__Q23ipl6System = .bss:0x81089008; // type:object size:0x2D8 data:4byte smCSVm__Q33ipl7channel20ChannelScriptManager = .bss:0x810892E0; // type:object size:0x270 smArg__Q23ipl11PlayTimeLog = .bss:0x81089550; // type:object size:0xD0 data:byte @@ -373,6 +373,7 @@ lbl_811B1458 = .bss:0x811B1458; // type:object size:0x28 data:4byte lbl_811B1480 = .bss:0x811B1480; // type:object size:0x8 data:4byte lbl_811B1488 = .bss:0x811B1488; // type:object size:0x8 data:byte lbl_811B1490 = .bss:0x811B1490; // type:object size:0x4 data:byte +lbl_811B1498 = .bss:0x811B1498; // type:object size:0x17EB68 scope:local data:byte noreloc noexport __start = .init:0x81330000; // type:function size:0xA8 scope:weak __init_registers = .init:0x813300A8; // type:function size:0x90 scope:local __init_data = .init:0x81330138; // type:function size:0xA0 scope:local @@ -2315,7 +2316,7 @@ ReadFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x8136846 WriteFlags__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81368560; // type:function size:0xF0 UpdateFlagsFile__Q33ipl7utility7CSFlagsFv = .text:0x81368650; // type:function size:0xB8 SetEULAFlag__Q33ipl7utility7CSFlagsFPQ33ipl7utility11CSFlagsData = .text:0x81368708; // type:function size:0x50 -iplCSFlags_81368758 = .text:0x81368758; // type:function size:0x1C0 scope:local +GuiMgr_81368758 = .text:0x81368758; // type:function size:0x1C0 scope:local update__Q23gui9ComponentFiffUlUlUlPv = .text:0x81368918; // type:function size:0x2C0 isVisible__Q23gui9ComponentFv = .text:0x81368BD8; // type:function size:0x8 isPointed__Q23gui9ComponentFi = .text:0x81368BE0; // type:function size:0xC @@ -14234,7 +14235,7 @@ lbl_81634D90 = .data:0x81634D90; // type:object size:0x16 data:string lbl_81634DA6 = .data:0x81634DA6; // type:object size:0x12 data:string __vt__Q33ipl4nand10SharedFile = .data:0x81634DB8; // type:object size:0x54 lbl_81634E10 = .data:0x81634E10; // type:object size:0x1A data:string -lbl_81634E2A = .data:0x81634E2A; // type:object size:0x12 +lbl_81634E2A = .data:0x81634E2A; // type:object size:0x10 data:string __vt__Q33ipl4nand8MetaFile = .data:0x81634E3C; // type:object size:0x54 lbl_81634E90 = .data:0x81634E90; // type:object size:0x13 data:string lbl_81634EA3 = .data:0x81634EA3; // type:object size:0x4D data:string diff --git a/configure.py b/configure.py index 5a171afb..639008b6 100644 --- a/configure.py +++ b/configure.py @@ -217,9 +217,9 @@ config.scratch_preset_id = None config.progress_all = False config.progress_use_fancy = True -config.progress_code_fancy_frac = 288 +config.progress_code_fancy_frac = 288 # Maxumum amount on System Memory + Maxumum amount on SD Card config.progress_code_fancy_item = "Channels" -config.progress_data_fancy_frac = 4096 +config.progress_data_fancy_frac = 4096 # Amount of Wii blocks avaiable (apparenty) config.progress_data_fancy_item = "Blocks" # Base flags @@ -469,7 +469,7 @@ config.libs = [ IPLSection("utility", [ Object(Matching, "utility/iplTree.cpp"), - Object(NonMatching, "utility/iplFrameController.cpp"), + Object(Matching, "utility/iplFrameController.cpp"), Object(NonMatching, "utility/iplGraphics.cpp"), Object(Matching, "utility/iplCapture.cpp"), Object(NonMatching, "utility/iplUtility.cpp"), @@ -510,7 +510,7 @@ config.libs = [ Object(NonMatching, "homebutton/HBMBase.cpp"), Object(NonMatching, "homebutton/HBMAnmController.cpp"), Object(NonMatching, "homebutton/HBMController.cpp"), - Object(NonMatching, "homebutton/HBMFrameController.cpp"), + Object(Matching, "homebutton/HBMFrameController.cpp"), Object(NonMatching, "homebutton/HBMGUIManager.cpp"), Object(NonMatching, "homebutton/HBMRemoteSpk.cpp"), ] diff --git a/include/homebutton/HBMFrameController.h b/include/homebutton/HBMFrameController.h new file mode 100644 index 00000000..18095c3a --- /dev/null +++ b/include/homebutton/HBMFrameController.h @@ -0,0 +1,68 @@ +#ifndef HOME_BUTTON_FRAME_CONTROLLER_H +#define HOME_BUTTON_FRAME_CONTROLLER_H + +#include + +namespace homebutton { + enum { + ANIM_TYPE_FORWARD = 0, + ANIM_TYPE_BACKWARD, + ANIM_TYPE_LOOP, + ANIM_TYPE_BOUNCE + }; + + enum { + ANIM_STATE_READY = 0, + ANIM_STATE_PLAY, + ANIM_STATE_STOP, + }; + + class FrameController { + public: + FrameController() {} + virtual ~FrameController() {} + + void init(int type, f32 maxFrame, f32 minFrame, f32 delta); + void initFrame(); + + virtual void calc(); + + void setMaxFrame(f32 value) { mMaxFrame = value; } + f32 getMaxFrame() const { return mMaxFrame; } + + f32 getLastFrame() const { return mMaxFrame - 1.0f; } + + void setMinFrame(f32 value) { mMinFrame = value; } + f32 getMinFrame() const { return mMinFrame; } + + void setCurrentFrame(f32 value) { mFrame = value; } + f32 getCurrentFrame() const { return mFrame; } + + void setDelta(f32 value) { mDelta = value; } + f32 getDelta() const { return mDelta; } + + void setState(int value) { mState = value; } + int getState() const { return mState; } + + void setAnimType(int value) { mAnmType = value; } + int getAnimType() const { return mAnmType; } + + bool isPlaying() const { return mState == ANIM_STATE_PLAY; } + + protected: + f32 mMaxFrame; // 0x04 + f32 mMinFrame; // 0x08 + f32 mFrame; // 0x0C + + f32 mDelta; // 0x10 + + int mState; // 0x14 + + int mAnmType; // 0x18 + + private: + bool mbBounceBack; // 0x1C + }; +} + +#endif // HOME_BUTTON_FRAME_CONTROLLER_H diff --git a/include/math/iplInterporation.h b/include/math/iplInterporation.h index f16d2a4c..b969e1ed 100644 --- a/include/math/iplInterporation.h +++ b/include/math/iplInterporation.h @@ -3,25 +3,25 @@ #include +#include "utility/iplFrameController.h" + namespace ipl { namespace math { - class Interporation /* : utility::FrameController */ { + class Interporation : utility::FrameController { public: - virtual ~Interporation(); + virtual ~Interporation() {} }; class LinearIntp : Interporation { public: - virtual ~LinearIntp(); + virtual ~LinearIntp() {} }; class HermiteIntp : Interporation { public: - virtual ~HermiteIntp(); + virtual ~HermiteIntp() {} }; } } #endif // IPL_MATH_INTERPORATION_H - - diff --git a/include/system/iplFramework.h b/include/system/iplFramework.h index 1759f847..fdb778c8 100644 --- a/include/system/iplFramework.h +++ b/include/system/iplFramework.h @@ -1 +1,46 @@ -// nothing to see here... yet \ No newline at end of file +#ifndef IPL_FRAME_WORK_H +#define IPL_FRAME_WORK_H + +#include "revolution/gx/GXStruct.h" +#include + +#include +#include + +#include + +namespace ipl { + class Framework { + public: + Framework(EGG::Heap* heap); + + void beginFrame(); + void beginRender(); + void endRender(); + void endFrame(); + + void resetRenderMode(); + + GXRenderModeObj* getRenderMode() { return mpRMode; } + BOOL isWidescreen() { return mWideScreen; } + f32 getDelta() { return mDelta; } + + private: + void flip_xfb(); + + void init_vi(); + void init_xfb(EGG::Heap* heap); + void reset_render_mode(); + + GXRenderModeObj* mpRMode; // 0x00 + + int mCurXfb; // 0x04 + u8* mpXfb[2]; // 0x08 + + BOOL mWideScreen; // 0x10 + + f32 mDelta; // 0x14 + }; +} + +#endif // IPL_FRAME_WORK_H diff --git a/include/system/iplSystem.h b/include/system/iplSystem.h index 3a1ebccb..58b2a587 100644 --- a/include/system/iplSystem.h +++ b/include/system/iplSystem.h @@ -11,6 +11,9 @@ #include +#include "iplMath.h" + +#include "system/iplFramework.h" #include "system/iplNand.h" #include "system/iplController.h" #include "system/iplErrorHandler.h" @@ -27,8 +30,6 @@ #include "system/iplNigaoeManager.h" #include "system/iplBS2Manager.h" -#include "iplMath.h" - #include "scene/iplSceneManager.h" namespace ipl { @@ -52,7 +53,9 @@ namespace ipl { scene::Manager* mpSceneManager; // 0x64 nigaoe::Manager* mpNigaoeManager; // 0x68 nand::Manager* mpNandManager; // 0x6C - undefined unk_0x70[0x80 - 0x70]; + undefined4 unk_0x70; + Framework* mpFramework; // 0x74 + undefined unk_0x78[0x80 - 0x78]; message::Message* mpMessage; // 0x80 undefined4 unk_0x84; undefined4 unk_0x88; @@ -142,6 +145,8 @@ namespace ipl { static nigaoe::Manager* getMiiManager() { return smArg.mpNigaoeManager; } /** @return The Content Manager object. */ static nand::Manager* getNandManager() { return smArg.mpNandManager; } + /** @return The animation speed. */ + static f32 getAnimDelta() { return smArg.mpFramework->getDelta(); } /** @return The WiiConnect24 Manager object. */ static nwc24::Manager* getNwc24Manager() { return smArg.mpNwc24Manager; } /** @return The Save Data Manager object. */ diff --git a/include/utility/iplFrameController.h b/include/utility/iplFrameController.h index 4f5d22f5..28ac69e6 100644 --- a/include/utility/iplFrameController.h +++ b/include/utility/iplFrameController.h @@ -1,8 +1,6 @@ #ifndef IPL_FRAME_CONTROLLER_H #define IPL_FRAME_CONTROLLER_H -#include - #include namespace ipl { @@ -10,13 +8,13 @@ namespace ipl { ANIM_TYPE_FORWARD = 0, ANIM_TYPE_BACKWARD, ANIM_TYPE_LOOP, - ANIM_TYPE_ALTERNATE + ANIM_TYPE_BOUNCE }; enum { - ANIM_STATUS_NOTPLAY = 0, - ANIM_STATUS_PLAY, - ANIM_STATUS_STOP, + ANIM_STATE_READY = 0, + ANIM_STATE_PLAY, + ANIM_STATE_STOP, }; namespace utility { @@ -25,19 +23,44 @@ namespace ipl { FrameController() {} virtual ~FrameController() {} - void init(int type, f32 maxFrame, f32 minFrame, f32 speed); + void init(int type, f32 maxFrame, f32 minFrame = 1.0f, f32 speed = 1.0f); void initFrame(); virtual void calc(); + + void setMaxFrame(f32 value) { mMaxFrame = value; } + f32 getMaxFrame() const { return mMaxFrame; } + + void setMinFrame(f32 value) { mMinFrame = value; } + f32 getMinFrame() const { return mMinFrame; } + + void setCurrentFrame(f32 value) { mFrame = value; } + f32 getCurrentFrame() const { return mFrame; } + + void setSpeed(f32 value) { mSpeed = value; } + f32 getSpeed() const { return mSpeed; } + + void setState(int value) { mState = value; } + int getState() const { return mState; } + + void setAnimType(int value) { mAnmType = value; } + int getAnimType() const { return mAnmType; } + bool isPlaying() const { return mState == ANIM_STATE_PLAY; } + + protected: f32 mMaxFrame; // 0x04 f32 mMinFrame; // 0x08 f32 mFrame; // 0x0C + f32 mSpeed; // 0x10 - int mStatus; // 0x14 + int mState; // 0x14 + int mAnmType; // 0x18 - bool unk_0x1C; + + private: + bool mbBounceBack; // 0x1C }; } } diff --git a/include/utility/iplGraphics.h b/include/utility/iplGraphics.h index ca1e0792..97665bc6 100644 --- a/include/utility/iplGraphics.h +++ b/include/utility/iplGraphics.h @@ -14,7 +14,7 @@ namespace ipl { class Arg { private: u8 unk_0x00[0x40 - 0x00]; - math::MTX34 unk_0x3C; + math::MTX34 mViewMtx; u8 unk_0x6C[0x88 - 0x6C]; friend class Graphics; }; @@ -22,7 +22,7 @@ namespace ipl { static void setDefaultOrtho(u32 ortho = GX_PNMTX0); static void calcOrthoCamera(); - static math::MTX34* getUnk3C() { return &mArg.unk_0x3C; } + static math::MTX34& getViewMtx() { return mArg.mViewMtx; } private: static Arg mArg; diff --git a/libs/NW4R/include/nw4r/lyt/drawInfo.h b/libs/NW4R/include/nw4r/lyt/drawInfo.h index e0f7143e..adfe7cc0 100644 --- a/libs/NW4R/include/nw4r/lyt/drawInfo.h +++ b/libs/NW4R/include/nw4r/lyt/drawInfo.h @@ -23,15 +23,15 @@ namespace nw4r { void SetLocationAdjustScale(const math::VEC2& scale) { mLocationAdjustScale = scale; } bool IsMultipleViewMtxOnDraw() { return mFlag.mulViewDraw; } - void SetMultipleViewMtxOnDraw(bool value) { mFlag.mulViewDraw = value; } + void SetMultipleViewMtxOnDraw(bool bEnable) { mFlag.mulViewDraw = bEnable; } bool IsInfluencedAlpha() { return mFlag.influencedAlpha; } - void SetInfluencedAlpha(bool value) { mFlag.influencedAlpha = value; } + void SetInfluencedAlpha(bool bEnable) { mFlag.influencedAlpha = bEnable; } bool IsLocationAdjust() { return mFlag.locationAdjust; } - void SetLocationAdjust(bool value) { mFlag.locationAdjust = value; } + void SetLocationAdjust(bool bEnable) { mFlag.locationAdjust = bEnable; } bool IsInvisiblePaneCalculateMtx() { return mFlag.invisiblePaneCalculateMtx; } - void SetInvisiblePaneCalculateMtx(bool value) { mFlag.invisiblePaneCalculateMtx = value; } + void SetInvisiblePaneCalculateMtx(bool bEnable) { mFlag.invisiblePaneCalculateMtx = bEnable; } bool IsDebugDrawMode() { return mFlag.debugDrawMode; } - void SetDebugDrawMode(bool value) { mFlag.debugDrawMode = value; } + void SetDebugDrawMode(bool bEnable) { mFlag.debugDrawMode = bEnable; } protected: math::MTX34 mViewMtx; // 0x04 diff --git a/libs/RVL_SDK/include/revolution/gx/GXFrameBuffer.h b/libs/RVL_SDK/include/revolution/gx/GXFrameBuffer.h index b9eb2b60..c32eb195 100644 --- a/libs/RVL_SDK/include/revolution/gx/GXFrameBuffer.h +++ b/libs/RVL_SDK/include/revolution/gx/GXFrameBuffer.h @@ -3,15 +3,27 @@ #include #include +#include #ifdef __cplusplus extern "C" { #endif void GXSetCopyFilter(GXBool aa, const u8 sample_pattern[12][2], GXBool vf, const u8 vfilter[7]); -void GXSetTexCopySrc(u16 x, u16 y, u16 width, u16 height); + +void GXSetDispCopySrc(u16 left, u16 top, u16 width, u16 height); + +void GXSetTexCopySrc(u16 left, u16 top, u16 width, u16 height); void GXSetTexCopyDst(u16 width, u16 height, GXTexFmt fmt, GXBool mipmap); -void GXCopyTex(void *pDest, GXBool clear); +void GXCopyTex(void *dest, GXBool clear); + +void GXSetCopyClear(GXColor clear_clr, u32 clear_z); + +u32 GXSetDispCopyYScale(f32 vscale); +void GXSetDispCopyDst(u16 width, u16 height); +void GXCopyDisp(void *dest, GXBool clear); + +f32 GXGetYScaleFactor(u16 efbHeight, u16 xfbHeight); #ifdef __cplusplus } diff --git a/libs/RVL_SDK/include/revolution/gx/GXManage.h b/libs/RVL_SDK/include/revolution/gx/GXManage.h index 9123b1fb..3135c74c 100644 --- a/libs/RVL_SDK/include/revolution/gx/GXManage.h +++ b/libs/RVL_SDK/include/revolution/gx/GXManage.h @@ -9,10 +9,12 @@ extern "C" { void GXPixModeSync(); +void GXDrawDone(); + +void GXFlush(); + #ifdef __cplusplus } #endif #endif // REVOLUTION_GX_MANAGE_H - - diff --git a/libs/RVL_SDK/include/revolution/gx/GXPixel.h b/libs/RVL_SDK/include/revolution/gx/GXPixel.h index a0dd4710..c180d5dc 100644 --- a/libs/RVL_SDK/include/revolution/gx/GXPixel.h +++ b/libs/RVL_SDK/include/revolution/gx/GXPixel.h @@ -13,6 +13,9 @@ void GXSetDither(GXBool enable); void GXSetZCompLoc(GXBool before_tex); void GXSetZMode(GXBool compare_enable, GXCompare func, GXBool update_enable); +void GXSetColorUpdate(GXBool update_enable); +void GXSetAlphaUpdate(GXBool update_enable); + #ifdef __cplusplus } #endif diff --git a/libs/RVL_SDK/include/revolution/gx/GXTexture.h b/libs/RVL_SDK/include/revolution/gx/GXTexture.h index 5b720a40..8292dba7 100644 --- a/libs/RVL_SDK/include/revolution/gx/GXTexture.h +++ b/libs/RVL_SDK/include/revolution/gx/GXTexture.h @@ -2,12 +2,15 @@ #define REVOLUTION_GX_TEXTURE_H #include +#include #include #ifdef __cplusplus extern "C" { #endif +void GXInvalidateTexAll(); + void GXInitTexObj(GXTexObj* obj, void* pImage, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrapS, GXTexWrapMode wrapT, GXBool mipmap); u32 GXGetTexBufferSize(u16 width, u16 height, u32 format, GXBool mipmap, u8 max_lod); diff --git a/libs/RVL_SDK/include/revolution/sc.h b/libs/RVL_SDK/include/revolution/sc.h index bca98256..039ddc33 100644 --- a/libs/RVL_SDK/include/revolution/sc.h +++ b/libs/RVL_SDK/include/revolution/sc.h @@ -11,6 +11,9 @@ extern "C" { #define SC_ASPECT_RATIO_16x9 1 u8 SCGetAspectRatio(); +u8 SCGetEuRgb60Mode(); +u8 SCGetProgressiveMode(); +u8 SCGetScreenSaverMode(); #define SC_LANG_JAPANESE 0 #define SC_LANG_ENGLISH 1 diff --git a/libs/RVL_SDK/include/revolution/vi/vifuncs.h b/libs/RVL_SDK/include/revolution/vi/vifuncs.h index 164b4a14..e677a19f 100644 --- a/libs/RVL_SDK/include/revolution/vi/vifuncs.h +++ b/libs/RVL_SDK/include/revolution/vi/vifuncs.h @@ -2,20 +2,34 @@ #define REVOLUTION_VI_FUNCTIONS_H #include +#include #ifdef __cplusplus extern "C" { #endif -void VIWaitForRetrace(); -void VISetBlack(BOOL setBlack); -void VIFlush(); -u32 VIGetTvFormat(); +#define VIPadFrameBufferWidth(width) ((u16)(((u16)(width) + 15) & ~15)) + +void VIInit(); +void VIWaitForRetrace(); + +void VIConfigure(GXRenderModeObj *rm); + +void VIFlush(); +void VISetNextFrameBuffer(void *fb); + +void VISetBlack(BOOL setBlack); + +void VISetTrapFilter(BOOL setTrap); +void VIEnableDimming(BOOL enableDim); + +u32 VIGetRetraceCount(); +u32 VIGetDTVStatus(); + +u32 VIGetTvFormat(); #ifdef __cplusplus } #endif #endif // REVOLUTION_VI_FUNCTIONS_H - - diff --git a/libs/RVL_SDK/include/revolution/vi/vitypes.h b/libs/RVL_SDK/include/revolution/vi/vitypes.h index ae6565da..7df13205 100644 --- a/libs/RVL_SDK/include/revolution/vi/vitypes.h +++ b/libs/RVL_SDK/include/revolution/vi/vitypes.h @@ -5,7 +5,21 @@ extern "C" { #endif -typedef enum { +#define VI_DISPLAY_PIX_SZ (2) + +#define VI_MAX_WIDTH_NTSC (720) +#define VI_MAX_HEIGHT_NTSC (480) + +#define VI_MAX_WIDTH_PAL (720) +#define VI_MAX_HEIGHT_PAL (574) + +#define VI_MAX_WIDTH_MPAL (720) +#define VI_MAX_HEIGHT_MPAL (480) + +#define VI_MAX_WIDTH_EURGB60 VI_MAX_WIDTH_NTSC +#define VI_MAX_HEIGHT_EURGB60 VI_MAX_HEIGHT_NTSC + +enum { VI_NTSC = 0, VI_PAL, VI_MPAL, @@ -14,7 +28,7 @@ typedef enum { VI_EURGB60 }; -typedef enum { +enum { VI_INTERLACE = 0, VI_NON_INTERLACE, VI_PROGRESSIVE @@ -39,7 +53,6 @@ typedef enum { VI_TVMODE_MPAL_PROG = VI_TVMODE(VI_MPAL, VI_PROGRESSIVE), VI_TVMODE_DEBUG_INT = VI_TVMODE(VI_DEBUG, VI_INTERLACE), - VI_TVMODE_DEBUG_PAL_INT = VI_TVMODE(VI_DEBUG_PAL, VI_INTERLACE), VI_TVMODE_DEBUG_PAL_DS = VI_TVMODE(VI_DEBUG_PAL, VI_NON_INTERLACE) } VITVMode; @@ -54,5 +67,3 @@ typedef enum { #endif #endif // REVOLUTION_VI_TYPES_H - - diff --git a/src/homebutton/HBMFrameController.cpp b/src/homebutton/HBMFrameController.cpp new file mode 100644 index 00000000..239e7382 --- /dev/null +++ b/src/homebutton/HBMFrameController.cpp @@ -0,0 +1,76 @@ +#include "homebutton/HBMFrameController.h" +#pragma sym on +namespace homebutton { + void FrameController::init(int type, f32 maxFrame, f32 minFrame, f32 delta) { + mAnmType = type; + + mMaxFrame = maxFrame; + mMinFrame = minFrame; + + mDelta = delta; + + mState = ANIM_STATE_READY; + + mbBounceBack = false; + + initFrame(); + } + + void FrameController::initFrame() { + float frame; + if (mAnmType == ANIM_TYPE_BACKWARD) { + frame = mMaxFrame; + } + else { + frame = mMinFrame; + } + mFrame = frame; + } + + void FrameController::calc() { + if (mState == ANIM_STATE_PLAY) { + switch (mAnmType) { + // Animate normally; Once reaching the maximum frame, the animation stops. + case ANIM_TYPE_FORWARD: { + if ((mFrame += mDelta) >= getLastFrame()) { + mFrame = getLastFrame(); + mState = ANIM_STATE_READY; + } + break; + } + // Animate in reverse; Once reaching the minimum frame, the animation stops. + case ANIM_TYPE_BACKWARD: { + if ((mFrame -= mDelta) <= mMinFrame) { + mFrame = mMinFrame; + mState = ANIM_STATE_READY; + } + break; + } + // Animate forever; Once reaching the maximum frame, the animation repeats. + case ANIM_TYPE_LOOP: { + if ((mFrame += mDelta) >= mMaxFrame) { + mFrame -= (mMaxFrame - mMinFrame); + } + break; + } + // Animate in a bouncy way; Once reaching the maximum frame, it then animates forward. + // And once reaching the minimum frame, it animates forwards. Then repeat. + case ANIM_TYPE_BOUNCE: { + if (mbBounceBack == false) { + if ((mFrame += mDelta) >= getLastFrame()) { + mFrame = getLastFrame(); + mbBounceBack = true; + } + } + else { + if ((mFrame -= mDelta) <= mMinFrame) { + mFrame = mMinFrame; + mbBounceBack = false; + } + } + break; + } + } + } + } +} diff --git a/src/layout/iplLayout.cpp b/src/layout/iplLayout.cpp index 0f11f920..1fe4938d 100644 --- a/src/layout/iplLayout.cpp +++ b/src/layout/iplLayout.cpp @@ -40,7 +40,7 @@ namespace ipl { } void Animator::calc() { - setFlag(mStatus != ANIM_STATUS_NOTPLAY); + setFlag(mState != ANIM_STATE_READY); utility::FrameController::calc(); setFrame(); } @@ -52,14 +52,14 @@ namespace ipl { } void Animator::initAnmFrame() { - mStatus = ANIM_STATUS_STOP; + mState = ANIM_STATE_STOP; utility::FrameController::initFrame(); setFrame(); } void Animator::initAnmFrame(float frame) { mFrame = frame; - mStatus = ANIM_STATUS_STOP; + mState = ANIM_STATE_STOP; setFrame(); } @@ -171,7 +171,7 @@ namespace ipl { mLayout.Build(lytBuf, &mArc); utility::Graphics::calcOrthoCamera(); - mDrawInfo.SetViewMtx(*utility::Graphics::getUnk3C()); + mDrawInfo.SetViewMtx(utility::Graphics::getViewMtx()); nw4r::ut::Rect lytRect = mLayout.GetLayoutRect(); mDrawInfo.SetViewRect(lytRect); @@ -283,13 +283,13 @@ namespace ipl { anim = NULL; while (anim = (Animator*)nw4r::ut::List_GetNext(&mAnims, anim), anim != NULL) { anim->initFrame(); - anim->mStatus = ANIM_STATUS_PLAY; + anim->setState(ANIM_STATE_PLAY); } } else { anim = (Animator*)nw4r::ut::List_GetNth(&mAnims, (u16)animIdx); anim->initFrame(); - anim->mStatus = ANIM_STATUS_PLAY; + anim->setState(ANIM_STATE_PLAY); } } @@ -298,12 +298,12 @@ namespace ipl { if (animIdx == -1) { anim = NULL; while (anim = (Animator*)nw4r::ut::List_GetNext(&mAnims, anim), anim != NULL) { - anim->mMaxFrame = maxFrame; + anim->setMaxFrame(maxFrame); } } else { anim = (Animator*)nw4r::ut::List_GetNth(&mAnims, (u16)animIdx); - anim->mMaxFrame = maxFrame; + anim->setMaxFrame(maxFrame); } } @@ -312,12 +312,12 @@ namespace ipl { if (animIdx == -1) { anim = NULL; while (anim = (Animator*)nw4r::ut::List_GetNext(&mAnims, anim), anim != NULL) { - anim->mMinFrame = minFrame; + anim->setMinFrame(minFrame); } } else { anim = (Animator*)nw4r::ut::List_GetNth(&mAnims, (u16)animIdx); - anim->mMinFrame = minFrame; + anim->setMinFrame(minFrame); } } @@ -326,12 +326,12 @@ namespace ipl { if (animIdx == -1) { anim = NULL; while (anim = (Animator*)nw4r::ut::List_GetNext(&mAnims, anim), anim != NULL) { - anim->mAnmType = type; + anim->setAnimType(type); } } else { anim = (Animator*)nw4r::ut::List_GetNth(&mAnims, (u16)animIdx); - anim->mAnmType = type; + anim->setAnimType(type); } } @@ -342,13 +342,13 @@ namespace ipl { if (animIdx == -1) { anim = NULL; while (anim = (Animator*)nw4r::ut::List_GetNext(&mAnims, anim), anim != NULL) { - // The bitwise OR on a boolean was probably a typo (luckily for them it does nothing) - result |= anim->mStatus == ANIM_STATUS_PLAY; + // The bitwise OR on a boolean was probably a typo (luckily for them it does nothing different) + result |= anim->isPlaying(); } } else { anim = (Animator*)nw4r::ut::List_GetNth(&mAnims, (u16)animIdx); - result = anim->mStatus == ANIM_STATUS_PLAY; + result = anim->isPlaying(); } return result; diff --git a/src/system/iplFramework.cpp b/src/system/iplFramework.cpp new file mode 100644 index 00000000..40b25472 --- /dev/null +++ b/src/system/iplFramework.cpp @@ -0,0 +1,287 @@ +#include "system/iplFramework.h" + +#include + +namespace ipl { + #define DELTA_60 1.0f /* Delta for NTSC, MPAL and PAL60 */ + #define DELTA_50 1.2f /* Delta for PAL50 */ + + // NTSC Interlaced + static GXRenderModeObj sRMO_Ntsc_640x456IntDf = { + VI_TVMODE_NTSC_INT, + 640, + 456, + 456, + 25, + 12, + 670, + 456, + VI_XFBMODE_DF, + GX_FALSE, + GX_FALSE, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 7, 7, + 12, 12, 12, + 7, 7, + }; + + // NTSC Progressive + static GXRenderModeObj sRMO_Ntsc_640x456Prog = { + VI_TVMODE_NTSC_PROG, + 640, + 456, + 456, + 25, + 12, + 670, + 456, + VI_XFBMODE_SF, + GX_FALSE, + GX_FALSE, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 0, 0, + 21, 22, 21, + 0, 0, + }; + + // PAL50 Progressive + static GXRenderModeObj sRMO_Pal50_640x456IntDf = { + VI_TVMODE_PAL_INT, + 640, + 456, + 542, + 27, + 16, + 666, + 542, + VI_XFBMODE_DF, + GX_FALSE, + GX_FALSE, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 7, 7, + 12, 12, 12, + 7, 7, + }; + + // PAL60 Interlaced + static GXRenderModeObj sRMO_Pal60_640x456IntDf = { + VI_TVMODE_EURGB60_INT, + 640, + 456, + 456, + 25, + 12, + 670, + 456, + VI_XFBMODE_DF, + GX_FALSE, + GX_FALSE, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 7, 7, + 12, 12, 12, + 7, 7, + }; + + // PAL60 Progressive + static GXRenderModeObj sRMO_Pal60_640x456Prog = { + VI_TVMODE_EURGB60_PROG, + 640, + 456, + 456, + 25, + 12, + 670, + 456, + VI_XFBMODE_SF, + GX_FALSE, + GX_FALSE, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, + 0, 0, + 21, 22, 21, + 0, 0, + }; + + Framework::Framework(EGG::Heap* heap) { + mpRMode = NULL; + + VIInit(); + + init_vi(); + init_xfb(heap); + } + + inline void Framework::flip_xfb() { + mCurXfb = !mCurXfb; + } + + void Framework::beginFrame() { + flip_xfb(); + } + + void Framework::beginRender() { + GXInvalidateTexAll(); + } + + void Framework::endRender() { + GXColor clrColor = {0x00, 0x00, 0x00, 0x00}; + GXSetCopyClear(clrColor, 0xFFFFFF); + + GXSetZMode(GX_TRUE, GX_ALWAYS, GX_TRUE); + + GXSetAlphaUpdate(GX_TRUE); + GXSetColorUpdate(GX_TRUE); + + GXCopyDisp(mpXfb[mCurXfb], GX_TRUE); + + GXFlush(); + } + + void Framework::endFrame() { + GXDrawDone(); + + VISetNextFrameBuffer(mpXfb[mCurXfb]); + VIFlush(); + VIWaitForRetrace(); + } + + void Framework::resetRenderMode() { + reset_render_mode(); + + VIFlush(); { + GXSetDispCopySrc(0, 0, mpRMode->fbWidth, mpRMode->efbHeight); + f32 yScaleFactor = GXGetYScaleFactor(mpRMode->efbHeight, mpRMode->xfbHeight); + u32 height = GXSetDispCopyYScale(yScaleFactor); + GXSetDispCopyDst(mpRMode->fbWidth, height); + } + + // XFB[0] + flip_xfb(); + GXInvalidateTexAll(); + endRender(); + endFrame(); + + // XFB[1] + flip_xfb(); + GXInvalidateTexAll(); + endRender(); + endFrame(); + } + + void Framework::reset_render_mode() { + u32 wideScreen = SCGetAspectRatio(); + u32 progressive = SCGetProgressiveMode(); + u32 pal60 = SCGetEuRgb60Mode(); + + mWideScreen = wideScreen; + mDelta = DELTA_60; + + switch (VIGetTvFormat()) { + // NTSC Progressive and Interlaced + case VI_MPAL: + case VI_NTSC: { + if (VIGetDTVStatus() == TRUE && progressive == TRUE) { + mpRMode = &sRMO_Ntsc_640x456Prog; + } + else { + mpRMode = &sRMO_Ntsc_640x456IntDf; + } + if (wideScreen == TRUE) { + mpRMode->viWidth = 686; + } + else { + mpRMode->viWidth = 670; + } + mpRMode->viXOrigin = (VI_MAX_WIDTH_NTSC - mpRMode->viWidth) / 2; + break; + } + case VI_PAL: + case VI_EURGB60: { + // PAL60 Progressive + if (VIGetDTVStatus() == TRUE && progressive == TRUE) { + mpRMode = &sRMO_Pal60_640x456Prog; + if (wideScreen == TRUE) { + sRMO_Pal60_640x456Prog.viWidth = 686; + } + else { + sRMO_Pal60_640x456Prog.viWidth = 670; + } + mpRMode->viXOrigin = (VI_MAX_WIDTH_EURGB60 - mpRMode->viWidth) / 2; + } + // PAL60 Interlaced + else if (pal60 == TRUE) { + mpRMode = &sRMO_Pal60_640x456IntDf; + if (wideScreen == TRUE) { + sRMO_Pal60_640x456IntDf.viWidth = 686; + } + else { + sRMO_Pal60_640x456IntDf.viWidth = 670; + } + mpRMode->viXOrigin = (VI_MAX_WIDTH_EURGB60 - mpRMode->viWidth) / 2; + } + // PAL50 Interlaced + else { + mpRMode = &sRMO_Pal50_640x456IntDf; + if (wideScreen == TRUE) { + sRMO_Pal50_640x456IntDf.viWidth = 682; + } + else { + sRMO_Pal50_640x456IntDf.viWidth = 666; + } + mpRMode->viXOrigin = (VI_MAX_WIDTH_PAL - mpRMode->viWidth) / 2; + mDelta = DELTA_50; + } + break; + } + } + VIConfigure(mpRMode); + } + + void Framework::init_vi() { + VISetBlack(TRUE); + + reset_render_mode(); + + VISetTrapFilter(TRUE); + VISetTrapFilter(FALSE); + + // Screen burn in reduction + VIEnableDimming(FALSE); + VIEnableDimming((BOOL)SCGetScreenSaverMode()); + + VIFlush(); { + GXSetDispCopySrc(0, 0, mpRMode->fbWidth, mpRMode->efbHeight); + f32 yScaleFactor = GXGetYScaleFactor(mpRMode->efbHeight, mpRMode->xfbHeight); + u32 height = GXSetDispCopyYScale(yScaleFactor); + GXSetDispCopyDst(mpRMode->fbWidth, height); + } + + // Wait for VI to be ready + VIWaitForRetrace(); + VIWaitForRetrace(); + } + + void Framework::init_xfb(EGG::Heap* heap) { + u32 xfbSize = VIPadFrameBufferWidth(mpRMode->fbWidth) * mpRMode->xfbHeight * VI_DISPLAY_PIX_SZ; + + for (int i = 0; i < 2; i++) { + mpXfb[i] = new(heap, BUFFER_HEAP) u8[xfbSize]; + } + + mCurXfb = 0; + } +} diff --git a/src/utility/iplFrameController.cpp b/src/utility/iplFrameController.cpp index 1332e8d1..0c608261 100644 --- a/src/utility/iplFrameController.cpp +++ b/src/utility/iplFrameController.cpp @@ -1,3 +1,85 @@ +#include "system/iplSystem.h" #include "utility/iplFrameController.h" +namespace ipl { + namespace utility { + void FrameController::init(int type, f32 maxFrame, f32 minFrame, f32 speed) { + mAnmType = type; + mMaxFrame = maxFrame; + mMinFrame = minFrame; + + mSpeed = speed; + + mState = 0; + + mbBounceBack = false; + + initFrame(); + } + + void FrameController::initFrame() { + float frame; + if (mAnmType == ANIM_TYPE_BACKWARD) { + frame = mMaxFrame; + } + else { + frame = mMinFrame; + } + mFrame = frame; + } + + void FrameController::calc() { + f32 speed = mSpeed * System::getAnimDelta(); + if (mState == ANIM_STATE_PLAY) { + switch (mAnmType) { + // Animate normally; Once reaching the maximum frame, the animation stops. + case ANIM_TYPE_FORWARD: { + if ((mFrame += speed) >= mMaxFrame) { + mFrame = mMaxFrame; + mState = ANIM_STATE_READY; + } + break; + } + // Animate in reverse; Once reaching the minimum frame, the animation stops. + case ANIM_TYPE_BACKWARD: { + if ((mFrame -= speed) <= mMinFrame) { + mFrame = mMinFrame; + mState = ANIM_STATE_READY; + } + break; + } + // Animate forever; Once reaching the maximum frame, the animation repeats. + case ANIM_TYPE_LOOP: { + if ((mFrame += speed) >= mMaxFrame) { + while (mFrame >= mMaxFrame) { + mFrame -= (mMaxFrame - mMinFrame); + } + } + break; + } + // Animate in a bouncy way; Once reaching the maximum frame, it then animates forward. + // And once reaching the minimum frame, it animates forwards. Then repeat. + case ANIM_TYPE_BOUNCE: { + if (mbBounceBack == false) { + if ((mFrame += speed) >= mMaxFrame) { + mFrame = mMaxFrame; + mbBounceBack = true; + } + } + else { + if ((mFrame -= speed) <= mMinFrame) { + mFrame = mMinFrame; + mbBounceBack = false; + } + } + break; + } + } + } + else if (mState == ANIM_STATE_STOP) { + mState = ANIM_STATE_READY; + } + } + } +}