aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspicyjpeg <thatspicyjpeg@gmail.com>2023-04-05 01:30:55 +0200
committerspicyjpeg <thatspicyjpeg@gmail.com>2023-04-05 01:30:55 +0200
commitb4242acc35c522bd4d4a951a84933ba6f80d2015 (patch)
tree02cdff7a11329a7445baae489dd2b38225b12d96
parent651415f5b549b363dec971e2ef589cce098ee1f2 (diff)
downloadpsn00bsdk-b4242acc35c522bd4d4a951a84933ba6f80d2015.tar.gz
Clean up all headers, add and rename some BIOS APIs
-rw-r--r--examples/system/childexec/parent.c2
-rw-r--r--examples/system/console/main.c2
-rw-r--r--libpsn00b/include/assert.h9
-rw-r--r--libpsn00b/include/ctype.h5
-rw-r--r--libpsn00b/include/dlfcn.h5
-rw-r--r--libpsn00b/include/elf.h18
-rw-r--r--libpsn00b/include/hwregs_c.h5
-rw-r--r--libpsn00b/include/inline_c.h5
-rw-r--r--libpsn00b/include/ioctl.h19
-rw-r--r--libpsn00b/include/lzconfig.h68
-rw-r--r--libpsn00b/include/lzp/lzp.h34
-rw-r--r--libpsn00b/include/lzp/lzqlp.h32
-rw-r--r--libpsn00b/include/malloc.h8
-rw-r--r--libpsn00b/include/psxapi.h116
-rw-r--r--libpsn00b/include/psxcd.h5
-rw-r--r--libpsn00b/include/psxetc.h5
-rw-r--r--libpsn00b/include/psxgpu.h22
-rw-r--r--libpsn00b/include/psxgte.h5
-rw-r--r--libpsn00b/include/psxkernel.h45
-rw-r--r--libpsn00b/include/psxpad.h5
-rw-r--r--libpsn00b/include/psxpress.h5
-rw-r--r--libpsn00b/include/psxsio.h5
-rw-r--r--libpsn00b/include/psxsn.h5
-rw-r--r--libpsn00b/include/psxspu.h27
-rw-r--r--libpsn00b/include/stdio.h41
-rw-r--r--libpsn00b/include/stdlib.h7
-rw-r--r--libpsn00b/include/string.h7
-rw-r--r--libpsn00b/include/strings.h5
-rw-r--r--libpsn00b/include/sys/fcntl.h12
-rw-r--r--libpsn00b/include/sys/ioctl.h13
-rw-r--r--libpsn00b/include/sys/types.h12
-rw-r--r--libpsn00b/lzp/bit.h7
-rw-r--r--libpsn00b/lzp/compress.c16
-rw-r--r--libpsn00b/lzp/lzconfig.h (renamed from tools/lzpack/lzp/lzconfig.h)40
-rw-r--r--libpsn00b/lzp/lzp.h34
-rw-r--r--libpsn00b/lzp/lzqlp.h32
-rw-r--r--libpsn00b/psxapi/drivers.s32
-rw-r--r--libpsn00b/psxapi/fs.s18
-rw-r--r--libpsn00b/psxapi/stdio.s36
-rw-r--r--libpsn00b/psxapi/stubs.json62
-rw-r--r--libpsn00b/psxapi/sys.s58
-rw-r--r--libpsn00b/psxetc/interrupts.c4
-rw-r--r--libpsn00b/psxsio/tty.c10
-rw-r--r--tools/CMakeLists.txt6
44 files changed, 456 insertions, 453 deletions
diff --git a/examples/system/childexec/parent.c b/examples/system/childexec/parent.c
index 79c81f1..cfed11c 100644
--- a/examples/system/childexec/parent.c
+++ b/examples/system/childexec/parent.c
@@ -273,7 +273,7 @@ extern char child_exe[];
void run_child(void) {
// Arguments for the child program
- char *args[] =
+ const char *args[] =
{
"SAMPLE=0",
"SESSION=1",
diff --git a/examples/system/console/main.c b/examples/system/console/main.c
index b4f91b4..845ca95 100644
--- a/examples/system/console/main.c
+++ b/examples/system/console/main.c
@@ -25,7 +25,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <ioctl.h>
+#include <sys/ioctl.h>
#include <sys/fcntl.h>
#include <psxapi.h>
#include <psxetc.h>
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
diff --git a/libpsn00b/lzp/bit.h b/libpsn00b/lzp/bit.h
index 321160a..5e7ed23 100644
--- a/libpsn00b/lzp/bit.h
+++ b/libpsn00b/lzp/bit.h
@@ -1,5 +1,5 @@
-#ifndef _LZP_BIT_H
-#define _LZP_BIT_H
+
+#pragma once
extern const unsigned char* inPtr;
extern int inBytes;
@@ -21,6 +21,3 @@ int get_bits(int n);
#ifdef __cplusplus
}
#endif
-
-
-#endif // _LZP_BIT_H
diff --git a/libpsn00b/lzp/compress.c b/libpsn00b/lzp/compress.c
index 9cfc64d..16cb606 100644
--- a/libpsn00b/lzp/compress.c
+++ b/libpsn00b/lzp/compress.c
@@ -1,7 +1,7 @@
// Based on ilia muraviev's CRUSH compressor program which falls under public domain
#include <string.h>
-#if LZP_USE_MALLOC == TRUE
+#ifdef LZP_USE_MALLOC
#include <stdlib.h>
#endif
@@ -11,7 +11,7 @@
// Internal structure for hash table allocation sizes
-#if LZP_NO_COMPRESS == FALSE
+#ifndef LZP_NO_COMPRESS
struct {
short WindowSize; // Window size (17 - 23)
@@ -67,7 +67,7 @@ struct {
// LZ77
//
-#if LZP_NO_COMPRESS == FALSE
+#ifndef LZP_NO_COMPRESS
int update_hash1(int h, int c) {
@@ -108,13 +108,13 @@ int get_penalty(int a, int b) {
int lzCompress(void* outBuff, const void* inBuff, int inSize, int level) {
- #if LZP_USE_MALLOC == FALSE
+#ifndef LZP_USE_MALLOC
int head[HASH1_SIZE+HASH2_SIZE];
int prev[W_SIZE];
- #else
+#else
int* head = malloc(4*(HASH1_SIZE+HASH2_SIZE));
int* prev = malloc(4*W_SIZE);
- #endif
+#endif
int max_chain[] = {4, 256, 1<<12};
@@ -319,10 +319,10 @@ int lzCompress(void* outBuff, const void* inBuff, int inSize, int level) {
flush_bits();
- #if LZP_USE_MALLOC == TRUE
+#ifdef LZP_USE_MALLOC
free(head);
free(prev);
- #endif
+#endif
return(outBytes);
diff --git a/tools/lzpack/lzp/lzconfig.h b/libpsn00b/lzp/lzconfig.h
index 65e623c..83579a3 100644
--- a/tools/lzpack/lzp/lzconfig.h
+++ b/libpsn00b/lzp/lzconfig.h
@@ -3,29 +3,9 @@
* \details Define settings will only take effect when you recompile the library.
*/
-#ifndef _LZP_CONFIG_H
-#define _LZP_CONFIG_H
+#pragma once
-
-#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 FALSE
-
-
-/* Set to TRUE to make default compression table sizes to maximum and works best
+/* Uncomment 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.
*
@@ -34,21 +14,16 @@
*
* This define only affects lzCompress().
*/
-#define LZP_MAX_COMPRESS TRUE
-
+//#define LZP_MAX_COMPRESS
/* 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 TRUE
+//#define LZP_USE_MALLOC
-/* Hash table sizes (in power-of-two multiple units)
- *
- * These define only affect lzCompress().
- */
-#if LZP_MAX_COMPRESS == TRUE
+#if defined(PSN00BSDK) && !defined(LZP_MAX_COMPRESS)
// Minimal defaults
#define LZP_WINDOW_SIZE 17
@@ -57,12 +32,11 @@
#else
+#define LZP_USE_MALLOC
+
// 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/lzp/lzp.h b/libpsn00b/lzp/lzp.h
index 456de02..1aeea30 100644
--- a/libpsn00b/lzp/lzp.h
+++ b/libpsn00b/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/lzp/lzqlp.h b/libpsn00b/lzp/lzqlp.h
index 32ce0d7..127f263 100644
--- a/libpsn00b/lzp/lzqlp.h
+++ b/libpsn00b/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/psxapi/drivers.s b/libpsn00b/psxapi/drivers.s
index d991f90..c601201 100644
--- a/libpsn00b/psxapi/drivers.s
+++ b/libpsn00b/psxapi/drivers.s
@@ -32,10 +32,10 @@ _96_remove:
jr $t2
li $t1, 0x72
-.section .text.AddDummyTty
-.global AddDummyTty
-.type AddDummyTty, @function
-AddDummyTty:
+.section .text.add_nullcon_driver
+.global add_nullcon_driver
+.type add_nullcon_driver, @function
+add_nullcon_driver:
li $t2, 0xa0
jr $t2
li $t1, 0x99
@@ -66,26 +66,26 @@ _card_clear:
## B0 table functions (12)
-.section .text.AddDev
-.global AddDev
-.type AddDev, @function
-AddDev:
+.section .text.AddDrv
+.global AddDrv
+.type AddDrv, @function
+AddDrv:
li $t2, 0xb0
jr $t2
li $t1, 0x47
-.section .text.DelDev
-.global DelDev
-.type DelDev, @function
-DelDev:
+.section .text.DelDrv
+.global DelDrv
+.type DelDrv, @function
+DelDrv:
li $t2, 0xb0
jr $t2
li $t1, 0x48
-.section .text.ListDev
-.global ListDev
-.type ListDev, @function
-ListDev:
+.section .text.ListDrv
+.global ListDrv
+.type ListDrv, @function
+ListDrv:
li $t2, 0xb0
jr $t2
li $t1, 0x49
diff --git a/libpsn00b/psxapi/fs.s b/libpsn00b/psxapi/fs.s
index f225d64..8b6d57a 100644
--- a/libpsn00b/psxapi/fs.s
+++ b/libpsn00b/psxapi/fs.s
@@ -6,12 +6,12 @@
.set noreorder
-## B0 table functions (5)
+## B0 table functions (6)
-.section .text.chdir
-.global chdir
-.type chdir, @function
-chdir:
+.section .text.cd
+.global cd
+.type cd, @function
+cd:
li $t2, 0xb0
jr $t2
li $t1, 0x40
@@ -48,3 +48,11 @@ erase:
jr $t2
li $t1, 0x45
+.section .text.undelete
+.global undelete
+.type undelete, @function
+undelete:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x46
+
diff --git a/libpsn00b/psxapi/stdio.s b/libpsn00b/psxapi/stdio.s
index e65f871..14c6d03 100644
--- a/libpsn00b/psxapi/stdio.s
+++ b/libpsn00b/psxapi/stdio.s
@@ -6,7 +6,7 @@
.set noreorder
-## A0 table functions (13)
+## A0 table functions (14)
.section .text.open
.global open
@@ -16,10 +16,10 @@ open:
jr $t2
li $t1, 0x00
-.section .text.seek
-.global seek
-.type seek, @function
-seek:
+.section .text.lseek
+.global lseek
+.type lseek, @function
+lseek:
li $t2, 0xa0
jr $t2
li $t1, 0x01
@@ -56,6 +56,14 @@ ioctl:
jr $t2
li $t1, 0x05
+.section .text.isatty
+.global isatty
+.type isatty, @function
+isatty:
+ li $t2, 0xa0
+ jr $t2
+ li $t1, 0x07
+
.section .text.getc
.global getc
.type getc, @function
@@ -112,3 +120,21 @@ printf:
jr $t2
li $t1, 0x3f
+## B0 table functions (2)
+
+.section .text._get_errno
+.global _get_errno
+.type _get_errno, @function
+_get_errno:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x54
+
+.section .text._get_error
+.global _get_error
+.type _get_error, @function
+_get_error:
+ li $t2, 0xb0
+ jr $t2
+ li $t1, 0x55
+
diff --git a/libpsn00b/psxapi/stubs.json b/libpsn00b/psxapi/stubs.json
index 50ffb55..afa83c6 100644
--- a/libpsn00b/psxapi/stubs.json
+++ b/libpsn00b/psxapi/stubs.json
@@ -8,7 +8,7 @@
{
"type": "a",
"id": 1,
- "name": "seek",
+ "name": "lseek",
"file": "stdio.s"
},
{
@@ -37,6 +37,12 @@
},
{
"type": "a",
+ "id": 7,
+ "name": "isatty",
+ "file": "stdio.s"
+ },
+ {
+ "type": "a",
"id": 8,
"name": "getc",
"file": "stdio.s"
@@ -109,6 +115,12 @@
},
{
"type": "a",
+ "id": 81,
+ "name": "LoadExec",
+ "file": "sys.s"
+ },
+ {
+ "type": "a",
"id": 85,
"name": "_bu_init",
"file": "drivers.s"
@@ -128,7 +140,7 @@
{
"type": "a",
"id": 153,
- "name": "AddDummyTty",
+ "name": "add_nullcon_driver",
"file": "drivers.s"
},
{
@@ -139,6 +151,18 @@
},
{
"type": "a",
+ "id": 157,
+ "name": "GetConf",
+ "file": "sys.s"
+ },
+ {
+ "type": "a",
+ "id": 159,
+ "name": "SetMem",
+ "file": "sys.s"
+ },
+ {
+ "type": "a",
"id": 160,
"name": "_boot",
"file": "sys.s"
@@ -170,13 +194,13 @@
{
"type": "b",
"id": 0,
- "name": "_kernel_malloc",
+ "name": "alloc_kernel_memory",
"file": "sys.s"
},
{
"type": "b",
"id": 1,
- "name": "_kernel_free",
+ "name": "free_kernel_memory",
"file": "sys.s"
},
{
@@ -296,13 +320,13 @@
{
"type": "b",
"id": 24,
- "name": "SetDefaultExitFromException",
+ "name": "ResetEntryInt",
"file": "sys.s"
},
{
"type": "b",
"id": 25,
- "name": "SetCustomExitFromException",
+ "name": "HookEntryInt",
"file": "sys.s"
},
{
@@ -314,7 +338,7 @@
{
"type": "b",
"id": 64,
- "name": "chdir",
+ "name": "cd",
"file": "fs.s"
},
{
@@ -343,20 +367,26 @@
},
{
"type": "b",
+ "id": 70,
+ "name": "undelete",
+ "file": "fs.s"
+ },
+ {
+ "type": "b",
"id": 71,
- "name": "AddDev",
+ "name": "AddDrv",
"file": "drivers.s"
},
{
"type": "b",
"id": 72,
- "name": "DelDev",
+ "name": "DelDrv",
"file": "drivers.s"
},
{
"type": "b",
"id": 73,
- "name": "ListDev",
+ "name": "ListDrv",
"file": "drivers.s"
},
{
@@ -397,6 +427,18 @@
},
{
"type": "b",
+ "id": 84,
+ "name": "_get_errno",
+ "file": "stdio.s"
+ },
+ {
+ "type": "b",
+ "id": 85,
+ "name": "_get_error",
+ "file": "stdio.s"
+ },
+ {
+ "type": "b",
"id": 86,
"name": "GetC0Table",
"file": "sys.s"
diff --git a/libpsn00b/psxapi/sys.s b/libpsn00b/psxapi/sys.s
index e2505e1..40dcdff 100644
--- a/libpsn00b/psxapi/sys.s
+++ b/libpsn00b/psxapi/sys.s
@@ -6,7 +6,7 @@
.set noreorder
-## A0 table functions (8)
+## A0 table functions (11)
.section .text.b_setjmp
.global b_setjmp
@@ -48,6 +48,14 @@ FlushCache:
jr $t2
li $t1, 0x44
+.section .text.LoadExec
+.global LoadExec
+.type LoadExec, @function
+LoadExec:
+ li $t2, 0xa0
+ jr $t2
+ li $t1, 0x51
+
.section .text.SetConf
.global SetConf
.type SetConf, @function
@@ -56,6 +64,22 @@ SetConf:
jr $t2
li $t1, 0x9c
+.section .text.GetConf
+.global GetConf
+.type GetConf, @function
+GetConf:
+ li $t2, 0xa0
+ jr $t2
+ li $t1, 0x9d
+
+.section .text.SetMem
+.global SetMem
+.type SetMem, @function
+SetMem:
+ li $t2, 0xa0
+ jr $t2
+ li $t1, 0x9f
+
.section .text._boot
.global _boot
.type _boot, @function
@@ -74,18 +98,18 @@ GetSystemInfo:
## B0 table functions (27)
-.section .text._kernel_malloc
-.global _kernel_malloc
-.type _kernel_malloc, @function
-_kernel_malloc:
+.section .text.alloc_kernel_memory
+.global alloc_kernel_memory
+.type alloc_kernel_memory, @function
+alloc_kernel_memory:
li $t2, 0xb0
jr $t2
li $t1, 0x00
-.section .text._kernel_free
-.global _kernel_free
-.type _kernel_free, @function
-_kernel_free:
+.section .text.free_kernel_memory
+.global free_kernel_memory
+.type free_kernel_memory, @function
+free_kernel_memory:
li $t2, 0xb0
jr $t2
li $t1, 0x01
@@ -242,18 +266,18 @@ ReturnFromException:
jr $t2
li $t1, 0x17
-.section .text.SetDefaultExitFromException
-.global SetDefaultExitFromException
-.type SetDefaultExitFromException, @function
-SetDefaultExitFromException:
+.section .text.ResetEntryInt
+.global ResetEntryInt
+.type ResetEntryInt, @function
+ResetEntryInt:
li $t2, 0xb0
jr $t2
li $t1, 0x18
-.section .text.SetCustomExitFromException
-.global SetCustomExitFromException
-.type SetCustomExitFromException, @function
-SetCustomExitFromException:
+.section .text.HookEntryInt
+.global HookEntryInt
+.type HookEntryInt, @function
+HookEntryInt:
li $t2, 0xb0
jr $t2
li $t1, 0x19
diff --git a/libpsn00b/psxetc/interrupts.c b/libpsn00b/psxetc/interrupts.c
index b7bbd07..8bd11fc 100644
--- a/libpsn00b/psxetc/interrupts.c
+++ b/libpsn00b/psxetc/interrupts.c
@@ -210,7 +210,7 @@ void RestartCallback(void) {
// Install the ISR hook and prevent the kernel's internal handlers from
// automatically acknowledging SPI and timer IRQs.
- SetCustomExitFromException(&_isr_jmp_buf);
+ HookEntryInt(&_isr_jmp_buf);
ChangeClearPAD(0);
ChangeClearRCnt(0, 0);
ChangeClearRCnt(1, 0);
@@ -237,7 +237,7 @@ void StopCallback(void) {
DMA_DPCR = _saved_dma_dpcr & 0x07777777;
DMA_DICR = 0;
- SetDefaultExitFromException();
+ ResetEntryInt();
ChangeClearPAD(1);
ChangeClearRCnt(0, 1);
ChangeClearRCnt(1, 1);
diff --git a/libpsn00b/psxsio/tty.c b/libpsn00b/psxsio/tty.c
index a1b33c8..a88af85 100644
--- a/libpsn00b/psxsio/tty.c
+++ b/libpsn00b/psxsio/tty.c
@@ -8,7 +8,7 @@
* critical section or even from an interrupt handler.
*/
-#include <ioctl.h>
+#include <sys/ioctl.h>
#include <psxapi.h>
#include <psxsio.h>
#include <hwregs_c.h>
@@ -93,8 +93,8 @@ void AddSIO(int baud) {
close(0);
close(1);
- DelDev(_sio_dcb.name);
- AddDev(&_sio_dcb);
+ DelDrv(_sio_dcb.name);
+ AddDrv(&_sio_dcb);
open(_sio_dcb.name, 2);
open(_sio_dcb.name, 1);
}
@@ -102,6 +102,6 @@ void AddSIO(int baud) {
void DelSIO(void) {
SIO_Quit();
- DelDev(_sio_dcb.name);
- AddDummyTty();
+ DelDrv(_sio_dcb.name);
+ add_nullcon_driver();
}
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index c48bc10..9246e19 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -38,11 +38,7 @@ file(
)
add_library(lzp STATIC ${_sources})
-target_include_directories(
- lzp PUBLIC
- lzpack/lzp
- ${LIBPSN00B_PATH}/include/lzp
-)
+target_include_directories(lzp PUBLIC ${LIBPSN00B_PATH}/lzp)
## Executables