diff options
| author | John Wilbert M. Villamor <lameguy64@gmail.com> | 2019-11-22 09:11:12 +0800 |
|---|---|---|
| committer | John Wilbert M. Villamor <lameguy64@gmail.com> | 2019-11-22 09:11:12 +0800 |
| commit | ea46d05aed0343c20d8fdfaa0e67d54d51e8e2a0 (patch) | |
| tree | 43e2a53f4e5f7f55b075cfc9d6dc7a652a7b0837 /libpsn00b/include/psxcd.h | |
| parent | d80d92e13330d527ddb94420b19f9e21bf0e74eb (diff) | |
| download | psn00bsdk-ea46d05aed0343c20d8fdfaa0e67d54d51e8e2a0.tar.gz | |
Added long awaited CD-ROM library and loads of fixes, see changelog for details
Diffstat (limited to 'libpsn00b/include/psxcd.h')
| -rw-r--r-- | libpsn00b/include/psxcd.h | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/libpsn00b/include/psxcd.h b/libpsn00b/include/psxcd.h new file mode 100644 index 0000000..5bb1b5f --- /dev/null +++ b/libpsn00b/include/psxcd.h @@ -0,0 +1,149 @@ +#ifndef _LIBPSXCD_H +#define _LIBPSXCD_H + +#include <sys/types.h> + +/* + * CD-ROM control commands + */ +#define CdlNop 0x01 /* a.k.a. Getstat */ +#define CdlSetloc 0x02 +#define CdlPlay 0x03 +#define CdlForward 0x04 +#define CdlBackward 0x05 +#define CdlReadN 0x06 +#define CdlStandby 0x07 /* a.k.a. MotorOn */ +#define CdlStop 0x08 +#define CdlPause 0x09 +#define CdlInit 0x0A +#define CdlMute 0x0B +#define CdlDemute 0x0C +#define CdlSetfilter 0x0D +#define CdlSetmode 0x0E +#define CdlGetparam 0x0F +#define CdlGetlocL 0x10 +#define CdlGetlocP 0x11 +#define CdlSetsession 0x12 /* ORIGINAL CODE */ +#define CdlGetTN 0x13 +#define CdlGetTD 0x14 +#define CdlSeekL 0x15 +#define CdlSeekP 0x16 +#define CdlTest 0x19 /* ORIGINAL CODE */ +#define CdlReadS 0x1B + +/* + * CD-ROM status bits + */ +#define CdlStatError 0x01 +#define CdlStatStandby 0x02 +#define CdlStatSeekError 0x04 +#define CdlStatIdError 0x08 /* ORIGINAL CODE */ +#define CdlStatShellOpen 0x10 +#define CdlStatRead 0x20 +#define CdlStatSeek 0x40 +#define CdlStatPlay 0x80 + +/* + * CD-ROM mode bits + */ +#define CdlModeDA 0x01 +#define CdlModeAP 0x02 +#define CdlModeRept 0x04 +#define CdlModeSF 0x08 +#define CdlModeSize0 0x10 +#define CdlModeSize1 0x20 +#define CdlModeRT 0x40 +#define CdlModeSpeed 0x80 + +/* + * CD-ROM interrupt result values + */ +#define CdlNoIntr 0x00 +#define CdlDataReady 0x01 +#define CdlComplete 0x02 +#define CdlAcknowledge 0x03 +#define CdlDataEnd 0x04 +#define CdlDiskError 0x05 + +#define btoi(b) ((b)/16*10+(b)%16) /* Convert BCD value to integer */ +#define itob(i) ((i)/10*16+(i)%10) /* Convert integer to BCD value */ + +/* + * CD-ROM disc location struct + */ +typedef struct CdlLOC +{ + u_char minute; + u_char second; + u_char sector; + u_char track; +} CdlLOC; + +/* + * CD-ROM audio attenuation struct (volume) + */ +typedef struct CdlATV +{ + u_char val0; /* L -> SPU L */ + u_char val1; /* L -> SPU R */ + u_char val2; /* R -> SPU R */ + u_char val3; /* R -> SPU L */ +} CdlATV; + +/* + * CD-ROM file information struct + */ +typedef struct CdlFILE +{ + CdlLOC loc; + u_int size; + char name[16]; +} CdlFILE; + +typedef struct CdlFILTER +{ + u_char file; + u_char chan; + u_short pad; +} CdlFILTER; + +/* Data callback */ +typedef void (*CdlCB)(int, unsigned char *); + +#ifdef __cplusplus +extern "C" { +#endif + +int CdInit(int mode); + +CdlLOC *CdIntToPos(int i, CdlLOC *p); +int CdPosToInt(CdlLOC *p); +int CdGetToc(CdlLOC *toc); + +int CdControl(unsigned char com, unsigned char *param, unsigned char *result); +int CdControlB(unsigned char com, unsigned char *param, unsigned char *result); +int CdControlF(unsigned char com, unsigned char *param); +int CdSync(int mode, unsigned char *result); +unsigned int CdSyncCallback(CdlCB func); + +long CdReadyCallback(CdlCB func); +int CdGetSector(void *madr, int size); + +CdlFILE *CdSearchFile(CdlFILE *loc, const char *filename); +int CdRead(int sectors, unsigned int *buf, int mode); +int CdReadSync(int mode, unsigned char *result); +unsigned int CdReadCallback(CdlCB func); + +int CdStatus(void); +int CdMode(void); + +int CdMix(CdlATV *vol); + +/* ORIGINAL CODE */ +long *CdAutoPauseCallback(void(*func)()); + +#ifdef __cplusplus +} +#endif + +#endif /* _LIBPSXCD_H */ |
