diff options
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | arm9/Makefile | 3 | ||||
-rw-r--r-- | arm9/lib/Makefile | 1 | ||||
-rw-r--r-- | files/particledata/particledata/narc_0000.bin | bin | 712 -> 0 bytes | |||
-rw-r--r-- | files/particledata/particledata/narc_0001.bin | bin | 1220 -> 0 bytes | |||
-rw-r--r-- | files/particledata/particledata/narc_0002.bin | bin | 6112 -> 0 bytes | |||
-rw-r--r-- | files/particledata/particledata/narc_0003.bin | bin | 12904 -> 0 bytes | |||
-rw-r--r-- | files/particledata/particledata/narc_0004.bin | bin | 7892 -> 0 bytes | |||
-rw-r--r-- | files/particledata/particledata/narc_0005.bin | bin | 5360 -> 0 bytes | |||
-rw-r--r-- | ld_script.txt | 98 | ||||
-rw-r--r-- | tools/narccomp/.gitignore | 1 | ||||
-rw-r--r-- | tools/narccomp/Makefile | 12 | ||||
-rw-r--r-- | tools/narccomp/narccomp.cpp | 261 |
13 files changed, 0 insertions, 377 deletions
@@ -183,7 +183,6 @@ MWCCARM = tools/mwccarm/$(MWCCVERSION)/mwccarm.exe KNARC = tools/knarc/knarc$(EXE) MWLDARM = tools/mwccarm/$(MWCCVERSION)/mwldarm.exe MWASMARM = tools/mwccarm/$(MWCCVERSION)/mwasmarm.exe -NARCCOMP = tools/narccomp/narccomp$(EXE) SCANINC = tools/scaninc/scaninc$(EXE) AS = $(WINE) $(MWASMARM) diff --git a/arm9/Makefile b/arm9/Makefile index 8efb8421..47051dd6 100644 --- a/arm9/Makefile +++ b/arm9/Makefile @@ -285,9 +285,6 @@ $(S_OBJS) $(LIBS_OBJS): $(BUILD_DIR)/%.o: %.s $$(dep) $(BUILD_DIR)/$(LD_SCRIPT): $(LD_SPEC) $(LD_TEMPLATE) $(MAKELCF) $(MAKELCF_FLAGS) $^ $@ -#$(BUILD_DIR)/$(LD_SCRIPT): $(LD_SCRIPT) -# $(CPP) $(VERSION_CFLAGS) -MMD -MP -MT $@ -MF $@.d -I include/ -I . -DBUILD_DIR=$(BUILD_DIR) -o $@ $< - $(ROM): $(BUILD_DIR)/$(LD_SCRIPT) $(O_FILES) $(STATIC_LIBS) cd $(BUILD_DIR) && LM_LICENSE_FILE=../../$(LM_LICENSE_FILE) $(WINE) ../../$(MWLDARM) $(LDFLAGS) $(LIBS) -o ../../$(ELF) $(LD_SCRIPT) $(O_FILES:$(BUILD_DIR)/%=%) $(OBJCOPY) $(foreach ov,arm9 $(OVERLAYS),--update-section $(ov)=$(BUILD_DIR)/$(ov).sbin -j $(ov)) $(ELF) 2>/dev/null diff --git a/arm9/lib/Makefile b/arm9/lib/Makefile index fd6471f1..0ff7e9e4 100644 --- a/arm9/lib/Makefile +++ b/arm9/lib/Makefile @@ -44,7 +44,6 @@ MWCCARM = ../../tools/mwccarm/$(MWCCVERSION)/mwccarm.exe # only dependency should be MWCCARM. MWLDARM = ../../tools/mwccarm/$(MWCCVERSION)/mwldarm.exe MWASMARM = ../../tools/mwccarm/$(MWCCVERSION)/mwasmarm.exe -NARCCOMP = ../../tools/narccomp/narccomp$(EXE) SCANINC = ../../tools/scaninc/scaninc$(EXE) AS = $(WINE) $(MWASMARM) diff --git a/files/particledata/particledata/narc_0000.bin b/files/particledata/particledata/narc_0000.bin Binary files differdeleted file mode 100644 index bf480346..00000000 --- a/files/particledata/particledata/narc_0000.bin +++ /dev/null diff --git a/files/particledata/particledata/narc_0001.bin b/files/particledata/particledata/narc_0001.bin Binary files differdeleted file mode 100644 index 172e13bc..00000000 --- a/files/particledata/particledata/narc_0001.bin +++ /dev/null diff --git a/files/particledata/particledata/narc_0002.bin b/files/particledata/particledata/narc_0002.bin Binary files differdeleted file mode 100644 index 42591e28..00000000 --- a/files/particledata/particledata/narc_0002.bin +++ /dev/null diff --git a/files/particledata/particledata/narc_0003.bin b/files/particledata/particledata/narc_0003.bin Binary files differdeleted file mode 100644 index c9dd0fc7..00000000 --- a/files/particledata/particledata/narc_0003.bin +++ /dev/null diff --git a/files/particledata/particledata/narc_0004.bin b/files/particledata/particledata/narc_0004.bin Binary files differdeleted file mode 100644 index 4f15716c..00000000 --- a/files/particledata/particledata/narc_0004.bin +++ /dev/null diff --git a/files/particledata/particledata/narc_0005.bin b/files/particledata/particledata/narc_0005.bin Binary files differdeleted file mode 100644 index 852d1063..00000000 --- a/files/particledata/particledata/narc_0005.bin +++ /dev/null diff --git a/ld_script.txt b/ld_script.txt deleted file mode 100644 index d7f1135a..00000000 --- a/ld_script.txt +++ /dev/null @@ -1,98 +0,0 @@ -/* Linker Script to build Pokemon Diamond */ - -#define BEGIN_SEG(name, addr) \ - _##name##SegmentStart = ADDR(.name); \ - _##name##SegmentRomStart = __romPos; \ - .name addr : AT(__romPos) - -#define END_SEG(name) \ - _##name##SegmentEnd = ADDR(.name) + SIZEOF(.name); \ - _##name##SegmentRomEnd = __romPos + SIZEOF(.name); \ - _##name##SegmentSize = SIZEOF(.name); \ - __romPos += SIZEOF(.name); - -SECTIONS { - __romPos = 0; - BEGIN_SEG(ARM7Overlay, 0) - { - } - END_SEG(ARM7Overlay) - - BEGIN_SEG(header, 0x0) - { - build/asm/rom_header.o(.text); - . = 0x4000; - } =0 - END_SEG(header) - - BEGIN_SEG(arm9, 0x2000000) - { - build/asm/secure.o(.text); - build/asm/entry.o(.text); - build/asm/main.o(.text); - build/src/sub_02000DF4.o(.text); - build/asm/arm9_thumb.o(.text); - build/asm/rom2.o(.text); - } - END_SEG(arm9) - - garbage : - { - build/asm/unk_10b724.o(.text); - }=0 - - . = 0x10B800;__romPos = .; - BEGIN_SEG(ARM9Overlay, 0) - { - build/asm/arm9overlay.o(.text); - } - END_SEG(ARM9Overlay) - - . = 0x10C400;__romPos = .; - BEGIN_SEG(rom3, 0) /* shrug */ - { - build/asm/rom3.o(.text); - } - END_SEG(rom3) - - . = 0x30D000;__romPos = .; - BEGIN_SEG(arm7, 0x02380000) - { - build/asm/arm7_rom.o(.text); - } - END_SEG(arm7) - - . = 0x336400;__romPos = .; - BEGIN_SEG(FileNameTable, 0) - { - build/asm/filenametable.o(.text); - } - END_SEG(FileNameTable) - - . = 0x337A00;__romPos = .; - BEGIN_SEG(FileAllocationTable, 0) - { - build/asm/fat.o(.text); - } - END_SEG(FileAllocationTable) - - . = 0x338600;__romPos = .; - BEGIN_SEG(Icon, __romPos) - { - build/asm/icon.o(.text); - build/asm/title.o(.text); - } - END_SEG(Icon) - - . = 0x339000;__romPos = .; - BEGIN_SEG(NARC, 0) - { - build/asm/narc.o(.text); - } - END_SEG(NARC) - - /DISCARD/ : - { - *(*); - } -} diff --git a/tools/narccomp/.gitignore b/tools/narccomp/.gitignore deleted file mode 100644 index e96a03a5..00000000 --- a/tools/narccomp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -narccomp diff --git a/tools/narccomp/Makefile b/tools/narccomp/Makefile deleted file mode 100644 index 6b404f32..00000000 --- a/tools/narccomp/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -CXXFLAGS := -O3 -std=c++11 - -.PHONY: all clean - -all: narccomp - @: - -clean: - $(RM) narccomp narccomp.exe - -narccomp: narccomp.cpp - $(CXX) $(CXXFLAGS) -o $@ $^ diff --git a/tools/narccomp/narccomp.cpp b/tools/narccomp/narccomp.cpp deleted file mode 100644 index 2cbbeb4c..00000000 --- a/tools/narccomp/narccomp.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#include <iostream> -#include <fstream> -#include <vector> -#include <string> -#include <cstring> -#include <sstream> -#include <map> -#include <set> - -using namespace std; - -struct Options -{ - fstream outfile; - map<string, string> infiles; - unsigned char padval; - bool keep_names; - string host_root; - string nitro_root; - Options(int const & argc, char ** const & argv) : - // Default values - padval(255), - keep_names(false) - { - char last_opt = 0; - string outfname; // Use this to avoid clobbering an existing file in the event of an error - for (string arg : vector<char *>(argv + 1, argv + argc)) - { - if (last_opt != 0) { - switch (last_opt) - { - case 'p': - { - // Padding - unsigned long x; - stringstream is(arg); - is >> x; - if (x >= 256) { - stringstream ss; - ss << "Invalid value for -p: " << x << endl; - throw invalid_argument(ss.str()); - } - padval = x; - break; - } - case 'o': - // Outfile - if (!outfname.empty()) { - throw invalid_argument("Can't output more than one file\n"); - } - outfname = arg; - break; - case 'r': - // Not fully implemented - if (!host_root.empty()) { - throw invalid_argument("Duplicate settings for option -r\n"); - } - host_root = arg; - break; - case 'R': - // Not fully implemented - if (!nitro_root.empty()) { - throw invalid_argument("Duplicate settings for option -R\n"); - } - nitro_root = arg; - break; - default: - stringstream ss; - ss << "Unrecognized option: -" << (char)last_opt << endl; - throw invalid_argument(ss.str()); - } - last_opt = 0; - } - else if (arg[0] == '-') { - if (arg[1] == 0 || arg[2] != 0) { - stringstream ss; - ss << "Unrecognized option: " << arg << endl; - throw invalid_argument(ss.str()); - } - switch (arg[1]) { - case 'h': - cout << "Usage: " << argv[0] << " [-p PADVAL] [-h] -o OUTFILE FILE [FILE ...]" << endl; - cout << endl; - cout << " FILE [FILE ...] List of files to be packed into the archive." << endl; - cout << " -o OUTFILE The destination archive, in NARC format" << endl; - cout << " -p PADVAL Pad archive members to word with this character. Default: 255" << endl; - cout << " -h Print this message and exit" << endl; - exit(0); - case 'k': - throw invalid_argument("'-k': not implemented\n"); -// if (keep_names) { -// throw invalid_argument("'-k' specified more than once\n"); -// } -// keep_names = true; -// break; - default: - last_opt = arg[1]; - } - } - else - { - fstream file; - stringstream uss; - - if (!infiles[arg].empty()) { - stringstream ss; - ss << "Duplicate file: " << arg << endl; - throw invalid_argument(ss.str()); - } - file.open(arg, ios_base::in | ios_base::binary); - uss << file.rdbuf(); - file.close(); - infiles[arg] = uss.str(); - } - } - if (outfname.empty()) { - throw invalid_argument("Must specify an output file (-o OUTFILE)\n"); - } - if (infiles.empty()) { - throw invalid_argument("No input files\n"); - } - outfile.open(outfname, ios_base::binary | ios_base::out); - } -}; - -struct FatbEntry -{ - uint32_t start; - uint32_t end; -}; - -struct FatbHeader -{ - char magic[4]; - uint32_t chunk_size; - uint16_t file_count; - char padding[2]; - FatbHeader(uint16_t numfiles) : - chunk_size(sizeof(FatbHeader) + sizeof(FatbEntry) * numfiles), - file_count(numfiles) - { strncpy(magic, "BTAF", 4); memset(padding, 0, 2); } -}; - -struct FntbDirHeader -{ - uint32_t offset; - uint16_t first_file; - uint16_t id_or_count; -}; - -struct FntbHeader -{ - char magic[4]; - uint32_t chunk_size; - FntbHeader() : - chunk_size(sizeof(FntbHeader) + sizeof(FntbDirHeader)) - { strncpy(magic, "BTNF", 4); } - string set_names(Options*& opt, FntbDirHeader*& dirHeader) { - throw runtime_error("not implemented\n"); -// typedef struct NitroFS { -// bool is_dir; -// vector<struct NitroFS> children; -// } nitrofs_t; -// map<string, nitrofs_t> fs; -// fs[opt->nitro_root].is_dir = true; -// string host_root; -// for (auto pair : opt->infiles) { -// string fname = pair.first; -// fname = fname.replace(0, opt->host_root.size(), opt->nitro_root); -// int pos; -// while ((pos = fname.find("//")) != fname.npos) { -// fname = fname.replace(pos, 2, 1, '/'); -// } -// } -// return nullptr; - } -}; - -#define FNT_END 0 -#define FNT_LENGTH_MASK 0x7F -#define FNT_IS_DIR_MASK 0x80 - -struct FimgHeader -{ - char magic[4]; - uint32_t chunk_size; - FimgHeader(size_t image_size) : - chunk_size(sizeof(FimgHeader) + image_size) - { strncpy(magic, "GMIF", 4); } -}; - -struct NarcHeader -{ - char magic[4]; // NARC - uint16_t bom; - uint16_t version; - uint32_t size; - uint16_t chunk_size; - uint16_t num_chunks; - NarcHeader(uint16_t numfiles, size_t image_size) : - bom(0xFFFE), - version(0x0100), - size(sizeof(NarcHeader) + sizeof(FatbHeader) + sizeof(FatbEntry) * numfiles + sizeof(FntbHeader) + sizeof(FntbDirHeader) + sizeof(FimgHeader) + image_size), - chunk_size(sizeof(NarcHeader)), - num_chunks(3) - { strncpy(magic, "NARC", 4); } -}; - -int main(int argc, char ** argv) -{ - try - { - auto opt = new Options(argc, argv); - size_t nfiles = opt->infiles.size(); - auto fatb = new FatbEntry[nfiles]; - FatbEntry *entry = fatb; - for (auto pair : opt->infiles) - { - entry->start = (entry == fatb ? 0 : (entry[-1].end + 3) & ~3); - entry->end = entry->start + pair.second.size(); - entry++; - } - size_t image_size = (fatb[nfiles - 1].end + 3) & ~3; - FntbHeader fntbHeader; - auto fntbDir = new FntbDirHeader; - *fntbDir = (FntbDirHeader) {4, 0, 1}; // dummy - stringstream fnt; - if (opt->keep_names) - { - fntbHeader.set_names(opt, fntbDir); - } - NarcHeader narcHeader(nfiles, (fatb[nfiles - 1].end + 3) & ~3); - FatbHeader fatbHeader(nfiles); - FimgHeader fimgHeader((fatb[nfiles - 1].end + 3) & ~3); - opt->outfile.write((char *) &narcHeader, sizeof(NarcHeader)); - opt->outfile.write((char *) &fatbHeader, sizeof(FatbHeader)); - opt->outfile.write((char *) fatb, sizeof(FatbEntry) * nfiles); - opt->outfile.write((char *) &fntbHeader, sizeof(FntbHeader)); - opt->outfile.write((char *) fntbDir, sizeof(FntbDirHeader)); - opt->outfile.write((char *) &fimgHeader, sizeof(FimgHeader)); - char padding[4]; - memset(padding, opt->padval, 4); - for (auto pair : opt->infiles) - { - stringstream uss(pair.second); - opt->outfile.write(pair.second.c_str(), pair.second.size()); - opt->outfile.write(padding, (4 - pair.second.size()) & 3); - } - opt->outfile.close(); - return 0; - } catch (invalid_argument e) { - cerr << "Invalid exception: " << e.what() << endl; - return 1; - } catch (runtime_error e) { - cerr << "Runtime error: " << e.what() << endl; - return 2; - } catch (exception e) { - cerr << "unhandled exception caught" << endl; - return 3; - } -} |