Start DolphinCTexture and CARAMToken

This commit is contained in:
Phillip Stephens 2022-12-03 13:31:54 -08:00
parent 209fd5d3b5
commit f711682fbf
19 changed files with 327 additions and 90 deletions

View File

@ -19,6 +19,18 @@ mPreInitializeAlloc__12CARAMManager:
.comm lbl_805A679C, 0x18, 4
.lcomm lbl_804BFF40, 0x10, 4
.section .sdata2, "a"
.balign 8
.global kInvalidAlloc__12CARAMManager
kInvalidAlloc__12CARAMManager:
# ROM: 0x3FB168
.4byte 0xFFFFFFFF
.global kInvalidHandle__12CARAMManager
kInvalidHandle__12CARAMManager:
# ROM: 0x3FB16C
.4byte 0xFFFFFFFF
.section .sbss, "wa"
.balign 8
@ -310,7 +322,7 @@ lbl_803448FC:
/* 80344948 003418A8 80 9E 00 20 */ lwz r4, 0x20(r30)
/* 8034494C 003418AC 48 02 AD 25 */ bl ARQPostRequest
/* 80344950 003418B0 80 6D A9 74 */ lwz r3, lbl_805A9534@sda21(r13)
/* 80344954 003418B4 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 80344954 003418B4 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 80344958 003418B8 38 63 00 01 */ addi r3, r3, 1
/* 8034495C 003418BC 7C 03 00 40 */ cmplw r3, r0
/* 80344960 003418C0 90 6D A9 74 */ stw r3, lbl_805A9534@sda21(r13)
@ -394,7 +406,7 @@ lbl_80344A30:
/* 80344A7C 003419DC 80 9E 00 20 */ lwz r4, 0x20(r30)
/* 80344A80 003419E0 48 02 AB F1 */ bl ARQPostRequest
/* 80344A84 003419E4 80 6D A9 74 */ lwz r3, lbl_805A9534@sda21(r13)
/* 80344A88 003419E8 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 80344A88 003419E8 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 80344A8C 003419EC 38 63 00 01 */ addi r3, r3, 1
/* 80344A90 003419F0 7C 03 00 40 */ cmplw r3, r0
/* 80344A94 003419F4 90 6D A9 74 */ stw r3, lbl_805A9534@sda21(r13)
@ -411,7 +423,7 @@ lbl_80344AA4:
.global Free__12CARAMManagerFPCv
Free__12CARAMManagerFPCv:
/* 80344ABC 00341A1C 80 02 CB A8 */ lwz r0, lbl_805AE8C8@sda21(r2)
/* 80344ABC 00341A1C 80 02 CB A8 */ lwz r0, kInvalidAlloc__12CARAMManager@sda21(r2)
/* 80344AC0 00341A20 7C 00 18 40 */ cmplw r0, r3
/* 80344AC4 00341A24 40 82 00 0C */ bne lbl_80344AD0
/* 80344AC8 00341A28 38 60 00 00 */ li r3, 0

View File

