mirror of
https://github.com/izzy2lost/Diddy-Kong-Racing.git
synced 2026-06-19 01:16:26 -07:00
Fixed bugs & readded dkr_decompressor to make the build OK again
This commit is contained in:
@@ -54,6 +54,7 @@ FixPath = $(subst /,,$1)
|
||||
|
||||
N64CRC = $(TOOLS_DIR)/n64crc
|
||||
TEXBUILDER = $(TOOLS_DIR)/dkr_texbuilder
|
||||
COMPRESS = $(TOOLS_DIR)/dkr_decompressor -c
|
||||
|
||||
ASM_DIRS := asm asm/boot asm/assets
|
||||
SRC_DIRS := src
|
||||
@@ -95,18 +96,21 @@ BINS_BUILT := $(patsubst $(BINS_IN_DIR)/%.bin,$(BINS_OUT_DIR)/%.bin,$(BINS))
|
||||
|
||||
ANIMATIONS_IN_DIR = $(ASSETS_DIR)/animations
|
||||
ANIMATIONS_OUT_DIR = $(BUILD_DIR)/animations
|
||||
ANIMATIONS = $(wildcard $(ANIMATIONS_IN_DIR)/*.bin)
|
||||
ANIMATIONS_BUILT := $(patsubst $(ANIMATIONS_IN_DIR)/%.bin,$(ANIMATIONS_OUT_DIR)/%.bin,$(ANIMATIONS))
|
||||
ANIMATIONS = $(wildcard $(ANIMATIONS_IN_DIR)/*.bin $(ANIMATIONS_IN_DIR)/*.cbin)
|
||||
ANIMATIONS_BUILT = $(patsubst $(ANIMATIONS_IN_DIR)/%.bin,$(ANIMATIONS_OUT_DIR)/%.bin,$(ANIMATIONS))
|
||||
ANIMATIONS_BUILT += $(patsubst $(ANIMATIONS_IN_DIR)/%.cbin,$(ANIMATIONS_OUT_DIR)/%.cbin,$(ANIMATIONS))
|
||||
|
||||
LEVELS_IN_DIR = $(ASSETS_DIR)/levels
|
||||
LEVELS_OUT_DIR = $(BUILD_DIR)/levels
|
||||
LEVELS = $(wildcard $(LEVELS_IN_DIR)/*.bin)
|
||||
LEVELS_BUILT := $(patsubst $(LEVELS_IN_DIR)/%.bin,$(LEVELS_OUT_DIR)/%.bin,$(LEVELS))
|
||||
LEVELS = $(wildcard $(LEVELS_IN_DIR)/*.bin $(LEVELS_IN_DIR)/*.cbin)
|
||||
LEVELS_BUILT = $(patsubst $(LEVELS_IN_DIR)/%.bin,$(LEVELS_OUT_DIR)/%.bin,$(LEVELS))
|
||||
LEVELS_BUILT += $(patsubst $(LEVELS_IN_DIR)/%.cbin,$(LEVELS_OUT_DIR)/%.cbin,$(LEVELS))
|
||||
|
||||
OBJECTS_IN_DIR = $(ASSETS_DIR)/objects
|
||||
OBJECTS_OUT_DIR = $(BUILD_DIR)/objects
|
||||
OBJECTS = $(wildcard $(OBJECTS_IN_DIR)/*.bin)
|
||||
OBJECTS_BUILT := $(patsubst $(OBJECTS_IN_DIR)/%.bin,$(OBJECTS_OUT_DIR)/%.bin,$(OBJECTS))
|
||||
OBJECTS = $(wildcard $(OBJECTS_IN_DIR)/*.bin $(OBJECTS_IN_DIR)/*.cbin)
|
||||
OBJECTS_BUILT = $(patsubst $(OBJECTS_IN_DIR)/%.bin,$(OBJECTS_OUT_DIR)/%.bin,$(OBJECTS))
|
||||
OBJECTS_BUILT += $(patsubst $(OBJECTS_IN_DIR)/%.cbin,$(OBJECTS_OUT_DIR)/%.cbin,$(OBJECTS))
|
||||
|
||||
TEXT_IN_DIR = $(ASSETS_DIR)/text
|
||||
TEXT_OUT_DIR = $(BUILD_DIR)/text
|
||||
@@ -144,15 +148,24 @@ dont_remove_asset_files: $(ALL_ASSETS_BUILT)
|
||||
$(ANIMATIONS_OUT_DIR)/%.bin: $(ANIMATIONS_IN_DIR)/%.bin
|
||||
$(ASSETS_OBJCOPY) $^ $@
|
||||
|
||||
$(ANIMATIONS_OUT_DIR)/%.cbin: $(ANIMATIONS_IN_DIR)/%.cbin
|
||||
$(COMPRESS) $^ $@
|
||||
|
||||
$(BINS_OUT_DIR)/%.bin: $(BINS_IN_DIR)/%.bin
|
||||
$(ASSETS_OBJCOPY) $^ $@
|
||||
|
||||
$(LEVELS_OUT_DIR)/%.bin: $(LEVELS_IN_DIR)/%.bin
|
||||
$(ASSETS_OBJCOPY) $^ $@
|
||||
|
||||
$(LEVELS_OUT_DIR)/%.cbin: $(LEVELS_IN_DIR)/%.cbin
|
||||
$(COMPRESS) $^ $@
|
||||
|
||||
$(OBJECTS_OUT_DIR)/%.bin: $(OBJECTS_IN_DIR)/%.bin
|
||||
$(ASSETS_OBJCOPY) $^ $@
|
||||
|
||||
$(OBJECTS_OUT_DIR)/%.cbin: $(OBJECTS_IN_DIR)/%.cbin
|
||||
$(COMPRESS) $^ $@
|
||||
|
||||
$(TEXTURES_OUT_DIR)/%.bin: $(TEXTURES_IN_DIR)/%.png
|
||||
$(call build_texture,$^)
|
||||
@echo $@
|
||||
|
||||
+4413
-1051
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,4 @@
|
||||
/n64crc
|
||||
/dkr_decompressor
|
||||
/dkr_extractor
|
||||
/dkr_texbuilder
|
||||
+4
-1
@@ -3,12 +3,15 @@ CXX := g++
|
||||
CFLAGS := -I . -Wall -Wextra -Wno-unused-parameter -pedantic -std=c99 -O2 -s
|
||||
LDFLAGS := -lm
|
||||
PROGRAMS := n64crc
|
||||
CXX_PROGRAMS := dkr_extractor dkr_texbuilder
|
||||
CXX_PROGRAMS := dkr_decompressor dkr_extractor dkr_texbuilder
|
||||
|
||||
default: all
|
||||
|
||||
n64crc_SOURCES := n64crc.c
|
||||
|
||||
dkr_decompressor_SOURCES := dkr_decompressor.cpp $(wildcard dkr_decompressor_src/*.cpp dkr_decompressor_src/*.c)
|
||||
dkr_decompressor_CXXFLAGS := -lstdc++fs -lcrypto -lssl
|
||||
|
||||
dkr_extractor_SOURCES := dkr_extractor.cpp $(wildcard dkr_decompressor_src/*.cpp dkr_decompressor_src/*.c dkr_extractor_classes/*.cpp n64graphics/*.c)
|
||||
dkr_extractor_CXXFLAGS := -lstdc++fs -lcrypto -lssl
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdlib>
|
||||
#include "dkr_decompressor_src/DKRCompression.h"
|
||||
|
||||
void printHelp()
|
||||
{
|
||||
std::cout
|
||||
<< "---- Usage ----" << std::endl
|
||||
<< " Compress file: ./dkr_decompressor -c <input_filename> <output_filename>" << std::endl
|
||||
<< " Decompress file: ./dkr_decompressor -d <input_filename> <output_filename>" << std::endl;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if(argc == 1)
|
||||
{
|
||||
printHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
std::string option = std::string(argv[1]);
|
||||
|
||||
bool fileOptionCheck = ((option == "-d" || option == "-c") && argc != 4);
|
||||
bool invalidOptionCheck = (option != "-d" && option != "-c");
|
||||
|
||||
if(fileOptionCheck || invalidOptionCheck)
|
||||
{
|
||||
printHelp();
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
DKRCompression compression;
|
||||
|
||||
std::string inputFilename = std::string(argv[2]);
|
||||
std::string outputFilename = std::string(argv[3]);
|
||||
std::vector<uint8_t> inputBinary, outputBinary;
|
||||
|
||||
if(compression.readBinaryFile(inputBinary, inputFilename))
|
||||
{
|
||||
if (option == "-c")
|
||||
{
|
||||
outputBinary = compression.compressBuffer(inputBinary);
|
||||
}
|
||||
else if (option == "-d")
|
||||
{
|
||||
outputBinary = compression.decompressBuffer(inputBinary);
|
||||
}
|
||||
|
||||
compression.writeBinaryFile(outputBinary, outputFilename);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Could not read file: " << inputFilename << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ void write_binary_file(std::vector<uint8_t>& data, std::string& filename) {
|
||||
wf.close();
|
||||
}
|
||||
|
||||
void extract_binary(std::vector<uint8_t>& data, int startOffset, int endOffset, std::string& name, std::string& subfolder, std::string& outFolder) {
|
||||
void extract_binary(std::vector<uint8_t>& data, int startOffset, int endOffset, std::string& name, const char* extension, std::string& subfolder, std::string& outFolder) {
|
||||
// std::cout << "Extracting Binary! " << startHex << std::endl;
|
||||
std::stringstream hexStream, rangeStream, filenameStream;
|
||||
|
||||
@@ -87,13 +87,15 @@ void extract_binary(std::vector<uint8_t>& data, int startOffset, int endOffset,
|
||||
fs::create_directories(outputDirectory);
|
||||
}
|
||||
|
||||
filenameStream << outputDirectory << "/" << name << "." << startHex << ".bin";
|
||||
filenameStream << outputDirectory << "/" << name << "." << startHex << extension;
|
||||
std::string filename = filenameStream.str();
|
||||
|
||||
// Make sure the file is 16-byte aligned.
|
||||
/*
|
||||
while(data.size() % 16 != 0) {
|
||||
data.push_back(0);
|
||||
}
|
||||
*/
|
||||
|
||||
write_binary_file(data, filename);
|
||||
|
||||
@@ -109,7 +111,7 @@ void extract_compressed(std::vector<uint8_t>& data, int startOffset, int endOffs
|
||||
data.push_back(0);
|
||||
}
|
||||
data = compression.decompressBuffer(data);
|
||||
extract_binary(data, startOffset, endOffset, name, subfolder, outFolder);
|
||||
extract_binary(data, startOffset, endOffset, name, ".cbin", subfolder, outFolder);
|
||||
}
|
||||
|
||||
int get_texture_size(int width, int height, int textureFormat) {
|
||||
@@ -366,7 +368,7 @@ void extract_range(std::string subfolder, ConfigRange& range, ROM& rom) {
|
||||
case ConfigRangeType::BINARY:
|
||||
{
|
||||
std::vector<uint8_t> data = rom.get_bytes_from_range(startOffset, range.get_size());
|
||||
extract_binary(data, startOffset, endOffset, name, subfolder, outFolder);
|
||||
extract_binary(data, startOffset, endOffset, name, ".bin", subfolder, outFolder);
|
||||
numberOfFilesExtracted++;
|
||||
break;
|
||||
}
|
||||
|
||||
+73
-31
@@ -35,12 +35,17 @@ bool starts_with(std::string filename, std::string pattern) {
|
||||
return std::equal(pattern.begin(), pattern.end(), filename.begin());
|
||||
}
|
||||
|
||||
std::vector<std::tuple<std::string, std::string>> get_filenames_from_directory(std::string directory, std::string name) {
|
||||
std::vector<std::tuple<std::string, std::string>> filenames;
|
||||
std::vector<std::tuple<std::string, std::string, int>> get_filenames_from_directory(std::string directory, std::string name) {
|
||||
std::vector<std::tuple<std::string, std::string, int>> filenames;
|
||||
int start, end;
|
||||
std::string indexString;
|
||||
for (const auto & entry : fs::directory_iterator(directory)){
|
||||
std::string filename = entry.path().filename();
|
||||
if(starts_with(filename, name)) {
|
||||
filenames.push_back(std::make_tuple(filename, entry.path().string()));
|
||||
start = filename.find('.');
|
||||
start = filename.find('.', start + 1) + 1;
|
||||
end = filename.find('.', start);
|
||||
filenames.push_back(std::make_tuple(filename, entry.path().string(), std::stoi(filename.substr(start, end - start))));
|
||||
}
|
||||
}
|
||||
return filenames;
|
||||
@@ -169,19 +174,21 @@ std::vector<uint8_t> load_texture_from_png(std::string filepath, int textureForm
|
||||
}
|
||||
}
|
||||
|
||||
#define ALIGN16(val) ((val) + 15) & 0xFFFFFFF0
|
||||
|
||||
int get_texture_size(int width, int height, int textureFormat) {
|
||||
switch(textureFormat) {
|
||||
case TEX_FORMAT_RGBA32:
|
||||
return (width * height * 4) + TEX_HEADER_SIZE;
|
||||
return ALIGN16((width * height * 4) + TEX_HEADER_SIZE);
|
||||
case TEX_FORMAT_RGBA16:
|
||||
case TEX_FORMAT_IA16:
|
||||
return (width * height * 2) + TEX_HEADER_SIZE;
|
||||
return ALIGN16((width * height * 2) + TEX_HEADER_SIZE);
|
||||
case TEX_FORMAT_I8:
|
||||
case TEX_FORMAT_IA8:
|
||||
return (width * height) + TEX_HEADER_SIZE;
|
||||
return ALIGN16((width * height) + TEX_HEADER_SIZE);
|
||||
case TEX_FORMAT_I4:
|
||||
case TEX_FORMAT_IA4:
|
||||
return (width * height / 2) + TEX_HEADER_SIZE;
|
||||
return ALIGN16((width * height / 2) + TEX_HEADER_SIZE);
|
||||
case TEX_FORMAT_CI4:
|
||||
std::cout << "Error: CI4 texture format is not currently supported." << std::endl;
|
||||
throw 1;
|
||||
@@ -192,7 +199,7 @@ int get_texture_size(int width, int height, int textureFormat) {
|
||||
}
|
||||
|
||||
void generate_texture_header(std::vector<uint8_t>& outData, int width, int height, int textureFormat,
|
||||
int numberOfTextures, std::string flags, std::string headerBytes) {
|
||||
int numberOfTextures, std::string flags, std::string headerBytes, bool& forceAlignment) {
|
||||
// I currently do not know what these are for.
|
||||
int A = std::stoi(headerBytes.substr(0, 1), 0, 16);
|
||||
int B = std::stoi(headerBytes.substr(1, 2), 0, 16);
|
||||
@@ -230,9 +237,11 @@ void generate_texture_header(std::vector<uint8_t>& outData, int width, int heigh
|
||||
if(dontComputeSize) {
|
||||
/* 0x16 */ outData.push_back(0); // Keep it zero, Not sure why though.
|
||||
outData.push_back(0);
|
||||
forceAlignment = true;
|
||||
} else {
|
||||
/* 0x16 */ outData.push_back((textureSize >> 8) & 0xFF); // Texture size
|
||||
outData.push_back(textureSize & 0xFF);
|
||||
forceAlignment = false;
|
||||
}
|
||||
/* 0x18 */ outData.push_back(0);
|
||||
/* 0x19 */ outData.push_back(0);
|
||||
@@ -264,7 +273,7 @@ int get_bitdepth_from_format(int textureFormat){
|
||||
}
|
||||
|
||||
// std::get<0>(file) = filename, std::get<1>(file) = filepath
|
||||
std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> file, int numberOfTextures) {
|
||||
std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string, int> file, int numberOfTextures) {
|
||||
std::vector<uint8_t> outData;
|
||||
|
||||
std::vector<std::string> elems = split(std::get<0>(file), '.');
|
||||
@@ -278,17 +287,17 @@ std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> fil
|
||||
|
||||
std::vector<uint8_t> pngData = load_texture_from_png(std::get<1>(file), textureFormat, &width, &height);
|
||||
|
||||
if(flipVertically) {
|
||||
flip_vertically(pngData, width, height, get_bitdepth_from_format(textureFormat));
|
||||
}
|
||||
|
||||
generate_texture_header(outData, width, height, textureFormat, numberOfTextures, flags, headerBytes);
|
||||
bool forceAlignment;
|
||||
generate_texture_header(outData, width, height, textureFormat, numberOfTextures, flags, headerBytes, forceAlignment);
|
||||
|
||||
bool interlace = ((outData[0x06] & 0x4) == 0x04);
|
||||
|
||||
switch(textureFormat) {
|
||||
case TEX_FORMAT_RGBA32:
|
||||
{
|
||||
if(flipVertically) {
|
||||
flip_vertically(pngData, width, height, 32);
|
||||
}
|
||||
if (interlace) {
|
||||
deinterlace(pngData, width, height, 32, 8);
|
||||
}
|
||||
@@ -301,6 +310,9 @@ std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> fil
|
||||
rgba2raw(rgba16Data, (const rgba*)&pngData[0], width, height, 16);
|
||||
std::vector<uint8_t> rgba16(rgba16Data, rgba16Data + (width * height * 2));
|
||||
free(rgba16Data);
|
||||
if(flipVertically) {
|
||||
flip_vertically(rgba16, width, height, 16);
|
||||
}
|
||||
if (interlace) {
|
||||
deinterlace(rgba16, width, height, 16, 4);
|
||||
}
|
||||
@@ -313,6 +325,9 @@ std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> fil
|
||||
i2raw(i8Data, (const ia*)&pngData[0], width, height, 8);
|
||||
std::vector<uint8_t> i8(i8Data, i8Data + (width * height));
|
||||
free(i8Data);
|
||||
if(flipVertically) {
|
||||
flip_vertically(i8, width, height, 8);
|
||||
}
|
||||
if (interlace) {
|
||||
deinterlace(i8, width, height, 8, 4);
|
||||
}
|
||||
@@ -325,6 +340,9 @@ std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> fil
|
||||
i2raw(i4Data, (const ia*)&pngData[0], width, height, 4);
|
||||
std::vector<uint8_t> i4(i4Data, i4Data + (width * height / 2));
|
||||
free(i4Data);
|
||||
if(flipVertically) {
|
||||
flip_vertically(i4, width, height, 4);
|
||||
}
|
||||
if (interlace) {
|
||||
deinterlace(i4, width, height, 4, 4);
|
||||
}
|
||||
@@ -337,6 +355,9 @@ std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> fil
|
||||
ia2raw(ia16Data, (const ia*)&pngData[0], width, height, 16);
|
||||
std::vector<uint8_t> ia16(ia16Data, ia16Data + (width * height * 2));
|
||||
free(ia16Data);
|
||||
if(flipVertically) {
|
||||
flip_vertically(ia16, width, height, 16);
|
||||
}
|
||||
if (interlace) {
|
||||
deinterlace(ia16, width, height, 16, 4);
|
||||
}
|
||||
@@ -349,6 +370,9 @@ std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> fil
|
||||
ia2raw(ia8Data, (const ia*)&pngData[0], width, height, 8);
|
||||
std::vector<uint8_t> ia8(ia8Data, ia8Data + (width * height));
|
||||
free(ia8Data);
|
||||
if(flipVertically) {
|
||||
flip_vertically(ia8, width, height, 8);
|
||||
}
|
||||
if (interlace) {
|
||||
deinterlace(ia8, width, height, 8, 4);
|
||||
}
|
||||
@@ -361,6 +385,9 @@ std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> fil
|
||||
ia2raw(ia4Data, (const ia*)&pngData[0], width, height, 4);
|
||||
std::vector<uint8_t> ia4(ia4Data, ia4Data + (width * height / 2));
|
||||
free(ia4Data);
|
||||
if(flipVertically) {
|
||||
flip_vertically(ia4, width, height, 4);
|
||||
}
|
||||
if (interlace) {
|
||||
deinterlace(ia4, width, height, 4, 4);
|
||||
}
|
||||
@@ -369,6 +396,12 @@ std::vector<uint8_t> get_texture_binary(std::tuple<std::string, std::string> fil
|
||||
}
|
||||
}
|
||||
|
||||
if(forceAlignment) {
|
||||
while(outData.size() % 16 != 0) {
|
||||
outData.push_back(0);
|
||||
}
|
||||
}
|
||||
|
||||
return outData;
|
||||
}
|
||||
|
||||
@@ -386,39 +419,48 @@ int main(int argc, char* argv[]) {
|
||||
std::string out_texture_name = argv[4];
|
||||
std::string outFilename;
|
||||
|
||||
std::vector<std::tuple<std::string, std::string>> files = get_filenames_from_directory(input_directory, texture_name);
|
||||
std::vector<std::tuple<std::string, std::string, int>> files = get_filenames_from_directory(input_directory, texture_name);
|
||||
|
||||
int numberOfTextures = files.size();
|
||||
std::vector<uint8_t> uncompressed;
|
||||
|
||||
std::vector<uint8_t> binaries[numberOfTextures];
|
||||
|
||||
//std::cout << "Number of textures: " << numberOfTextures << std::endl;
|
||||
for(int i = 0; i < numberOfTextures; i++) {
|
||||
//std::cout << std::get<0>(files[i]) << std::endl;
|
||||
std::vector<uint8_t> binary = get_texture_binary(files[i], numberOfTextures);
|
||||
uncompressed.insert(uncompressed.end(), binary.begin(), binary.end());
|
||||
// std::cout << '#' << std::get<0>(files[i]) << std::endl;
|
||||
binaries[std::get<2>(files[i])] = get_texture_binary(files[i], numberOfTextures);
|
||||
}
|
||||
|
||||
//outFilename = output_filepath + "/" + texture_name + ".uncmp.bin";
|
||||
//write_binary_file(uncompressed, outFilename);
|
||||
std::vector<uint8_t> uncompressed;
|
||||
for(int i = 0; i < numberOfTextures; i++) {
|
||||
uncompressed.insert(uncompressed.end(), binaries[i].begin(), binaries[i].end());
|
||||
}
|
||||
|
||||
// DEBUG
|
||||
// outFilename = output_filepath + "/" + texture_name + ".uncmp.bin";
|
||||
// write_binary_file(uncompressed, outFilename);
|
||||
|
||||
std::vector<uint8_t> compressedHeader;
|
||||
compressedHeader.insert(compressedHeader.end(), uncompressed.begin(), uncompressed.begin() + 0x20);
|
||||
|
||||
outFilename = output_filepath + "/" + out_texture_name + ".bin";
|
||||
|
||||
std::string flags = split(std::get<0>(files[0]), '.')[3];
|
||||
if(flags.at(0) == 'C') {
|
||||
compressedHeader[0x1D] = 0x01;
|
||||
|
||||
DKRCompression compression;
|
||||
std::vector<uint8_t> compressed = compression.compressBuffer(uncompressed);
|
||||
|
||||
// Note: uncompressed is garbled at this point.
|
||||
|
||||
compressed.insert(compressed.begin(), compressedHeader.begin(), compressedHeader.end());
|
||||
|
||||
write_binary_file(compressed, outFilename);
|
||||
} else {
|
||||
write_binary_file(uncompressed, outFilename);
|
||||
}
|
||||
|
||||
DKRCompression compression;
|
||||
std::vector<uint8_t> compressed = compression.compressBuffer(uncompressed);
|
||||
|
||||
// Note: uncompressed is garbled at this point.
|
||||
|
||||
compressed.insert(compressed.begin(), compressedHeader.begin(), compressedHeader.end());
|
||||
|
||||
outFilename = output_filepath + "/" + out_texture_name + ".bin";
|
||||
write_binary_file(compressed, outFilename);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,8 @@ class LD:
|
||||
if fileExtension == '.png' and int(fileProperties[1]) != 0:
|
||||
continue
|
||||
ramAddress = fileProperties[0]
|
||||
outFilename = 'build/' + matchedGroups[0] + '.' + matchedGroups[1] + '.bin'
|
||||
outFileExtension = '.cbin' if fileExtension == '.cbin' else '.bin'
|
||||
outFilename = 'build/' + matchedGroups[0] + '.' + matchedGroups[1] + outFileExtension
|
||||
if int(ramAddress, 16) >= ASSETS_START:
|
||||
assetFiles.append((outFilename, ramAddress, fileExtension))
|
||||
assetFiles.sort(key = lambda x: x[1]) # Sort tuples by RAM address
|
||||
@@ -160,8 +161,16 @@ class LD:
|
||||
def generate_assets_file(self):
|
||||
assets = self.get_asset_files()
|
||||
assetsText = '# This file was generated by generate_ld.py\n\n'
|
||||
prevAssetMadeAlignment = False
|
||||
for asset in assets:
|
||||
if 'lut' in asset[0] and not prevAssetMadeAlignment:
|
||||
assetsText += '.balign 16\n'
|
||||
assetsText += '.incbin "./' + asset[0] + '"\n'
|
||||
if asset[2] == '.png' or asset[2] == '.cbin': # Make sure that compressed data ends on a 16-byte boundary
|
||||
assetsText += '.balign 16\n'
|
||||
prevAssetMadeAlignment = True
|
||||
else:
|
||||
prevAssetMadeAlignment = False
|
||||
with open(ASSETS_S_FILENAME, "w") as assetsFile:
|
||||
assetsFile.write(assetsText)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user