mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-07-12 12:21:26 -07:00
learning...
This commit is contained in:
@@ -206,7 +206,8 @@
|
||||
* writes at this granularity.
|
||||
*
|
||||
* ============================================================================*/
|
||||
#define tape_regs(...) (__VA_ARGS__)
|
||||
#define atom_reads(...) (__VA_ARGS__)
|
||||
#define atom_writes(...) (__VA_ARGS__)
|
||||
|
||||
/* ============================================================================
|
||||
* ATOM ANNOTATION MACROS
|
||||
|
||||
@@ -189,22 +189,6 @@ internal MipsAtom_(mips_flush_icache) {
|
||||
, mac_yield()
|
||||
};
|
||||
|
||||
typedef Struct_(Binds_SyncPrimCursor) {
|
||||
U4 PrimtiveArena_Used;
|
||||
U4 PrimtiveBase;
|
||||
};
|
||||
internal MipsAtom_(sync_prim_cursor) {
|
||||
/* Pop the C-struct address and base address from the tape */
|
||||
// Note(Ed): Argument shuffle....
|
||||
load_word(R_AT, R_TapePtr, O_(Binds_SyncPrimCursor,PrimtiveArena_Used)),
|
||||
load_word(R_T0, R_TapePtr, O_(Binds_SyncPrimCursor,PrimtiveBase)),
|
||||
add_ui_1( R_TapePtr, S_(Binds_SyncPrimCursor)),
|
||||
/* Calculate byte offset and store directly back to RAM */
|
||||
sub_u(R_T0, R_PrimCursor, R_T0), // R_T0 = PrimitiveArea_Used(R_AT) - R_PrimCur
|
||||
store_word(R_T0, R_AT, 0), // PrimitiveBase(R_AT)[0] = R_T0
|
||||
mac_yield()
|
||||
};
|
||||
|
||||
internal MipsAtom_(set_gte_world) {
|
||||
/* Pop matrix address from tape into R_T3 ($11) */
|
||||
load_word(R_T3, R_TapePtr, 0),
|
||||
@@ -221,7 +205,6 @@ internal MipsAtom_(set_gte_world) {
|
||||
mac_yield()
|
||||
};
|
||||
|
||||
|
||||
// TODO(Ed): I'm not sure yet if the bindings are redundant with the floortri atom yet.
|
||||
|
||||
typedef Struct_(Binds_CubeTri) {
|
||||
@@ -278,7 +261,6 @@ internal MipsAtom_(rbind_cube_tri) {
|
||||
* Inner branch (OTZ bounds): branch_equal(R_AT, R_0, 13)
|
||||
* → Skip 13 instructions from BD slot, land at add_ui(R_FaceCur,...)
|
||||
* ============================================================================ */
|
||||
atom_resource(cube_tri, "model_ship_cube")
|
||||
atom_region (cube_tri, REGION_PRIM_ARENA)
|
||||
atom_group (cube_tri, GROUP_RENDER_PRIMS)
|
||||
atom_cadence (cube_tri, CADENCE_FRAME)
|
||||
|
||||
@@ -259,7 +259,7 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
||||
tb_emit(& tb, code_cube_tri);
|
||||
}
|
||||
|
||||
tb_emit(& tb, code_sync_prim_cursor);
|
||||
tb_emit(& tb, code_sync_primitive_arena);
|
||||
tb_data(& tb, u4_(& pa->used));
|
||||
tb_data(& tb, prim_base);
|
||||
}
|
||||
@@ -351,8 +351,8 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
||||
for (U4 i = 0; i < Floor_num_faces; i++) {
|
||||
tb_emit(& tb, code_floor_tri);
|
||||
}
|
||||
|
||||
tb_emit(& tb, code_sync_prim_cursor);
|
||||
// After code_floor_tri iterations complete, the primitive arena's used counter is wrong.
|
||||
tb_emit(& tb, code_sync_primitive_arena);
|
||||
tb_data(& tb, u4_(& pa->used));
|
||||
tb_data(& tb, prim_base);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
atom_group( floor_tri, GROUP_RENDER_FLOOR)
|
||||
atom_cadence(floor_tri, CADENCE_FRAME)
|
||||
atom_annot( floor_tri, phase_work,
|
||||
tape_regs(R_PrimCursor, R_FaceCursor, R_VertBase, R_OtBase),
|
||||
tape_regs(R_PrimCursor, R_FaceCursor))
|
||||
atom_reads( R_PrimCursor, R_FaceCursor, R_VertBase, R_OtBase),
|
||||
atom_writes(R_PrimCursor, R_FaceCursor))
|
||||
internal
|
||||
MipsAtom_(floor_tri) {
|
||||
// T0-T2 allocated
|
||||
@@ -69,11 +69,29 @@ MipsAtom_(floor_tri) {
|
||||
|
||||
/* 8. Insert into Ordering Table Linked List */
|
||||
mac_insert_ot_tag(R_T1, 0x0400),
|
||||
add_ui(R_PrimCursor, R_PrimCursor, S_(Poly_F3)), /* Advance Prim Cursor (5 words) */
|
||||
add_ui_1(R_PrimCursor, S_(Poly_F3)), /* Advance Prim Cursor (5 words) */
|
||||
// Note(Ed): No bounds checking, should be checked before atom runs.
|
||||
|
||||
/* 9. Advance Input Cursor & Yield (Both branch targets land here) */
|
||||
atom_label(floor_tri_exit)
|
||||
add_ui(R_FaceCursor, R_FaceCursor, S_(S2) * 4), /* Advance Face Cursor (4 * S2 = 8 bytes) */
|
||||
add_ui_1(R_FaceCursor, S_(S2) * 4), /* Advance Face Cursor (4 * S2 = 8 bytes) */
|
||||
mac_yield()
|
||||
};
|
||||
|
||||
typedef Struct_(Binds_SyncPrimitiveArena) { U4 PrimtiveArena_Used; U4 PrimtiveBase; };
|
||||
atom_region( sync_primitive_arena, REGION_PRIM_ARENA)
|
||||
atom_group( sync_primitive_arena, GROUP_RENDER_FLOOR)
|
||||
atom_cadence(sync_primitive_arena, CADENCE_FRAME)
|
||||
atom_annot( sync_primitive_arena, phase_work,
|
||||
atom_reads( R_TapePtr, R_PrimCursor),
|
||||
atom_writes(R_TapePtr))
|
||||
internal MipsAtom_(sync_primitive_arena) {
|
||||
load_word(R_AT, R_TapePtr, O_(Binds_SyncPrimitiveArena,PrimtiveArena_Used)),
|
||||
load_word(R_T0, R_TapePtr, O_(Binds_SyncPrimitiveArena,PrimtiveBase)),
|
||||
add_ui_1( R_TapePtr, S_(Binds_SyncPrimitiveArena)),
|
||||
/* Calculate byte offset and store directly back to RAM */
|
||||
sub_u( R_T0, R_PrimCursor, R_T0), // R_T0 = R_PrimCursor - prim-base
|
||||
store_word(R_T0, R_AT, 0), // R_AT[0] = R_T0
|
||||
mac_yield()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user