@ -1,6 +1,6 @@
.include "macros.inc"
.comm lbl_805A680C, 0x1C, 4
.comm sLists__10CARAMToken, 0x1C, 4
.section .text, "ax"
@ -83,9 +83,9 @@ MakeInvalid__10CARAMTokenFv:
/* 80358428 00355388 7C 7F 1B 78 */ mr r31, r3
/* 8035842C 0035538C 48 00 00 7D */ bl MoveToList__10CARAMTokenFQ210CARAMToken7EStatus
/* 80358430 00355390 38 80 00 00 */ li r4, 0
/* 80358434 00355394 80 62 CB A8 */ lwz r3, lbl_805AE8C8@sda21(r2)
/* 80358434 00355394 80 62 CB A8 */ lwz r3, kInvalidAlloc__12CARAMManager@sda21(r2)
/* 80358438 00355398 90 9F 00 04 */ stw r4, 4(r31)
/* 8035843C 0035539C 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 8035843C 0035539C 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 80358440 003553A0 90 7F 00 08 */ stw r3, 8(r31)
/* 80358444 003553A4 90 9F 00 0C */ stw r4, 0xc(r31)
/* 80358448 003553A8 90 1F 00 10 */ stw r0, 0x10(r31)
@ -101,9 +101,9 @@ RemoveFromList__10CARAMTokenFv:
/* 80358464 003553C4 28 04 00 00 */ cmplwi r4, 0
/* 80358468 003553C8 40 82 00 20 */ bne lbl_80358488
/* 8035846C 003553CC 80 03 00 00 */ lwz r0, 0(r3)
/* 80358470 003553D0 3C 80 80 5A */ lis r4, lbl_805A680C@ha
/* 80358470 003553D0 3C 80 80 5A */ lis r4, sLists__10CARAMToken@ha
/* 80358474 003553D4 80 A3 00 18 */ lwz r5, 0x18(r3)
/* 80358478 003553D8 38 84 68 0C */ addi r4, r4, lbl_805A680C@l
/* 80358478 003553D8 38 84 68 0C */ addi r4, r4, sLists__10CARAMToken@l
/* 8035847C 003553DC 54 00 10 3A */ slwi r0, r0, 2
/* 80358480 003553E0 7C A4 01 2E */ stwx r5, r4, r0
/* 80358484 003553E4 48 00 00 0C */ b lbl_80358490
@ -145,9 +145,9 @@ lbl_803584E0:
.global InitiallyMoveToList__10CARAMTokenFv
InitiallyMoveToList__10CARAMTokenFv:
/* 803584F8 00355458 38 00 00 00 */ li r0, 0
/* 803584FC 0035545C 3C 80 80 5A */ lis r4, lbl_805A680C@ha
/* 803584FC 0035545C 3C 80 80 5A */ lis r4, sLists__10CARAMToken@ha
/* 80358500 00355460 90 03 00 14 */ stw r0, 0x14(r3)
/* 80358504 00355464 38 84 68 0C */ addi r4, r4, lbl_805A680C@l
/* 80358504 00355464 38 84 68 0C */ addi r4, r4, sLists__10CARAMToken@l
/* 80358508 00355468 80 03 00 00 */ lwz r0, 0(r3)
/* 8035850C 0035546C 54 00 10 3A */ slwi r0, r0, 2
/* 80358510 00355470 7C 04 00 2E */ lwzx r0, r4, r0
@ -165,9 +165,9 @@ InitiallyMoveToList__10CARAMTokenFv:
UpdateAllDMAs__10CARAMTokenFv:
/* 80358538 00355498 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 8035853C 0035549C 7C 08 02 A6 */ mflr r0
/* 80358540 003554A0 3C 60 80 5A */ lis r3, lbl_805A680C@ha
/* 80358540 003554A0 3C 60 80 5A */ lis r3, sLists__10CARAMToken@ha
/* 80358544 003554A4 90 01 00 24 */ stw r0, 0x24(r1)
/* 80358548 003554A8 38 63 68 0C */ addi r3, r3, lbl_805A680C@l
/* 80358548 003554A8 38 63 68 0C */ addi r3, r3, sLists__10CARAMToken@l
/* 8035854C 003554AC 93 E1 00 1C */ stw r31, 0x1c(r1)
/* 80358550 003554B0 3B E3 00 08 */ addi r31, r3, 8
/* 80358554 003554B4 93 C1 00 18 */ stw r30, 0x18(r1)
@ -218,7 +218,7 @@ lbl_803585D8:
/* 803585E8 00355548 38 60 00 00 */ li r3, 0
/* 803585EC 0035554C 48 00 00 78 */ b lbl_80358664
lbl_803585F0:
/* 803585F0 00355550 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 803585F0 00355550 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 803585F4 00355554 90 1F 00 10 */ stw r0, 0x10(r31)
/* 803585F8 00355558 80 1F 00 00 */ lwz r0, 0(r31)
/* 803585FC 0035555C 2C 00 00 05 */ cmpwi r0, 5
@ -234,7 +234,7 @@ lbl_80358618:
/* 80358620 00355580 40 82 00 14 */ bne lbl_80358634
/* 80358624 00355584 80 7F 00 08 */ lwz r3, 8(r31)
/* 80358628 00355588 4B FE C4 95 */ bl Free__12CARAMManagerFPCv
/* 8035862C 0035558C 80 02 CB A8 */ lwz r0, lbl_805AE8C8@sda21(r2)
/* 8035862C 0035558C 80 02 CB A8 */ lwz r0, kInvalidAlloc__12CARAMManager@sda21(r2)
/* 80358630 00355590 90 1F 00 08 */ stw r0, 8(r31)
lbl_80358634:
/* 80358634 00355594 7F E3 FB 78 */ mr r3, r31
@ -306,7 +306,7 @@ lbl_80358700:
/* 8035870C 0035566C 80 7F 00 0C */ lwz r3, 0xc(r31)
/* 80358710 00355670 4B FE C5 19 */ bl Alloc__12CARAMManagerFUi
/* 80358714 00355674 90 7F 00 08 */ stw r3, 8(r31)
/* 80358718 00355678 80 02 CB A8 */ lwz r0, lbl_805AE8C8@sda21(r2)
/* 80358718 00355678 80 02 CB A8 */ lwz r0, kInvalidAlloc__12CARAMManager@sda21(r2)
/* 8035871C 0035567C 80 9F 00 08 */ lwz r4, 8(r31)
/* 80358720 00355680 7C 00 20 40 */ cmplw r0, r4
/* 80358724 00355684 40 82 00 0C */ bne lbl_80358730
@ -439,8 +439,8 @@ lbl_803588BC:
/* 803588CC 0035582C 38 21 00 10 */ addi r1, r1, 0x10
/* 803588D0 00355830 4E 80 00 20 */ blr
.global PostConstruct__10CARAMTokenFPvUi
PostConstruct__10CARAMTokenFPvUi:
.global PostConstruct__10CARAMTokenFPvUii
PostConstruct__10CARAMTokenFPvUii:
/* 803588D4 00355834 94 21 FF E0 */ stwu r1, -0x20(r1)
/* 803588D8 00355838 7C 08 02 A6 */ mflr r0
/* 803588DC 0035583C 90 01 00 24 */ stw r0, 0x24(r1)
@ -481,7 +481,7 @@ __dt__10CARAMTokenFv:
/* 8035895C 003558BC 7C 7E 1B 79 */ or. r30, r3, r3
/* 80358960 003558C0 41 82 00 50 */ beq lbl_803589B0
/* 80358964 003558C4 80 7E 00 10 */ lwz r3, 0x10(r30)
/* 80358968 003558C8 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 80358968 003558C8 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 8035896C 003558CC 7C 03 00 40 */ cmplw r3, r0
/* 80358970 003558D0 41 82 00 18 */ beq lbl_80358988
/* 80358974 003558D4 4B FE BD 49 */ bl CancelDMA__12CARAMManagerFUi
@ -548,7 +548,7 @@ __ct__10CARAMTokenFRC10CARAMToken:
__ct__10CARAMTokenFPvUi:
/* 80358A4C 003559AC 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80358A50 003559B0 7C 08 02 A6 */ mflr r0
/* 80358A54 003559B4 80 E2 CB A8 */ lwz r7, lbl_805AE8C8@sda21(r2)
/* 80358A54 003559B4 80 E2 CB A8 */ lwz r7, kInvalidAlloc__12CARAMManager@sda21(r2)
/* 80358A58 003559B8 90 01 00 14 */ stw r0, 0x14(r1)
/* 80358A5C 003559BC 38 00 00 01 */ li r0, 1
/* 80358A60 003559C0 93 E1 00 0C */ stw r31, 0xc(r1)
@ -558,7 +558,7 @@ __ct__10CARAMTokenFPvUi:
/* 80358A70 003559D0 38 C0 00 00 */ li r6, 0
/* 80358A74 003559D4 90 83 00 04 */ stw r4, 4(r3)
/* 80358A78 003559D8 54 04 D9 7E */ srwi r4, r0, 5
/* 80358A7C 003559DC 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 80358A7C 003559DC 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 80358A80 003559E0 90 E3 00 08 */ stw r7, 8(r3)
/* 80358A84 003559E4 90 A3 00 0C */ stw r5, 0xc(r3)
/* 80358A88 003559E8 90 03 00 10 */ stw r0, 0x10(r3)
@ -582,7 +582,7 @@ __ct__10CARAMTokenFPvUi:
/* 80358AD0 00355A30 90 7F 00 10 */ stw r3, 0x10(r31)
/* 80358AD4 00355A34 80 7F 00 10 */ lwz r3, 0x10(r31)
/* 80358AD8 00355A38 4B FE BC 71 */ bl WaitForDMACompletion__12CARAMManagerFUi
/* 80358ADC 00355A3C 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 80358ADC 00355A3C 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 80358AE0 00355A40 90 1F 00 10 */ stw r0, 0x10(r31)
lbl_80358AE4:
/* 80358AE4 00355A44 80 01 00 14 */ lwz r0, 0x14(r1)
@ -597,13 +597,13 @@ __ct__10CARAMTokenFv:
/* 80358AFC 00355A5C 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 80358B00 00355A60 7C 08 02 A6 */ mflr r0
/* 80358B04 00355A64 38 A0 00 00 */ li r5, 0
/* 80358B08 00355A68 80 82 CB A8 */ lwz r4, lbl_805AE8C8@sda21(r2)
/* 80358B08 00355A68 80 82 CB A8 */ lwz r4, kInvalidAlloc__12CARAMManager@sda21(r2)
/* 80358B0C 00355A6C 90 01 00 14 */ stw r0, 0x14(r1)
/* 80358B10 00355A70 38 00 00 06 */ li r0, 6
/* 80358B14 00355A74 93 E1 00 0C */ stw r31, 0xc(r1)
/* 80358B18 00355A78 7C 7F 1B 78 */ mr r31, r3
/* 80358B1C 00355A7C 90 03 00 00 */ stw r0, 0(r3)
/* 80358B20 00355A80 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 80358B20 00355A80 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 80358B24 00355A84 90 A3 00 04 */ stw r5, 4(r3)
/* 80358B28 00355A88 90 83 00 08 */ stw r4, 8(r3)
/* 80358B2C 00355A8C 90 A3 00 0C */ stw r5, 0xc(r3)

