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 | |
| 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')
| -rw-r--r-- | libpsn00b/include/hwregs_a.h | 4 | ||||
| -rw-r--r-- | libpsn00b/include/psxapi.h | 58 | ||||
| -rw-r--r-- | libpsn00b/include/psxcd.h | 149 | ||||
| -rw-r--r-- | libpsn00b/include/psxgpu.h | 56 | ||||
| -rw-r--r-- | libpsn00b/include/psxsio.h | 3 | ||||
| -rw-r--r-- | libpsn00b/include/string.h | 4 |
6 files changed, 238 insertions, 36 deletions
diff --git a/libpsn00b/include/hwregs_a.h b/libpsn00b/include/hwregs_a.h index 27cfc88..9d4313b 100644 --- a/libpsn00b/include/hwregs_a.h +++ b/libpsn00b/include/hwregs_a.h @@ -82,6 +82,10 @@ .set D2_BCR, 0x10a4 .set D2_CHCR, 0x10a8 +.set D3_MADR, 0x10b0 +.set D3_BCR, 0x10b4 +.set D3_CHCR, 0x10b8 + .set D4_MADR, 0x10c0 .set D4_BCR, 0x10c4 .set D4_CHCR, 0x10c8 diff --git a/libpsn00b/include/psxapi.h b/libpsn00b/include/psxapi.h index 9abcd0c..0953dc3 100644 --- a/libpsn00b/include/psxapi.h +++ b/libpsn00b/include/psxapi.h @@ -1,23 +1,38 @@ #ifndef __PSXAPI__ #define __PSXAPI__ -#define DescHW 0xf0000000 -#define DescSW 0xf4000000 - -#define HwCARD (DescHW|0x11) -#define HwCARD_1 (DescHW|0x12) -#define HwCARD_0 (DescHW|0x13) -#define SwCARD (DescHW|0x02) - -#define EvSpIOE 0x0004 -#define EvSpERROR 0x8000 -#define EvSpTIMOUT 0x0100 -#define EvSpNEW 0x0200 - -#define EvMdINTR 0x1000 -#define EvMdNOINTR 0x2000 - -typedef struct { // Device control block +#define DescHW 0xf0000000 +#define DescSW 0xf4000000 + +#define HwCARD (DescHW|0x11) +#define HwCARD_1 (DescHW|0x12) +#define HwCARD_0 (DescHW|0x13) +#define SwCARD (DescHW|0x02) + +#define EvSpIOE 0x0004 +#define EvSpERROR 0x8000 +#define EvSpTIMOUT 0x0100 +#define EvSpNEW 0x0200 + +#define EvMdINTR 0x1000 +#define EvMdNOINTR 0x2000 + +// Root counter (timer) definitions +#define DescRC 0xf2000000 + +#define RCntCNT0 (DescRC|0x00) +#define RCntCNT1 (DescRC|0x01) +#define RCntCNT2 (DescRC|0x02) +#define RCntCNT3 (DescRC|0x03) + +#define RCntMdINTR 0x1000 // Turns on IRQ +#define RCntMdNOINTR 0x2000 // Polling mode +#define RCntMdSC 0x0001 // IRQ when counter target +#define RCntMdSP 0x0000 +#define RCntMdFR 0x0000 +#define RCntMdGATE 0x0010 + +typedef struct { // Device control block char *name; int flags; int ssize; @@ -121,6 +136,7 @@ int chdir(const char *path); int AddDev(DCB *dcb); int DelDev(const char *name); void ListDev(void); +void AddDummyTty(void); void EnterCriticalSection(void); void ExitCriticalSection(void); @@ -151,8 +167,14 @@ int _card_read(int chan, int sector, unsigned char *buf); int _card_write(int chan, int sector, unsigned char *buf); void _new_card(void); +// Timers +int SetRCnt(int spec, unsigned short target, int mode); +int GetRCnt(int spec); +int StartRCnt(int spec); +int StopRCnt(int spec); +int ResetRCnt(int spec); -// Interrupt acknowledge control +// BIOS IRQ acknowledge control void ChangeClearPAD(int mode); void ChangeClearRCnt(int t, int m); 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 */ diff --git a/libpsn00b/include/psxgpu.h b/libpsn00b/include/psxgpu.h index 230775f..5f0798a 100644 --- a/libpsn00b/include/psxgpu.h +++ b/libpsn00b/include/psxgpu.h @@ -114,9 +114,9 @@ /* * Primitive handling macros */ -#define setlen( p, _len ) ( ((P_TAG*)(p))->len = (unsigned char)_len ) -#define setaddr( p, _addr ) ( ((P_TAG*)(p))->addr = (unsigned int)_addr ) -#define setcode( p, _code ) ( ((P_TAG*)(p))->code = (unsigned char)_code ) +#define setlen( p, _len ) ( ((P_TAG*)(p))->len = (unsigned char)(_len) ) +#define setaddr( p, _addr ) ( ((P_TAG*)(p))->addr = (unsigned int)(_addr) ) +#define setcode( p, _code ) ( ((P_TAG*)(p))->code = (unsigned char)(_code) ) #define getlen( p ) ( ((P_TAG*)(p))->len ) #define getaddr( p ) ( ((P_TAG*)(p))->addr ) @@ -126,7 +126,7 @@ #define isendprim( p ) ((((P_TAG*)(p))->addr)==0xffffff) #define addPrim( ot, p ) setaddr( p, getaddr( ot ) ), setaddr( ot, p ) -#define addPrims(ot, p0, p1) setaddr( p1, getaddr( ot ) ), setaddr( ot, p0 ) +#define addPrims( ot, p0, p1 ) setaddr( p1, getaddr( ot ) ), setaddr( ot, p0 ) #define catPrim( p0, p1 ) setaddr( p0, p1 ) #define termPrim( p ) setaddr( p, 0xffffff ) @@ -186,6 +186,22 @@ #define setFill( p ) setlen( p, 3 ), setcode( p, 0x02 ) +#define setDrawOffset( p, _x, _y ) \ + setlen( p, 1 ), \ + (p)->code[0] = (_x&0x3FF)|((_y&0x3FF)<<11), \ + ((char*)(p)->code)[3] = 0xE5 + +#define setDrawArea( p, r ) \ + setlen( p, 2 ), \ + (p)->code[0] = ((r)->x&0x3FF)|(((r)->y&0x1FF)<<10), \ + (p)->code[1] = (((r)->x+(r)->w-1)&0x3FF)|((((r)->y+(r)->h-1)&0x1FF)<<10), \ + ((char*)&(p)->code[0])[3] = 0xE3, \ + ((char*)&(p)->code[1])[3] = 0xE4 + +#define setTexWindow( p, r ) \ + setlen( p, 1 ), \ + (p)->code[0] = ((r)->w&0x1F)|(((r)->h&0x1F)<<5)|(((r)->x&0x1F)<<10)|(((r)->y&0x1F)<<15), \ + ((char*)&(p)->code[0])[3] = 0xE2 /* * Primitive definitions @@ -427,34 +443,44 @@ typedef struct { * VRAM fill and transfer primitive definitions */ -typedef struct { +typedef struct DR_ENV { unsigned int tag; unsigned int code[15]; } DR_ENV; -typedef struct { +typedef struct DR_AREA { + unsigned int tag; + unsigned int code[2]; +} DR_AREA; + +typedef struct DR_OFFSET { + unsigned int tag; + unsigned int code[1]; +} DR_OFFSET; + +typedef struct DR_TWIN { unsigned int tag; unsigned int code[2]; } DR_TWIN; -typedef struct { +typedef struct DR_TPAGE { unsigned int tag; unsigned int code[1]; } DR_TPAGE; -typedef struct { /* ORIGINAL */ +typedef struct DR_MASK { /* ORIGINAL */ unsigned int tag; unsigned int code[1]; } DR_MASK; -typedef struct { /* ORIGINAL */ +typedef struct FILL { /* ORIGINAL */ unsigned int tag; unsigned char r0,g0,b0,code; unsigned short x0,y0; // Note: coordinates must be in 16 pixel steps unsigned short w,h; } FILL; -typedef struct { /* ORIGINAL */ +typedef struct VRAM2VRAM { /* ORIGINAL */ unsigned int tag; unsigned char p0,p1,p2,code; unsigned short x0,y0; @@ -465,18 +491,18 @@ typedef struct { /* ORIGINAL */ // General structs -typedef struct { +typedef struct RECT { short x,y; short w,h; } RECT; -typedef struct { +typedef struct DISPENV_RAW { unsigned int vid_mode; // Video mode short vid_xpos,vid_ypos; // Video position (not framebuffer) short fb_x,fb_y; // Framebuffer display position } DISPENV_RAW; -typedef struct { +typedef struct DISPENV { RECT disp; RECT screen; char isinter; @@ -485,7 +511,7 @@ typedef struct { char pad; } DISPENV; -typedef struct { +typedef struct DRAWENV { RECT clip; // Drawing area short ofs[2]; // GPU draw offset (relative to draw area) RECT tw; // Texture window (doesn't do anything atm) @@ -497,7 +523,7 @@ typedef struct { DR_ENV dr_env; // Draw mode packet area (used by PutDrawEnv) } DRAWENV; -typedef struct { +typedef struct TIM_IMAGE { unsigned int mode; RECT *crect; unsigned int *caddr; diff --git a/libpsn00b/include/psxsio.h b/libpsn00b/include/psxsio.h index df218ac..3f571d7 100644 --- a/libpsn00b/include/psxsio.h +++ b/libpsn00b/include/psxsio.h @@ -58,9 +58,10 @@ void *Sio1Callback(void (*func)(void)); // ORIGINAL void WaitSIO(void); +int kbhit(); #ifdef __cplusplus } #endif -#endif
\ No newline at end of file +#endif diff --git a/libpsn00b/include/string.h b/libpsn00b/include/string.h index 9cd1d64..365d238 100644 --- a/libpsn00b/include/string.h +++ b/libpsn00b/include/string.h @@ -29,8 +29,8 @@ char *strncat(char *s , const char *append, int n); char *strcpy(char *dst , const char *src); char *strncpy(char *dst , const char *src , int n); int strlen(const char *s); -//char *strchr(const char *s , int c); -//char *strrchr(const char *s , int c); +char *strchr(const char *s , int c); +char *strrchr(const char *s , int c); void *memmove(void *dst , const void *src , int n); void *memchr(void *s , int c , int n); |
