Repository: libsdl-org/SDL
File: src/render/ps2/SDL_render_ps2.c (C)

Code before:
    }

    // 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;
    gsGlobal->ZBuffering = GS_SETTING_OFF;
    gsGlobal->DoubleBuffering = GS_SETTING_ON;
    gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
    gsGlobal->Dithering = GS_SETTING_OFF;

    gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0);

    dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
    dmaKit_chan_init(DMA_CHANNEL_GIF);

    gsKit_set_clamp(gsGlobal, GS_CMODE_REPEAT);

    gsKit_vram_clear(gsGlobal);

    gsKit_init_screen(gsGlobal);

    gsKit_TexManager_init(gsGlobal);

    data->vsync_callback_id = gsKit_add_vsync_handler(vsync_handler);

    gsKit_mode_switch(gsGlobal, GS_ONESHOT);


Review comment (suggestion):
```suggestion
    // GS interlaced/progressive
    if (SDL_GetHintBoolean(SDL_HINT_PS2_GS_PROGRESSIVE, false)) {
        gsGlobal->Interlace = GS_NONINTERLACED;
    } else {
        gsGlobal->Interlace = GS_INTERLACED;
    }
    
    // GS width/height
    gsGlobal->Width = 0;
    gsGlobal->Height = 0;
    const char *hint = SDL_GetHint(SDL_HINT_PS2_GS_WIDTH);
    if (hint) {
        gsGlobal->Width = SDL_atoi(hint);
    }
    hint = SDL_GetHint(SDL_HINT_PS2_GS_HEIGHT);
    if (hint) {
        gsGlobal->Height = SDL_atoi(hint);
    }
    if (gsGlobal->Width <= 0) {
        gsGlobal->Width = 640;
    }
    if (gsGlobal->Height <= 0) {
        gsGlobal->Height = 448;
    }

    // GS region
    hint = SDL_GetHint(SDL_HINT_PS2_GS_MODE);
    if (hint) {
        if (SDL_strcasecmp(SDL_GetHint(SDL_HINT_PS2_GS_MODE), "NTSC") == 0) {
            gsGlobal->Mode = GS_MODE_NTSC;
        }

        if (SDL_strcasecmp(SDL_GetHint(SDL_HINT_PS2_GS_MODE), "PAL") == 0) {
            gsGlobal->Mode = GS_MODE_PAL;
        }
    }
```

Code after:
    
    // GS width/height
    gsGlobal->Width = 0;
    gsGlobal->Height = 0;
    const char *hint = SDL_GetHint(SDL_HINT_PS2_GS_WIDTH);
    if (hint) {
        gsGlobal->Width = SDL_atoi(hint);
    }
    hint = SDL_GetHint(SDL_HINT_PS2_GS_HEIGHT);
    if (hint) {
        gsGlobal->Height = SDL_atoi(hint);
    }
    if (gsGlobal->Width <= 0) {
        gsGlobal->Width = 640;
    }
    if (gsGlobal->Height <= 0) {
        gsGlobal->Height = 448;
    }

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

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

    gsGlobal->PSM = GS_PSM_CT24;
    gsGlobal->PSMZ = GS_PSMZ_16S;
    gsGlobal->ZBuffering = GS_SETTING_OFF;
    gsGlobal->DoubleBuffering = GS_SETTING_ON;
    gsGlobal->PrimAlphaEnable = GS_SETTING_ON;
    gsGlobal->Dithering = GS_SETTING_OFF;

    gsKit_set_primalpha(gsGlobal, GS_SETREG_ALPHA(0, 1, 0, 1, 0), 0);

    dmaKit_init(D_CTRL_RELE_OFF, D_CTRL_MFD_OFF, D_CTRL_STS_UNSPEC, D_CTRL_STD_OFF, D_CTRL_RCYC_8, 1 << DMA_CHANNEL_GIF);
    dmaKit_chan_init(DMA_CHANNEL_GIF);

    gsKit_set_clamp(gsGlobal, GS_CMODE_REPEAT);

    gsKit_vram_clear(gsGlobal);

    gsKit_init_screen(gsGlobal);

    gsKit_TexManager_init(gsGlobal);