From e5be999d0622b2ba9df5ca8ae1bf949496a0b2dd Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 26 Jan 2021 22:54:56 +1000 Subject: [PATCH] Decompile __osDequeueThread --- Makefile | 1 + src/lib/ultra/os/thread.c | 39 +++++++++++++++++---------------------- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 22bfc4877..29a7ab719 100644 --- a/Makefile +++ b/Makefile @@ -75,6 +75,7 @@ $(B_DIR)/lib/ultra/io/vigetnextframebuf.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/io/visetevent.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/os/destroythread.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/os/resetglobalintmask.o: OPT_LVL := -O1 +$(B_DIR)/lib/ultra/os/thread.o: OPT_LVL := -O1 CFLAGS = -DVERSION=$(VERSION) \ -DNTSC=$(NTSC) \ diff --git a/src/lib/ultra/os/thread.c b/src/lib/ultra/os/thread.c index 372583a53..a161f5a46 100644 --- a/src/lib/ultra/os/thread.c +++ b/src/lib/ultra/os/thread.c @@ -1,24 +1,19 @@ #include -GLOBAL_ASM( -glabel __osDequeueThread -/* 4a210: 00803025 */ or $a2,$a0,$zero -/* 4a214: 8cc70000 */ lw $a3,0x0($a2) -/* 4a218: 27bdfff8 */ addiu $sp,$sp,-8 -/* 4a21c: 10e0000a */ beqz $a3,.L0004a248 -/* 4a220: 00000000 */ nop -.L0004a224: -/* 4a224: 14e50004 */ bne $a3,$a1,.L0004a238 -/* 4a228: 00000000 */ nop -/* 4a22c: 8cae0000 */ lw $t6,0x0($a1) -/* 4a230: 10000005 */ b .L0004a248 -/* 4a234: acce0000 */ sw $t6,0x0($a2) -.L0004a238: -/* 4a238: 00e03025 */ or $a2,$a3,$zero -/* 4a23c: 8cc70000 */ lw $a3,0x0($a2) -/* 4a240: 14e0fff8 */ bnez $a3,.L0004a224 -/* 4a244: 00000000 */ nop -.L0004a248: -/* 4a248: 03e00008 */ jr $ra -/* 4a24c: 27bd0008 */ addiu $sp,$sp,0x8 -); +void __osDequeueThread(OSThread **queue, OSThread *t) +{ + register OSThread *pred; + register OSThread *succ; + pred = (OSThread *)queue; //this is actually legit.. + succ = pred->next; + + while (succ != NULL) { + if (succ == t) { + pred->next = t->next; + return; + } + + pred = succ; + succ = pred->next; + } +}