diff --git a/asm/Kyoto/Basics/CStopwatch.s b/asm/Kyoto/Basics/CStopwatch.s index 031f5b3c..808c5194 100644 --- a/asm/Kyoto/Basics/CStopwatch.s +++ b/asm/Kyoto/Basics/CStopwatch.s @@ -9,18 +9,15 @@ lbl_ctor: .section .sbss, "wa" .balign 8 -.global lbl_805A9238 -lbl_805A9238: - .skip 0x4 -.global lbl_805A923C -lbl_805A923C: - .skip 0x4 +.global mGlobalTimer__10CStopwatch +mGlobalTimer__10CStopwatch: + .skip 0x8 .section .text, "ax" .global GetGlobalTimerObj__10CStopwatchFv GetGlobalTimerObj__10CStopwatchFv: -/* 802D6264 002D31C4 38 6D A6 78 */ addi r3, r13, lbl_805A9238@sda21 +/* 802D6264 002D31C4 38 6D A6 78 */ addi r3, r13, mGlobalTimer__10CStopwatch@sda21 /* 802D6268 002D31C8 4E 80 00 20 */ blr .global Wait__10CStopwatchFf @@ -63,9 +60,9 @@ InitGlobalTimer__10CStopwatchFv: /* 802D62E4 002D3244 48 00 04 39 */ bl Initialize__Q210CStopwatch7CSWDataFv lbl_802D62E8: /* 802D62E8 002D3248 48 0A F0 C1 */ bl OSGetTime -/* 802D62EC 002D324C 90 6D A6 78 */ stw r3, lbl_805A9238@sda21(r13) +/* 802D62EC 002D324C 90 6D A6 78 */ stw r3, mGlobalTimer__10CStopwatch@sda21(r13) /* 802D62F0 002D3250 38 60 00 01 */ li r3, 1 -/* 802D62F4 002D3254 90 8D A6 7C */ stw r4, lbl_805A923C@sda21(r13) +/* 802D62F4 002D3254 90 8D A6 7C */ stw r4, mGlobalTimer__10CStopwatch+4@sda21(r13) /* 802D62F8 002D3258 80 01 00 14 */ lwz r0, 0x14(r1) /* 802D62FC 002D325C 7C 08 03 A6 */ mtlr r0 /* 802D6300 002D3260 38 21 00 10 */ addi r1, r1, 0x10 @@ -86,8 +83,8 @@ __sinit_CStopwatch_cpp: /* 802D6330 002D3290 90 03 00 08 */ stw r0, 8(r3) /* 802D6334 002D3294 D0 03 00 10 */ stfs f0, 0x10(r3) /* 802D6338 002D3298 48 0A F0 71 */ bl OSGetTime -/* 802D633C 002D329C 90 8D A6 7C */ stw r4, lbl_805A923C@sda21(r13) -/* 802D6340 002D32A0 90 6D A6 78 */ stw r3, lbl_805A9238@sda21(r13) +/* 802D633C 002D329C 90 8D A6 7C */ stw r4, mGlobalTimer__10CStopwatch+4@sda21(r13) +/* 802D6340 002D32A0 90 6D A6 78 */ stw r3, mGlobalTimer__10CStopwatch@sda21(r13) /* 802D6344 002D32A4 80 01 00 14 */ lwz r0, 0x14(r1) /* 802D6348 002D32A8 7C 08 03 A6 */ mtlr r0 /* 802D634C 002D32AC 38 21 00 10 */ addi r1, r1, 0x10 @@ -104,6 +101,5 @@ lbl_805AE278: .global lbl_805AE280 lbl_805AE280: # ROM: 0x3FAB20 - .4byte 0 - .4byte 0 + .float 0.0 diff --git a/asm/Kyoto/Particles/CParticleElectric.s b/asm/Kyoto/Particles/CParticleElectric.s index 8d8f9fb2..1c043116 100644 --- a/asm/Kyoto/Particles/CParticleElectric.s +++ b/asm/Kyoto/Particles/CParticleElectric.s @@ -2337,8 +2337,8 @@ Render__17CParticleElectricFv: /* 80360854 0035D7B4 93 81 00 10 */ stw r28, 0x10(r1) /* 80360858 0035D7B8 7C 7E 1B 78 */ mr r30, r3 /* 8036085C 0035D7BC 48 02 4B 4D */ bl OSGetTime -/* 80360860 0035D7C0 80 AD A6 7C */ lwz r5, lbl_805A923C@sda21(r13) -/* 80360864 0035D7C4 80 0D A6 78 */ lwz r0, lbl_805A9238@sda21(r13) +/* 80360860 0035D7C0 80 AD A6 7C */ lwz r5, mGlobalTimer__10CStopwatch+4@sda21(r13) +/* 80360864 0035D7C4 80 0D A6 78 */ lwz r0, mGlobalTimer__10CStopwatch@sda21(r13) /* 80360868 0035D7C8 7C 85 20 10 */ subfc r4, r5, r4 /* 8036086C 0035D7CC 7C 60 19 10 */ subfe r3, r0, r3 /* 80360870 0035D7D0 48 02 96 F5 */ bl __cvt_sll_flt @@ -2410,8 +2410,8 @@ lbl_80360950: /* 80360958 0035D8B8 41 80 FF D4 */ blt lbl_8036092C lbl_8036095C: /* 8036095C 0035D8BC 48 02 4A 4D */ bl OSGetTime -/* 80360960 0035D8C0 80 AD A6 7C */ lwz r5, lbl_805A923C@sda21(r13) -/* 80360964 0035D8C4 80 0D A6 78 */ lwz r0, lbl_805A9238@sda21(r13) +/* 80360960 0035D8C0 80 AD A6 7C */ lwz r5, mGlobalTimer__10CStopwatch+4@sda21(r13) +/* 80360964 0035D8C4 80 0D A6 78 */ lwz r0, mGlobalTimer__10CStopwatch@sda21(r13) /* 80360968 0035D8C8 7C 85 20 10 */ subfc r4, r5, r4 /* 8036096C 0035D8CC 7C 60 19 10 */ subfe r3, r0, r3 /* 80360970 0035D8D0 48 02 95 F5 */ bl __cvt_sll_flt diff --git a/asm/Kyoto/Particles/CParticleSwoosh.s b/asm/Kyoto/Particles/CParticleSwoosh.s index 25fc227c..5ea1ef6b 100644 --- a/asm/Kyoto/Particles/CParticleSwoosh.s +++ b/asm/Kyoto/Particles/CParticleSwoosh.s @@ -4985,10 +4985,10 @@ lbl_8032EDC8: /* 8032EF44 0032BEA4 54 00 DF FF */ rlwinm. r0, r0, 0x1b, 0x1f, 0x1f /* 8032EF48 0032BEA8 41 82 00 54 */ beq lbl_8032EF9C /* 8032EF4C 0032BEAC 48 05 64 5D */ bl OSGetTime -/* 8032EF50 0032BEB0 80 ED A6 7C */ lwz r7, lbl_805A923C@sda21(r13) +/* 8032EF50 0032BEB0 80 ED A6 7C */ lwz r7, mGlobalTimer__10CStopwatch+4@sda21(r13) /* 8032EF54 0032BEB4 3C A0 80 5A */ lis r5, mData__10CStopwatch@ha /* 8032EF58 0032BEB8 38 C5 FD 30 */ addi r6, r5, mData__10CStopwatch@l -/* 8032EF5C 0032BEBC 80 0D A6 78 */ lwz r0, lbl_805A9238@sda21(r13) +/* 8032EF5C 0032BEBC 80 0D A6 78 */ lwz r0, mGlobalTimer__10CStopwatch@sda21(r13) /* 8032EF60 0032BEC0 7C 87 20 10 */ subfc r4, r7, r4 /* 8032EF64 0032BEC4 80 A6 00 08 */ lwz r5, 8(r6) /* 8032EF68 0032BEC8 80 C6 00 0C */ lwz r6, 0xc(r6) diff --git a/include/Kyoto/Basics/CStopwatch.hpp b/include/Kyoto/Basics/CStopwatch.hpp index 1d1d280d..f5a41605 100644 --- a/include/Kyoto/Basics/CStopwatch.hpp +++ b/include/Kyoto/Basics/CStopwatch.hpp @@ -9,6 +9,11 @@ class CStopwatch { public: class CSWData { public: + CSWData() + : x0_timerFreq(0) + , x8_timerFreqO1M(0) + , x10_timerPeriod(0.f) {} + bool Initialize(); void Wait(f32) const; @@ -24,8 +29,8 @@ public: }; CStopwatch() : x0_startTime(mData.GetCPUCycles()) {} - // static inline void InitGlobalTimer() {} - // static inline CStopwatch& GetGlobalTimerObj() { return mGlobalTimer; } + static bool InitGlobalTimer(); + static CStopwatch& GetGlobalTimerObj(); inline void Reset() { if (mData.GetTimerFreq() == 0) { mData.Initialize(); diff --git a/obj_files.mk b/obj_files.mk index b3e08440..1b359ac1 100644 --- a/obj_files.mk +++ b/obj_files.mk @@ -419,7 +419,7 @@ COLLISION :=\ KYOTO_1 :=\ $(BUILD_DIR)/asm/Kyoto/Basics/CBasics.o\ - $(BUILD_DIR)/asm/Kyoto/Basics/CStopwatch.o\ + $(BUILD_DIR)/src/Kyoto/Basics/CStopwatch.o\ $(BUILD_DIR)/asm/Kyoto/Basics/CBasicsDolphin.o\ $(BUILD_DIR)/asm/Kyoto/Basics/CCallStackDolphin.o\ $(BUILD_DIR)/asm/Kyoto/Basics/COsContextDolphin.o\ diff --git a/src/Kyoto/Basics/CStopwatch.cpp b/src/Kyoto/Basics/CStopwatch.cpp new file mode 100644 index 00000000..61d640e1 --- /dev/null +++ b/src/Kyoto/Basics/CStopwatch.cpp @@ -0,0 +1,23 @@ +#include +#include + +CStopwatch::CSWData CStopwatch::mData; +CStopwatch CStopwatch::mGlobalTimer; + + +bool CStopwatch::InitGlobalTimer() { + mGlobalTimer.Reset(); + return true; +} + +void CStopwatch::Wait(float wait) { + if (fabs(wait) < 0.0010000000474974512) { + mData.Wait(0.f); + } else { + mData.Wait(wait); + } +} + +CStopwatch& CStopwatch::GetGlobalTimerObj() { + return mGlobalTimer; +}