mirror of
https://github.com/Ed94/pikuma_ps1.git
synced 2026-08-09 00:58:16 +00:00
converted pad input for cam to mips atom
This commit is contained in:
@@ -26,6 +26,24 @@ enum {
|
|||||||
atom_offset_end_low_exit_stick = _atom_offset_end_low_exit_stick,
|
atom_offset_end_low_exit_stick = _atom_offset_end_low_exit_stick,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// --- atom: pad_input_cam (41 words) ---
|
||||||
|
|
||||||
|
#define _atom_offset_left_x_exit_left_x 3
|
||||||
|
#define _atom_offset_right_x_exit_right_x 3
|
||||||
|
#define _atom_offset_up_y_exit_up_y 3
|
||||||
|
#define _atom_offset_down_y_exit_down_y 3
|
||||||
|
#define _atom_offset_cross_z_exit_cross_z 3
|
||||||
|
#define _atom_offset_circle_z_exit_circle_z 3
|
||||||
|
|
||||||
|
enum {
|
||||||
|
atom_offset_left_x_exit_left_x = _atom_offset_left_x_exit_left_x,
|
||||||
|
atom_offset_right_x_exit_right_x = _atom_offset_right_x_exit_right_x,
|
||||||
|
atom_offset_up_y_exit_up_y = _atom_offset_up_y_exit_up_y,
|
||||||
|
atom_offset_down_y_exit_down_y = _atom_offset_down_y_exit_down_y,
|
||||||
|
atom_offset_cross_z_exit_cross_z = _atom_offset_cross_z_exit_cross_z,
|
||||||
|
atom_offset_circle_z_exit_circle_z = _atom_offset_circle_z_exit_circle_z,
|
||||||
|
};
|
||||||
|
|
||||||
// --- atom: cube_g4_face (76 words) ---
|
// --- atom: cube_g4_face (76 words) ---
|
||||||
|
|
||||||
#define _atom_offset_cull_cube_g4_face_exit 41
|
#define _atom_offset_cull_cube_g4_face_exit 41
|
||||||
|
|||||||
@@ -313,15 +313,57 @@ atom_label(exit_stick)
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
R_Cam = R_T4 atom_reg,
|
R_Cam = R_T4 atom_reg,
|
||||||
|
R_CamPadState = R_T5 atom_reg,
|
||||||
};
|
};
|
||||||
typedef Struct_(Binds_PadInputCam) {
|
typedef Struct_(Binds_PadInputCam) {
|
||||||
Camera* cam;
|
PadState* state;
|
||||||
|
Camera* cam;
|
||||||
};
|
};
|
||||||
internal MipsAtom_(pad_input_cam) atom_info(atom_bind(Binds_PadInputCam)) {
|
internal MipsAtom_(pad_input_cam) atom_info(atom_bind(Binds_PadInputCam)
|
||||||
load_word(R_Cam, R_TapePtr, O_(Binds_PadInputCam,cam)),
|
, atom_reads( R_Cam, R_CamPadState, R_TapePtr)
|
||||||
add_ui_self( R_TapePtr, S_(Binds_PadInputCam)),
|
, atom_writes(R_Cam)
|
||||||
// TODO(Ed): Implement.
|
) {
|
||||||
|
/* Bind pop: state → R_CamPadState (R_T5), cam → R_Cam (R_T4), advance R_TapePtr by 8. */
|
||||||
|
load_word(R_CamPadState, R_TapePtr, O_(Binds_PadInputCam,state)),
|
||||||
|
load_word(R_Cam, R_TapePtr, O_(Binds_PadInputCam,cam)),
|
||||||
|
add_ui_self( R_TapePtr, S_(Binds_PadInputCam)),
|
||||||
|
|
||||||
|
/* Load pad[0].buttons into R_T0; nop fills the load-delay slot. */
|
||||||
|
load_word(R_T0, R_CamPadState, O_(PadState,buttons)),
|
||||||
|
load_word(R_T1, R_Cam, O_(Camera,pos.x)), // BD-Slot.
|
||||||
|
|
||||||
|
// D-pad Left → cam.pos.x -= 50. and_i fulfills BD-slot for load on R_Cam.
|
||||||
|
and_i(R_T3, R_T0, Pad_Left), branch_le_zero(R_T3, atom_offset(left_x, exit_left_x)), nop,
|
||||||
|
add_si(R_T1, R_T1, -50), store_word(R_T1, R_Cam, O_(Camera,pos.x)),
|
||||||
|
atom_label(exit_left_x)
|
||||||
|
|
||||||
|
/* D-pad Right → cam.pos.x += 50. Reuses R_T1 from Left. */
|
||||||
|
and_i(R_T3, R_T0, Pad_Right), branch_le_zero(R_T3, atom_offset(right_x, exit_right_x)), nop,
|
||||||
|
add_si(R_T1, R_T1, 50), store_word(R_T1, R_Cam, O_(Camera,pos.x)),
|
||||||
|
atom_label(exit_right_x)
|
||||||
|
|
||||||
|
/* D-pad Up → cam.pos.y -= 50. Load pos.y BEFORE the andi. */
|
||||||
|
load_word(R_T1, R_Cam, O_(Camera,pos.y)),
|
||||||
|
and_i(R_T3, R_T0, Pad_Up), branch_le_zero(R_T3, atom_offset(up_y, exit_up_y)), nop,
|
||||||
|
add_si(R_T1, R_T1, -50), store_word(R_T1, R_Cam, O_(Camera,pos.y)),
|
||||||
|
atom_label(exit_up_y)
|
||||||
|
|
||||||
|
/* D-pad Down → cam.pos.y += 50. Reuses R_T1 from Up. */
|
||||||
|
and_i(R_T3, R_T0, Pad_Down), branch_le_zero(R_T3, atom_offset(down_y, exit_down_y)), nop,
|
||||||
|
add_si(R_T1, R_T1, 50), store_word(R_T1, R_Cam, O_(Camera,pos.y)),
|
||||||
|
atom_label(exit_down_y)
|
||||||
|
|
||||||
|
/* D-pad Cross → cam.pos.z -= 50. Load pos.z BEFORE the andi. */
|
||||||
|
load_word(R_T1, R_Cam, O_(Camera,pos.z)),
|
||||||
|
and_i(R_T3, R_T0, Pad_Cross), branch_le_zero(R_T3, atom_offset(cross_z, exit_cross_z)), nop,
|
||||||
|
add_si(R_T1, R_T1, -50), store_word(R_T1, R_Cam, O_(Camera,pos.z)),
|
||||||
|
atom_label(exit_cross_z)
|
||||||
|
|
||||||
|
/* D-pad Circle → cam.pos.z += 50. Reuses R_T1 from Cross. */
|
||||||
|
and_i(R_T3, R_T0, Pad_Circle), branch_le_zero(R_T3, atom_offset(circle_z, exit_circle_z)), nop,
|
||||||
|
add_si(R_T1, R_T1, 50), store_word(R_T1, R_Cam, O_(Camera,pos.z)),
|
||||||
|
atom_label(exit_circle_z)
|
||||||
|
|
||||||
mac_yield(),
|
mac_yield(),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -134,27 +134,28 @@ void update(PrimitiveArena* pa, U4* ordering_buf)
|
|||||||
tb_data_(state, & smem.pad[1]);
|
tb_data_(state, & smem.pad[1]);
|
||||||
|
|
||||||
// TODO(Ed): Implement based on below.
|
// TODO(Ed): Implement based on below.
|
||||||
// tb_emit_(pad_input_cam);
|
tb_emit_(pad_input_cam);
|
||||||
// tb_data_(cam, & smem.cam);
|
tb_data_(state, & smem.pad[0]);
|
||||||
|
tb_data_(cam, & smem.cam);
|
||||||
|
|
||||||
if (pad0_btn_(Pad_Left)) {
|
// if (pad0_btn_(Pad_Left)) {
|
||||||
smem.cam.pos.x -= 50;
|
// smem.cam.pos.x -= 50;
|
||||||
}
|
// }
|
||||||
if (pad0_btn_(Pad_Right)) {
|
// if (pad0_btn_(Pad_Right)) {
|
||||||
smem.cam.pos.x += 50;
|
// smem.cam.pos.x += 50;
|
||||||
}
|
// }
|
||||||
if (pad0_btn_(Pad_Up)) {
|
// if (pad0_btn_(Pad_Up)) {
|
||||||
smem.cam.pos.y -= 50;
|
// smem.cam.pos.y -= 50;
|
||||||
}
|
// }
|
||||||
if (pad0_btn_(Pad_Down)) {
|
// if (pad0_btn_(Pad_Down)) {
|
||||||
smem.cam.pos.y += 50;
|
// smem.cam.pos.y += 50;
|
||||||
}
|
// }
|
||||||
if (pad0_btn_(Pad_Cross)) {
|
// if (pad0_btn_(Pad_Cross)) {
|
||||||
smem.cam.pos.z -= 50;
|
// smem.cam.pos.z -= 50;
|
||||||
}
|
// }
|
||||||
if (pad0_btn_(Pad_Circle)) {
|
// if (pad0_btn_(Pad_Circle)) {
|
||||||
smem.cam.pos.z += 50;
|
// smem.cam.pos.z += 50;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
// Demo input (not longer using)
|
// Demo input (not longer using)
|
||||||
|
|||||||
Reference in New Issue
Block a user