This commit is contained in:
Donkey Kong 2023-06-01 21:16:38 +09:30
parent 849b2d0eae
commit 917e81f4c2
9 changed files with 255 additions and 41 deletions

View File

@ -3,16 +3,23 @@
#include <ultra64.h>
extern u8 *D_80013AC0; // extern u8 *inbuf;
// extern u8 *D_80007284; //slide
extern u8 *D_80013AC4; //slide
extern u32 D_80013AEC; // extern u32 inptr;
extern u32 D_80013AF0; // wp
extern struct huft *D_80013AB0; //unk
extern u32 D_80013AB4; // extern u32 bb;
extern u32 D_80013AB8; // extern u32 bk;
// extern u32 crc1; //crc1
// extern u32 crc2; //crc2
extern s32 D_80013ABC; //hufts
extern u8 D_8000EDE0[]; // border
extern u16 D_8000EDF4[]; // cplens
extern u8 D_8000EE34[]; // cplext
extern u16 D_8000EE54[]; // cpdist
extern u8 D_8000EE90[]; // cpdext
extern s32 D_8000EED4; // lbits
extern s32 D_8000EED8; // dbits
extern u16 mask_bits[]; // mask_bits
#ifndef WSIZE
# define WSIZE 0x8000 /* window size--must be a power of two, and */
#endif /* at least 32K for zip's deflate method */

View File

@ -143,7 +143,7 @@ us,boot,__osSiCreateAccessQueue,80,no
us,boot,__osSiDeviceBusy,48,no
us,boot,func_80005070,336,no
us,boot,__osTimerServicesInit,140,no
us,boot,func_80001AF4,340,no
us,boot,func_80001AF4,340,yes
us,boot,__osPfsRequestOneChannel,196,no
us,boot,__osSiRawWriteIo,76,yes
us,boot,guRotate,92,no
@ -154,7 +154,7 @@ us,boot,__osPfsGetOneChannelData,156,no
us,boot,osJamMesg,336,yes
us,boot,__osSpSetPc,52,yes
us,boot,func_80007788,56,no
us,boot,func_80001C48,360,no
us,boot,func_80001C48,360,yes
us,boot,osViGetNextFramebuffer,64,yes
us,boot,guPosition,112,no
us,boot,func_80000EEC,320,no
@ -167,7 +167,7 @@ us,boot,guScale,72,yes
us,boot,osAiSetNextBuffer,164,yes
us,boot,__osDisableInt,32,yes
us,boot,__osViInit,316,yes
us,boot,func_80001DB0,1316,no
us,boot,func_80001DB0,1316,yes
us,boot,func_80000E48,164,no
us,boot,__osPackRequestData,256,no
us,boot,osPiRawStartDma,224,yes

1 version section function length matching
143 us boot __osSiDeviceBusy 48 no
144 us boot func_80005070 336 no
145 us boot __osTimerServicesInit 140 no
146 us boot func_80001AF4 340 no yes
147 us boot __osPfsRequestOneChannel 196 no
148 us boot __osSiRawWriteIo 76 yes
149 us boot guRotate 92 no
154 us boot osJamMesg 336 yes
155 us boot __osSpSetPc 52 yes
156 us boot func_80007788 56 no
157 us boot func_80001C48 360 no yes
158 us boot osViGetNextFramebuffer 64 yes
159 us boot guPosition 112 no
160 us boot func_80000EEC 320 no
167 us boot osAiSetNextBuffer 164 yes
168 us boot __osDisableInt 32 yes
169 us boot __osViInit 316 yes
170 us boot func_80001DB0 1316 no yes
171 us boot func_80000E48 164 no
172 us boot __osPackRequestData 256 no
173 us boot osPiRawStartDma 224 yes

View File

@ -4111,7 +4111,7 @@ us,boot,__osSiCreateAccessQueue,80,no
us,boot,__osSiDeviceBusy,48,no
us,boot,func_80005070,336,no
us,boot,__osTimerServicesInit,140,no
us,boot,func_80001AF4,340,no
us,boot,func_80001AF4,340,yes
us,boot,__osPfsRequestOneChannel,196,no
us,boot,__osSiRawWriteIo,76,yes
us,boot,guRotate,92,no
@ -4122,7 +4122,7 @@ us,boot,__osPfsGetOneChannelData,156,no
us,boot,osJamMesg,336,yes
us,boot,__osSpSetPc,52,yes
us,boot,func_80007788,56,no
us,boot,func_80001C48,360,no
us,boot,func_80001C48,360,yes
us,boot,osViGetNextFramebuffer,64,yes
us,boot,guPosition,112,no
us,boot,func_80000EEC,320,no
@ -4135,7 +4135,7 @@ us,boot,guScale,72,yes
us,boot,osAiSetNextBuffer,164,yes
us,boot,__osDisableInt,32,yes
us,boot,__osViInit,316,yes
us,boot,func_80001DB0,1316,no
us,boot,func_80001DB0,1316,yes
us,boot,func_80000E48,164,no
us,boot,__osPackRequestData,256,no
us,boot,osPiRawStartDma,224,yes

