Implement & link jaudio_NES/dummyrom.c

This commit is contained in:
Cuyler36
2024-06-03 18:52:26 -04:00
parent 7f001f81e7
commit 1ae02605f6
10 changed files with 153 additions and 14 deletions
+1
View File
@@ -5,6 +5,7 @@ blocked_targets:
- 0x800A97E0 # boot.c local static const tbl, also start of .rodata
- 0x80008000
- 0x80018800
- 0x800189C0
- 0x801F6C7C # tcs_bad
- 0x801F6C7D # ics_bad
- 0x800a9a90
+5
View File
@@ -38,6 +38,11 @@ jaudio_NES/aictrl.c:
.sdata2: [0x80218da8, 0x80218db8]
jaudio_NES/sample.c:
.text: [0x80018640, 0x80018920]
jaudio_NES/dummyrom.c:
.text: [0x80018920, 0x80018bc0]
.rodata: [0x800aa518, 0x800aa528]
# .bss: [0x8020d78c, 0x8020d7a0] # placed in common bss
.sbss: [0x80218420, 0x80218440]
# jaudio_NES/game64.c: # TODO: finish
# .rodata: [0x800a9938, 0x800a9b98]
#jaudio_NES/verysimple.c:
+2 -1
View File
@@ -626,7 +626,8 @@ class AsmSource(Source):
JAUDIO_FUNC_ALIGN_32_TUS = [
"sample.c",
"aictrl.c"
"aictrl.c",
"dummyrom.c"
]
class CSource(Source):
+3
View File
@@ -10,6 +10,9 @@ extern "C" {
#define S16_MIN (-0x8000)
#define S16_MAX (0x7FFF)
#define AUDIO_ARAM_SIZE 0x400000 /* 4MB */
#define AUDIO_ARAM_HEAP_SIZE 0xC000
#ifdef __cplusplus
}
#endif
+1 -11
View File
@@ -3,6 +3,7 @@
#include "types.h"
#include "jaudio_NES/audiocommon.h"
#include "PR/abi.h"
#ifdef __cplusplus
extern "C" {
@@ -39,17 +40,6 @@ typedef struct AudioPort_ {
/* 0x04 */ u32 param;
} AudioPort;
/* sizeof(Acmd) == 0x4*/
typedef union Acmd {
struct {
/* 0x00 */ u8 p0;
/* 0x01 */ u8 p1;
/* 0x02 */ u8 p2;
/* 0x03 */ u8 p3;
};
/* 0x00 */ u32 uint32;
} Acmd;
/* sizeof(ALHeap) == 0x14 */
typedef struct ALHeap {
/* 0x00 */ u8* base;
+23
View File
@@ -0,0 +1,23 @@
#ifndef DUMMYROM_H
#define DUMMYROM_H
#include "types.h"
#include "jaudio_NES/audiostruct.h"
#include "libultra/libultra.h"
#define DUMMYROM_DRAM_TO_ARAM 0
#define DUMMYROM_ARAM_TO_DRAM 1
extern u8* JAC_ARAM_DMA_BUFFER_TOP;
ALHeap aram_hp; /* placed in common bss */
extern u32 GetNeos_FileTop(void);
extern u32 GetNeosRomTop(void);
extern u32 GetNeosRom_PreLoaded(void);
extern void SetPreCopy_NeosRom(u8* load_addr, u32 load_size, BOOL cut_flag);
extern BOOL ARAMStartDMAmesg(u32 dir, u32 dramAddr, u32 aramAddr, u32 size, s32 unused, OSMesgQueue* mq);
extern void Jac_SetAudioARAMSize(u32 size);
extern void ARAllocFull(u32* outSize);
extern void Jac_InitARAM(u32 loadAudiorom);
#endif
+13
View File
@@ -0,0 +1,13 @@
#ifndef DVDTHREAD_H
#define DVDTHREAD_H
#include "types.h"
#include "dolphin/dvd.h"
typedef void (*Jac_DVDCallback)(u32);
extern s32 DVDT_DRAMtoARAM(u32 owner, u32 dram, u32 aram, u32 len, u32* outLen, Jac_DVDCallback callback);
extern s32 DVDT_ARAMtoDRAM(u32 owner, u32 dram, u32 aram, u32 len, u32* outLen, Jac_DVDCallback callback);
extern u32 Jac_CheckFile(char* path);
#endif
+9
View File
@@ -0,0 +1,9 @@
#ifndef OS_H
#define OS_H
#include "types.h"
#include "libultra/libultra.h"
extern int Z_osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 block);
#endif
+2 -2
View File
@@ -7,7 +7,7 @@
typedef void* OSMesg;
typedef struct OSMesgQueue {
typedef struct OSMesgQueue_s {
/* 0x00 */ OSThread* mtqueue;
/* 0x04 */ OSThread* fullqueue;
/* 0x08 */ int validCount;
@@ -16,7 +16,7 @@ typedef struct OSMesgQueue {
/* 0x14 */ OSMesg* msg;
} OSMesgQueue; // size = 0x18
extern void osCreateMesgQueue(OSMessageQueue* mq ,OSMessage msg, int flags);
extern void osCreateMesgQueue(OSMessageQueue* mq, OSMessage msg, int flags);
extern int osSendMesg(OSMessageQueue* mq, OSMessage msg, int flags);
extern int osRecvMesg(OSMessageQueue* mq, OSMessage* msg, int flags);
+94
View File
@@ -0,0 +1,94 @@
#include "jaudio_NES/dummyrom.h"
#include "dolphin/ar.h"
#include "jaudio_NES/dvdthread.h"
#include "jaudio_NES/os.h"
#include "jaudio_NES/memory.h"
u8* JAC_ARAM_DMA_BUFFER_TOP = nullptr;
static u32 AUDIO_ARAM_TOP = 0;
static u32 CARD_SECURITY_BUFFER = 0;
static u32 init_load_size = 0;
static u8* init_load_addr = nullptr;
static BOOL init_cut_flag = FALSE;
static u32 SELECTED_ARAM_SIZE = 0;
extern u32 GetNeos_FileTop(void) {
if (init_cut_flag) {
return 0;
}
return init_load_size;
}
extern u32 GetNeosRomTop(void) {
return AUDIO_ARAM_TOP;
}
extern u32 GetNeosRom_PreLoaded(void) {
DVDT_DRAMtoARAM(0, (u32)init_load_addr, AUDIO_ARAM_TOP, init_load_size, nullptr, nullptr);
return init_load_size;
}
extern void SetPreCopy_NeosRom(u8* load_addr, u32 load_size, BOOL cut_flag) {
init_load_size = load_size;
init_load_addr = load_addr;
init_cut_flag = cut_flag;
}
static void mesg_finishcall(u32 mq) {
Z_osSendMesg((OSMesgQueue*)mq, NULL, OS_MESSAGE_NOBLOCK);
}
extern BOOL ARAMStartDMAmesg(u32 dir, u32 dramAddr, u32 aramAddr, u32 size, s32 unused, OSMesgQueue* mq) {
aramAddr += AUDIO_ARAM_TOP;
if (dir == DUMMYROM_ARAM_TO_DRAM) {
DVDT_ARAMtoDRAM((u32)mq, dramAddr, aramAddr, size, nullptr, &mesg_finishcall);
} else {
DVDT_DRAMtoARAM((u32)mq, dramAddr, aramAddr, size, nullptr, &mesg_finishcall);
}
return FALSE;
}
extern void Jac_SetAudioARAMSize(u32 size) {
SELECTED_ARAM_SIZE = size;
}
extern void ARAllocFull(u32* outSize) {
u32 freeSize = aram_hp.length - ((int)aram_hp.current - (int)aram_hp.base);
Nas_HeapAlloc(&aram_hp, freeSize - 32);
*outSize = freeSize - 32;
}
extern void Jac_InitARAM(u32 loadAudiorom) {
u32 aram_size = AUDIO_ARAM_SIZE;
volatile u32 audiorom_size;
if (SELECTED_ARAM_SIZE != 0) {
aram_size = SELECTED_ARAM_SIZE;
}
AUDIO_ARAM_TOP = ARGetBaseAddress();
if (loadAudiorom) {
audiorom_size = Jac_CheckFile("/audiorom.img");
if (audiorom_size != 0) {
audiorom_size = ALIGN_NEXT(audiorom_size, 32);
(void)audiorom_size; /* leftover from some debug print? */
}
} else {
audiorom_size = 0;
}
CARD_SECURITY_BUFFER = 0x40;
audiorom_size += AUDIO_ARAM_TOP;
JAC_ARAM_DMA_BUFFER_TOP = (u8*)audiorom_size;
audiorom_size += AUDIO_ARAM_HEAP_SIZE;
Nas_HeapInit(&aram_hp, (u8*)audiorom_size, aram_size - audiorom_size);
/* Probably leftovers from some debug print statement */
(void)audiorom_size;
(void)audiorom_size;
}