Merge pull request #22 from Random06457/master

Decompiled z_sample.c
This commit is contained in:
Roman971 2020-03-22 20:04:39 +01:00 committed by GitHub
commit b372169893
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 126 additions and 176 deletions

View File

@ -8,7 +8,7 @@ glabel D_8013F2D0
.balign 4
.text
glabel func_80097604
glabel Sample_Draw
/* B0E7A4 80097604 27BDFF90 */ addiu $sp, $sp, -0x70
/* B0E7A8 80097608 AFBF002C */ sw $ra, 0x2c($sp)
/* B0E7AC 8009760C AFB00028 */ sw $s0, 0x28($sp)

View File

@ -1,16 +0,0 @@
glabel func_800975D0
/* B0E770 800975D0 948E0020 */ lhu $t6, 0x20($a0)
/* B0E774 800975D4 2401EFFF */ li $at, -4097
/* B0E778 800975D8 3C18800C */ lui $t8, %hi(func_800BCA64) # $t8, 0x800c
/* B0E77C 800975DC 01C17827 */ nor $t7, $t6, $at
/* B0E780 800975E0 15E00006 */ bnez $t7, .L800975FC
/* B0E784 800975E4 2718CA64 */ addiu $t8, %lo(func_800BCA64) # addiu $t8, $t8, -0x359c
/* B0E788 800975E8 3C190001 */ lui $t9, (0x00012518 >> 16) # lui $t9, 1
/* B0E78C 800975EC 37392518 */ ori $t9, (0x00012518 & 0xFFFF) # ori $t9, $t9, 0x2518
/* B0E790 800975F0 AC990010 */ sw $t9, 0x10($a0)
/* B0E794 800975F4 AC98000C */ sw $t8, 0xc($a0)
/* B0E798 800975F8 AC800098 */ sw $zero, 0x98($a0)
.L800975FC:
/* B0E79C 800975FC 03E00008 */ jr $ra
/* B0E7A0 80097600 00000000 */ nop

View File

@ -1,12 +0,0 @@
glabel func_80097820
/* B0E9C0 80097820 27BDFFE8 */ addiu $sp, $sp, -0x18
/* B0E9C4 80097824 AFBF0014 */ sw $ra, 0x14($sp)
/* B0E9C8 80097828 0C025D81 */ jal func_80097604
/* B0E9CC 8009782C AFA40018 */ sw $a0, 0x18($sp)
/* B0E9D0 80097830 0C025D74 */ jal func_800975D0
/* B0E9D4 80097834 8FA40018 */ lw $a0, 0x18($sp)
/* B0E9D8 80097838 8FBF0014 */ lw $ra, 0x14($sp)
/* B0E9DC 8009783C 27BD0018 */ addiu $sp, $sp, 0x18
/* B0E9E0 80097840 03E00008 */ jr $ra
/* B0E9E4 80097844 00000000 */ nop

View File

@ -1,4 +0,0 @@
glabel func_80097848
/* B0E9E8 80097848 03E00008 */ jr $ra
/* B0E9EC 8009784C AFA40000 */ sw $a0, ($sp)

View File

