diff options
author | red031000 <rubenru09@aol.com> | 2020-07-10 17:25:12 +0100 |
---|---|---|
committer | red031000 <rubenru09@aol.com> | 2020-07-10 17:26:17 +0100 |
commit | 7762fa4d5454be7be0e89b09986f31bbdff79a83 (patch) | |
tree | 2c04561d5b08c7e21f863250b2bc06591381e99a | |
parent | d022486e419b8651a9716fb50e0cedcbb6733168 (diff) |
bit of work on graphics, mostly setup
23 files changed, 86 insertions, 7 deletions
@@ -1,6 +1,7 @@ # Makefile to build Pokemon Diamond image include config.mk +include graphics_rules.mk HOSTCC = $(CC) HOSTCXX = $(CXX) @@ -156,6 +157,7 @@ clean: mostlyclean clean-fs clean-fs: $(RM) $(filter %.narc %.arc,$(HOSTFS_FILES)) + $(RM) $(NCGR_CLEAN_LIST) $(NCLR_CLEAN_LIST) find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' \) -exec $(RM) {} + mostlyclean: tidy @@ -240,6 +242,21 @@ PADDED_LZ_FILES := $(addsuffix .lz,$(wildcard \ $(PADDED_LZ_FILES): %.lz: % $(NTRCOMP) -l2 -s -A4 -o $@ $< +%.NCGR: %.png + $(GFX) $< $@ + +$(CLOBBER_SIZE_NCGR_FILES): %.NCGR: %.png + $(GFX) $< $@ -clobbersize + +$(CLOBBER_SIZE_VERSION101_NCGR_FILES): %.NCGR: %.png + $(GFX) $< $@ -clobbersize -version101 + +%.NCLR: %.png + $(GFX) $< $@ + +%.NCLR: %.pal + $(GFX) $< $@ + %.png: ; %.pal: ; diff --git a/files/data/.gitignore b/files/data/.gitignore new file mode 100644 index 00000000..e405595a --- /dev/null +++ b/files/data/.gitignore @@ -0,0 +1,2 @@ +cell0.NCGR +cell0.NCLR diff --git a/files/data/cell0.NCGR b/files/data/cell0.NCGR Binary files differdeleted file mode 100644 index 76a112b3..00000000 --- a/files/data/cell0.NCGR +++ /dev/null diff --git a/files/data/cell0.NCLR b/files/data/cell0.NCLR Binary files differdeleted file mode 100644 index 680c004b..00000000 --- a/files/data/cell0.NCLR +++ /dev/null diff --git a/files/data/cell0.png b/files/data/cell0.png Binary files differnew file mode 100644 index 00000000..bfd49d69 --- /dev/null +++ b/files/data/cell0.png diff --git a/files/graphic/bag_gra/.gitignore b/files/graphic/bag_gra/.gitignore new file mode 100644 index 00000000..6fc1835d --- /dev/null +++ b/files/graphic/bag_gra/.gitignore @@ -0,0 +1,6 @@ +narc_0002.NCGR +narc_0006.NCGR +narc_0035.NCLR +narc_0034.NCGR +narc_0003.NCLR +narc_0034.NCLR diff --git a/files/graphic/bag_gra/narc_0002.NCGR b/files/graphic/bag_gra/narc_0002.NCGR Binary files differdeleted file mode 100644 index a33c847c..00000000 --- a/files/graphic/bag_gra/narc_0002.NCGR +++ /dev/null diff --git a/files/graphic/bag_gra/narc_0002.png b/files/graphic/bag_gra/narc_0002.png Binary files differnew file mode 100644 index 00000000..9152a7e1 --- /dev/null +++ b/files/graphic/bag_gra/narc_0002.png diff --git a/files/graphic/bag_gra/narc_0003.NCLR b/files/graphic/bag_gra/narc_0003.NCLR Binary files differdeleted file mode 100644 index 4e6b57e1..00000000 --- a/files/graphic/bag_gra/narc_0003.NCLR +++ /dev/null diff --git a/files/graphic/bag_gra/narc_0003.pal b/files/graphic/bag_gra/narc_0003.pal new file mode 100644 index 00000000..45483a1e --- /dev/null +++ b/files/graphic/bag_gra/narc_0003.pal @@ -0,0 +1,19 @@ +JASC-PAL +0100 +16 +189 238 205 +238 164 106 +238 115 106 +230 90 90 +197 82 65 +156 57 57 +180 65 65 +82 82 82 +255 255 255 +115 115 115 +164 131 57 +238 213 106 +230 180 90 +197 164 65 +139 115 57 +115 90 49 diff --git a/files/graphic/bag_gra/narc_0006.NCGR b/files/graphic/bag_gra/narc_0006.NCGR Binary files differdeleted file mode 100644 index 3517cd01..00000000 --- a/files/graphic/bag_gra/narc_0006.NCGR +++ /dev/null diff --git a/files/graphic/bag_gra/narc_0006.png b/files/graphic/bag_gra/narc_0006.png Binary files differnew file mode 100644 index 00000000..a9982600 --- /dev/null +++ b/files/graphic/bag_gra/narc_0006.png diff --git a/files/graphic/bag_gra/narc_0034.NCGR b/files/graphic/bag_gra/narc_0034.NCGR Binary files differdeleted file mode 100644 index 55f4282b..00000000 --- a/files/graphic/bag_gra/narc_0034.NCGR +++ /dev/null diff --git a/files/graphic/bag_gra/narc_0034.png b/files/graphic/bag_gra/narc_0034.png Binary files differnew file mode 100644 index 00000000..ba296b4c --- /dev/null +++ b/files/graphic/bag_gra/narc_0034.png diff --git a/files/graphic/bag_gra/narc_0035.NCLR b/files/graphic/bag_gra/narc_0035.NCLR Binary files differdeleted file mode 100644 index 4e6b57e1..00000000 --- a/files/graphic/bag_gra/narc_0035.NCLR +++ /dev/null diff --git a/filesystem.mk b/filesystem.mk index 180845ac..013d64a9 100644 --- a/filesystem.mk +++ b/filesystem.mk @@ -794,6 +794,13 @@ files/wazaeffect/effectclact/wecellanm.narc: \ files/wazaeffect/effectclact/wecellanm/narc_0013.NANR.lz \ files/wazaeffect/effectclact/wecellanm/narc_0007.NANR.lz +files/graphic/bag_gra.narc: \ + files/graphic/bag_gra/narc_0002.NCGR \ + files/graphic/bag_gra/narc_0003.NCLR \ + files/graphic/bag_gra/narc_0006.NCGR \ + files/graphic/bag_gra/narc_0034.NCGR \ + files/graphic/bag_gra/narc_0034.NCLR + files/graphic/box.narc: \ files/graphic/box/narc_0022.NANR.lz \ files/graphic/box/narc_0036.NSCR.lz \ diff --git a/graphics_rules.mk b/graphics_rules.mk new file mode 100644 index 00000000..0ad43bf2 --- /dev/null +++ b/graphics_rules.mk @@ -0,0 +1,17 @@ +#todo data/dp_areawindow.NCGR (weirdness with size) +#todo data/graphic/bag_gra/narc_0007.NCGR (SOPC section) (width 32, palette narc_0003.NCLR) + +CLOBBER_SIZE_NCGR_FILES := files/data/cell0.NCGR + +CLOBBER_SIZE_VERSION101_NCGR_FILES := files/graphic/bag_gra/narc_0002.NCGR \ + files/graphic/bag_gra/narc_0006.NCGR \ + files/graphic/bag_gra/narc_0034.NCGR + +NCGR_CLEAN_LIST := files/data/cell0.NCGR \ + files/graphic/bag_gra/narc_0002.NCGR \ + files/graphic/bag_gra/narc_0006.NCGR \ + files/graphic/bag_gra/narc_0034.NCGR + +NCLR_CLEAN_LIST := files/data/cell0.NCLR \ + files/graphic/bag_gra/narc_0003.NCLR \ + files/graphic/bag_gra/narc_0034.NCLR diff --git a/tools/nitrogfx/gfx.c b/tools/nitrogfx/gfx.c index 3315e00e..a80d341b 100644 --- a/tools/nitrogfx/gfx.c +++ b/tools/nitrogfx/gfx.c @@ -359,7 +359,7 @@ void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int m free(buffer); } -void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder) +void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder, bool version101) { FILE *fp = fopen(path, "wb"); @@ -407,7 +407,7 @@ void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, in break; } - WriteGenericNtrHeader(fp, "RGCN", bufferSize + 0x20, byteOrder); + WriteGenericNtrHeader(fp, "RGCN", bufferSize + 0x20, byteOrder, version101); unsigned char charHeader[0x20] = { 0x52, 0x41, 0x48, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00 }; @@ -545,7 +545,7 @@ void WriteNtrPalette(char *path, struct Palette *palette, bool ncpr) uint32_t extSize = size + (ncpr ? 0x10 : 0x18); //NCLR header - WriteGenericNtrHeader(fp, (ncpr ? "RPCN" : "RLCN"), extSize, !ncpr); + WriteGenericNtrHeader(fp, (ncpr ? "RPCN" : "RLCN"), extSize, !ncpr, false); unsigned char palHeader[0x18] = { diff --git a/tools/nitrogfx/gfx.h b/tools/nitrogfx/gfx.h index da56c5c5..1b097336 100644 --- a/tools/nitrogfx/gfx.h +++ b/tools/nitrogfx/gfx.h @@ -31,7 +31,7 @@ struct Image { void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); void ReadNtrImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); -void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder); +void WriteNtrImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors, bool clobberSize, bool byteOrder, bool version101); void FreeImage(struct Image *image); void ReadGbaPalette(char *path, struct Palette *palette); void ReadNtrPalette(char *path, struct Palette *palette); diff --git a/tools/nitrogfx/main.c b/tools/nitrogfx/main.c index 2f5b2735..076e7076 100644 --- a/tools/nitrogfx/main.c +++ b/tools/nitrogfx/main.c @@ -88,7 +88,7 @@ void ConvertPngToNtr(char *inputPath, char *outputPath, struct PngToNtrOptions * ReadPng(inputPath, &image); - WriteNtrImage(outputPath, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette, options->clobberSize, options->byteOrder); + WriteNtrImage(outputPath, options->numTiles, options->bitDepth, options->metatileWidth, options->metatileHeight, &image, !image.hasPalette, options->clobberSize, options->byteOrder, options->version101); FreeImage(&image); } @@ -320,6 +320,7 @@ void HandlePngToNtrCommand(char *inputPath, char *outputPath, int argc, char **a options.metatileHeight = 1; options.clobberSize = false; options.byteOrder = true; + options.version101 = false; for (int i = 3; i < argc; i++) { @@ -385,6 +386,10 @@ void HandlePngToNtrCommand(char *inputPath, char *outputPath, int argc, char **a { options.byteOrder = false; } + else if (strcmp(option, "-version101") == 0) + { + options.version101 = true; + } else { FATAL_ERROR("Unrecognized option \"%s\".\n", option); diff --git a/tools/nitrogfx/options.h b/tools/nitrogfx/options.h index 8376348f..77006f21 100644 --- a/tools/nitrogfx/options.h +++ b/tools/nitrogfx/options.h @@ -28,6 +28,7 @@ struct PngToNtrOptions { int metatileHeight; bool clobberSize; bool byteOrder; + bool version101; }; diff --git a/tools/nitrogfx/util.c b/tools/nitrogfx/util.c index 73a128a1..304a2319 100644 --- a/tools/nitrogfx/util.c +++ b/tools/nitrogfx/util.c @@ -124,13 +124,18 @@ void WriteWholeFile(char *path, void *buffer, int bufferSize) fclose(fp); } -void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder) +void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder, bool version101) { unsigned char header[0x10] = { 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFE, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00 }; //magic number memcpy(header, magicNumber, 4); + if (version101) + { + header[6] = 0x01; + } + //byte order if (!byteorder) { diff --git a/tools/nitrogfx/util.h b/tools/nitrogfx/util.h index f181b66e..bb1cd4ad 100644 --- a/tools/nitrogfx/util.h +++ b/tools/nitrogfx/util.h @@ -11,6 +11,6 @@ char *GetFileExtension(char *path); unsigned char *ReadWholeFile(char *path, int *size); unsigned char *ReadWholeFileZeroPadded(char *path, int *size, int padAmount); void WriteWholeFile(char *path, void *buffer, int bufferSize); -void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder); +void WriteGenericNtrHeader(FILE* fp, const char* magicNumber, uint32_t size, bool byteorder, bool version101); #endif // UTIL_H |