View File

@ -77,7 +77,7 @@ IsComplete__15CARAMDvdRequestFv:
/* 802FE63C 002FB59C 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 802FE640 002FB5A0 7C 08 02 A6 */ mflr r0
/* 802FE644 002FB5A4 90 01 00 14 */ stw r0, 0x14(r1)
/* 802FE648 002FB5A8 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 802FE648 002FB5A8 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 802FE64C 002FB5AC 93 E1 00 0C */ stw r31, 0xc(r1)
/* 802FE650 002FB5B0 7C 7F 1B 78 */ mr r31, r3
/* 802FE654 002FB5B4 80 63 00 04 */ lwz r3, 4(r3)
@ -89,7 +89,7 @@ IsComplete__15CARAMDvdRequestFv:
/* 802FE66C 002FB5CC 38 60 00 00 */ li r3, 0
/* 802FE670 002FB5D0 48 00 00 10 */ b lbl_802FE680
lbl_802FE674:
/* 802FE674 002FB5D4 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 802FE674 002FB5D4 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 802FE678 002FB5D8 90 1F 00 04 */ stw r0, 4(r31)
lbl_802FE67C:
/* 802FE67C 002FB5DC 38 60 00 01 */ li r3, 1
@ -105,14 +105,14 @@ WaitUntilComplete__15CARAMDvdRequestFv:
/* 802FE694 002FB5F4 94 21 FF F0 */ stwu r1, -0x10(r1)
/* 802FE698 002FB5F8 7C 08 02 A6 */ mflr r0
/* 802FE69C 002FB5FC 90 01 00 14 */ stw r0, 0x14(r1)
/* 802FE6A0 002FB600 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 802FE6A0 002FB600 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 802FE6A4 002FB604 93 E1 00 0C */ stw r31, 0xc(r1)
/* 802FE6A8 002FB608 7C 7F 1B 78 */ mr r31, r3
/* 802FE6AC 002FB60C 80 63 00 04 */ lwz r3, 4(r3)
/* 802FE6B0 002FB610 7C 03 00 40 */ cmplw r3, r0
/* 802FE6B4 002FB614 41 82 00 10 */ beq lbl_802FE6C4
/* 802FE6B8 002FB618 48 04 60 91 */ bl WaitForDMACompletion__12CARAMManagerFUi
/* 802FE6BC 002FB61C 80 02 CB AC */ lwz r0, lbl_805AE8CC@sda21(r2)
/* 802FE6BC 002FB61C 80 02 CB AC */ lwz r0, kInvalidHandle__12CARAMManager@sda21(r2)
/* 802FE6C0 002FB620 90 1F 00 04 */ stw r0, 4(r31)
lbl_802FE6C4:
/* 802FE6C4 002FB624 80 01 00 14 */ lwz r0, 0x14(r1)

View File

