Skip to content

Commit

Permalink
Merge pull request #1622 from nicolasnoble/torus
Browse files Browse the repository at this point in the history
Adding torus example.
  • Loading branch information
nicolasnoble committed Jun 29, 2024
2 parents 8ba887a + 547a2b8 commit 1e41345
Show file tree
Hide file tree
Showing 8 changed files with 1,167 additions and 3 deletions.
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,32 @@
"valuesFormatting": "parseText"
},

{
"type": "gdb",
"request": "attach",
"name": "(gdb) Launch Torus demo",
"target": "localhost:3333",
"remote": true,
"stopAtConnect": true,
"executable": "./src/mips/psyqo/examples/torus/torus.elf",
"gdbpath": "gdb-multiarch",
"windows": {
"gdbpath": "gdb-multiarch.exe"
},
"cwd": "${workspaceRoot}",
"autorun": [
"set confirm off",
"set substitute-path /project .",
"load ./src/mips/openbios/openbios.elf",
"add-symbol-file ./src/mips/openbios/openbios.elf",
"monitor reset shellhalt",
"load ./src/mips/psyqo/examples/torus/torus.elf",
"tbreak main",
"continue",
],
"valuesFormatting": "parseText"
},

{
"name": "(gdb) Launch PCSX-Redux",
"type": "cppdbg",
Expand Down
1 change: 0 additions & 1 deletion src/mips/psyqo/examples/gte/gte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ SOFTWARE.

#include <EASTL/array.h>

#include "common/syscalls/syscalls.h"
#include "psyqo/application.hh"
#include "psyqo/fixed-point.hh"
#include "psyqo/font.hh"
Expand Down
14 changes: 14 additions & 0 deletions src/mips/psyqo/examples/torus/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TARGET = torus
TYPE = ps-exe

SRCS = \
torus.cpp \

ifeq ($(TEST),true)
CPPFLAGS = -Werror
endif
CXXFLAGS = -std=c++20

LDFLAGS += -Wl,-wrap,memcpy -Wl,-wrap,memset

include ../../psyqo.mk
5 changes: 5 additions & 0 deletions src/mips/psyqo/examples/torus/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Torus example

This example contains a very extensive example of how to do 3D using psyqo. It'll render an animated torus with a texture on it, as well as a projected shadow underneath. The code is extensively commented.

The triangle and cross buttons of the pad can be used to change its color.
303 changes: 303 additions & 0 deletions src/mips/psyqo/examples/torus/presets.hh

Large diffs are not rendered by default.

810 changes: 810 additions & 0 deletions src/mips/psyqo/examples/torus/torus.cpp

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/mips/psyqo/gpu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,14 @@ class GPU {
*/
bool isChainTransferred() const;

/**
* @brief Waits until the background DMA transfer operation initiated by a frame flip is complete.
*
*/
void waitChainIdle() {
while (isChainTransferring()) pumpCallbacks();
}

/**
* @brief Gets the current timestamp in microseconds.
*
Expand Down Expand Up @@ -501,7 +509,7 @@ class GPU {
uint32_t *m_chainHead = nullptr;
uint32_t *m_chainTail = nullptr;
size_t m_chainTailCount = 0;
enum { CHAIN_IDLE, CHAIN_TRANSFERRING, CHAIN_TRANSFERRED } m_chainStatus;
enum { CHAIN_IDLE, CHAIN_TRANSFERRING, CHAIN_TRANSFERRED } m_chainStatus = CHAIN_IDLE;
struct Timer {
eastl::function<void(uint32_t)> callback;
uint32_t deadline;
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 @@ -26,7 +26,6 @@ SOFTWARE.

#include "psyqo/application.hh"

#include "common/hardware/hwregs.h"
#include "common/syscalls/syscalls.h"
#include "psyqo/alloc.h"
#include "psyqo/kernel.hh"
Expand Down

0 comments on commit 1e41345

Please sign in to comment.