start Pal WIP

This commit is contained in:
Banjo Kazooie
2024-09-04 01:30:42 -05:00
parent 98e97f4e95
commit 06e1330e71
17 changed files with 2936 additions and 188 deletions

View File

@@ -1,13 +1,16 @@
#include <ultra64.h>
#include "functions.h"
#include "variables.h"
#include "version.h"
#include "gc/gctransition.h"
void func_8023E00C(enum map_e);
void func_8023DFF0(s32);
#if VERSION == VERSION_PAL
extern s32 D_80000300;
#endif
s32 D_80275610 = 0;
s32 D_80275614 = 0;
@@ -16,10 +19,9 @@ u32 D_8027561C[] = {
0x9, 0x4, 0xA, 0x3, 0xB, 0x2, 0xC, 0x5, 0x0,
0x1, 0x6, 0xD, -1
};
u32 D_80275650 = 0xAD019D3C; //SM_DATA_CRC_1
u32 D_80275654 = 0xD381B72F; //SM_DATA_CRC_2
char D_80275658[] = "HjunkDire:218755";
u32 D_80275650 = VER_SELECT(0xAD019D3C, 0xA371A8F3, 0, 0); //SM_DATA_CRC_1
u32 D_80275654 = VER_SELECT(0xD381B72F, 0xD0709154, 0, 0); //SM_DATA_CRC_2
char D_80275658[] = VER_SELECT("HjunkDire:218755", "HjunkDire:300875", "HjunkDire:", "HjunkDire:");
/* .bss */
u32 D_8027A130;
@@ -99,6 +101,9 @@ void func_8023DBDC(void){
}
void core1_init(void){
#if VERSION == VERSION_PAL
D_80000300 = 0;
#endif
func_80255C30();
func_8023E00C(func_8023DBA4());
rarezip_init(); //initialize decompressor's huft table

View File

@@ -1,9 +1,12 @@
#include <ultra64.h>
#include "functions.h"
#include "variables.h"
#include "version.h"
#include "2.0L/PR/sched.h"
#include "n_libaudio.h"
#define AUDIO_HEAP_SIZE VER_SELECT(0x21000, 0x23A00, 0x21000, 0x21000)
extern void n_alInit(N_ALGlobals *, ALSynConfig *);
typedef struct AudioInfo_s {
@@ -144,12 +147,12 @@ struct {
} audioManager;
u8 pad_8027C178[0xE78];
ALHeap D_8027CFF0;
u8 * D_8027D000;
u8 * D_8027D000;
s32 D_8027D004;
OSMesgQueue D_8027D008;
OSMesg D_8027D020[50];
OSMesg D_8027D020[3000/FRAMERATE];
OSIoMesg D_8027D0E8;
Struct_core1_1D00_4 D_8027D100[50];
Struct_core1_1D00_4 D_8027D100[3000/FRAMERATE];
struct {
u8 unk0;
Struct_1D00_3 *unk4;
@@ -282,11 +285,16 @@ void func_8023FA64(ALSeqpConfig *arg0) {
}
void audioManager_init(void){
D_8027D000 = (u8 *) malloc(0x21000);
bzero(D_8027D000, 0x21000);
alHeapInit(&D_8027CFF0, D_8027D000, 0x21000);
D_8027D000 = (u8 *) malloc(AUDIO_HEAP_SIZE);
bzero(D_8027D000, AUDIO_HEAP_SIZE);
alHeapInit(&D_8027CFF0, D_8027D000, AUDIO_HEAP_SIZE);
#if VERSION == VERSION_USA_1_0
if(osTvType != OS_TV_NTSC)
osViClock = 0x2e6025c;
#elif VERSION == VERSION_PAL
PAL_EXCLUSIVE(
osViClock = 0x2f5b2d2;
)
audioManager_create();
sfxInstruments_init();
musicInstruments_init();
@@ -297,10 +305,10 @@ void audioManager_create(void) {
int i;
f32 var_f0;
osCreateMesgQueue(&D_8027D008, D_8027D020, 50);
osCreateMesgQueue(&D_8027D008, D_8027D020, 3000/FRAMERATE);
osCreateMesgQueue(&audioManager.audioReplyMsgQ, audioManager.audioReplyMsgBuf, 8); //audioReplyMesgQueue
osCreateMesgQueue(&audioManager.audioFrameMsgQ, audioManager.audioFrameMsgBuf, 8);
var_f0 = 733.333313f;
var_f0 = 44000.0f/FRAMERATE;
D_8027DD74 = (s32)var_f0;
if ((f32) D_8027DD74 < var_f0) {
D_8027DD74++;
@@ -321,14 +329,14 @@ void audioManager_create(void) {
D_8027D5C0[0].unk0.next = NULL;
for(i = 0; i < 89; i++){
alLink((ALLink *)&D_8027D5C0[i+1], (ALLink *)&D_8027D5C0[i]);
D_8027D5C0[i].unk10 = alHeapDBAlloc(0, 0, D_8027DD50.heap, 1, 0x200);
D_8027D5C0[i].unk10 = alHeapDBAlloc(0, 0, D_8027DD50.heap, 1, VER_SELECT(0x200, 0x270, 0x200, 0x200));
}
D_8027D5C0[i].unk10 = alHeapDBAlloc(0, 0, D_8027DD50.heap, 1, 0x200);
D_8027D5C0[i].unk10 = alHeapDBAlloc(0, 0, D_8027DD50.heap, 1, VER_SELECT(0x200, 0x270, 0x200, 0x200));
for(i = 0; i < 2; i++){
audioManager.ACMDList[i] = malloc(20000);
audioManager.ACMDList[i] = malloc(1200000/FRAMERATE);
}
D_8027DD80 = 2500;
D_8027DD80 = 150000/FRAMERATE;
for(i = 0; i < 3; i++){
audioManager.audioInfo[i] = alHeapDBAlloc(0, 0, D_8027DD50.heap, 1, 0x10);
audioManager.audioInfo[i]->unk8 = 0;
@@ -368,7 +376,11 @@ bool audioManager_handleFrameMsg(AudioInfo *info, AudioInfo *prev_info){
s16 *outbuffer;
Acmd *sp38;
s32 sp34;
#if VERSION == VERSION_USA_1_0
s32 sp30 = 0;
#else
s32 sp30;
#endif
f32 pad;
outbuffer = (s16 *)osVirtualToPhysical(info->data);
@@ -377,13 +389,15 @@ bool audioManager_handleFrameMsg(AudioInfo *info, AudioInfo *prev_info){
if(prev_info){
sp30 = osAiSetNextBuffer(prev_info->data, prev_info->frameSamples*4);
}//L8024003C
#if VERSION == VERSION_USA_1_0
if(sp30 == -1){
func_80247F24(2, 0x7d2);
func_80247F9C(prev_info->frameSamples);
func_80247F9C(info->frameSamples);
func_802483D8();
}
}
#endif
if((D_80275770 >= 0x139) & !D_80275778){
info->frameSamples = D_8027DD78;
@@ -401,12 +415,14 @@ bool audioManager_handleFrameMsg(AudioInfo *info, AudioInfo *prev_info){
sp38 = n_alAudioFrame(audioManager.ACMDList[D_8027DCD0], &sp34, outbuffer, info->frameSamples);
#if VERSION == VERSION_USA_1_0
if(D_8027DD80 < sp34){
func_80247F24(2, 2000);
func_80247F9C(sp34);
func_80247F9C(D_8027DD80);
func_802483D8();
}
#endif
if(sp34 == 0){
return 0;
@@ -426,6 +442,7 @@ void audioManager_handleDoneMsg(AudioInfo *info)
}
}
#if VERSION == VERSION_USA_1_0
s32 func_80240204(s32 addr, s32 len, void *state){
void *sp44;
s32 sp40;
@@ -479,6 +496,63 @@ s32 func_80240204(s32 addr, s32 len, void *state){
osPiStartDma(&D_8027D100[D_8027DCCC++], 1, 0, addr, sp44, 0x200U, &D_8027D008);
return osVirtualToPhysical(sp44) + sp40;
}
#elif VERSION == VERSION_PAL
#ifndef NONMATCHING
s32 func_80240204(s32 addr, s32 len, void *state);
#pragma GLOBAL_ASM("asm/nonmatchings/core1/code_1D00/func_80240204.s")
#else
s32 func_80240204(s32 addr, s32 len, void *state){
void *sp44;
s32 sp40;
Struct_1D00_3 *phi_s0;
Struct_1D00_3 *phi_v0;
s32 new_var;
Struct_1D00_3 *sp30;
phi_v0 = D_8027D5B0.unk4;
sp30 = NULL;
for(phi_s0 = phi_v0; phi_s0 != NULL; phi_s0 = phi_s0->unk0.next) {
sp40 = (phi_s0->unk8 + 0x270);
if ((phi_s0->unk8 > addr)) break;
sp30 = phi_s0;
if ((addr + len) <= sp40) {
phi_s0->unkC = (s32) D_8027DCC8;
return osVirtualToPhysical(phi_s0->unk10 + (addr - phi_s0->unk8));
}
}
phi_s0 = D_8027D5B0.unk8;
if (phi_s0 == NULL) {
return osVirtualToPhysical(phi_v0);
}
D_8027D5B0.unk8 = phi_s0->unk0.next;
alUnlink(phi_s0);
if (sp30 != NULL) {
alLink(phi_s0, sp30);
} else {
phi_v0 = D_8027D5B0.unk4;
if (phi_v0 != NULL) {
D_8027D5B0.unk4 = phi_s0;
phi_s0->unk0.next = (ALLink *)phi_v0;
phi_s0->unk0.prev = NULL;
phi_v0->unk0.prev = (ALLink *)phi_s0;
} else {
D_8027D5B0.unk4 = phi_s0;
phi_s0->unk0.next = NULL;
phi_s0->unk0.prev = NULL;
}
}
new_var = addr & 1;
addr = addr - new_var;
phi_s0->unk8 = addr;
phi_s0->unkC = (s32) D_8027DCC8;
sp44 = phi_s0->unk10;
osPiStartDma(&D_8027D100[D_8027DCCC++], 1, 0, phi_s0->unk8, phi_s0->unk10, 0x270U, &D_8027D008);
return osVirtualToPhysical(sp44) + new_var;
}
#endif
#endif
void *func_802403B8(void *state) {
if (D_8027D5B0.unk0 == 0) {
@@ -498,12 +572,17 @@ void func_802403F0(void) {
sp40 = NULL;
for(phi_s0 = 0; phi_s0 < D_8027DCCC; phi_s0++){
#if VERSION == VERSION_USA_1_0
if (osRecvMesg(&D_8027D008, &sp40, 0) == -1) {
func_80247F24(2, 0x7D5);
func_80247F9C(D_8027DCCC);
func_80247F9C(phi_s0);
func_802483D8();
}
#else
osRecvMesg(&D_8027D008, &sp40, 0);
#endif
}
phi_s0_2 = D_8027D5B0.unk4;
while(phi_s0_2 != NULL){
@@ -527,6 +606,11 @@ void func_802403F0(void) {
D_8027DCC8 += 1;
}
#if VERSION == VERSION_PAL
void *audioManager_getThread_PAL(void){
return &audioManager.thread;
}
void audioManager_stopThread(void){
if(D_80275774){
D_80275774 = 0;

View File

@@ -1,6 +1,8 @@
#include <ultra64.h>
#include "functions.h"
#include "variables.h"
#include "version.h"
OSIoMesg D_8027E090;
struct {
@@ -13,7 +15,7 @@ OSMesgQueue D_8027E108; //g_PimgrMesgQueue
void func_802405F0(u32 * arg0, s32 arg1, s32 size){
s32 block_cnt;
s32 block_remainder;
s32 block_size = 0x20000;
s32 block_size = VER_SELECT(0x20000, 0x8000, 0, 0);
int i;
osWritebackDCache(arg0, size);
@@ -21,10 +23,10 @@ void func_802405F0(u32 * arg0, s32 arg1, s32 size){
block_remainder = size % block_size;
for(i = 0; i < block_cnt; i++){
osPiStartDma(&D_8027E090, OS_MESG_PRI_NORMAL, OS_READ, arg1, arg0, 0x20000, &D_8027E0A8.queue);
osPiStartDma(&D_8027E090, OS_MESG_PRI_NORMAL, OS_READ, arg1, arg0, VER_SELECT(0x20000, 0x8000, 0, 0), &D_8027E0A8.queue);
osRecvMesg(&D_8027E0A8.queue, NULL, 1);
arg1 += 0x20000;
arg0 += 0x8000;
arg1 += VER_SELECT(0x20000, 0x8000, 0, 0);
arg0 += VER_SELECT(0x8000, 0x2000, 0, 0);
}
osPiStartDma(&D_8027E090, OS_MESG_PRI_NORMAL, OS_READ, arg1, arg0, block_remainder, &D_8027E0A8.queue);

View File

@@ -1,10 +1,16 @@
#include <ultra64.h>
#include "functions.h"
#include "variables.h"
#include "version.h"
static void _guMtxIdentF(float mf[4][4]);
u8 D_80275900[] = {0xCF, 0xAD, 0xA2, 0x90, 0x93, 0x4A, 0x83, 0xF1};
#if VERSION == VERSION_USA_1_0
u8 D_80275900[8] = {0xCF, 0xAD, 0xA2, 0x90, 0x93, 0x4A, 0x83, 0xF1};
#elif VERSION == VERSION_PAL
u8 D_80275900[8] = {0xD3, 0x9E, 0xA6, 0x20, 0xC7, 0x7E, 0xD5, 0xC6};
#endif
f32 D_80275908 = BAD_DTOR;
static s32 guFToFix32(f32 arg0){