grumpycoders / pcsx-redux

The PCSX-Redux project is a collection of tools, research, hardware design, and libraries aiming at development and reverse engineering on the PlayStation 1. The core product itself, PCSX-Redux, is yet another fork of the Playstation emulator, PCSX.
https://pcsx-redux.consoledev.net
GNU General Public License v2.0
652 stars 104 forks source link

[psyqo] wrong aspect ratio (presumably on PAL systems) #1770

Open eliasdaler opened 3 weeks ago

eliasdaler commented 3 weeks ago

The aspect ratio seems wrong in some cases on real HW.

Repro:

#include <psyqo/application.hh>
#include <psyqo/gpu.hh>
#include <psyqo/scene.hh>
#include <psyqo/primitives/quads.hh>
#include <psyqo/gte-registers.hh>
#include <psyqo/gte-kernels.hh>
#include <psyqo/soft-math.hh>

namespace
{

class Game final : public psyqo::Application {
    void prepare() override;
    void createScene() override;

public:
    psyqo::Trig<> m_trig;
};

class GameplayScene final : public psyqo::Scene {
    void frame() override;

    psyqo::Prim::Quad quad2d{{.r = 255, .g = 0, .b = 255}};
};

// We're instantiating the two objects above right now.
Game game;
GameplayScene gameplayScene;

} // namespace

void Game::prepare()
{
    psyqo::GPU::Configuration config;
    config.set(psyqo::GPU::Resolution::W320)
        .set(psyqo::GPU::VideoMode::AUTO)
        .set(psyqo::GPU::ColorMode::C15BITS)
        .set(psyqo::GPU::Interlace::PROGRESSIVE);
    gpu().initialize(config);
}

void Game::createScene()
{
    pushScene(&gameplayScene);
}

void GameplayScene::frame()
{
    // draw
    psyqo::Color bg{{.r = 0, .g = 64, .b = 91}};
    game.gpu().clear(bg);

    quad2d.pointA.x = 160;
    quad2d.pointA.y = 160;
    quad2d.pointB.x = 200;
    quad2d.pointB.y = 160;
    quad2d.pointC.x = 160;
    quad2d.pointC.y = 200;
    quad2d.pointD.x = 200;
    quad2d.pointD.y = 200;

    gpu().sendPrimitive(quad2d);
}

int main()
{
    return game.run();
}

Emulators: image On HW: image (measured with ruler - it's 13x11 cm)

nicolasnoble commented 3 weeks ago

So, this is really due to these hardcoded clock settings:

https://github.com/grumpycoders/pcsx-redux/blob/main/src/mips/psyqo/src/gpu.cpp#L63-L71

These were derped out of trial and error, but they should actually be properly computed at runtime instead. Unfortunately, I don't have the right equipment to test what the proper values ought to be, aka some NTSC and PAL CRT TVs, and some NTSC and PAL consoles.