Merge pull request #2 from Clownacy/master

Added automatic compile-time resource conversion
This commit is contained in:
Cucky 2019-01-20 17:55:19 -05:00 committed by GitHub
commit 4c752e08ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
105 changed files with 22476 additions and 29671 deletions

View file

@ -43,7 +43,71 @@ SOURCES = \
Sound \ Sound \
Stage \ Stage \
TextScr \ TextScr \
Triangle \ Triangle
RESOURCES = \
BITMAP/CREDIT01.bmp \
BITMAP/CREDIT02.bmp \
BITMAP/CREDIT03.bmp \
BITMAP/CREDIT04.bmp \
BITMAP/CREDIT05.bmp \
BITMAP/CREDIT06.bmp \
BITMAP/CREDIT07.bmp \
BITMAP/CREDIT08.bmp \
BITMAP/CREDIT09.bmp \
BITMAP/CREDIT10.bmp \
BITMAP/CREDIT11.bmp \
BITMAP/CREDIT12.bmp \
BITMAP/CREDIT14.bmp \
BITMAP/CREDIT15.bmp \
BITMAP/CREDIT16.bmp \
BITMAP/CREDIT17.bmp \
BITMAP/CREDIT18.bmp \
BITMAP/PIXEL.bmp \
ICON/4.bmp \
ORG/ACCESS \
ORG/ANZEN \
ORG/BALCONY \
ORG/BALLOS \
ORG/BDOWN \
ORG/CEMETERY \
ORG/CURLY \
ORG/DR \
ORG/ENDING \
ORG/ESCAPE \
ORG/FANFALE1 \
ORG/FANFALE2 \
ORG/FANFALE3 \
ORG/FIREEYE \
ORG/GAMEOVER \
ORG/GINSUKE \
ORG/GRAND \
ORG/GRAVITY \
ORG/HELL \
ORG/IRONH \
ORG/JENKA \
ORG/JENKA2 \
ORG/KODOU \
ORG/LASTBT3 \
ORG/LASTBTL \
ORG/LASTCAVE \
ORG/MARINE \
ORG/MAZE \
ORG/MDOWN2 \
ORG/MURA \
ORG/OSIDE \
ORG/PLANT \
ORG/QUIET \
ORG/REQUIEM \
ORG/TOROKO \
ORG/VIVI \
ORG/WANPAK2 \
ORG/WANPAKU \
ORG/WEED \
ORG/WHITE \
ORG/XXXX \
ORG/ZONBIE \
WAVE/WAVE100
OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES))) OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES)))
@ -59,5 +123,20 @@ obj/$(FILENAME)/%.o: src/%.cpp
@echo Compiling $^ @echo Compiling $^
@g++ $(CXXFLAGS) $^ -o $@ -c @g++ $(CXXFLAGS) $^ -o $@ -c
obj/$(FILENAME)/Resource.o: src/Resource.cpp $(addprefix src/Resource/, $(addsuffix .h, $(RESOURCES)))
@mkdir -p $(@D)
@echo Compiling $<
@g++ $(CXXFLAGS) $< -o $@ -c
src/Resource/%.h: res/% obj/bin2h.exe
@mkdir -p $(@D)
@echo Converting $<
@obj/bin2h.exe $< $@
obj/bin2h.exe: res/bin2h.cpp
@mkdir -p $(@D)
@echo Compiling $^
@g++ -O3 -s -static $^ -o $@
clean: clean:
@rm -rf build obj @rm -rf build obj

BIN
res/BITMAP/CREDIT01.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT02.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT03.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT04.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT05.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT06.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT07.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT08.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT09.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT10.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT11.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT12.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT14.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT15.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT16.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT17.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/CREDIT18.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/BITMAP/PIXEL.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
res/ICON/3.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

BIN
res/ICON/3s.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

BIN
res/ICON/4.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
res/ICON/4.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 318 B

BIN
res/ICON/4s.ico Normal file

Binary file not shown.

BIN
res/ORG/ACCESS Normal file

