diff --git a/Makefile b/Makefile index 8ff570569..93747171b 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,7 @@ $(B_DIR)/lib/ultra/io/visetevent.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/io/visetmode.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/io/visetxscale.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/io/visetyscale.o: OPT_LVL := -O1 +$(B_DIR)/lib/ultra/io/viswapbuf.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/os/createmesgqueue.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/os/destroythread.o: OPT_LVL := -O1 $(B_DIR)/lib/ultra/os/jammesg.o: OPT_LVL := -O1 diff --git a/ld/libfiles.inc b/ld/libfiles.inc index b8af0b1a6..0edf2d463 100644 --- a/ld/libfiles.inc +++ b/ld/libfiles.inc @@ -108,7 +108,9 @@ build/ROMID/lib/ultra/io/visetxscale.o (section); \ build/ROMID/lib/ultra/io/visetyscale.o (section); \ build/ROMID/lib/lib_48f50.o (section); \ - build/ROMID/lib/lib_490b0.o (section); \ + build/ROMID/lib/ultra/io/viswapbuf.o (section); \ + build/ROMID/lib/ultra/io/sptaskyield.o (section); \ + build/ROMID/lib/lib_49120.o (section); \ build/ROMID/lib/ultra/os/timerintr.o (section); \ build/ROMID/lib/ultra/os/interrupt.o (section); \ build/ROMID/lib/ultra/io/vi.o (section); \ diff --git a/src/boot/entry.c b/src/boot/entry.c index 87914f60e..43e62f61b 100644 --- a/src/boot/entry.c +++ b/src/boot/entry.c @@ -22,7 +22,6 @@ #include "lib/lib_48150.h" #include "lib/lib_48cd0.h" #include "lib/lib_48f50.h" -#include "lib/lib_490b0.h" #include "types.h" GLOBAL_ASM( diff --git a/src/boot/init.c b/src/boot/init.c index a182e90b3..67256bd61 100644 --- a/src/boot/init.c +++ b/src/boot/init.c @@ -25,7 +25,6 @@ #include "lib/lib_48150.h" #include "lib/lib_48cd0.h" #include "lib/lib_48f50.h" -#include "lib/lib_490b0.h" #include "types.h" #if VERSION >= VERSION_NTSC_1_0 diff --git a/src/boot/sched.c b/src/boot/sched.c index 21048634f..771cf91a7 100644 --- a/src/boot/sched.c +++ b/src/boot/sched.c @@ -24,7 +24,6 @@ #include "lib/lib_48150.h" #include "lib/lib_48cd0.h" #include "lib/lib_48f50.h" -#include "lib/lib_490b0.h" #include "types.h" void func00001b10(u32 value) @@ -514,7 +513,7 @@ s32 __scTaskComplete(OSSched *sc, OSScTask *t) } func00001b40(t->framebuffer); - func000490b0(t->framebuffer); + osViSwapBuffer(t->framebuffer); } osSendMesg(t->msgQ, t->msg, OS_MESG_BLOCK); diff --git a/src/include/lib/lib_490b0.h b/src/include/lib/lib_490b0.h index 816df9228..004550f02 100644 --- a/src/include/lib/lib_490b0.h +++ b/src/include/lib/lib_490b0.h @@ -3,7 +3,7 @@ #include #include "types.h" -void func000490b0(void *framebuffer); +void osViSwapBuffer(void *framebuffer); u64 func00049120(void); #endif diff --git a/src/lib/audiomgr.c b/src/lib/audiomgr.c index 3aaed25d8..658b63d22 100644 --- a/src/lib/audiomgr.c +++ b/src/lib/audiomgr.c @@ -15,7 +15,6 @@ #include "lib/lib_2fba0.h" #include "lib/lib_2fc60.h" #include "lib/lib_30ce0.h" -#include "lib/lib_490b0.h" #include "lib/libc/ll.h" #include "types.h" diff --git a/src/lib/lib_490b0.c b/src/lib/lib_490b0.c index 9e415bdef..c80f44f6f 100644 --- a/src/lib/lib_490b0.c +++ b/src/lib/lib_490b0.c @@ -11,7 +11,7 @@ #include "types.h" GLOBAL_ASM( -glabel func000490b0 +glabel osViSwapBuffer /* 490b0: 27bdffe0 */ addiu $sp,$sp,-32 /* 490b4: afbf0014 */ sw $ra,0x14($sp) /* 490b8: 0c01256c */ jal __osDisableInt @@ -33,48 +33,3 @@ glabel func000490b0 /* 490f8: 03e00008 */ jr $ra /* 490fc: 00000000 */ nop ); - -void osSpTaskYield(void) -{ - __osSpSetStatus(SP_SET_YIELD); -} - -GLOBAL_ASM( -glabel func00049120 -/* 49120: 27bdffc8 */ addiu $sp,$sp,-56 -/* 49124: afbf001c */ sw $ra,0x1c($sp) -/* 49128: 0c01256c */ jal __osDisableInt -/* 4912c: afb00018 */ sw $s0,0x18($sp) -/* 49130: 0c012144 */ jal osGetCount -/* 49134: 00408025 */ or $s0,$v0,$zero -/* 49138: afa20034 */ sw $v0,0x34($sp) -/* 4913c: 3c0f800a */ lui $t7,%hi(var8009c788) -/* 49140: 8defc788 */ lw $t7,%lo(var8009c788)($t7) -/* 49144: 8fae0034 */ lw $t6,0x34($sp) -/* 49148: 3c08800a */ lui $t0,%hi(var8009c780) -/* 4914c: 3c09800a */ lui $t1,%hi(var8009c784) -/* 49150: 8d29c784 */ lw $t1,%lo(var8009c784)($t1) -/* 49154: 8d08c780 */ lw $t0,%lo(var8009c780)($t0) -/* 49158: 01cfc023 */ subu $t8,$t6,$t7 -/* 4915c: afb80030 */ sw $t8,0x30($sp) -/* 49160: 02002025 */ or $a0,$s0,$zero -/* 49164: afa9002c */ sw $t1,0x2c($sp) -/* 49168: 0c012588 */ jal __osRestoreInt -/* 4916c: afa80028 */ sw $t0,0x28($sp) -/* 49170: 8fb90030 */ lw $t9,0x30($sp) -/* 49174: 8fad002c */ lw $t5,0x2c($sp) -/* 49178: 8fbf001c */ lw $ra,0x1c($sp) -/* 4917c: 03205825 */ or $t3,$t9,$zero -/* 49180: 016d1821 */ addu $v1,$t3,$t5 -/* 49184: 8fac0028 */ lw $t4,0x28($sp) -/* 49188: 240a0000 */ addiu $t2,$zero,0x0 -/* 4918c: 006d082b */ sltu $at,$v1,$t5 -/* 49190: 002a1021 */ addu $v0,$at,$t2 -/* 49194: 8fb00018 */ lw $s0,0x18($sp) -/* 49198: 27bd0038 */ addiu $sp,$sp,0x38 -/* 4919c: 03e00008 */ jr $ra -/* 491a0: 004c1021 */ addu $v0,$v0,$t4 -/* 491a4: 00000000 */ nop -/* 491a8: 00000000 */ nop -/* 491ac: 00000000 */ nop -); diff --git a/src/lib/lib_49120.c b/src/lib/lib_49120.c new file mode 100644 index 000000000..d8a48ceb8 --- /dev/null +++ b/src/lib/lib_49120.c @@ -0,0 +1,51 @@ +#include +#include "constants.h" +#include "game/data/data_000000.h" +#include "game/data/data_0083d0.h" +#include "game/data/data_00e460.h" +#include "game/data/data_0160b0.h" +#include "game/data/data_01a3a0.h" +#include "game/data/data_020df0.h" +#include "game/data/data_02da90.h" +#include "gvars/gvars.h" +#include "types.h" + +GLOBAL_ASM( +glabel func00049120 +/* 49120: 27bdffc8 */ addiu $sp,$sp,-56 +/* 49124: afbf001c */ sw $ra,0x1c($sp) +/* 49128: 0c01256c */ jal __osDisableInt +/* 4912c: afb00018 */ sw $s0,0x18($sp) +/* 49130: 0c012144 */ jal osGetCount +/* 49134: 00408025 */ or $s0,$v0,$zero +/* 49138: afa20034 */ sw $v0,0x34($sp) +/* 4913c: 3c0f800a */ lui $t7,%hi(var8009c788) +/* 49140: 8defc788 */ lw $t7,%lo(var8009c788)($t7) +/* 49144: 8fae0034 */ lw $t6,0x34($sp) +/* 49148: 3c08800a */ lui $t0,%hi(var8009c780) +/* 4914c: 3c09800a */ lui $t1,%hi(var8009c784) +/* 49150: 8d29c784 */ lw $t1,%lo(var8009c784)($t1) +/* 49154: 8d08c780 */ lw $t0,%lo(var8009c780)($t0) +/* 49158: 01cfc023 */ subu $t8,$t6,$t7 +/* 4915c: afb80030 */ sw $t8,0x30($sp) +/* 49160: 02002025 */ or $a0,$s0,$zero +/* 49164: afa9002c */ sw $t1,0x2c($sp) +/* 49168: 0c012588 */ jal __osRestoreInt +/* 4916c: afa80028 */ sw $t0,0x28($sp) +/* 49170: 8fb90030 */ lw $t9,0x30($sp) +/* 49174: 8fad002c */ lw $t5,0x2c($sp) +/* 49178: 8fbf001c */ lw $ra,0x1c($sp) +/* 4917c: 03205825 */ or $t3,$t9,$zero +/* 49180: 016d1821 */ addu $v1,$t3,$t5 +/* 49184: 8fac0028 */ lw $t4,0x28($sp) +/* 49188: 240a0000 */ addiu $t2,$zero,0x0 +/* 4918c: 006d082b */ sltu $at,$v1,$t5 +/* 49190: 002a1021 */ addu $v0,$at,$t2 +/* 49194: 8fb00018 */ lw $s0,0x18($sp) +/* 49198: 27bd0038 */ addiu $sp,$sp,0x38 +/* 4919c: 03e00008 */ jr $ra +/* 491a0: 004c1021 */ addu $v0,$v0,$t4 +/* 491a4: 00000000 */ nop +/* 491a8: 00000000 */ nop +/* 491ac: 00000000 */ nop +); diff --git a/src/lib/ultra/io/sptaskyield.c b/src/lib/ultra/io/sptaskyield.c new file mode 100644 index 000000000..cec70651a --- /dev/null +++ b/src/lib/ultra/io/sptaskyield.c @@ -0,0 +1,6 @@ +#include + +void osSpTaskYield(void) +{ + __osSpSetStatus(SP_SET_YIELD); +} diff --git a/src/lib/ultra/io/viswapbuf.c b/src/lib/ultra/io/viswapbuf.c new file mode 100644 index 000000000..0afebf064 --- /dev/null +++ b/src/lib/ultra/io/viswapbuf.c @@ -0,0 +1,12 @@ +#include +#include "game/data/data_000000.h" + +void osViSwapBuffer(void *frameBufPtr) +{ + u32 saveMask = __osDisableInt(); + + __osViNext->framep = frameBufPtr; + __osViNext->state |= VI_STATE_10; + + __osRestoreInt(saveMask); +}