Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs/README-ps2.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ Credit to
## Building
To build SDL2 library for the PS2, make sure you have the latest PS2Dev status and run:
```bash
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PS2DEV/ps2sdk/ps2dev.cmake
cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=$PS2DEV/share/ps2dev.cmake
cmake --build build
cmake --install build
```

## Hints
The PS2 port has a special Hint for having a dynamic VSYNC. The Hint is `SDL_HINT_PS2_DYNAMIC_VSYNC`.
If you enabled the dynamic vsync having as well `SDL_RENDERER_PRESENTVSYNC` enabled, then if the app is not able to run at 60 FPS, automatically the `vsync` will be disabled having a better performance, instead of droping FPS to 30.
- `SDL_HINT_PS2_DYNAMIC_VSYNC`: Hint for having a dynamic VSYNC. If you enabled the dynamic vsync having as well `SDL_RENDERER_PRESENTVSYNC` enabled, then if the app is not able to run at 60 FPS, automatically the `vsync` will be disabled having a better performance, instead of droping FPS to 30.
- `SDL_HINT_PS2_GS_WIDTH`: Width of the framebuffer. Defaults to 640.
- `SDL_HINT_PS2_GS_HEIGHT`: Height of the framebuffer. Defaults to 448.
- `SDL_HINT_PS2_GS_PROGRESSIVE`: Whether to use progressive, instead of interlaced. Defaults to 0.
- `SDL_HINT_PS2_GS_MODE`: Regional standard of the signal. "NTSC" (60hz), "PAL" (50hz) or "" (the console's region, default).

## Notes
If you trying to debug a SDL app through [ps2client](https://github.com/ps2dev/ps2client) you need to avoid the IOP reset, otherwise you will lose the conection with your computer.
Expand Down
31 changes: 31 additions & 0 deletions include/SDL_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -2038,6 +2038,37 @@ extern "C" {
*/
#define SDL_HINT_PS2_DYNAMIC_VSYNC "SDL_PS2_DYNAMIC_VSYNC"

/**
* Variable controlling the width of the PS2's framebuffer in pixels
*
* By default, this variable is "640"
*/
#define SDL_HINT_PS2_GS_WIDTH "SDL_PS2_GS_WIDTH"

/**
* Variable controlling the height of the PS2's framebuffer in pixels
*
* By default, this variable is "448"
*/
#define SDL_HINT_PS2_GS_HEIGHT "SDL_PS2_GS_HEIGHT"

/**
* Variable controlling whether the signal is interlaced or progressive
*
* - "0": Image is interlaced. Default
* - "1": Image is progressive
*/
#define SDL_HINT_PS2_GS_PROGRESSIVE "SDL_PS2_GS_PROGRESSIVE"

/**
* Variable controlling the video mode of the console
*
* - "": Console-native. Default
* - "NTSC": 60hz region
* - "PAL": 50hz region
*/
#define SDL_HINT_PS2_GS_MODE "SDL_PS2_GS_MODE"

/**
* A variable to control whether the return key on the soft keyboard should
* hide the soft keyboard on Android and iOS.
Expand Down
34 changes: 32 additions & 2 deletions src/render/ps2/SDL_render_ps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ static int PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, Uint32
GSGLOBAL *gsGlobal;
ee_sema_t sema;
SDL_bool dynamicVsync;
int w,h;

data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data));
if (!data) {
Expand All @@ -624,8 +625,37 @@ static int PS2_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, Uint32

gsGlobal = gsKit_init_global_custom(RENDER_QUEUE_OS_POOLSIZE, RENDER_QUEUE_PER_POOLSIZE);

gsGlobal->Mode = GS_MODE_NTSC;
gsGlobal->Height = 448;
// GS interlaced/progressive
if (SDL_GetHintBoolean(SDL_HINT_PS2_GS_PROGRESSIVE,0)) {
gsGlobal->Interlace = GS_NONINTERLACED;
} else {
gsGlobal->Interlace = GS_INTERLACED;
}

// GS width/height
if (
SDL_GetHint(SDL_HINT_PS2_GS_WIDTH) == NULL ||
sscanf(SDL_GetHint(SDL_HINT_PS2_GS_WIDTH),"%d",&w) != 1
) { w = 640; }

if (
SDL_GetHint(SDL_HINT_PS2_GS_HEIGHT) == NULL ||
sscanf(SDL_GetHint(SDL_HINT_PS2_GS_HEIGHT),"%d",&h) != 1
) { h = 448; }

gsGlobal->Width = w;
gsGlobal->Height = h;

// GS region
if (SDL_GetHint(SDL_HINT_PS2_GS_MODE) != NULL) {
if (strcmp(SDL_GetHint(SDL_HINT_PS2_GS_MODE),"NTSC") == 0) {
gsGlobal->Mode = GS_MODE_NTSC;
}

if (strcmp(SDL_GetHint(SDL_HINT_PS2_GS_MODE),"PAL") == 0) {
gsGlobal->Mode = GS_MODE_PAL;
}
}

gsGlobal->PSM = GS_PSM_CT24;
gsGlobal->PSMZ = GS_PSMZ_16S;
Expand Down
Loading