From 8b5fb7a5a1f4b768342df2203d9f980e4000a893 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sun, 31 May 2026 23:26:43 -0400 Subject: [PATCH] prepping to setup gte.h with similar setup to gp.h, maybe with more lessons from color forth learnings.. --- code/duffle/gte.h | 56 ++++++++++++++++++++++++++++++++++++++ code/gte_hello/hello_gte.c | 22 ++++++++++++++- scripts/build_psyq.ps1 | 2 +- scripts/output.json | 2 +- 4 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 code/duffle/gte.h diff --git a/code/duffle/gte.h b/code/duffle/gte.h new file mode 100644 index 0000000..e06d3bb --- /dev/null +++ b/code/duffle/gte.h @@ -0,0 +1,56 @@ +#ifdef INTELLISENSE_DIRECTIVES +# pragma once +# include "dsl.h" +# include "math.h" +#endif + +/* C2 data registers */ + +#define C2_VXY0 0 +#define C2_VZ0 1 +#define C2_VXY1 2 +#define C2_VZ1 3 +#define C2_VXY2 4 +#define C2_VZ2 5 +#define C2_RGB 6 +#define C2_OTZ 7 +#define C2_IR0 8 +#define C2_IR1 9 +#define C2_IR2 10 +#define C2_IR3 11 +#define C2_SXY0 12 +#define C2_SXY1 13 +#define C2_SXY2 14 +#define C2_SXYP 15 +#define C2_SZ0 16 +#define C2_SZ1 17 +#define C2_SZ2 18 +#define C2_SZ3 19 +#define C2_MAC0 24 +#define C2_MAC1 25 +#define C2_MAC2 26 +#define C2_FLAG 31 + +/* C2 control registers */ + +#define C2_RT11RT12 0 +#define C2_RT13RT21 1 +#define C2_RT22RT23 2 +#define C2_RT31RT32 3 +#define C2_RT33_TRX 4 +#define C2_TRY_TRZ 5 +#define C2_OFX_OFY 18 /* (low = OFX, high = OFY) */ +#define C2_H_SF 20 + +/* Command codes (low 6 bits) */ + +#define CMD_RTPS 0x01 +#define CMD_RTPT 0x02 +#define CMD_NCLIP 0x06 +#define CMD_OP 0x0C +#define CMD_DPCS 0x10 +#define CMD_INTPL 0x11 +#define CMD_MVMVA 0x09 +#define CMD_AVSZ3 0x2D +#define CMD_AVSZ4 0x2E + diff --git a/code/gte_hello/hello_gte.c b/code/gte_hello/hello_gte.c index 2a854f8..dd6fee7 100644 --- a/code/gte_hello/hello_gte.c +++ b/code/gte_hello/hello_gte.c @@ -157,6 +157,26 @@ void gp_display_frame(DoubleBuffer* screen_buf, S2* active_buf_id, U4* ordering_ void render(void) { } +// #define gte_ldv0(r0) \ +// __asm__ volatile( \ +// "lwc2 $0, 0( %0 );" \ +// "lwc2 $1, 4( %0 )" \ +// : \ +// : "r"(r0)) + +/** + * @brief Loads a single V3_S2 to GTE vector register V0 + * + * @details Loads values from an V3_S2 struct to GTE data registers C2_VXY0 + * and C2_VZ0. + */ +// #define gte_ldv0( r0 ) __asm__ volatile ( \ +// "lwc2 $0, 0( %0 );" \ +// "lwc2 $1, 4( %0 );" \ +// : \ +// : "r"( r0 ) \ +// : "$t0" ) + void update(PrimitiveArena* pa, U4* ordering_buf) { orderingtbl_clear_reverse(ordering_buf, OrderingTbl_Len); @@ -219,7 +239,7 @@ void update(PrimitiveArena* pa, U4* ordering_buf) // static_mem.cube.rot.x += 6; // static_mem.cube.rot.y += 8; // static_mem.cube.rot.z += 12; - static_mem.cube.rot.y += 20; + static_mem.cube.rot.y += 0; } // Draw Floor { diff --git a/scripts/build_psyq.ps1 b/scripts/build_psyq.ps1 index 996ff05..01f0f76 100644 --- a/scripts/build_psyq.ps1 +++ b/scripts/build_psyq.ps1 @@ -349,4 +349,4 @@ function build-gte_hello { link-modules @($module_asm_crt, $module_asm, $module_c) $elf $link_args make-binary $elf $exe } -build-gte_hello \ No newline at end of file +build-gte_hello diff --git a/scripts/output.json b/scripts/output.json index f8286b0..e92720a 100644 --- a/scripts/output.json +++ b/scripts/output.json @@ -2,6 +2,6 @@ "configureme": true, "grey": false, "mask": 0.5, - "masktype": 2, + "masktype": 1, "warp": 0 }