summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-06-24 14:24:45 +0200
committerTreeki <treeki@gmail.com>2011-06-24 14:24:45 +0200
commit673484e580337cd1ab14bfd43c770f004494b9a4 (patch)
tree59ad19982b31a0a81c48bd51c1749c49e2425a42
parent14f66f5e100561a71f2fe2be957b74c16303b8b1 (diff)
downloadkamek-673484e580337cd1ab14bfd43c770f004494b9a4.tar.gz
kamek-673484e580337cd1ab14bfd43c770f004494b9a4.zip
added the compression updates from master
Diffstat (limited to '')
-rw-r--r--NewerProject.yaml1
-rw-r--r--compression.yaml18
-rw-r--r--src/compression.S127
3 files changed, 146 insertions, 0 deletions
diff --git a/NewerProject.yaml b/NewerProject.yaml
index 367d0c5..727447c 100644
--- a/NewerProject.yaml
+++ b/NewerProject.yaml
@@ -18,3 +18,4 @@ modules:
# - processed/replay.yaml
- processed/growup.yaml
- processed/levelspecial.yaml
+ - processed/compression.yaml
diff --git a/compression.yaml b/compression.yaml
new file mode 100644
index 0000000..9d3a058
--- /dev/null
+++ b/compression.yaml
@@ -0,0 +1,18 @@
+---
+source_files: [../src/compression.S]
+hooks:
+ - name: InitialiseEverything
+ type: branch_insn
+ branch_type: b
+ src_addr_pal: 0x8015BC70
+ target_func: 'InitCompression'
+
+ - name: GetFileEntrynumNew
+ type: branch_insn
+ branch_type: b
+ src_addr_pal: 0x8016BD70
+ target_func: 'GetFileEntrynumNew'
+
+ - name: FixStreamingLHDecompression
+ type: nop_insn
+ area_pal: 0x801D7884
diff --git a/src/compression.S b/src/compression.S
new file mode 100644
index 0000000..dfa2894
--- /dev/null
+++ b/src/compression.S
@@ -0,0 +1,127 @@
+.text
+.align 4
+.set sp, 1
+
+#ifndef __MWERKS__
+.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
+.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
+.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
+.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
+.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
+.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
+.set r30,30; .set r31,31; .set f0,0; .set f2,2; .set f3,3
+.set f1,1; .set f30,30; .set f31,31
+#endif
+
+.extern StoreCompressionClassList
+
+.extern SZSDecompClass
+.extern LZDecompClass
+.extern LHDecompClass
+.extern LRCDecompClass
+.extern RLDecompClass
+
+.extern DecompBufferPointer
+
+.extern AllocFromGameHeap1
+.extern OSReport
+
+.extern TryAndFindCompressedFile
+.extern DVDConvertPathToEntrynum
+
+.global InitCompression
+InitCompression:
+ stwu sp, -0x10(sp)
+ mflr r0
+ stw r0, 0x14(sp)
+ # -- Prolog
+
+ lis r3, CMsg@h
+ ori r3, r3, CMsg@l
+ crclr 4*cr1+eq
+ bl OSReport
+
+ lis r3, CCCL@h
+ ori r3, r3, CCCL@l
+ lis r4, CCCL_End@h
+ ori r4, r4, CCCL_End@l
+ bl StoreCompressionClassList
+
+ # Allocate a buffer for decompression stuff
+ li r3, 0x8B4
+ bl AllocFromGameHeap1
+ lis r4, DecompBufferPointer@h
+ ori r4, r4, DecompBufferPointer@l
+ stw r3, 0(r4)
+
+ mr r4, r3
+ lis r3, CMsg2@h
+ ori r3, r3, CMsg2@l
+ crclr 4*cr1+eq
+ bl OSReport
+
+ # -- Epilog
+ li r3, 1
+ lwz r0, 0x14(sp)
+ mtlr r0
+ addi sp, sp, 0x10
+ blr
+
+
+.global GetFileEntrynumNew
+GetFileEntrynumNew:
+ stwu sp, -0x20(sp)
+ mflr r0
+ stw r0, 0x24(sp)
+ stw r31, 0x1C(sp)
+ stw r30, 0x18(sp)
+ stw r29, 0x14(sp)
+ # Compression Type pointer (byte*)
+ mr r30, r4
+ # Filename
+ mr r29, r3
+
+ # first, try compression
+ # don't bother checking 5278, it's always on in NSMBW anyway
+ bl TryAndFindCompressedFile
+ cmpwi r3, -1
+ bne returnEntrynum
+
+ # didn't find it, so try the normal version
+ mr r3, r29
+ bl DVDConvertPathToEntrynum
+ # return value gets passed through
+
+ cmpwi r30, 0
+ beq returnEntrynum
+ li r0, 0
+ stb r0, 0(r30)
+
+returnEntrynum:
+ lwz r31, 0x1C(sp)
+ lwz r30, 0x18(sp)
+ lwz r29, 0x14(sp)
+ lwz r0, 0x24(sp)
+ mtlr r0
+ addi sp, sp, 0x20
+ blr
+
+
+.data
+CCCL:
+ .long LHDecompClass
+ .long LZDecompClass
+CCCL_End:
+ .long 0
+
+CMsg:
+ .string "Setting up fancy decompression!\n"
+
+CMsg2:
+ .string "Buffer: %p\n"
+
+.align 4
+
+
+
+