Skip to content

Commit

Permalink
Merge pull request #1489 from nicolasnoble/psyqo-smoother
Browse files Browse the repository at this point in the history
Smoother psyqo
  • Loading branch information
nicolasnoble authored Dec 16, 2023
2 parents f87d24b + 442c8df commit 47fe273
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/mips/psyqo/gpu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ class GPU {
/**
* @brief Waits until the GPU is ready to send a command.
*/
static void waitReady();
void waitReady();

/**
* @brief Waits until the GPU's FIFO is ready to receive data.
*/
static void waitFifo();
void waitFifo();

/**
* @brief Sends a raw 32 bits value to the Data register of the GPU.
Expand All @@ -257,7 +257,7 @@ class GPU {
* @param primitive The primitive to send to the GPU.
*/
template <Primitive Prim>
static void sendPrimitive(const Prim &primitive) {
void sendPrimitive(const Prim &primitive) {
waitReady();
const uint32_t *ptr = reinterpret_cast<const uint32_t *>(&primitive);
constexpr size_t size = sizeof(Prim) / sizeof(uint32_t);
Expand Down
12 changes: 2 additions & 10 deletions src/mips/psyqo/kernel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,14 @@ static inline void setCop0Status(uint32_t r) { asm("mtc0 %0, $12 ; nop" : : "r"(
* @details This function is technically equivalent to `enterCriticalSection`.
* @return false if the critical section was already entered, true otherwise.
*/
static inline bool fastEnterCriticalSection() {
uint32_t sr = Internal::getCop0Status();
Internal::setCop0Status(sr & ~0x401);
return (sr & 0x401) == 0x401;
}
static inline void fastEnterCriticalSection() { asm volatile("mtc0 %0, $12 ; nop ; nop" : : "r"(0x40000000)); }

/**
* @brief A faster version of `leaveCriticalSection`.
*
* @details This function is technically equivalent to `leaveCriticalSection`.
*/
static inline void fastLeaveCriticalSection() {
uint32_t sr = Internal::getCop0Status();
sr |= 0x401;
Internal::setCop0Status(sr);
}
static inline void fastLeaveCriticalSection() { asm volatile("mtc0 %0, $12" : : "r"(0x40000401)); }

enum class DMA : unsigned {
MDECin,
Expand Down
1 change: 0 additions & 1 deletion src/mips/psyqo/src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ SOFTWARE.

int psyqo::Application::run() {
enterCriticalSection();
Kernel::Internal::setCop0Status(Kernel::Internal::getCop0Status() | 0x40000000);
syscall_puts("*** PSYQo Application - starting ***\n");
psyqo_free(psyqo_malloc(1));
ramsyscall_printf("Current heap start: %p\n", psyqo_heap_start());
Expand Down
14 changes: 8 additions & 6 deletions src/mips/psyqo/src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ SOFTWARE.
#include "psyqo/kernel.hh"

void psyqo::GPU::waitReady() {
while ((Hardware::GPU::Ctrl & uint32_t(0x04000000)) == 0)
;
while ((Hardware::GPU::Ctrl & uint32_t(0x04000000)) == 0) {
pumpCallbacks();
}
}

void psyqo::GPU::waitFifo() {
while ((Hardware::GPU::Ctrl & uint32_t(0x02000000)) == 0)
;
while ((Hardware::GPU::Ctrl & uint32_t(0x02000000)) == 0) {
pumpCallbacks();
}
}

void psyqo::GPU::initialize(const psyqo::GPU::Configuration &config) {
Expand All @@ -55,8 +57,8 @@ void psyqo::GPU::initialize(const psyqo::GPU::Configuration &config) {
Hardware::GPU::Ctrl = 0x04000001;
// Display Mode
Hardware::GPU::Ctrl = 0x08000000 | (config.config.hResolution << 0) | (config.config.vResolution << 2) |
(config.config.videoMode << 3) | (config.config.colorDepth << 4) |
(config.config.videoInterlace << 5) | (config.config.hResolutionExtended << 6);
(config.config.videoMode << 3) | (config.config.colorDepth << 4) |
(config.config.videoInterlace << 5) | (config.config.hResolutionExtended << 6);
// Horizontal Range
Hardware::GPU::Ctrl = 0x06000000 | 0x260 | (0xc60 << 12);

Expand Down

0 comments on commit 47fe273

Please sign in to comment.