豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Commit e9e4123

Browse files
committed
Merge branch 'android-dev' into android
2 parents 193d500 + 5badf39 commit e9e4123

File tree

228 files changed

+16353
-11468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+16353
-11468
lines changed

.github/workflows/build-coop.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
jobs:
99
build-linux:
1010
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]') }}
11-
runs-on: ubuntu-latest
11+
runs-on: ubuntu-22.04
1212
steps:
1313
- name: Checkout repository
1414
uses: actions/checkout@v4
@@ -40,7 +40,7 @@ jobs:
4040

4141
build-steamos:
4242
if: ${{ github.event_name == 'workflow_dispatch' || contains(github.event.head_commit.message, '[build]') }}
43-
runs-on: ubuntu-latest
43+
runs-on: ubuntu-22.04
4444
steps:
4545
- name: Checkout repository
4646
uses: actions/checkout@v4

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ endif
285285
# Including an option to disable it.
286286

287287
# Level 0 produces no debug information at all. Thus, -g0 negates -g.
288-
# Level 1 produces minimal information, enough for making backtraces in parts of the program that you dont plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.
288+
# Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. This includes descriptions of functions and external variables, and line number tables, but no information about local variables.
289289
# Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macro expansion when you use -g3.
290290
# From https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
291291
ifeq ($(DEBUG_INFO_LEVEL),3)

autogen/autogen.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env bash
2+
python3 ./autogen/gen_math.py $1
23
python3 ./autogen/convert_structs.py $1
34
python3 ./autogen/convert_functions.py $1
45
python3 ./autogen/convert_constants.py $1

autogen/common.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
exclude_structs = [
2222
'SPTask',
2323
'VblankHandler',
24-
'GraphNodeRoot',
2524
'MarioAnimDmaRelatedThing',
2625
'UnusedArea28',
2726
]
@@ -234,7 +233,10 @@ def translate_type_to_lua(ptype):
234233
ptype = ptype.split(' ')[1].replace('*', '')
235234
return ptype, 'structs.md#%s' % ptype
236235

237-
if 'Vec3' in ptype:
236+
if ptype in VECP_TYPES:
237+
return VECP_TYPES[ptype], 'structs.md#%s' % VECP_TYPES[ptype]
238+
239+
if ptype in VEC_TYPES:
238240
return ptype, 'structs.md#%s' % ptype
239241

240242
if ptype.startswith('enum '):
@@ -268,7 +270,7 @@ def translate_type_to_lua(ptype):
268270

269271
if ptype.count('*') == 1 and '???' not in translate_type_to_lvt(ptype):
270272
ptype = ptype.replace('const', '').replace('*', '').strip()
271-
s = '`Pointer` <%s>' % translate_type_to_lua(ptype)[0]
273+
s = '`Pointer` <`%s`>' % translate_type_to_lua(ptype)[0].replace('`', '').strip()
272274
return s, None
273275

274276
if not ptype.startswith('`'):

autogen/convert_constants.py

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from common import *
22
from extract_constants import *
3+
from vec_types import *
34
import sys
45

56
in_filename = 'autogen/lua_constants/built-in.lua'
@@ -365,12 +366,30 @@ def build_files(processed_files):
365366

366367
return s
367368

369+
def build_vec_type_constant(type_name, vec_type, constant, values):
370+
txt = 'g%s%s = create_read_only_table({' % (type_name, constant)
371+
txt += ','.join([
372+
'%s=%s' % (lua_field, str(values[i]))
373+
for i, lua_field in enumerate(vec_type["fields_mapping"])
374+
])
375+
txt += '})'
376+
return txt
377+
368378
def build_to_c(built_files):
369379
txt = ''
380+
381+
# Built-in and deprecated
370382
for filename in [in_filename, deprecated_filename]:
371383
with open(get_path(filename), 'r') as f:
372384
for line in f.readlines():
373385
txt += line.strip() + '\n'
386+
387+
# Vec types constants
388+
for type_name, vec_type in VEC_TYPES.items():
389+
for constant, values in vec_type.get("constants", {}).items():
390+
txt += build_vec_type_constant(type_name, vec_type, constant, values) + '\n'
391+
392+
# Source files
374393
txt += '\n' + built_files
375394

