#ifndef _AR_LIB_H_ #define _AR_LIB_H_ #include // If you define AR_DEBUG in your NY_Debug_Prefix.h // then the standard file i/o functions will be redirected // to their Action Replay File Server (ARS) equivalents. // Also, printf will be defined as being cg_printf, and also output // to the ARS console. // ++cg[22/2/1998] // New stuff... // o I've done a kernal jump table patch mode for the comms lib. // Turn it on with the define below: #define ARLIB_KERNAL_PATCH_MODE // What this will do is patch the playstation OS jump table // to point to the ARS comms functions, so the standard PSX open/read/close // and printf will go to the ARS console. You'll notice the difference, // as PSX OS error messages and the "ResetGraph:jtb=..." message will // now come out on the ARS console. // o GNU C is now supported as well as Code Warrior #ifdef AR_DEBUG #ifdef __MWERKS__ asm unsigned char ar_rw(unsigned char v); asm unsigned char ar_r(void); asm void ar_w(unsigned char v); #else unsigned char ar_rw(unsigned char v); unsigned char ar_r(void); void ar_w(unsigned char v); #endif // cg_fsinit() is now a function as it patches the OS kernaljumptable for you void cg_fsinit(void); // If you want your program to exit gracefully and return to the console // make sure you call this before exitting to un-hook the kernal jump table // vectors we hijacked... void cg_shutdown(void); long cg_fopen(char *fname, int mode); void cg_fclose(long handle); long cg_fread(long handle, char *buf, long num); long cg_bload(char *fname, unsigned char *buf); void cg_print(char *t); int cg_printf(char *fmt,...); // NOTE: the define for open includes a +6 to skip past the // usual cdrom:\ prefix that filenames usually have on a PSX. #ifndef ARLIB_KERNAL_PATCH_MODE #define open(n,f) cg_fopen((n)+6,(f)) #define close(d) cg_fclose((d)) #define read(d, b, n) cg_fread((d),(b),(n)) #define printf cg_printf #endif #define bload(n, a) cg_bload((n),(a)) //lseek() & write() aren't supported. There's a kernal patch routine //which redirects writes to stdout (handle=0) and stderr (handle==2) //to the ARS console diags printout, so writes to those handles would //probably work....but not to any others. #define lseek(d, o, f) 0 #define write(d, b, n) 0 #else #define cg_fsinit() #define cg_fopen(x,y) (-1) #define cg_fclose(x) (0) #define cg_fread(x,y,z) (0) #define cg_bload(x, y) (0) #define cg_print(t) #define cg_printf // #define printf // #endif #endif