mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-07-12 20:31:25 -07:00
adjustments, studying
This commit is contained in:
@@ -1,50 +1,12 @@
|
||||
// Auto-generated by gen_atom_offsets.lua — DO NOT EDIT
|
||||
// Source: C:\projects\Pikuma\ps1\code\duffle\lottes_tape.h
|
||||
#ifndef LOTTES_TAPE_OFFSETS_H
|
||||
#define LOTTES_TAPE_OFFSETS_H
|
||||
#pragma once
|
||||
|
||||
#pragma region lottes_tape
|
||||
|
||||
// Override the placeholder atom_offset() to dispatch via token pasting.
|
||||
// Dispatch macro: token-pastes <tag>_<target> to the enum name
|
||||
#undef atom_offset
|
||||
#define atom_offset(name) atom_offset_##name
|
||||
|
||||
// --- atom: sym (8 words) ---
|
||||
|
||||
|
||||
// --- atom: tape_exit (2 words) ---
|
||||
|
||||
|
||||
// --- atom: yield (4 words) ---
|
||||
|
||||
|
||||
// --- atom: mips_flush_icache (13 words) ---
|
||||
|
||||
|
||||
// --- atom: sync_prim_cursor (6 words) ---
|
||||
|
||||
|
||||
// --- atom: set_gte_world (22 words) ---
|
||||
|
||||
|
||||
// --- atom: rbind_cube_tri (6 words) ---
|
||||
|
||||
|
||||
// --- atom: cube_tri (74 words) ---
|
||||
|
||||
|
||||
// --- atom: rbind_floor_tri (6 words) ---
|
||||
|
||||
|
||||
// --- atom: diag_yield (4 words) ---
|
||||
|
||||
|
||||
// --- atom: diag_color (28 words) ---
|
||||
|
||||
|
||||
// --- atom: diag_gte (34 words) ---
|
||||
|
||||
#define atom_offset(tag, name) atom_offset_##tag##_##name
|
||||
|
||||
#pragma endregion lottes_tape
|
||||
|
||||
#endif // LOTTES_TAPE_OFFSETS_H
|
||||
|
||||
@@ -62,7 +62,8 @@ FI_ void tape_run(Slice_U4 tape) { register U4* tp rgcc(R_TapePtr) = tape.ptr; a
|
||||
|
||||
typedef Relative_(FArena) Struct_(TapeBuilder) { U4 ptr; U4 capacity; U4 used; };
|
||||
FI_ void tb_init(TapeBuilder* tb, FArena* arena) { tb->ptr = arena->start; tb->used = 0; }
|
||||
FI_ TapeBuilder tb_make( FArena* arena) { return (TapeBuilder){ arena->start, 0 }; }
|
||||
FI_ TapeBuilder tb_make_old( FArena* arena) { return (TapeBuilder){ arena->start, 0 }; }
|
||||
FI_ TapeBuilder tb_make(Slice mem) { return (TapeBuilder){ mem.ptr, mem.len, 0 }; }
|
||||
|
||||
#define tb_emit_(tb, atom) tb_emit(tb, tmpl(code,atom))
|
||||
FI_ void tb_emit(TapeBuilder* tb, MipsCode* atom) { u4_r(tb->ptr)[tb->used] = u4_(atom); ++ tb->used; }
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
// Auto-generated by gen_atom_offsets.lua — DO NOT EDIT
|
||||
// Source: C:\projects\Pikuma\ps1\code\gte_hello\hello_gte_tape.c
|
||||
#ifndef HELLO_GTE_TAPE_OFFSETS_H
|
||||
#define HELLO_GTE_TAPE_OFFSETS_H
|
||||
#pragma once
|
||||
|
||||
#pragma region hello_gte_tape
|
||||
|
||||
// Override the placeholder atom_offset() to dispatch via token pasting.
|
||||
// Dispatch macro: token-pastes <tag>_<target> to the enum name
|
||||
#undef atom_offset
|
||||
#define atom_offset(name) atom_offset_##name
|
||||
#define atom_offset(tag, name) atom_offset_##tag##_##name
|
||||
|
||||
// --- atom: floor_tri (49 words) ---
|
||||
// --- atom: floor_tri (51 words) ---
|
||||
|
||||
#define atom_offset_floor_tri_exit (17)
|
||||
#define _atom_offset_culling_floor_tri_exit 17
|
||||
#define _atom_offset_bounds_chk_floor_tri_exit 3
|
||||
|
||||
enum {
|
||||
atom_offset_culling_floor_tri_exit = _atom_offset_culling_floor_tri_exit,
|
||||
atom_offset_bounds_chk_floor_tri_exit = _atom_offset_bounds_chk_floor_tri_exit,
|
||||
};
|
||||
|
||||
#pragma endregion hello_gte_tape
|
||||
|
||||
#endif // HELLO_GTE_TAPE_OFFSETS_H
|
||||
|
||||
@@ -246,7 +246,7 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
||||
U4 prim_cursor = prim_base + pa->used;
|
||||
|
||||
LP_ U4 mem_temp_tape[512]; FArena tape_arena; farena_init(& tape_arena, slice_ut_arr(mem_temp_tape));
|
||||
TapeBuilder tb = tb_make(&tape_arena); tb_scope(& tb) {
|
||||
TapeBuilder tb = tb_make_old(&tape_arena); tb_scope(& tb) {
|
||||
tb_emit(& tb, code_rbind_cube_tri);
|
||||
tb_data(& tb, prim_cursor);
|
||||
tb_data(& tb, u4_(static_mem.cube.faces));
|
||||
@@ -334,12 +334,11 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
||||
U4 prim_cursor = prim_base + pa->used;
|
||||
|
||||
// Prepare the tape.
|
||||
LP_ U4 mem_temp_tape[512]; FArena tape_arena; farena_init(& tape_arena, slice_ut_arr(mem_temp_tape));
|
||||
TapeBuilder tb = tb_make(&tape_arena); tb_scope(& tb) {
|
||||
LP_ U4 mem_temp_tape[512];
|
||||
TapeBuilder tb = tb_make(slice_ut_arr(mem_temp_tape)); tb_scope(& tb) {
|
||||
// Push "Protocol" to tape
|
||||
tb_emit(& tb, code_rbind_floor_tri);
|
||||
// Note(Ed): This is technically argument shuffle and would be better if we did a single reference at most to a global batch context.
|
||||
// Note(Ed): We can technically allocate a single ptr with the global offset to the working context instead of utilizing the tape for this stack of refs.
|
||||
// TODO(Ed): Just use a single context struct ref
|
||||
tb_data(& tb, prim_cursor);
|
||||
tb_data(& tb, u4_(static_mem.floor.faces));
|
||||
tb_data(& tb, u4_(static_mem.floor.verts));
|
||||
@@ -367,7 +366,7 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
||||
if (0)
|
||||
{
|
||||
LP_ U4 mem_temp_tape[512]; FArena tape_arena; farena_init(& tape_arena, slice_ut_arr(mem_temp_tape));
|
||||
TapeBuilder tb = tb_make(& tape_arena); tb_scope(& tb) {
|
||||
TapeBuilder tb = tb_make_old(& tape_arena); tb_scope(& tb) {
|
||||
// Skip set_gte_world atom for diagnostics to isolate the triangle loop
|
||||
for (U4 i = 0; i < Floor_num_faces; i++) {
|
||||
// =======================================================
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# include "gen/hello_gte_tape.offsets.h"
|
||||
#endif
|
||||
|
||||
#pragma region MACs
|
||||
#pragma region MACs (Mips Atom components)
|
||||
|
||||
/* Words: 3; High: 0x20/B, Low: G/R */
|
||||
#define mac_format_f3_color(color_hi, color_lo) \
|
||||
@@ -24,17 +24,25 @@
|
||||
|
||||
internal MipsAtom_(floor_tri) {
|
||||
// T0-T2 allocated
|
||||
mac_load_tri_indices(R_T0, R_T1, R_T2),
|
||||
mac_load_tri_verts( R_T0, R_T1, R_T2),
|
||||
// mac_load_tri_indices(R_T0, R_T1, R_T2),
|
||||
load_half_u(R_T0, R_FaceCur, 0 * S_(S2))
|
||||
, load_half_u(R_T1, R_FaceCur, 1 * S_(S2))
|
||||
, load_half_u(R_T2, R_FaceCur, 2 * S_(S2))
|
||||
,
|
||||
// mac_load_tri_verts( R_T0, R_T1, R_T2),
|
||||
shift_ll(R_AT, R_T0, 3), add_u(R_AT, R_AT, R_VertBase), load_word(R_V0, R_AT, 0), load_word(R_V1, R_AT, 4), gte_mt(R_V0, C2_VXY0), gte_mt(R_V1, C2_VZ0)
|
||||
, shift_ll(R_AT, R_T1, 3), add_u(R_AT, R_AT, R_VertBase), load_word(R_V0, R_AT, 0), load_word(R_V1, R_AT, 4), gte_mt(R_V0, C2_VXY1), gte_mt(R_V1, C2_VZ1)
|
||||
, shift_ll(R_AT, R_T2, 3), add_u(R_AT, R_AT, R_VertBase), load_word(R_V0, R_AT, 0), load_word(R_V1, R_AT, 4), gte_mt(R_V0, C2_VXY2), gte_mt(R_V1, C2_VZ2)
|
||||
,
|
||||
|
||||
/* 3. Execute Math */
|
||||
nop, nop, gte_cmdw_rotate_translate_perspective_triple,
|
||||
nop, nop, gte_cmdw_nclip,
|
||||
nop, nop,
|
||||
|
||||
/* 4. Culling (Branch forward 29 instructions if Backface) */
|
||||
/* 4. Culling (Branch forward if Backface) */
|
||||
gte_mf(R_T0, C2_MAC0),
|
||||
nop, branch_le_zero(R_T0, atom_offset(floor_tri_exit)),
|
||||
nop, branch_le_zero(R_T0, atom_offset(culling, floor_tri_exit)),
|
||||
nop,
|
||||
|
||||
/* 5. Format Primitive */
|
||||
@@ -45,10 +53,10 @@ internal MipsAtom_(floor_tri) {
|
||||
nop, nop, gte_avg_sort_z3,
|
||||
nop, nop, gte_mf(R_T1, C2_OTZ),
|
||||
|
||||
/* 7. Bounds Check OTZ < 2048 (Branch forward 13 instructions to skip insertion) */
|
||||
/* 7. Bounds Check OTZ < 2048 (Branch forward to skip insertion) */
|
||||
add_ui( R_AT, R_0, OrderingTbl_Len),
|
||||
slt_u( R_AT, R_T1, R_AT),
|
||||
branch_equal(R_AT, R_0, 13),
|
||||
branch_equal(R_AT, R_0, atom_offset(bounds_chk, floor_tri_exit)),
|
||||
nop,
|
||||
|
||||
/* 8. Insert into Ordering Table Linked List */
|
||||
|
||||
Reference in New Issue
Block a user