Add libcd symbols

This commit is contained in:
Luciano Ciccariello 2022-03-05 00:23:07 +00:00
parent f797715148
commit ea230d7139
9 changed files with 243 additions and 21 deletions

View File

@ -138,7 +138,7 @@ StopPAD = 0x800152D8;
PAD_init = 0x800152E8;
PAD_dr = 0x800152F8;
VSync = 0x80015308;
VSyncWait = 0x80015450;
v_wait = 0x80015450;
ChangeClearRCnt = 0x800154EC;
ResetCallback = 0x800154FC;
InterruptCallback = 0x8001552C;
@ -150,6 +150,9 @@ RestartCallback = 0x80015620;
CheckCallback = 0x80015650;
GetIntrMask = 0x80015660;
SetIntrMask = 0x80015678;
startIntr = 0x80015694;
trapIntr = 0x80015770;
setIntr = 0x80015958;
_96_remove = 0x80015C0C;
ReturnFromException = 0x80015C1C;
ResetEntryInt = 0x80015C2C;
@ -240,9 +243,55 @@ RotMatrixY = 0x80018D6C;
RotMatrixZ = 0x80018F0C;
FlushCache = 0x800192CC;
CdInit = 0x8001930C;
def_cbsync = 0x8001939C;
def_cbready = 0x800193C4;
def_cbread = 0x800193EC;
DeliverEvent = 0x80019414;
CdStatus = 0x80019424;
CdMode = 0x80019434;
CdLastCom = 0x8001944;
CdLastPos = 0x80019454;
CdReset = 0x80019464;
CdFlush = 0x800194D0;
CdSync = 0x80019570;
CdReady = 0x80019590;
CdSyncCallback = 0x800195B0;
CdReadyCallback = 0x800195C8;
CdControl = 0x800195E0;
CdControlF = 0x80019718;
CdControlB = 0x80019844;
CdMix = 0x80019988;
CdGetSector = 0x800199AC;
CdDataCallback = 0x800199D0;
CdIntToPos = 0x80019A14;
CdPosToInt = 0x80019B18;
getintr = 0x80019B98;
CD_sync = 0x8001A110;
CD_ready = 0x8001A390;
CD_cw = 0x8001A65C;
CD_vol = 0x8001AAA4;
CD_flush = 0x8001AB2C;
CD_initvol = 0x8001AC0C;
CD_initintr = 0x8001AD00;
CD_init = 0x8001AD50;
CD_datasync = 0x8001AF3C;
CD_getsector = 0x8001B0A8;
callback = 0x8001B1B8;
CdSearchFile = 0x8001B298;
cmp = 0x8001B578;
CD_newmedia = 0x8001B59C;
CD_searchdir = 0x8001B878;
CD_cachefile = 0x8001B920;
cd_read = 0x8001BBC4;
cd_memcpy = 0x8001BC30;
strcmp = 0x8001BC64;
strncmp = 0x8001BC74;
cb_read = 0x8001BC84;
cd_read_retry = 0x8001BEA8;
CdRead = 0x8001C080;
CdReadSync = 0x8001C188;
CdReadCallback = 0x8001C254;
CdRead2 = 0x8001C26C;
StClearRing = 0x8001C320;
StSetStream = 0x8001C4C8;
SsVoKeyOff = 0x8001F7AC;
@ -281,10 +330,23 @@ _spu_setReverbAttr = 0x80029810;
SpuClearReverbWorkArea = 0x80029CE0;
WaitEvent = 0x80029E7C;
TestEvent = 0x8002AD5C;
Hcount = 0x8002C2B0;
g_InterruptMask = 0x8002D348;
_vsync_rcnt = 0x8002D374;
aThisFunctionIs = 0x8002E1EA;
CD_cbsync = 0x80032AA4;
CD_cbready = 0x80032AA8;
CD_status = 0x80032AB4;
CD_status1 = 0x80032AB8;
CD_nopen = 0x80032ABC;
CD_pos = 0x80032AC0;
CD_mode = 0x80032AC4;
CD_com = 0x80032AC5;
pad_buf = 0x8003925C;
Alarm = 0x80039278;
file = 0x80039284;
load_buf = 0x8003AE84;
fp_2 = 0x8003B684;
D_8003BDE0 = 0x8003BDE0;
D_8003BDEC = 0x8003BDEC;
D_8003BDFF = 0x8003BDFF;

View File

@ -1,7 +1,9 @@
#ifndef MAIN_H
#define MAIN_H
#include <psxsdk/kernel.h>
#include <psxsdk/libetc.h>
#include <psxsdk/libgpu.h>
#include <psxsdk/libcd.h>
extern s32 D_8003925C;
@ -13,8 +15,6 @@ s32 func_800190AC(s32, s32);
extern unsigned char func_80019424();
extern unsigned char func_80019434();
extern unsigned char func_80019444();
extern void func_800195C8(s32);
extern void func_800199D0(s32);
extern s32 func_8001D290(s32, s32);
extern s32 func_8001D374(s8, s16, s16);
extern void func_8001D2E0(s32, s32, s32);

