From 092d200dd502c1de1f1386fbd39d63981cca899c Mon Sep 17 00:00:00 2001 From: Mittenshugg Date: Fri, 31 Jul 2020 20:26:37 -0500 Subject: [PATCH] c_src: osGetTime --- Makefile | 1 + .../unknown_0D3020/osViSwapBuffer.s | 22 ------------------- lib/src/unknown_0D29F0.c | 20 ++++++++++++++++- 3 files changed, 20 insertions(+), 23 deletions(-) delete mode 100644 lib/asm/non_matchings/unknown_0D3020/osViSwapBuffer.s diff --git a/Makefile b/Makefile index 414075d8..b23aa45c 100755 --- a/Makefile +++ b/Makefile @@ -172,6 +172,7 @@ ALL_ASSETS_BUILT := $(ANIMATIONS_BUILT) $(AUDIO_BUILT) $(BILLBOARDS_BUILT) $(BIN $(BUILD_DIR)/lib/%.o: OPT_FLAGS := -O2 $(BUILD_DIR)/lib/%.o: MIPSISET := -mips2 +$(BUILD_DIR)/lib/src/unknown_0D29F0.o: OPT_FLAGS := -O1 $(BUILD_DIR)/lib/src/osSetTimer.o: OPT_FLAGS := -O1 $(BUILD_DIR)/lib/src/osTimer.o: OPT_FLAGS := -O1 $(BUILD_DIR)/lib/src/osViBlack.o: OPT_FLAGS := -O1 diff --git a/lib/asm/non_matchings/unknown_0D3020/osViSwapBuffer.s b/lib/asm/non_matchings/unknown_0D3020/osViSwapBuffer.s deleted file mode 100644 index 3b6db105..00000000 --- a/lib/asm/non_matchings/unknown_0D3020/osViSwapBuffer.s +++ /dev/null @@ -1,22 +0,0 @@ -glabel osViSwapBuffer -/* 0D3020 800D2420 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0D3024 800D2424 AFBF0014 */ sw $ra, 0x14($sp) -/* 0D3028 800D2428 0C034958 */ jal __osDisableInt -/* 0D302C 800D242C AFA40020 */ sw $a0, 0x20($sp) -/* 0D3030 800D2430 3C0F800E */ lui $t7, %hi(D_800E4874) # $t7, 0x800e -/* 0D3034 800D2434 8DEF4874 */ lw $t7, %lo(D_800E4874)($t7) -/* 0D3038 800D2438 8FAE0020 */ lw $t6, 0x20($sp) -/* 0D303C 800D243C AFA2001C */ sw $v0, 0x1c($sp) -/* 0D3040 800D2440 3C18800E */ lui $t8, %hi(D_800E4874) # $t8, 0x800e -/* 0D3044 800D2444 ADEE0004 */ sw $t6, 4($t7) -/* 0D3048 800D2448 8F184874 */ lw $t8, %lo(D_800E4874)($t8) -/* 0D304C 800D244C 97190000 */ lhu $t9, ($t8) -/* 0D3050 800D2450 37280010 */ ori $t0, $t9, 0x10 -/* 0D3054 800D2454 A7080000 */ sh $t0, ($t8) -/* 0D3058 800D2458 0C034960 */ jal __osRestoreInt -/* 0D305C 800D245C 8FA4001C */ lw $a0, 0x1c($sp) -/* 0D3060 800D2460 8FBF0014 */ lw $ra, 0x14($sp) -/* 0D3064 800D2464 27BD0020 */ addiu $sp, $sp, 0x20 -/* 0D3068 800D2468 03E00008 */ jr $ra -/* 0D306C 800D246C 00000000 */ nop - diff --git a/lib/src/unknown_0D29F0.c b/lib/src/unknown_0D29F0.c index 0b356a7e..e4e8aa06 100644 --- a/lib/src/unknown_0D29F0.c +++ b/lib/src/unknown_0D29F0.c @@ -3,6 +3,10 @@ #include "types.h" #include "macros.h" +#include "libultra_internal.h" + +extern OSTime D_8012D220;//__osCurrentTime +extern u32 D_8012D228; //__osBaseCounter GLOBAL_ASM("lib/asm/non_matchings/unknown_0D29F0/func_800D1DF0.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D29F0/func_800D1E70.s") @@ -10,4 +14,18 @@ GLOBAL_ASM("lib/asm/non_matchings/unknown_0D29F0/func_800D1EB0.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D29F0/_VirtualToPhysicalTask.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D29F0/osSpTaskLoad.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0D29F0/osSpTaskStartGo.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0D29F0/osGetTime.s") +//GLOBAL_ASM("lib/asm/non_matchings/unknown_0D29F0/osGetTime.s") + +OSTime osGetTime() +{ + u32 tmptime; + u32 elapseCount; + OSTime currentCount; + register u32 saveMask; + saveMask = __osDisableInt(); + tmptime = osGetCount(); + elapseCount = tmptime - D_8012D228; + currentCount = D_8012D220; + __osRestoreInt(saveMask); + return currentCount + elapseCount; +}