This commit is contained in:
Donkey Kong 2024-11-03 18:37:01 -06:00
parent c8fc4856e4
commit f5132b6a4a
11 changed files with 90 additions and 20 deletions

View File

@ -321,7 +321,7 @@ clean:
build/us/src/dk64_boot/dk64_boot_3390.c.o: OPT_FLAGS = -O2
build/us/src/dk64_boot/dk64_boot_3D20.c.o: OPT_FLAGS = -O2
build/us/src/dk64_boot/dk64_boot_3C00.c.o: OPT_FLAGS = -O1
build/us/src/dk64_boot/dk64_boot_5C70.c.o: OPT_FLAGS = -O2
build/us/src/dk64_boot/io/aisetfreq.c.o: OPT_FLAGS = -O2
build/us/src/dk64_boot/dk64_boot_61D0.c.o: OPT_FLAGS = -O1
build/us/src/dk64_boot/dk64_boot_62F0.c.o: OPT_FLAGS = -O1
build/us/src/dk64_boot/ll.c.o: OPT_FLAGS = -O1

View File

@ -65,7 +65,7 @@ segments:
- [0x5890, c, io/vimgr]
- [0x5BA0, c, io/visetmode] #DONE
- [0x5C10, bin, dk64_boot_5C10] #??? nops ???
- [0x5C70, c, dk64_boot_5C70]
- [0x5C70, c, io/aisetfreq]
- [0x5DC0, hasm, libc/bzero] #DONE
- [0x5E60, hasm, os/invalicache] #DONE
- [0x5EE0, hasm, os/writebackdcacheall] #DONE

View File

@ -90,8 +90,8 @@ void *memcpy(void *dest, void *src, u32 n);
// dk64_boot/io/vimgr.c
// TODO: viMgrMain has no documented signature
// dk64_boot/dk64_boot_5C70.c
s32 func_dk64_boot_80005070(u32 frequency); //s32 osAiSetFrequency(u32 frequency)
// dk64_boot/io/aisetfreq.c
s32 osAiSetFrequency(u32 frequency); //s32 osAiSetFrequency(u32 frequency)
// TODO: osWriteBackDCacheAll has no documented signature but has been matched
// dk64_boot/dk64_boot_61D0.c

View File

@ -28,7 +28,6 @@ us,boot,__osSpGetStatus,12,yes
us,boot,strchr,76,yes
us,boot,__ull_rshift,44,yes
us,boot,__osSetFpcCsr,16,yes
us,boot,func_dk64_boot_80005070,324,yes
us,boot,osCreateMesgQueue,44,yes
us,boot,__osEepStatus,428,no
us,boot,func_dk64_boot_800024E0,196,yes
@ -143,6 +142,7 @@ us,boot,osSetTimer,212,yes
us,boot,__osPackRamWriteDataSafe,128,no
us,boot,sqrtf,16,yes
us,boot,__osInsertTimer,392,yes
us,boot,osAiSetFrequency,324,yes
us,boot,func_dk64_boot_800073D0,132,yes
us,boot,func_dk64_boot_800004B4,64,yes
us,boot,__osPackEepReadData,140,no
@ -198,7 +198,7 @@ us,boot,__osPopThread,16,yes
us,boot,func_dk64_boot_800023F4,232,yes
us,boot,func_dk64_boot_8000320C,4884,no
us,boot,__ll_mul,48,yes
us,boot,__osContAddressCrc,208,no
us,boot,__osContAddressCrc,208,yes
us,boot,__ll_div,92,yes
us,boot,osGetTime,132,yes
us,boot,func_dk64_boot_80000EEC,320,no
@ -225,7 +225,7 @@ us,boot,func_dk64_boot_80005A70,12,yes
us,boot,__cosf,360,yes
us,boot,guOrtho,104,yes
us,boot,__osGetSR,16,yes
us,boot,__osContDataCrc,160,no
us,boot,__osContDataCrc,148,yes
us,boot,osInvalDCache,176,yes
us,boot,__osSpRawStartDma,140,yes
us,boot,osMapTLBRdb,96,yes