Binary file not shown.

BIN
res/ORG/ANZEN Normal file

Binary file not shown.

BIN
res/ORG/BALCONY Normal file

Binary file not shown.

BIN
res/ORG/BALLOS Normal file

Binary file not shown.

BIN
res/ORG/BDOWN Normal file

Binary file not shown.

BIN
res/ORG/CEMETERY Normal file

Binary file not shown.

BIN
res/ORG/CURLY Normal file

Binary file not shown.

BIN
res/ORG/DR Normal file

Binary file not shown.

BIN
res/ORG/ENDING Normal file

Binary file not shown.

BIN
res/ORG/ESCAPE Normal file

Binary file not shown.

BIN
res/ORG/FANFALE1 Normal file

Binary file not shown.

BIN
res/ORG/FANFALE2 Normal file

Binary file not shown.

BIN
res/ORG/FANFALE3 Normal file

Binary file not shown.

BIN
res/ORG/FIREEYE Normal file

Binary file not shown.

BIN
res/ORG/GAMEOVER Normal file

Binary file not shown.

BIN
res/ORG/GINSUKE Normal file

Binary file not shown.

BIN
res/ORG/GRAND Normal file

Binary file not shown.

BIN
res/ORG/GRAVITY Normal file

Binary file not shown.

BIN
res/ORG/HELL Normal file

Binary file not shown.

BIN
res/ORG/IRONH Normal file

Binary file not shown.

BIN
res/ORG/JENKA Normal file

Binary file not shown.

BIN
res/ORG/JENKA2 Normal file

Binary file not shown.

BIN
res/ORG/KODOU Normal file

Binary file not shown.

BIN
res/ORG/LASTBT3 Normal file

Binary file not shown.

BIN
res/ORG/LASTBTL Normal file

Binary file not shown.

BIN
res/ORG/LASTCAVE Normal file

Binary file not shown.

BIN
res/ORG/MARINE Normal file

Binary file not shown.

BIN
res/ORG/MAZE Normal file

Binary file not shown.

BIN
res/ORG/MDOWN2 Normal file

Binary file not shown.

BIN
res/ORG/MURA Normal file

Binary file not shown.

BIN
res/ORG/OSIDE Normal file

Binary file not shown.

BIN
res/ORG/PLANT Normal file

Binary file not shown.

BIN
res/ORG/QUIET Normal file

Binary file not shown.

BIN
res/ORG/REQUIEM Normal file

Binary file not shown.

BIN
res/ORG/TOROKO Normal file

Binary file not shown.

BIN
res/ORG/VIVI Normal file

Binary file not shown.

BIN
res/ORG/WANPAK2 Normal file

Binary file not shown.

BIN
res/ORG/WANPAKU Normal file

Binary file not shown.

BIN
res/ORG/WEED Normal file

Binary file not shown.

BIN
res/ORG/WHITE Normal file

Binary file not shown.

BIN
res/ORG/XXXX Normal file

Binary file not shown.

BIN
res/ORG/ZONBIE Normal file

Binary file not shown.

BIN
res/WAVE/WAVE100 Normal file

Binary file not shown.

71
res/bin2h.cpp Normal file
View file