73
include/psxsdk/kernel.h Normal file
View File

@ -0,0 +1,73 @@
#define DescMask 0xff000000
#define DescTH DescMask
#define DescHW 0xf0000000
#define DescEV 0xf1000000
#define DescRC 0xf2000000
#define DescUEV 0xf3000000 /* User event */
#define DescSW 0xf4000000 /* BIOS */
#define HwVBLANK (DescHW|0x01) /* VBLANK */
#define HwGPU (DescHW|0x02) /* GPU */
#define HwCdRom (DescHW|0x03) /* CDROM Decorder */
#define HwDMAC (DescHW|0x04) /* DMA controller */
#define HwRTC0 (DescHW|0x05) /* RTC0 */
#define HwRTC1 (DescHW|0x06) /* RTC1 */
#define HwRTC2 (DescHW|0x07) /* RTC2 */
#define HwCNTL (DescHW|0x08) /* Controller */
#define HwSPU (DescHW|0x09) /* SPU */
#define HwPIO (DescHW|0x0a) /* PIO */
#define HwSIO (DescHW|0x0b) /* SIO */
#define HwCPU (DescHW|0x10) /* Exception */
#define HwCARD (DescHW|0x11) /* memory card */
#define HwCARD_0 (DescHW|0x12) /* memory card */
#define HwCARD_1 (DescHW|0x13) /* memory card */
#define SwCARD (DescSW|0x01) /* memory card */
#define SwMATH (DescSW|0x02) /* libmath */
#define RCntCNT0 (DescRC|0x00) /* <20>\<5C><><EFBFBD>s<EFBFBD>N<EFBFBD>Z<EFBFBD><5A> */
#define RCntCNT1 (DescRC|0x01) /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
#define RCntCNT2 (DescRC|0x02) /* <20>V<EFBFBD>X<EFBFBD>e<EFBFBD><65><EFBFBD>N<EFBFBD><4E><EFBFBD>b<EFBFBD>N<EFBFBD>W<EFBFBD><57><EFBFBD><EFBFBD> */
#define RCntCNT3 (DescRC|0x03) /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>^<5E>[<5B>Q<EFBFBD>b<EFBFBD>g<EFBFBD>l<EFBFBD>͂P<CD82>ɌŒ<C98C> */
#define RCntMdINTR 0x1000
#define RCntMdNOINTR 0x2000
#define RCntMdSC 0x0001
#define RCntMdSP 0x0000
#define RCntMdFR 0x0000
#define RCntMdGATE 0x0010
#define EvSpCZ 0x0001 /* counter becomes zero */
#define EvSpINT 0x0002 /* interrupted */
#define EvSpIOE 0x0004 /* end of i/o */
#define EvSpCLOSE 0x0008 /* file was closed */
#define EvSpACK 0x0010 /* command acknowledged */
#define EvSpCOMP 0x0020 /* command completed */
#define EvSpDR 0x0040 /* data ready */
#define EvSpDE 0x0080 /* data end */
#define EvSpTIMOUT 0x0100 /* time out */
#define EvSpUNKNOWN 0x0200 /* unknown command */
#define EvSpIOER 0x0400 /* end of read buffer */
#define EvSpIOEW 0x0800 /* end of write buffer */
#define EvSpTRAP 0x1000 /* general interrupt */
#define EvSpNEW 0x2000 /* new device */
#define EvSpSYSCALL 0x4000 /* system call instruction */
#define EvSpERROR 0x8000 /* error happned */
#define EvSpPERROR 0x8001 /* previous write error happned */
#define EvSpEDOM 0x0301 /* domain error in libmath */
#define EvSpERANGE 0x0302 /* range error in libmath */
#define EvMdINTR 0x1000
#define EvMdNOINTR 0x2000
#define EvStUNUSED 0x0000
#define EvStWAIT 0x1000
#define EvStACTIVE 0x2000
#define EvStALREADY 0x4000
#define TcbMdRT 0x1000 /* reserved by system */
#define TcbMdPRI 0x2000 /* reserved by system */
#define TcbStUNUSED 0x1000
#define TcbStACTIVE 0x4000

58
include/psxsdk/libcd.h Normal file
View File

