diff options
| author | John Wilbert M. Villamor <lameguy64@gmail.com> | 2019-04-06 10:11:07 +0800 |
|---|---|---|
| committer | John Wilbert M. Villamor <lameguy64@gmail.com> | 2019-04-06 10:11:07 +0800 |
| commit | f3e040230772f978540a71aea43dfde200992922 (patch) | |
| tree | bd8ca31b72dd01e24980b073854e263589530f56 /libpsn00b/include | |
| download | psn00bsdk-f3e040230772f978540a71aea43dfde200992922.tar.gz | |
First commit
Diffstat (limited to 'libpsn00b/include')
| -rw-r--r-- | libpsn00b/include/ctype.h | 7 | ||||
| -rw-r--r-- | libpsn00b/include/gtereg.h | 81 | ||||
| -rw-r--r-- | libpsn00b/include/hwregs_a.h | 97 | ||||
| -rw-r--r-- | libpsn00b/include/inline_c.h | 433 | ||||
| -rw-r--r-- | libpsn00b/include/inline_s.h | 230 | ||||
| -rw-r--r-- | libpsn00b/include/lzconfig.h | 68 | ||||
| -rw-r--r-- | libpsn00b/include/malloc.h | 17 | ||||
| -rw-r--r-- | libpsn00b/include/psxapi.h | 97 | ||||
| -rw-r--r-- | libpsn00b/include/psxetc.h | 15 | ||||
| -rw-r--r-- | libpsn00b/include/psxgpu.h | 556 | ||||
| -rw-r--r-- | libpsn00b/include/psxgte.h | 72 | ||||
| -rw-r--r-- | libpsn00b/include/psxkernel.h | 45 | ||||
| -rw-r--r-- | libpsn00b/include/psxpad.h | 108 | ||||
| -rw-r--r-- | libpsn00b/include/psxspu.h | 138 | ||||
| -rw-r--r-- | libpsn00b/include/stdarg.h | 122 | ||||
| -rw-r--r-- | libpsn00b/include/stdio.h | 47 | ||||
| -rw-r--r-- | libpsn00b/include/stdlib.h | 57 | ||||
| -rw-r--r-- | libpsn00b/include/string.h | 42 | ||||
| -rw-r--r-- | libpsn00b/include/strings.h | 18 | ||||
| -rw-r--r-- | libpsn00b/include/sys/fcntl.h | 20 | ||||
| -rw-r--r-- | libpsn00b/include/sys/types.h | 9 |
21 files changed, 2279 insertions, 0 deletions
diff --git a/libpsn00b/include/ctype.h b/libpsn00b/include/ctype.h new file mode 100644 index 0000000..b79498a --- /dev/null +++ b/libpsn00b/include/ctype.h @@ -0,0 +1,7 @@ +#ifndef _CTYPE_H +#define _CTYPE_H + +extern int tolower(int chr); +extern int toupper(int chr); + +#endif
\ No newline at end of file diff --git a/libpsn00b/include/gtereg.h b/libpsn00b/include/gtereg.h new file mode 100644 index 0000000..0d051fc --- /dev/null +++ b/libpsn00b/include/gtereg.h @@ -0,0 +1,81 @@ +# GTE register definitions for GNU assembler (as). +# +# Part of the PSn00bSDK Project by Lameguy64. +# 2019 Meido-Tek Productions + +# +# GTE data registers (use mfc2, mtc2, lwc2, swc2) +# +.set C2_VXY0, $0 +.set C2_VZ0, $1 +.set C2_VXY1, $2 +.set C2_VZ1, $3 +.set C2_VXY2, $4 +.set C2_VZ2, $5 +.set C2_RGB, $6 +.set C2_OTZ, $7 + +.set C2_IR0, $8 +.set C2_IR1, $9 +.set C2_IR2, $10 +.set C2_IR3, $11 +.set C2_SXY0, $12 +.set C2_SXY1, $13 +.set C2_SXY2, $14 +.set C2_SXYP, $15 + +.set C2_SZ0, $16 +.set C2_SZ1, $17 +.set C2_SZ2, $18 +.set C2_SZ3, $19 +.set C2_RGB0, $20 +.set C2_RGB1, $21 +.set C2_RGB2, $22 + +.set C2_MAC0, $24 +.set C2_MAC1, $25 +.set C2_MAC2, $26 +.set C2_MAC3, $27 +.set C2_IRGB, $28 +.set C2_ORGB, $29 +.set C2_LZCS, $30 +.set C2_LZCR, $31 + +# +# GTE control registers (use cfc2/ctc2) +# +.set C2_R11R12, $0 +.set C2_R13R21, $1 +.set C2_R22R23, $2 +.set C2_R31R32, $3 +.set C2_R33, $4 +.set C2_TRX, $5 +.set C2_TRY, $6 +.set C2_TRZ, $7 + +.set C2_L11L12, $8 +.set C2_L13L21, $9 +.set C2_L22L23, $10 +.set C2_L31L32, $11 +.set C2_L33, $12 +.set C2_RBK, $13 +.set C2_GBK, $14 +.set C2_BBK, $15 + +.set C2_LR1LR2, $16 +.set C2_LR3LG1, $17 +.set C2_LG2LG3, $18 +.set C2_LB1LB2, $19 +.set C2_LB3, $20 +.set C2_RFC, $21 +.set C2_GFC, $22 +.set C2_BFC, $23 + +.set C2_OFX, $24 +.set C2_OFY, $25 +.set C2_H, $26 +.set C2_DQA, $27 +.set C2_DQB, $28 +.set C2_ZSF3, $29 +.set C2_ZSF4, $30 +.set C2_FLAG, $31 diff --git a/libpsn00b/include/hwregs_a.h b/libpsn00b/include/hwregs_a.h new file mode 100644 index 0000000..a71a657 --- /dev/null +++ b/libpsn00b/include/hwregs_a.h @@ -0,0 +1,97 @@ +# Hardware register definitions for GNU assembler (as) +# +# Part of the PSn00bSDK Project by Lameguy64 +# 2019 Meido-Tek Productions + + +.set IOBASE, 0x1f80 # IO segment base + +# GPU +.set GP0, 0x1810 # Also GPUREAD +.set GP1, 0x1814 # Also GPUSTAT + +# CD +.set CD_STAT, 0x1800 +.set CD_CMD, 0x1801 # Also response FIFO +.set CD_DATA, 0x1802 # Also parameters +.set CD_IRQ, 0x1803 + +.set CD_REG0, 0x1800 +.set CD_REG1, 0x1801 +.set CD_REG2, 0x1802 +.set CD_REG3, 0x1803 + +.set COM_DELAY, 0x1020 + +# SPU (must be used with 16-bit load/store instructions) +.set SPU_VOICE_BASE, 0x1c00 + +.set SPU_MASTER_VOL, 0x1d80 +.set SPU_REVERB_VOL, 0x1d84 +.set SPU_KEY_ON, 0x1d88 +.set SPU_KEY_OFF, 0x1d8c +.set SPU_FM_MODE, 0x1d90 +.set SPU_NOISE_MODE, 0x1d94 +.set SPU_REVERB_ON, 0x1d98 +.set SPU_CHAN_STATUS, 0x1d9c + +.set SPU_REVERB_ADDR, 0x1da2 +.set SPU_IRQ_ADDR, 0x1da4 +.set SPU_ADDR, 0x1da6 +.set SPU_DATA, 0x1da8 + +.set SPUCNT, 0x1daa +.set SPUDTCNT, 0x1dac +.set SPUSTAT, 0x1dae + +.set SPU_CD_VOL, 0x1db0 +.set SPU_EXT_VOL, 0x1db4 +.set SPU_CURRENT_VOL, 0x1db8 + +.set SPU_VOICE_VOL_L, 0x00 +.set SPU_VOICE_VOL_R, 0x02 +.set SPU_VOICE_FREQ, 0x04 +.set SPU_VOICE_ADDR, 0x06 +.set SPU_VOICE_ADSR_L, 0x08 +.set SPU_VOICE_ADSR_H, 0x0a +.set SPU_VOICE_LOOP, 0x0e + +# Pads +.set JOY_TXRX, 0x1040 +.set JOY_STAT, 0x1044 +.set JOY_MODE, 0x1048 +.set JOY_CTRL, 0x104A +.set JOY_BAUD, 0x104E + +# IRQ +.set ISTAT, 0x1070 +.set IMASK, 0x1074 + +# DMA +.set DPCR, 0x10f0 +.set DICR, 0x10f4 + +.set D2_MADR, 0x10a0 +.set D2_BCR, 0x10a4 +.set D2_CHCR, 0x10a8 + +.set D4_MADR, 0x10c0 +.set D4_BCR, 0x10c4 +.set D4_CHCR, 0x10c8 + +.set D6_MADR, 0x10e0 +.set D6_BCR, 0x10e4 +.set D6_CHCR, 0x10e8 + +# Timers +.set T0_CNT, 0x1100 +.set T0_MODE, 0x1104 +.set T0_TGT, 0x1108 + +.set T1_CNT, 0x1110 +.set T1_MODE, 0x1114 +.set T1_TGT, 0x1118 + +.set T2_CNT, 0x1120 +.set T2_MODE, 0x1124 +.set T2_TGT, 0x1128 diff --git a/libpsn00b/include/inline_c.h b/libpsn00b/include/inline_c.h new file mode 100644 index 0000000..4341624 --- /dev/null +++ b/libpsn00b/include/inline_c.h @@ -0,0 +1,433 @@ +/* Inline GTE macros for the GNU C compiler. + * + * Part of the PSn00bSDK Project by Lameguy64. + * 2019 Meido-Tek Production + * + * All GTE commands can be used without having to pass your object file + * through some stupid tool such as DMPSX. Perhaps it was Sony's attempt + * to prevent people from quickly discovering the GTE commands from the + * official SDK easily? Though people could just extract the cop2 opcodes + * of an object file after it has been passed through DMPSX. + * + * Todo: A couple of GTE operation macros are still missing such as + * gte_rtv*() though they appear to be just variants of gte_mvmva more or + * less (gte_rtv0() is actually gte_mvmva(1, 0, 0, 3, 0) for example). + * + */ + +#ifndef _INLINE_C_H +#define _INLINE_C_H + +/* + * GTE load macros + */ + +/* Load a SVECTOR (passed as a pointer) to GTE V0 + */ +#define gte_ldv0( r0 ) __asm__ volatile ( \ + "lwc2 $0 , 0( %0 );" \ + "lwc2 $1 , 4( %0 );" \ + : \ + : "r"( r0 ) \ + : "$t0" ) + +/* Load a SVECTOR (passed as a pointer) to GTE V1 + */ +#define gte_ldv1( r0 ) __asm__ volatile ( \ + "lwc2 $2 , 0( %0 );" \ + "lwc2 $3 , 4( %0 );" \ + : \ + : "r"( r0 ) \ + : "$t0" ) + +/* Load a SVECTOR (passed as a pointer) to GTE V2 + */ +#define gte_ldv2( r0 ) __asm__ volatile ( \ + "lwc2 $4 , 0( %0 );" \ + "lwc2 $5 , 4( %0 );" \ + : \ + : "r"( r0 ) \ + : "$t0" ) + +/* Load three SVECTORs (passed as a pointer) to the GTE at once + */ +#define gte_ldv3( r0, r1, r2 ) __asm__ volatile ( \ + "lwc2 $0 , 0( %0 );" \ + "lwc2 $1 , 4( %0 );" \ + "lwc2 $2 , 0( %1 );" \ + "lwc2 $3 , 4( %1 );" \ + "lwc2 $4 , 0( %2 );" \ + "lwc2 $5 , 4( %2 );" \ + : \ + : "r"( r0 ), "r"( r1 ), "r"( r2 ) ) + +#define gte_ldrgb( r0 ) __asm__ volatile ( \ + "lwc2 $6 , 0( %0 );" \ + : \ + : "r"( r0 ) ) + +#define gte_ldopv2( r0 ) __asm__ volatile ( \ + "lwc2 $11, 8( %0 );" \ + "lwc2 $9 , 0( %0 );" \ + "lwc2 $10, 4( %0 );" \ + : \ + : "r"( r0 ) ) + +/* Sets the GTE offset + */ +#define gte_SetGeomOffset( r0, r1 ) __asm__ volatile ( \ + "sll $t0, %0, 16;" \ + "sll $t1, %1, 16;" \ + "ctc2 $t0, $24;" \ + "ctc2 $t1, $25;" \ + : \ + : "r"( r0 ), "r"( r1 ) \ + : "$t0", "$t1" ) + +#define gte_SetGeomScreen( r0 ) __asm__ volatile ( \ + "ctc2 %0, $26;" \ + : \ + : "r"( r0 ) ) + +#define gte_SetTransMatrix( r0 ) __asm__ volatile ( \ + "lw $t0, 20( %0 );" \ + "lw $t1, 24( %0 );" \ + "ctc2 $t0, $5;" \ + "lw $t2, 28( %0 );" \ + "ctc2 $t1, $6;" \ + "ctc2 $t2, $7;" \ + : \ + : "r"( r0 ) \ + : "$t2" ) + +#define gte_SetRotMatrix( r0 ) __asm__ volatile ( \ + "lw $t0, 0( %0 );" \ + "lw $t1, 4( %0 );" \ + "ctc2 $t0, $0;" \ + "ctc2 $t1, $1;" \ + "lw $t0, 8( %0 );" \ + "lw $t1, 12( %0 );" \ + "lhu $t2, 16( %0 );" \ + "ctc2 $t0, $2;" \ + "ctc2 $t1, $3;" \ + "ctc2 $t2, $4;" \ + : \ + : "r"( r0 ) \ + : "$t2" ) + +#define gte_SetLightMatrix( r0 ) __asm__ volatile ( \ + "lw $t0, 0( %0 );" \ + "lw $t1, 4( %0 );" \ + "ctc2 $t0, $8;" \ + "ctc2 $t1, $9;" \ + "lw $t0, 8( %0 );" \ + "lw $t1, 12( %0 );" \ + "lhu $t2, 16( %0 );" \ + "ctc2 $t0, $10;" \ + "ctc2 $t1, $11;" \ + "ctc2 $t2, $12;" \ + : \ + : "r"( r0 ) \ + : "$t2" ) + +#define gte_SetColorMatrix( r0 ) __asm__ volatile ( \ + "lw $t0, 0( %0 );" \ + "lw $t1, 4( %0 );" \ + "ctc2 $t0, $16;" \ + "ctc2 $t1, $17;" \ + "lw $t0, 8( %0 );" \ + "lw $t1, 12( %0 );" \ + "lhu $t2, 16( %0 );" \ + "ctc2 $t0, $18;" \ + "ctc2 $t1, $19;" \ + "ctc2 $t2, $20;" \ + : \ + : "r"( r0 ) \ + : "$t2" ) + +#define gte_SetBackColor( r0, r1, r2 ) __asm__ volatile ( \ + "sll $t0, %0, 4;" \ + "sll $t1, %1, 4;" \ + "sll $t2, %2, 4;" \ + "ctc2 $t0, $13;" \ + "ctc2 $t1, $14;" \ + "ctc2 $t2, $15;" \ + : \ + : "r"( r0 ), "r"( r1 ), "r"( r2 ) \ + : "$t0", "$t1", "$t2" ) + +/* + * GTE store macros + */ + +#define gte_otz( r0 ) __asm__ volatile ( \ + "swc2 $7, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_stflg( r0 ) __asm__ volatile ( \ + "cfc2 $t0, $31;" \ + "nop;" \ + "sw $t0, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_stsxy( r0 ) __asm__ volatile ( \ + "swc2 $14, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_stsxy0( r0 ) __asm__ volatile ( \ + "swc2 $12, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_stsxy1( r0 ) __asm__ volatile ( \ + "swc2 $13, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_stsxy2( r0 ) __asm__ volatile ( \ + "swc2 $14, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_stsxy3( r0, r1, r2 ) __asm__ volatile ( \ + "swc2 $12, 0( %0 );" \ + "swc2 $13, 0( %1 );" \ + "swc2 $14, 0( %2 );" \ + : \ + : "r"( r0 ), "r"( r1 ), "r"( r2 ) \ + : "memory" ) + +#define gte_stotz( r0 ) __asm__ volatile ( \ + "swc2 $7, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_stopz( r0 ) __asm__ volatile ( \ + "swc2 $24, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_strgb( r0 ) __asm__ volatile ( \ + "swc2 $22, 0( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_strgb3( r0, r1, r2 ) __asm__ volatile ( \ + "swc2 $20, 0( %0 );" \ + "swc2 $21, 0( %1 );" \ + "swc2 $22, 0( %2 );" \ + : \ + : "r"( r0 ), "r"( r1 ), "r" ( r2 ) \ + : "memory" ) + +#define gte_stsv( r0 ) __asm__ volatile ( \ + "mfc2 $t0, $9;" \ + "mfc2 $t1, $10;" \ + "mfc2 $t2, $11;" \ + "sh $t0, 0( %0 );" \ + "sh $t1, 2( %0 );" \ + "sh $t2, 4( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + +#define gte_stlvnl( r0 ) __asm__ volatile ( \ + "swc2 $25, 0( %0 );" \ + "swc2 $26, 4( %0 );" \ + "swc2 $27, 8( %0 );" \ + : \ + : "r"( r0 ) \ + : "memory" ) + + +/* + * GTE operation macros (does not need a stupid tool such as dmpsx!) + */ + +#define gte_rtps() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0180001;" ) + +#define gte_rtpt() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0280030;" ) + +#define gte_nclip() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x1400006;" ) + +#define gte_avsz3() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x158002D;" ) + +#define gte_avsz4() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x168002E;" ) + +#define gte_sqr0() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0A00428;" ) + +#define gte_sqr12() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0A80428;" ) + +#define gte_op0() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x170000C;" ) + +#define gte_op12() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x178000C;" ) + +#define gte_ncs() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0C8041E;" ) + +#define gte_nct() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0D80420;" ) + +#define gte_nccs() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x108041B;" ) \ + +#define gte_ncct() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x118043F;" ) + +#define gte_ncds() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0E80413;" ) + +#define gte_ncdt() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0F80416;" ) + +#define gte_cc() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x138041C;" ) + +#define gte_cdp() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x1280414;" ) + +#define gte_dcpl() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0680029;" ) + +#define gte_dpcs() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0780010;" ) + +#define gte_dpct() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0180001;" ) + +#define gte_intpl() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x0980011;" ) + +#define gte_gpf0() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x190003D;" ) + +#define gte_gpf12() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x198003D;" ) + +#define gte_gpl0() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x1A0003E;" ) + +#define gte_gpl12() __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 0x1A8003E;" ) + +#define gte_mvmva_core( r0 ) __asm__ volatile ( \ + "nop;" \ + "nop;" \ + "cop2 %0" \ + : \ + : "g"( r0 ) ) + +#define gte_mvmva(sf, mx, v, cv, lm) gte_mvmva_core( 0x0400012 | \ + ((sf)<<19) | ((mx)<<17) | ((v)<<15) | ((cv)<<13) | ((lm)<<10) ) + + +/* + * GTE operation macros without leading nops + * + * Checking assembler output when using these is advised. + */ + +#define gte_rtps_b() __asm__ volatile ( "cop2 0x0180001;" ) +#define gte_rtpt_b() __asm__ volatile ( "cop2 0x0280030;" ) +#define gte_nclip_b() __asm__ volatile ( "cop2 0x1400006;" ) +#define gte_avsz3_b() __asm__ volatile ( "cop2 0x158002D;" ) +#define gte_avsz4_b() __asm__ volatile ( "cop2 0x168002E;" ) +#define gte_sqr0_b() __asm__ volatile ( "cop2 0x0A00428;" ) +#define gte_sqr12_b() __asm__ volatile ( "cop2 0x0A80428;" ) +#define gte_op0_b() __asm__ volatile ( "cop2 0x170000C;" ) +#define gte_op12_b() __asm__ volatile ( "cop2 0x178000C;" ) +#define gte_ncs_b() __asm__ volatile ( "cop2 0x0C8041E;" ) +#define gte_nct_b() __asm__ volatile ( "cop2 0x0D80420;" ) +#define gte_nccs_b() __asm__ volatile ( "cop2 0x108041B;" ) +#define gte_ncct_b() __asm__ volatile ( "cop2 0x118043F;" ) +#define gte_ncds_b() __asm__ volatile ( "cop2 0x0E80413;" ) +#define gte_ncdt_b() __asm__ volatile ( "cop2 0x0F80416;" ) +#define gte_cc_b() __asm__ volatile ( "cop2 0x138041C;" ) +#define gte_cdp_b() __asm__ volatile ( "cop2 0x1280414;" ) +#define gte_dcpl_b() __asm__ volatile ( "cop2 0x0680029;" ) +#define gte_dpcs_b() __asm__ volatile ( "cop2 0x0780010;" ) +#define gte_dpct_b() __asm__ volatile ( "cop2 0x0180001;" ) +#define gte_intpl_b() __asm__ volatile ( "cop2 0x0980011;" ) +#define gte_gpf0_b() __asm__ volatile ( "cop2 0x190003D;" ) +#define gte_gpf12_b() __asm__ volatile ( "cop2 0x198003D;" ) +#define gte_gpl0_b() __asm__ volatile ( "cop2 0x1A0003E;" ) +#define gte_gpl12_b() __asm__ volatile ( "cop2 0x1A8003E;" ) +#define gte_mvmva_core_b( r0 ) __asm__ volatile ( \ + "cop2 %0" \ + : \ + : "g"( r0 ) ) +#define gte_mvmva_b(sf, mx, v, cv, lm) gte_mvmva_core_b( 0x0400012 | \ + ((sf)<<19) | ((mx)<<17) | ((v)<<15) | ((cv)<<13) | ((lm)<<10) ) + +#endif // _INLINE_C_H
\ No newline at end of file diff --git a/libpsn00b/include/inline_s.h b/libpsn00b/include/inline_s.h new file mode 100644 index 0000000..68e0d07 --- /dev/null +++ b/libpsn00b/include/inline_s.h @@ -0,0 +1,230 @@ +# Inline GTE macros for GNU assembler (as). +# +# Part of the PSn00bSDK Project by Lameguy64. +# 2019 Meido-Tek Productions +# +# Similar to inline_c.h, it does not require running your object file +# through some silly tool. + +.macro nRTPS + nop + nop + cop2 0x0180001 +.endm + +.macro nRTPT + nop + nop + cop2 0x0280030 +.endm + +.macro nNCLIP + nop + nop + cop2 0x1400006 +.endm + +.macro nAVSZ3 + nop + nop + cop2 0x158002D +.endm + +.macro nAVSZ4 + nop + nop + cop2 0x168002E +.endm + +.macro nMVMVA sf mx v cv lm + nop + nop + cop2 0x0400012|(\sf<<19)|(\mx<<17)|(\v<<15)|(\cv<<13)|(\lm<<10) +.endm + +.macro nSQR sf + nop + nop + cop2 0x0A00428|(\sf<<19) +.endm + +.macro nnOP sf lm # extra n to prevent conflict with the nop opcode + nop + nop + cop2 0x170000C|(\sf<<19)|(\lm<<10) +.endm + +.macro nNCS + nop + nop + cop2 0x0C8041E +.endm + +.macro nNCT + nop + nop + cop2 0x0D80420 +.endm + +.macro nNCCS + nop + nop + cop2 0x108041B +.endm + +.macro nNCCT + nop + nop + cop2 0x118043F +.endm + +.macro nNCDS + nop + nop + cop2 0x0E80413 +.endm + +.macro nNCDT + nop + nop + cop2 0x0F80416 +.endm + +.macro nCC + nop + nop + cop2 0x138041C +.endm + +.macro nCDP + nop + nop + cop2 0x1280414 +.endm + +.macro nDCPL + nop + nop + cop2 0x0680029 +.endm + +.macro nDPCS + nop + nop + cop2 0x0780010 +.endm + +.macro nDPCT + nop + nop + cop2 0x0180001 +.endm + +.macro nINTPL + nop + nop + cop2 0x0980011 +.endm + +.macro nGPF sf + nop + nop + cop2 0x190003D|(\sf<<19) +.endm + +.macro nGPL sf + nop + nop + cop2 0x1A0003E|(\sf<<19) +.endm + +# +# Macros without leading nops (for optimized usage) +# +.macro RTPS + cop2 0x0180001 +.endm + +.macro RTPT + cop2 0x0280030 +.endm + +.macro NCLIP + cop2 0x1400006 +.endm + +.macro AVSZ3 + cop2 0x158002D +.endm + +.macro AVSZ4 + cop2 0x168002E +.endm + +.macro MVMVA sf mx v cv lm + cop2 0x0400012|(\sf<<19)|(\mx<<17)|(\v<<15)|(\cv<<13)|(\lm<<10) +.endm + +.macro SQR sf + cop2 0x0A00428|(\sf<<19) +.endm + +.macro OP sf lm + cop2 0x170000C|(\sf<<19)|(\lm<<10) +.endm + +.macro NCS + cop2 0x0C8041E +.endm + +.macro NCT + cop2 0x0D80420 +.endm + +.macro NCCS + cop2 0x108041B +.endm + +.macro NCCT + cop2 0x118043F +.endm + +.macro NCDS + cop2 0x0E80413 +.endm + +.macro NCDT + cop2 0x0F80416 +.endm + +.macro CC + cop2 0x138041C +.endm + +.macro CDP + cop2 0x1280414 +.endm + +.macro DCPL + cop2 0x0680029 +.endm + +.macro DPCS + cop2 0x0780010 +.endm + +.macro DPCT + cop2 0x0180001 +.endm + +.macro INTPL + cop2 0x0980011 +.endm + +.macro GPF sf + cop2 0x190003D|(\sf<<19) +.endm + +.macro GPL sf + cop2 0x1A0003E|(\sf<<19) +.endm diff --git a/libpsn00b/include/lzconfig.h b/libpsn00b/include/lzconfig.h new file mode 100644 index 0000000..cb8a830 --- /dev/null +++ b/libpsn00b/include/lzconfig.h @@ -0,0 +1,68 @@ +/*! \file lzconfig.h + * \brief Library configuration header + * \details Define settings will only take effect when you recompile the library. + */ + +#ifndef _LZP_CONFIG_H +#define _LZP_CONFIG_H + + +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif + + +/* Set to TRUE to compile without data compression routines useful if you + * plan to use this library on a program that does not require said routines + * especially on a platform with limited memory (such as the PlayStation). + * + * This define will rule out lzCompress(), lzSetHashSizes() and + * lzResetHashSizes() functions and their associated functions. + */ +#define LZP_NO_COMPRESS TRUE + + +/* Set to TRUE to make default compression table sizes to maximum and works best + * when compressing large amounts of data. LZP_USE_MALLOC must be set to TRUE to + * prevent stack overflow errors. + * + * Do not enable this if you plan to compile for a platform with limited memory + * otherwise, the library will consume all memory and crash the system. + * + * This define only affects lzCompress(). + */ +#define LZP_MAX_COMPRESS FALSE + + +/* Uncomment to make the library use malloc() instead of array initializers to + * allocate hash tables. Enabling this is a must if you plan to use large hash + * and window table sizes. + */ +#define LZP_USE_MALLOC FALSE + + +/* Hash table sizes (in power-of-two multiple units) + * + * These define only affect lzCompress(). + */ +#if LZP_MAX_COMPRESS == TRUE + +// Minimal defaults +#define LZP_WINDOW_SIZE 17 +#define LZP_HASH1_SIZE 8 +#define LZP_HASH2_SIZE 10 + +#else + +// Maximum defaults +#define LZP_WINDOW_SIZE 17 +#define LZP_HASH1_SIZE 22 +#define LZP_HASH2_SIZE 24 + +#endif + + +#endif // _LZP_CONFIG_H diff --git a/libpsn00b/include/malloc.h b/libpsn00b/include/malloc.h new file mode 100644 index 0000000..e6cd126 --- /dev/null +++ b/libpsn00b/include/malloc.h @@ -0,0 +1,17 @@ +#ifndef _MALLOC_H +#define _MALLOC_H + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned int *GetBSSend(); +void InitHeap(unsigned int *addr, int size); +void *malloc(int size); +void free(void *ptr); + +#ifdef __cplusplus +} +#endif + +#endif // _MALLOC_H
\ No newline at end of file diff --git a/libpsn00b/include/psxapi.h b/libpsn00b/include/psxapi.h new file mode 100644 index 0000000..54b87ee --- /dev/null +++ b/libpsn00b/include/psxapi.h @@ -0,0 +1,97 @@ +#ifndef __PSXAPI__ +#define __PSXAPI__ + +typedef struct { // Device control block + char *name; + int flags; + int ssize; + char *desc; + void *f_init; + void *f_open; + void *f_inout; + void *f_close; + void *f_ioctl; + void *f_read; + void *f_write; + void *f_erase; + void *f_undelete; + void *f_firstfile; + void *f_nextfile; + void *f_format; + void *f_chdir; + void *f_rename; + void *f_remove; + void *f_testdevice; +} DCB; + +typedef struct { // File control block + int status; + unsigned int diskid; + void *trns_addr; + unsigned int trns_len; + unsigned int filepos; + unsigned int flags; + unsigned int lasterr; + DCB *dcb; + unsigned int filesize; + unsigned int lba; + unsigned int fcbnum; +} FCB; + +struct DIRENTRY { // Directory entry + char name[20]; + int attr; + int size; + struct DIRENTRY *next; + int head; + char system[4]; +}; + +// Not recommended to use these functions to install IRQ handlers + +typedef struct { + unsigned int* next; + unsigned int* func2; + unsigned int* func1; + unsigned int pad; +} INT_RP; + +extern void SysEnqIntRP(int pri, INT_RP *rp); +extern void SysDeqIntRP(int pri, INT_RP *rp); + +// Use event handlers instead + +extern int OpenEvent(unsigned int class, int spec, int mode, void (*func)()); +extern int CloseEvent(int ev_desc); +extern int EnableEvent(int ev_desc); +extern int DisableEvent(int ev_desc); + +// BIOS file functions + +extern int open(const char *name, int mode); +extern int close(int fd); +extern int seek(int fd, unsigned int offset, int mode); +extern int read(int fd, char *buff, unsigned int len); +extern int write(int fd, const char *buff, unsigned int len); +extern int ioctl(int fd, int cmd, int arg); +extern struct DIRENTRY *firstfile(const char *wildcard, struct DIRENTRY *entry); +extern struct DIRENTRY *nextfile(struct DIRENTRY *entry); +extern int erase(const char *name); +extern int chdir(const char *path); + +#define delete( p ) erase( p ) +#define cd( p ) chdir( p ) // For compatibility + +int AddDev(DCB *dcb); +int DelDev(const char *name); +extern void ListDev(); + +extern void EnterCriticalSection(); +extern void ExitCriticalSection(); + +extern void _96_init(); +extern void _96_remove(); + +extern void ChangeClearPAD(int mode); + +#endif diff --git a/libpsn00b/include/psxetc.h b/libpsn00b/include/psxetc.h new file mode 100644 index 0000000..67df29f --- /dev/null +++ b/libpsn00b/include/psxetc.h @@ -0,0 +1,15 @@ +#ifndef _PSXETC_H +#define _PSXETC_H + +#ifdef __cplusplus +extern "C" { +#endif + +void FntLoad(int x, int y); +char *FntSort(unsigned int *ot, char *pri, int x, int y, const char *text); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libpsn00b/include/psxgpu.h b/libpsn00b/include/psxgpu.h new file mode 100644 index 0000000..24d023a --- /dev/null +++ b/libpsn00b/include/psxgpu.h @@ -0,0 +1,556 @@ +#ifndef __PSXGPU_H +#define __PSXGPU_H + +// Low-level display parameters for DISPENV_RAW. A leftover from prototyping +#define DISP_WIDTH_256 0 +#define DISP_WIDTH_320 1 +#define DISP_WIDTH_384 64 +#define DISP_WIDTH_512 2 +#define DISP_WIDTH_640 3 + +#define DISP_HEIGHT_LOW 0 // Could be 240 for NTSC, 256 for PAL +#define DISP_HEIGHT_HIGH 4 // Could be 480 for NTSC, 512 for PAL +#define DISP_INTERLACE 32 +#define DISP_24BIT_COLOR 16 +#define DISP_MODE_NTSC 0 +#define DISP_MODE_PAL 8 + + +#define MODE_NTSC 0 +#define MODE_PAL 1 + + +// Vector macros + +#define setVector( v, _x, _y, _z ) \ + (v)->vx = _x, (v)->vy = _y, (v)->vz = _z + +#define setRECT( r, _x, _y, _w, _h ) \ + (v)->x = _x, (v)->y = _y, (v)->w = _w, (v)->h = _h + + + + + +// Primitive macros + + +#define setDrawTPage( p, tp, abr, x, y ) \ + ( (p)->code[0] = getTPage( tp, abr, x, y ), \ + setlen( p, 1 ), setcode( p, 0xe1 ) ) + +/** ORIGINAL FUNCTION **/ +#define setDrawTPageVal( p, tp ) \ + ( (p)->code[0] = tp, \ + setlen( p, 1 ), setcode( p, 0xe1 ) ) + +/*#define setVram2Vram( p ) ( setlen( p, 8 ), setcode( p, 0x80 ), \ + (p)->nop[0] = 0, (p)->nop[1] = 0, (p)->nop[2] = 0, (p)->nop[3] = 0 )*/ + +/* + +#define setTPagePri2( p, dth, tp, abr, x, y ) \ + ( (p)->code[0] = getTPage( tp, abr, x, y )|(dth<<9), \ + setlen( p, 1 ), setcode( p, 0xe1 ) )*/ + +/* + * Set primitive attributes + */ +#define setTPage( p, tp, abr, x, y ) \ + ( (p)->tpage = getTPage( tp, abr, x, y ) ) + +#define setClut( p, x, y ) \ + ( (p)->clut = getClut(x, y) ) + + +/* + * Set primitive colors + */ +#define setRGB0( p, r, g, b ) ( (p)->r0 = r, (p)->g0 = g, (p)->b0 = b ) +#define setRGB1( p, r, g, b ) ( (p)->r1 = r, (p)->g1 = g, (p)->b1 = b ) +#define setRGB2( p, r, g, b ) ( (p)->r2 = r, (p)->g2 = g, (p)->b2 = b ) +#define setRGB3( p, r, g, b ) ( (p)->r3 = r, (p)->g3 = g, (p)->b3 = b ) + + +/* + * Set primitive screen coordinates + */ +#define setXY0( p, _x0, _y0 ) \ + (p)->x0 = _x0, (p)->y0 = _y0 + +#define setXY2( p, _x0, _y0, _x1, _y1 ) \ + (p)->x0 = _x0, (p)->y0 = _y0, \ + (p)->x1 = _x1, (p)->y1 = _y1 + +#define setXY3( p, _x0, _y0, _x1, _y1, _x2, _y2 ) \ + (p)->x0 = _x0, (p)->y0 = _y0, \ + (p)->x1 = _x1, (p)->y1 = _y1, \ + (p)->x2 = _x2, (p)->y2 = _y2 + +#define setXY4( p, _x0, _y0, _x1, _y1, _x2, _y2, _x3, _y3 ) \ + (p)->x0 = _x0, (p)->y0 = _y0, \ + (p)->x1 = _x1, (p)->y1 = _y1, \ + (p)->x2 = _x2, (p)->y2 = _y2, \ + (p)->x3 = _x3, (p)->y3 = _y3 + +#define setWH( p, _w, _h ) \ + (p)->w = _w, (p)->h = _h + + +/* + * Set texture coordinates + */ +#define setUV0( p, _u0, _v0 ) \ + (p)->u0 = _u0, (p)->v0 = _v0 + +#define setUV3( p, _u0, _v0, _u1, _v1, _u2, _v2 ) \ + (p)->u0 = _u0, (p)->v0 = _v0, \ + (p)->u1 = _u1, (p)->v1 = _v1, \ + (p)->u2 = _u2, (p)->v2 = _v2 + +#define setUV4( p, _u0, _v0, _u1, _v1, _u2, _v2, _u3, _v3 ) \ + (p)->u0 = _u0, (p)->v0 = _v0, \ + (p)->u1 = _u1, (p)->v1 = _v1, \ + (p)->u2 = _u2, (p)->v2 = _v2, \ + (p)->u3 = _u3, (p)->v3 = _v3 + +#define setUVWH( p, _u0, _v0, _w, _h ) \ + (p)->u0 = _u0, (p)->v0 = _v0, \ + (p)->u1 = _u1+(_w), (p)->v1 = _v1, \ + (p)->u2 = _u2, (p)->v2 = _v2+(_h), \ + (p)->u2 = _u3+(_h), (p)->v2 = _v3+(_h) + + +/* + * 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 getlen( p ) ( ((P_TAG*)(p))->len ) +#define getaddr( p ) ( ((P_TAG*)(p))->addr ) +#define getcode( p ) ( ((P_TAG*)(p))->code ) + +#define nextPrim( p ) (void*)((((P_TAG*)(p))->addr)|0x80000000) +#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 catPrim( p0, p1 ) setaddr( p0, p1 ) +#define termPrim( p ) setaddr( p, 0xffffffff ) + +#define setSemiTrans( p, abe ) \ + ( (abe)?setcode( p, getcode( p )|0x2 ):setcode( p, getcode( p )&~0x2 ) ) + +#define setShadeTex( p, tge ) \ + ( (tge)?setcode( p, getcode( p )|0x1 ):setcode( p, getcode( p )&~0x1 ) ) + + +/* ORIGINAl CODE */ +#define setDrawMask( p, sb, mt ) \ + setlen( p, 1 ), p->code[0] = sb|(mt<<1), \ + setcode( p, 0xe6 ) + + +#define getTPage( tp, abr, x, y ) \ + ( (((x)&0x3ff)>>6) | (((y)>>8)<<4) | (((abr)&0x3)<<5) | (((tp)&0x3)<<7) ) + +#define getClut( x, y ) \ + ( ((y)<<6)|(((x)>>4)&0x3f) ) + + +/* + * Primitive initializers + */ +#define setPolyF3( p ) setlen( p, 4 ), setcode( p, 0x20 ) +#define setPolyFT3( p ) setlen( p, 7 ), setcode( p, 0x24 ) +#define setPolyG3( p ) setlen( p, 6 ), setcode( p, 0x30 ) +#define setPolyGT3( p ) setlen( p, 9 ), setcode( p, 0x34 ) + +#define setPolyF4( p ) setlen( p, 5 ), setcode( p, 0x28 ) +#define setPolyFT4( p ) setlen( p, 9 ), setcode( p, 0x2c ) +#define setPolyG4( p ) setlen( p, 8 ), setcode( p, 0x38 ) +#define setPolyGT4( p ) setlen( p, 12 ), setcode( p, 0x3c ) + +#define setSprt8( p ) setlen( p, 3 ), setcode( p, 0x74 ) +#define setSprt16( p ) setlen( p, 3 ), setcode( p, 0x7c ) +#define setSprt( p ) setlen( p, 4 ), setcode( p, 0x64 ) + +#define setTile1( p ) setlen( p, 2 ), setcode( p, 0x68 ) +#define setTile8( p ) setlen( p, 2 ), setcode( p, 0x70 ) +#define setTile16( p ) setlen( p, 2 ), setcode( p, 0x78 ) +#define setTile( p ) setlen( p, 3 ), setcode( p, 0x60 ) + +#define setLineG2( p ) setlen( p, 4 ), setcode( p, 0x50 ) + +#define setLineF4( p ) setlen( p, 6 ), setcode( p, 0x4c ), (p)->pad = 0x55555555 +#define setLineG4( p ) setlen( p, 9 ), setcode( p, 0x5c ), (p)->pad = 0x55555555, \ + (p)->p2 = 0, (p)->p3 = 0 + +#define setFill( p ) setlen( p, 3 ), setcode( p, 0x02 ) + + +/* + * Primitive definitions + */ +typedef struct { + unsigned int addr:24; + unsigned int len:8; + unsigned char r,g,b; + unsigned char code; +} P_TAG; + +/* + * Polygon primitive definitions + */ +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + short x1,y1; + short x2,y2; +} POLY_F3; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char u0,v0; + unsigned short clut; + short x1,y1; + unsigned char u1,v1; + unsigned short tpage; + short x2,y2; + unsigned char u2,v2; + unsigned short pad; +} POLY_FT3; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char r1,g1,b1,pad0; + short x1,y1; + unsigned char r2,g2,b2,pad1; + short x2,y2; +} POLY_G3; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char u0,v0; + unsigned short clut; + unsigned char r1,g1,b1,pad0; + short x1,y1; + unsigned char u1,v1; + unsigned short tpage; + unsigned char r2,g2,b2,pad1; + short x2,y2; + unsigned char u2,v2; + unsigned short pad2; +} POLY_GT3; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + short x1,y1; + short x2,y2; + short x3,y3; +} POLY_F4; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char u0,v0; + unsigned short clut; + short x1,y1; + unsigned char u1,v1; + unsigned short tpage; + short x2,y2; + unsigned char u2,v2; + unsigned short pad0; + short x3,y3; + unsigned char u3,v3; + unsigned short pad1; +} POLY_FT4; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char r1,g1,b1,pad0; + short x1,y1; + unsigned char r2,g2,b2,pad1; + short x2,y2; + unsigned char r3,g3,b3,pad2; + short x3,y3; +} POLY_G4; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char u0,v0; + unsigned short clut; + unsigned char r1,g1,b1,pad0; + short x1,y1; + unsigned char u1,v1; + unsigned short tpage; + unsigned char r2,g2,b2,pad1; + short x2,y2; + unsigned char u2,v2; + unsigned short pad2; + unsigned char r3,g3,b3,pad3; + short x3,y3; + unsigned char u3,v3; + unsigned short pad4; +} POLY_GT4; + +/* + * Line primitive definitions + */ +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + short x1,y1; +} LINE_F2; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char r1,g1,b1,p1; + short x1,y1; +} LINE_G2; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + short x1,y1; + short x2,y2; + unsigned int pad; +} LINE_F3; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char r1,g1,b1,p1; + short x1,y1; + unsigned char r2,g2,b2,p2; + short x2,y2; + unsigned int pad; +} LINE_G3; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + short x1,y1; + short x2,y2; + short x3,y3; + unsigned int pad; +} LINE_F4; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char r1,g1,b1,p1; + short x1,y1; + unsigned char r2,g2,b2,p2; + short x2,y2; + unsigned char r3,g3,b3,p3; + short x3,y3; + unsigned int pad; +} LINE_G4; + +/* + * Tile and sprite primitive definitions + */ +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + short w,h; +} TILE; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; +} TILE_1; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; +} TILE_8; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; +} TILE_16; + +/* + * Sprite primitive definitions + */ +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char u0,v0; + unsigned short clut; + unsigned short w,h; +} SPRT; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char u0,v0; + unsigned short clut; +} SPRT_8; + +typedef struct { + unsigned int tag; + unsigned char r0,g0,b0,code; + short x0,y0; + unsigned char u0,v0; + unsigned short clut; +} SPRT_16; + +/* + * VRAM fill and transfer primitive definitions + */ +typedef struct { + 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 { + unsigned int tag; + unsigned char p0,p1,p2,code; + unsigned short x0,y0; + unsigned short x1,y1; + unsigned short w,h; + unsigned int nop[4]; +} VRAM2VRAM; + +typedef struct { + unsigned int tag; + unsigned int code[15]; +} DR_ENV; + +typedef struct { + unsigned int tag; + unsigned int code[2]; +} DR_TWIN; + +typedef struct { + unsigned int tag; + unsigned int code[1]; +} DR_TPAGE; + +typedef struct { /* ORIGINAL CODE */ + unsigned int tag; + unsigned int code[1]; +} DR_MASK; + + +// General structs + +typedef struct { + short x,y; + short w,h; +} RECT; + +typedef struct { + 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 { + RECT disp; + RECT screen; + char isinter; + char isrgb24; + char reverse; + char pad; +} DISPENV; + +typedef struct { + RECT clip; // Drawing area + short ofs[2]; // GPU draw offset (relative to draw area) + RECT tw; // Texture window (doesn't do anything atm) + unsigned short tpage; // Initial tpage value + unsigned char dtd; // Dither processing flag (simply OR'ed to tpage) + unsigned char dfe; // Drawing to display area blocked/allowed (simply OR'ed to tpage) + unsigned char isbg; // Clear draw area if non-zero + unsigned char r0,g0,b0; // Draw area clear color (if isbg iz nonzero) + DR_ENV dr_env; // Draw mode packet area (used by PutDrawEnv) +} DRAWENV; + +typedef struct { + unsigned int mode; + RECT *crect; + unsigned int *caddr; + RECT *prect; + unsigned int *paddr; +} TIM_IMAGE; + + +#ifdef __cplusplus +extern "C" { +#endif + +// Function definitions (asm) + +void ResetGraph(int mode); + +int GetVideoMode(); +void SetVideoMode(int mode); + +void PutDispEnvRaw(DISPENV_RAW *disp); +void PutDispEnv(DISPENV *disp); +void PutDrawEnv(DRAWENV *draw); + +void SetDispMask(int mask); + +void VSync(); +void DrawSync(); +void WaitGPUcmd(); +void WaitGPUdma(); + +void VSyncCallback(void (*func)()); + +void LoadImage(RECT *rect, unsigned int *data); + +void ClearOTagR(unsigned int* ot, int n); +void DrawOTag(unsigned int* ot); + +void AddPrim(unsigned int* ot, void* pri); + +// Function definitions (C) + +int GetTimInfo(unsigned int *tim, TIM_IMAGE *timimg); + +DISPENV *SetDefDispEnv(DISPENV *disp, int x, int y, int w, int h); +DRAWENV *SetDefDrawEnv(DRAWENV *draw, int x, int y, int w, int h); + +#ifdef __cplusplus +} +#endif + +#endif
\ No newline at end of file diff --git a/libpsn00b/include/psxgte.h b/libpsn00b/include/psxgte.h new file mode 100644 index 0000000..0a8ded0 --- /dev/null +++ b/libpsn00b/include/psxgte.h @@ -0,0 +1,72 @@ +#ifndef _PSXGTE_H +#define _PSXGTE_H + + +#define ONE 4096 + + +// For compatibility with official library syntax +#define csin(a) isin(a) +#define ccos(a) icos(a) +#define rsin(a) isin(a) +#define rcos(a) icos(a) + + +typedef struct { + short m[3][3]; + int t[3]; +} MATRIX; + +typedef struct { + int vx, vy, vz; +} VECTOR; + +typedef struct { + short vx, vy, vz, pad; +} SVECTOR; + +typedef struct { + unsigned char r, g, b, cd; +} CVECTOR; + + +#ifdef __cplusplus +extern "C" { +#endif + +void InitGeom(); + +// Integer SIN/COS functions (4096 = 360 degrees) +// Does not use tables! +int isin(int a); +int icos(int a); + +// Higher precision integer sin/cos functions (131072 = 360 degrees) +// Does not use tables! +int hisin(int a); +int hicos(int a); + +void PushMatrix(); +void PopMatrix(); + +MATRIX *RotMatrix(SVECTOR *r, MATRIX *m); +MATRIX *HiRotMatrix(VECTOR *r, MATRIX *m); + +MATRIX *TransMatrix(MATRIX *m, VECTOR *r); +MATRIX *ScaleMatrix(MATRIX *m, VECTOR *s); + +MATRIX *MulMatrix(MATRIX *m0, MATRIX *m1); +MATRIX *MulMatrix0(MATRIX *m0, MATRIX *m1, MATRIX *m2); + +MATRIX *CompMatrixLV(MATRIX *v0, MATRIX *v1, MATRIX *v2); +VECTOR *ApplyMatrixLV(MATRIX *m, VECTOR *v0, VECTOR *v1); + +void VectorNormalS(VECTOR *v0, SVECTOR *v1); + +void Square0(VECTOR *v0, VECTOR *v1); + +#ifdef __cplusplus +} +#endif + +#endif // _PSXGTE_H diff --git a/libpsn00b/include/psxkernel.h b/libpsn00b/include/psxkernel.h new file mode 100644 index 0000000..0c55bcb --- /dev/null +++ b/libpsn00b/include/psxkernel.h @@ -0,0 +1,45 @@ +#ifndef _PSXKERNEL_H +#define _PSXKERNEL_H + +// Event descriptors +#define DescMask 0xff000000 // Event descriptor mask +#define DescTH DescMask +#define DescHW 0xf0000000 // Hardware event (IRQ) +#define DescEV 0xf1000000 // Event event +#define DescRC 0xf2000000 // Root counter event +#define DescUEV 0xf3000000 // User event +#define DescSW 0xf4000000 // BIOS event + +// Hardware events +#define HwVBLANK (DescHW|0x01) // VBlank +#define HwGPU (DescHW|0x02) // GPU +#define HwCdRom (DescHW|0x03) // CDROM +#define HwDMAC (DescHW|0x04) // DMA +#define HwRTC0 (DescHW|0x05) // Timer 0 +#define HwRTC1 (DescHW|0x06) // Timer 1 +#define HwRTC2 (DescHW|0x07) // Timer 2 +#define HwCNTL (DescHW|0x08) // Controller +#define HwSPU (DescHW|0x09) // SPU +#define HwPIO (DescHW|0x0a) // PIO & lightgun +#define HwSIO (DescHW|0x0b) // Serial + +#define HwCPU (DescHW|0x10) // Processor exception +#define HwCARD (DescHW|0x11) // Memory card (lower level BIOS functions) +#define HwCard_0 (DescHW|0x12) // Memory card (unused) +#define HwCard_1 (DescHW|0x13) // Memory card (unused) +#define SwCARD (DescSW|0x01) // Memory card (higher level BIOS functions) +#define SwMATH (DescSW|0x02) // Libmath related apparently, unknown purpose + +#define RCntCNT0 (DescRC|0x00) // Root counter 0 (dot clock) +#define RCntCNT1 (DescRC|0x01) // Horizontal sync +#define RCntCNT2 (DescRC|0x02) // 1/8 of system clock +#define RCntCNT3 (DescRC|0x03) // Vertical blank + +#define RCntMdINTR 0x1000 // General interrupt +#define RCntMdNOINTR 0x2000 // New device +#define RCntMdSC 0x0001 // Counter becomes zero +#define RCntMdSP 0x0000 // Unknown purpose +#define RCntMdFR 0x0000 +#define RCntMdGATE 0x0010 // Command acknowledged + +#endif // _PSXKERNEL_H
\ No newline at end of file diff --git a/libpsn00b/include/psxpad.h b/libpsn00b/include/psxpad.h new file mode 100644 index 0000000..09d17b1 --- /dev/null +++ b/libpsn00b/include/psxpad.h @@ -0,0 +1,108 @@ +/* Controller support header + * Part of PSn00bSDK + * 2019 Lameguy64 / Meido-Tek Productions + * + * Currently only provides a bunch of definitions and a few structs but no + * handling functions yet. Use the code in pad.s in one of the sample + * programs for the meantime instead. + * + * Work in progress, subject to change significantly in future releases. + */ + +#ifndef _PSXPAD_H +#define _PSXPAD_H + +// Pad button definitions for digital pad, joystick, dual analog, +// Dualshock and Jogcon +#define PAD_SELECT 1 +#define PAD_L3 2 +#define PAD_R3 4 +#define PAD_START 8 +#define PAD_UP 16 +#define PAD_RIGHT 32 +#define PAD_DOWN 64 +#define PAD_LEFT 128 +#define PAD_L2 256 +#define PAD_R2 512 +#define PAD_L1 1024 +#define PAD_R1 2048 +#define PAD_TRIANGLE 4096 +#define PAD_CIRCLE 8192 +#define PAD_CROSS 16384 +#define PAD_SQUARE 32768 + +// Mouse button definitions +#define MOUSE_RIGHT 1024 +#define MOUSE_LEFT 2048 + +// neGcon button definitions +#define NCON_START 8 +#define NCON_UP 16 +#define NCON_RIGHT 32 +#define NCON_DOWN 64 +#define NCON_LEFT 128 +#define NCON_R 256 +#define NCON_B 512 +#define NCON_A 1024 + +// Guncon button definitions +#define GCON_A 8 +#define GCON_TRIGGER 8192 +#define GCON_B 16384 + +// Struct for digital, joystick, dual analog and Dualshock controllers +typedef struct { + unsigned char stat; // Status + unsigned char len:4; // Data length (in halfwords) + unsigned char type:4; // Device type: + // 0x4 - digital pad + // 0x5 - analog joystick + // 0x7 - dual analog & Dualshock + unsigned short btn; // Button states + unsigned char rs_x,rs_y; // Right stick coordinates + unsigned char ls_x,ls_y; // Left stick coordinates +} PADTYPE; + +// Struct for a mouse controller +typedef struct { + unsigned char stat; + unsigned char len:4; + unsigned char type:4; // Device type (0x1) + unsigned char btn; + char x_mov; // X movement of mouse + char y_mov; // Y movement of mouse +} MOUSETYPE; + +// Struct for a neGcon controller (for Namco neGcon) +typedef struct { + unsigned char stat; + unsigned char len:4; + unsigned char type:4; // (0x2) + unsigned short btn; + unsigned char twist; // Controller twist + unsigned char btn_i; // I button value + unsigned char btn_ii; // II button value + unsigned char trg_l; // L trigger value +} NCONTYPE; + +// Struct for a Jogcon controller (for Namco Jogcon) +typedef struct { + unsigned char stat; + unsigned char len:4; + unsigned char type:4; // (0xE) + unsigned short btn; + unsigned short jog_rot; // Jog rotation +} JCONTYPE; + +// Struct for a Gun-Con controller (for Namco Gun-Con) +typedef struct { + unsigned char status; + unsigned char len:4; + unsigned char type:4; // (0x6) + unsigned short btn; + unsigned short gun_x; // Gun X position in dotclocks + unsigned short gun_y; // Gun Y position in scanlines +} GCONTYPE; + + +#endif
\ No newline at end of file diff --git a/libpsn00b/include/psxspu.h b/libpsn00b/include/psxspu.h new file mode 100644 index 0000000..a87e347 --- /dev/null +++ b/libpsn00b/include/psxspu.h @@ -0,0 +1,138 @@ +#ifndef __PSXSPU_H +#define __PSXSPU_H + +#include <sys/types.h> + +// Mask settings bits for specifying voice channels + +#define SPU_00CH (1<<0) +#define SPU_01CH (1<<1) +#define SPU_02CH (1<<2) +#define SPU_03CH (1<<3) +#define SPU_04CH (1<<4) +#define SPU_05CH (1<<5) +#define SPU_06CH (1<<6) +#define SPU_07CH (1<<7) +#define SPU_08CH (1<<8) +#define SPU_09CH (1<<9) +#define SPU_10CH (1<<10) +#define SPU_11CH (1<<11) +#define SPU_12CH (1<<12) +#define SPU_13CH (1<<13) +#define SPU_14CH (1<<14) +#define SPU_15CH (1<<15) +#define SPU_16CH (1<<16) +#define SPU_17CH (1<<17) +#define SPU_18CH (1<<18) +#define SPU_19CH (1<<19) +#define SPU_20CH (1<<20) +#define SPU_21CH (1<<21) +#define SPU_22CH (1<<22) +#define SPU_23CH (1<<23) + +#define SPU_0CH SPU_00CH +#define SPU_1CH SPU_01CH +#define SPU_2CH SPU_02CH +#define SPU_3CH SPU_03CH +#define SPU_4CH SPU_04CH +#define SPU_5CH SPU_05CH +#define SPU_6CH SPU_06CH +#define SPU_7CH SPU_07CH +#define SPU_8CH SPU_08CH +#define SPU_9CH SPU_09CH + +#define SPU_KEYCH(x) (1<<(x)) +#define SPU_VOICECH(x) SPU_KEYCH(x) + + +// Mask setting bits for SpuVoiceAttr.mask + +#define SPU_VOICE_VOLL (1<<0) // Left volume +#define SPU_VOICE_VOLR (1<<1) // Right volume +#define SPU_VOICE_VOLMODEL (1<<2) // Left volume mode +#define SPU_VOICE_VOLMODER (1<<3) // Right volume mode +#define SPU_VOICE_PITCH (1<<4) // Pitch tone +#define SPU_VOICE_NOTE (1<<5) // Pitch note +#define SPU_VOICE_SAMPLE_NOTE (1<<6) // Sample base frequency? +#define SPU_VOICE_WDSA (1<<7) // Sample start address (in SPU RAM) +#define SPU_VOICE_ADSR_AMODE (1<<8) // ADSR attack mode +#define SPU_VOICE_ADSR_SMODE (1<<9) // ADSR sustain mode +#define SPU_VOICE_ADSR_RMODE (1<<10) // ADSR release mode +#define SPU_VOICE_ADSR_AR (1<<11) // ADSR attack rate +#define SPU_VOICE_ADSR_DR (1<<12) // ADSR decay rate +#define SPU_VOICE_ADSR_SR (1<<13) // ADSR sustain rate +#define SPU_VOICE_ADSR_RR (1<<14) // ADSR release rate +#define SPU_VOICE_ADSR_SL (1<<15) // ADSR sustain level +#define SPU_VOICE_LSAX (1<<16) // Loop start address (in SPU RAM) +#define SPU_VOICE_ADSR_ADSR1 (1<<17) // adsr1 for VagAtr (?) +#define SPU_VOICE_ADSR_ADSR2 (1<<18) // adsr2 for VagAtr (?) + + +#define SPU_TRANSFER_BY_DMA 0 + + +typedef struct { + short left; + short right; +} SpuVolume; + +typedef struct { + SpuVolume vol; // 0 + unsigned short freq; // 4 + unsigned short addr; // 6 + unsigned short loop_addr; // 8 + unsigned short res; // 10 + unsigned int adsr_param; // 12 +} SpuVoiceRaw; + +typedef struct { + u_int voice; + u_int mask; + SpuVolume volume; + SpuVolume volmode; + SpuVolume volumex; + u_short pitch; + u_short note; + u_short sample_note; + short envx; + u_int addr; + u_int loop_addr; + int a_mode; + int s_mode; + int r_mode; + u_short ar; + u_short dr; + u_short sr; + u_short rr; + u_short sl; + u_short adsr1; + u_short adsr2; +} SpuVoiceAttr; + +#ifdef __cplusplus +extern "C" { +#endif + +void SpuInit(); + +void SpuSetVoiceRaw( int voice, SpuVoiceRaw* param ); +void SpuReverbOn( int voice ); +void SpuSetReverb(); + +void SpuSetReverbAddr( int addr ); +void SpuSetReverbVolume( int left, int right ); + + +void SpuSetKey(int on_off, u_int voice_bit); + +// SPU transfer functions +int SpuSetTransferMode(int mode); +int SpuSetTransferStartAddr(int addr); +int SpuWrite(unsigned char* addr, int size); +void SpuWait(); + +#ifdef __cplusplus +} +#endif + +#endif
\ No newline at end of file diff --git a/libpsn00b/include/stdarg.h b/libpsn00b/include/stdarg.h new file mode 100644 index 0000000..bdf4c00 --- /dev/null +++ b/libpsn00b/include/stdarg.h @@ -0,0 +1,122 @@ +/* Copyright (C) 1989-2018 Free Software Foundation, Inc. +This file is part of GCC. +GCC is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. +GCC is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. */ + +/* + * ISO C Standard: 7.15 Variable arguments <stdarg.h> + */ + +#ifndef _STDARG_H +#ifndef _ANSI_STDARG_H_ +#ifndef __need___va_list +#define _STDARG_H +#define _ANSI_STDARG_H_ +#endif /* not __need___va_list */ +#undef __need___va_list + +/* Define __gnuc_va_list. */ + +#ifndef __GNUC_VA_LIST +#define __GNUC_VA_LIST +typedef __builtin_va_list __gnuc_va_list; +#endif + +/* Define the standard macros for the user, + if this invocation was from the user program. */ +#ifdef _STDARG_H + +#define va_start(v,l) __builtin_va_start(v,l) +#define va_end(v) __builtin_va_end(v) +#define va_arg(v,l) __builtin_va_arg(v,l) +#if !defined(__STRICT_ANSI__) || __STDC_VERSION__ + 0 >= 199900L \ + || __cplusplus + 0 >= 201103L +#define va_copy(d,s) __builtin_va_copy(d,s) +#endif +#define __va_copy(d,s) __builtin_va_copy(d,s) + +/* Define va_list, if desired, from __gnuc_va_list. */ +/* We deliberately do not define va_list when called from + stdio.h, because ANSI C says that stdio.h is not supposed to define + va_list. stdio.h needs to have access to that data type, + but must not use that name. It should use the name __gnuc_va_list, + which is safe because it is reserved for the implementation. */ + +#ifdef _BSD_VA_LIST +#undef _BSD_VA_LIST +#endif + +#if defined(__svr4__) || (defined(_SCO_DS) && !defined(__VA_LIST)) +/* SVR4.2 uses _VA_LIST for an internal alias for va_list, + so we must avoid testing it and setting it here. + SVR4 uses _VA_LIST as a flag in stdarg.h, but we should + have no conflict with that. */ +#ifndef _VA_LIST_ +#define _VA_LIST_ +#ifdef __i860__ +#ifndef _VA_LIST +#define _VA_LIST va_list +#endif +#endif /* __i860__ */ +typedef __gnuc_va_list va_list; +#ifdef _SCO_DS +#define __VA_LIST +#endif +#endif /* _VA_LIST_ */ +#else /* not __svr4__ || _SCO_DS */ + +/* The macro _VA_LIST_ is the same thing used by this file in Ultrix. + But on BSD NET2 we must not test or define or undef it. + (Note that the comments in NET 2's ansi.h + are incorrect for _VA_LIST_--see stdio.h!) */ +#if !defined (_VA_LIST_) || defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__) || defined(WINNT) +/* The macro _VA_LIST_DEFINED is used in Windows NT 3.5 */ +#ifndef _VA_LIST_DEFINED +/* The macro _VA_LIST is used in SCO Unix 3.2. */ +#ifndef _VA_LIST +/* The macro _VA_LIST_T_H is used in the Bull dpx2 */ +#ifndef _VA_LIST_T_H +/* The macro __va_list__ is used by BeOS. */ +#ifndef __va_list__ +typedef __gnuc_va_list va_list; +#endif /* not __va_list__ */ +#endif /* not _VA_LIST_T_H */ +#endif /* not _VA_LIST */ +#endif /* not _VA_LIST_DEFINED */ +#if !(defined (__BSD_NET2__) || defined (____386BSD____) || defined (__bsdi__) || defined (__sequent__) || defined (__FreeBSD__)) +#define _VA_LIST_ +#endif +#ifndef _VA_LIST +#define _VA_LIST +#endif +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED +#endif +#ifndef _VA_LIST_T_H +#define _VA_LIST_T_H +#endif +#ifndef __va_list__ +#define __va_list__ +#endif + +#endif /* not _VA_LIST_, except on certain systems */ + +#endif /* not __svr4__ */ + +#endif /* _STDARG_H */ + +#endif /* not _ANSI_STDARG_H_ */ +#endif /* not _STDARG_H */
\ No newline at end of file diff --git a/libpsn00b/include/stdio.h b/libpsn00b/include/stdio.h new file mode 100644 index 0000000..5ee9e9b --- /dev/null +++ b/libpsn00b/include/stdio.h @@ -0,0 +1,47 @@ +#ifndef _STDIO_H +#define _STDIO_H + +#include <stdarg.h> + +#ifndef NULL +#define NULL (void*)0 +#endif + +// BIOS seek modes +#ifndef SEEK_SET +#define SEEK_SET 0 +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* warning: reportedly buggy */ +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// The following functions use the BIOS +extern void printf (const char *__format, ...); + +extern int getc(int __fd); +extern int putc(int __char, int __fd); +extern void putchar(int __c); + +// The following functions do not use the BIOS +int vsnprintf(char *string, unsigned int size, char *fmt, va_list ap); +int vsprintf(char *string, char *fmt, va_list ap); +int sprintf(char *string, char *fmt, ...); +int snprintf(char *string, unsigned int size, char *fmt, ...); + +#ifdef __cplusplus +} +#endif + +#endif // _STDIO_H
\ No newline at end of file diff --git a/libpsn00b/include/stdlib.h b/libpsn00b/include/stdlib.h new file mode 100644 index 0000000..3909796 --- /dev/null +++ b/libpsn00b/include/stdlib.h @@ -0,0 +1,57 @@ +/* + * stdlib.h + * + * Standard library functions + * + * Inherited from PSXSDK + */ + +#ifndef _STDLIB_H +#define _STDLIB_H + +#define RAND_MAX 0x7fff + +/* Conversion functions (not yet implemented) */ + +/* +extern int atoi(char *s); +extern long atol(char *s); +extern char atob(char *s); // Is this right? +*/ + +// Random number functions (not yet implemented) + +/* +int rand(); +void srand(unsigned int seed); +*/ + +// Quick sort (not yet implemented) + +//void qsort(void *base , int nel , int width , int (*cmp)(const void *,const void *)); + +// Memory allocation functions (not yet implemented, avoid using BIOS as they are reportedly buggy) + +/* +#warning "malloc() family of functions NEEDS MORE TESTING" + +void *malloc(int size); +void free(void *buf); +void *calloc(int number, int size); +void *realloc(void *buf , int n); +*/ + +int rand(); +void srand(unsigned long seed); + +int abs(int j); +long long strtoll(const char *nptr, char **endptr, int base); +long strtol(const char *nptr, char **endptr, int base); +long double strtold(const char *nptr, char **endptr); + +// Note: these use floats internally! +double strtod(const char *nptr, char **endptr); +float strtof(const char *nptr, char **endptr); + +#endif + diff --git a/libpsn00b/include/string.h b/libpsn00b/include/string.h new file mode 100644 index 0000000..95796d5 --- /dev/null +++ b/libpsn00b/include/string.h @@ -0,0 +1,42 @@ +/* + * string.h + * + * Prototypes for string functions of the C library + * + * PSXSDK + */ + +#ifndef _STRING_H +#define _STRING_H + +int strcmp(const char *dst , const char *src); +int strncmp(const char *dst , const char *src , int len); +char *strpbrk(const char *dst , const char *src); +char *strtok(char *s , char *set); +char *strstr(const char *big , const char *little); + +//int strspn(char *s , char *set); +//int strcspn(char *s , char *set); +//int index(char *s , int c); +//int rindex(char *s , int c); + +char *strcat(char *s , const char *append); +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); + +void *memmove(void *dst , const void *src , int n); +void *memchr(void *s , int c , int n); + +// Functions converted to ASM + +void *memcpy(void *dst , const void *src , int n); +void *memset(void *dst , char c , int n); +int memcmp(const void *b1 , const void *b2 , int n); + + +#endif + diff --git a/libpsn00b/include/strings.h b/libpsn00b/include/strings.h new file mode 100644 index 0000000..e5e88d4 --- /dev/null +++ b/libpsn00b/include/strings.h @@ -0,0 +1,18 @@ +/* + * strings.h + * + * PSXSDK + */ + +#ifndef _STRINGS_H +#define _STRINGS_H + +#include <string.h> + +#define bcopy(src,dst,len) memmove(dst,src,len) +#define bzero(ptr, len) memset(ptr, 0, len) +#define bcmp(b1,b2,len) memcmp(b1,b2,len) +#define index(s, c) strchr(s, c) +#define rindex(s, c) strrchr(s, c) + +#endif diff --git a/libpsn00b/include/sys/fcntl.h b/libpsn00b/include/sys/fcntl.h new file mode 100644 index 0000000..dfbf5b2 --- /dev/null +++ b/libpsn00b/include/sys/fcntl.h @@ -0,0 +1,20 @@ +#ifndef _SYS_FCNTL_H +#define _SYS_FCNTL_H + +// File control mode flags for BIOS file functions +// (many weren't documented in nocash docs) +#define FREAD 0x1 // Read +#define FWRITE 0x2 // Write +#define FNBLOCK 0x4 // Non-blocking read access +#define FRLOCK 0x10 // Read lock +#define FWLOCK 0x20 // Write lock +#define FAPPEND 0x100 // Append +#define FCREATE 0x200 // Create if not exist +#define FTRUNC 0x400 // Truncate to zero length +#define FSCAN 0x2000 // Scanning type +#define FRCOM 0x2000 // Remote command entry +#define FNBUF 0x4000 // No ring buffer and terminal interrupt +#define FASYNC 0x8000 // Asynchronous I/O +#define FNBLOCKS(a) (a<<16) // Number of blocks? (from nocash docs) + +#endif
\ No newline at end of file diff --git a/libpsn00b/include/sys/types.h b/libpsn00b/include/sys/types.h new file mode 100644 index 0000000..2f30a5f --- /dev/null +++ b/libpsn00b/include/sys/types.h @@ -0,0 +1,9 @@ +#ifndef _TYPES_H +#define _TYPES_H + +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; + +#endif // _TYPES_H
\ No newline at end of file |
