mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-06-16 00:52:22 -07:00
triangle spotted (not yellow!)
This commit is contained in:
@@ -25,7 +25,7 @@ typedef Slice_(U4);
|
||||
|
||||
FI_ void tape_run(Slice_U4 tape, B1** r_prim_cursor, void* face_cursor, void* vert_base, void* ot_base) {
|
||||
register U4* tp rgcc(R_TP) = tape.ptr;
|
||||
register B1* pcur rgcc(R_T7) = *r_prim_cursor;
|
||||
register B1* pcur rgcc(R_T7) = r_prim_cursor[0];
|
||||
register void* r_t4 rgcc(R_T4) = face_cursor;
|
||||
register void* r_t5 rgcc(R_T5) = vert_base;
|
||||
register void* r_t6 rgcc(R_T6) = ot_base;
|
||||
@@ -42,15 +42,13 @@ FI_ void tape_run(Slice_U4 tape, B1** r_prim_cursor, void* face_cursor, void* ve
|
||||
: "at", "v0", "v1", "t0", "t1", "t2", "t3", "t9", "memory"
|
||||
);
|
||||
|
||||
*r_prim_cursor = pcur;
|
||||
r_prim_cursor[0] = pcur;
|
||||
}
|
||||
|
||||
/* Custom TapeBuilder that bypasses FArena to guarantee tightly packed U4s */
|
||||
typedef Struct_(TapeBuilder) { U4* ptr; U4 count; };
|
||||
FI_ TapeBuilder tb_begin(FArena* arena) { return (TapeBuilder){ (U4*)arena->start, 0 }; }
|
||||
|
||||
I_ void tb_emit(TapeBuilder* tb, Code* atom) { r_(tb->ptr)[tb->count] = u4_(atom); ++ tb->count; }
|
||||
|
||||
I_ Slice_U4 tb_end(TapeBuilder* tb) {
|
||||
tb_emit(tb, code_tape_exit);
|
||||
return (Slice_U4){ tb->ptr, tb->count };
|
||||
@@ -154,33 +152,28 @@ internal Code CodeBlob_(atom_diag_yield) {
|
||||
|
||||
/* DIAGNOSTIC 2: Pure memory test (No GTE). Draws a fixed cyan triangle. */
|
||||
internal Code CodeBlob_(atom_diag_color) {
|
||||
/* 1. Store Primitive Data (Code 0x20, Cyan color) */
|
||||
store_word(R_0, R_T7, 0),
|
||||
load_ui(R_AT, 0x2000),
|
||||
or_i(R_AT, R_AT, 0xFFFF),
|
||||
store_word(R_AT, R_T7, 4),
|
||||
|
||||
/* 2. Fake coordinates */
|
||||
load_ui(R_AT, 0x0010), or_i(R_AT, R_AT, 0x0010), store_word(R_AT, R_T7, 8),
|
||||
load_ui(R_AT, 0x0010), or_i(R_AT, R_AT, 0x0050), store_word(R_AT, R_T7, 12),
|
||||
load_ui(R_AT, 0x0050), or_i(R_AT, R_AT, 0x0010), store_word(R_AT, R_T7, 16),
|
||||
/* Fake coordinates - Swapped winding order to prevent GPU culling! */
|
||||
load_ui(R_AT, 0x0010), or_i(R_AT, R_AT, 0x0010), store_word(R_AT, R_T7, 8), /* (16, 16) */
|
||||
load_ui(R_AT, 0x0050), or_i(R_AT, R_AT, 0x0010), store_word(R_AT, R_T7, 12), /* (80, 16) */
|
||||
load_ui(R_AT, 0x0010), or_i(R_AT, R_AT, 0x0050), store_word(R_AT, R_T7, 16), /* (16, 80) */
|
||||
|
||||
/* 3. Link to Ordering Table at fixed depth (10) */
|
||||
add_ui(R_T1, R_0, 10), /* <--- FIXED: Use add_ui for small constants! */
|
||||
add_ui(R_T1, R_0, 10),
|
||||
shift_ll(R_T1, R_T1, 2),
|
||||
add_u(R_T1, R_T1, R_T6),
|
||||
|
||||
load_word(R_AT, R_T1, 0),
|
||||
load_ui(R_V0, 0x0400),
|
||||
store_word(R_AT, R_T7, 0),
|
||||
|
||||
shift_ll(R_AT, R_T7, 8),
|
||||
shift_lr(R_AT, R_AT, 8),
|
||||
load_ui(R_V0, 0x0400),
|
||||
shift_ll(R_AT, R_T7, 8), shift_lr(R_AT, R_AT, 8),
|
||||
or_u(R_AT, R_AT, R_V0),
|
||||
|
||||
store_word(R_AT, R_T1, 0),
|
||||
|
||||
/* 4. Advance Prim Cursor and Yield */
|
||||
add_ui(R_T7, R_T7, 20),
|
||||
mips_yield
|
||||
};
|
||||
|
||||
@@ -98,7 +98,7 @@ typedef Struct_(SMemory) {
|
||||
DoubleBuffer screen_buf;
|
||||
A2_OrderingTable_Buffer ordering_tbl;
|
||||
PrimitiveArena primitives;
|
||||
S2 active_buf_id;
|
||||
S4 active_buf_id;
|
||||
|
||||
M3_S2 tform_world;
|
||||
|
||||
@@ -118,7 +118,7 @@ I_ B1* prim__alloc(U4 type_width, Str8 type_name) {
|
||||
}
|
||||
#define prim_alloc(type) (type*)prim__alloc(S_(type), slit( stringify(type)))
|
||||
|
||||
void gp_screen_init_c11(DoubleBuffer* screen_buf, S2* active_buf_id)
|
||||
void gp_screen_init_c11(DoubleBuffer* screen_buf, S4* active_buf_id)
|
||||
{
|
||||
reset_graph(0);
|
||||
|
||||
@@ -150,7 +150,7 @@ void gp_screen_init_c11(DoubleBuffer* screen_buf, S2* active_buf_id)
|
||||
set_display_enabled(1); // gp_DisplayEnabled
|
||||
}
|
||||
|
||||
void gp_display_frame(DoubleBuffer* screen_buf, S2* active_buf_id, U4* ordering_buf, PrimitiveArena* pa) {
|
||||
void gp_display_frame(DoubleBuffer* screen_buf, S4* active_buf_id, U4* ordering_buf, PrimitiveArena* pa) {
|
||||
draw_sync(0);
|
||||
vsync(0);
|
||||
displayenv_put(& r_(screen_buf->display)[active_buf_id[0] ]);
|
||||
@@ -231,7 +231,7 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
||||
static_mem.cube.rot.y += 30;
|
||||
}
|
||||
// Draw Floor
|
||||
if (1)
|
||||
if (0)
|
||||
{
|
||||
m3s2_rotation (& static_mem.floor.rot, & static_mem.tform_world);
|
||||
m3s2_translation(& static_mem.tform_world, & static_mem.floor.pos);
|
||||
@@ -305,11 +305,6 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
||||
}
|
||||
}
|
||||
Slice_U4 tape = tb_end(&tb);
|
||||
|
||||
// 1. Setup Argument Registers (The Workspace)
|
||||
register V3_S2* face_cursor rgcc(R_T4) = static_mem.floor.faces;
|
||||
register V3_S2* vert_base rgcc(R_T5) = static_mem.floor.verts;
|
||||
register U4* ot_base rgcc(R_T6) = ordering_buf;
|
||||
// --- EXECUTION ---
|
||||
B1* prim_cursor = (B1*)r_(pa->buf)[static_mem.active_buf_id] + pa->used;
|
||||
// 2. Fire the Tape Drive (Explicitly bind the workspace variables)
|
||||
@@ -336,7 +331,7 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
||||
// 2. code_atom_diag_color -> Tests OT and Prim Arena memory
|
||||
// 3. code_atom_diag_gte -> Tests Vertex arrays and GTE Math
|
||||
// tb_emit(&tb, code_atom_diag_yield);
|
||||
// tb_emit(&tb, code_atom_diag_color);
|
||||
tb_emit(&tb, code_atom_diag_color);
|
||||
// tb_emit(&tb, code_atom_diag_gte);
|
||||
}
|
||||
}
|
||||
@@ -374,7 +369,7 @@ int main(void)
|
||||
gp_screen_init_c11(& static_mem.screen_buf, & static_mem.active_buf_id);
|
||||
while (1)
|
||||
{
|
||||
gknown S2* active_buf_id = & static_mem.active_buf_id;
|
||||
gknown S4* active_buf_id = & static_mem.active_buf_id;
|
||||
gknown U4* ordering_buf = r_(static_mem.ordering_tbl)[active_buf_id[0]];
|
||||
gknown PrimitiveArena* pa = & static_mem.primitives;
|
||||
update(pa, ordering_buf);
|
||||
|
||||
Reference in New Issue
Block a user