mirror of
https://github.com/GearsProgress/Poke_Transporter_GB.git
synced 2026-03-21 17:34:42 -05:00
Merge pull request #78 from risingPhil:use-pccs-as-a-proper-static-lib
Use pccs as a proper static lib
This commit is contained in:
commit
8347f63286
36
Makefile
36
Makefile
|
|
@ -11,10 +11,15 @@ endif
|
|||
|
||||
include $(DEVKITARM)/gba_rules
|
||||
|
||||
# The directory this makefile is located in.
|
||||
# This is relevant when the second stage of this Makefile is called from the build directory.
|
||||
MKFILE_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# the LIBGBA path is defined in gba_rules, but we have to define LIBTONC ourselves
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBTONC := $(DEVKITPRO)/libtonc
|
||||
LIBPCCS := $(CURDIR)/PCCS
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
|
|
@ -30,7 +35,7 @@ LIBTONC := $(DEVKITPRO)/libtonc
|
|||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))_mb
|
||||
BUILD := build
|
||||
SOURCES := source PCCS/lib/source
|
||||
SOURCES := source
|
||||
INCLUDES := include PCCS/lib/include
|
||||
DATA := data
|
||||
MUSIC := audio
|
||||
|
|
@ -73,7 +78,7 @@ endif
|
|||
#---------------------------------------------------------------------------------
|
||||
# any extra libraries we wish to link with the project
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBS := -lmm -ltonc -lgba -lc -lgcc -lsysbase
|
||||
LIBS := -lmm -ltonc -lgba -lc -lgcc -lsysbase -lpccs
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
|
|
@ -81,7 +86,7 @@ LIBS := -lmm -ltonc -lgba -lc -lgcc -lsysbase
|
|||
# include and lib.
|
||||
# the LIBGBA path should remain in this list if you want to use maxmod
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(LIBGBA) $(LIBTONC)
|
||||
LIBDIRS := $(LIBGBA) $(LIBTONC) $(LIBPCCS)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
|
|
@ -135,7 +140,7 @@ export HFILES := $(addsuffix .h,$(subst .,_,$(BINFILES))) $(PNGFILES:.png=.h)
|
|||
export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD) \
|
||||
-I$(CURDIR)/tools/data-generator/include
|
||||
-I$(CURDIR)/tools/payload-generator/include
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
|
|
@ -146,11 +151,21 @@ all: $(BUILD)
|
|||
generate_data:
|
||||
mkdir -p data
|
||||
mkdir -p to_compress
|
||||
@env -i "PATH=$(PATH)" $(MAKE) -C tools/data-generator
|
||||
@env - \
|
||||
PATH="$(PATH)" \
|
||||
TMPDIR=/tmp TMP=/tmp TEMP=/tmp \
|
||||
SYSTEMROOT="$(SYSTEMROOT)" \
|
||||
CC=cc \
|
||||
CXX=c++ \
|
||||
CFLAGS= \
|
||||
CXXFLAGS= \
|
||||
LDFLAGS= \
|
||||
AR=ar \
|
||||
$(MAKE) -C tools/payload-generator
|
||||
@echo
|
||||
@echo "----------------------------------------------------------------"
|
||||
@echo
|
||||
@tools/data-generator/data-generator to_compress
|
||||
@tools/payload-generator/payload-generator to_compress
|
||||
@python3 text_helper/main.py
|
||||
@echo "Compressing bin files!"
|
||||
@echo -n "["
|
||||
|
|
@ -164,6 +179,12 @@ generate_data:
|
|||
#---------------------------------------------------------------------------------
|
||||
$(BUILD): generate_data
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) -C PCCS \
|
||||
CC="$(CC)" \
|
||||
CXX="$(CXX)" \
|
||||
CFLAGS="$(CFLAGS)" \
|
||||
CXXFLAGS="$(CXXFLAGS)" \
|
||||
LDFLAGS="$(LDFLAGS)"
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
@mkdir -p loader/data
|
||||
@cp $(TARGET).gba loader/data/multiboot_rom.bin
|
||||
|
|
@ -172,8 +193,9 @@ $(BUILD): generate_data
|
|||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@$(MAKE) -C tools/data-generator clean
|
||||
@$(MAKE) -C tools/payload-generator clean
|
||||
@$(MAKE) -C loader clean
|
||||
@$(MAKE) -C PCCS clean
|
||||
@rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba data/ to_compress/
|
||||
@rm -f text_helper/output.json
|
||||
|
||||
|
|
|
|||
2
PCCS
2
PCCS
|
|
@ -1 +1 @@
|
|||
Subproject commit 289ded81568b847da1702c565ef6296e7d5e1abf
|
||||
Subproject commit 1c98a391c2261c8141c8917160b2040514a0c2ee
|
||||
|
|
@ -521,7 +521,7 @@ for lang in Languages:
|
|||
|
||||
# now generate the cpp file.
|
||||
with open(os.curdir + '/source/translated_text.cpp', 'w') as cppFile:
|
||||
cppFile.write("#include \"translated_text.h\"\n#include \"debug_mode.h\"\n#include \"extern_pokemon_data.h\"\n")
|
||||
cppFile.write("#include \"translated_text.h\"\n#include \"debug_mode.h\"\n")
|
||||
# generate includes for each language
|
||||
for lang in Languages:
|
||||
for cat in mainDict[lang.name]:
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
#ifndef _COMMON_H
|
||||
#define _COMMON_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
||||
void writeTable(const char *input_path, const char *output_path, const char *filename, const char *buffer, size_t buffer_size);
|
||||
void generate_pokemon_data(const char *output_path);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef _POKEMON_DATA_H
|
||||
#define _POKEMON_DATA_H
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#define NUM_POKEMON 252
|
||||
#define POKEMON_ARRAY_SIZE NUM_POKEMON + 1
|
||||
|
||||
#ifndef TONC_TYPES
|
||||
typedef uint8_t u8;
|
||||
typedef uint8_t byte;
|
||||
typedef uint16_t u16;
|
||||
typedef uint32_t u32;
|
||||
#endif
|
||||
|
||||
void generate_pokemon_data(const char *output_path);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
#include "common.h"
|
||||
#include "extern_pokemon_data.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <filesystem>
|
||||
|
||||
// Data pulled from https://docs.google.com/spreadsheets/d/14LLs5lLqWasFcssBmJdGXjjYxARAJBa_QUOUhXZt4v8/edit
|
||||
|
||||
void writeTable(const char *input_path, const char *output_path, const char *filename, const char *buffer, size_t buffer_size)
|
||||
{
|
||||
char full_output_path[4096];
|
||||
|
||||
FILE *f;
|
||||
|
||||
if (output_path[0] != '\0')
|
||||
{
|
||||
snprintf(full_output_path, sizeof(full_output_path), "%s/%s", output_path, filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(full_output_path, filename, sizeof(full_output_path));
|
||||
}
|
||||
|
||||
if (std::filesystem::exists(full_output_path))
|
||||
{
|
||||
|
||||
std::filesystem::file_time_type inf_time = std::filesystem::last_write_time(input_path);
|
||||
std::filesystem::file_time_type outf_time = std::filesystem::last_write_time(full_output_path);
|
||||
|
||||
if (outf_time > inf_time)
|
||||
{
|
||||
//printf("File %s is newer than %s, skipping\n", full_output_path, input_path);
|
||||
printf("S");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
f = fopen(full_output_path, "wb+");
|
||||
fwrite(buffer, 1, buffer_size, f);
|
||||
fclose(f);
|
||||
printf("B");
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
|
|
@ -18,7 +18,7 @@ define make_directory
|
|||
endef
|
||||
|
||||
# Target executable
|
||||
TARGET := data-generator
|
||||
TARGET := payload-generator
|
||||
|
||||
# Phony targets
|
||||
.PHONY: all clean
|
||||
|
|
@ -1,7 +1,5 @@
|
|||
//#include "pokemon_data.h"
|
||||
#include "common.h"
|
||||
#include "gba_rom_values/gba_rom_values.h"
|
||||
#include "gb_rom_values/gb_rom_values.h"
|
||||
#include "gba_rom_values/gba_rom_values.h"
|
||||
#include "payloads/payload_file_writer.h"
|
||||
#include "payloads/payload_file_reader.h"
|
||||
#include "payloads/binary_patch_generator.h"
|
||||
|
|
@ -10,22 +8,6 @@
|
|||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
|
||||
// This application holds the various long static data arrays that Poke Transporter GB uses
|
||||
// and it writes them to .bin files that can be compressed with gbalzss later.
|
||||
// it's useful to do it this way because it keeps this data easy to view, edit and document
|
||||
|
||||
// This function generates a binary file containing the specified list of ROM_DATA structs
|
||||
void generate_gba_rom_value_tables(const char *input_path, const char *output_path, const char *filename, const struct ROM_DATA *rom_data_values, u16 num_elements)
|
||||
{
|
||||
writeTable(input_path, output_path, filename, reinterpret_cast<const char *>(rom_data_values), num_elements * sizeof(struct ROM_DATA));
|
||||
}
|
||||
|
||||
void generate_gb_rom_value_tables(const char *input_path, const char *output_path, const char *filename, const struct GB_ROM *rom_data_values, u16 num_elements)
|
||||
{
|
||||
writeTable(input_path, output_path, filename, reinterpret_cast<const char *>(rom_data_values), num_elements * sizeof(struct GB_ROM));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the payloads for the specific pokémon generation.
|
||||
* Note: yellow_version indicates that we'd want to generate the payloads for pokémon yellow.
|
||||
|
|
@ -187,7 +169,7 @@ void generate_and_test_payloads_for(uint8_t generation, bool yellow_version, con
|
|||
if (std::filesystem::exists(full_output_path))
|
||||
{
|
||||
|
||||
std::filesystem::file_time_type inf_time = std::filesystem::last_write_time("tools/data-generator/src/payloads/payload_builder.cpp");
|
||||
std::filesystem::file_time_type inf_time = std::filesystem::last_write_time("tools/payload-generator/src/payloads/payload_builder.cpp");
|
||||
std::filesystem::file_time_type outf_time = std::filesystem::last_write_time(full_output_path);
|
||||
|
||||
if (outf_time > inf_time)
|
||||
|
|
@ -206,18 +188,6 @@ int main(int argc, char **argv)
|
|||
{
|
||||
printf("Converting data into bin files!\n[");
|
||||
const char *output_path = (argc > 1) ? argv[1] : "";
|
||||
generate_pokemon_data(output_path);
|
||||
|
||||
// generate the ROM_DATA tables for each language
|
||||
generate_gba_rom_value_tables("tools/data-generator/src/gba_rom_values/gba_rom_values_eng.cpp", output_path, "gba_rom_values_eng.bin", rom_data_values_eng, rom_data_values_eng_size);
|
||||
generate_gba_rom_value_tables("tools/data-generator/src/gba_rom_values/gba_rom_values_fre.cpp", output_path, "gba_rom_values_fre.bin", rom_data_values_fre, rom_data_values_fre_size);
|
||||
generate_gba_rom_value_tables("tools/data-generator/src/gba_rom_values/gba_rom_values_ger.cpp", output_path, "gba_rom_values_ger.bin", rom_data_values_ger, rom_data_values_ger_size);
|
||||
generate_gba_rom_value_tables("tools/data-generator/src/gba_rom_values/gba_rom_values_ita.cpp", output_path, "gba_rom_values_ita.bin", rom_data_values_ita, rom_data_values_ita_size);
|
||||
generate_gba_rom_value_tables("tools/data-generator/src/gba_rom_values/gba_rom_values_jpn.cpp", output_path, "gba_rom_values_jpn.bin", rom_data_values_jpn, rom_data_values_jpn_size);
|
||||
generate_gba_rom_value_tables("tools/data-generator/src/gba_rom_values/gba_rom_values_spa.cpp", output_path, "gba_rom_values_spa.bin", rom_data_values_spa, rom_data_values_spa_size);
|
||||
|
||||
generate_gb_rom_value_tables("tools/data-generator/src/gb_rom_values/gb_rom_values_eng.cpp", output_path, "gb_rom_values_eng.bin", gb_rom_values_eng, gb_rom_values_eng_size);
|
||||
generate_gb_rom_value_tables("tools/data-generator/src/gb_rom_values/gb_rom_values_fre.cpp", output_path, "gb_rom_values_fre.bin", gb_rom_values_fre, gb_rom_values_fre_size);
|
||||
|
||||
generate_and_test_payloads_for(1, false, output_path, "gb_gen1_payloads_RB.bin");
|
||||
generate_and_test_payloads_for(1, true, output_path, "gb_gen1_payloads_Y.bin");
|
||||
Loading…
Reference in New Issue
Block a user