bit of work on graphics, mostly setup

This commit is contained in:
red031000
2020-07-10 17:25:12 +01:00
parent d022486e41
commit 7762fa4d54
23 changed files with 86 additions and 7 deletions

View File

@@ -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: ;

2
files/data/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
cell0.NCGR
cell0.NCLR

Binary file not shown.

Binary file not shown.

BIN
files/data/cell0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

6
files/graphic/bag_gra/.gitignore vendored Normal file
View File

@@ -0,0 +1,6 @@
narc_0002.NCGR
narc_0006.NCGR
narc_0035.NCLR
narc_0034.NCGR
narc_0003.NCLR
narc_0034.NCLR

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

View File

@@ -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

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

View File

@@ -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 \

17
graphics_rules.mk Normal file
View File

@@ -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

View File

@@ -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] =
{

View File

@@ -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);

View File

@@ -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);

View File

@@ -28,6 +28,7 @@ struct PngToNtrOptions {
int metatileHeight;
bool clobberSize;
bool byteOrder;
bool version101;
};

View File

@@ -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)
{

View File

@@ -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