@ -0,0 +1,58 @@
/* Location */
typedef struct {
u_char minute;
u_char second;
u_char sector;
u_char track;
} CdlLOC;
/* Attenuator */
typedef struct {
u_char val0; /* volume for CD(L) -> SPU (L) */
u_char val1; /* volume for CD(L) -> SPU (R) */
u_char val2; /* volume for CD(R) -> SPU (L) */
u_char val3; /* volume for CD(R) -> SPU (R) */
} CdlATV;
/* Low Level File System for CdSearchFile() */
#define CdlMAXFILE 64 /* max number of files in a directory */
#define CdlMAXDIR 128 /* max number of total directories */
#define CdlMAXLEVEL 8 /* max levels of directories */
typedef struct {
CdlLOC pos; /* file location */
u_long size; /* file size */
char name[16]; /* file name (body) */
} CdlFILE;
typedef void (*CdlCB)(u_char,u_char *);
static void def_cbsync(u_char intr, u_char *result);
static void def_cbready(u_char intr, u_char *result);
static void def_cbread(u_char intr, u_char *result);
int CdInit(void);
int CdStatus(void);
int CdMode(void);
int CdLastCom(void);
int CdReset(int mode);
void CdFlush(void);
int CdSync(int mode, u_char *result);
int CdReady(int mode, u_char *result);
CdlCB CdSyncCallback(CdlCB func);
CdlCB CdReadyCallback(CdlCB func);
int CdControl(u_char com, u_char *param, u_char *result);
int CdControlB(u_char com, u_char *param, u_char *result);
int CdControlF(u_char com, u_char *param);
int CdMix(CdlATV *vol);
int CdGetSector(void *madr, int size);
void (*CdDataCallback(void (*func)()));
CdlLOC *CdIntToPos(int i, CdlLOC *p) ;
int CdPosToInt(CdlLOC *p);
CdlFILE *CdSearchFile(CdlFILE *fp, char *name);
int CdRead(int sectors, u_long *buf, int mode);
int CdReadSync(int mode, u_char *result);
CdlCB CdReadCallback(CdlCB func);
int CdRead2(long mode);

View File

@ -1749,8 +1749,8 @@ void func_80107360(POLY_GT4* poly, s32 x, s32 y, s32 width, s32 height, s8 u, s8
#endif
void func_801073C0(void) {
func_800195C8(0);
func_800199D0(0);
CdReadyCallback(NULL);
CdDataCallback(NULL);
}
INCLUDE_ASM("asm/dra/nonmatchings/42398", func_801073E8);

View File

@ -24,7 +24,7 @@ INCLUDE_ASM("asm/main/nonmatchings/5A38", PAD_dr);
INCLUDE_ASM("asm/main/nonmatchings/5A38", VSync);
INCLUDE_ASM("asm/main/nonmatchings/5A38", VSyncWait);
INCLUDE_ASM("asm/main/nonmatchings/5A38", v_wait);
INCLUDE_ASM("asm/main/nonmatchings/5A38", ChangeClearRCnt);

View File

@ -2,11 +2,11 @@
INCLUDE_ASM("asm/main/nonmatchings/5E78", SetIntrMask);
INCLUDE_ASM("asm/main/nonmatchings/5E78", func_80015694);
INCLUDE_ASM("asm/main/nonmatchings/5E78", startIntr);
INCLUDE_ASM("asm/main/nonmatchings/5E78", func_80015770);
INCLUDE_ASM("asm/main/nonmatchings/5E78", trapIntr);
INCLUDE_ASM("asm/main/nonmatchings/5E78", func_80015958);
INCLUDE_ASM("asm/main/nonmatchings/5E78", setIntr);
INCLUDE_ASM("asm/main/nonmatchings/5E78", func_80015AAC);

View File

@ -1,4 +1,5 @@
#include "common.h"
#include <main.h>
INCLUDE_ASM("asm/main/nonmatchings/72A4", func_80016AA4);
@ -178,10 +179,37 @@ INCLUDE_ASM("asm/main/nonmatchings/72A4", FlushCache);
INCLUDE_ASM("asm/main/nonmatchings/72A4", func_800192DC);
#ifndef NON_MATCHING
INCLUDE_ASM("asm/main/nonmatchings/72A4", CdInit);
#else
int CdInit() {
int i;
INCLUDE_ASM("asm/main/nonmatchings/72A4", func_8001939C);
for (i = 4; i != -1; i--) {
if ( CdReset(1) ) {
CdSyncCallback(def_cbsync);
CdReadyCallback(def_cbready);
CdReadCallback(def_cbread);
return true;
}
}
INCLUDE_ASM("asm/main/nonmatchings/72A4", func_800193C4);
printf("CdInit: Init failed\n");
return false;
}
#endif
INCLUDE_ASM("asm/main/nonmatchings/72A4", func_800193EC);
void def_cbsync(u_char intr, u_char *result)
{
DeliverEvent( HwCdRom, EvSpCOMP );
}
void def_cbready(u_char intr, u_char *result)
{
DeliverEvent( HwCdRom, EvSpDR );
}
void def_cbread(u_char intr, u_char *result)
{
DeliverEvent( HwCdRom, EvSpDR );
}

View File

@ -1,17 +1,18 @@
#include "common.h"
#include "main.h"
unsigned char func_80019424()
{
return *(unsigned char*)0x80032AB4;
extern u8 CD_status;
extern u8 CD_mode;
extern u8 CD_com;
int CdStatus(void) {
return CD_status;
}
unsigned char func_80019434()
{
return *(unsigned char*)0x80032AC4;
int CdMode(void) {
return CD_mode;
}
unsigned char func_80019444()
{
return *(unsigned char*)0x80032AC5;
int CdLastCom(void) {
return CD_com;
}