@ -1,52 +0,0 @@
.late_rodata
glabel D_8013F300
.float 3000
.text
glabel func_80097850
/* B0E9F0 80097850 27BDFFA0 */ addiu $sp, $sp, -0x60
/* B0E9F4 80097854 AFB00018 */ sw $s0, 0x18($sp)
/* B0E9F8 80097858 AFBF001C */ sw $ra, 0x1c($sp)
/* B0E9FC 8009785C 8C850000 */ lw $a1, ($a0)
/* B0EA00 80097860 249000A8 */ addiu $s0, $a0, 0xa8
/* B0EA04 80097864 0C02A89E */ jal func_800AA278
/* B0EA08 80097868 02002025 */ move $a0, $s0
/* B0EA0C 8009786C 240E00F0 */ li $t6, 240
/* B0EA10 80097870 240F0140 */ li $t7, 320
/* B0EA14 80097874 AFAF0054 */ sw $t7, 0x54($sp)
/* B0EA18 80097878 AFAE004C */ sw $t6, 0x4c($sp)
/* B0EA1C 8009787C AFA00048 */ sw $zero, 0x48($sp)
/* B0EA20 80097880 AFA00050 */ sw $zero, 0x50($sp)
/* B0EA24 80097884 02002025 */ move $a0, $s0
/* B0EA28 80097888 0C02A93F */ jal func_800AA4FC
/* B0EA2C 8009788C 27A50048 */ addiu $a1, $sp, 0x48
/* B0EA30 80097890 02002025 */ move $a0, $s0
/* B0EA34 80097894 3C054270 */ lui $a1, 0x4270
/* B0EA38 80097898 3C064120 */ lui $a2, 0x4120
/* B0EA3C 8009789C 0C02A918 */ jal func_800AA460
/* B0EA40 800978A0 3C074648 */ li $a3, 0x46480000 # 0.000000
/* B0EA44 800978A4 44800000 */ mtc1 $zero, $f0
/* B0EA48 800978A8 3C018014 */ lui $at, %hi(D_8013F300)
/* B0EA4C 800978AC C424F300 */ lwc1 $f4, %lo(D_8013F300)($at)
/* B0EA50 800978B0 3C013F80 */ li $at, 0x3F800000 # 0.000000
/* B0EA54 800978B4 44813000 */ mtc1 $at, $f6
/* B0EA58 800978B8 02002025 */ move $a0, $s0
/* B0EA5C 800978BC 27A5003C */ addiu $a1, $sp, 0x3c
/* B0EA60 800978C0 27A60030 */ addiu $a2, $sp, 0x30
/* B0EA64 800978C4 27A70024 */ addiu $a3, $sp, 0x24
/* B0EA68 800978C8 E7A0003C */ swc1 $f0, 0x3c($sp)
/* B0EA6C 800978CC E7A00040 */ swc1 $f0, 0x40($sp)
/* B0EA70 800978D0 E7A00030 */ swc1 $f0, 0x30($sp)
/* B0EA74 800978D4 E7A00034 */ swc1 $f0, 0x34($sp)
/* B0EA78 800978D8 E7A00038 */ swc1 $f0, 0x38($sp)
/* B0EA7C 800978DC E7A00024 */ swc1 $f0, 0x24($sp)
/* B0EA80 800978E0 E7A0002C */ swc1 $f0, 0x2c($sp)
/* B0EA84 800978E4 E7A40044 */ swc1 $f4, 0x44($sp)
/* B0EA88 800978E8 0C02A8D6 */ jal func_800AA358
/* B0EA8C 800978EC E7A60028 */ swc1 $f6, 0x28($sp)
/* B0EA90 800978F0 8FBF001C */ lw $ra, 0x1c($sp)
/* B0EA94 800978F4 8FB00018 */ lw $s0, 0x18($sp)
/* B0EA98 800978F8 27BD0060 */ addiu $sp, $sp, 0x60
/* B0EA9C 800978FC 03E00008 */ jr $ra
/* B0EAA0 80097900 00000000 */ nop

View File

