mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-12-22 16:30:23 +00:00
Even more Lua improvements
Reorganized autogenerated lua functions into their own file Grouped up COBJECT LVTs Partially implemented: struct MarioBodyState, Object, ObjectNode, GraphNodeObject Reimplemented lua function wrappers for: camera.h, mario.h, mario_actions_*.c, mario_step.h
This commit is contained in:
parent
8aa9a95d5b
commit
b364493807
19 changed files with 2881 additions and 2304 deletions
|
@ -1,55 +1,41 @@
|
|||
import os
|
||||
import re
|
||||
|
||||
rejects = ""
|
||||
integer_types = ["u8", "u16", "u32", "u64", "s8", "s16", "s32", "s64", "int"]
|
||||
number_types = ["f32", "float"]
|
||||
cobject_types = ["struct MarioState*", "Vec3s", "Vec3f"]
|
||||
cobject_lot_types = ["LOT_MARIO_STATE", "LOT_VEC3S", "LOT_VEC3F"]
|
||||
cobject_types = ["struct MarioState*", "struct Object*"]
|
||||
cobject_lot_types = ["LOT_MARIO_STATE", "LOT_OBJECT"]
|
||||
|
||||
template = """/* THIS FILE IS AUTOGENERATED */
|
||||
/* SHOULD NOT BE MANUALLY CHANGED */
|
||||
|
||||
#include "smlua.h"
|
||||
|
||||
#include "game/level_update.h"
|
||||
#include "game/area.h"
|
||||
#include "game/mario.h"
|
||||
#include "game/mario_step.h"
|
||||
#include "game/mario_actions_stationary.h"
|
||||
#include "audio/external.h"
|
||||
#include "object_fields.h"
|
||||
#include "engine/math_util.h"
|
||||
|
||||
$[FUNCTIONS]
|
||||
|
||||
void smlua_bind_functions_autogen(void) {
|
||||
lua_State* L = gLuaState;
|
||||
$[BINDS]
|
||||
}
|
||||
"""
|
||||
|
||||
built_functions = ""
|
||||
built_binds = ""
|
||||
|
||||
#######
|
||||
|
||||
do_extern = False
|
||||
header_h = """
|
||||
s32 check_common_idle_cancels(struct MarioState *m);
|
||||
s32 check_common_hold_idle_cancels(struct MarioState *m);
|
||||
s32 act_idle(struct MarioState *m);
|
||||
void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound);
|
||||
s32 act_start_sleeping(struct MarioState *m);
|
||||
s32 act_sleeping(struct MarioState *m);
|
||||
s32 act_waking_up(struct MarioState *m);
|
||||
s32 act_shivering(struct MarioState *m);
|
||||
s32 act_coughing(struct MarioState *m);
|
||||
s32 act_standing_against_wall(struct MarioState *m);
|
||||
s32 act_in_quicksand(struct MarioState *m);
|
||||
s32 act_crouching(struct MarioState *m);
|
||||
s32 act_panting(struct MarioState *m);
|
||||
void stopping_step(struct MarioState *m, s32 animID, u32 action);
|
||||
s32 act_braking_stop(struct MarioState *m);
|
||||
s32 act_butt_slide_stop(struct MarioState *m);
|
||||
s32 act_hold_butt_slide_stop(struct MarioState *m);
|
||||
s32 act_slide_kick_slide_stop(struct MarioState *m);
|
||||
s32 act_start_crouching(struct MarioState *m);
|
||||
s32 act_stop_crouching(struct MarioState *m);
|
||||
s32 act_start_crawling(struct MarioState *m);
|
||||
s32 act_stop_crawling(struct MarioState *m);
|
||||
s32 act_shockwave_bounce(struct MarioState *m);
|
||||
s32 landing_step(struct MarioState *m, s32 arg1, u32 action);
|
||||
s32 check_common_landing_cancels(struct MarioState *m, u32 action);
|
||||
s32 act_jump_land_stop(struct MarioState *m);
|
||||
s32 act_double_jump_land_stop(struct MarioState *m);
|
||||
s32 act_side_flip_land_stop(struct MarioState *m);
|
||||
s32 act_freefall_land_stop(struct MarioState *m);
|
||||
s32 act_triple_jump_land_stop(struct MarioState *m);
|
||||
s32 act_backflip_land_stop(struct MarioState *m);
|
||||
s32 act_lava_boost_land(struct MarioState *m);
|
||||
s32 act_long_jump_land_stop(struct MarioState *m);
|
||||
s32 act_hold_jump_land_stop(struct MarioState *m);
|
||||
s32 act_hold_freefall_land_stop(struct MarioState *m);
|
||||
s32 act_air_throw_land(struct MarioState *m);
|
||||
s32 act_twirl_land(struct MarioState *m);
|
||||
s32 act_ground_pound_land(struct MarioState *m);
|
||||
s32 act_first_person(struct MarioState *m);
|
||||
s32 check_common_stationary_cancels(struct MarioState *m);
|
||||
s32 mario_execute_stationary_action(struct MarioState *m);
|
||||
"""
|
||||
header_h = ""
|
||||
|
||||
functions = []
|
||||
|
||||
|
@ -70,6 +56,16 @@ def normalize_type(t):
|
|||
t = parts[0] + ' ' + parts[1].replace(' ', '')
|
||||
return t
|
||||
|
||||
def gen_comment_header(f):
|
||||
comment_h = "// " + f + " //"
|
||||
comment_l = "/" * len(comment_h)
|
||||
s = ""
|
||||
s += " " + comment_l + "\n"
|
||||
s += " " + comment_h + "\n"
|
||||
s += "" + comment_l + "\n"
|
||||
s += "\n"
|
||||
return s
|
||||
|
||||
def process_line(line):
|
||||
function = {}
|
||||
|
||||
|
@ -103,8 +99,8 @@ def process_line(line):
|
|||
|
||||
functions.append(function)
|
||||
|
||||
def process_lines():
|
||||
for line in header_h.splitlines():
|
||||
def process_lines(file_str):
|
||||
for line in file_str.splitlines():
|
||||
if reject_line(line):
|
||||
global rejects
|
||||
rejects += line + '\n'
|
||||
|
@ -143,7 +139,10 @@ def build_return(function):
|
|||
return ' %s(L, %s);\n' % (lfunc, ccall)
|
||||
|
||||
def build_function(function):
|
||||
s = 'int smlua_func_%s(lua_State* L) {\n' % function['identifier']
|
||||
if len(function['params']) <= 0:
|
||||
s = 'int smlua_func_%s(UNUSED lua_State* L) {\n' % function['identifier']
|
||||
else:
|
||||
s = 'int smlua_func_%s(lua_State* L) {\n' % function['identifier']
|
||||
|
||||
i = 1
|
||||
for param in function['params']:
|
||||
|
@ -152,32 +151,66 @@ def build_function(function):
|
|||
i += 1
|
||||
s += '\n'
|
||||
|
||||
global do_extern
|
||||
if do_extern:
|
||||
s += ' extern %s\n' % function['line']
|
||||
|
||||
s += build_return(function)
|
||||
s += ' return 1;\n}\n'
|
||||
|
||||
function['implemented'] = not ('UNIMPLEMENTED' in s)
|
||||
function['implemented'] = 'UNIMPLEMENTED' not in s
|
||||
if 'UNIMPLEMENTED' in s:
|
||||
s = "/*\n" + s + "*/\n"
|
||||
|
||||
print(s)
|
||||
global built_functions
|
||||
built_functions += s + "\n"
|
||||
|
||||
def build_functions():
|
||||
for function in functions:
|
||||
build_function(function)
|
||||
|
||||
process_lines()
|
||||
build_functions()
|
||||
print('')
|
||||
print('-------------------')
|
||||
for function in functions:
|
||||
def build_bind(function):
|
||||
s = 'smlua_bind_function(L, "%s", smlua_func_%s);' % (function['identifier'], function['identifier'])
|
||||
if function['implemented']:
|
||||
print(' ' + s)
|
||||
s = ' ' + s
|
||||
else:
|
||||
print(' //' + s + ' <--- UNIMPLEMENTED')
|
||||
print('-------------------')
|
||||
print('REJECTS:')
|
||||
print(rejects)
|
||||
s = ' //' + s + ' <--- UNIMPLEMENTED'
|
||||
global built_binds
|
||||
built_binds += s + "\n"
|
||||
|
||||
def build_binds(fname):
|
||||
global built_binds
|
||||
built_binds += "\n // " + fname.split('/')[-1] + "\n"
|
||||
for function in functions:
|
||||
build_bind(function)
|
||||
|
||||
def process_file(fname):
|
||||
functions.clear()
|
||||
global do_extern
|
||||
do_extern = fname.endswith(".c")
|
||||
with open(fname) as file:
|
||||
process_lines(file.read())
|
||||
build_functions()
|
||||
build_binds(fname)
|
||||
|
||||
def process_files():
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__)) + '/lua_functions/'
|
||||
files = os.listdir(dir_path)
|
||||
for f in files:
|
||||
comment_header = "// " + f + " //"
|
||||
comment_line = "/" * len(comment_header)
|
||||
|
||||
global built_functions
|
||||
built_functions += gen_comment_header(f)
|
||||
|
||||
process_file(dir_path + f)
|
||||
|
||||
def main():
|
||||
process_files()
|
||||
filename = os.path.dirname(os.path.realpath(__file__)) + '/../src/pc/lua/smlua_functions_autogen.c'
|
||||
with open(filename, 'w') as out:
|
||||
out.write(template.replace("$[FUNCTIONS]", built_functions).replace("$[BINDS]", built_binds))
|
||||
print('REJECTS:')
|
||||
print(rejects)
|
||||
|
||||
main()
|
3
autogen/lua_functions/camera.h
Normal file
3
autogen/lua_functions/camera.h
Normal file
|
@ -0,0 +1,3 @@
|
|||
void set_camera_shake_from_hit(s16 shake);
|
||||
void set_environmental_camera_shake(s16 shake);
|
||||
void set_camera_shake_from_point(s16 shake, f32 posX, f32 posY, f32 posZ);
|
44
autogen/lua_functions/mario.h
Normal file
44
autogen/lua_functions/mario.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
s32 is_anim_at_end(struct MarioState *m);
|
||||
s32 is_anim_past_end(struct MarioState *m);
|
||||
s16 set_mario_animation(struct MarioState *m, s32 targetAnimID);
|
||||
s16 set_mario_anim_with_accel(struct MarioState *m, s32 targetAnimID, s32 accel);
|
||||
void set_anim_to_frame(struct MarioState *m, s16 animFrame);
|
||||
s32 is_anim_past_frame(struct MarioState *m, s16 animFrame);
|
||||
s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, Vec3s translation);
|
||||
void update_mario_pos_for_anim(struct MarioState *m);
|
||||
s16 return_mario_anim_y_translation(struct MarioState *m);
|
||||
void play_sound_if_no_flag(struct MarioState *m, u32 soundBits, u32 flags);
|
||||
void play_mario_jump_sound(struct MarioState *m);
|
||||
void adjust_sound_for_speed(struct MarioState *m);
|
||||
void play_sound_and_spawn_particles(struct MarioState *m, u32 soundBits, u32 waveParticleType);
|
||||
void play_mario_action_sound(struct MarioState *m, u32 soundBits, u32 waveParticleType);
|
||||
void play_mario_landing_sound(struct MarioState *m, u32 soundBits);
|
||||
void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits);
|
||||
void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits);
|
||||
void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits);
|
||||
void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits);
|
||||
void mario_set_bubbled(struct MarioState* m);
|
||||
void mario_set_forward_vel(struct MarioState *m, f32 speed);
|
||||
s32 mario_get_floor_class(struct MarioState *m);
|
||||
u32 mario_get_terrain_sound_addend(struct MarioState *m);
|
||||
struct Surface *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius);
|
||||
f32 vec3f_find_ceil(Vec3f pos, f32 height, struct Surface **ceil);
|
||||
s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw);
|
||||
u32 mario_floor_is_slippery(struct MarioState *m);
|
||||
s32 mario_floor_is_slope(struct MarioState *m);
|
||||
s32 mario_floor_is_steep(struct MarioState *m);
|
||||
f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f32 distFromMario);
|
||||
s16 find_floor_slope(struct MarioState *m, s16 yawOffset);
|
||||
void update_mario_sound_and_camera(struct MarioState *m);
|
||||
void set_steep_jump_action(struct MarioState *m);
|
||||
u32 set_mario_action(struct MarioState *m, u32 action, u32 actionArg);
|
||||
s32 set_jump_from_landing(struct MarioState *m);
|
||||
s32 set_jumping_action(struct MarioState *m, u32 action, u32 actionArg);
|
||||
s32 drop_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg);
|
||||
s32 hurt_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg, s16 hurtCounter);
|
||||
s32 check_common_action_exits(struct MarioState *m);
|
||||
s32 check_common_hold_action_exits(struct MarioState *m);
|
||||
s32 transition_submerged_to_walking(struct MarioState *m);
|
||||
s32 set_water_plunge_action(struct MarioState *m);
|
||||
s32 execute_mario_action(UNUSED struct Object *o);
|
||||
s32 force_idle_state(struct MarioState* m);
|
64
autogen/lua_functions/mario_actions_airborne.c
Normal file
64
autogen/lua_functions/mario_actions_airborne.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
void play_flip_sounds(struct MarioState *m, s16 frame1, s16 frame2, s16 frame3);
|
||||
void play_far_fall_sound(struct MarioState *m);
|
||||
void play_knockback_sound(struct MarioState *m);
|
||||
s32 lava_boost_on_wall(struct MarioState *m);
|
||||
s32 check_fall_damage(struct MarioState *m, u32 hardFallAction);
|
||||
s32 check_kick_or_dive_in_air(struct MarioState *m);
|
||||
s32 should_get_stuck_in_ground(struct MarioState *m);
|
||||
s32 check_fall_damage_or_get_stuck(struct MarioState *m, u32 hardFallAction);
|
||||
s32 check_horizontal_wind(struct MarioState *m);
|
||||
void update_air_with_turn(struct MarioState *m);
|
||||
void update_air_without_turn(struct MarioState *m);
|
||||
void update_lava_boost_or_twirling(struct MarioState *m);
|
||||
void update_flying_yaw(struct MarioState *m);
|
||||
void update_flying_pitch(struct MarioState *m);
|
||||
void update_flying(struct MarioState *m);
|
||||
u32 common_air_action_step(struct MarioState *m, u32 landAction, s32 animation, u32 stepArg);
|
||||
s32 act_jump(struct MarioState *m);
|
||||
s32 act_double_jump(struct MarioState *m);
|
||||
s32 act_triple_jump(struct MarioState *m);
|
||||
s32 act_backflip(struct MarioState *m);
|
||||
s32 act_freefall(struct MarioState *m);
|
||||
s32 act_hold_jump(struct MarioState *m);
|
||||
s32 act_hold_freefall(struct MarioState *m);
|
||||
s32 act_side_flip(struct MarioState *m);
|
||||
s32 act_wall_kick_air(struct MarioState *m);
|
||||
s32 act_long_jump(struct MarioState *m);
|
||||
s32 act_riding_shell_air(struct MarioState *m);
|
||||
s32 act_twirling(struct MarioState *m);
|
||||
s32 act_dive(struct MarioState *m);
|
||||
s32 act_air_throw(struct MarioState *m);
|
||||
s32 act_water_jump(struct MarioState *m);
|
||||
s32 act_hold_water_jump(struct MarioState *m);
|
||||
s32 act_steep_jump(struct MarioState *m);
|
||||
s32 act_ground_pound(struct MarioState *m);
|
||||
s32 act_burning_jump(struct MarioState *m);
|
||||
s32 act_burning_fall(struct MarioState *m);
|
||||
s32 act_crazy_box_bounce(struct MarioState *m);
|
||||
u32 common_air_knockback_step(struct MarioState *m, u32 landAction, u32 hardFallAction, s32 animation, f32 speed);
|
||||
s32 check_wall_kick(struct MarioState *m);
|
||||
s32 act_backward_air_kb(struct MarioState *m);
|
||||
s32 act_forward_air_kb(struct MarioState *m);
|
||||
s32 act_hard_backward_air_kb(struct MarioState *m);
|
||||
s32 act_hard_forward_air_kb(struct MarioState *m);
|
||||
s32 act_thrown_backward(struct MarioState *m);
|
||||
s32 act_thrown_forward(struct MarioState *m);
|
||||
s32 act_soft_bonk(struct MarioState *m);
|
||||
s32 act_getting_blown(struct MarioState *m);
|
||||
s32 act_air_hit_wall(struct MarioState *m);
|
||||
s32 act_forward_rollout(struct MarioState *m);
|
||||
s32 act_backward_rollout(struct MarioState *m);
|
||||
s32 act_butt_slide_air(struct MarioState *m);
|
||||
s32 act_hold_butt_slide_air(struct MarioState *m);
|
||||
s32 act_lava_boost(struct MarioState *m);
|
||||
s32 act_slide_kick(struct MarioState *m);
|
||||
s32 act_jump_kick(struct MarioState *m);
|
||||
s32 act_shot_from_cannon(struct MarioState *m);
|
||||
s32 act_flying(struct MarioState *m);
|
||||
s32 act_riding_hoot(struct MarioState *m);
|
||||
s32 act_flying_triple_jump(struct MarioState *m);
|
||||
s32 act_top_of_pole_jump(struct MarioState *m);
|
||||
s32 act_vertical_wind(struct MarioState *m);
|
||||
s32 act_special_triple_jump(struct MarioState *m);
|
||||
s32 check_common_airborne_cancels(struct MarioState *m);
|
||||
s32 mario_execute_airborne_action(struct MarioState *m);
|
29
autogen/lua_functions/mario_actions_automatic.c
Normal file
29
autogen/lua_functions/mario_actions_automatic.c
Normal file
|
@ -0,0 +1,29 @@
|
|||
void add_tree_leaf_particles(struct MarioState *m);
|
||||
void play_climbing_sounds(struct MarioState *m, s32 b);
|
||||
s32 set_pole_position(struct MarioState *m, f32 offsetY);
|
||||
s32 act_holding_pole(struct MarioState *m);
|
||||
s32 act_climbing_pole(struct MarioState *m);
|
||||
s32 act_grab_pole_slow(struct MarioState *m);
|
||||
s32 act_grab_pole_fast(struct MarioState *m);
|
||||
s32 act_top_of_pole_transition(struct MarioState *m);
|
||||
s32 act_top_of_pole(struct MarioState *m);
|
||||
s32 perform_hanging_step(struct MarioState *m, Vec3f nextPos);
|
||||
s32 update_hang_moving(struct MarioState *m);
|
||||
void update_hang_stationary(struct MarioState *m);
|
||||
s32 act_start_hanging(struct MarioState *m);
|
||||
s32 act_hanging(struct MarioState *m);
|
||||
s32 act_hang_moving(struct MarioState *m);
|
||||
s32 let_go_of_ledge(struct MarioState *m);
|
||||
void climb_up_ledge(struct MarioState *m);
|
||||
void update_ledge_climb_camera(struct MarioState *m);
|
||||
void update_ledge_climb(struct MarioState *m, s32 animation, u32 endAction);
|
||||
s32 act_ledge_grab(struct MarioState *m);
|
||||
s32 act_ledge_climb_slow(struct MarioState *m);
|
||||
s32 act_ledge_climb_down(struct MarioState *m);
|
||||
s32 act_ledge_climb_fast(struct MarioState *m);
|
||||
s32 act_grabbed(struct MarioState *m);
|
||||
s32 act_in_cannon(struct MarioState *m);
|
||||
s32 act_tornado_twirling(struct MarioState *m);
|
||||
s32 act_bubbled(struct MarioState* m);
|
||||
s32 check_common_automatic_cancels(struct MarioState *m);
|
||||
s32 mario_execute_automatic_action(struct MarioState *m);
|
11
autogen/lua_functions/mario_actions_cutscene.c
Normal file
11
autogen/lua_functions/mario_actions_cutscene.c
Normal file
|
@ -0,0 +1,11 @@
|
|||
void print_displaying_credits_entry(void);
|
||||
void bhv_end_peach_loop(void);
|
||||
void bhv_end_toad_loop(void);
|
||||
void handle_save_menu(struct MarioState *m);
|
||||
struct Object *spawn_obj_at_mario_rel_yaw(struct MarioState *m, s32 model, BehaviorScript *behavior, s16 relYaw);
|
||||
void cutscene_take_cap_off(struct MarioState *m);
|
||||
void cutscene_put_cap_on(struct MarioState *m);
|
||||
u8 should_start_or_continue_dialog(struct MarioState* m, struct Object* object);
|
||||
void general_star_dance_handler(struct MarioState *m, s32 isInWater);
|
||||
void stuck_in_ground_handler(struct MarioState *m, s32 animation, s32 unstuckFrame, s32 target2, s32 target3, s32 endAction);
|
||||
void generate_yellow_sparkles(s16 x, s16 y, s16 z, f32 radius);
|
34
autogen/lua_functions/mario_actions_moving.c
Normal file
34
autogen/lua_functions/mario_actions_moving.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
s16 tilt_body_running(struct MarioState *m);
|
||||
void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2);
|
||||
void align_with_floor(struct MarioState *m);
|
||||
s32 begin_walking_action(struct MarioState *m, f32 forwardVel, u32 action, u32 actionArg);
|
||||
void check_ledge_climb_down(struct MarioState *m);
|
||||
void slide_bonk(struct MarioState *m, u32 fastAction, u32 slowAction);
|
||||
s32 set_triple_jump_action(struct MarioState *m, UNUSED u32 action, UNUSED u32 actionArg);
|
||||
void update_sliding_angle(struct MarioState *m, f32 accel, f32 lossFactor);
|
||||
s32 update_sliding(struct MarioState *m, f32 stopSpeed);
|
||||
void apply_slope_accel(struct MarioState *m);
|
||||
s32 apply_landing_accel(struct MarioState *m, f32 frictionFactor);
|
||||
void update_shell_speed(struct MarioState *m);
|
||||
s32 apply_slope_decel(struct MarioState *m, f32 decelCoef);
|
||||
s32 update_decelerating_speed(struct MarioState *m);
|
||||
void update_walking_speed(struct MarioState *m);
|
||||
s32 should_begin_sliding(struct MarioState *m);
|
||||
s32 analog_stick_held_back(struct MarioState *m);
|
||||
s32 check_ground_dive_or_punch(struct MarioState *m);
|
||||
s32 begin_braking_action(struct MarioState *m);
|
||||
void anim_and_audio_for_walk(struct MarioState *m);
|
||||
void anim_and_audio_for_hold_walk(struct MarioState *m);
|
||||
void anim_and_audio_for_heavy_walk(struct MarioState *m);
|
||||
void push_or_sidle_wall(struct MarioState *m, Vec3f startPos);
|
||||
void tilt_body_walking(struct MarioState *m, s16 startYaw);
|
||||
void tilt_body_ground_shell(struct MarioState *m, s16 startYaw);
|
||||
void tilt_body_butt_slide(struct MarioState *m);
|
||||
void common_slide_action(struct MarioState *m, u32 endAction, u32 airAction, s32 animation);
|
||||
s32 common_slide_action_with_jump(struct MarioState *m, u32 stopAction, u32 jumpAction, u32 airAction, s32 animation);
|
||||
s32 stomach_slide_action(struct MarioState *m, u32 stopAction, u32 airAction, s32 animation);
|
||||
s32 common_ground_knockback_action(struct MarioState *m, s32 animation, s32 arg2, s32 arg3, s32 arg4);
|
||||
u32 common_landing_action(struct MarioState *m, s16 animation, u32 airAction);
|
||||
s32 quicksand_jump_land_action(struct MarioState *m, s32 animation1, s32 animation2, u32 endAction, u32 airAction);
|
||||
s32 check_common_moving_cancels(struct MarioState *m);
|
||||
s32 mario_execute_moving_action(struct MarioState *m);
|
4
autogen/lua_functions/mario_actions_object.c
Normal file
4
autogen/lua_functions/mario_actions_object.c
Normal file
|
@ -0,0 +1,4 @@
|
|||
void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 endAction);
|
||||
s32 mario_update_punch_sequence(struct MarioState *m);
|
||||
s32 check_common_object_cancels(struct MarioState *m);
|
||||
s32 mario_execute_object_action(struct MarioState *m);
|
8
autogen/lua_functions/mario_actions_stationary.c
Normal file
8
autogen/lua_functions/mario_actions_stationary.c
Normal file
|
@ -0,0 +1,8 @@
|
|||
s32 check_common_idle_cancels(struct MarioState *m);
|
||||
s32 check_common_hold_idle_cancels(struct MarioState *m);
|
||||
void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound);
|
||||
void stopping_step(struct MarioState *m, s32 animID, u32 action);
|
||||
s32 landing_step(struct MarioState *m, s32 arg1, u32 action);
|
||||
s32 check_common_landing_cancels(struct MarioState *m, u32 action);
|
||||
s32 check_common_stationary_cancels(struct MarioState *m);
|
||||
s32 mario_execute_stationary_action(struct MarioState *m);
|
1
autogen/lua_functions/mario_actions_submerged.c
Normal file
1
autogen/lua_functions/mario_actions_submerged.c
Normal file
|
@ -0,0 +1 @@
|
|||
s32 mario_execute_submerged_action(struct MarioState *m);
|
11
autogen/lua_functions/mario_step.h
Normal file
11
autogen/lua_functions/mario_step.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
f32 get_additive_y_vel_for_jumps(void);
|
||||
void mario_bonk_reflection(struct MarioState *, u32);
|
||||
u32 mario_update_quicksand(struct MarioState *, f32);
|
||||
u32 mario_push_off_steep_floor(struct MarioState *, u32, u32);
|
||||
u32 mario_update_moving_sand(struct MarioState *);
|
||||
u32 mario_update_windy_ground(struct MarioState *);
|
||||
void stop_and_set_height_to_floor(struct MarioState *);
|
||||
s32 stationary_ground_step(struct MarioState *);
|
||||
s32 perform_ground_step(struct MarioState *);
|
||||
s32 perform_air_step(struct MarioState *, u32);
|
||||
void set_vel_from_pitch_and_yaw(struct MarioState* m);
|
|
@ -254,12 +254,12 @@ end
|
|||
function act_ground_pound_jump(m)
|
||||
local e = gMarioStateExtras[m.playerIndex]
|
||||
if check_kick_or_dive_in_air(m) ~= 0 then
|
||||
-- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle
|
||||
m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle
|
||||
return 1
|
||||
end
|
||||
|
||||
if (m.input & INPUT_Z_PRESSED) ~= 0 then
|
||||
-- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle
|
||||
m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle
|
||||
return set_mario_action(m, ACT_GROUND_POUND, 0)
|
||||
end
|
||||
|
||||
|
@ -280,7 +280,7 @@ function act_ground_pound_jump(m)
|
|||
AIR_STEP_CHECK_LEDGE_GRAB | AIR_STEP_CHECK_HANG)
|
||||
|
||||
e.rotAngle = e.rotAngle + (0x10000*1.0 - e.rotAngle) / 5.0
|
||||
-- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y - e.rotAngle
|
||||
m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y - e.rotAngle
|
||||
|
||||
m.actionTimer = m.actionTimer + 1
|
||||
|
||||
|
@ -478,12 +478,12 @@ function act_spin_jump(m)
|
|||
e.rotAngle = e.rotAngle + 0x2867
|
||||
if (e.rotAngle > 0x10000) then e.rotAngle = e.rotAngle - 0x10000 end
|
||||
if (e.rotAngle < -0x10000) then e.rotAngle = e.rotAngle + 0x10000 end
|
||||
-- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + (s16) (e.rotAngle * spinDirFactor)
|
||||
m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + (e.rotAngle * spinDirFactor)
|
||||
|
||||
-- gravity
|
||||
m.vel.y = m.vel.y + 2
|
||||
if (m.flags & MARIO_WING_CAP) ~= 0 and m.vel.y < 0.0 and (m.input & INPUT_A_DOWN) ~= 0 then
|
||||
-- TODO: m.marioBodyState.wingFlutter = 1
|
||||
m.marioBodyState.wingFlutter = 1
|
||||
m.vel.y = m.vel.y - 0.7
|
||||
if m.vel.y < -37.5 then
|
||||
m.vel.y = m.vel.y + 1.4
|
||||
|
@ -553,7 +553,7 @@ function act_spin_pound(m)
|
|||
e.rotAngle = e.rotAngle + 0x3053
|
||||
if e.rotAngle > 0x10000 then e.rotAngle = e.rotAngle - 0x10000 end
|
||||
if e.rotAngle < -0x10000 then e.rotAngle = e.rotAngle + 0x10000 end
|
||||
-- TODO: m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle * spinDirFactor
|
||||
m.marioObj.header.gfx.angle.y = m.marioObj.header.gfx.angle.y + e.rotAngle * spinDirFactor
|
||||
|
||||
m.actionTimer = m.actionTimer + 1
|
||||
|
||||
|
|
|
@ -176,6 +176,7 @@ void smlua_init(void) {
|
|||
|
||||
smlua_bind_cobject();
|
||||
smlua_bind_functions();
|
||||
smlua_bind_functions_autogen();
|
||||
|
||||
smlua_execfile("mods/constants.lua");
|
||||
smlua_init_mario_states();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "smlua_cobject.h"
|
||||
#include "smlua_utils.h"
|
||||
#include "smlua_functions.h"
|
||||
#include "smlua_functions_autogen.h"
|
||||
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
|
|
|
@ -14,9 +14,8 @@ enum LuaValueType {
|
|||
LVT_S16,
|
||||
LVT_S32,
|
||||
LVT_F32,
|
||||
LVT_VEC3S,
|
||||
LVT_VEC3F,
|
||||
LVT_CONTROLLER,
|
||||
LVT_COBJECT,
|
||||
LVT_COBJECT_P,
|
||||
};
|
||||
|
||||
struct LuaObjectField {
|
||||
|
@ -24,93 +23,94 @@ struct LuaObjectField {
|
|||
enum LuaValueType valueType;
|
||||
size_t valueOffset;
|
||||
bool immutable;
|
||||
enum LuaObjectType lot;
|
||||
};
|
||||
|
||||
#define LUA_VEC3S_FIELD_COUNT 3
|
||||
static struct LuaObjectField sVec3sFields[LUA_VEC3S_FIELD_COUNT] = {
|
||||
{ "x", LVT_S16, sizeof(s16) * 0, false },
|
||||
{ "y", LVT_S16, sizeof(s16) * 1, false },
|
||||
{ "z", LVT_S16, sizeof(s16) * 2, false },
|
||||
{ "x", LVT_S16, sizeof(s16) * 0, false, LOT_NONE },
|
||||
{ "y", LVT_S16, sizeof(s16) * 1, false, LOT_NONE },
|
||||
{ "z", LVT_S16, sizeof(s16) * 2, false, LOT_NONE },
|
||||
};
|
||||
|
||||
#define LUA_VEC3F_FIELD_COUNT 3
|
||||
static struct LuaObjectField sVec3fFields[LUA_VEC3F_FIELD_COUNT] = {
|
||||
{ "x", LVT_F32, sizeof(f32) * 0, false },
|
||||
{ "y", LVT_F32, sizeof(f32) * 1, false },
|
||||
{ "z", LVT_F32, sizeof(f32) * 2, false },
|
||||
{ "x", LVT_F32, sizeof(f32) * 0, false, LOT_NONE },
|
||||
{ "y", LVT_F32, sizeof(f32) * 1, false, LOT_NONE },
|
||||
{ "z", LVT_F32, sizeof(f32) * 2, false, LOT_NONE },
|
||||
};
|
||||
|
||||
#define LUA_MARIO_STATE_FIELD_COUNT 56
|
||||
#define LUA_MARIO_STATE_FIELD_COUNT 62
|
||||
static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
|
||||
{ "playerIndex", LVT_U16, offsetof(struct MarioState, playerIndex) , true },
|
||||
{ "input", LVT_U16, offsetof(struct MarioState, input) , false },
|
||||
{ "flags", LVT_U32, offsetof(struct MarioState, flags) , false },
|
||||
{ "particleFlags", LVT_U32, offsetof(struct MarioState, particleFlags) , false },
|
||||
{ "action", LVT_U32, offsetof(struct MarioState, action) , false },
|
||||
{ "prevAction", LVT_U32, offsetof(struct MarioState, prevAction) , false },
|
||||
{ "terrainSoundAddend", LVT_U32, offsetof(struct MarioState, terrainSoundAddend) , false },
|
||||
{ "actionState", LVT_U16, offsetof(struct MarioState, actionState) , false },
|
||||
{ "actionTimer", LVT_U16, offsetof(struct MarioState, actionTimer) , false },
|
||||
{ "actionArg", LVT_U32, offsetof(struct MarioState, actionArg) , false },
|
||||
{ "intendedMag", LVT_F32, offsetof(struct MarioState, intendedMag) , false },
|
||||
{ "intendedYaw", LVT_S16, offsetof(struct MarioState, intendedYaw) , false },
|
||||
{ "invincTimer", LVT_S16, offsetof(struct MarioState, invincTimer) , false },
|
||||
{ "framesSinceA", LVT_U8, offsetof(struct MarioState, framesSinceA) , false },
|
||||
{ "framesSinceB", LVT_U8, offsetof(struct MarioState, framesSinceB) , false },
|
||||
{ "wallKickTimer", LVT_U8, offsetof(struct MarioState, wallKickTimer) , false },
|
||||
{ "doubleJumpTimer", LVT_U8, offsetof(struct MarioState, doubleJumpTimer) , false },
|
||||
{ "faceAngle", LVT_VEC3S, offsetof(struct MarioState, faceAngle) , true },
|
||||
{ "angleVel", LVT_VEC3S, offsetof(struct MarioState, angleVel) , true },
|
||||
{ "slideYaw", LVT_S16, offsetof(struct MarioState, slideYaw) , false },
|
||||
{ "twirlYaw", LVT_S16, offsetof(struct MarioState, twirlYaw) , false },
|
||||
{ "pos", LVT_VEC3F, offsetof(struct MarioState, pos) , true },
|
||||
{ "vel", LVT_VEC3F, offsetof(struct MarioState, vel) , true },
|
||||
{ "forwardVel", LVT_F32, offsetof(struct MarioState, forwardVel) , false },
|
||||
{ "slideVelX", LVT_F32, offsetof(struct MarioState, slideVelX) , false },
|
||||
{ "slideVelZ", LVT_F32, offsetof(struct MarioState, slideVelZ) , false },
|
||||
{ "ceilHeight", LVT_F32, offsetof(struct MarioState, ceilHeight) , false },
|
||||
{ "floorHeight", LVT_F32, offsetof(struct MarioState, floorHeight) , false },
|
||||
{ "floorAngle", LVT_S16, offsetof(struct MarioState, floorAngle) , false },
|
||||
{ "waterLevel", LVT_S16, offsetof(struct MarioState, waterLevel) , false },
|
||||
{ "controller", LVT_CONTROLLER, offsetof(struct MarioState, controller) , true },
|
||||
{ "collidedObjInteractTypes", LVT_U32, offsetof(struct MarioState, collidedObjInteractTypes), false },
|
||||
{ "numCoins", LVT_S16, offsetof(struct MarioState, numCoins) , false },
|
||||
{ "numStars", LVT_S16, offsetof(struct MarioState, numStars) , false },
|
||||
{ "mechani", LVT_S8, offsetof(struct MarioState, numKeys) , false },
|
||||
{ "numLives", LVT_S8, offsetof(struct MarioState, numLives) , false },
|
||||
{ "health", LVT_S16, offsetof(struct MarioState, health) , false },
|
||||
{ "unkB0", LVT_S16, offsetof(struct MarioState, unkB0) , false },
|
||||
{ "hurtCounter", LVT_U8, offsetof(struct MarioState, hurtCounter) , false },
|
||||
{ "healCounter", LVT_U8, offsetof(struct MarioState, healCounter) , false },
|
||||
{ "squishTimer", LVT_U8, offsetof(struct MarioState, squishTimer) , false },
|
||||
{ "fadeWarpOpacity", LVT_U8, offsetof(struct MarioState, fadeWarpOpacity) , false },
|
||||
{ "capTimer", LVT_U16, offsetof(struct MarioState, capTimer) , false },
|
||||
{ "prevNumStarsForDialog", LVT_S16, offsetof(struct MarioState, prevNumStarsForDialog) , false },
|
||||
{ "peakHeight", LVT_F32, offsetof(struct MarioState, peakHeight) , false },
|
||||
{ "quicksandDepth", LVT_F32, offsetof(struct MarioState, quicksandDepth) , false },
|
||||
{ "unkC4", LVT_F32, offsetof(struct MarioState, unkC4) , false },
|
||||
{ "currentRoom", LVT_S16, offsetof(struct MarioState, currentRoom) , false },
|
||||
{ "isSnoring", LVT_U8, offsetof(struct MarioState, isSnoring) , false },
|
||||
{ "freeze", LVT_U8, offsetof(struct MarioState, freeze) , false },
|
||||
{ "splineKeyframeFraction", LVT_F32, offsetof(struct MarioState, splineKeyframeFraction) , false },
|
||||
{ "splineState", LVT_S32, offsetof(struct MarioState, splineState) , false },
|
||||
{ "nonInstantWarpPos", LVT_VEC3F, offsetof(struct MarioState, nonInstantWarpPos) , true },
|
||||
{ "wasNetworkVisible", LVT_U8, offsetof(struct MarioState, wasNetworkVisible) , false },
|
||||
{ "minimumBoneY", LVT_F32, offsetof(struct MarioState, minimumBoneY) , false },
|
||||
{ "curAnimOffset", LVT_F32, offsetof(struct MarioState, curAnimOffset) , false },
|
||||
{ "playerIndex", LVT_U16, offsetof(struct MarioState, playerIndex), true, LOT_NONE },
|
||||
{ "input", LVT_U16, offsetof(struct MarioState, input), false, LOT_NONE },
|
||||
{ "flags", LVT_U32, offsetof(struct MarioState, flags), false, LOT_NONE },
|
||||
{ "particleFlags", LVT_U32, offsetof(struct MarioState, particleFlags), false, LOT_NONE },
|
||||
{ "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE },
|
||||
{ "prevAction", LVT_U32, offsetof(struct MarioState, prevAction), false, LOT_NONE },
|
||||
{ "terrainSoundAddend", LVT_U32, offsetof(struct MarioState, terrainSoundAddend), false, LOT_NONE },
|
||||
{ "actionState", LVT_U16, offsetof(struct MarioState, actionState), false, LOT_NONE },
|
||||
{ "actionTimer", LVT_U16, offsetof(struct MarioState, actionTimer), false, LOT_NONE },
|
||||
{ "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE },
|
||||
{ "intendedMag", LVT_F32, offsetof(struct MarioState, intendedMag), false, LOT_NONE },
|
||||
{ "intendedYaw", LVT_S16, offsetof(struct MarioState, intendedYaw), false, LOT_NONE },
|
||||
{ "invincTimer", LVT_S16, offsetof(struct MarioState, invincTimer), false, LOT_NONE },
|
||||
{ "framesSinceA", LVT_U8, offsetof(struct MarioState, framesSinceA), false, LOT_NONE },
|
||||
{ "framesSinceB", LVT_U8, offsetof(struct MarioState, framesSinceB), false, LOT_NONE },
|
||||
{ "wallKickTimer", LVT_U8, offsetof(struct MarioState, wallKickTimer), false, LOT_NONE },
|
||||
{ "doubleJumpTimer", LVT_U8, offsetof(struct MarioState, doubleJumpTimer), false, LOT_NONE },
|
||||
{ "faceAngle", LVT_COBJECT, offsetof(struct MarioState, faceAngle), true, LOT_VEC3S },
|
||||
{ "angleVel", LVT_COBJECT, offsetof(struct MarioState, angleVel), true, LOT_VEC3S },
|
||||
{ "slideYaw", LVT_S16, offsetof(struct MarioState, slideYaw), false, LOT_NONE },
|
||||
{ "twirlYaw", LVT_S16, offsetof(struct MarioState, twirlYaw), false, LOT_NONE },
|
||||
{ "pos", LVT_COBJECT, offsetof(struct MarioState, pos), true, LOT_VEC3F },
|
||||
{ "vel", LVT_COBJECT, offsetof(struct MarioState, vel), true, LOT_VEC3F },
|
||||
{ "forwardVel", LVT_F32, offsetof(struct MarioState, forwardVel), false, LOT_NONE },
|
||||
{ "slideVelX", LVT_F32, offsetof(struct MarioState, slideVelX), false, LOT_NONE },
|
||||
{ "slideVelZ", LVT_F32, offsetof(struct MarioState, slideVelZ), false, LOT_NONE },
|
||||
{ "ceilHeight", LVT_F32, offsetof(struct MarioState, ceilHeight), false, LOT_NONE },
|
||||
{ "floorHeight", LVT_F32, offsetof(struct MarioState, floorHeight), false, LOT_NONE },
|
||||
{ "floorAngle", LVT_S16, offsetof(struct MarioState, floorAngle), false, LOT_NONE },
|
||||
{ "waterLevel", LVT_S16, offsetof(struct MarioState, waterLevel), false, LOT_NONE },
|
||||
{ "interactObj", LVT_COBJECT_P, offsetof(struct MarioState, interactObj), false, LOT_OBJECT },
|
||||
{ "heldObj", LVT_COBJECT_P, offsetof(struct MarioState, heldObj), false, LOT_OBJECT },
|
||||
{ "usedObj", LVT_COBJECT_P, offsetof(struct MarioState, usedObj), false, LOT_OBJECT },
|
||||
{ "interactObj", LVT_COBJECT_P, offsetof(struct MarioState, interactObj), false, LOT_OBJECT },
|
||||
{ "marioObj", LVT_COBJECT_P, offsetof(struct MarioState, marioObj), true, LOT_OBJECT },
|
||||
{ "marioBodyState", LVT_COBJECT_P, offsetof(struct MarioState, marioBodyState), true, LOT_BODY_STATE },
|
||||
{ "controller", LVT_COBJECT_P, offsetof(struct MarioState, controller), true, LOT_CONTROLLER },
|
||||
{ "collidedObjInteractTypes", LVT_U32, offsetof(struct MarioState, collidedObjInteractTypes), false, LOT_NONE },
|
||||
{ "numCoins", LVT_S16, offsetof(struct MarioState, numCoins), false, LOT_NONE },
|
||||
{ "numStars", LVT_S16, offsetof(struct MarioState, numStars), false, LOT_NONE },
|
||||
{ "mechani", LVT_S8, offsetof(struct MarioState, numKeys), false, LOT_NONE },
|
||||
{ "numLives", LVT_S8, offsetof(struct MarioState, numLives), false, LOT_NONE },
|
||||
{ "health", LVT_S16, offsetof(struct MarioState, health), false, LOT_NONE },
|
||||
{ "unkB0", LVT_S16, offsetof(struct MarioState, unkB0), false, LOT_NONE },
|
||||
{ "hurtCounter", LVT_U8, offsetof(struct MarioState, hurtCounter), false, LOT_NONE },
|
||||
{ "healCounter", LVT_U8, offsetof(struct MarioState, healCounter), false, LOT_NONE },
|
||||
{ "squishTimer", LVT_U8, offsetof(struct MarioState, squishTimer), false, LOT_NONE },
|
||||
{ "fadeWarpOpacity", LVT_U8, offsetof(struct MarioState, fadeWarpOpacity), false, LOT_NONE },
|
||||
{ "capTimer", LVT_U16, offsetof(struct MarioState, capTimer), false, LOT_NONE },
|
||||
{ "prevNumStarsForDialog", LVT_S16, offsetof(struct MarioState, prevNumStarsForDialog), false, LOT_NONE },
|
||||
{ "peakHeight", LVT_F32, offsetof(struct MarioState, peakHeight), false, LOT_NONE },
|
||||
{ "quicksandDepth", LVT_F32, offsetof(struct MarioState, quicksandDepth), false, LOT_NONE },
|
||||
{ "unkC4", LVT_F32, offsetof(struct MarioState, unkC4), false, LOT_NONE },
|
||||
{ "currentRoom", LVT_S16, offsetof(struct MarioState, currentRoom), false, LOT_NONE },
|
||||
{ "isSnoring", LVT_U8, offsetof(struct MarioState, isSnoring), false, LOT_NONE },
|
||||
{ "freeze", LVT_U8, offsetof(struct MarioState, freeze), false, LOT_NONE },
|
||||
{ "splineKeyframeFraction", LVT_F32, offsetof(struct MarioState, splineKeyframeFraction), false, LOT_NONE },
|
||||
{ "splineState", LVT_S32, offsetof(struct MarioState, splineState), false, LOT_NONE },
|
||||
{ "nonInstantWarpPos", LVT_COBJECT, offsetof(struct MarioState, nonInstantWarpPos), true, LOT_VEC3F },
|
||||
{ "wasNetworkVisible", LVT_U8, offsetof(struct MarioState, wasNetworkVisible), false, LOT_NONE },
|
||||
{ "minimumBoneY", LVT_F32, offsetof(struct MarioState, minimumBoneY), false, LOT_NONE },
|
||||
{ "curAnimOffset", LVT_F32, offsetof(struct MarioState, curAnimOffset), false, LOT_NONE },
|
||||
/* TODO: implement
|
||||
struct Surface *wall;
|
||||
struct Surface *ceil;
|
||||
struct Surface *floor;
|
||||
struct Object *interactObj;
|
||||
struct Object *heldObj;
|
||||
struct Object *usedObj;
|
||||
struct Object *riddenObj;
|
||||
struct Object *marioObj;
|
||||
struct SpawnInfo *spawnInfo;
|
||||
struct Area *area;
|
||||
struct PlayerCameraState *statusForCamera;
|
||||
struct MarioBodyState *marioBodyState;
|
||||
struct MarioAnimation *animation;
|
||||
struct Object* heldByObj;
|
||||
struct Object* bubbleObj;
|
||||
|
@ -121,18 +121,98 @@ static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
|
|||
|
||||
#define LUA_CONTROLLER_FIELD_COUNT 10
|
||||
static struct LuaObjectField sControllerFields[LUA_CONTROLLER_FIELD_COUNT] = {
|
||||
{ "rawStickX", LVT_S16, offsetof(struct Controller, rawStickX), false },
|
||||
{ "rawStickY", LVT_S16, offsetof(struct Controller, rawStickY), false },
|
||||
{ "stickX", LVT_F32, offsetof(struct Controller, stickX), false },
|
||||
{ "stickY", LVT_F32, offsetof(struct Controller, stickY), false },
|
||||
{ "stickMag", LVT_F32, offsetof(struct Controller, stickMag), false },
|
||||
{ "buttonDown", LVT_U16, offsetof(struct Controller, buttonDown), false },
|
||||
{ "buttonPressed", LVT_U16, offsetof(struct Controller, buttonPressed), false },
|
||||
//{ "statusData", LVT_OSCONTSTATUS, offsetof(struct Controller, statusData), false },
|
||||
//{ "controllerData", LVT_OSCONTPAD, offsetof(struct Controller, controllerData), false },
|
||||
{ "port", LVT_S32, offsetof(struct Controller, port), false },
|
||||
{ "extStickX", LVT_S16, offsetof(struct Controller, extStickX), false },
|
||||
{ "extStickY", LVT_S16, offsetof(struct Controller, extStickY), false },
|
||||
{ "rawStickX", LVT_S16, offsetof(struct Controller, rawStickX), false, LOT_NONE },
|
||||
{ "rawStickY", LVT_S16, offsetof(struct Controller, rawStickY), false, LOT_NONE },
|
||||
{ "stickX", LVT_F32, offsetof(struct Controller, stickX), false, LOT_NONE },
|
||||
{ "stickY", LVT_F32, offsetof(struct Controller, stickY), false, LOT_NONE },
|
||||
{ "stickMag", LVT_F32, offsetof(struct Controller, stickMag), false, LOT_NONE },
|
||||
{ "buttonDown", LVT_U16, offsetof(struct Controller, buttonDown), false, LOT_NONE },
|
||||
{ "buttonPressed", LVT_U16, offsetof(struct Controller, buttonPressed), false, LOT_NONE },
|
||||
//{ "statusData", LVT_OSCONTSTATUS, offsetof(struct Controller, statusData), false, LOT_NONE },
|
||||
//{ "controllerData", LVT_OSCONTPAD, offsetof(struct Controller, controllerData), false, LOT_NONE },
|
||||
{ "port", LVT_S32, offsetof(struct Controller, port), false, LOT_NONE },
|
||||
{ "extStickX", LVT_S16, offsetof(struct Controller, extStickX), false, LOT_NONE },
|
||||
{ "extStickY", LVT_S16, offsetof(struct Controller, extStickY), false, LOT_NONE },
|
||||
};
|
||||
|
||||
#define LUA_BODY_STATE_FIELD_COUNT 11
|
||||
static struct LuaObjectField sMarioBodyStateFields[LUA_BODY_STATE_FIELD_COUNT] = {
|
||||
{ "action", LVT_U32, offsetof(struct MarioBodyState, action), false, LOT_NONE },
|
||||
{ "capState", LVT_S8, offsetof(struct MarioBodyState, capState), false, LOT_NONE },
|
||||
{ "eyeState", LVT_S8, offsetof(struct MarioBodyState, eyeState), false, LOT_NONE },
|
||||
{ "handState", LVT_S8, offsetof(struct MarioBodyState, handState), false, LOT_NONE },
|
||||
{ "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE },
|
||||
{ "modelState", LVT_S16, offsetof(struct MarioBodyState, modelState), false, LOT_NONE },
|
||||
{ "grabPos", LVT_S8, offsetof(struct MarioBodyState, grabPos), false, LOT_NONE },
|
||||
{ "punchState", LVT_U8, offsetof(struct MarioBodyState, punchState), false, LOT_NONE },
|
||||
{ "torsoAngle", LVT_COBJECT, offsetof(struct MarioBodyState, torsoAngle), true, LOT_VEC3S },
|
||||
{ "headAngle", LVT_COBJECT, offsetof(struct MarioBodyState, headAngle), true, LOT_VEC3S },
|
||||
{ "heldObjLastPosition", LVT_COBJECT, offsetof(struct MarioBodyState, heldObjLastPosition), true, LOT_VEC3S },
|
||||
};
|
||||
|
||||
#define LUA_OBJECT_FIELD_COUNT 16
|
||||
static struct LuaObjectField sObjectFields[LUA_OBJECT_FIELD_COUNT] = {
|
||||
{ "header", LVT_COBJECT, offsetof(struct Object, header), true, LOT_OBJECTNODE },
|
||||
{ "parentObj", LVT_COBJECT_P, offsetof(struct Object, parentObj), false, LOT_OBJECT },
|
||||
{ "prevObj", LVT_COBJECT_P, offsetof(struct Object, prevObj), false, LOT_OBJECT },
|
||||
{ "collidedObjInteractTypes", LVT_U32, offsetof(struct Object, collidedObjInteractTypes), false, LOT_NONE },
|
||||
{ "activeFlags", LVT_S16, offsetof(struct Object, activeFlags), false, LOT_NONE },
|
||||
{ "numCollidedObjs", LVT_S16, offsetof(struct Object, numCollidedObjs), false, LOT_NONE },
|
||||
{ "bhvStackIndex", LVT_U32, offsetof(struct Object, bhvStackIndex), false, LOT_NONE },
|
||||
{ "bhvDelayTimer", LVT_S16, offsetof(struct Object, bhvDelayTimer), false, LOT_NONE },
|
||||
{ "respawnInfoType", LVT_S16, offsetof(struct Object, respawnInfoType), false, LOT_NONE },
|
||||
{ "hitboxRadius", LVT_F32, offsetof(struct Object, hitboxRadius), false, LOT_NONE },
|
||||
{ "hitboxHeight", LVT_F32, offsetof(struct Object, hitboxHeight), false, LOT_NONE },
|
||||
{ "hurtboxRadius", LVT_F32, offsetof(struct Object, hurtboxRadius), false, LOT_NONE },
|
||||
{ "hurtboxHeight", LVT_F32, offsetof(struct Object, hurtboxHeight), false, LOT_NONE },
|
||||
{ "hitboxDownOffset", LVT_F32, offsetof(struct Object, hitboxDownOffset), false, LOT_NONE },
|
||||
{ "heldByPlayerIndex", LVT_U32, offsetof(struct Object, heldByPlayerIndex), false, LOT_NONE },
|
||||
{ "platform", LVT_COBJECT_P, offsetof(struct Object, platform), false, LOT_OBJECT },
|
||||
/* TODO: implement
|
||||
struct Object *collidedObjs[4]
|
||||
union rawData
|
||||
const BehaviorScript *curBhvCommand
|
||||
uintptr_t bhvStack[8]
|
||||
const BehaviorScript *behavior
|
||||
void *collisionData
|
||||
Mat4 transform
|
||||
void *respawnInfo
|
||||
*/
|
||||
};
|
||||
|
||||
#define LUA_OBJECTNODE_FIELD_COUNT 3
|
||||
static struct LuaObjectField sObjectNodeFields[LUA_OBJECTNODE_FIELD_COUNT] = {
|
||||
{ "gfx", LVT_COBJECT, offsetof(struct ObjectNode, gfx), true, LOT_GRAPHNODEOBJECT },
|
||||
{ "next", LVT_COBJECT_P, offsetof(struct ObjectNode, next), true, LOT_OBJECTNODE },
|
||||
{ "prev", LVT_COBJECT_P, offsetof(struct ObjectNode, prev), true, LOT_OBJECTNODE },
|
||||
};
|
||||
|
||||
#define LUA_GRAPHNODEOBJECT_FIELD_COUNT 13
|
||||
static struct LuaObjectField sGraphNodeObjectFields[LUA_GRAPHNODEOBJECT_FIELD_COUNT] = {
|
||||
{ "unk18", LVT_S8, offsetof(struct GraphNodeObject, unk18), false, LOT_NONE },
|
||||
{ "unk19", LVT_S8, offsetof(struct GraphNodeObject, unk19), false, LOT_NONE },
|
||||
{ "angle", LVT_COBJECT, offsetof(struct GraphNodeObject, angle), false, LOT_VEC3S },
|
||||
{ "pos", LVT_COBJECT, offsetof(struct GraphNodeObject, pos), false, LOT_VEC3F },
|
||||
{ "prevAngle", LVT_COBJECT, offsetof(struct GraphNodeObject, prevAngle), false, LOT_VEC3S },
|
||||
{ "prevPos", LVT_COBJECT, offsetof(struct GraphNodeObject, prevPos), false, LOT_VEC3F },
|
||||
{ "prevTimestamp", LVT_U32, offsetof(struct GraphNodeObject, prevTimestamp), false, LOT_NONE },
|
||||
{ "prevShadowPos", LVT_COBJECT, offsetof(struct GraphNodeObject, prevShadowPos), false, LOT_VEC3F },
|
||||
{ "prevShadowPosTimestamp", LVT_U32, offsetof(struct GraphNodeObject, prevShadowPosTimestamp), false, LOT_NONE },
|
||||
{ "scale", LVT_COBJECT, offsetof(struct GraphNodeObject, scale), false, LOT_VEC3F },
|
||||
{ "prevScale", LVT_COBJECT, offsetof(struct GraphNodeObject, prevScale), false, LOT_VEC3F },
|
||||
{ "prevScaleTimestamp", LVT_U32, offsetof(struct GraphNodeObject, prevScaleTimestamp), false, LOT_NONE },
|
||||
{ "cameraToObject", LVT_COBJECT, offsetof(struct GraphNodeObject, cameraToObject), false, LOT_VEC3F },
|
||||
/* unimplemented
|
||||
struct GraphNode node;
|
||||
struct GraphNode *sharedChild;
|
||||
struct GraphNodeObject_sub unk38;
|
||||
struct SpawnInfo *unk4C;
|
||||
Mat4 *throwMatrix;
|
||||
Mat4 prevThrowMatrix;
|
||||
u32 prevThrowMatrixTimestamp;
|
||||
Mat4 *throwMatrixInterpolated;
|
||||
u32 skipInterpolationTimestamp;
|
||||
*/
|
||||
};
|
||||
|
||||
struct LuaObjectTable {
|
||||
|
@ -142,10 +222,15 @@ struct LuaObjectTable {
|
|||
};
|
||||
|
||||
struct LuaObjectTable sLuaObjectTable[LOT_MAX] = {
|
||||
{ LOT_VEC3S, sVec3sFields, LUA_VEC3S_FIELD_COUNT },
|
||||
{ LOT_VEC3F, sVec3fFields, LUA_VEC3F_FIELD_COUNT },
|
||||
{ LOT_MARIO_STATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT },
|
||||
{ LOT_CONTROLLER, sControllerFields, LUA_CONTROLLER_FIELD_COUNT },
|
||||
{ LOT_NONE, NULL, 0 },
|
||||
{ LOT_VEC3S, sVec3sFields, LUA_VEC3S_FIELD_COUNT },
|
||||
{ LOT_VEC3F, sVec3fFields, LUA_VEC3F_FIELD_COUNT },
|
||||
{ LOT_MARIO_STATE, sMarioStateFields, LUA_MARIO_STATE_FIELD_COUNT },
|
||||
{ LOT_CONTROLLER, sControllerFields, LUA_CONTROLLER_FIELD_COUNT },
|
||||
{ LOT_BODY_STATE, sMarioBodyStateFields, LUA_BODY_STATE_FIELD_COUNT },
|
||||
{ LOT_OBJECT, sObjectFields, LUA_OBJECT_FIELD_COUNT },
|
||||
{ LOT_OBJECTNODE, sObjectNodeFields, LUA_OBJECTNODE_FIELD_COUNT },
|
||||
{ LOT_GRAPHNODEOBJECT, sGraphNodeObjectFields, LUA_GRAPHNODEOBJECT_FIELD_COUNT },
|
||||
};
|
||||
|
||||
static struct LuaObjectField* smlua_get_object_field(struct LuaObjectTable* ot, const char* key) {
|
||||
|
@ -175,22 +260,21 @@ static int smlua__get_field(lua_State* L) {
|
|||
|
||||
struct LuaObjectField* data = smlua_get_object_field(&sLuaObjectTable[lot], key);
|
||||
if (data == NULL) {
|
||||
LOG_LUA("_get_field on invalid key '%s'", key);
|
||||
LOG_LUA("_get_field on invalid key '%s', lot '%d'", key, lot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8* p = ((u8*)pointer) + data->valueOffset;
|
||||
switch (data->valueType) {
|
||||
case LVT_U8: lua_pushinteger(L, *(u8* )p); break;
|
||||
case LVT_U16: lua_pushinteger(L, *(u16*)p); break;
|
||||
case LVT_U32: lua_pushinteger(L, *(u32*)p); break;
|
||||
case LVT_S8: lua_pushinteger(L, *(s8* )p); break;
|
||||
case LVT_S16: lua_pushinteger(L, *(s16*)p); break;
|
||||
case LVT_S32: lua_pushinteger(L, *(s32*)p); break;
|
||||
case LVT_F32: lua_pushnumber( L, *(f32*)p); break;
|
||||
case LVT_VEC3S: smlua_push_object(L, LOT_VEC3S, p); break;
|
||||
case LVT_VEC3F: smlua_push_object(L, LOT_VEC3F, p); break;
|
||||
case LVT_CONTROLLER: smlua_push_object(L, LOT_CONTROLLER, *(struct Controller**)p); break;
|
||||
case LVT_U8: lua_pushinteger(L, *(u8* )p); break;
|
||||
case LVT_U16: lua_pushinteger(L, *(u16*)p); break;
|
||||
case LVT_U32: lua_pushinteger(L, *(u32*)p); break;
|
||||
case LVT_S8: lua_pushinteger(L, *(s8* )p); break;
|
||||
case LVT_S16: lua_pushinteger(L, *(s16*)p); break;
|
||||
case LVT_S32: lua_pushinteger(L, *(s32*)p); break;
|
||||
case LVT_F32: lua_pushnumber( L, *(f32*)p); break;
|
||||
case LVT_COBJECT: smlua_push_object(L, data->lot, p); break;
|
||||
case LVT_COBJECT_P: smlua_push_object(L, data->lot, *(u8**)p); break;
|
||||
default:
|
||||
LOG_LUA("_get_field on unimplemented type '%d', key '%s'", data->valueType, key);
|
||||
return 0;
|
||||
|
@ -205,39 +289,43 @@ static int smlua__set_field(lua_State* L) {
|
|||
const char* key = lua_tostring(L, -2);
|
||||
|
||||
if (pointer == 0) {
|
||||
LOG_LUA("_get_field on null pointer");
|
||||
LOG_LUA("_set_field on null pointer");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lot >= LOT_MAX) {
|
||||
LOG_LUA("_get_field on invalid LOT '%u'", lot);
|
||||
LOG_LUA("_set_field on invalid LOT '%u'", lot);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct LuaObjectField* data = smlua_get_object_field(&sLuaObjectTable[lot], key);
|
||||
if (data == NULL) {
|
||||
LOG_LUA("_get_field on invalid key '%s'", key);
|
||||
LOG_LUA("_set_field on invalid key '%s'", key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (data->immutable) {
|
||||
LOG_LUA("_get_field on immutable key '%s'", key);
|
||||
LOG_LUA("_set_field on immutable key '%s'", key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8* p = ((u8*)pointer) + data->valueOffset;
|
||||
switch (data->valueType) {
|
||||
case LVT_U8: *(u8*) p = lua_tointeger(L, -1); break;
|
||||
case LVT_U16: *(u16*)p = lua_tointeger(L, -1); break;
|
||||
case LVT_U32: *(u32*)p = lua_tointeger(L, -1); break;
|
||||
case LVT_S8: *(s8*) p = lua_tointeger(L, -1); break;
|
||||
case LVT_S16: *(s16*)p = lua_tointeger(L, -1); break;
|
||||
case LVT_S32: *(s32*)p = lua_tointeger(L, -1); break;
|
||||
case LVT_F32: *(f32*)p = lua_tonumber(L, -1); break;
|
||||
case LVT_U8: *(u8*) p = smlua_to_integer(L, -1); break;
|
||||
case LVT_U16: *(u16*)p = smlua_to_integer(L, -1); break;
|
||||
case LVT_U32: *(u32*)p = smlua_to_integer(L, -1); break;
|
||||
case LVT_S8: *(s8*) p = smlua_to_integer(L, -1); break;
|
||||
case LVT_S16: *(s16*)p = smlua_to_integer(L, -1); break;
|
||||
case LVT_S32: *(s32*)p = smlua_to_integer(L, -1); break;
|
||||
case LVT_F32: *(f32*)p = smlua_to_number(L, -1); break;
|
||||
default:
|
||||
LOG_LUA("_get_field on unimplemented type '%d', key '%s'", data->valueType, key);
|
||||
LOG_LUA("_set_field on unimplemented type '%d', key '%s'", data->valueType, key);
|
||||
return 0;
|
||||
}
|
||||
if (!gSmLuaConvertSuccess) {
|
||||
LOG_LUA("_set_field failed to retrieve value type '%d', key '%s'", data->valueType, key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -2,10 +2,15 @@
|
|||
#define SMLUA_COBJECT_H
|
||||
|
||||
enum LuaObjectType {
|
||||
LOT_NONE,
|
||||
LOT_VEC3S,
|
||||
LOT_VEC3F,
|
||||
LOT_MARIO_STATE,
|
||||
LOT_CONTROLLER,
|
||||
LOT_BODY_STATE,
|
||||
LOT_OBJECT,
|
||||
LOT_OBJECTNODE,
|
||||
LOT_GRAPHNODEOBJECT,
|
||||
LOT_MAX,
|
||||
};
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
2360
src/pc/lua/smlua_functions_autogen.c
Normal file
2360
src/pc/lua/smlua_functions_autogen.c
Normal file
File diff suppressed because it is too large
Load diff
6
src/pc/lua/smlua_functions_autogen.h
Normal file
6
src/pc/lua/smlua_functions_autogen.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef SMLUA_FUNCTIONS_AUTOGEN_H
|
||||
#define SMLUA_FUNCTIONS_AUTOGEN_H
|
||||
|
||||
void smlua_bind_functions_autogen(void);
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue