diff options
| author | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2022-03-12 14:28:11 +0100 |
|---|---|---|
| committer | spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> | 2022-03-12 14:28:11 +0100 |
| commit | 8c68b4b8a5bf7757b8e4d6bc2f68f10584b0deb1 (patch) | |
| tree | 71e7927f56c5f11350f236e32b396adac3f75e3a /examples | |
| parent | 93f0a6d23ebed50833f565f949f351c2b80853ac (diff) | |
| download | psn00bsdk-8c68b4b8a5bf7757b8e4d6bc2f68f10584b0deb1.tar.gz | |
Minor fixes, add C++ placement new, n00bdemo 573 support
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/demos/n00bdemo/main.c | 46 | ||||
| -rw-r--r-- | examples/io/system573/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/lowlevel/cartrom/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | examples/sound/spustream/main.c | 4 |
4 files changed, 47 insertions, 7 deletions
diff --git a/examples/demos/n00bdemo/main.c b/examples/demos/n00bdemo/main.c index d2fe317..cb64c42 100644 --- a/examples/demos/n00bdemo/main.c +++ b/examples/demos/n00bdemo/main.c @@ -11,14 +11,19 @@ * * Changelog: * + * Mar 12, 2022 - Added Konami System 573 support. + * * May 10, 2021 - Variable types updated for psxgpu.h changes. * * Apr 4, 2019 - Some code clean-up and added more comments. * - * Mar 20, 2019 - Initial completed version. + * Mar 20, 2019 - Initial completed version. * */ - + +// Comment to disable 573 support +#define SYSTEM_573_SUPPORT + #include <sys/types.h> #include <sys/fcntl.h> #include <stdio.h> @@ -27,7 +32,9 @@ #include <psxgte.h> #include <psxgpu.h> #include <psxspu.h> +#include <psxapi.h> #include <inline_c.h> +#include <hwregs_c.h> #include <string.h> #include <lzp/lzp.h> #include <lzp/lzqlp.h> @@ -64,6 +71,34 @@ SPRT psn00b_sprite; void sort_overlay(int showlotl); void lightdemo(); +#ifdef SYSTEM_573_SUPPORT +#define K573_WATCHDOG *((volatile uint16_t *) 0x1f5c0000) +#define K573_EXP1_CFG 0x24173f47 + +/* + The only thing required to support the 573 is to periodically reset the + watchdog. Hooking the vblank IRQ (through VSyncCallback) is the "right" way + to do it, however using a hardware timer running at a higher rate (100 Hz) + seems to improve stability. +*/ +void reset573Watchdog() { + K573_WATCHDOG = 0; +} + +void system573Setup() { + EnterCriticalSection(); + + EXP1_ADDR = 0x1f000000; + EXP1_DELAY_SIZE = K573_EXP1_CFG; + TIMER_CTRL(2) = 0x0258; // CLK/8 input, IRQ on reload + TIMER_RELOAD(2) = (F_CPU / 8) / 100; // 100 Hz + + // Configure timer 2 IRQ + ChangeClearRCnt(2, 0); + InterruptCallback(6, &reset573Watchdog); + ExitCriticalSection(); +} +#endif void UploadTIM(TIM_IMAGE *tim) { @@ -197,9 +232,10 @@ void unpackModels() { } void init() { - - int i; - +#ifdef SYSTEM_573_SUPPORT + system573Setup(); +#endif + // Init display initDisplay(); diff --git a/examples/io/system573/CMakeLists.txt b/examples/io/system573/CMakeLists.txt index 1c74347..2a362e8 100644 --- a/examples/io/system573/CMakeLists.txt +++ b/examples/io/system573/CMakeLists.txt @@ -1,7 +1,7 @@ # PSn00bSDK example CMake script # (C) 2021 spicyjpeg - MPL licensed -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 3.20) project( system573 diff --git a/examples/lowlevel/cartrom/CMakeLists.txt b/examples/lowlevel/cartrom/CMakeLists.txt index 107cc3d..7d5e86e 100644 --- a/examples/lowlevel/cartrom/CMakeLists.txt +++ b/examples/lowlevel/cartrom/CMakeLists.txt @@ -1,7 +1,7 @@ # PSn00bSDK example CMake script # (C) 2021 spicyjpeg - MPL licensed -cmake_minimum_required(VERSION 3.21) +cmake_minimum_required(VERSION 3.20) project( cartrom diff --git a/examples/sound/spustream/main.c b/examples/sound/spustream/main.c index 6284c6d..6b9db93 100644 --- a/examples/sound/spustream/main.c +++ b/examples/sound/spustream/main.c @@ -308,6 +308,10 @@ void init_stream(CdlFILE *file) { CdReadyCallback(&cd_event_handler); ExitCriticalSection(); + // Configure the CD drive to read 2048-byte sectors at 2x speed. + uint8_t mode = CdlModeSpeed; + CdControl(CdlSetmode, (const uint8_t *) &mode, 0); + // Set the initial LBA of the stream file, which is going to be incremented // as the stream is played. str_ctx.lba = CdPosToInt(&(file->pos)); |
