From 8c68b4b8a5bf7757b8e4d6bc2f68f10584b0deb1 Mon Sep 17 00:00:00 2001 From: spicyjpeg <88942473+spicyjpeg@users.noreply.github.com> Date: Sat, 12 Mar 2022 14:28:11 +0100 Subject: Minor fixes, add C++ placement new, n00bdemo 573 support --- examples/demos/n00bdemo/main.c | 46 ++++++++++++++++++++++++++++---- examples/io/system573/CMakeLists.txt | 2 +- examples/lowlevel/cartrom/CMakeLists.txt | 2 +- examples/sound/spustream/main.c | 4 +++ 4 files changed, 47 insertions(+), 7 deletions(-) (limited to 'examples') 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 #include #include @@ -27,7 +32,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -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)); -- cgit v1.2.3