@ -1,40 +0,0 @@
.rdata
glabel D_8013F2E0
.asciz "../z_sample.c"
.balign 4
glabel D_8013F2F0
.asciz "../z_sample.c"
.balign 4
.text
glabel func_80097904
/* B0EAA4 80097904 3C0E01AF */ lui $t6, %hi(_title_staticSegmentRomEnd) # $t6, 0x1af
/* B0EAA8 80097908 3C0F01AA */ lui $t7, %hi(_title_staticSegmentRomStart) # $t7, 0x1aa
/* B0EAAC 8009790C 27BDFFD8 */ addiu $sp, $sp, -0x28
/* B0EAB0 80097910 25EF4000 */ addiu $t7, %lo(_title_staticSegmentRomStart) # addiu $t7, $t7, 0x4000
/* B0EAB4 80097914 25CEB440 */ addiu $t6, %lo(_title_staticSegmentRomEnd) # addiu $t6, $t6, -0x4bc0
/* B0EAB8 80097918 AFBF001C */ sw $ra, 0x1c($sp)
/* B0EABC 8009791C 01CF2823 */ subu $a1, $t6, $t7
/* B0EAC0 80097920 3C068014 */ lui $a2, %hi(D_8013F2E0) # $a2, 0x8014
/* B0EAC4 80097924 AFA40028 */ sw $a0, 0x28($sp)
/* B0EAC8 80097928 24C6F2E0 */ addiu $a2, %lo(D_8013F2E0) # addiu $a2, $a2, -0xd20
/* B0EACC 8009792C AFA50020 */ sw $a1, 0x20($sp)
/* B0EAD0 80097930 0C031521 */ jal Game_Alloc
/* B0EAD4 80097934 240700A3 */ li $a3, 163
/* B0EAD8 80097938 8FB80028 */ lw $t8, 0x28($sp)
/* B0EADC 8009793C 3C0501AA */ lui $a1, %hi(_title_staticSegmentRomStart) # $a1, 0x1aa
/* B0EAE0 80097940 3C078014 */ lui $a3, %hi(D_8013F2F0) # $a3, 0x8014
/* B0EAE4 80097944 241900A4 */ li $t9, 164
/* B0EAE8 80097948 AF0200A4 */ sw $v0, 0xa4($t8)
/* B0EAEC 8009794C AFB90010 */ sw $t9, 0x10($sp)
/* B0EAF0 80097950 8FA60020 */ lw $a2, 0x20($sp)
/* B0EAF4 80097954 24E7F2F0 */ addiu $a3, %lo(D_8013F2F0) # addiu $a3, $a3, -0xd10
/* B0EAF8 80097958 24A54000 */ addiu $a1, %lo(_title_staticSegmentRomStart) # addiu $a1, $a1, 0x4000
/* B0EAFC 8009795C 0C0006A8 */ jal DmaMgr_SendRequest1
/* B0EB00 80097960 00402025 */ move $a0, $v0
/* B0EB04 80097964 8FBF001C */ lw $ra, 0x1c($sp)
/* B0EB08 80097968 27BD0028 */ addiu $sp, $sp, 0x28
/* B0EB0C 8009796C 03E00008 */ jr $ra
/* B0EB10 80097970 00000000 */ nop

View File

@ -1,36 +0,0 @@
glabel func_80097974
/* B0EB14 80097974 27BDFFE8 */ addiu $sp, $sp, -0x18
/* B0EB18 80097978 AFBF0014 */ sw $ra, 0x14($sp)
/* B0EB1C 8009797C 3C0E8009 */ lui $t6, %hi(func_80097820) # $t6, 0x8009
/* B0EB20 80097980 3C0F8009 */ lui $t7, %hi(func_80097848) # $t7, 0x8009
/* B0EB24 80097984 3C028016 */ lui $v0, %hi(gGameInfo) # $v0, 0x8016
/* B0EB28 80097988 25CE7820 */ addiu $t6, %lo(func_80097820) # addiu $t6, $t6, 0x7820
/* B0EB2C 8009798C 25EF7848 */ addiu $t7, %lo(func_80097848) # addiu $t7, $t7, 0x7848
/* B0EB30 80097990 2442FA90 */ addiu $v0, %lo(gGameInfo) # addiu $v0, $v0, -0x570
/* B0EB34 80097994 AC8E0004 */ sw $t6, 4($a0)
/* B0EB38 80097998 AC8F0008 */ sw $t7, 8($a0)
/* B0EB3C 8009799C 8C590000 */ lw $t9, ($v0)
/* B0EB40 800979A0 24180001 */ li $t8, 1
/* B0EB44 800979A4 A7380110 */ sh $t8, 0x110($t9)
/* B0EB48 800979A8 0C025E14 */ jal func_80097850
/* B0EB4C 800979AC AFA40018 */ sw $a0, 0x18($sp)
/* B0EB50 800979B0 0C025E41 */ jal func_80097904
/* B0EB54 800979B4 8FA40018 */ lw $a0, 0x18($sp)
/* B0EB58 800979B8 3C028016 */ lui $v0, %hi(gGameInfo) # $v0, 0x8016
/* B0EB5C 800979BC 2442FA90 */ addiu $v0, %lo(gGameInfo) # addiu $v0, $v0, -0x570
/* B0EB60 800979C0 8C480000 */ lw $t0, ($v0)
/* B0EB64 800979C4 A500011E */ sh $zero, 0x11e($t0)
/* B0EB68 800979C8 8C490000 */ lw $t1, ($v0)
/* B0EB6C 800979CC A5200120 */ sh $zero, 0x120($t1)
/* B0EB70 800979D0 8C4A0000 */ lw $t2, ($v0)
/* B0EB74 800979D4 A5400122 */ sh $zero, 0x122($t2)
/* B0EB78 800979D8 8C4B0000 */ lw $t3, ($v0)
/* B0EB7C 800979DC A5600124 */ sh $zero, 0x124($t3)
/* B0EB80 800979E0 8C4C0000 */ lw $t4, ($v0)
/* B0EB84 800979E4 A5800126 */ sh $zero, 0x126($t4)
/* B0EB88 800979E8 8C4D0000 */ lw $t5, ($v0)
/* B0EB8C 800979EC A5A00128 */ sh $zero, 0x128($t5)
/* B0EB90 800979F0 8FBF0014 */ lw $ra, 0x14($sp)
/* B0EB94 800979F4 27BD0018 */ addiu $sp, $sp, 0x18
/* B0EB98 800979F8 03E00008 */ jr $ra
/* B0EB9C 800979FC 00000000 */ nop

