diff options
| author | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-01-22 15:40:14 +0100 |
|---|---|---|
| committer | spicyjpeg <thatspicyjpeg@gmail.com> | 2023-01-22 15:40:14 +0100 |
| commit | a21e949c9aea98cb4b3feee48bb98579bbdfba70 (patch) | |
| tree | 5fad8655bc674bebdbecb385d3e4878acbac3597 | |
| parent | 3095b4571dabc8d6cee90673d679f3e77b21b164 (diff) | |
Fix VSync(), assert(), warnings and some examples
| -rw-r--r-- | examples/demos/n00bdemo/main.c | 14 | ||||
| -rw-r--r-- | examples/graphics/billboard/billboard.c | 2 | ||||
| -rw-r--r-- | examples/io/system573/iso.xml | 8 | ||||
| -rw-r--r-- | examples/system/childexec/child/child.c | 7 | ||||
| -rw-r--r-- | examples/system/childexec/parent.c | 22 | ||||
| -rw-r--r-- | libpsn00b/include/assert.h | 8 | ||||
| -rw-r--r-- | libpsn00b/psxcd/misc.c | 6 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/common.c | 11 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/image.c | 2 |
9 files changed, 37 insertions, 43 deletions
diff --git a/examples/demos/n00bdemo/main.c b/examples/demos/n00bdemo/main.c index 6d0be3c..c9ca3ce 100644 --- a/examples/demos/n00bdemo/main.c +++ b/examples/demos/n00bdemo/main.c @@ -624,7 +624,7 @@ void plasmastuff() { // Simple stripe transition effect void transition() { - int i,count,comp; + int count = 0; int bheight[16] = { 0 }; TILE *tile = (TILE*)nextpri; @@ -632,9 +632,9 @@ void transition() { while( 1 ) { - comp = 0; + int comp = 0; - for( i=0; i<16; i++ ) { + for( int i=0; i<16; i++ ) { if( bheight[i] > 0 ) { @@ -657,19 +657,11 @@ void transition() { if( bheight[count>>1] == 0 ) bheight[count>>1] = 1; - display(); count++; if( comp >= 16 ) break; - - /* - I haven't yet managed to figure out why this loop hangs on no$psx - if I comment out this completely useless call to puts(). Some - alignment or timing crap perhaps? -- spicyjpeg - */ - puts("."); } DrawSync(0); diff --git a/examples/graphics/billboard/billboard.c b/examples/graphics/billboard/billboard.c index ea98b28..1ddc4dc 100644 --- a/examples/graphics/billboard/billboard.c +++ b/examples/graphics/billboard/billboard.c @@ -152,7 +152,7 @@ int main() { setRGB0(quad, 128, 128, 128); // Set tpage - quad->tpage = getTPage(tim.mode&0x8, 0, tim.prect->x, tim.prect->y); + quad->tpage = getTPage(tim.mode, 0, tim.prect->x, tim.prect->y); // Set CLUT setClut(quad, tim.crect->x, tim.crect->y); diff --git a/examples/io/system573/iso.xml b/examples/io/system573/iso.xml index 2226089..c960b8a 100644 --- a/examples/io/system573/iso.xml +++ b/examples/io/system573/iso.xml @@ -19,9 +19,9 @@ The System 573 BIOS does not parse SYSTEM.CNF, it's instead hardcoded to look for an executable named PSX.EXE. Some modded or hacked BIOS variants may instead look for slightly altered - file names (QSY.DXD, SSW.BXF, TSV.AXG) as an obfuscation - measure, so it's recommended to have multiple copies of the - executable on the disc. + file names (QSY.DXD, SSW.BXF, TSV.AXG, GSE.NXX, NSE.GXX) as an + obfuscation measure, so it's recommended to have multiple + copies of the executable on the disc. Note that this behavior can be abused to make multi-system CDs with different executables for PS1 and 573 (i.e. have both @@ -33,6 +33,8 @@ <file name="QSY.DXD" type="data" source="system573.exe" /> <file name="SSW.BXF" type="data" source="system573.exe" /> <file name="TSV.AXG" type="data" source="system573.exe" /> + <file name="GSE.NXX" type="data" source="system573.exe" /> + <file name="NSE.GXX" type="data" source="system573.exe" /> <dummy sectors="1024"/> </directory_tree> diff --git a/examples/system/childexec/child/child.c b/examples/system/childexec/child/child.c index dcfbfaf..b52dd32 100644 --- a/examples/system/childexec/child/child.c +++ b/examples/system/childexec/child/child.c @@ -238,11 +238,12 @@ int main(int argc, const char *argv[]) { display(); } - + + DrawSync(0); StopPAD(); - + StopCallback(); + return 0; - } void init(void) { diff --git a/examples/system/childexec/parent.c b/examples/system/childexec/parent.c index 83d964c..79c81f1 100644 --- a/examples/system/childexec/parent.c +++ b/examples/system/childexec/parent.c @@ -285,31 +285,27 @@ void run_child(void) { // Copy child executable to its intended adddress memcpy((void*)exe->param.t_addr, child_exe+2048, exe->param.t_size); - - // Prepare for program execution and disable interrupts - //EnterCriticalSection(); - StopCallback(); - // Stop pads, enable auto acknowledge + // Prepare for program execution and disable interrupts + DrawSync(0); StopPAD(); - ChangeClearPAD(1); - ChangeClearRCnt(3, 1); + StopCallback(); + FlushCache(); // Execute child - printf("Child exec!\n"); + printf("Executing child...\n"); Exec(&exe->param, 3, args); - + // Restore interrupts for this PS-EXE RestartCallback(); - //ExitCriticalSection(); - + printf("Child returned\n"); + // Re-init and re-enable pads InitPAD(pad_buff[0], 34, pad_buff[1], 34); StartPAD(); ChangeClearPAD(0); - + // Set this program's display mode SetDispMask(0); PutDispEnv(&disp); - } diff --git a/libpsn00b/include/assert.h b/libpsn00b/include/assert.h index 1b2bda2..d18a56f 100644 --- a/libpsn00b/include/assert.h +++ b/libpsn00b/include/assert.h @@ -1,6 +1,6 @@ /* * PSn00bSDK assert macro and internal logging - * (C) 2022 spicyjpeg - MPL licensed + * (C) 2022-2023 spicyjpeg - MPL licensed * * Note that the _sdk_log() macro is used internally by PSn00bSDK to output * debug messages and warnings. @@ -32,9 +32,11 @@ void _assert_abort(const char *file, int line, const char *expr); ((expr) ? ((void) 0) : _assert_abort(__FILE__, __LINE__, #expr)) #ifdef SDK_LIBRARY_NAME -#define _sdk_log(fmt, ...) printf(SDK_LIBRARY_NAME ": " fmt, ##__VA_ARGS__) +#define _sdk_log(fmt, ...) \ + printf(SDK_LIBRARY_NAME ": " fmt __VA_OPT__(,) __VA_ARGS__) #else -#define _sdk_log(fmt, ...) printf(fmt, ##__VA_ARGS__) +#define _sdk_log(fmt, ...) \ + printf(fmt __VA_OPT__(,) __VA_ARGS__) #endif #endif diff --git a/libpsn00b/psxcd/misc.c b/libpsn00b/psxcd/misc.c index fc87676..851fea6 100644 --- a/libpsn00b/psxcd/misc.c +++ b/libpsn00b/psxcd/misc.c @@ -14,7 +14,7 @@ /* Unlock command strings */ -static char *_unlock_strings[] = { +static const char *_unlock_strings[] = { "", "Licensed by", "Sony", @@ -24,7 +24,7 @@ static char *_unlock_strings[] = { "" }; -static const char *_unlock_regions[] = { +static const char *const _unlock_regions[] = { "of America", // CdlRegionSCEA "(Europe)", // CdlRegionSCEE "World wide" // CdlRegionSCEW @@ -66,7 +66,7 @@ int CdDataSync(int mode) { return 0; } - _sdk_log("CdDataSync() timeout\n"); + _sdk_log("CdDataSync() timeout, CHCR=0x%08x\n", DMA_CHCR(DMA_CD)); return -1; } diff --git a/libpsn00b/psxgpu/common.c b/libpsn00b/psxgpu/common.c index c52ab8a..537f672 100644 --- a/libpsn00b/psxgpu/common.c +++ b/libpsn00b/psxgpu/common.c @@ -133,12 +133,13 @@ int VSync(int mode) { return delta; if (mode < 0) return _vblank_counter; - if (!mode) - mode = 1; // VSync(0) = wait for one vblank - // Wait for at least one vertical blank event since the last call to - // VSync() to occur. - for (uint32_t target = _last_vblank + mode; _vblank_counter < target;) { + // Wait for the specified number of vertical blank events since the last + // call to VSync() to occur (if mode >= 2) or just for a single vertical + // blank (if mode = 0). + uint32_t target = mode ? (_last_vblank + mode) : (_vblank_counter + 1); + + while (_vblank_counter < target) { uint32_t status = GPU_GP1; _vsync_halt_func(); diff --git a/libpsn00b/psxgpu/image.c b/libpsn00b/psxgpu/image.c index 61ac484..ba5c445 100644 --- a/libpsn00b/psxgpu/image.c +++ b/libpsn00b/psxgpu/image.c @@ -53,7 +53,7 @@ static void _dma_transfer(const RECT *rect, uint32_t *data, int write) { // Enable DMA request, route to GP0 (2) or from GPU_READ (3) GPU_GP1 = 0x04000002 | (write ^ 1); - while (DMA_CHCR(DMA_GPU) & (1 << 24)) + while ((DMA_CHCR(DMA_GPU) & (1 << 24)) || !(GPU_GP1 & (1 << 28))) __asm__ volatile(""); DMA_MADR(DMA_GPU) = (uint32_t) data; |
