Skip to content

Commit

Permalink
update again
Browse files Browse the repository at this point in the history
  • Loading branch information
ImaDoor2785 committed Feb 11, 2024
2 parents d304568 + 18903f0 commit fdd5b97
Show file tree
Hide file tree
Showing 925 changed files with 308,654 additions and 13,923 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/inform-pages-repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Append File Docstrings
run: |
python ./scripts/docs/append-file-docs.py
python ./scripts/ci/docs/append-file-docs.py
- name: Upload Docs Artifact
uses: actions/upload-artifact@v4
Expand All @@ -75,7 +75,7 @@ jobs:
run: echo ${{ github.run_id }}

- name: Send Dispatch
uses: peter-evans/repository-dispatch@v2
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.BOT_PAT }}
repository: 'open-goal/open-goal.github.io'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-controller-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
wget -O ./game/assets/sdl_controller_db.txt https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.BOT_PAT }}
author: 'OpenGOALBot <[email protected]>'
Expand Down
4 changes: 2 additions & 2 deletions .vs/launch.vs.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@
"type" : "default",
"project" : "CMakeLists.txt",
"projectTarget" : "formatter.exe (bin\\formatter.exe)",
"name" : "Tools - Formatter",
"args" : ["--new", "--file", "C:\\Users\\xtvas\\Repos\\opengoal\\jak-project\\test-formatter.gc"]
"name" : "Tools - Formatter - Inplace",
"args" : ["--write", "--file", "C:\\Users\\xtvas\\Repos\\opengoal\\jak-project\\decompiler_out\\jak3\\mood-h_disasm.gc"]
},
{
"type": "default",
Expand Down
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
"version": "0.2.0",
"configurations": [
{
"name": "Append File Docs",
"name": "run python script",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/scripts/ci/lint-characters.py",
"program": "${workspaceFolder}/scripts/gsrc/copy-common-naming.py",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}",
"args": ["--fix"]
"args": ["--update-names-from-refs", "--decompiler", "./out/build/Release/bin/decompiler"]
},
]
}
94 changes: 0 additions & 94 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,99 +7,5 @@
},
"editor.wordBasedSuggestions": "matchingDocuments",
"editor.snippetSuggestions": "top"
},
"python.formatting.provider": "black",
"files.associations": {
"optional": "cpp",
"algorithm": "cpp",
"any": "cpp",
"array": "cpp",
"atomic": "cpp",
"bit": "cpp",
"bitset": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"cinttypes": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"codecvt": "cpp",
"compare": "cpp",
"concepts": "cpp",
"condition_variable": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"deque": "cpp",
"exception": "cpp",
"filesystem": "cpp",
"format": "cpp",
"forward_list": "cpp",
"fstream": "cpp",
"functional": "cpp",
"future": "cpp",
"initializer_list": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"list": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"numeric": "cpp",
"ostream": "cpp",
"queue": "cpp",
"random": "cpp",
"ranges": "cpp",
"ratio": "cpp",
"regex": "cpp",
"set": "cpp",
"shared_mutex": "cpp",
"span": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"unordered_set": "cpp",
"utility": "cpp",
"valarray": "cpp",
"variant": "cpp",
"vector": "cpp",
"xfacet": "cpp",
"xhash": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xstring": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
}
}
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-Wdisabled-optimization \
-Wformat \
-Wextra \
-Wmissing-include-dirs \
-Woverloaded-virtual \
-Wredundant-decls \
-Wshadow \
Expand All @@ -120,7 +119,6 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
-Wdisabled-optimization \
-Wformat \
-Wextra \
-Wmissing-include-dirs \
-Woverloaded-virtual \
-Wredundant-decls \
-Wshadow \
Expand Down
29 changes: 21 additions & 8 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,14 @@ tasks:
desc: "Format code"
cmds:
# npm install -g prettier
- cmd: npx prettier --write ./decompiler/config/jak1/**/*.jsonc
ignore_error: true
- cmd: npx prettier --write ./decompiler/config/jak2/**/*.jsonc
ignore_error: true
- cmd: npx prettier --write ./decompiler/config/jak3/**/*.jsonc
- cmd: npx prettier --write ./decompiler/config/jak*/**/*.jsonc
ignore_error: true
format:
desc: "Format code"
cmds:
- cmd: python ./scripts/cpp/format-includes.py
- cmd: python ./third-party/run-clang-format/run-clang-format.py -r common decompiler game goalc test tools lsp -i
- task: format-json