@ -1464,7 +1464,7 @@ lbl_80368574:
/* 803685BC 0036551C 88 1D 00 28 */ lbz r0, 0x28(r29)
/* 803685C0 00365520 53 C0 3E 30 */ rlwimi r0, r30, 7, 0x18, 0x18
/* 803685C4 00365524 38 C0 00 00 */ li r6, 0
/* 803685C8 00365528 80 82 CB A8 */ lwz r4, lbl_805AE8C8@sda21(r2)
/* 803685C8 00365528 80 82 CB A8 */ lwz r4, kInvalidAlloc__12CARAMManager@sda21(r2)
/* 803685CC 0036552C 98 1D 00 28 */ stb r0, 0x28(r29)
/* 803685D0 00365530 38 00 FF FF */ li r0, -1
/* 803685D4 00365534 7F A3 EB 78 */ mr r3, r29
@ -2128,4 +2128,3 @@ lbl_803D84E0:
.asciz "??(??)"
.balign 4
.4byte 0

View File

@ -1891,19 +1891,6 @@ lbl_8033C5BC:
/* 8033C5D8 00339538 38 21 00 20 */ addi r1, r1, 0x20
/* 8033C5DC 0033953C 4E 80 00 20 */ blr
.section .sdata2, "a"
.balign 8
.global lbl_805AE8C8
lbl_805AE8C8:
# ROM: 0x3FB168
.4byte 0xFFFFFFFF
.global lbl_805AE8CC
lbl_805AE8CC:
# ROM: 0x3FB16C
.4byte 0xFFFFFFFF
.section .rodata
.balign 8
.global lbl_803D7A38

View File

@ -684,7 +684,7 @@ TryARAMFile__8CDvdFileFv:
/* 80350150 0034D0B0 80 63 00 14 */ lwz r3, 0x14(r3)
/* 80350154 0034D0B4 4B FF 4A D5 */ bl Alloc__12CARAMManagerFUi
/* 80350158 0034D0B8 90 7B 00 04 */ stw r3, 4(r27)
/* 8035015C 0034D0BC 80 62 CB A8 */ lwz r3, lbl_805AE8C8@sda21(r2)
/* 8035015C 0034D0BC 80 62 CB A8 */ lwz r3, kInvalidAlloc__12CARAMManager@sda21(r2)
/* 80350160 0034D0C0 80 1B 00 04 */ lwz r0, 4(r27)
/* 80350164 0034D0C4 7C 03 00 40 */ cmplw r3, r0
/* 80350168 0034D0C8 41 82 00 E0 */ beq lbl_80350248

View File

