diff --git a/Makefile b/Makefile index 300d311f..1070f994 100755 --- a/Makefile +++ b/Makefile @@ -16,7 +16,10 @@ COMPILE_ASSETS ?= 0 $(eval $(call validate-option,COMPILE_ASSETS,0 1)) ifeq ($(COMPILE_ASSETS),1) - DUMMY != ./tools/dkr_assets_tool -c ./assets $(VERSION) + DUMMY != ./tools/dkr_assets_tool -c $(VERSION) ./assets >&2 || echo FAIL + ifeq ($(DUMMY),FAIL) + $(error Failed to compile assets) + endif endif ifeq ($(VERSION),us_1.0) diff --git a/extract.sh b/extract.sh index 86ad5496..811be6ce 100755 --- a/extract.sh +++ b/extract.sh @@ -1,26 +1,27 @@ #!/bin/bash if [[ $# == 0 || (($1 != "us_1.0") && ($1 != "us_1.1") && ($1 != "eu_1.0") && ($1 != "eu_1.1") && ($1 != "jp"))]]; then - echo 'Usage: ./extract.sh ' - echo 'Acceptable versions: us_1.0, us_1.1, eu_1.0, eu_1.1, jp' - exit 1 + echo 'No valid version specified, defaulting to us_1.0...' + VER="us_1.0" +else + VER=$1 fi echo 'Extracting Assets...' # Remove assets directory if it exists. -ASSETS_DIR="./assets/vanilla/$1" +ASSETS_DIR="./assets/vanilla/$VER" if [ -d "$ASSETS_DIR" ]; then rm -r $ASSETS_DIR fi # Remove ucode directory if it exists. -UCODE_DIR="./ucode/$1" +UCODE_DIR="./ucode/$VER" if [ -d "$UCODE_DIR" ]; then rm -r $UCODE_DIR fi -if ! ./tools/dkr_assets_tool -e "$1" ./assets ./extract-ver ./baseroms . ; then +if ! ./tools/dkr_assets_tool -e "$VER" ./assets ./extract-ver ./baseroms . ; then exit 1 fi diff --git a/tools/.gitignore b/tools/.gitignore index 3f7da8e1..dc35de12 100755 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -1,7 +1,5 @@ /n64crc -/dkr_decompressor -/dkr_cheats_encryptor -/dkr_extractor -/dkr_texbuilder +/dkr_assets_tool +/dkr_assets_tool_classes/_build /binutils -/ido5.3_recomp \ No newline at end of file +/ido5.3_recomp diff --git a/tools/dkr_assets_tool b/tools/dkr_assets_tool index 43b9279d..16c41770 100755 Binary files a/tools/dkr_assets_tool and b/tools/dkr_assets_tool differ diff --git a/tools/dkr_assets_tool.cpp b/tools/dkr_assets_tool.cpp index dc2a3ae1..10337637 100644 --- a/tools/dkr_assets_tool.cpp +++ b/tools/dkr_assets_tool.cpp @@ -52,11 +52,6 @@ typedef enum _CurrentParseOption { PO_TYPE } CurrentParseOption; -template -void invalid_arg_error(T arg) { - std::cout << "Error: Invalid argument \"" << arg << "\"" << std::endl; -} - std::string get_cmd_from_parse_option(ToolType type) { switch(type) { case TT_EXTRACT: return "-e"; @@ -84,8 +79,7 @@ bool parse_options(int argc, char *argv[]) { for (size_t i = 1; i < args.size(); ++i) { if(args[i][0] == '-') { if(parsingCmd) { - std::cout << "Error: Not enough args for the current command \"" - << get_cmd_from_parse_option(options.type) << "\"" << std::endl; + display_error("Not enough args for the current command \"", get_cmd_from_parse_option(options.type), "\""); return false; } if(args[i] == "-e") { @@ -121,14 +115,13 @@ bool parse_options(int argc, char *argv[]) { } else if(args[i] == "-h") { return false; } else { - std::cout << "Error: Invalid option " << args[i] << std::endl; + display_error("Invalid option \"", args[i], "\""); return false; } curOptionArgs = 0; } else { if(!parsingCmd) { - std::cout << "Error: Too many args for the current command \"" - << get_cmd_from_parse_option(options.type) << "\"" << std::endl; + display_error("Too many args for the current command \"", get_cmd_from_parse_option(options.type), "\""); return false; } switch(curOption) { @@ -199,16 +192,14 @@ bool parse_options(int argc, char *argv[]) { } break; default: // This should hopefully never get called - std::cout << "Error: You should not be seeing this message." << std::endl; - return false; + display_error_and_abort("Invalid dkr_assets_tool option. You should not be seeing this message!"); } curOptionArgs++; } } if(parsingCmd) { - std::cout << "Error: Not enough args for the current command \"" - << get_cmd_from_parse_option(options.type) << "\"" << std::endl; + display_error("Not enough args for the current command \"", get_cmd_from_parse_option(options.type), "\""); return false; } @@ -274,7 +265,7 @@ int main(int argc, char *argv[]) { set_assets_folder_path(assetsDir); set_version(version); - AssetCompiler compiler(); + AssetCompiler compiler; } break; case TT_ASSET_COMPRESS_FILE: @@ -285,26 +276,19 @@ int main(int argc, char *argv[]) { std::string outputFilename = options.paths[1]; std::vector inputBinary, outputBinary; - if(compression.readBinaryFile(inputBinary, inputFilename)) - { + if(compression.readBinaryFile(inputBinary, inputFilename)) { if(inputBinary.size() == 0) { compression.writeBinaryFile(inputBinary, outputFilename); } else { - if (options.type == TT_ASSET_COMPRESS_FILE) - { + if (options.type == TT_ASSET_COMPRESS_FILE) { outputBinary = compression.compressBuffer(inputBinary); - } - else if (options.type == TT_ASSET_DECOMPRESS_FILE) - { + } else if (options.type == TT_ASSET_DECOMPRESS_FILE) { outputBinary = compression.decompressBuffer(inputBinary); } compression.writeBinaryFile(outputBinary, outputFilename); } - } - else - { - std::cout << "Could not read file: " << inputFilename << std::endl; - return 1; + } else { + display_error_and_abort("Could not read file: ", inputFilename); } } break; diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool.o deleted file mode 100644 index d699bc69..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_fonts.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_fonts.o deleted file mode 100644 index aae8267d..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_fonts.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_gametext.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_gametext.o deleted file mode 100644 index dd3d48fb..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_gametext.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_levelheader.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_levelheader.o deleted file mode 100644 index 75fc41ad..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_levelheader.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_levelname.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_levelname.o deleted file mode 100644 index 78b23a28..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_levelname.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_menutext.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_menutext.o deleted file mode 100644 index f5f39da3..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_menutext.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_sprite.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_sprite.o deleted file mode 100644 index 14cd3d20..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_sprite.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_texture.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_texture.o deleted file mode 100644 index dea0e799..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_texture.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_ttghost.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_ttghost.o deleted file mode 100644 index e41ad9f0..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/build_files/build_ttghost.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/builder.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/builder.o deleted file mode 100644 index bffbb513..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/builder/builder.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/textures.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/textures.o deleted file mode 100644 index 0f590c56..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/textures.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/types.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/types.o deleted file mode 100644 index 4b34dd58..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/types.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util.o deleted file mode 100644 index c803996e..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/enumHelper.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/enumHelper.o deleted file mode 100644 index 2519fa11..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/enumHelper.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/fileHelper.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/fileHelper.o deleted file mode 100644 index b6bcf506..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/fileHelper.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/jsonHelper.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/jsonHelper.o deleted file mode 100644 index f523e12c..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/common/util/jsonHelper.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/compiler/compiler.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/compiler/compiler.o deleted file mode 100644 index 0f3e4352..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/compiler/compiler.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/config.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/config.o deleted file mode 100644 index e8f1a76b..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/config.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract.o deleted file mode 100644 index dcdda32a..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_binary.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_binary.o deleted file mode 100644 index deed0af2..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_binary.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_compressed.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_compressed.o deleted file mode 100644 index 9f72491b..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_compressed.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_fonts.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_fonts.o deleted file mode 100644 index 44783acc..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_fonts.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_gametext.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_gametext.o deleted file mode 100644 index 71c9a138..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_gametext.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_levelheader.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_levelheader.o deleted file mode 100644 index 7d7e79b3..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_levelheader.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_levelname.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_levelname.o deleted file mode 100644 index d1b67abf..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_levelname.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_menutext.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_menutext.o deleted file mode 100644 index 488e28a3..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_menutext.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_sprite.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_sprite.o deleted file mode 100644 index f218db16..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_sprite.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_textures.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_textures.o deleted file mode 100644 index 33a1a82e..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_textures.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_ttghost.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_ttghost.o deleted file mode 100644 index f7627f91..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extract/extract_ttghost.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extractor.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extractor.o deleted file mode 100644 index d3ca9602..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/extractor.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/rom.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/rom.o deleted file mode 100644 index 3dbba927..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/extractor/rom.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/DKRCompression.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/DKRCompression.o deleted file mode 100644 index 6c8a54b8..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/DKRCompression.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/DKRGzip.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/DKRGzip.o deleted file mode 100644 index a24bbd0f..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/DKRGzip.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/GECompression.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/GECompression.o deleted file mode 100644 index 0be0f1b6..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/GECompression.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/n64graphics-utils.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/n64graphics-utils.o deleted file mode 100644 index 7dbb06ae..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/n64graphics-utils.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/n64graphics.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/n64graphics.o deleted file mode 100644 index 2d1a7f08..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/libs/n64graphics.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/make_asset_files/asset_asm_data.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/make_asset_files/asset_asm_data.o deleted file mode 100644 index 6f71cb71..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/make_asset_files/asset_asm_data.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/make_asset_files/asset_enums_header.o b/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/make_asset_files/asset_enums_header.o deleted file mode 100644 index fa17b55f..00000000 Binary files a/tools/dkr_assets_tool_classes/_build/dkr_assets_tool_classes/make_asset_files/asset_enums_header.o and /dev/null differ diff --git a/tools/dkr_assets_tool_classes/builder/build_files/build_fonts.cpp b/tools/dkr_assets_tool_classes/builder/build_files/build_fonts.cpp index 030d4826..6a434c8b 100644 --- a/tools/dkr_assets_tool_classes/builder/build_files/build_fonts.cpp +++ b/tools/dkr_assets_tool_classes/builder/build_files/build_fonts.cpp @@ -50,9 +50,8 @@ BuildFonts::BuildFonts(std::string srcPath, std::string dstPath) { write_ascii_char_nodes(out, srcPath, fontOffset + 0x100, font); } else if(encoding == "CUSTOM") { write_custom_char_nodes(out, srcPath, fontOffset + 0x100, font); - } else{ - std::cout << "Error: Unsupported font encoding type: \"" << encoding << "\"" << std::endl; - throw 1; + } else { + display_error_and_abort("Unsupported font encoding type: \"", encoding, "\""); } } @@ -98,8 +97,7 @@ void BuildFonts::write_custom_char_nodes(std::vector &out, std::string for(std::string &chr : order) { if(index >= NUMBER_OF_CHAR_NODES) { std::string fontName = get_string_from_json(srcPath, "fonts", font, "name"); - std::cout << "Error: Too many character nodes in " << fontName << ". The limit is " << NUMBER_OF_CHAR_NODES << std::endl; - throw 1; + display_error_and_abort("Too many character nodes in ", fontName, ". The limit is ", NUMBER_OF_CHAR_NODES); } int nodeOffset = offset + (index++ * SIZEOF_CHAR_NODE); write_char_node(out, srcPath, nodeOffset, font, chr); diff --git a/tools/dkr_assets_tool_classes/builder/build_files/build_levelheader.cpp b/tools/dkr_assets_tool_classes/builder/build_files/build_levelheader.cpp index e2bc9836..d121e87a 100644 --- a/tools/dkr_assets_tool_classes/builder/build_files/build_levelheader.cpp +++ b/tools/dkr_assets_tool_classes/builder/build_files/build_levelheader.cpp @@ -1,68 +1,112 @@ #include "build_levelheader.h" -#define GET_UNKNOWN_VALUE(name, index) get_int_from_json(srcPath, "unknownData", name, index) +#define GET_UNKNOWN_VALUE(name, index) get_int_from_json(srcPath, "unknown-data", name, index) #define GET_UNKNOWN_VALUES(out, start, end, name) \ for(int i = start; i < end; i++) { \ out[i] = GET_UNKNOWN_VALUE(name, i - start); \ } +int get_bitfield_from_enum_values(std::string &srcPath, std::string propertyName, std::string enumName) { + int numEntries = get_array_length_from_json(srcPath, propertyName); + int out = 0; + for(int i = 0; i < numEntries; i++) { + out |= 1 << get_enum_value_from_string(enumName, get_string_from_json(srcPath, propertyName, i)); + } + return out; +} + BuildLevelHeader::BuildLevelHeader(std::string srcPath, std::string dstPath) { std::vector out(SIZEOF_LEVEL_HEADER); + // World ID out[0] = get_enum_value_from_string("World", get_string_from_json(srcPath, "world")); - out[1] = get_int_from_json(srcPath, "unknownData", "unk1"); - out[2] = get_int_from_json(srcPath, "unknownData", "unk2"); - out[3] = get_int_from_json(srcPath, "unknownData", "unk3"); + + out[1] = get_int_from_json(srcPath, "unknown-data", "unk1"); + out[2] = get_int_from_json(srcPath, "unknown-data", "unk2"); + out[3] = get_int_from_json(srcPath, "unknown-data", "unk3"); GET_UNKNOWN_VALUES(out, 4, 8, "unk4"); + + // Ceiling height for planes write_big_endian_float(out, 8, get_float_from_json(srcPath, "ceiling-height")); + GET_UNKNOWN_VALUES(out, 0xC, 0x34, "unkC"); + + // Track ID to use write_big_endian_halfword(out, 0x34, get_index_from_build_id("ASSET_LEVEL_MODELS", get_string_from_json(srcPath, "model"))); + + // Collectables bitflags (bananas, balloons, etc) write_big_endian_halfword(out, 0x36, get_int_from_json(srcPath, "collectables")); + + // Skydome object model ID write_big_endian_halfword(out, 0x38, get_int_from_json(srcPath, "skybox")); - write_big_endian_halfword(out, 0x3A, get_int_from_json(srcPath, "fog", "unk3A")); - write_big_endian_halfword(out, 0x3C, get_int_from_json(srcPath, "fog", "unk3C")); - write_big_endian_halfword(out, 0x3E, get_int_from_json(srcPath, "fog", "red")); - write_big_endian_halfword(out, 0x40, get_int_from_json(srcPath, "fog", "green")); - write_big_endian_halfword(out, 0x42, get_int_from_json(srcPath, "fog", "blue")); + + // Fog + write_big_endian_halfword(out, 0x3A, get_int_from_json(srcPath, "fog", "range", "min")); + write_big_endian_halfword(out, 0x3C, get_int_from_json(srcPath, "fog", "range", "max")); + write_big_endian_halfword(out, 0x3E, get_int_from_json(srcPath, "fog", "colour", "red")); + write_big_endian_halfword(out, 0x40, get_int_from_json(srcPath, "fog", "colour", "green")); + write_big_endian_halfword(out, 0x42, get_int_from_json(srcPath, "fog", "colour", "blue")); + GET_UNKNOWN_VALUES(out, 0x44, 0x4B, "unk44"); + + // Number of laps to complete the race. out[0x4B] = get_int_from_json(srcPath, "number-laps"); + + // Type of race (standard, boss race, hub world, etc. out[0x4C] = get_enum_value_from_string("RaceType", get_string_from_json(srcPath, "race-type")); + + // Default vehicle used for this track. (Either Car, Hovercraft, or Plane) out[0x4D] = get_enum_value_from_string("Vehicle", get_string_from_json(srcPath, "default-vehicle")); - int avaliableVehicles = 0; - for(int i = 0; i < get_array_length_from_json(srcPath, "available-vehicles"); i++) { - avaliableVehicles |= 1 << get_enum_value_from_string("Vehicle", get_string_from_json(srcPath, "available-vehicles", i)); - } - out[0x4E] = avaliableVehicles; + + // Which vehicles can be used in this track (Either Car, Hovercraft, or Plane) + out[0x4E] = get_bitfield_from_enum_values(srcPath, "available-vehicles", "Vehicle"); GET_UNKNOWN_VALUES(out, 0x4F, 0x52, "unk4F"); + + // Music ID to use for this track out[0x52] = get_int_from_json(srcPath, "music"); - out[0x53] = get_int_from_json(srcPath, "unknownData", "unk53"); + + // Unknown, but *probably* related to audio. + out[0x53] = get_int_from_json(srcPath, "unknown-data", "unk53"); + + // Instruments bitflags. Most levels have 0xFFFF, except for the central hub which is 0xB write_big_endian_halfword(out, 0x54, get_int_from_json(srcPath, "instruments")); + GET_UNKNOWN_VALUES(out, 0x56, 0x74, "unk56"); for(int i = 0; i < 7; i++) { - write_big_endian_word(out, 0x74 + (i * 4), get_int_from_json(srcPath, "unknownData", "unk74", i)); + write_big_endian_word(out, 0x74 + (i * 4), get_int_from_json(srcPath, "unknown-data", "unk74", i)); } - write_big_endian_halfword(out, 0x90, get_int_from_json(srcPath, "unknownData", "weather", "unk90")); - write_big_endian_halfword(out, 0x92, get_int_from_json(srcPath, "unknownData", "weather", "unk92")); - out[0x94] = get_int_from_json(srcPath, "unknownData", "weather", "unk94"); - out[0x95] = get_int_from_json(srcPath, "unknownData", "weather", "unk95"); - write_big_endian_halfword(out, 0x96, get_int_from_json(srcPath, "unknownData", "weather", "unk96")); - write_big_endian_halfword(out, 0x98, get_int_from_json(srcPath, "unknownData", "weather", "unk98")); - write_big_endian_halfword(out, 0x9A, get_int_from_json(srcPath, "unknownData", "weather", "unk9A")); + + // Weather values currently unknown. + write_big_endian_halfword(out, 0x90, get_int_from_json(srcPath, "unknown-data", "weather", "unk90")); + write_big_endian_halfword(out, 0x92, get_int_from_json(srcPath, "unknown-data", "weather", "unk92")); + out[0x94] = get_int_from_json(srcPath, "unknown-data", "weather", "unk94"); + out[0x95] = get_int_from_json(srcPath, "unknown-data", "weather", "unk95"); + write_big_endian_halfword(out, 0x96, get_int_from_json(srcPath, "unknown-data", "weather", "unk96")); + write_big_endian_halfword(out, 0x98, get_int_from_json(srcPath, "unknown-data", "weather", "unk98")); + write_big_endian_halfword(out, 0x9A, get_int_from_json(srcPath, "unknown-data", "weather", "unk9A")); + + // Field of view out[0x9C] = get_int_from_json(srcPath, "fov"); - out[0x9D] = get_int_from_json(srcPath, "backgroundColor", "red"); - out[0x9E] = get_int_from_json(srcPath, "backgroundColor", "green"); - out[0x9F] = get_int_from_json(srcPath, "backgroundColor", "blue"); + + // Background clear color + out[0x9D] = get_int_from_json(srcPath, "background-colour", "red"); + out[0x9E] = get_int_from_json(srcPath, "background-colour", "green"); + out[0x9F] = get_int_from_json(srcPath, "background-colour", "blue"); + GET_UNKNOWN_VALUES(out, 0xA0, 0xA4, "unkA0"); - write_big_endian_word(out, 0xA4, get_int_from_json(srcPath, "unknownData", "unkA4")); - write_big_endian_halfword(out, 0xA8, get_int_from_json(srcPath, "unknownData", "unkA8")); - write_big_endian_halfword(out, 0xAA, get_int_from_json(srcPath, "unknownData", "unkAA")); + write_big_endian_word(out, 0xA4, get_int_from_json(srcPath, "unknown-data", "unkA4")); + write_big_endian_halfword(out, 0xA8, get_int_from_json(srcPath, "unknown-data", "unkA8")); + write_big_endian_halfword(out, 0xAA, get_int_from_json(srcPath, "unknown-data", "unkAA")); + + // Pulsating lights are only used in spaceport alpha int pulsatingLights = -1; if(json_has_key(srcPath, "pulsating-lights")) { pulsatingLights = get_index_from_build_id("ASSET_MISC", get_string_from_json(srcPath, "pulsating-lights")); } write_big_endian_word(out, 0xAC, pulsatingLights); + GET_UNKNOWN_VALUES(out, 0xB0, 0xC4, "unkB0"); - write_big_endian_word(out, 0xC4, get_int_from_json(srcPath, "unknownData", "unkC4")); + write_big_endian_word(out, 0xC4, get_int_from_json(srcPath, "unknown-data", "unkC4")); write_binary_file(out, dstPath); } diff --git a/tools/dkr_assets_tool_classes/builder/build_files/build_texture.cpp b/tools/dkr_assets_tool_classes/builder/build_files/build_texture.cpp index 8c60fe70..d266a878 100644 --- a/tools/dkr_assets_tool_classes/builder/build_files/build_texture.cpp +++ b/tools/dkr_assets_tool_classes/builder/build_files/build_texture.cpp @@ -214,8 +214,8 @@ void BuildTexture::write_texture_data(std::vector &out, int outOffset, case TEX_FORMAT_CI4: case TEX_FORMAT_CI8: { - std::cout << "Error: CI texture formats are not currently supported." << std::endl; - break; + display_error_and_abort("CI4/CI8 texture formats are not currently supported."); } } } + diff --git a/tools/dkr_assets_tool_classes/builder/builder.cpp b/tools/dkr_assets_tool_classes/builder/builder.cpp index 8f78bfc9..221432be 100644 --- a/tools/dkr_assets_tool_classes/builder/builder.cpp +++ b/tools/dkr_assets_tool_classes/builder/builder.cpp @@ -2,8 +2,7 @@ Builder::Builder(std::string srcPath, std::string dstPath) { if(!path_exists(srcPath)) { - std::cout << "Error: Invalid path \"" << srcPath << "\"" << std::endl; - throw 1; + display_error_and_abort("Invalid path \"", srcPath, "\""); } if(ends_with(srcPath, ".json")) { @@ -24,7 +23,11 @@ Builder::Builder(std::string srcPath, std::string dstPath) { BuildMenuText(srcPath, dstPath); } else if (type == "Fonts") { BuildFonts(srcPath, dstPath); - } + } else if (type == "") { + display_error_and_abort("No type found for \"", srcPath, "\".\nMake sure the \"type\" property is defined in the json file!"); + } else { + display_error_and_abort("Unknown type \"", type, "\" in \"", srcPath, "\""); + } } } diff --git a/tools/dkr_assets_tool_classes/common/textures.cpp b/tools/dkr_assets_tool_classes/common/textures.cpp index 7191fb47..ea2a51ea 100644 --- a/tools/dkr_assets_tool_classes/common/textures.cpp +++ b/tools/dkr_assets_tool_classes/common/textures.cpp @@ -12,7 +12,7 @@ std::string get_texture_format_string(int format) { case TEX_FORMAT_CI4: return "CI4"; case TEX_FORMAT_CI8: return "CI8"; } - throw 1; + display_error_and_abort("Invalid texture format ", format); } int get_texture_format_from_string(std::string format) { @@ -25,7 +25,7 @@ int get_texture_format_from_string(std::string format) { if(format == "IA4") return TEX_FORMAT_IA4; if(format == "CI4") return TEX_FORMAT_CI4; if(format == "CI8") return TEX_FORMAT_CI8; - throw 1; + display_error_and_abort("Invalid texture format ", format); } void deinterlace(std::vector& texData, int texDataOffset, int width, int height, int bitDepth, int bufferSize) { @@ -102,12 +102,10 @@ int get_texture_size(int width, int height, int format) { return (width * height / 2) + TEX_HEADER_SIZE; case TEX_FORMAT_CI4: case TEX_FORMAT_CI8: - std::cout << "Error: CI texture formats are not currently supported." << std::endl; - throw 1; + display_error_and_abort("CI texture formats are not currently supported."); } - - std::cout << "Error: Invalid texture format " << format << std::endl; - throw 1; + + display_error_and_abort("Invalid texture format ", format); } std::vector load_texture_from_png(std::string filepath, int textureFormat, int *width, int *height) { @@ -132,10 +130,9 @@ std::vector load_texture_from_png(std::string filepath, int textureForm return vec; } case TEX_FORMAT_CI4: - std::cout << "Error: CI4 is currently not supported." << std::endl; - throw 1; + case TEX_FORMAT_CI8: + display_error_and_abort("CI4/CI8 texture formats are not currently supported."); default: - std::cout << "Error: Invalid texture type: " << textureFormat << std::endl; - throw 1; + display_error_and_abort("Invalid texture format: ", textureFormat); } } diff --git a/tools/dkr_assets_tool_classes/common/textures.h b/tools/dkr_assets_tool_classes/common/textures.h index fedc488f..e960dd8d 100644 --- a/tools/dkr_assets_tool_classes/common/textures.h +++ b/tools/dkr_assets_tool_classes/common/textures.h @@ -4,6 +4,7 @@ #include #include #include "../libs/n64graphics.h" +#include "util/errorHelper.h" #define TEX_HEADER_SIZE 0x20 diff --git a/tools/dkr_assets_tool_classes/common/util.h b/tools/dkr_assets_tool_classes/common/util.h index 535ec0d1..f0b19de1 100644 --- a/tools/dkr_assets_tool_classes/common/util.h +++ b/tools/dkr_assets_tool_classes/common/util.h @@ -14,6 +14,7 @@ #include "util/fileHelper.h" #include "util/jsonHelper.h" #include "util/enumHelper.h" +#include "util/errorHelper.h" uint32_t get_big_endian_word(std::vector &data, int offset); void write_big_endian_word(std::vector &data, int offset, uint32_t value); diff --git a/tools/dkr_assets_tool_classes/common/util/errorHelper.cpp b/tools/dkr_assets_tool_classes/common/util/errorHelper.cpp new file mode 100644 index 00000000..d00ba0ef --- /dev/null +++ b/tools/dkr_assets_tool_classes/common/util/errorHelper.cpp @@ -0,0 +1,3 @@ +#include "errorHelper.h" + + diff --git a/tools/dkr_assets_tool_classes/common/util/errorHelper.h b/tools/dkr_assets_tool_classes/common/util/errorHelper.h new file mode 100644 index 00000000..f75c4366 --- /dev/null +++ b/tools/dkr_assets_tool_classes/common/util/errorHelper.h @@ -0,0 +1,26 @@ +#pragma once + +#include +#include + +// Requires C++17 +#define RED_TEXT "\033[1;31m" +#define RESET_TEXT "\033[0m" + +// Requires C++17 +template +inline void display_error(Args... args) { + std::cout << RED_TEXT << "Error: "; + (std::cout << ... << args); + std::cout << RESET_TEXT << std::endl; +} + +// Requires C++17 +template +inline void display_error_and_abort(Args... args) { + display_error(args...); + std::cout << RED_TEXT << "Aborting!" << RESET_TEXT << std::endl; + throw 1; +} + + diff --git a/tools/dkr_assets_tool_classes/compiler/compiler.cpp b/tools/dkr_assets_tool_classes/compiler/compiler.cpp index 2a6db6a8..f1faec59 100644 --- a/tools/dkr_assets_tool_classes/compiler/compiler.cpp +++ b/tools/dkr_assets_tool_classes/compiler/compiler.cpp @@ -3,36 +3,60 @@ const std::string BASE_DIR_NAME = "vanilla"; const std::string EXT_DIR_NAME = "packages"; -AssetCompiler::AssetCompiler(std::string assetsDirectory, std::string version) { +AssetCompiler::AssetCompiler() { + std::cout << "Compiling assets..." << std::endl; + + std::string assetsDirectory = get_asset_folder_path(); + std::string version = get_version(); + std::string vanillaDirPath = assetsDirectory + "/" + BASE_DIR_NAME; std::string outDirPath = assetsDirectory + "/" + version; std::string packagesDirPath = assetsDirectory + "/" + EXT_DIR_NAME + "/" + version; // Deletes the output directory if it currently exists. + std::cout << "Deleting \"" << outDirPath << "\"..." << std::endl; delete_directory(outDirPath); // Copy vanilla folder to the output directory as the baseline. + std::cout << "Copying vanilla files..." << std::endl; recursively_copy_directory(vanillaDirPath + "/" + version, outDirPath); + std::cout << "Reading package order..." << std::endl; std::string packageOrderFilepath = packagesDirPath + "/order.json"; if(path_exists(packageOrderFilepath)) { std::vector packageOrder = get_array_from_json(packageOrderFilepath); for(std::string &packageName : packageOrder) { + std::cout << "Applying package: " << packageName << std::endl; std::string packageDir = packagesDirPath + "/" + packageName; copy_stuff_from_folders(packageDir, outDirPath, packageName); append_manifest_files(packageDir, outDirPath, packageName); } } + std::cout << "Done!" << std::endl; } AssetCompiler::~AssetCompiler() { } +// TODO: Implement more checks. Maybe add option to skip verification? +void AssetCompiler::verify_json_files(std::string &folderPath) { + std::vector jsonFiles = get_filenames_from_directory_with_extension(folderPath, ".json"); + for(std::string &jsonFilePath : jsonFiles) { + // Need to make sure that all the json files within directories have a type in them. + std::string jsonFileType = get_string_from_json(jsonFilePath, "type"); + if(jsonFileType == "") { + display_error_and_abort("\"", jsonFilePath, "\" does not have a type."); + } + } +} + void AssetCompiler::copy_stuff_from_folders(std::string &packageDir, std::string &outDirPath, std::string &packageName) { std::vector packageFolders = get_folders_from_directory_only(packageDir); for(int i = 0; i < packageFolders.size(); i++) { - recursively_copy_directory(packageFolders[i].string(), outDirPath + "/" + packageFolders[i].filename().string()); + std::string folderPath = packageFolders[i].string(); + verify_json_files(folderPath); + recursively_copy_directory(folderPath, outDirPath + "/" + packageFolders[i].filename().string()); } } @@ -41,6 +65,7 @@ void AssetCompiler::append_manifest_files(std::string &packageDir, std::string & std::string curDataPath, newDataPath; for(int i = 0; i < packageFiles.size(); i++) { std::string filename = packageFiles[i].filename().string(); + // meta.json is a special file, so ignore it! if(filename == "meta.json") { continue; } diff --git a/tools/dkr_assets_tool_classes/compiler/compiler.h b/tools/dkr_assets_tool_classes/compiler/compiler.h index b070087c..fb588a59 100644 --- a/tools/dkr_assets_tool_classes/compiler/compiler.h +++ b/tools/dkr_assets_tool_classes/compiler/compiler.h @@ -11,9 +11,10 @@ class AssetCompiler { public: - AssetCompiler(std::string assetsDirectory, std::string version); + AssetCompiler(); ~AssetCompiler(); private: void copy_stuff_from_folders(std::string &packagesDirPath, std::string &outDirPath, std::string &packageName); void append_manifest_files(std::string &packagesDirPath, std::string &outDirPath, std::string &packageName); + void verify_json_files(std::string &folderPath); }; diff --git a/tools/dkr_assets_tool_classes/extractor/config.cpp b/tools/dkr_assets_tool_classes/extractor/config.cpp index 83ccbe46..a0384fb4 100644 --- a/tools/dkr_assets_tool_classes/extractor/config.cpp +++ b/tools/dkr_assets_tool_classes/extractor/config.cpp @@ -136,10 +136,7 @@ std::vector> get_section_files(std::vector& sectio int length = nextTableValue - currentTableValue; if(length < 0) { - std::cout << "Error: Invalid table length: " << length << std::endl; - std::cout << std::hex << "currentTableValue: " << currentTableValue << std::dec << std::endl; - std::cout << std::hex << "nextTableValue: " << nextTableValue << std::dec << std::endl; - throw 1; + display_error_and_abort("Invalid table length: ", length, "\ncurrentTableValue: ", currentTableValue, "\nnextTableValue: ", nextTableValue); } std::vector file(section.begin() + currentTableValue, section.begin() + nextTableValue); @@ -160,10 +157,8 @@ void ExtractConfig::extract_asset_sections(int &romOffset) { int numAssetSectionsFromTable = rom->get_uint(romOffset); if(numAssetSections != numAssetSectionsFromTable) { - std::cout << "Error: Number of asset sections in config does not match ROM." << std::endl; - std::cout << "Number of asset sections in Config: " << numAssetSections << std::endl; - std::cout << "Number of asset sections in ROM: " << numAssetSectionsFromTable << std::endl; - throw 1; + display_error_and_abort("Number of asset sections in config does not match ROM.\nNumber of asset sections in Config: ", + numAssetSections, "\nNumber of asset sections in ROM: ", numAssetSectionsFromTable); } romOffset += 4; @@ -329,8 +324,8 @@ void write_vanilla_warning_file(std::string baseDirectory) { void ExtractConfig::execute_extraction() { // These braces are important, because I want the ThreadPool to call its destructor by going out of scope. { - //ThreadPool pool(std::thread::hardware_concurrency()); - ThreadPool pool(1); + ThreadPool pool(std::thread::hardware_concurrency()); + //ThreadPool pool(1); for(int i = 0; i < extractions.size(); i++) { std::string key = extractions[i].key; @@ -364,8 +359,7 @@ void ExtractConfig::execute_extraction() { ExtractCompressed(key, data, outFilepath + ".cbin"); } else if(type == "Empty") { } else if(type != "NoExtract") { - std::cout << "Unknown extraction type: " << type << std::endl; - throw 1; + display_error_and_abort("Unknown extraction type: ", type); } }); } diff --git a/tools/dkr_assets_tool_classes/extractor/extract/extract_levelheader.cpp b/tools/dkr_assets_tool_classes/extractor/extract/extract_levelheader.cpp index 5670381b..ea0cd7b4 100644 --- a/tools/dkr_assets_tool_classes/extractor/extract/extract_levelheader.cpp +++ b/tools/dkr_assets_tool_classes/extractor/extract/extract_levelheader.cpp @@ -1,92 +1,128 @@ #include "extract_levelheader.h" +// Extracts a bitfield as an array of enum value strings. +json::JSON extract_enum_values(std::vector &data, int offset, int numBytes, std::string enumName) { + json::JSON values = json::Array(); + int bitflags = 0; + for(int i = 0; i < numBytes; i++) { + bitflags |= data[offset + i] << (8 * i); + } + for(int i = 0; bitflags != 0; i++) { + if(bitflags & 1) { + values.append(get_enum_string_from_value(enumName, i)); + } + bitflags >>= 1; + } + return values; +} + ExtractLevelHeader::ExtractLevelHeader(std::string key, std::vector data, std::string outFilepath) : Extract(key, data, outFilepath) { json::JSON out = json::Object(); out["type"] = "LevelHeaders"; - out["unknownData"] = json::Object(); + out["unknown-data"] = json::Object(); + + // World ID out["world"] = get_enum_string_from_value("World", (int8_t)data[0]); - out["unknownData"]["unk1"] = data[1]; - out["unknownData"]["unk2"] = data[2]; - out["unknownData"]["unk3"] = data[3]; - out["unknownData"]["unk4"] = json::Array(); + + out["unknown-data"]["unk1"] = data[1]; + out["unknown-data"]["unk2"] = data[2]; + out["unknown-data"]["unk3"] = data[3]; + out["unknown-data"]["unk4"] = json::Array(); for(int i = 4; i < 8; i++) { - out["unknownData"]["unk4"].append(data[i]); + out["unknown-data"]["unk4"].append(data[i]); } + + // Ceiling height for planes out["ceiling-height"] = get_big_endian_float(data, 8); - out["unknownData"]["unkC"] = json::Array(); + + out["unknown-data"]["unkC"] = json::Array(); for(int i = 0xC; i < 0x34; i++) { - out["unknownData"]["unkC"].append(data[i]); + out["unknown-data"]["unkC"].append(data[i]); } + + // Track Model ID to use int modelId = get_big_endian_halfword(data, 0x34); out["model"] = get_build_id_from_section("ASSET_LEVEL_MODELS", modelId); + + // Collectables bitflags (bananas, balloons, etc) out["collectables"] = get_big_endian_halfword(data, 0x36); + + // Skydome object model ID out["skybox"] = get_big_endian_halfword(data, 0x38); + + // Fog out["fog"] = json::Object(); - out["fog"]["unk3A"] = get_big_endian_halfword(data, 0x3A); - out["fog"]["unk3C"] = get_big_endian_halfword(data, 0x3C); - out["fog"]["red"] = get_big_endian_halfword(data, 0x3E); - out["fog"]["green"] = get_big_endian_halfword(data, 0x40); - out["fog"]["blue"] = get_big_endian_halfword(data, 0x42); + out["fog"]["range"] = json::Object(); + out["fog"]["range"]["min"] = get_big_endian_halfword(data, 0x3A); + out["fog"]["range"]["max"] = get_big_endian_halfword(data, 0x3C); + out["fog"]["colour"] = json::Object(); + out["fog"]["colour"]["red"] = get_big_endian_halfword(data, 0x3E); + out["fog"]["colour"]["green"] = get_big_endian_halfword(data, 0x40); + out["fog"]["colour"]["blue"] = get_big_endian_halfword(data, 0x42); + for(int i = 0x44; i < 0x4B; i++) { - out["unknownData"]["unk44"].append(data[i]); + out["unknown-data"]["unk44"].append(data[i]); } + + // Number of laps to complete the race out["number-laps"] = data[0x4B]; + + // Type of race (standard, boss race, hub world, etc. out["race-type"] = get_enum_string_from_value("RaceType", data[0x4C]); + + // Default vehicle used for this track. (Either Car, Hovercraft, or Plane) out["default-vehicle"] = get_enum_string_from_value("Vehicle", data[0x4D]); - out["available-vehicles"] = json::Array(); - int avaliableVehicles = data[0x4E]; - for(int i = 0; i < 3; i++) { - if(avaliableVehicles & (1 << i)) { - out["available-vehicles"].append(get_enum_string_from_value("Vehicle", i)); - } - } - out["unknownData"]["unk4F"] = json::Array(); + + // Which vehicles can be used in this track (Either Car, Hovercraft, or Plane) + out["available-vehicles"] = extract_enum_values(data, 0x4E, 1, "Vehicle"); + + out["unknown-data"]["unk4F"] = json::Array(); for(int i = 0x4F; i < 0x52; i++) { - out["unknownData"]["unk4F"].append(data[i]); + out["unknown-data"]["unk4F"].append(data[i]); } out["music"] = data[0x52]; - out["unknownData"]["unk53"] = data[0x53]; + out["unknown-data"]["unk53"] = data[0x53]; out["instruments"] = get_big_endian_halfword(data, 0x54); - out["unknownData"]["unk56"] = json::Array(); + out["unknown-data"]["unk56"] = json::Array(); for(int i = 0x56; i < 0x74; i++) { - out["unknownData"]["unk56"].append(data[i]); + out["unknown-data"]["unk56"].append(data[i]); } - out["unknownData"]["unk74"] = json::Array(); + out["unknown-data"]["unk74"] = json::Array(); for(int i = 0; i < 7; i++) { int ptr = get_big_endian_word(data, 0x74 + (i*4)); - out["unknownData"]["unk74"].append(ptr); + out["unknown-data"]["unk74"].append(ptr); } - out["unknownData"]["weather"] = json::Object(); - out["unknownData"]["weather"]["unk90"] = (int)get_big_endian_halfword(data, 0x90); - out["unknownData"]["weather"]["unk92"] = (int)get_big_endian_halfword(data, 0x92); - out["unknownData"]["weather"]["unk94"] = data[0x94]; - out["unknownData"]["weather"]["unk95"] = data[0x95]; - out["unknownData"]["weather"]["unk96"] = (int)get_big_endian_halfword(data, 0x96); - out["unknownData"]["weather"]["unk98"] = (int)get_big_endian_halfword(data, 0x98); - out["unknownData"]["weather"]["unk9A"] = (int)get_big_endian_halfword(data, 0x9A); + out["unknown-data"]["weather"] = json::Object(); + out["unknown-data"]["weather"]["unk90"] = (int)get_big_endian_halfword(data, 0x90); + out["unknown-data"]["weather"]["unk92"] = (int)get_big_endian_halfword(data, 0x92); + out["unknown-data"]["weather"]["unk94"] = data[0x94]; + out["unknown-data"]["weather"]["unk95"] = data[0x95]; + out["unknown-data"]["weather"]["unk96"] = (int)get_big_endian_halfword(data, 0x96); + out["unknown-data"]["weather"]["unk98"] = (int)get_big_endian_halfword(data, 0x98); + out["unknown-data"]["weather"]["unk9A"] = (int)get_big_endian_halfword(data, 0x9A); out["fov"] = data[0x9C]; - out["backgroundColor"] = json::Object(); - out["backgroundColor"]["red"] = data[0x9D]; - out["backgroundColor"]["green"] = data[0x9E]; - out["backgroundColor"]["blue"] = data[0x9F]; - out["unknownData"]["unkA0"] = json::Array(); + out["background-colour"] = json::Object(); + out["background-colour"]["red"] = data[0x9D]; + out["background-colour"]["green"] = data[0x9E]; + out["background-colour"]["blue"] = data[0x9F]; + out["unknown-data"]["unkA0"] = json::Array(); for(int i = 0xA0; i < 0xA4; i++) { - out["unknownData"]["unkA0"].append(data[i]); + out["unknown-data"]["unkA0"].append(data[i]); } - out["unknownData"]["unkA4"] = (int)get_big_endian_word(data, 0xA4); - out["unknownData"]["unkA8"] = (int)get_big_endian_halfword(data, 0xA8); - out["unknownData"]["unkAA"] = (int)get_big_endian_halfword(data, 0xAA); + out["unknown-data"]["unkA4"] = (int)get_big_endian_word(data, 0xA4); + out["unknown-data"]["unkA8"] = (int)get_big_endian_halfword(data, 0xA8); + out["unknown-data"]["unkAA"] = (int)get_big_endian_halfword(data, 0xAA); int pulsatingLightsOffset = (int)get_big_endian_word(data, 0xAC); if(pulsatingLightsOffset != -1) { out["pulsating-lights"] = get_build_id_from_section("ASSET_MISC", pulsatingLightsOffset); } - out["unknownData"]["unkB0"] = json::Array(); + out["unknown-data"]["unkB0"] = json::Array(); for(int i = 0xB0; i < 0xC4; i++) { - out["unknownData"]["unkB0"].append(data[i]); + out["unknown-data"]["unkB0"].append(data[i]); } - out["unknownData"]["unkC4"] = (int)get_big_endian_word(data, 0xC4); + out["unknown-data"]["unkC4"] = (int)get_big_endian_word(data, 0xC4); write_json(out, outFilepath); print_extracted(); diff --git a/tools/dkr_assets_tool_classes/extractor/extract/extract_textures.cpp b/tools/dkr_assets_tool_classes/extractor/extract/extract_textures.cpp index 65d6b74f..b4046fd8 100644 --- a/tools/dkr_assets_tool_classes/extractor/extract/extract_textures.cpp +++ b/tools/dkr_assets_tool_classes/extractor/extract/extract_textures.cpp @@ -189,13 +189,11 @@ void ExtractTextures::write_images(std::string outImagePath, std::vector