mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-08-14 11:38:14 +00:00
add ac_yield_load and ac_yield_tail for delay slot optimization opportunities.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#pragma once
|
||||
#endif
|
||||
// Auto-generated by ps1_meta.lua — DO NOT EDIT
|
||||
// Source: C:\projects\Pikuma\ps1\code\duffle\lottes_tape.h
|
||||
// Source: C:\projects\pikuma\ps1\code\duffle\lottes_tape.h
|
||||
// Component atoms (MipsAtomComp_(ac_*)) -> macro variants (mac_*)
|
||||
|
||||
#ifndef WORD_COUNT
|
||||
@@ -15,6 +15,10 @@
|
||||
* These do NOT yield. They are expanded inline inside Tape Atoms.
|
||||
* ---------------------------------------------------------------------------*/
|
||||
// The 'Yield' sequence for Tape Atoms (mac_yield).
|
||||
// - mac_yield() is the safe default for atom-endings: 4 words, BD-slot of jr is mandatory nop.
|
||||
// - mac_yield_load() + mac_yield_tail():
|
||||
// - unconditional branch: mac_yield_load fills the branch's BD-slot (replaces a nop);
|
||||
// - mac_yield_tail runs at the branch target (does NOT re-load R_AtomJmp).
|
||||
#define mac_yield(...) \
|
||||
load_word(R_AtomJmp, R_TapePtr, 0) \
|
||||
, add_ui_self( R_TapePtr, S_(MipsCode)) \
|
||||
@@ -22,6 +26,18 @@
|
||||
, nop
|
||||
WORD_COUNT(mac_yield, 4)
|
||||
|
||||
/* atom_dbg_skip */
|
||||
#define mac_yield_load(...) \
|
||||
load_word(R_AtomJmp, R_TapePtr, 0)
|
||||
WORD_COUNT(mac_yield_load, 1)
|
||||
|
||||
/* atom_dbg_skip */
|
||||
#define mac_yield_tail(...) \
|
||||
add_ui_self(R_TapePtr, S_(MipsCode)) \
|
||||
, jump_reg( R_AtomJmp) \
|
||||
, nop
|
||||
WORD_COUNT(mac_yield_tail, 3)
|
||||
|
||||
/* atom_dbg_skip */
|
||||
/* Words: 3; Loads 3 S2 indices from the face array */
|
||||
#define mac_load_tri_indices(...) \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated by ps1_meta.lua (passes/offsets.lua) — DO NOT EDIT
|
||||
// Source: C:\projects\Pikuma\ps1\code\duffle\lottes_tape.h
|
||||
// Source: C:\projects\pikuma\ps1\code\duffle\lottes_tape.h
|
||||
#pragma once
|
||||
|
||||
#pragma region lottes_tape
|
||||
|
||||
@@ -122,13 +122,27 @@ FI_ void tb_scope_run_end(TapeBuilder* tb) { tb_emit(tb,tape_exit); tape_run(tb_
|
||||
* These do NOT yield. They are expanded inline inside Tape Atoms.
|
||||
* ---------------------------------------------------------------------------*/
|
||||
|
||||
// The 'Yield' sequence for Tape Atoms (mac_yield).
|
||||
// The 'Yield' sequence for Tape Atoms (mac_yield).
|
||||
// - mac_yield() is the safe default for atom-endings: 4 words, BD-slot of jr is mandatory nop.
|
||||
// - mac_yield_load() + mac_yield_tail():
|
||||
// - unconditional branch: mac_yield_load fills the branch's BD-slot (replaces a nop);
|
||||
// - mac_yield_tail runs at the branch target (does NOT re-load R_AtomJmp).
|
||||
|
||||
atom_dbg_skip MipsAtomComp_(ac_yield) {
|
||||
load_word(R_AtomJmp, R_TapePtr, 0),
|
||||
add_ui_self( R_TapePtr, S_(MipsCode)),
|
||||
jump_reg( R_AtomJmp), nop,
|
||||
};
|
||||
|
||||
atom_dbg_skip MipsAtomComp_(ac_yield_load) {
|
||||
load_word(R_AtomJmp, R_TapePtr, 0),
|
||||
};
|
||||
|
||||
atom_dbg_skip MipsAtomComp_(ac_yield_tail) {
|
||||
add_ui_self(R_TapePtr, S_(MipsCode)),
|
||||
jump_reg( R_AtomJmp), nop,
|
||||
};
|
||||
|
||||
enum {
|
||||
R_PrimCursor = R_T7 atom_reg atom_type(U4*), /* VRAM output cursor (primitive buffer) */
|
||||
R_FaceCursor = R_T4 atom_reg atom_type(V4_S2*), /* Cube face-index cursor (V4_S2*); floor context switches to V3_S2* via atom_phase */
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#pragma once
|
||||
#endif
|
||||
// Auto-generated by ps1_meta.lua — DO NOT EDIT
|
||||
// Source: C:\projects\Pikuma\ps1\code\hello_joypad\hello_joypad.tape.c
|
||||
// Source: C:\projects\pikuma\ps1\code\hello_joypad\hello_joypad.tape.c
|
||||
// Component atoms (MipsAtomComp_(ac_*)) -> macro variants (mac_*)
|
||||
|
||||
#ifndef WORD_COUNT
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Auto-generated by ps1_meta.lua (passes/offsets.lua) — DO NOT EDIT
|
||||
// Source: C:\projects\Pikuma\ps1\code\hello_joypad\hello_joypad.tape.c
|
||||
// Source: C:\projects\pikuma\ps1\code\hello_joypad\hello_joypad.tape.c
|
||||
#pragma once
|
||||
|
||||
#pragma region hello_joypad.tape
|
||||
@@ -25,7 +25,7 @@ enum {
|
||||
atom_offset_bounds_chk_floor_f3_face_exit = _atom_offset_bounds_chk_floor_f3_face_exit,
|
||||
};
|
||||
|
||||
// --- atom: pad_bios_snapshot (78 words) ---
|
||||
// --- atom: pad_bios_snapshot (77 words) ---
|
||||
|
||||
#define _atom_offset_snap_root_skip_disconnected 8
|
||||
#define _atom_offset_disconnected_snap_end 60
|
||||
@@ -51,7 +51,7 @@ enum {
|
||||
atom_offset_analog_pad_snap_end = _atom_offset_analog_pad_snap_end,
|
||||
};
|
||||
|
||||
// --- atom: pad_apply_input (60 words) ---
|
||||
// --- atom: pad_apply_input (59 words) ---
|
||||
|
||||
#define _atom_offset_dpad_left_exit_dpad_left 6
|
||||
#define _atom_offset_dpad_right_exit_dpad_right 6
|
||||
|
||||
@@ -400,7 +400,11 @@ atom_label(disconnected) /* === Disconnected body. */
|
||||
load_upper_i(R_T4, 0x8080), or_i_self(R_T4, 0x8080),
|
||||
store_word( R_T4, R_PadState, O_(PadState,left_x)),
|
||||
store_byte( R_RawId, R_PadState, O_(PadState,id)),
|
||||
jump_rel(atom_offset(disconnected, snap_end)), nop,
|
||||
jump_rel(atom_offset(disconnected, snap_end)),
|
||||
/* BD-slot: load next atom's entry point (replaces the nop).
|
||||
* The unconditional branch always jumps to snap_end, where mac_yield_tail()
|
||||
* transfers control to R_AtomJmp without re-loading it. */
|
||||
mac_yield_load(),
|
||||
atom_label(skip_disconnected)
|
||||
|
||||
/* === Case 2: Pending (status == 0 && id == 0)
|
||||
@@ -418,7 +422,8 @@ atom_label(pending) /* === Pending body */
|
||||
load_upper_i(R_T4, 0x8080), or_i_self(R_T4, 0x8080),
|
||||
store_word( R_T4, R_PadState, O_(PadState,left_x)),
|
||||
store_byte( R_RawId, R_PadState, O_(PadState,id)),
|
||||
jump_rel(atom_offset(pending, snap_end)), nop,
|
||||
jump_rel(atom_offset(pending, snap_end)),
|
||||
mac_yield_load(),
|
||||
|
||||
atom_label(id_dispatch) /* === Case 3-6: ID dispatch */
|
||||
add_ui(R_T4, R_0, 0x41), branch_ne(R_RawId, R_T4, atom_offset(id_dispatch, try_analog_stick)),
|
||||
@@ -440,7 +445,8 @@ atom_label(id_dispatch) /* === Case 3-6: ID dispatch */
|
||||
add_ui( R_T4, R_0, 0x41),
|
||||
store_byte( R_T4, R_PadState, O_(PadState,id)),
|
||||
|
||||
jump_rel(atom_offset(id_dispatch, snap_end)), nop,
|
||||
jump_rel(atom_offset(id_dispatch, snap_end)),
|
||||
mac_yield_load(),
|
||||
|
||||
atom_label(try_analog_stick) /* === Case 4: AnalogStick (id == 0x53)*/
|
||||
add_ui(R_T4, R_0, 0x53), branch_ne(R_RawId, R_T4, atom_offset(try_analog_stick, try_analog_pad)),
|
||||
@@ -461,7 +467,8 @@ atom_label(analog_stick) /* === AnalogStick body
|
||||
store_half( R_T4, R_PadState, O_(PadState,right_x)),
|
||||
add_ui( R_T5, R_0, 0x53), /* R_T5 = id value (clobbers left_xy, already stored) */
|
||||
store_byte( R_T5, R_PadState, O_(PadState,id)),
|
||||
jump_rel(atom_offset(analog_stick, snap_end)), nop,
|
||||
jump_rel(atom_offset(analog_stick, snap_end)),
|
||||
mac_yield_load(),
|
||||
|
||||
atom_label(try_analog_pad) /* === Case 5-6: AnalogPad (id & 0xF0 == 0x70) */
|
||||
and_i( R_T4, R_RawId, 0xF0),
|
||||
@@ -483,7 +490,8 @@ atom_label(analog_pad) /* === AnalogPad body
|
||||
store_half( R_T4, R_PadState, O_(PadState,right_x)),
|
||||
store_byte( R_RawId, R_PadState, O_(PadState,id)),
|
||||
|
||||
jump_rel(atom_offset(analog_pad, snap_end)), nop,
|
||||
jump_rel(atom_offset(analog_pad, snap_end)),
|
||||
mac_yield_load(),
|
||||
|
||||
atom_label(try_unsupported) /* === Case 7: Unsupported — fall through from the AnalogPad range-check miss. */
|
||||
add_ui( R_T4, R_0, PadStatus_Unsupported),
|
||||
@@ -497,7 +505,8 @@ atom_label(try_unsupported) /* === Case 7: Unsupported — fall through from the
|
||||
/* Fall through to snap_end. */
|
||||
|
||||
atom_label(snap_end)
|
||||
mac_yield(),
|
||||
/* NOT mac_yield() — R_AtomJmp was already loaded in the BD-slot of the case-exit branch. */
|
||||
mac_yield_tail(),
|
||||
};
|
||||
|
||||
/* ----- pad_apply_input -----
|
||||
@@ -581,7 +590,8 @@ atom_label(dead_check_upper)
|
||||
/* R_T4 = (0x90 < left_x) ? 1 : 0 → (left_x > 0x90) ? 1 : 0 */
|
||||
set_lt_u(R_T4, R_T4, R_T3), branch_ne(R_T4, R_0, atom_offset(dead_zone_high_check, dead_high_active)),
|
||||
add_ui( R_T4, R_0, 0x80), /* BD-slot: pre-load 0x80 for dead_high_active */
|
||||
jump_rel(atom_offset(dead_zone_skip, exit_stick)), nop,
|
||||
jump_rel(atom_offset(dead_zone_skip, exit_stick)),
|
||||
mac_yield_load(),
|
||||
|
||||
atom_label(dead_low_active)
|
||||
/* R_T3 = left_x (from line 632 lbu; not clobbered between dead_zone_low_check branch + its BD-slot `add_ui R_T4, 0x80`).
|
||||
@@ -603,7 +613,8 @@ atom_label(dead_low_active)
|
||||
add_u( R_T0, R_T0, R_T4),
|
||||
store_half( R_T0, R_FloorRot, O_(V3_S2,y)),
|
||||
|
||||
jump_rel(atom_offset(end_low, exit_stick)), nop,
|
||||
jump_rel(atom_offset(end_low, exit_stick)),
|
||||
mac_yield_load(),
|
||||
|
||||
atom_label(dead_high_active)
|
||||
/* R_T3 = left_x (from line 641 lbu in dead_check_upper; not clobbered between dead_zone_high_check branch + its BD-slot `add_ui R_T4, 0x80`).
|
||||
@@ -625,7 +636,8 @@ atom_label(dead_high_active)
|
||||
store_half( R_T0, R_FloorRot, O_(V3_S2,y)),
|
||||
|
||||
atom_label(exit_stick)
|
||||
mac_yield(),
|
||||
/* NOT mac_yield() — R_AtomJmp was already loaded in the BD-slot of the dead-zone/exit branch. */
|
||||
mac_yield_tail(),
|
||||
};
|
||||
|
||||
#pragma endregion Baked Atoms
|
||||
|
||||
Reference in New Issue
Block a user