@ -37,19 +37,19 @@ lbl_803ED994:
.section .bss
.balign 8
.lcomm lbl_804BFD10, 0x20, 4
.lcomm sLoadedTextures, 0x20, 4
.section .sbss, "wa"
.balign 8
.global lbl_805A9430
lbl_805A9430:
.global sCurrentFrameCount__8CTexture
sCurrentFrameCount__8CTexture:
.skip 0x4
.global lbl_805A9434
lbl_805A9434:
.global sTotalAllocatedMemory__8CTexture
sTotalAllocatedMemory__8CTexture:
.skip 0x4
.global lbl_805A9438
lbl_805A9438:
.global sMangleMips__8CTexture
sMangleMips__8CTexture:
.skip 0x8
.section .text, "ax"
@ -75,9 +75,9 @@ lbl_8030E138:
.global InvalidateTexmap__8CTextureF11_GXTexMapID
InvalidateTexmap__8CTextureF11_GXTexMapID:
/* 8030E148 0030B0A8 3C 80 80 4C */ lis r4, lbl_804BFD10@ha
/* 8030E148 0030B0A8 3C 80 80 4C */ lis r4, sLoadedTextures@ha
/* 8030E14C 0030B0AC 54 60 10 3A */ slwi r0, r3, 2
/* 8030E150 0030B0B0 38 64 FD 10 */ addi r3, r4, lbl_804BFD10@l
/* 8030E150 0030B0B0 38 64 FD 10 */ addi r3, r4, sLoadedTextures@l
/* 8030E154 0030B0B4 38 80 00 00 */ li r4, 0
/* 8030E158 0030B0B8 7C 83 01 2E */ stwx r4, r3, r0
/* 8030E15C 0030B0BC 4E 80 00 20 */ blr
@ -89,11 +89,11 @@ UncountMemory__8CTextureCFv:
/* 8030E168 0030B0C8 4D 82 00 20 */ beqlr
/* 8030E16C 0030B0CC 38 00 00 00 */ li r0, 0
/* 8030E170 0030B0D0 50 04 1F 38 */ rlwimi r4, r0, 3, 0x1c, 0x1c
/* 8030E174 0030B0D4 80 0D A8 74 */ lwz r0, lbl_805A9434@sda21(r13)
/* 8030E174 0030B0D4 80 0D A8 74 */ lwz r0, sTotalAllocatedMemory__8CTexture@sda21(r13)
/* 8030E178 0030B0D8 98 83 00 0A */ stb r4, 0xa(r3)
/* 8030E17C 0030B0DC 80 63 00 0C */ lwz r3, 0xc(r3)
/* 8030E180 0030B0E0 7C 03 00 50 */ subf r0, r3, r0
/* 8030E184 0030B0E4 90 0D A8 74 */ stw r0, lbl_805A9434@sda21(r13)
/* 8030E184 0030B0E4 90 0D A8 74 */ stw r0, sTotalAllocatedMemory__8CTexture@sda21(r13)
/* 8030E188 0030B0E8 4E 80 00 20 */ blr
.global CountMemory__8CTextureCFv
@ -102,12 +102,12 @@ CountMemory__8CTextureCFv:
/* 8030E190 0030B0F0 54 A0 EF FF */ rlwinm. r0, r5, 0x1d, 0x1f, 0x1f
/* 8030E194 0030B0F4 4C 82 00 20 */ bnelr
/* 8030E198 0030B0F8 38 00 00 01 */ li r0, 1
/* 8030E19C 0030B0FC 80 8D A8 74 */ lwz r4, lbl_805A9434@sda21(r13)
/* 8030E19C 0030B0FC 80 8D A8 74 */ lwz r4, sTotalAllocatedMemory__8CTexture@sda21(r13)
/* 8030E1A0 0030B100 50 05 1F 38 */ rlwimi r5, r0, 3, 0x1c, 0x1c
/* 8030E1A4 0030B104 98 A3 00 0A */ stb r5, 0xa(r3)
/* 8030E1A8 0030B108 80 03 00 0C */ lwz r0, 0xc(r3)
/* 8030E1AC 0030B10C 7C 04 02 14 */ add r0, r4, r0
/* 8030E1B0 0030B110 90 0D A8 74 */ stw r0, lbl_805A9434@sda21(r13)
/* 8030E1B0 0030B110 90 0D A8 74 */ stw r0, sTotalAllocatedMemory__8CTexture@sda21(r13)
/* 8030E1B4 0030B114 4E 80 00 20 */ blr
.global MakeSwappable__8CTextureCFv
@ -838,7 +838,7 @@ lbl_8030EBAC:
/* 8030EBB8 0030BB18 38 60 00 00 */ li r3, 0
/* 8030EBBC 0030BB1C 48 00 00 54 */ b lbl_8030EC10
lbl_8030EBC0:
/* 8030EBC0 0030BB20 80 6D A8 70 */ lwz r3, lbl_805A9430@sda21(r13)
/* 8030EBC0 0030BB20 80 6D A8 70 */ lwz r3, sCurrentFrameCount__8CTexture@sda21(r13)
/* 8030EBC4 0030BB24 80 9E 00 64 */ lwz r4, 0x64(r30)
/* 8030EBC8 0030BB28 38 03 FF FF */ addi r0, r3, -1
/* 8030EBCC 0030BB2C 7C 04 00 40 */ cmplw r4, r0
@ -881,7 +881,7 @@ LoadToMRAM__8CTextureCFv:
/* 8030EC48 0030BBA8 38 60 00 00 */ li r3, 0
/* 8030EC4C 0030BBAC 48 00 00 18 */ b lbl_8030EC64
lbl_8030EC50:
/* 8030EC50 0030BBB0 80 0D A8 70 */ lwz r0, lbl_805A9430@sda21(r13)
/* 8030EC50 0030BBB0 80 0D A8 70 */ lwz r0, sCurrentFrameCount__8CTexture@sda21(r13)
/* 8030EC54 0030BBB4 90 1F 00 64 */ stw r0, 0x64(r31)
/* 8030EC58 0030BBB8 4B FF F5 35 */ bl CountMemory__8CTextureCFv
/* 8030EC5C 0030BBBC 38 7F 00 44 */ addi r3, r31, 0x44
@ -1639,11 +1639,11 @@ lbl_8030F700:
/* 8030F700 0030C660 7F E4 FB 78 */ mr r4, r31
/* 8030F704 0030C664 38 61 00 08 */ addi r3, r1, 8
/* 8030F708 0030C668 48 06 AD 8D */ bl GXLoadTexObj
/* 8030F70C 0030C66C 80 0D A8 70 */ lwz r0, lbl_805A9430@sda21(r13)
/* 8030F710 0030C670 3C 60 80 4C */ lis r3, lbl_804BFD10@ha
/* 8030F70C 0030C66C 80 0D A8 70 */ lwz r0, sCurrentFrameCount__8CTexture@sda21(r13)
/* 8030F710 0030C670 3C 60 80 4C */ lis r3, sLoadedTextures@ha
/* 8030F714 0030C674 57 E4 10 3A */ slwi r4, r31, 2
/* 8030F718 0030C678 38 A0 00 00 */ li r5, 0
/* 8030F71C 0030C67C 38 63 FD 10 */ addi r3, r3, lbl_804BFD10@l
/* 8030F71C 0030C67C 38 63 FD 10 */ addi r3, r3, sLoadedTextures@l
/* 8030F720 0030C680 90 1D 00 64 */ stw r0, 0x64(r29)
/* 8030F724 0030C684 7C A3 21 2E */ stwx r5, r3, r4
/* 8030F728 0030C688 BB 61 00 2C */ lmw r27, 0x2c(r1)
@ -1659,11 +1659,11 @@ Load__8CTextureCF11_GXTexMapIDQ28CTexture10EClampMode:
/* 8030F744 0030C6A4 90 01 00 24 */ stw r0, 0x24(r1)
/* 8030F748 0030C6A8 BF 41 00 08 */ stmw r26, 8(r1)
/* 8030F74C 0030C6AC 7C 9E 23 78 */ mr r30, r4
/* 8030F750 0030C6B0 3C 80 80 4C */ lis r4, lbl_804BFD10@ha
/* 8030F750 0030C6B0 3C 80 80 4C */ lis r4, sLoadedTextures@ha
/* 8030F754 0030C6B4 7C 7D 1B 78 */ mr r29, r3
/* 8030F758 0030C6B8 57 DF 10 3A */ slwi r31, r30, 2
/* 8030F75C 0030C6BC 7C BA 2B 78 */ mr r26, r5
/* 8030F760 0030C6C0 3B 84 FD 10 */ addi r28, r4, lbl_804BFD10@l
/* 8030F760 0030C6C0 3B 84 FD 10 */ addi r28, r4, sLoadedTextures@l
/* 8030F764 0030C6C4 7C 1C F8 2E */ lwzx r0, r28, r31
/* 8030F768 0030C6C8 7C 00 E8 40 */ cmplw r0, r29
/* 8030F76C 0030C6CC 40 82 00 10 */ bne lbl_8030F77C
@ -1712,7 +1712,7 @@ lbl_8030F7F8:
/* 8030F804 0030C764 7F C4 F3 78 */ mr r4, r30
/* 8030F808 0030C768 38 7D 00 20 */ addi r3, r29, 0x20
/* 8030F80C 0030C76C 48 06 AC 89 */ bl GXLoadTexObj
/* 8030F810 0030C770 80 0D A8 70 */ lwz r0, lbl_805A9430@sda21(r13)
/* 8030F810 0030C770 80 0D A8 70 */ lwz r0, sCurrentFrameCount__8CTexture@sda21(r13)
/* 8030F814 0030C774 7F BC F9 2E */ stwx r29, r28, r31
/* 8030F818 0030C778 90 1D 00 64 */ stw r0, 0x64(r29)
lbl_8030F81C:
@ -1951,7 +1951,7 @@ __ct__8CTextureFR12CInputStreamQ28CTexture11EAutoMipmapQ28CTexture9EBlackKey:
/* 8030FB60 0030CAC0 90 1D 00 1C */ stw r0, 0x1c(r29)
/* 8030FB64 0030CAC4 90 DD 00 40 */ stw r6, 0x40(r29)
/* 8030FB68 0030CAC8 48 04 8F 95 */ bl __ct__10CARAMTokenFv
/* 8030FB6C 0030CACC 80 0D A8 70 */ lwz r0, lbl_805A9430@sda21(r13)
/* 8030FB6C 0030CACC 80 0D A8 70 */ lwz r0, sCurrentFrameCount__8CTexture@sda21(r13)
/* 8030FB70 0030CAD0 7F C3 F3 78 */ mr r3, r30
/* 8030FB74 0030CAD4 90 1D 00 64 */ stw r0, 0x64(r29)
/* 8030FB78 0030CAD8 48 02 F1 0D */ bl ReadLong__12CInputStreamFv
@ -2116,7 +2116,7 @@ lbl_8030FDA0:
lbl_8030FDC8:
/* 8030FDC8 0030CD28 7C 1A F8 00 */ cmpw r26, r31
/* 8030FDCC 0030CD2C 41 80 FF C4 */ blt lbl_8030FD90
/* 8030FDD0 0030CD30 88 0D A8 78 */ lbz r0, lbl_805A9438@sda21(r13)
/* 8030FDD0 0030CD30 88 0D A8 78 */ lbz r0, sMangleMips__8CTexture@sda21(r13)
/* 8030FDD4 0030CD34 28 00 00 00 */ cmplwi r0, 0
/* 8030FDD8 0030CD38 41 82 00 30 */ beq lbl_8030FE08
/* 8030FDDC 0030CD3C 7F BB EB 78 */ mr r27, r29
@ -2191,7 +2191,7 @@ __ct__8CTextureF12ETexelFormatssi:
/* 8030FED8 0030CE38 90 1B 00 1C */ stw r0, 0x1c(r27)
/* 8030FEDC 0030CE3C 90 DB 00 40 */ stw r6, 0x40(r27)
/* 8030FEE0 0030CE40 48 04 8C 1D */ bl __ct__10CARAMTokenFv
/* 8030FEE4 0030CE44 80 0D A8 70 */ lwz r0, lbl_805A9430@sda21(r13)
/* 8030FEE4 0030CE44 80 0D A8 70 */ lwz r0, sCurrentFrameCount__8CTexture@sda21(r13)
/* 8030FEE8 0030CE48 7F 63 DB 78 */ mr r3, r27
/* 8030FEEC 0030CE4C 7F 84 E3 78 */ mr r4, r28
/* 8030FEF0 0030CE50 7F A5 EB 78 */ mr r5, r29

