diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-04-05 01:30:55 +0200 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-04-05 01:30:55 +0200 |
| commit | b4242acc35c522bd4d4a951a84933ba6f80d2015 (patch) | |
| tree | 02cdff7a11329a7445baae489dd2b38225b12d96 /libpsn00b/include | |
| parent | 651415f5b549b363dec971e2ef589cce098ee1f2 (diff) | |
| download | psn00bsdk-b4242acc35c522bd4d4a951a84933ba6f80d2015.tar.gz | |
Clean up all headers, add and rename some BIOS APIs
Diffstat (limited to 'libpsn00b/include')
29 files changed, 227 insertions, 323 deletions
diff --git a/libpsn00b/include/assert.h b/libpsn00b/include/assert.h index 26b2023..8f8df74 100644 --- a/libpsn00b/include/assert.h +++ b/libpsn00b/include/assert.h @@ -2,12 +2,11 @@ * PSn00bSDK assert macro and internal logging * (C) 2022-2023 spicyjpeg - MPL licensed * - * Note that the _sdk_log() macro is used internally by PSn00bSDK to output - * debug messages and warnings. + * The _sdk_*() macros are used internally by PSn00bSDK to output messages when + * building in debug mode. */ -#ifndef __ASSERT_H -#define __ASSERT_H +#pragma once #include <stdio.h> @@ -59,5 +58,3 @@ void _assert_abort(const char *file, int line, const char *expr); } #endif - -#endif diff --git a/libpsn00b/include/ctype.h b/libpsn00b/include/ctype.h index ad78397..2fe0a42 100644 --- a/libpsn00b/include/ctype.h +++ b/libpsn00b/include/ctype.h @@ -3,8 +3,7 @@ * (C) 2019-2023 PSXSDK authors, Lameguy64, spicyjpeg - MPL licensed */ -#ifndef __CTYPE_H -#define __CTYPE_H +#pragma once #ifdef __cplusplus extern "C" { @@ -23,5 +22,3 @@ int toupper(int ch); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/dlfcn.h b/libpsn00b/include/dlfcn.h index 6192430..5e1e3b6 100644 --- a/libpsn00b/include/dlfcn.h +++ b/libpsn00b/include/dlfcn.h @@ -3,8 +3,7 @@ * (C) 2021-2022 spicyjpeg - MPL licensed */ -#ifndef __DLFCN_H -#define __DLFCN_H +#pragma once #include <stdint.h> #include <stddef.h> @@ -215,5 +214,3 @@ void *DL_GetDLLSymbol(const DLL *dll, const char *name); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/elf.h b/libpsn00b/include/elf.h index abfb3d5..b0ddf71 100644 --- a/libpsn00b/include/elf.h +++ b/libpsn00b/include/elf.h @@ -9,8 +9,7 @@ * converted to enums. */ -#ifndef __ELF_H -#define __ELF_H +#pragma once #include <stdint.h> @@ -121,18 +120,3 @@ typedef enum { STT_LOPROC = 13, /* Start of processor-specific */ STT_HIPROC = 15 /* End of processor-specific */ } Elf32_st_type; - -// If you need to add more constants, you may use the following Python snippet -// to quickly convert #defines to enums: -/* -import re -t = """<paste #defines here>""" -t = re.sub( - r"(0x[0-9a-f]+|0b[01]+|[0-9]+)", - lambda m: f"= {m.group(1)},", - t.replace("#define ", "\t").replace("#define\t", "\t") -) -print("typedef enum {\n" + t + "\n} NAME;") -*/ - -#endif diff --git a/libpsn00b/include/hwregs_c.h b/libpsn00b/include/hwregs_c.h index 7015101..3fd5b2c 100644 --- a/libpsn00b/include/hwregs_c.h +++ b/libpsn00b/include/hwregs_c.h @@ -3,8 +3,7 @@ * (C) 2022 spicyjpeg - MPL licensed */ -#ifndef __HWREGS_C_H -#define __HWREGS_C_H +#pragma once #include <stdint.h> @@ -130,5 +129,3 @@ #define BUS_EXP2_CFG _MMIO32(IOBASE | 0x101c) #define BUS_COM_DELAY _MMIO32(IOBASE | 0x1020) #define BUS_RAM_SIZE _MMIO32(IOBASE | 0x1060) - -#endif diff --git a/libpsn00b/include/inline_c.h b/libpsn00b/include/inline_c.h index 5facc1c..cb550b9 100644 --- a/libpsn00b/include/inline_c.h +++ b/libpsn00b/include/inline_c.h @@ -16,8 +16,7 @@ * compiled object files. */ -#ifndef _INLINE_C_H -#define _INLINE_C_H +#pragma once /* GTE load macros */ @@ -1612,5 +1611,3 @@ : "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 diff --git a/libpsn00b/include/ioctl.h b/libpsn00b/include/ioctl.h deleted file mode 100644 index 5c56422..0000000 --- a/libpsn00b/include/ioctl.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _IOCTL_H -#define _IOCTL_H - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef EOF -#define EOF -1 -#endif - -// General -#define FIONBLOCK (('f'<<8)|1) -#define FIOCSCAN (('f'<<8)|2) - -// disk -#define DIO_FORMAT (('d'<<8)|1) - -#endif
\ No newline at end of file diff --git a/libpsn00b/include/lzconfig.h b/libpsn00b/include/lzconfig.h deleted file mode 100644 index cb8a830..0000000 --- a/libpsn00b/include/lzconfig.h +++ /dev/null @@ -1,68 +0,0 @@ -/*! \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/lzp/lzp.h b/libpsn00b/include/lzp/lzp.h index 456de02..1aeea30 100644 --- a/libpsn00b/include/lzp/lzp.h +++ b/libpsn00b/include/lzp/lzp.h @@ -1,20 +1,29 @@ -/*! \file lzp.h - * \brief Main library header +/* + * liblzp data compression library + * (C) 2019 Lameguy64 - MPL licensed */ -/*! \mainpage - * \version 0.20b - * \author John Wilbert 'Lameguy64' Villamor +/** + * @file lzp.h + * @brief Utility library for file bundling and compression * - * \section creditsSection Credits - * - LZ77 data compression/decompression routines based from Ilya Muravyov's - * crush.cpp released under public domain. Refined and ported to C by Lameguy64. - * - CRC calculation routines based from Lammert Bies' lib_crc routines. + * @details This library implements a simple in-memory archive format which + * can be used to package and compress assets for faster loading, as well as a + * generic LZ77 compressor and matching decompressor. Two archive formats are + * supported, one uncompressed (.QLP) and one with individually compressed + * entries (.LZP). * + * This header provides the LZ77 compression API and functions to parse and + * decompress .LZP archives after they have been loaded into memory. + * + * @section creditsSection Credits + * - LZ77 data compression/decompression routines based from Ilya Muravyov's + * crush.cpp released under public domain. Refined and ported to C by + * Lameguy64. + * - CRC calculation routines based from Lammert Bies' lib_crc routines. */ -#ifndef _LZPACK_H -#define _LZPACK_H +#pragma once #include <stdint.h> #ifdef _WIN32 @@ -218,6 +227,3 @@ int lzpUnpackFile(void* buff, const LZP_HEAD* lzpack, int fileNum); #ifdef __cplusplus } #endif - - -#endif // _LZPACK_H diff --git a/libpsn00b/include/lzp/lzqlp.h b/libpsn00b/include/lzp/lzqlp.h index 32ce0d7..127f263 100644 --- a/libpsn00b/include/lzp/lzqlp.h +++ b/libpsn00b/include/lzp/lzqlp.h @@ -1,5 +1,23 @@ -#ifndef _QLP_H -#define _QLP_H +/* + * liblzp data compression library + * (C) 2019 Lameguy64 - MPL licensed + */ + +/** + * @file lzqlp.h + * @brief Utility library for file bundling + * + * @details This library implements a simple in-memory archive format which + * can be used to package and compress assets for faster loading, as well as a + * generic LZ77 compressor and matching decompressor. Two archive formats are + * supported, one uncompressed (.QLP) and one with individually compressed + * entries (.LZP). + * + * This header provides functions to parse .QLP archives and retrieve pointers + * to their contents after they have been loaded into memory. + */ + +#pragma once #include <stdint.h> #ifdef _WIN32 @@ -23,9 +41,17 @@ typedef struct { uint32_t offs; } QLP_FILE; + +// Function prototypes +#ifdef __cplusplus +extern "C" { +#endif + int qlpFileCount(const QLP_HEAD* qlpfile); const QLP_FILE* qlpFileEntry(int index, const QLP_HEAD* qlpfile); const void* qlpFileAddr(int index, const QLP_HEAD* qlpfile); int qlpFindFile(char* fileName, const QLP_HEAD* qlpfile); -#endif // _QLP_H
\ No newline at end of file +#ifdef __cplusplus +} +#endif diff --git a/libpsn00b/include/malloc.h b/libpsn00b/include/malloc.h deleted file mode 100644 index 75c3711..0000000 --- a/libpsn00b/include/malloc.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _MALLOC_H -#define _MALLOC_H - -#warning "<malloc.h> is deprecated, include <stdlib.h> instead" - -#include <stdlib.h> - -#endif // _MALLOC_H
\ No newline at end of file diff --git a/libpsn00b/include/psxapi.h b/libpsn00b/include/psxapi.h index 7353ed2..35ee040 100644 --- a/libpsn00b/include/psxapi.h +++ b/libpsn00b/include/psxapi.h @@ -1,10 +1,21 @@ /* * PSn00bSDK kernel API library - * (C) 2019-2022 Lameguy64, spicyjpeg - MPL licensed + * (C) 2019-2023 Lameguy64, spicyjpeg - MPL licensed */ -#ifndef __PSXAPI_H -#define __PSXAPI_H +/** + * @file psxapi.h + * @brief Kernel API library header + * + * @details This header provides access to most of the APIs made available by + * the system's BIOS, including basic file I/O, TTY output, controller and + * memory card drivers, threads, events as well as kernel memory allocation. + * + * For more information and up-to-date documentation on kernel APIs, see: + * https://psx-spx.consoledev.net/kernelbios/ + */ + +#pragma once #include <stdint.h> #include <stddef.h> @@ -12,13 +23,38 @@ /* Definitions */ -#define DescHW 0xf0000000 -#define DescSW 0xf4000000 - -#define HwCARD (DescHW|0x11) -#define HwCARD_1 (DescHW|0x12) -#define HwCARD_0 (DescHW|0x13) -#define SwCARD (DescHW|0x02) +// TODO: these desperately need to be cleaned up + +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +#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 + +#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) +#define HwCard_1 (DescHW|0x13) +#define SwCARD (DescSW|0x01) // Memory card (higher level BIOS functions) +#define SwMATH (DescSW|0x02) #define EvSpIOE 0x0004 #define EvSpERROR 0x8000 @@ -135,8 +171,6 @@ struct JMP_BUF { uint32_t gp; }; -// Not recommended to use these functions to install IRQ handlers - typedef struct { uint32_t *next; uint32_t *func2; @@ -158,7 +192,8 @@ typedef struct { #define FastExitCriticalSection() \ (IRQ_MASK = __saved_irq_mask) -/*#define FastEnterCriticalSection() { \ +#if 0 +#define FastEnterCriticalSection() { \ uint32_t r0, r1; \ __asm__ volatile( \ "mfc0 %0, $12;" \ @@ -179,9 +214,10 @@ typedef struct { "nop;" \ : "=r"(r0) :: \ ); \ -}*/ +} +#endif -/* API */ +/* BIOS API */ #ifdef __cplusplus extern "C" { @@ -199,23 +235,28 @@ int DisableEvent(int event); void DeliverEvent(uint32_t cl, uint32_t spec); void UnDeliverEvent(uint32_t cl, uint32_t spec); -int open(const char *name, int mode); +int open(const char *path, int mode); int close(int fd); -int seek(int fd, uint32_t offset, int mode); -int read(int fd, uint8_t *buff, size_t len); -int write(int fd, const uint8_t *buff, size_t len); +int lseek(int fd, uint32_t offset, int mode); +int read(int fd, void *buff, size_t len); +int write(int fd, const void *buff, size_t len); +int getc(int fd); +int putc(int ch, int fd); int ioctl(int fd, int cmd, int arg); +int isatty(int fd); struct DIRENTRY *firstfile(const char *wildcard, struct DIRENTRY *entry); struct DIRENTRY *nextfile(struct DIRENTRY *entry); -int erase(const char *name); -int chdir(const char *path); +int erase(const char *path); +int undelete(const char *path); +int cd(const char *path); -//#define cd(p) chdir(p) +int _get_errno(void); +int _get_error(int fd); -int AddDev(DCB *dcb); -int DelDev(const char *name); -void ListDev(void); -void AddDummyTty(void); +int AddDrv(DCB *dcb); +int DelDrv(const char *name); +void ListDrv(void); +void add_nullcon_driver(void); int EnterCriticalSection(void); void ExitCriticalSection(void); @@ -254,30 +295,33 @@ int ResetRCnt(int spec); void ChangeClearPAD(int mode); void ChangeClearRCnt(int t, int m); -uint32_t OpenTh(uint32_t (*func)(), uint32_t sp, uint32_t gp); -int CloseTh(uint32_t thread); -int ChangeTh(uint32_t thread); +int OpenTh(uint32_t (*func)(), uint32_t sp, uint32_t gp); +int CloseTh(int thread); +int ChangeTh(int thread); -int Exec(struct EXEC *exec, int argc, char **argv); +int Exec(struct EXEC *exec, int argc, const char **argv); +int LoadExec(const char *path, int argc, const char **argv); void FlushCache(void); void b_setjmp(struct JMP_BUF *buf); void b_longjmp(const struct JMP_BUF *buf, int param); -void SetDefaultExitFromException(void); -void SetCustomExitFromException(const struct JMP_BUF *buf); +void ResetEntryInt(void); +void HookEntryInt(const struct JMP_BUF *buf); void ReturnFromException(void); +int SetConf(int evcb, int tcb, uint32_t sp); +void GetConf(int *evcb, int *tcb, uint32_t *sp); +void SetMem(int size); + int GetSystemInfo(int index); void *GetB0Table(void); void *GetC0Table(void); -void *_kernel_malloc(int size); -void _kernel_free(void *ptr); +void *alloc_kernel_memory(int size); +void free_kernel_memory(void *ptr); void _boot(void); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/psxcd.h b/libpsn00b/include/psxcd.h index 78c90db..fc9c391 100644 --- a/libpsn00b/include/psxcd.h +++ b/libpsn00b/include/psxcd.h @@ -21,8 +21,7 @@ * library extension is considered for future development. */ -#ifndef __PSXCD_H -#define __PSXCD_H +#pragma once #include <stdint.h> @@ -1073,5 +1072,3 @@ int CdLoadSession(int session); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/psxetc.h b/libpsn00b/include/psxetc.h index e45abf4..8dd1dd5 100644 --- a/libpsn00b/include/psxetc.h +++ b/libpsn00b/include/psxetc.h @@ -13,8 +13,7 @@ * separate header). */ -#ifndef __PSXETC_H -#define __PSXETC_H +#pragma once /* IRQ and DMA channel definitions */ @@ -239,5 +238,3 @@ void StopCallback(void); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/psxgpu.h b/libpsn00b/include/psxgpu.h index 78d8342..9b99fe9 100644 --- a/libpsn00b/include/psxgpu.h +++ b/libpsn00b/include/psxgpu.h @@ -3,8 +3,24 @@ * (C) 2019-2023 Lameguy64, spicyjpeg - MPL licensed */ -#ifndef __PSXGPU_H -#define __PSXGPU_H +/** + * @file psxgpu.h + * @brief GPU library header + * + * @details This library provides access to the PS1's GPU through a fully + * asynchronous command queue, which allows GPU commands to be batched and sent + * efficiently in the background without stalling the CPU. Helper structures + * and macros to initialize, generate and link GPU display lists in memory are + * also provided, in addition to support for asynchronous VRAM data transfers + * and a debug font API that can be used to easily draw text overlays for + * debugging purposes. + * + * This library is for the most part a drop-in replacement for the official + * SDK's GPU library and is only missing a handful of functions, mainly related + * to Kanji debug fonts and command queue pausing. + */ + +#pragma once #include <stdint.h> #include <stddef.h> @@ -603,5 +619,3 @@ char *FntFlush(int id); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/psxgte.h b/libpsn00b/include/psxgte.h index 91dfd6a..2200a55 100644 --- a/libpsn00b/include/psxgte.h +++ b/libpsn00b/include/psxgte.h @@ -14,8 +14,7 @@ * registers and issue commands to the GTE. */ -#ifndef __PSXGTE_H -#define __PSXGTE_H +#pragma once #include <stdint.h> @@ -259,5 +258,3 @@ void Square0(VECTOR *v0, VECTOR *v1); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/psxkernel.h b/libpsn00b/include/psxkernel.h deleted file mode 100644 index 0c55bcb..0000000 --- a/libpsn00b/include/psxkernel.h +++ /dev/null @@ -1,45 +0,0 @@ -#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 index 32f7f8a..09f28c4 100644 --- a/libpsn00b/include/psxpad.h +++ b/libpsn00b/include/psxpad.h @@ -11,8 +11,7 @@ * Reference: https://gist.github.com/scanlime/5042071 */ -#ifndef _PSXPAD_H -#define _PSXPAD_H +#pragma once #include <stdint.h> @@ -234,5 +233,3 @@ typedef struct __attribute__((packed)) _MemCardRequest { uint8_t checksum; // = lba_h ^ lba_l ^ data (CMD_WRITE only) uint8_t dummy2[3]; } MemCardRequest; - -#endif
\ No newline at end of file diff --git a/libpsn00b/include/psxpress.h b/libpsn00b/include/psxpress.h index ea0c2ec..f26e030 100644 --- a/libpsn00b/include/psxpress.h +++ b/libpsn00b/include/psxpress.h @@ -22,8 +22,7 @@ * anyway. */ -#ifndef __PSXPRESS_H -#define __PSXPRESS_H +#pragma once #include <stdint.h> #include <stddef.h> @@ -512,5 +511,3 @@ void DecDCTvlcBuild(DECDCTTAB *table); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/psxsio.h b/libpsn00b/include/psxsio.h index 449e43a..8932830 100644 --- a/libpsn00b/include/psxsio.h +++ b/libpsn00b/include/psxsio.h @@ -18,8 +18,7 @@ * debugging purposes. */ -#ifndef __PSXSIO_H -#define __PSXSIO_H +#pragma once #include <stdint.h> @@ -280,5 +279,3 @@ void DelSIO(void); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/psxsn.h b/libpsn00b/include/psxsn.h index 53a3cd9..1acbc18 100644 --- a/libpsn00b/include/psxsn.h +++ b/libpsn00b/include/psxsn.h @@ -18,8 +18,7 @@ * in PSn00bSDK they are part of libpsxapi. */ -#ifndef __PSXSN_H -#define __PSXSN_H +#pragma once #include <stddef.h> @@ -50,5 +49,3 @@ int PClseek(int fd, int offset, PCDRV_SeekMode mode); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/psxspu.h b/libpsn00b/include/psxspu.h index cdc3ac7..d829821 100644 --- a/libpsn00b/include/psxspu.h +++ b/libpsn00b/include/psxspu.h @@ -1,10 +1,25 @@ /* * PSn00bSDK SPU library - * (C) 2019-2022 Lameguy64, spicyjpeg - MPL licensed + * (C) 2019-2023 Lameguy64, spicyjpeg - MPL licensed */ -#ifndef __PSXSPU_H -#define __PSXSPU_H +/** + * @file psxspu.h + * @brief SPU library header + * + * @details The PSn00bSDK SPU library allows for SPU initialization, DMA + * transfers (both sample data uploads and capture buffer reads) and provides + * helper macros for accessing SPU control registers, which can be used to + * control sample playback on each channel, configure reverb and enable more + * advanced features such as interrupts. + * + * This library currently has fewer functions than its Sony SDK counterpart, in + * part because it is not yet complete but also since the vast majority of the + * Sony library's functions are redundant, inefficient and can be replaced with + * simple SPU register writes. + */ + +#pragma once #include <stdint.h> #include <stddef.h> @@ -12,6 +27,7 @@ /* Definitions */ +#if 0 typedef enum _SPU_AttrMask { SPU_VOICE_VOLL = 1 << 0, // Left volume SPU_VOICE_VOLR = 1 << 1, // Right volume @@ -33,6 +49,7 @@ typedef enum _SPU_AttrMask { SPU_VOICE_ADSR_ADSR1 = 1 << 17, SPU_VOICE_ADSR_ADSR2 = 1 << 18 } SPU_AttrMask; +#endif typedef enum _SPU_TransferMode { SPU_TRANSFER_BY_DMA = 0, @@ -46,6 +63,7 @@ typedef enum _SPU_WaitMode { /* Structure definitions */ +#if 0 typedef struct _SpuVolume { int16_t left, right; } SpuVolume; @@ -72,6 +90,7 @@ typedef struct _SpuCommonAttr { SpuVolume mvol, mvolmode, mvolx; SpuExtAttr cd, ext; } SpuCommonAttr; +#endif /* Macros */ @@ -143,5 +162,3 @@ int SpuIsTransferCompleted(int mode); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/stdio.h b/libpsn00b/include/stdio.h index 8aaf4c7..1bb5b74 100644 --- a/libpsn00b/include/stdio.h +++ b/libpsn00b/include/stdio.h @@ -1,39 +1,26 @@ -#ifndef _STDIO_H -#define _STDIO_H +/* + * PSn00bSDK standard library + * (C) 2019-2023 Lameguy64, spicyjpeg - MPL licensed + */ -#include <stdarg.h> +#pragma once -// 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 +#include <stdarg.h> #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); +/* String I/O API (provided by BIOS) */ -#define fputc(__char, __fd) putc(__char, __fd) -#define fgetc(__char, __fd) getc(__char, __fd) +int printf(const char *fmt, ...); +char *gets(char *str); +void puts(const char *str); +int getchar(void); +void putchar(int ch); -// Console TTY -extern void gets(char *__s); -extern void puts(const char *__s); -extern int getchar(void); -extern void putchar(int __c); +/* String formatting API (built-in) */ -// The following functions do not use the BIOS int vsnprintf(char *string, unsigned int size, const char *fmt, va_list ap); int vsprintf(char *string, const char *fmt, va_list ap); int sprintf(char *string, const char *fmt, ...); @@ -45,5 +32,3 @@ int sscanf(const char *str, const 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 index 49ae7b9..19761df 100644 --- a/libpsn00b/include/stdlib.h +++ b/libpsn00b/include/stdlib.h @@ -1,10 +1,9 @@ /* * PSn00bSDK standard library - * (C) 2019-2022 PSXSDK authors, Lameguy64, spicyjpeg - MPL licensed + * (C) 2019-2023 PSXSDK authors, Lameguy64, spicyjpeg - MPL licensed */ -#ifndef __STDLIB_H -#define __STDLIB_H +#pragma once #include <stddef.h> @@ -59,5 +58,3 @@ void free(void *ptr); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/string.h b/libpsn00b/include/string.h index 84afbae..6310b1a 100644 --- a/libpsn00b/include/string.h +++ b/libpsn00b/include/string.h @@ -1,10 +1,9 @@ /* * PSn00bSDK standard library - * (C) 2019-2022 PSXSDK authors, Lameguy64, spicyjpeg - MPL licensed + * (C) 2019-2023 PSXSDK authors, Lameguy64, spicyjpeg - MPL licensed */ -#ifndef __STRING_H -#define __STRING_H +#pragma once #include <stddef.h> @@ -39,5 +38,3 @@ char *strtok(char *str, const char *delim); #ifdef __cplusplus } #endif - -#endif diff --git a/libpsn00b/include/strings.h b/libpsn00b/include/strings.h index 7223ab9..0595637 100644 --- a/libpsn00b/include/strings.h +++ b/libpsn00b/include/strings.h @@ -3,8 +3,7 @@ * (C) 2019-2022 PSXSDK authors, Lameguy64, spicyjpeg - MPL licensed */ -#ifndef __STRINGS_H -#define __STRINGS_H +#pragma once #include <string.h> @@ -15,5 +14,3 @@ #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 index dfbf5b2..54c2d05 100644 --- a/libpsn00b/include/sys/fcntl.h +++ b/libpsn00b/include/sys/fcntl.h @@ -1,8 +1,10 @@ -#ifndef _SYS_FCNTL_H -#define _SYS_FCNTL_H +/* + * PSn00bSDK kernel API library + * (C) 2019-2023 Lameguy64, spicyjpeg - MPL licensed + */ + +#pragma once -// 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 @@ -16,5 +18,3 @@ #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/ioctl.h b/libpsn00b/include/sys/ioctl.h new file mode 100644 index 0000000..af65e5d --- /dev/null +++ b/libpsn00b/include/sys/ioctl.h @@ -0,0 +1,13 @@ +/* + * PSn00bSDK kernel API library + * (C) 2019-2023 Lameguy64, spicyjpeg - MPL licensed + */ + +#pragma once + +#define EOF -1 + +#define FIONBLOCK (('f'<<8)|1) +#define FIOCSCAN (('f'<<8)|2) + +#define DIOFORMAT (('d'<<8)|1) diff --git a/libpsn00b/include/sys/types.h b/libpsn00b/include/sys/types.h index da43590..9075b5e 100644 --- a/libpsn00b/include/sys/types.h +++ b/libpsn00b/include/sys/types.h @@ -1,13 +1,13 @@ -#ifndef _TYPES_H -#define _TYPES_H +/* + * PSn00bSDK standard library + * (C) 2019-2023 Lameguy64, spicyjpeg - MPL licensed + */ -//#warning "<sys/types.h> and u_* types are deprecated, include <stdint.h> instead" +#pragma once -//#include <stdint.h> +//#warning "<sys/types.h> and u_* types are deprecated, use <stdint.h> instead" 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 |