@ -0,0 +1,71 @@
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdint.h>
const char *h1 = "#pragma once\n";
const char *end = "\n};\n";
int main(int argc, char *argv[])
{
if (argc > 2)
{
std::string filename = argv[1];
// Remove directory if present.
// Do this before extension removal incase directory has a period character.
const size_t last_slash_idx = filename.find_last_of("\\/");
if (std::string::npos != last_slash_idx)
{
filename.erase(0, last_slash_idx + 1);
}
// Remove extension if present.
const size_t period_idx = filename.rfind('.');
if (std::string::npos != period_idx)
{
filename.erase(period_idx);
}
//Open files
FILE *from = fopen(argv[1], "rb");
FILE *to = fopen(argv[2], "wb");
//Write "#pragma once"
fwrite(h1, strlen(h1), 1, to);
//Get from file's size
fseek(from, 0, SEEK_END);
size_t fromSize = ftell(from);
rewind(from);
//Write definition
char defin[0x400];
sprintf(defin, "const unsigned char r%s[%d] = {", filename.c_str(), fromSize);
fwrite(defin, strlen(defin), 1, to);
//Write actual data
char tLine[0x400];
for (size_t v = 0; v < fromSize; v++)
{
if ((v & 0xF) == 0)
strcpy(tLine, "\n\x09");
uint8_t val;
fread(&val, 1, 1, from);
sprintf(tLine, "%s0x%2.2X, ", tLine, val);
if ((((v + 1) & 0xF) == 0))
fwrite(tLine, strlen(tLine), 1, to);
}
//Write end
fwrite(end, strlen(end), 1, to);
//Close files
fclose(from);
fclose(to);
}
return 0;
}

View file

@ -47,25 +47,25 @@
#include "Resource/ORG/XXXX.h" #include "Resource/ORG/XXXX.h"
#include "Resource/ORG/ZONBIE.h" #include "Resource/ORG/ZONBIE.h"
#include "Resource/WAVE/WAVE100.h" #include "Resource/WAVE/WAVE100.h"
#include "Resource/Bitmap/CREDIT01.h" #include "Resource/BITMAP/CREDIT01.bmp.h"
#include "Resource/Bitmap/CREDIT02.h" #include "Resource/BITMAP/CREDIT02.bmp.h"
#include "Resource/Bitmap/CREDIT03.h" #include "Resource/BITMAP/CREDIT03.bmp.h"
#include "Resource/Bitmap/CREDIT04.h" #include "Resource/BITMAP/CREDIT04.bmp.h"
#include "Resource/Bitmap/CREDIT05.h" #include "Resource/BITMAP/CREDIT05.bmp.h"
#include "Resource/Bitmap/CREDIT06.h" #include "Resource/BITMAP/CREDIT06.bmp.h"
#include "Resource/Bitmap/CREDIT07.h" #include "Resource/BITMAP/CREDIT07.bmp.h"
#include "Resource/Bitmap/CREDIT08.h" #include "Resource/BITMAP/CREDIT08.bmp.h"
#include "Resource/Bitmap/CREDIT09.h" #include "Resource/BITMAP/CREDIT09.bmp.h"
#include "Resource/Bitmap/CREDIT10.h" #include "Resource/BITMAP/CREDIT10.bmp.h"
#include "Resource/Bitmap/CREDIT11.h" #include "Resource/BITMAP/CREDIT11.bmp.h"
#include "Resource/Bitmap/CREDIT12.h" #include "Resource/BITMAP/CREDIT12.bmp.h"
#include "Resource/Bitmap/CREDIT14.h" #include "Resource/BITMAP/CREDIT14.bmp.h"
#include "Resource/Bitmap/CREDIT15.h" #include "Resource/BITMAP/CREDIT15.bmp.h"
#include "Resource/Bitmap/CREDIT16.h" #include "Resource/BITMAP/CREDIT16.bmp.h"
#include "Resource/Bitmap/CREDIT17.h" #include "Resource/BITMAP/CREDIT17.bmp.h"
#include "Resource/Bitmap/CREDIT18.h" #include "Resource/BITMAP/CREDIT18.bmp.h"
#include "Resource/Bitmap/PIXEL.h" #include "Resource/BITMAP/PIXEL.bmp.h"
#include "Resource/Icon/ICON4.h" #include "Resource/ICON/4.bmp.h"
const unsigned char* GetResource(const char *name, size_t *size) const unsigned char* GetResource(const char *name, size_t *size)
{ {
@ -383,8 +383,8 @@ const unsigned char* GetResource(const char *name, size_t *size)
//ICON //ICON
if (!strcmp(name, "ICON4")) if (!strcmp(name, "ICON4"))
{ {
*size = sizeof(rICON4); *size = sizeof(r4);
return rICON4; return r4;
} }
return NULL; return NULL;
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more