1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2024-11-29 03:34:07 +00:00

Decompile KaleidoScope_Draw (#189)

* Decompile KaleidoScope_Draw

* Naming

* Simplify (casts)

* Cleanup (comments)

* Delete the .s file
This commit is contained in:
Robin Allen 2020-06-07 18:02:27 +01:00 committed by GitHub
parent 93e8dbcc9e
commit 09d8cc529a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 160 deletions

View file

@ -1,156 +0,0 @@
glabel KaleidoScope_Draw
/* 12A98 808262B8 27BDFF98 */ addiu $sp, $sp, 0xFF98 ## $sp = FFFFFF98
/* 12A9C 808262BC AFBF001C */ sw $ra, 0x001C($sp)
/* 12AA0 808262C0 AFB10018 */ sw $s1, 0x0018($sp)
/* 12AA4 808262C4 AFB00014 */ sw $s0, 0x0014($sp)
/* 12AA8 808262C8 8C850000 */ lw $a1, 0x0000($a0) ## 00000000
/* 12AAC 808262CC 00808825 */ or $s1, $a0, $zero ## $s1 = 00000000
/* 12AB0 808262D0 3C068083 */ lui $a2, %hi(D_8082FD78) ## $a2 = 80830000
/* 12AB4 808262D4 24C6FD78 */ addiu $a2, $a2, %lo(D_8082FD78) ## $a2 = 8082FD78
/* 12AB8 808262D8 27A40048 */ addiu $a0, $sp, 0x0048 ## $a0 = FFFFFFE0
/* 12ABC 808262DC 24070C74 */ addiu $a3, $zero, 0x0C74 ## $a3 = 00000C74
/* 12AC0 808262E0 0C031AB1 */ jal Graph_OpenDisps
/* 12AC4 808262E4 AFA50058 */ sw $a1, 0x0058($sp)
/* 12AC8 808262E8 26220014 */ addiu $v0, $s1, 0x0014 ## $v0 = 00000014
/* 12ACC 808262EC 804E0014 */ lb $t6, 0x0014($v0) ## 00000028
/* 12AD0 808262F0 3C010001 */ lui $at, 0x0001 ## $at = 00010000
/* 12AD4 808262F4 34210760 */ ori $at, $at, 0x0760 ## $at = 00010760
/* 12AD8 808262F8 8FA80058 */ lw $t0, 0x0058($sp)
/* 12ADC 808262FC 02218021 */ addu $s0, $s1, $at
/* 12AE0 80826300 A60E0214 */ sh $t6, 0x0214($s0) ## 00000214
/* 12AE4 80826304 804F0015 */ lb $t7, 0x0015($v0) ## 00000029
/* 12AE8 80826308 3C19DB06 */ lui $t9, 0xDB06 ## $t9 = DB060000
/* 12AEC 8082630C 37390008 */ ori $t9, $t9, 0x0008 ## $t9 = DB060008
/* 12AF0 80826310 A60F0216 */ sh $t7, 0x0216($s0) ## 00000216
/* 12AF4 80826314 8D0202C0 */ lw $v0, 0x02C0($t0) ## 000002C0
/* 12AF8 80826318 3C090001 */ lui $t1, 0x0001 ## $t1 = 00010000
/* 12AFC 8082631C 01314821 */ addu $t1, $t1, $s1
/* 12B00 80826320 24580008 */ addiu $t8, $v0, 0x0008 ## $t8 = 0000001C
/* 12B04 80826324 AD1802C0 */ sw $t8, 0x02C0($t0) ## 000002C0
/* 12B08 80826328 AC590000 */ sw $t9, 0x0000($v0) ## 00000014
/* 12B0C 8082632C 8D290620 */ lw $t1, 0x0620($t1) ## 00010620
/* 12B10 80826330 3C0BDB06 */ lui $t3, 0xDB06 ## $t3 = DB060000
/* 12B14 80826334 356B001C */ ori $t3, $t3, 0x001C ## $t3 = DB06001C
/* 12B18 80826338 AC490004 */ sw $t1, 0x0004($v0) ## 00000018
/* 12B1C 8082633C 8D0202C0 */ lw $v0, 0x02C0($t0) ## 000002C0
/* 12B20 80826340 3C0EDB06 */ lui $t6, 0xDB06 ## $t6 = DB060000
/* 12B24 80826344 35CE0020 */ ori $t6, $t6, 0x0020 ## $t6 = DB060020
/* 12B28 80826348 244A0008 */ addiu $t2, $v0, 0x0008 ## $t2 = 0000001C
/* 12B2C 8082634C AD0A02C0 */ sw $t2, 0x02C0($t0) ## 000002C0
/* 12B30 80826350 AC4B0000 */ sw $t3, 0x0000($v0) ## 00000014
/* 12B34 80826354 8E0C013C */ lw $t4, 0x013C($s0) ## 0000013C
/* 12B38 80826358 3C19DB06 */ lui $t9, 0xDB06 ## $t9 = DB060000
/* 12B3C 8082635C 37390024 */ ori $t9, $t9, 0x0024 ## $t9 = DB060024
/* 12B40 80826360 AC4C0004 */ sw $t4, 0x0004($v0) ## 00000018
/* 12B44 80826364 8D0202C0 */ lw $v0, 0x02C0($t0) ## 000002C0
/* 12B48 80826368 3C0BDB06 */ lui $t3, 0xDB06 ## $t3 = DB060000
/* 12B4C 8082636C 356B0028 */ ori $t3, $t3, 0x0028 ## $t3 = DB060028
/* 12B50 80826370 244D0008 */ addiu $t5, $v0, 0x0008 ## $t5 = 0000001C
/* 12B54 80826374 AD0D02C0 */ sw $t5, 0x02C0($t0) ## 000002C0
/* 12B58 80826378 AC4E0000 */ sw $t6, 0x0000($v0) ## 00000014
/* 12B5C 8082637C 8E0F0128 */ lw $t7, 0x0128($s0) ## 00000128
/* 12B60 80826380 3C0EDB06 */ lui $t6, 0xDB06 ## $t6 = DB060000
/* 12B64 80826384 35CE0030 */ ori $t6, $t6, 0x0030 ## $t6 = DB060030
/* 12B68 80826388 AC4F0004 */ sw $t7, 0x0004($v0) ## 00000018
/* 12B6C 8082638C 8D0202C0 */ lw $v0, 0x02C0($t0) ## 000002C0
/* 12B70 80826390 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000
/* 12B74 80826394 24580008 */ addiu $t8, $v0, 0x0008 ## $t8 = 0000001C
/* 12B78 80826398 AD1802C0 */ sw $t8, 0x02C0($t0) ## 000002C0
/* 12B7C 8082639C AC590000 */ sw $t9, 0x0000($v0) ## 00000014
/* 12B80 808263A0 8E09012C */ lw $t1, 0x012C($s0) ## 0000012C
/* 12B84 808263A4 3C19DB06 */ lui $t9, 0xDB06 ## $t9 = DB060000
/* 12B88 808263A8 37390034 */ ori $t9, $t9, 0x0034 ## $t9 = DB060034
/* 12B8C 808263AC AC490004 */ sw $t1, 0x0004($v0) ## 00000018
/* 12B90 808263B0 8D0202C0 */ lw $v0, 0x02C0($t0) ## 000002C0
/* 12B94 808263B4 244A0008 */ addiu $t2, $v0, 0x0008 ## $t2 = 0000001C
/* 12B98 808263B8 AD0A02C0 */ sw $t2, 0x02C0($t0) ## 000002C0
/* 12B9C 808263BC AC4B0000 */ sw $t3, 0x0000($v0) ## 00000014
/* 12BA0 808263C0 8E0C0138 */ lw $t4, 0x0138($s0) ## 00000138
/* 12BA4 808263C4 AC4C0004 */ sw $t4, 0x0004($v0) ## 00000018
/* 12BA8 808263C8 8D0202C0 */ lw $v0, 0x02C0($t0) ## 000002C0
/* 12BAC 808263CC 244D0008 */ addiu $t5, $v0, 0x0008 ## $t5 = 0000001C
/* 12BB0 808263D0 AD0D02C0 */ sw $t5, 0x02C0($t0) ## 000002C0
/* 12BB4 808263D4 AC4E0000 */ sw $t6, 0x0000($v0) ## 00000014
/* 12BB8 808263D8 8E0F0130 */ lw $t7, 0x0130($s0) ## 00000130
/* 12BBC 808263DC AC4F0004 */ sw $t7, 0x0004($v0) ## 00000018
/* 12BC0 808263E0 8D0202C0 */ lw $v0, 0x02C0($t0) ## 000002C0
/* 12BC4 808263E4 24580008 */ addiu $t8, $v0, 0x0008 ## $t8 = 0000001C
/* 12BC8 808263E8 AD1802C0 */ sw $t8, 0x02C0($t0) ## 000002C0
/* 12BCC 808263EC AC590000 */ sw $t9, 0x0000($v0) ## 00000014
/* 12BD0 808263F0 8E090134 */ lw $t1, 0x0134($s0) ## 00000134
/* 12BD4 808263F4 AC490004 */ sw $t1, 0x0004($v0) ## 00000018
/* 12BD8 808263F8 960A01D6 */ lhu $t2, 0x01D6($s0) ## 000001D6
/* 12BDC 808263FC 55400029 */ bnel $t2, $zero, .L808264A4
/* 12BE0 80826400 960201D4 */ lhu $v0, 0x01D4($s0) ## 000001D4
/* 12BE4 80826404 8E0501D8 */ lw $a1, 0x01D8($s0) ## 000001D8
/* 12BE8 80826408 8E0601DC */ lw $a2, 0x01DC($s0) ## 000001DC
/* 12BEC 8082640C 8E0701E0 */ lw $a3, 0x01E0($s0) ## 000001E0
/* 12BF0 80826410 0C208E65 */ jal func_80823994
/* 12BF4 80826414 AFA80058 */ sw $t0, 0x0058($sp)
/* 12BF8 80826418 0C02526A */ jal func_800949A8
/* 12BFC 8082641C 8E240000 */ lw $a0, 0x0000($s1) ## 00000000
/* 12C00 80826420 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000
/* 12C04 80826424 0C209027 */ jal func_8082409C
/* 12C08 80826428 8E250000 */ lw $a1, 0x0000($s1) ## 00000000
/* 12C0C 8082642C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000
/* 12C10 80826430 0C20810D */ jal func_80820434
/* 12C14 80826434 8E250000 */ lw $a1, 0x0000($s1) ## 00000000
/* 12C18 80826438 0C02526A */ jal func_800949A8
/* 12C1C 8082643C 8E240000 */ lw $a0, 0x0000($s1) ## 00000000
/* 12C20 80826440 8FA80058 */ lw $t0, 0x0058($sp)
/* 12C24 80826444 44800000 */ mtc1 $zero, $f0 ## $f0 = 0.00
/* 12C28 80826448 3C0CFC30 */ lui $t4, 0xFC30 ## $t4 = FC300000
/* 12C2C 8082644C 8D0202C0 */ lw $v0, 0x02C0($t0) ## 000002C0
/* 12C30 80826450 3C0D552E */ lui $t5, 0x552E ## $t5 = 552E0000
/* 12C34 80826454 35ADFF7F */ ori $t5, $t5, 0xFF7F ## $t5 = 552EFF7F
/* 12C38 80826458 244B0008 */ addiu $t3, $v0, 0x0008 ## $t3 = 00000008
/* 12C3C 8082645C 358C9661 */ ori $t4, $t4, 0x9661 ## $t4 = FC309661
/* 12C40 80826460 AD0B02C0 */ sw $t3, 0x02C0($t0) ## 000002C0
/* 12C44 80826464 44050000 */ mfc1 $a1, $f0
/* 12C48 80826468 44060000 */ mfc1 $a2, $f0
/* 12C4C 8082646C 02002025 */ or $a0, $s0, $zero ## $a0 = 00000000
/* 12C50 80826470 3C074280 */ lui $a3, 0x4280 ## $a3 = 42800000
/* 12C54 80826474 AC4D0004 */ sw $t5, 0x0004($v0) ## 00000004
/* 12C58 80826478 0C208E65 */ jal func_80823994
/* 12C5C 8082647C AC4C0000 */ sw $t4, 0x0000($v0) ## 00000000
/* 12C60 80826480 960201D4 */ lhu $v0, 0x01D4($s0) ## 000001D4
/* 12C64 80826484 28410008 */ slti $at, $v0, 0x0008
/* 12C68 80826488 14200003 */ bne $at, $zero, .L80826498
/* 12C6C 8082648C 28410012 */ slti $at, $v0, 0x0012
/* 12C70 80826490 54200004 */ bnel $at, $zero, .L808264A4
/* 12C74 80826494 960201D4 */ lhu $v0, 0x01D4($s0) ## 000001D4
.L80826498:
/* 12C78 80826498 0C208704 */ jal func_80821C10
/* 12C7C 8082649C 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000
/* 12C80 808264A0 960201D4 */ lhu $v0, 0x01D4($s0) ## 000001D4
.L808264A4:
/* 12C84 808264A4 2841000B */ slti $at, $v0, 0x000B
/* 12C88 808264A8 14200005 */ bne $at, $zero, .L808264C0
/* 12C8C 808264AC 28410012 */ slti $at, $v0, 0x0012
/* 12C90 808264B0 50200004 */ beql $at, $zero, .L808264C4
/* 12C94 808264B4 960201D6 */ lhu $v0, 0x01D6($s0) ## 000001D6
/* 12C98 808264B8 0C209705 */ jal func_80825C14
/* 12C9C 808264BC 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000
.L808264C0:
/* 12CA0 808264C0 960201D6 */ lhu $v0, 0x01D6($s0) ## 000001D6
.L808264C4:
/* 12CA4 808264C4 24010001 */ addiu $at, $zero, 0x0001 ## $at = 00000001
/* 12CA8 808264C8 10410003 */ beq $v0, $at, .L808264D8
/* 12CAC 808264CC 24010002 */ addiu $at, $zero, 0x0002 ## $at = 00000002
/* 12CB0 808264D0 14410003 */ bne $v0, $at, .L808264E0
/* 12CB4 808264D4 00000000 */ nop
.L808264D8:
/* 12CB8 808264D8 0C20586B */ jal func_808161AC
/* 12CBC 808264DC 02202025 */ or $a0, $s1, $zero ## $a0 = 00000000
.L808264E0:
/* 12CC0 808264E0 3C068083 */ lui $a2, %hi(D_8082FD94) ## $a2 = 80830000
/* 12CC4 808264E4 24C6FD94 */ addiu $a2, $a2, %lo(D_8082FD94) ## $a2 = 8082FD94
/* 12CC8 808264E8 27A40048 */ addiu $a0, $sp, 0x0048 ## $a0 = FFFFFFE0
/* 12CCC 808264EC 8E250000 */ lw $a1, 0x0000($s1) ## 00000000
/* 12CD0 808264F0 0C031AD5 */ jal Graph_CloseDisps
/* 12CD4 808264F4 24070CB6 */ addiu $a3, $zero, 0x0CB6 ## $a3 = 00000CB6
/* 12CD8 808264F8 8FBF001C */ lw $ra, 0x001C($sp)
/* 12CDC 808264FC 8FB00014 */ lw $s0, 0x0014($sp)
/* 12CE0 80826500 8FB10018 */ lw $s1, 0x0018($sp)
/* 12CE4 80826504 03E00008 */ jr $ra
/* 12CE8 80826508 27BD0068 */ addiu $sp, $sp, 0x0068 ## $sp = 00000000

View file

@ -2554,4 +2554,12 @@ void Opening_Destroy(OpeningContext* this);
void func_80811A20(GameState*); // FileChoose_Init
void func_80811A18(GameState*); // FileChoose_Destroy
void func_80823994(PauseContext*, f32, f32, f32);
void func_800949A8(GraphicsContext*);
void func_8082409C(GlobalContext*, GraphicsContext*);
void func_80820434(GlobalContext*, GraphicsContext*);
void func_80821C10(GlobalContext*);
void func_80825C14(GlobalContext*);
void func_808161AC(GlobalContext*);
#endif

View file

@ -817,16 +817,24 @@ typedef struct {
typedef struct {
/* 0x0000 */ View view;
/* 0x0128 */ void* unk_128;
/* 0x012C */ char unk_12C[0x03C];
/* 0x012C */ void* unk_12C;
/* 0x0130 */ void* unk_130;
/* 0x0134 */ void* unk_134;
/* 0x0138 */ void* unk_138;
/* 0x013C */ void* unk_13C;
/* 0x0140 */ char unk_140[0x028];
/* 0x0168 */ Vtx* vtx_168;
/* 0x016C */ char unk_16C[0x068];
/* 0x01D4 */ u16 state;
/* 0x01D6 */ u16 flag;
/* 0x01D8 */ char unk_1D8[0x00C];
/* 0x01D8 */ Vec3f unk_1D8;
/* 0x01E4 */ u16 unk_1E4;
/* 0x01E6 */ char unk_1E6[0x006];
/* 0x01EC */ u16 unk_1EC;
/* 0x01EE */ char unk_1EE[0x04A];
/* 0x01EE */ char unk_1EE[0x026];
/* 0x0214 */ s16 inputX;
/* 0x0216 */ s16 inputY;
/* 0x0218 */ char unk_21A[0x20];
/* 0x0238 */ u16 unk_238;
/* 0x023A */ char unk_23A[0x004];
/* 0x023E */ u16 unk_23E;

View file

@ -1,3 +1,6 @@
#include <ultra64.h>
#include <global.h>
/*
* File: z_kaleido_scope.c
* Overlay: ovl_kaleido_scope
@ -76,7 +79,52 @@
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_80825C14.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/KaleidoScope_Draw.s")
extern const char D_8082FD78[], D_8082FD94[];
void KaleidoScope_Draw(GlobalContext* globalCtx) {
Input* input = &globalCtx->state.input[0];
PauseContext* pauseCtx = &globalCtx->pauseCtx;
InterfaceContext* interfaceCtx = &globalCtx->interfaceCtx;
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
Gfx* dispRefs[4];
Graph_OpenDisps(dispRefs, globalCtx->state.gfxCtx, D_8082FD78, 3188);
pauseCtx->inputX = input->rel.in.x;
pauseCtx->inputY = input->rel.in.y;
gSPSegment(gfxCtx->polyOpa.p++, 0x02, interfaceCtx->parameterSegment);
gSPSegment(gfxCtx->polyOpa.p++, 0x07, pauseCtx->unk_13C);
gSPSegment(gfxCtx->polyOpa.p++, 0x08, pauseCtx->unk_128);
gSPSegment(gfxCtx->polyOpa.p++, 0x09, pauseCtx->unk_12C);
gSPSegment(gfxCtx->polyOpa.p++, 0x0A, pauseCtx->unk_138);
gSPSegment(gfxCtx->polyOpa.p++, 0x0C, pauseCtx->unk_130);
gSPSegment(gfxCtx->polyOpa.p++, 0x0D, pauseCtx->unk_134);
if (pauseCtx->flag == 0) {
func_80823994(pauseCtx, pauseCtx->unk_1D8.x, pauseCtx->unk_1D8.y, pauseCtx->unk_1D8.z);
func_800949A8(globalCtx->state.gfxCtx);
func_8082409C(globalCtx, globalCtx->state.gfxCtx);
func_80820434(globalCtx, globalCtx->state.gfxCtx);
func_800949A8(globalCtx->state.gfxCtx);
gDPSetCombineLERP(gfxCtx->polyOpa.p++, PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0,
PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, PRIMITIVE, 0);
func_80823994(pauseCtx, 0.0f, 0.0f, 64.0f);
if (pauseCtx->state < 8 || 17 < pauseCtx->state) {
func_80821C10(globalCtx);
}
}
if (pauseCtx->state > 10 && pauseCtx->state <= 17) {
func_80825C14(globalCtx);
}
if (pauseCtx->flag == 1 || pauseCtx->flag == 2) {
func_808161AC(globalCtx);
}
Graph_CloseDisps(dispRefs, globalCtx->state.gfxCtx, D_8082FD94, 3254);
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_kaleido_scope/func_8082650C.s")