View File

@ -495,7 +495,7 @@ lbl_80106FC8:
/* 80107008 00103F68 83 81 00 AC */ lwz r28, 0xac(r1)
/* 8010700C 00103F6C 38 03 FF FF */ addi r0, r3, 0x7FFFFFFF@l
/* 80107010 00103F70 3B 01 00 7C */ addi r24, r1, 0x7c
/* 80107014 00103F74 90 0D A8 70 */ stw r0, lbl_805A9430@sda21(r13)
/* 80107014 00103F74 90 0D A8 70 */ stw r0, sCurrentFrameCount__8CTexture@sda21(r13)
/* 80107018 00103F78 3F C0 00 10 */ lis r30, 0x10
/* 8010701C 00103F7C 48 00 01 20 */ b lbl_8010713C
lbl_80107020:
@ -587,7 +587,7 @@ lbl_8010713C:
lbl_80107154:
/* 80107154 001040B4 88 01 00 08 */ lbz r0, 8(r1)
/* 80107158 001040B8 38 60 00 00 */ li r3, 0
/* 8010715C 001040BC 90 6D A8 70 */ stw r3, lbl_805A9430@sda21(r13)
/* 8010715C 001040BC 90 6D A8 70 */ stw r3, sCurrentFrameCount__8CTexture@sda21(r13)
/* 80107160 001040C0 38 7F 01 2C */ addi r3, r31, 0x12c
/* 80107164 001040C4 38 81 00 10 */ addi r4, r1, 0x10
/* 80107168 001040C8 98 01 00 0C */ stb r0, 0xc(r1)

View File

@ -8989,7 +8989,7 @@ FrameBegin__13CStateManagerFUi:
/* 8004B56C 000484CC 90 83 08 D4 */ stw r4, 0x8d4(r3)
/* 8004B570 000484D0 38 80 00 02 */ li r4, 2
/* 8004B574 000484D4 80 03 08 D4 */ lwz r0, 0x8d4(r3)
/* 8004B578 000484D8 90 0D A8 70 */ stw r0, lbl_805A9430@sda21(r13)
/* 8004B578 000484D8 90 0D A8 70 */ stw r0, sCurrentFrameCount__8CTexture@sda21(r13)
/* 8004B57C 000484DC 80 03 08 D4 */ lwz r0, 0x8d4(r3)
/* 8004B580 000484E0 90 0D A8 68 */ stw r0, sCurrentFrameCount__16CGraphicsPalette@sda21(r13)
/* 8004B584 000484E4 4B FF FF D5 */ bl SwapOutTexturesToARAM__13CStateManagerFiUi

View File