# DECOMPILING
decomp:
cmds:
Expand All @@ -103,7 +98,7 @@ tasks:
- python ./scripts/tasks/clean-decomp.py --game "{{.GAME}}"
lint-gsrc-file:
cmds:
- python ./scripts/gsrc/lint-gsrc-file.py --game {{.GAME}} --file {{.FILE}}
- python ./scripts/gsrc/lint-gsrc-file.py --game {{.GAME}} --file "{{.FILE}}"
update-gsrc:
cmds:
- python ./scripts/gsrc/update-gsrc-via-refs.py --game "{{.GAME}}" --decompiler "{{.DECOMP_BIN_RELEASE_DIR}}/decompiler" --decompiler_config {{.DECOMP_CONFIG}} --version {{.DECOMP_CONFIG_VERSION}}
Expand All @@ -113,8 +108,26 @@ tasks:
update-gsrc-file:
cmds:
- task: decomp-file
- python ./scripts/gsrc/update-from-decomp.py --game "{{.GAME}}" --file {{.FILE}}
- python ./scripts/gsrc/update-from-decomp.py --game "{{.GAME}}" --file "{{.FILE}}"
- task: lint-gsrc-file
copy-common-naming:
cmds:
- python ./scripts/gsrc/copy-common-naming.py --file "{{.FILE}}" --decompiler "{{.DECOMP_BIN_RELEASE_DIR}}/decompiler"
- task: format-json
copy-common-naming-from-refs:
cmds:
- python ./scripts/gsrc/copy-common-naming.py --update-names-from-refs --decompiler "{{.DECOMP_BIN_RELEASE_DIR}}/decompiler"
- task: format-json
# ASSET RIPPING
rip-textures:
cmds:
- "{{.DECOMP_BIN_RELEASE_DIR}}/decompiler \"./decompiler/config/{{.DECOMP_CONFIG}}\" \"./iso_data\" \"./decompiler_out\" --version \"{{.DECOMP_CONFIG_VERSION}}\" --config-override '{\"decompile_code\": false, \"levels_extract\": true, \"save_texture_pngs\": true}'"
rip-levels:
cmds:
- "{{.DECOMP_BIN_RELEASE_DIR}}/decompiler \"./decompiler/config/{{.DECOMP_CONFIG}}\" \"./iso_data\" \"./decompiler_out\" --version \"{{.DECOMP_CONFIG_VERSION}}\" --config-override '{\"decompile_code\": false, \"levels_extract\": true, \"rip_levels\": true}'"
rip-collision:
cmds:
- "{{.DECOMP_BIN_RELEASE_DIR}}/decompiler \"./decompiler/config/{{.DECOMP_CONFIG}}\" \"./iso_data\" \"./decompiler_out\" --version \"{{.DECOMP_CONFIG_VERSION}}\" --config-override '{\"decompile_code\": false, \"levels_extract\": true, \"extract_collision\": true, \"rip_collision\": true}'"
# TOOLS
analyze-ee-memory:
cmds:
Expand Down
23 changes: 20 additions & 3 deletions common/audio/audio_formats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ void write_wave_file(const std::vector<s16>& left_samples,
writer.write_to_file(name);
}