376395
while ('\n\n' in txt):
@@ -505,6 +524,14 @@ def build_to_def(processed_files):
505524
s += f.read()
506525
s += '\n'
507526

527+
s += '\n\n-------------------------\n'
528+
s += '-- vec types constants --\n'
529+
s += '-------------------------\n\n'
530+
for type_name, vec_type in VEC_TYPES.items():
531+
for constant, values in vec_type.get("constants", {}).items():
532+
s += '--- @type %s\n' % (type_name)
533+
s += build_vec_type_constant(type_name, vec_type, constant, values) + '\n\n'
534+
508535
for file in processed_files:
509536
constants = file['constants']
510537
skip_constant = False
@@ -523,15 +550,15 @@ def main():
523550

524551
built_c = build_to_c(built_files)
525552

526-
with open(get_path(out_filename), 'w') as out:
553+
with open(get_path(out_filename), 'w', encoding='utf-8', newline='\n') as out:
527554
out.write(built_c)
528555

529556
doc = doc_files(processed_files)
530-
with open(get_path(out_filename_docs), 'w') as out:
557+
with open(get_path(out_filename_docs), 'w', encoding='utf-8', newline='\n') as out:
531558
out.write(doc)
532559

533560
defs = build_to_def(processed_files)
534-
with open(get_path(out_filename_defs), 'w') as out:
561+
with open(get_path(out_filename_defs), 'w', encoding='utf-8', newline='\n') as out:
535562
out.write(defs)
536563

537564
global totalConstants

autogen/convert_functions.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
in_files = [
1717
"src/audio/external.h",
1818
"src/engine/math_util.h",
19+
"src/engine/math_util.inl",
20+
"src/engine/math_util_vec3f.inl",
21+
"src/engine/math_util_vec3i.inl",
22+
"src/engine/math_util_vec3s.inl",
23+
"src/engine/math_util_mat4.inl",
1924
"src/engine/surface_collision.h",
2025
"src/engine/surface_load.h",
2126
"src/game/camera.h",
@@ -49,7 +54,6 @@
4954
"src/pc/lua/utils/smlua_camera_utils.h",
5055
"src/pc/lua/utils/smlua_gfx_utils.h",
5156
"src/pc/lua/utils/smlua_collision_utils.h",
52-
"src/pc/lua/utils/smlua_math_utils.h",
5357
"src/pc/lua/utils/smlua_model_utils.h",
5458
"src/pc/lua/utils/smlua_text_utils.h",
5559
"src/pc/lua/utils/smlua_audio_utils.h",
@@ -73,7 +77,8 @@
7377
"src/game/first_person_cam.h",
7478
"src/engine/behavior_script.h",
7579
"src/audio/seqplayer.h",
76-
"src/engine/lighting_engine.h"
80+
"src/engine/lighting_engine.h",
81+
"src/pc/network/sync_object.h"
7782
]
7883

7984
override_allowed_functions = {
@@ -91,12 +96,12 @@
9196
"src/game/area.h": [ "get_mario_spawn_type", "area_get_warp_node", "area_get_any_warp_node", "play_transition" ],
9297
"src/engine/level_script.h": [ "area_create_warp_node" ],
9398
"src/game/ingame_menu.h": [ "set_min_dialog_width", "set_dialog_override_pos", "reset_dialog_override_pos", "set_dialog_override_color", "reset_dialog_override_color", "set_menu_mode", "create_dialog_box", "create_dialog_box_with_var", "create_dialog_inverted_box", "create_dialog_box_with_response", "reset_dialog_render_state", "set_dialog_box_state", ],
94-
"src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ]
99+
"src/audio/seqplayer.h": [ "sequence_player_set_tempo", "sequence_player_set_tempo_acc", "sequence_player_set_transposition", "sequence_player_get_tempo", "sequence_player_get_tempo_acc", "sequence_player_get_transposition", "sequence_player_get_volume", "sequence_player_get_fade_volume", "sequence_player_get_mute_volume_scale" ],
100+
"src/pc/network/sync_object.h": [ "sync_object_is_initialized", "sync_object_is_owned_locally", "sync_object_get_object" ]
95101
}
96102

