Skip to content

Commit

Permalink
Merge pull request #1678 from nicolasnoble/psyqo-gpu-tweaks
Browse files Browse the repository at this point in the history
Psyqo GPU tweaks
  • Loading branch information
nicolasnoble committed Jul 1, 2024
2 parents 1e41345 + 6f705bf commit 3ba2e37
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
13 changes: 9 additions & 4 deletions src/mips/psyqo/gpu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ namespace timer_literals {
* `gpu().armPeriodicTimer(1_s, callback)` will create a timer that
* fires every second.
*/
constexpr uint32_t operator""_ns(unsigned long long int value) { return value / 1'000; }
constexpr uint32_t operator""_us(unsigned long long int value) { return value; }
constexpr uint32_t operator""_ms(unsigned long long int value) { return value * 1'000; }
constexpr uint32_t operator""_s(unsigned long long int value) { return value * 1'000'000; }
consteval uint32_t operator""_ns(unsigned long long int value) { return value / 1'000; }
consteval uint32_t operator""_us(unsigned long long int value) { return value; }
consteval uint32_t operator""_ms(unsigned long long int value) { return value * 1'000; }
consteval uint32_t operator""_s(unsigned long long int value) { return value * 1'000'000; }
consteval uint32_t operator""_ns(long double value) { return value / 1'000; }
consteval uint32_t operator""_us(long double value) { return value; }
consteval uint32_t operator""_ms(long double value) { return value * 1'000; }
consteval uint32_t operator""_s(long double value) { return value * 1'000'000; }

} // namespace timer_literals

Expand All @@ -85,6 +89,7 @@ class GPU {
enum class VideoMode { AUTO, NTSC, PAL };
enum class ColorMode { C15BITS, C24BITS };
enum class Interlace { PROGRESSIVE, INTERLACED };
enum class MiscSetting { CLEAR_VRAM, KEEP_VRAM };
void initialize(const Configuration &config);

static constexpr uint32_t US_PER_HBLANK = 64;
Expand Down
13 changes: 13 additions & 0 deletions src/mips/psyqo/internal/gpu/configuration.hh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ struct psyqo::GPU::Configuration {
config.vResolution = interlace == Interlace::INTERLACED ? VR_480 : VR_240;
return *this;
}
Configuration &set(MiscSetting setting) {
switch (setting) {
case MiscSetting::CLEAR_VRAM:
clearVRAM = true;
break;
case MiscSetting::KEEP_VRAM:
clearVRAM = false;
break;
}
return *this;
}

private:
enum HResolution {
Expand Down Expand Up @@ -125,5 +136,7 @@ struct psyqo::GPU::Configuration {
};

DisplayModeConfig config = {};
bool clearVRAM = true;

friend class GPU;
};
8 changes: 5 additions & 3 deletions src/mips/psyqo/src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@ void psyqo::GPU::initialize(const psyqo::GPU::Configuration &config) {
syscall_enableEvent(event);
syscall_enableTimerIRQ(3);
syscall_setTimerAutoAck(3, 1);
Prim::FastFill ff;
ff.rect = Rect{0, 0, 1024, 512};
sendPrimitive(ff);
if (config.clearVRAM) {
Prim::FastFill ff;
ff.rect = Rect{0, 0, 1024, 512};
sendPrimitive(ff);
}
// Enable Display
Hardware::GPU::Ctrl = 0x03000000;
Kernel::enableDma(Kernel::DMA::GPU);
Expand Down

0 comments on commit 3ba2e37

Please sign in to comment.