std::pair<std::vector<s16>, std::vector<s16>> decode_adpcm(BinaryReader& reader, const bool mono) {
std::pair<std::vector<s16>, std::vector<s16>> decode_adpcm(BinaryReader& reader,
const bool stereo) {
std::vector<s16> left_samples;
std::vector<s16> right_samples;
s32 left_sample_prev[2] = {0, 0};
s32 right_sample_prev[2] = {0, 0};
bool first_left = true;
bool first_right = true;
constexpr s32 f1[5] = {0, 60, 115, 98, 122};
constexpr s32 f2[5] = {0, 0, -52, -55, -60};

Expand All @@ -71,15 +74,29 @@ std::pair<std::vector<s16>, std::vector<s16>> decode_adpcm(BinaryReader& reader,
// instead they are partitioned into contiguous 8kb (thats 8192 bytes) chunks
// alternating left/right
bool processing_left_chunk = true;
// We need to skip the vag header for each channel
if (first_left) {
reader.ffwd(48);
bytes_read += 48;
first_left = false;
}
while (true) {
if (!reader.bytes_left()) {
break;
}

if (bytes_read == 0x2000) {
if (stereo && bytes_read == 0x2000) {
// switch streams
processing_left_chunk = !processing_left_chunk;
bytes_read = 0;

// We need to skip the vag header for each channel
if (first_right) {
// skip the header
reader.ffwd(48);
bytes_read += 48;
first_right = false;
}
}

u8 shift_filter = reader.read<u8>();
Expand Down Expand Up @@ -107,7 +124,7 @@ std::pair<std::vector<s16>, std::vector<s16>> decode_adpcm(BinaryReader& reader,
s32 sample = (s32)(s16)(nibble << 12);
sample >>= shift;

if (mono || processing_left_chunk) {
if (!stereo || processing_left_chunk) {
sample += (left_sample_prev[0] * f1[filter] + left_sample_prev[1] * f2[filter] + 32) / 64;

if (sample > 0x7fff) {
Expand Down
18 changes: 16 additions & 2 deletions common/formatter/formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,12 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
}

// Consolidate any lines if the configuration requires it
// TODO there is a hack here so that multi-line forms that are consolidated still line up properly
// i have to make consolidate a more first-class feature of the config
if (curr_node.formatting_config.inline_until_index(form_lines)) {
std::vector<std::string> new_form_lines = {};
const auto original_form_head_width = str_util::split(form_lines.at(0), '\n').at(0).length();
bool consolidating_lines = true;
for (int i = 0; i < (int)form_lines.size(); i++) {
if (i < curr_node.formatting_config.inline_until_index(form_lines)) {
if (new_form_lines.empty()) {
Expand All @@ -298,7 +302,13 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
new_form_lines.at(0) += fmt::format(" {}", form_lines.at(i));
}
} else {
new_form_lines.push_back(form_lines.at(i));
if (str_util::starts_with(form_lines.at(i), " ") && consolidating_lines) {
new_form_lines.push_back(fmt::format(
"{}{}", str_util::repeat(original_form_head_width, " "), form_lines.at(i)));
} else {
consolidating_lines = false;
new_form_lines.push_back(form_lines.at(i));
}
}
}
form_lines = new_form_lines;
Expand Down Expand Up @@ -355,7 +365,11 @@ std::optional<std::string> formatter::format_code(const std::string& source) {

// Get the root node of the syntax tree.
TSNode root_node = ts_tree_root_node(tree.get());
if (ts_node_is_null(root_node) || ts_node_has_error(root_node)) {
if (ts_node_is_null(root_node)) {
lg::error("null root node");
return std::nullopt;
} else if (ts_node_has_error(root_node)) {
lg::error("grammar parsing error, go figure it out!");
return std::nullopt;
}

Expand Down
11 changes: 7 additions & 4 deletions common/formatter/rules/rule_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,19 @@ FormFormattingConfig new_flow_rule_prevent_inlining_indexes(
return cfg;
}

FormFormattingConfig new_binding_rule() {
FormFormattingConfig new_binding_rule(int form_head_width) {
FormFormattingConfig cfg;
cfg.hang_forms = false;
cfg.combine_first_two_lines = true;
auto binding_list_config = std::make_shared<FormFormattingConfig>();
binding_list_config->hang_forms = false;
binding_list_config->indentation_width = 1;
binding_list_config->indentation_width_for_index = [](FormFormattingConfig /*cfg*/, int index) {
binding_list_config->indentation_width_for_index = [form_head_width](FormFormattingConfig /*cfg*/,
int index) {
if (index == 0) {
return 0;
}
return 4;
return form_head_width;
};
binding_list_config->should_prevent_inlining = [](FormFormattingConfig /*config*/, int num_refs) {
// Only prevent inlining a binding list, if there are more than 1 bindings
Expand Down Expand Up @@ -87,13 +88,15 @@ const std::unordered_map<std::string, FormFormattingConfig> opengoal_form_config
{"defmethod", new_flow_rule(3)},
{"deftype", new_flow_rule_prevent_inlining_indexes(3, {3, 4, 5})},
{"defun", new_flow_rule(3)},
{"defun-debug", new_flow_rule(3)},
{"defbehavior", new_flow_rule(4)},
{"if", new_permissive_flow_rule()},
{"define", new_permissive_flow_rule()},
{"define-extern", new_permissive_flow_rule()},
{"defmacro", new_flow_rule(3)},
{"dotimes", new_flow_rule(2)},
{"let", new_binding_rule()},
{"let", new_binding_rule(4)},
{"rlet", new_binding_rule(5)},
{"when", new_flow_rule(2)},
{"with-dma-buffer-add-bucket", new_flow_rule(2)}};
} // namespace config
Expand Down
23 changes: 23 additions & 0 deletions common/log/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,31 @@ void log_print(const char* message) {
}
}
}

void log_vprintf(const char* format, va_list arg_list) {
{
// We always immediately flush prints because since it has no associated level
// it could be anything from a fatal error to a useless debug log.
std::lock_guard<std::mutex> lock(gLogger.mutex);
if (gLogger.fp) {
// Log to File
vfprintf(gLogger.fp, format, arg_list);
fflush(gLogger.fp);
}

if (gLogger.stdout_log_level < lg::level::off_unless_die) {
vprintf(format, arg_list);
fflush(stdout);
fflush(stderr);
}
}
}
} // namespace internal

void printstd(const std::string& format, va_list arg_list) {
internal::log_vprintf(format.c_str(), arg_list);
}

// how many extra log files for a single program should be kept?
constexpr int LOG_ROTATE_MAX = 10;

Expand Down
Loading

0 comments on commit fdd5b97

Please sign in to comment.