View File

@ -1093,12 +1093,13 @@ s32 func_8009728C(GlobalContext* globalCtx, RoomContext* roomCtx, s32 roomNum);
s32 func_800973FC(GlobalContext* globalCtx, RoomContext* roomCtx);
void Room_Draw(GlobalContext* globalCtx, Room* room, u32 flags);
void func_80097534(GlobalContext* globalCtx, RoomContext* roomCtx);
// ? func_800975D0(?);
// ? func_80097604(?);
// ? func_80097820(?);
// ? func_80097848(?);
// ? func_80097850(?);
// ? func_80097904(?);
void Sample_Calc(SampleContext* this);
void Sample_Draw(SampleContext* this);
void Sample_Update(SampleContext* this);
void Sample_Destroy(SampleContext* this);
void Sample_SetupView(SampleContext* this);
void Sample_LoadTitleStatic(SampleContext* this);
void Sample_Init(SampleContext* this);
void Inventory_ChangeEquipment(s16 equipment, u16 value);
u8 Inventory_DeleteEquipment(GlobalContext* globalCtx, s16 equipment);
void Inventory_ChangeUpgrade(s16 upgrade, s16 value);
@ -2299,7 +2300,7 @@ void func_80103A70(UNK_PTR, Gfx*, Hilite*, f32, f32, f32, f32, f32, f32, f32, f3
// ? func_80103B30(?);
// ? func_80103B60(?);
// ? func_80103BB0(?);
// ? func_80103D58(?);
void func_80103D58(Mtx*, f32, f32, f32, f32, f32, f32, f32);
// ? func_80103DC0(?);
// ? func_80103E20(?);
// ? func_80103FA4(?);

View File

@ -302,7 +302,9 @@ typedef struct
{
/* 0x0000 */ char unk_00[0x28];
/* 0x0028 */ Vec3f eye;
/* 0x0034 */ char unk_34[0xF4];
/* 0x0034 */ char unk_34[0xEC];
/* 0x0120 */ u32 unk_120;
/* 0x0124 */ char unk_124[4];
} View; // size = 0x128
typedef struct
@ -865,6 +867,13 @@ typedef struct
/* 0x01E2 */ char unk_1E2[6];
} TitleContext; // size = 0x1E8
typedef struct
{
/* 0x0000 */ GameState state;
/* 0x00A4 */ void* staticSegment;
/* 0x00A8 */ View view;
} SampleContext;
// Global Context (dbg ram start: 80212020)
typedef struct GlobalContext
{

View File

@ -1,17 +1,117 @@
#include <ultra64.h>
#include <global.h>
#include <PR/os_cont.h>
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_800975D0.s")
void Sample_Calc(SampleContext* this)
{
if (!~(this->state.input[0].padPressed | ~START_BUTTON))
{
this->state.init = func_800BCA64; this->state.size = sizeof(GlobalContext);
this->state.running = false;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097604.s")
// very close from matching, the only difference is the place of "mtx" in the stack
#ifdef NON_MATCHING
void Sample_Draw(SampleContext* this)
{
u32 pad;
GraphicsContext* gfxCtx = this->state.gfxCtx;
View* view = &this->view;
Gfx* gfxArr[4];
Mtx* mtx;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097820.s")
func_800C6AC4(gfxArr, gfxCtx, "../z_sample.c", 62);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097848.s")
gSPSegment(gfxCtx->polyOpa.p++, 0, NULL;
gSPSegment(gfxCtx->polyOpa.p++, 1, this->staticSegment);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097850.s")
func_80095248(gfxCtx, 0, 0, 0);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097904.s")
view->unk_120 = 7;
func_800AAA50(view, 15);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/func_80097974.s")
mtx = Graph_Alloc(gfxCtx, sizeof(Mtx));
func_80103D58(mtx, SREG(37), SREG(38), SREG(39), 1.0f, SREG(40), SREG(41), SREG(42));
gSPMatrix(gfxCtx->polyOpa.p++, mtx, G_MTX_LOAD);
gfxCtx->polyOpa.p = func_80093708(gfxCtx->polyOpa.p, 0xFF, 0xFF, 0xFF, 0, 0, 0);
func_80093D18(gfxCtx);
gDPSetCycleType(gfxCtx->polyOpa.p++, G_CYC_1CYCLE);
gDPSetRenderMode(gfxCtx->polyOpa.p++, G_RM_AA_ZB_OPA_SURF, G_RM_AA_ZB_OPA_SURF2);
gDPSetCombineLERP(gfxCtx->polyOpa.p++, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE);
gDPSetPrimColor(gfxCtx->polyOpa.p++, 0, 0, 0xFF, 0xFF, 0x00, 0x00);
func_800C6B54(gfxArr, gfxCtx, "../z_sample.c", 111);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_sample/Sample_Draw.s")
#endif
void Sample_Update(SampleContext* this)
{
Sample_Draw(this);
Sample_Calc(this);
}
void Sample_Destroy(SampleContext* this)
{
}
void Sample_SetupView(SampleContext* this)
{
View* view;
GraphicsContext* gfxCtx;
u32 v0[4];
Vec3f v1;
Vec3f v2;
Vec3f v3;
view = &this->view;
gfxCtx = this->state.gfxCtx;
func_800AA278(view, gfxCtx);
v0[1] = SCREEN_HEIGHT; v0[3] = SCREEN_WIDTH;
v0[0] = 0;
v0[2] = 0;
func_800AA4FC(view, &v0);
func_800AA460(view, 60, 10, 12800);
v1.x = 0;
v1.y = 0;
v2.x = 0;
v2.y = 0;
v2.z = 0;
v3.x = 0;
v3.z = 0;
v1.z = 3000;
v3.y = 1;
func_800AA358(view, &v1, &v2, &v3);
}
void Sample_LoadTitleStatic(SampleContext* this)
{
u32 size = _title_staticSegmentRomEnd - _title_staticSegmentRomStart;
this->staticSegment = Game_Alloc(&this->state, size, "../z_sample.c", 163);
DmaMgr_SendRequest1(this->staticSegment, _title_staticSegmentRomStart, size, "../z_sample.c", 164);
}
void Sample_Init(SampleContext* this)
{
this->state.main = Sample_Update;
this->state.destroy = Sample_Destroy;
R_UPDATE_RATE = 1;
Sample_SetupView(this);
Sample_LoadTitleStatic(this);
SREG(37) = 0;
SREG(38) = 0;
SREG(39) = 0;
SREG(40) = 0;
SREG(41) = 0;
SREG(42) = 0;
}