1 version section function length matching
28 us boot strchr 76 yes
29 us boot __ull_rshift 44 yes
30 us boot __osSetFpcCsr 16 yes
us boot func_dk64_boot_80005070 324 yes
31 us boot osCreateMesgQueue 44 yes
32 us boot __osEepStatus 428 no
33 us boot func_dk64_boot_800024E0 196 yes
142 us boot __osPackRamWriteDataSafe 128 no
143 us boot sqrtf 16 yes
144 us boot __osInsertTimer 392 yes
145 us boot osAiSetFrequency 324 yes
146 us boot func_dk64_boot_800073D0 132 yes
147 us boot func_dk64_boot_800004B4 64 yes
148 us boot __osPackEepReadData 140 no
198 us boot func_dk64_boot_800023F4 232 yes
199 us boot func_dk64_boot_8000320C 4884 no
200 us boot __ll_mul 48 yes
201 us boot __osContAddressCrc 208 no yes
202 us boot __ll_div 92 yes
203 us boot osGetTime 132 yes
204 us boot func_dk64_boot_80000EEC 320 no
225 us boot __cosf 360 yes
226 us boot guOrtho 104 yes
227 us boot __osGetSR 16 yes
228 us boot __osContDataCrc 160 148 no yes
229 us boot osInvalDCache 176 yes
230 us boot __osSpRawStartDma 140 yes
231 us boot osMapTLBRdb 96 yes

View File

@ -4303,7 +4303,6 @@ us,boot,__osSpGetStatus,12,yes
us,boot,strchr,76,yes
us,boot,__ull_rshift,44,yes
us,boot,__osSetFpcCsr,16,yes
us,boot,func_dk64_boot_80005070,324,yes
us,boot,osCreateMesgQueue,44,yes
us,boot,__osEepStatus,428,no
us,boot,func_dk64_boot_800024E0,196,yes
@ -4418,6 +4417,7 @@ us,boot,osSetTimer,212,yes
us,boot,__osPackRamWriteDataSafe,128,no
us,boot,sqrtf,16,yes
us,boot,__osInsertTimer,392,yes
us,boot,osAiSetFrequency,324,yes
us,boot,func_dk64_boot_800073D0,132,yes
us,boot,func_dk64_boot_800004B4,64,yes
us,boot,__osPackEepReadData,140,no
@ -4473,7 +4473,7 @@ us,boot,__osPopThread,16,yes
us,boot,func_dk64_boot_800023F4,232,yes
us,boot,func_dk64_boot_8000320C,4884,no
us,boot,__ll_mul,48,yes
us,boot,__osContAddressCrc,208,no
us,boot,__osContAddressCrc,208,yes
us,boot,__ll_div,92,yes
us,boot,osGetTime,132,yes
us,boot,func_dk64_boot_80000EEC,320,no
@ -4500,7 +4500,7 @@ us,boot,func_dk64_boot_80005A70,12,yes
us,boot,__cosf,360,yes
us,boot,guOrtho,104,yes
us,boot,__osGetSR,16,yes
us,boot,__osContDataCrc,160,no
us,boot,__osContDataCrc,148,yes
us,boot,osInvalDCache,176,yes
us,boot,__osSpRawStartDma,140,yes
us,boot,osMapTLBRdb,96,yes

1 version section function length matching
4303 us boot strchr 76 yes
4304 us boot __ull_rshift 44 yes
4305 us boot __osSetFpcCsr 16 yes
us boot func_dk64_boot_80005070 324 yes
4306 us boot osCreateMesgQueue 44 yes
4307 us boot __osEepStatus 428 no
4308 us boot func_dk64_boot_800024E0 196 yes
4417 us boot __osPackRamWriteDataSafe 128 no
4418 us boot sqrtf 16 yes
4419 us boot __osInsertTimer 392 yes
4420 us boot osAiSetFrequency 324 yes
4421 us boot func_dk64_boot_800073D0 132 yes
4422 us boot func_dk64_boot_800004B4 64 yes
4423 us boot __osPackEepReadData 140 no
4473 us boot func_dk64_boot_800023F4 232 yes
4474 us boot func_dk64_boot_8000320C 4884 no
4475 us boot __ll_mul 48 yes
4476 us boot __osContAddressCrc 208 no yes
4477 us boot __ll_div 92 yes
4478 us boot osGetTime 132 yes
4479 us boot func_dk64_boot_80000EEC 320 no
4500 us boot __cosf 360 yes
4501 us boot guOrtho 104 yes
4502 us boot __osGetSR 16 yes
4503 us boot __osContDataCrc 160 148 no yes
4504 us boot osInvalDCache 176 yes
4505 us boot __osSpRawStartDma 140 yes
4506 us boot osMapTLBRdb 96 yes

View File