97103
override_disallowed_functions = {
98104
"src/audio/external.h": [ " func_" ],
99-
"src/engine/math_util.h": [ "atan2f", "vec3s_sub" ],
100105
"src/engine/surface_load.h": [ "load_area_terrain", "alloc_surface_pools", "clear_dynamic_surfaces", "get_area_terrain_size" ],
101106
"src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ],
102107
"src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ],
@@ -892,9 +897,7 @@ def build_param(fid, param, i):
892897
else:
893898
s = ' ' + s
894899

895-
sanity_check = ' if (lua_isnil(L, %d)) { return 0; }\n' % (i)
896-
897-
return sanity_check + s + '\n'
900+
return s + '\n'
898901

899902
def build_param_after(param, i):
900903
ptype = param['type']
@@ -918,6 +921,9 @@ def build_call(function):
918921
elif ftype == 'void *':
919922
return ' %s;\n' % ccall
920923

924+
if ftype in VECP_TYPES:
925+
return ' %s;\n' % ccall
926+
921927
flot = translate_type_to_lot(ftype)
922928

923929
lfunc = 'UNIMPLEMENTED -->'
@@ -991,6 +997,10 @@ def build_function(function, do_extern):
991997
i += 1
992998
s += '\n'
993999

1000+
# To allow chaining vector functions calls, return the table corresponding to `dest` parameter
1001+
if function['type'] in VECP_TYPES:
1002+
s += ' lua_settop(L, 1);\n'
1003+
9941004
s += ' return 1;\n}\n'
9951005

9961006
if fid in override_function_version_excludes:
@@ -1192,7 +1202,7 @@ def output_fuzz_file():
11921202
global fuzz_functions
11931203
with open(fuzz_from) as f:
11941204
file_str = f.read()
1195-
with open(fuzz_to, 'w') as f:
1205+
with open(fuzz_to, 'w', encoding='utf-8', newline='\n') as f:
11961206
f.write(file_str.replace('-- $[FUNCS]', fuzz_functions))
11971207

11981208
############################################################################
@@ -1381,7 +1391,7 @@ def doc_files(processed_files):
13811391

13821392
buffer = buffer.replace('$[FUNCTION_NAV_HERE', function_nav)
13831393

1384-
with open(get_path(out_filename_docs % page_name), 'w', newline='\n') as out:
1394+
with open(get_path(out_filename_docs % page_name), 'w', encoding='utf-8', newline='\n') as out:
13851395
out.write(buffer)
13861396

13871397
############################################################################
@@ -1439,7 +1449,10 @@ def def_files(processed_files):
14391449
for def_pointer in def_pointers:
14401450
s += '--- @alias %s %s\n' % (def_pointer, def_pointer[8:])
14411451

1442-
with open(get_path(out_filename_defs), 'w', newline='\n') as out:
1452+
for vecp_type, vec_type in VECP_TYPES.items():
1453+
s += '--- @alias %s %s\n' % (vecp_type, vec_type)
1454+
1455+
with open(get_path(out_filename_defs), 'w', encoding='utf-8', newline='\n') as out:
14431456
out.write(s)
14441457

14451458
############################################################################
@@ -1460,7 +1473,7 @@ def main():
14601473
.replace("$[BINDS]", built_binds) \
14611474
.replace("$[INCLUDES]", built_includes)
14621475

1463-
with open(filename, 'w', newline='\n') as out:
1476+
with open(filename, 'w', encoding='utf-8', newline='\n') as out:
14641477
out.write(gen)
14651478

14661479
if rejects != "":

autogen/convert_structs.py

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@
7070
#endif
7171
"""
7272

73-
override_field_names = {
74-
}
75-
7673
override_field_types = {
7774
"Surface": { "normal": "Vec3f" },
7875
"Object": { "oAnimations": "ObjectAnimPointer*" },
@@ -94,7 +91,8 @@
9491
"Mod": [ "files", "showedScriptWarning" ],
9592
"MarioState": [ "visibleToEnemies" ],
9693
"NetworkPlayer": [ "gag", "moderator", "discordId" ],
97-
"GraphNode": [ "_guard1", "_guard2" ],
94+
"GraphNode": [ "_guard1", "_guard2", "padding" ],
95+
"GraphNodeRoot": ["unk15", "views"],
9896
"FnGraphNode": [ "luaTokenIndex" ],
9997
"Object": [ "firstSurface" ],
10098
"ModAudio": [ "sound", "decoder", "buffer", "bufferSize", "sampleCopiesTail" ],
@@ -114,8 +112,8 @@
114112
"Object": ["oSyncID", "coopFlags", "oChainChompSegments", "oWigglerSegments", "oHauntedChairUnk100", "oTTCTreadmillBigSurface", "oTTCTreadmillSmallSurface", "bhvStackIndex", "respawnInfoType", "numSurfaces" ],
115113
"GlobalObjectAnimations": [ "*"],
116114
"SpawnParticlesInfo": [ "model" ],
117-
"MarioBodyState": [ "updateTorsoTime" ],
118-
"Area": [ "localAreaTimer", "nextSyncID", "unk04", "objectSpawnInfos", "paintingWarpNodes", "warpNodes" ],
115+
"MarioBodyState": [ "updateTorsoTime", "updateHeadPosTime", "animPartsPos", "currAnimPart" ],
116+
"Area": [ "localAreaTimer", "nextSyncID", "objectSpawnInfos", "paintingWarpNodes", "warpNodes" ],
119117
"Mod": [ "*" ],
120118
"ModFile": [ "*" ],
121119
"Painting": [ "id", "imageCount", "textureType", "textureWidth", "textureHeight" ],
@@ -129,6 +127,7 @@
129127
"GraphNodeObjectParent": [ "sharedChild" ],
130128
"GraphNodePerspective": [ "unused" ],
131129
"GraphNodeSwitchCase": [ "fnNode", "unused" ],
130+
"GraphNodeRoot": ["node", "areaIndex", "numViews"],
132131
"ObjectWarpNode": [ "next "],
133132
"Animation": [ "length" ],
134133
"AnimationTable": [ "count" ],
@@ -413,7 +412,7 @@ def output_fuzz_file():
413412
global fuzz_structs_calls
414413
with open(fuzz_from) as f:
415414
file_str = f.read()
416-
with open(fuzz_to, 'w') as f:
415+
with open(fuzz_to, 'w', encoding='utf-8', newline='\n') as f:
417416
f.write(file_str.replace('-- $[STRUCTS]', fuzz_structs).replace('-- $[FUZZ-STRUCTS]', fuzz_structs_calls))
418417

419418
############################################################################
@@ -461,9 +460,6 @@ def get_struct_field_info(struct, field):
461460
ftype = field['type']
462461
size = 1
463462

464-
if sid in override_field_names and fid in override_field_names[sid]:
465-
fid = override_field_names[sid][fid]
466-
467463
if sid in override_field_types and fid in override_field_types[sid]:
468464
ftype = override_field_types[sid][fid]
469465

@@ -727,7 +723,7 @@ def doc_structs(structs):
727723
continue
728724
s += doc_struct(struct) + '\n'
729725

730-
with open(get_path(out_filename_docs), 'w', newline='\n') as out:
726+
with open(get_path(out_filename_docs), 'w', encoding='utf-8', newline='\n') as out:
731727
out.write(s)
732728

733729
############################################################################
@@ -775,7 +771,7 @@ def def_structs(structs):
775771
for def_pointer in def_pointers:
776772
s += '--- @alias %s %s\n' % (def_pointer, def_pointer[8:])
777773

778-
with open(get_path(out_filename_defs), 'w', newline='\n') as out:
774+
with open(get_path(out_filename_defs), 'w', encoding='utf-8', newline='\n') as out:
779775
out.write(s)
780776

781777
############################################################################
@@ -797,11 +793,11 @@ def build_files():
797793
built_include = build_includes()
798794

799795
out_c_filename = get_path(out_filename_c)
800-
with open(out_c_filename, 'w', newline='\n') as out:
796+
with open(out_c_filename, 'w', encoding='utf-8', newline='\n') as out:
801797
out.write(c_template.replace("$[BODY]", built_body).replace('$[INCLUDES]', built_include))
802798

803799
out_h_filename = get_path(out_filename_h)
804-
with open(out_h_filename, 'w', newline='\n') as out:
800+
with open(out_h_filename, 'w', encoding='utf-8', newline='\n') as out:
805801
out.write(h_template.replace("$[BODY]", built_enum))
806802

807803
doc_structs(parsed)

autogen/extract_display_lists.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,17 @@
8181
def main():
8282
verbose = len(sys.argv) > 1 and (sys.argv[1] == "-v" or sys.argv[1] == "--verbose")
8383
pattern = re.compile(r"[\W]+")
84-
display_lists = []
84+
display_lists = set()
8585
for dir in DIRECTORIES:
86-
for root, _, filenames in os.walk(dir):
86+
for root, dirs, filenames in os.walk(dir):
87+
dirs.sort()
88+
filenames.sort()
8789
for filename in filenames:
8890
if filename[filename.rfind("."):] in FILE_EXTENSIONS:
8991
display_lists_in_file = []
9092
filepath = os.path.join(root, filename)
91-
lines = open(filepath, "r").readlines()
93+
with open(filepath, "r", encoding="utf-8", errors="ignore") as f:
94+
lines = f.readlines()
9295
ignore = False
9396
for line in lines:
9497
if ("#ifdef VERSION_EU" in line or
@@ -102,17 +105,17 @@ def main():
102105
index_gfx = identifiers.index("Gfx")
103106
name = identifiers[index_gfx + 1]
104107
if name not in display_lists:
105-
display_lists.append(name)
108+
display_lists.add(name)
106109
if verbose:
107110
display_lists_in_file.append(name)
108111
if verbose and display_lists_in_file:
109112
print("%s\n %s" % (filepath, "\n ".join(display_lists_in_file)))
110113

111114
# Add these manually because they are defined by a macro
112-
display_lists += CUSTOM_DEFINED
115+
display_lists.update(CUSTOM_DEFINED)
113116

114-
with open("include/display_lists.inl", "w") as f:
115-
for name in display_lists:
117+
with open("include/display_lists.inl", "w", encoding="utf-8", newline="\n") as f:
118+
for name in sorted(display_lists):
116119
f.write("DISPLAY_LIST(%s)\n" % (name))
117120

118121
print("Total display lists: %d" % (len(display_lists)))

autogen/extract_functions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
'BAD_RETURN(u64)': 'void',
1414
'BAD_RETURN(f32)': 'void',
1515
'BAD_RETURN(f64)': 'void',
16+
'INLINE': '',
17+
'NOINLINE': '',
18+
'OPTIMIZE_O3': '',
1619
}
1720

1821
def extract_functions(filename):

0 commit comments

Comments
 (0)