From 8deeb216cbff4e578284fc040d8f0b51e96d4b04 Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Wed, 29 Jun 2022 13:09:57 +0200 Subject: Add -g to default flags, update changelog and known bugs --- doc/known_bugs.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'doc') diff --git a/doc/known_bugs.md b/doc/known_bugs.md index e39da43..9e83f03 100644 --- a/doc/known_bugs.md +++ b/doc/known_bugs.md @@ -1,8 +1,9 @@ # Known PSn00bSDK bugs -This is an incomplete list of things that are currently broken (or not behaving -as they should, or untested on real hardware) and haven't yet been fixed. +This is an incomplete list of things that are known to be currently broken (or +not behaving as they should, or untested on real hardware) and haven't yet been +fixed. ## Toolchain @@ -15,18 +16,28 @@ as they should, or untested on real hardware) and haven't yet been fixed. them. It might be necessary to list such symbols in a dummy array to prevent the compiler from stripping them away from the executable. +- Link-time optimization is broken due to GCC not supporting it when linking + weak functions written in assembly. + ## Libraries `psxgpu`: -- In some *very rare* cases, `VSync()` seems to crash the system by performing - unaligned accesses for unknown reasons. +- `LoadImage()` and `StoreImage()` use DMA to transfer data to/from the GPU. + As the DMA channel is configured to transfer 8 words (32 bytes) at a time, + the length of the data *must* be a multiple of 32 bytes. Attempting to + transfer any data whose length isn't a multiple of 32 bytes will result in + `DrawSync()` hanging and never returning, however a warning will be printed + on the debug console. `psxspu`: +- `SpuCtrlSync()` locks up on MAME, making any code that tries to initialize + the SPU hang. It works on other emulators as well as on real hardware. + - Calls to `SpuSetTransferMode()` are ignored. SPU transfers are always performed using DMA, which imposes limitations such as the data length having - to be a multiple of 64 bytes. + to be a multiple of 16 words (64 bytes, see above). `psxetc`: @@ -40,4 +51,4 @@ as they should, or untested on real hardware) and haven't yet been fixed. See [README.md in the examples directory](../examples/README.md#examples-summary). ----------------------------------------- -_Last updated on 2022-02-03 by spicyjpeg_ +_Last updated on 2022-06-29 by spicyjpeg_ -- cgit v1.2.3 From f2e946cc0f9730c0da56aae533b3429a0381003e Mon Sep 17 00:00:00 2001 From: spicyjpeg Date: Sun, 21 Aug 2022 23:36:45 +0200 Subject: Fix psxetc bugs, IRQ controller register size --- doc/known_bugs.md | 11 ++++------- libpsn00b/include/hwregs_c.h | 6 +++--- libpsn00b/psxetc/interrupts.c | 5 +++-- libpsn00b/psxgpu/common.c | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) (limited to 'doc') diff --git a/doc/known_bugs.md b/doc/known_bugs.md index 9e83f03..3fbfdc2 100644 --- a/doc/known_bugs.md +++ b/doc/known_bugs.md @@ -32,12 +32,9 @@ fixed. `psxspu`: -- `SpuCtrlSync()` locks up on MAME, making any code that tries to initialize - the SPU hang. It works on other emulators as well as on real hardware. - -- Calls to `SpuSetTransferMode()` are ignored. SPU transfers are always - performed using DMA, which imposes limitations such as the data length having - to be a multiple of 16 words (64 bytes, see above). +- `SpuInit()`, `SpuRead()` and `SpuWrite()` may take several seconds on MAME + due to the SPU status register being emulated incorrectly. They work as + expected on other emulators as well as on real hardware. `psxetc`: @@ -51,4 +48,4 @@ fixed. See [README.md in the examples directory](../examples/README.md#examples-summary). ----------------------------------------- -_Last updated on 2022-06-29 by spicyjpeg_ +_Last updated on 2022-08-21 by spicyjpeg_ diff --git a/libpsn00b/include/hwregs_c.h b/libpsn00b/include/hwregs_c.h index 7b80590..b205b87 100644 --- a/libpsn00b/include/hwregs_c.h +++ b/libpsn00b/include/hwregs_c.h @@ -14,7 +14,7 @@ /* Constants */ -#define IOBASE 0x1f800000 +#define IOBASE 0xbf800000 #define F_CPU 33868800UL #define F_GPU 53222400UL @@ -96,8 +96,8 @@ /* IRQ controller */ -#define IRQ_STAT _MMIO32(IOBASE | 0x1070) -#define IRQ_MASK _MMIO32(IOBASE | 0x1074) +#define IRQ_STAT _MMIO16(IOBASE | 0x1070) +#define IRQ_MASK _MMIO16(IOBASE | 0x1074) /* DMA */ diff --git a/libpsn00b/psxetc/interrupts.c b/libpsn00b/psxetc/interrupts.c index 32e91f0..859209a 100644 --- a/libpsn00b/psxetc/interrupts.c +++ b/libpsn00b/psxetc/interrupts.c @@ -18,7 +18,8 @@ static void (*_irq_handlers[NUM_IRQ_CHANNELS])(void); static void (*_dma_handlers[NUM_DMA_CHANNELS])(void); static int _num_dma_handlers = 0; -static uint32_t _saved_irq_mask, _saved_dma_dpcr, _saved_dma_dicr; +static uint16_t _saved_irq_mask; +static uint32_t _saved_dma_dpcr, _saved_dma_dicr; static int _isr_installed = 0; /* Custom ISR jmp_buf */ @@ -52,7 +53,7 @@ static const struct JMP_BUF _isr_jmp_buf = { /* Internal IRQ and DMA handlers */ static void _global_isr(void) { - uint32_t stat = IRQ_STAT, mask = IRQ_MASK; + uint16_t stat = IRQ_STAT, mask = IRQ_MASK; // Clear all IRQ flags in one shot. This is not the "proper" way to do it // but it's much faster than clearing one flag at a time. diff --git a/libpsn00b/psxgpu/common.c b/libpsn00b/psxgpu/common.c index de60df4..cef1508 100644 --- a/libpsn00b/psxgpu/common.c +++ b/libpsn00b/psxgpu/common.c @@ -215,7 +215,7 @@ void DrawOTag(const uint32_t *ot) { // condition where the DMA transfer could end while interrupts are being // disabled. Interrupts are disabled through the IRQ_MASK register rather // than by calling EnterCriticalSection() for performance reasons. - uint32_t mask = IRQ_MASK; + uint16_t mask = IRQ_MASK; IRQ_MASK = 0; if (DMA_CHCR(2) & (1 << 24)) { -- cgit v1.2.3 From 5746b6ef9df16447d78e77d00ad21a4dba0fe169 Mon Sep 17 00:00:00 2001 From: spicyjpeg Date: Wed, 21 Sep 2022 23:49:20 +0200 Subject: Bump GCC to 12.2.0, update docs and installation guide --- .github/workflows/build.yml | 15 +++-------- CHANGELOG.md | 17 ++++++++++++ README.md | 15 +++++++---- cpack/setup.cmake | 4 +-- doc/installation.md | 61 ++++++++++++++++++++++++++++++++------------ libpsn00b/psxpress/README.md | 42 ++++++++++++++++++++++++++++++ 6 files changed, 120 insertions(+), 34 deletions(-) create mode 100644 libpsn00b/psxpress/README.md (limited to 'doc') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6f42e41..f35872d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,8 +10,8 @@ name: Build PSn00bSDK on: [ push, pull_request ] env: - BINUTILS_VERSION: 2.36 - GCC_VERSION: 11.1.0 + BINUTILS_VERSION: 2.39 + GCC_VERSION: 12.2.0 GCC_TARGET: mipsel-none-elf jobs: @@ -131,7 +131,7 @@ jobs: - name: Upload build artifacts (NSIS) uses: actions/upload-artifact@v2 with: - name: psn00bsdk-windows-nsis + name: psn00bsdk-windows-installer path: build/packages/*.exe build-sdk-linux: @@ -169,12 +169,6 @@ jobs: name: psn00bsdk-linux path: build/packages/*.zip - - name: Upload build artifacts (DEB) - uses: actions/upload-artifact@v2 - with: - name: psn00bsdk-linux-deb - path: build/packages/*.deb - # This job takes care of creating a new release and upload the build # artifacts if the last commit is associated to a tag. create-release: @@ -224,6 +218,5 @@ jobs: files: | *.zip psn00bsdk-windows/* - psn00bsdk-windows-nsis/* + psn00bsdk-windows-installer/* psn00bsdk-linux/* - psn00bsdk-linux-deb/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 75f131c..b477b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,23 @@ to ensure the changelog can be parsed correctly. ------------------------------------------------------------------------------- +## 2022-08-21: 0.20 + +spicyjpeg: + +- psxgpu: Added `VSyncHaltFunction()`. + +- psxetc: Rewritten the library in C, making `RestartCallback()` behave more + like its official SDK counterpart. Added `StopCallback()` and + `ResetCallback()`. + +- psxspu: `SpuInit()` now properly resets the starting address of all channels, + preventing them from accidentally triggering the SPU IRQ. + +- examples: Added an example audio file to `sound/spustream` and a texture to + `graphics/gte`. Replaced `ball16c.h` in all examples that included it with a + binary .TIM file embedded through CMake. + ## 2022-07-31 spicyjpeg: diff --git a/README.md b/README.md index 29e73a0..e4a2d15 100644 --- a/README.md +++ b/README.md @@ -85,14 +85,19 @@ As of March 28, 2022 ## Obtaining PSn00bSDK -Prebuilt PSn00bSDK packages for Windows and Linux are available through GitHub -Actions which includes the libraries, a copy of the GCC MIPS toolchain, command -line tools, examples and documentation. CMake is **not** included and must be +Prebuilt PSn00bSDK packages for Windows and Linux are available on the releases +page and include the libraries, a copy of the GCC MIPS toolchain, command-line +tools, examples and documentation. CMake is **not** included and must be installed separately, either from [its website](https://cmake.org/download) or via MSys2 or your distro's package manager. -See [installation.md](doc/installation.md) for a quick start guide and for -details on how to build the SDK yourself. +The releases can be installed by simply extracting the archives into any +directory and adding the `bin` subfolder to the `PATH` environment variable. +`share/psn00bsdk/template` contains a barebones example project that can be +used as a starting point. + +For more information on how to get started, or if you wish to build the SDK +yourself from source instead, refer to [installation.md](doc/installation.md). ## Examples diff --git a/cpack/setup.cmake b/cpack/setup.cmake index 45580f7..13da515 100644 --- a/cpack/setup.cmake +++ b/cpack/setup.cmake @@ -108,8 +108,8 @@ if(NOT DEFINED CPACK_GENERATOR) elseif(APPLE) # TODO: add a macOS installer and related options set(CPACK_GENERATOR ZIP) - elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - set(CPACK_GENERATOR ZIP DEB) + #elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + #set(CPACK_GENERATOR ZIP DEB RPM) else() set(CPACK_GENERATOR ZIP) endif() diff --git a/doc/installation.md b/doc/installation.md index 2d058ab..382c721 100644 --- a/doc/installation.md +++ b/doc/installation.md @@ -1,18 +1,43 @@ # Getting started with PSn00bSDK -**IMPORTANT**: due to a bug in `libflac` (used by `mkpsxiso`), building using -MinGW on Windows currently requires `-DMKPSXISO_NO_LIBFLAC=ON` to be passed to -CMake when configuring PSn00bSDK. This will result in the `dumpsxiso` utility -being built without support for ripping CD audio tracks to FLAC, however the -`mkpsxiso` command will still retain FLAC support. +## Installing a prebuilt release (recommended) + +1. Install prerequisites. Currently CMake is the only external dependency; you + can install it from [here](https://cmake.org/download) or using MSys2 or + your distro's package manager. Make sure you have at least CMake 3.20. + +2. Head over to the releases page, download the latest release's ZIP for your + operating system and extract its contents to a directory of your choice, + preferably one whose absolute path is short (such as `C:\PSn00bSDK` or + `/opt/psn00bsdk`). Proceed to add the `bin` subdirectory you extracted (e.g. + `C:\PSn00bSDK\bin` or `/opt/psn00bsdk/bin`) to your `PATH` environment + variable, through System Properties on Windows or by modifying your profile + script on Linux. + +3. You may optionally set the `PSN00BSDK_LIBS` environment variable to point to + the `lib/libpsn00b` subdirectory (again, the full path would be something + like `C:\PSn00bSDK\lib\libpsn00b` or `/opt/psn00bsdk/lib/libpsn00b`). Doing + so is highly recommended as it will save you from having to hardcode a path + to the SDK in your projects later on. -## Building and installing +4. You should now be able to invoke the compiler (`mipsel-none-elf-gcc`) as + well as PSn00bSDK commands such as `elf2x` and `mkpsxiso`. If you get + "command not found" errors try rebooting, otherwise you can skip to + [Creating a project](#creating-a-project). + +## Building from source The instructions below are for Windows and Linux. Building on macOS hasn't been tested extensively yet, however it should work once the GCC toolchain is built and installed properly. +**IMPORTANT**: due to a bug in `libflac` (used by `mkpsxiso`), building using +MinGW on Windows currently requires `-DMKPSXISO_NO_LIBFLAC=ON` to be passed to +CMake when configuring PSn00bSDK. This will result in the `dumpsxiso` utility +being built without support for ripping CD audio tracks to FLAC, however the +`mkpsxiso` command will still retain FLAC support. + 1. Install prerequisites and a host compiler toolchain. On Linux (most distros) install the following packages from your distro's package manager: @@ -80,7 +105,7 @@ and installed properly. If you want to install the SDK to a custom location rather than the default one (`C:\Program Files\PSn00bSDK` or `/usr/local` depending on your OS), add - `--install-prefix ` to the first command. Remember to add + `--install-prefix ` to the first command. Remember to add `-DPSN00BSDK_TARGET=mipsel-unknown-elf` if necessary. **NOTE**: Ninja is used by default to build the SDK. If you can't get it to @@ -95,15 +120,18 @@ and installed properly. cmake --install ./build ``` - This will create and populate the following directories: + This will create and populate the following subfolders in the installation + directory: - - `/bin` - - `/lib/libpsn00b` - - `/share/psn00bsdk` + - `bin` + - `lib/libpsn00b` + - `share/psn00bsdk` 7. You may optionally set the `PSN00BSDK_LIBS` environment variable to point to - the `lib/libpsn00b` subfolder inside the install directory. You might also - want to add the `bin` folder to `PATH` if it's not listed already. + the `lib/libpsn00b` subfolder inside the install directory. Doing so is + highly recommended as it will save you from having to hardcode a path to the + SDK in your projects later on. You might also want to add the `bin` folder + to `PATH` if it's not listed already. Although not strictly required, you'll probably want to install a PS1 emulator with debugging capabilities such as [no$psx](https://problemkaputt.de/psx.htm) @@ -134,8 +162,9 @@ far from being feature-complete. ## Creating a project -1. Copy the contents of `/share/psn00bsdk/template` (or the - `template` folder within the repo) to your new project's root directory. +1. Copy the contents of `share/psn00bsdk/template` within the PSn00bSDK + installation directory (or the `template` folder within the repo) to a new + empty folder, which will become your project's root directory. 2. If you haven't set the `PSN00BSDK_LIBS` environment variable previously or if you want to use a different PSn00bSDK installation for the project, edit @@ -156,4 +185,4 @@ The toolchain script defines a few CMake macros to create PS1 executables, DLLs and CD images. See the [reference](cmake_reference.md) for details. ----------------------------------------- -_Last updated on 2022-02-06 by spicyjpeg_ +_Last updated on 2022-09-21 by spicyjpeg_ diff --git a/libpsn00b/psxpress/README.md b/libpsn00b/psxpress/README.md new file mode 100644 index 0000000..a894874 --- /dev/null +++ b/libpsn00b/psxpress/README.md @@ -0,0 +1,42 @@ + +# PSn00bSDK MDEC library + +This is a fully open source reimplementation of the official SDK's "data +compression" library. This library is made up of two parts, the MDEC API and +functions to decompress Huffman-encoded bitstreams (.BS files, or frames in +.STR files) into data to be fed to the MDEC. FMV playback is not part of this +library (nor the official one) per se, but can implemented by using these APIs +alongside some code to stream data from the CD drive. + +**Currently only version 1 and 2 bitstreams are supported**. + +## MDEC API + +The MDEC data input/output API is almost identical to the official one, with +only two minor differences: + +- `DecDCTPutEnv()` takes a second argument specifying whether the MDEC shall be + put into monochrome or color mode (the original API only supported color). +- A `DecDCTinRaw()` function was added for easier feeding of headerless data + buffers to the MDEC. This function does not affect how `DecDCTin()` works. + +## Decompression API + +The following functions are currently provided: + +- `DecDCTvlcStart()`, `DecDCTvlcContinue()`: a decompressor implementation that + uses a small (<1 KB) lookup table and leverages the GTE, written in assembly. + `DecDCTvlcCopyTable()` can optionally be called to temporarily move the table + to the scratchpad region to improve decompression speed. +- `DecDCTvlcStart2()`, `DecDCTvlcContinue2()`: a different implementation using + a large (34 KB) lookup table in main RAM, written in C. The table must be + decompressed ahead of time using `DecDCTvlcBuild()`, but can be deallocated + when no longer needed. +- `DecDCTvlc()`, `DecDCTvlc2()`: wrappers around the functions listed above, + for compatibility with the Sony SDK. Using them is not recommended. + +## SPU ADPCM encoding API + +The Sony library has functions that can be used to convert raw 16-bit PCM audio +data to SPU ADPCM. These are currently unimplemented due to their limited +usefulness, but might be added at some point. -- cgit v1.2.3