@ -146,7 +146,7 @@ lbl_80208F08:
/* 80208F0C 00205E6C 38 81 00 AC */ addi r4, r1, 0xac
/* 80208F10 00205E70 38 63 FF FF */ addi r3, r3, 0x7FFFFFFF@l
/* 80208F14 00205E74 38 00 00 00 */ li r0, 0
/* 80208F18 00205E78 90 6D A8 70 */ stw r3, lbl_805A9430@sda21(r13)
/* 80208F18 00205E78 90 6D A8 70 */ stw r3, sCurrentFrameCount__8CTexture@sda21(r13)
/* 80208F1C 00205E7C 90 81 00 A4 */ stw r4, 0xa4(r1)
/* 80208F20 00205E80 90 81 00 A8 */ stw r4, 0xa8(r1)
/* 80208F24 00205E84 90 81 00 AC */ stw r4, 0xac(r1)
@ -344,7 +344,7 @@ lbl_802091D8:
/* 802091E8 00206148 41 80 FD 60 */ blt lbl_80208F48
/* 802091EC 0020614C 38 00 00 00 */ li r0, 0
/* 802091F0 00206150 38 61 00 A0 */ addi r3, r1, 0xa0
/* 802091F4 00206154 90 0D A8 70 */ stw r0, lbl_805A9430@sda21(r13)
/* 802091F4 00206154 90 0D A8 70 */ stw r0, sCurrentFrameCount__8CTexture@sda21(r13)
/* 802091F8 00206158 38 80 FF FF */ li r4, -1
/* 802091FC 0020615C 48 00 26 AD */ bl sub_8020b8a8
/* 80209200 00206160 80 01 00 74 */ lwz r0, 0x74(r1)

View File