@ -9,7 +9,7 @@
</mask>
<g mask="url(#anybadge_1)">
<path fill="#555" d="M0 0h71v20H0z"/>
<path fill="#94c000" d="M71 0h67v20H71z"/>
<path fill="#92c000" 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">61.3787%</text>
<text x="104.5" y="14">61.3787%</text>
<text x="105.5" y="15" fill="#010101" fill-opacity=".3">62.0421%</text>
<text x="104.5" y="14">62.0421%</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -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">41.4643%</text>
<text x="165.5" y="14">41.4643%</text>
<text x="166.5" y="15" fill="#010101" fill-opacity=".3">41.4867%</text>
<text x="165.5" y="14">41.4867%</text>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -88,7 +88,7 @@ void func_dk64_boot_800005A8(void *arg0) {
func_dk64_boot_80000A30();
} else {
func_dk64_boot_80000450(&D_11320, &D_113F0, 0x805FB000);
D_dk64_boot_8000DCB4 = func_dk64_boot_80005070(22050); // osAiSetFrequency
D_dk64_boot_8000DCB4 = osAiSetFrequency(22050); // osAiSetFrequency
bzero(0x805FB300, 0x204D00);
sp34 = 0x80020000;
sp30 = 0x805FB300;

View File

@ -4,8 +4,7 @@
#include <rcp.h>
#include "osint.h"
s32 func_dk64_boot_80005070(u32 frequency) //s32 osAiSetFrequency(u32 frequency)
{
s32 osAiSetFrequency(u32 frequency) {
register unsigned int dacRate;
register unsigned char bitRate;
register float f;

View File

@ -1,6 +1,76 @@
#include <ultra64.h>
#define ADDRESS_CRC_MESSAGE_LENGTH 10
#define ADDRESS_CRC_LENGTH 5
#define ADDRESS_CRC_GENERATOR 0x15
#define ADDRESS_CRC_MASK ((1 << ADDRESS_CRC_LENGTH) - 1)
#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/crc/__osContAddressCrc.s")
u8 __osContAddressCrc(u16 addr) {
u32 addr32 = addr;
u32 ret = 0;
u32 bit;
s32 i;
#pragma GLOBAL_ASM("asm/nonmatchings/dk64_boot/io/crc/__osContDataCrc.s")
// ret is used as a shift register for the CRC
for (bit = (1 << ADDRESS_CRC_MESSAGE_LENGTH); bit != 0; bit >>= 1) {
ret <<= 1;
if (addr32 & bit) {
if (ret & (1 << ADDRESS_CRC_LENGTH)) {
// Same as ret++; ret ^= 0x15 since last bit always 0 after the shift
ret ^= ADDRESS_CRC_GENERATOR - 1;
} else {
ret++;
}
} else if (ret & (1 << ADDRESS_CRC_LENGTH)) {
ret ^= ADDRESS_CRC_GENERATOR;
}
}
// Acts like 5 bits of 0s are appended to addr
for (i = 0; i < ADDRESS_CRC_LENGTH; i++) {
ret <<= 1;
if (ret & (1 << ADDRESS_CRC_LENGTH)) {
ret ^= ADDRESS_CRC_GENERATOR;
}
}
// Discard the irrelevant bits above the actual remainder
return ret & ADDRESS_CRC_MASK;
}
#define DATA_CRC_MESSAGE_BYTES 32
#define DATA_CRC_LENGTH 8
#define DATA_CRC_GENERATOR 0x85
u8 __osContDataCrc(u8* data) {
s32 ret = 0;
u32 bit;
u32 byte;
for (byte = DATA_CRC_MESSAGE_BYTES; byte != 0; byte--, data++) {
// Loop over each bit in the byte starting with most significant
for (bit = (1 << (DATA_CRC_LENGTH - 1)); bit != 0; bit >>= 1) {
ret <<= 1;
if (*data & bit) {
if (ret & (1 << DATA_CRC_LENGTH)) {
// Same as ret++; ret ^= 0x85 since last bit always 0 after the shift
ret ^= DATA_CRC_GENERATOR - 1;
} else {
ret++;
}
} else if (ret & (1 << DATA_CRC_LENGTH)) {
ret ^= DATA_CRC_GENERATOR;
}
}
}
// Act like a byte of zeros is appended to data
do {
ret <<= 1;
if (ret & (1 << DATA_CRC_LENGTH)) {
ret ^= DATA_CRC_GENERATOR;
}
byte++;
} while (byte < DATA_CRC_LENGTH);
// Discarding the excess is done automatically by the return type
return ret;
}

View File

@ -93,6 +93,7 @@ __ll_to_d = 0x80007724; // segment:dk64_boot
__ll_to_f = 0x8000773C; // segment:dk64_boot
__ull_to_d = 0x80007754; // segment:dk64_boot
__ull_to_f = 0x80007788; // segment:dk64_boot
osAiSetFrequency = 0x80005070; // segment:dk64_boot
osContSetCh = 0x80007360; // segment:dk64_boot
osSetTimer = 0x800077C0; // segment:dk64_boot