1 version section function length matching
4111 us boot __osSiDeviceBusy 48 no
4112 us boot func_80005070 336 no
4113 us boot __osTimerServicesInit 140 no
4114 us boot func_80001AF4 340 no yes
4115 us boot __osPfsRequestOneChannel 196 no
4116 us boot __osSiRawWriteIo 76 yes
4117 us boot guRotate 92 no
4122 us boot osJamMesg 336 yes
4123 us boot __osSpSetPc 52 yes
4124 us boot func_80007788 56 no
4125 us boot func_80001C48 360 no yes
4126 us boot osViGetNextFramebuffer 64 yes
4127 us boot guPosition 112 no
4128 us boot func_80000EEC 320 no
4135 us boot osAiSetNextBuffer 164 yes
4136 us boot __osDisableInt 32 yes
4137 us boot __osViInit 316 yes
4138 us boot func_80001DB0 1316 no yes
4139 us boot func_80000E48 164 no
4140 us boot __osPackRequestData 256 no
4141 us boot osPiRawStartDma 224 yes

View File

@ -9,7 +9,7 @@
</mask>
<g mask="url(#anybadge_1)">
<path fill="#555" d="M0 0h71v20H0z"/>
<path fill="#c08a00" d="M71 0h67v20H71z"/>
<path fill="#c09800" d="M71 0h67v20H71z"/>
<path fill="url(#b)" d="M0 0h138v20H0z"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
@ -17,7 +17,7 @@
<text x="35.5" y="14">dk64_boot</text>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="105.5" y="15" fill="#010101" fill-opacity=".3">35.9244%</text>
<text x="104.5" y="14">35.9244%</text>
<text x="105.5" y="15" fill="#010101" fill-opacity=".3">39.5587%</text>
<text x="104.5" y="14">39.5587%</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -9,7 +9,7 @@
</mask>
<g mask="url(#anybadge_1)">
<path fill="#555" d="M0 0h132v20H0z"/>
<path fill="#c06000" d="M132 0h67v20H132z"/>
<path fill="#c06100" d="M132 0h67v20H132z"/>
<path fill="url(#b)" d="M0 0h199v20H0z"/>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
@ -17,7 +17,7 @@
<text x="66.0" y="14">Donkey Kong 64 (US)</text>
</g>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<text x="166.5" y="15" fill="#010101" fill-opacity=".3">25.1246%</text>
<text x="165.5" y="14">25.1246%</text>
<text x="166.5" y="15" fill="#010101" fill-opacity=".3">25.2469%</text>
<text x="165.5" y="14">25.2469%</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -5,9 +5,9 @@
// This is equivalent to https://gitlab.com/banjo.decomp/banjo-kazooie/-/blob/master/src/done/inflate.c
s32 func_80001AF4(void); // inflate_stored();
s32 func_80001C48(void); // inflate_fixed();
s32 func_80001DB0(void); // inflate_dynamic();
int func_80001AF4(void); // inflate_stored();
int func_80001C48(void); // inflate_fixed();
int func_80001DB0(void); // inflate_dynamic();
int func_800022D4(int *e); // inflate_block();
int func_800010C0(b, n, s, d, e, t, m) // int huft_build(b, n, s, d, e, t, m)
@ -200,16 +200,11 @@ int *m; /* maximum lookup bits, returns actual */
return y != 0 && g != 1;
}
#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_80001700.s")
// TODO: Need address of:
// mask_bits
// D_80007284
// crc1
// crc2
#if FALSE
// TODO: Hmmmm....
//^inflate_codes
/* static */ int func_80001700(struct huft *tl, struct huft *td, s32 bl, s32 bd) // int inflate_codes(struct huft *tl, struct huft *td, s32 bl, s32 bd)
{
@ -232,7 +227,7 @@ int *m; /* maximum lookup bits, returns actual */
md = mask_bits[bd];
for (;;) /* do until end of block */
{
{//L80000D78
NEEDBITS((unsigned)bl)
if ((e = (t = tl + ((unsigned)b & ml))->e) > 16)
do {
@ -245,44 +240,45 @@ int *m; /* maximum lookup bits, returns actual */
{
tmp = (u8)t->v.n;
D_80007284[w++] = tmp;
crc1 += tmp;
crc2 ^= tmp << (crc1 & 0x17);
D_80013AC4[w++] = tmp;
// crc1 += tmp;
// crc2 ^= tmp << (crc1 & 0x17);
}
else /* it's an EOB or a length */
{
{//L80000EAC
/* exit if end of block */
if (e == 15)
break;
/* get length of block to copy */
NEEDBITS(e)
NEEDBITS(e) //L80000EAC - L80000ED8
n = t->v.n + ((unsigned)b & mask_bits[e]);
DUMPBITS(e);
/* decode distance of block to copy */
NEEDBITS((unsigned)bd)
NEEDBITS((unsigned)bd)//L80000F04 - L80000F2C
if ((e = (t = td + ((unsigned)b & md))->e) > 16)
do {
DUMPBITS(t->b)
e -= 16;
NEEDBITS(e)
} while ((e = (t = t->v.t + ((unsigned)b & mask_bits[e]))->e) > 16);
//L80000FC8
DUMPBITS(t->b)
NEEDBITS(e)
NEEDBITS(e) //L80000FE0 - L80001008
d = w - t->v.n - ((unsigned)b & mask_bits[e]);
DUMPBITS(e)
/* do the copy */
do{
tmp = D_80007284[d++];
D_80007284[w++] = tmp;
crc1 += tmp;
crc2 ^= tmp << (crc1 & 0x17);
tmp = D_80013AC4[d++];
D_80013AC4[w++] = tmp;
// crc1 += tmp;
// crc2 ^= tmp << (crc1 & 0x17);
}while(--n);
}
}
/* restore the globals from the locals */
D_80013AF0 = w; // wp = w; /* restore global window pointer */
D_80013AB4 = b; // bb = b; /* restore global bit buffer */
@ -291,13 +287,197 @@ int *m; /* maximum lookup bits, returns actual */
/* done */
return 0;
}
#endif
#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_80001AF4.s")
/* static */ int func_80001AF4(void) // int inflate_stored(void)
/* "decompress" an inflated type 0 (stored) block. */
{
unsigned n; /* number of bytes in block */
unsigned w; /* current window position */
register u32 b; /* bit buffer */
register unsigned k; /* number of bits in bit buffer */
#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_80001C48.s")
/* make local copies of globals */
b = D_80013AB4; /* initialize bit buffer */
k = D_80013AB8;
w = D_80013AF0; /* initialize window position */
/* go to byte boundary */
n = k & 7;
DUMPBITS(n);
/* get the length and its complement */
NEEDBITS(16)
n = ((unsigned)b & 0xffff);
DUMPBITS(16)
NEEDBITS(16)
DUMPBITS(16)
/* read and output the compressed data */
while (n--)
{
NEEDBITS(8)
D_80013AC4[w++] = (u8) b;
DUMPBITS(8)
}
/* restore the globals from the locals */
D_80013AF0 = w; /* restore global window pointer */
D_80013AB4 = b; /* restore global bit buffer */
D_80013AB8 = k;
return 0;
}
/* static */ int func_80001C48(void) //int inflate_fixed(void)
/* decompress an inflated type 1 (fixed Huffman codes) block. We should
either replace this with a custom decoder, or at least precompute the
Huffman tables. */
{
int i; /* temporary variable */
struct huft *tl; /* literal/length code table */
struct huft *td; /* distance code table */
int bl; /* lookup bits for tl */
int bd; /* lookup bits for td */
unsigned l[288]; /* length list for huft_build */
/* set up literal table */
for (i = 0; i < 144; i++)
l[i] = 8;
for (; i < 256; i++)
l[i] = 9;
for (; i < 280; i++)
l[i] = 7;
for (; i < 288; i++) /* make a complete, but wrong code set */
l[i] = 8;
bl = 7;
func_800010C0(l, 288, 257, D_8000EDF4, D_8000EE34, &tl, &bl);
/* set up distance table */
for (i = 0; i < 30; i++) /* make an incomplete code set */
l[i] = 5;
bd = 5;
func_800010C0(l, 30, 0, D_8000EE54, D_8000EE90, &td, &bd);
/* decompress until an end-of-block code */
func_80001700(tl, td, bl, bd);
return 0;
}
/* static */ int func_80001DB0(void) //int inflate_dynamic(void)/* decompress an inflated type 2 (dynamic Huffman codes) block. */
{
int i; /* temporary variables */
unsigned j;
unsigned l; /* last length */
unsigned m; /* mask for bit lengths table */
unsigned n; /* number of lengths to get */
struct huft *tl; /* literal/length code table */
struct huft *td; /* distance code table */
int bl; /* lookup bits for tl */
int bd; /* lookup bits for td */
unsigned nb; /* number of bit length codes */
unsigned nl; /* number of literal/length codes */
unsigned nd; /* number of distance codes */
register unsigned k; /* number of bits in bit buffer */
register u32 b; /* bit buffer */
unsigned ll[286+30]; /* literal/length and distance code lengths */
/* make local bit buffer */
b = D_80013AB4;
k = D_80013AB8;
/* read in table lengths */
NEEDBITS(5)
nl = 257 + ((unsigned)b & 0x1f); /* number of literal/length codes */
DUMPBITS(5)
NEEDBITS(5)
nd = 1 + ((unsigned)b & 0x1f); /* number of distance codes */
DUMPBITS(5)
NEEDBITS(4)
nb = 4 + ((unsigned)b & 0xf); /* number of bit length codes */
DUMPBITS(4)
/* read in bit-length-code lengths */
for (j = 0; j < nb; j++)
{
NEEDBITS(3)
ll[D_8000EDE0[j]] = (unsigned)b & 7;
DUMPBITS(3)
}
for (; j < 19; j++)
ll[D_8000EDE0[j]] = 0;
/* build decoding table for trees--single level, 7 bit lookup */
bl = 7;
func_800010C0(ll, 19, 19, NULL, NULL, &tl, &bl);
/* read in literal and distance code lengths */
n = nl + nd;
m = mask_bits[bl];
i = l = 0;
while ((unsigned)i < n)
{
NEEDBITS((unsigned)bl)
j = (td = tl + ((unsigned)b & m))->b;
DUMPBITS(j)
j = td->v.n;
if (j < 16) /* length of code in bits (0..15) */
ll[i++] = l = j; /* save last length in l */
else if (j == 16) /* repeat last length 3 to 6 times */
{
NEEDBITS(2)
j = 3 + ((unsigned)b & 3);
DUMPBITS(2)
while (j--)
ll[i++] = l;
}
else if (j == 17) /* 3 to 10 zero length codes */
{
NEEDBITS(3)
j = 3 + ((unsigned)b & 7);
DUMPBITS(3)
while (j--)
ll[i++] = 0;
l = 0;
}
else /* j == 18: 11 to 138 zero length codes */
{
NEEDBITS(7)
j = 11 + ((unsigned)b & 0x7f);
DUMPBITS(7)
while (j--)
ll[i++] = 0;
l = 0;
}
}
/* restore the global bit buffer */
D_80013AB4 = b;
D_80013AB8 = k;
/* build the decoding tables for literal/length and distance codes */
bl = D_8000EED4;
func_800010C0(ll, nl, 257, D_8000EDF4, D_8000EE34, &tl, &bl);
bd = D_8000EED8;
func_800010C0(ll + nl, nd, 0, D_8000EE54, D_8000EE90, &td, &bd);
/* decompress until an end-of-block code */
func_80001700(tl, td, bl, bd);
return 0;
}
#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/dk64_boot_1CC0/func_80001DB0.s")
/* static */ int func_800022D4(int *e) // inflate_block()
/* decompress an inflated block */

View File

@ -186,3 +186,12 @@ __osBaseCounter = 0x80014FE8;
__osViIntrCount = 0x80014FEC;
__osTimerCounter = 0x80014FF0;
__osEepPifRam = 0x800162E0;
D_8000EDE0 = 0x8000EDE0;
D_8000EDF4 = 0x8000EDF4;
D_8000EE34 = 0x8000EE34;
D_8000EE54 = 0x8000EE54;
D_8000EE90 = 0x8000EE90;
mask_bits = 0x8000EEB0;
D_8000EED4 = 0x8000EED4;
D_8000EED8 = 0x8000EED8;

View File

@ -287,3 +287,12 @@ D_8075E908 = 0x8075E908;
D_8075E970 = 0x8075E970;
D_80744748 = 0x80744748;
D_8000EDE0 = 0x8000EDE0;
D_8000EDF4 = 0x8000EDF4;
D_8000EE34 = 0x8000EE34;
D_8000EE54 = 0x8000EE54;
D_8000EE90 = 0x8000EE90;
mask_bits = 0x8000EEB0;
D_8000EED4 = 0x8000EED4;
D_8000EED8 = 0x8000EED8;

View File

@ -26,3 +26,12 @@ D_1FED020 = 0x1FED020;
D_80100000 = 0x80100000;
D_80280000 = 0x80280000;
D_8000EDE0 = 0x8000EDE0;
D_8000EDF4 = 0x8000EDF4;
D_8000EE34 = 0x8000EE34;
D_8000EE54 = 0x8000EE54;
D_8000EE90 = 0x8000EE90;
mask_bits = 0x8000EEB0;
D_8000EED4 = 0x8000EED4;
D_8000EED8 = 0x8000EED8;