@ -560,7 +560,7 @@ LIBS = [
["Kyoto/Graphics/CTevCombiners", True],
["Kyoto/Graphics/DolphinCGraphics", False],
["Kyoto/Graphics/DolphinCPalette", False],
"Kyoto/Graphics/DolphinCTexture",
["Kyoto/Graphics/DolphinCTexture", False],
["Kyoto/Math/CloseEnough", True],
"Kyoto/Math/CMatrix3f",
"Kyoto/Math/CMatrix4f",
@ -666,7 +666,7 @@ LIBS = [
"Kyoto/Animation/CVertexMorphEffect",
"Kyoto/Animation/CSkinnedModelWithAvgNormals",
["Kyoto/CTimeProvider", True],
"Kyoto/CARAMToken",
["Kyoto/CARAMToken", False],
"Kyoto/Audio/CMidiManager",
["Kyoto/Text/CFontImageDef", True],
"Kyoto/Text/CImageInstruction",

View File

@ -10,9 +10,16 @@ public:
static void PreInitializeAlloc(uint size) { mPreInitializeAlloc += size; }
static void Initialize(uint);
static void WaitForAllDMAsToComplete();
static void* GetInvalidAlloc() { return kInvalidAlloc; }
static uint GetInvalidDMAHandle() { return kInvalidHandle; }
static bool CancelDMA(uint);
static void WaitForDMACompletion(uint);
static void Free(const void* ptr);
private:
static uint mPreInitializeAlloc;
static void* kInvalidAlloc;
static int kInvalidHandle;
};
#endif // _CARAMMANAGER

View File

@ -5,7 +5,39 @@
class CARAMToken {
public:
enum EStatus {
kS_Zero,
kS_One,
};
CARAMToken();
CARAMToken(void* ptr, uint len);
CARAMToken(const CARAMToken& other);
~CARAMToken();
void PostConstruct(void* ptr, uint len, int unk);
CARAMToken& operator=(const CARAMToken& other);
void LoadToMRAM();
void LoadToARAM();
void RefreshStatus();
static void UpdateAllDMAs();
void InitiallyMoveToList();
void MoveToList(EStatus status);
void RemoveFromList();
void MakeInvalid();
void sub_803583d4();
void sub_80358388();
void* GetMRAMSafe();
private:
int x0_;
void* x4_;
void* x8_;
int xc_;
uint x10_;
int x14_;
int x18_;
bool x1c_24_ : 1;
};
#endif // _CARAMTOKEN

View File

@ -3,12 +3,7 @@
#include "types.h"
class IDvdRequest {
public:
virtual ~IDvdRequest() = 0; // 8
virtual void Unknown1(bool) = 0; // c
virtual bool IsComplete() = 0; // 10
};
#include "Kyoto/IDvdRequest.hpp"
class CDvdFile {
public:

View File

@ -0,0 +1,10 @@
#ifndef _CDVDREQUEST
#define _CDVDREQUEST
#include "Kyoto/IDvdRequest.hpp"
class CDvdRequest : public IDvdRequest {
};
#endif // _CDVDREQUEST

View File

@ -3,9 +3,14 @@
#include "types.h"
#include <dolphin/gx/GXEnum.h>
#include "Kyoto/CARAMToken.hpp"
#include "rstl/single_ptr.hpp"
#include <dolphin/gx.h>
class CDvdRequest;
class CInputStream;
class CGraphicsPalette;
enum ETexelFormat {
kTF_Invalid = -1,
@ -24,6 +29,16 @@ enum ETexelFormat {
class CTexture {
public:
class CDumpedBitmapDataReloader {
int x0_;
uint x4_;
int x8_;
uint xc_;
bool x10_;
rstl::single_ptr< CDvdRequest > x14_;
rstl::single_ptr< uchar > x18_;
};
enum EClampMode {
kCM_Clamp,
kCM_Repeat,
@ -48,22 +63,50 @@ public:
void* GetBitMapData(int);
static void InvalidateTexmap(GXTexMapID id);
uint GetTexelFormat() const { return mTexelFormat; }
void InitBitmapBuffers(ETexelFormat fmt, short w, short h, int mips);
void InitTextureObjects();
ETexelFormat GetTexelFormat() const { return mTexelFormat; }
short GetWidth() const { return mWidth; }
short GetHeight() const { return mHeight; }
void SetFlag1(bool b) { mFlag1 = b; }
void* Lock() {
mLocked = true;
return GetBitMapData(0);
}
void MakeSwappable() const;
void CountMemory() const;
void UncountMemory() const;
void SetFlag1(bool b) { mLocked = b; }
static uint TexelFormatBitsPerPixel(ETexelFormat fmt);
static void InvalidateTexmap(GXTexMapID id);
static int sCurrentFrameCount;
static int sTotalAllocatedMemory;
static bool sMangleMips;
private:
uint mTexelFormat; // TODO: Enum
ETexelFormat mTexelFormat; // TODO: Enum
short mWidth;
short mHeight;
uchar mNumMips;
uchar mBitsPerPixel;
uchar mFlag1 : 1;
uchar pad[0x5A];
bool mLocked : 1;
bool mCanLoadPalette : 1;
bool mIsPowerOfTwo : 1;
mutable bool mNoSwap : 1;
mutable bool mCounted : 1;
uchar mCanLoadObj : 1;
uint mMemoryAllocated;
rstl::single_ptr< CGraphicsPalette > mGraphicsPalette;
rstl::single_ptr< CDumpedBitmapDataReloader > mBitmapReloader;
uint mNativeFormat;
uint mNativeCIFormat;
GXTexObj mTexObj;
EClampMode mClampMode;
CARAMToken mARAMToken;
uint mFrameAllocated;
};
CHECK_SIZEOF(CTexture, 0x68)

View File

@ -0,0 +1,12 @@
#ifndef _IDVDREQUEST
#define _IDVDREQUEST
class IDvdRequest {
public:
virtual ~IDvdRequest() = 0; // 8
virtual void Unknown1(bool) = 0; // c
virtual bool IsComplete() = 0; // 10
};
#endif // _IDVDREQUEST

65
src/Kyoto/CARAMToken.cpp Normal file
View File

@ -0,0 +1,65 @@
#include "Kyoto/CARAMToken.hpp"
#include "Kyoto/Alloc/CMemorySys.hpp"
#include "Kyoto/CARAMManager.hpp"
#include "rstl/construct.hpp"
CARAMToken::CARAMToken() {
x0_ = 6;
x4_ = NULL;
x8_ = CARAMManager::GetInvalidAlloc();
xc_ = 0;
x10_ = CARAMManager::GetInvalidDMAHandle();
x14_ = 0;
x18_ = 0;
x1c_24_ = false;
InitiallyMoveToList();
}
CARAMToken::CARAMToken(void* ptr, uint len) {}
CARAMToken::CARAMToken(const CARAMToken& other)
: x0_(other.x0_)
, x4_(other.x4_)
, x8_(other.x8_)
, xc_(other.xc_)
, x10_(other.x10_)
, x14_(0)
, x18_(0)
, x1c_24_(other.x1c_24_) {
const_cast< CARAMToken& >(other).MakeInvalid();
InitiallyMoveToList();
}
CARAMToken::~CARAMToken() {
if (x10_ != CARAMManager::GetInvalidDMAHandle() && !CARAMManager::CancelDMA(x10_)) {
CARAMManager::WaitForDMACompletion(x10_);
}
RemoveFromList();
CMemory::Free(x4_);
CARAMManager::Free(x8_);
}
void CARAMToken::PostConstruct(void* ptr, uint len, int unk) {
MoveToList(kS_One);
x4_ = ptr;
xc_ = len;
x1c_24_ = unk == 0;
}
CARAMToken& CARAMToken::operator=(const CARAMToken& other) {
if (&other == this) {
return *this;
}
rstl::destroy(this);
rstl::construct(this, other);
return *this;
}
void CARAMToken::LoadToMRAM() {
}

View File

@ -0,0 +1,75 @@
#include "Kyoto/Graphics/CTexture.hpp"
#include "Kyoto/CDvdRequest.hpp"
#include "Kyoto/Graphics/CGraphicsPalette.hpp"
#include "Kyoto/Alloc/CMemorySys.hpp"
int CTexture::sCurrentFrameCount = 0;
int CTexture::sTotalAllocatedMemory = 0;
bool CTexture::sMangleMips = false;
static CTexture* sLoadedTextures[GX_MAX_TEXMAP];
CTexture::CTexture(ETexelFormat fmt, short w, short h, int mips)
: mTexelFormat(fmt)
, mWidth(w)
, mHeight(h)
, mNumMips(mips)
, mBitsPerPixel(TexelFormatBitsPerPixel(fmt))
, mLocked(false)
, mCanLoadPalette(false)
, mIsPowerOfTwo(false)
, mNoSwap(true)
, mCounted(false)
, mCanLoadObj(false)
, mMemoryAllocated(0)
, mFrameAllocated(sCurrentFrameCount)
, mNativeFormat(GX_TF_RGB565)
, mNativeCIFormat(GX_TF_C8)
, mClampMode(kCM_Repeat) {
InitBitmapBuffers(fmt, w, h, mips);
InitTextureObjects();
}
CTexture::CTexture(CInputStream& in, EAutoMipmap automip, EBlackKey blackKey) {
}
CTexture::~CTexture() {
UncountMemory();
}
void CTexture::MakeSwappable() const {
if (!mNoSwap) {
return;
}
mNoSwap = false;
}
void CTexture::CountMemory() const {
if (mCounted) {
return;
}
mCounted = true;
sTotalAllocatedMemory += mMemoryAllocated;
}
void CTexture::UncountMemory() const {
if (!mCounted) {
return;
}
mCounted = false;
sTotalAllocatedMemory -= mMemoryAllocated;
}
void CTexture::InvalidateTexmap(GXTexMapID texmap) {
sLoadedTextures[texmap] = nullptr;
}
void CTexture::sub_8030e10c() {
}