Added automatic compile-time resource conversion
I've included the .h files in the repo since I might add automatic resource generation in the future, and in order for that to work, all .h files must be present on the first pass.
81
Makefile
|
@ -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
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT02.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT03.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT04.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT05.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT06.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT07.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT08.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT09.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT10.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT11.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT12.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT14.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT15.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT16.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT17.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/CREDIT18.bmp
Normal file
After Width: | Height: | Size: 19 KiB |
BIN
res/BITMAP/PIXEL.bmp
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
res/ICON/3.ico
Normal file
After Width: | Height: | Size: 766 B |
BIN
res/ICON/3s.ico
Normal file
After Width: | Height: | Size: 766 B |
BIN
res/ICON/4.bmp
Normal file
After Width: | Height: | Size: 2.2 KiB |
BIN
res/ICON/4.ico
Normal file
After Width: | Height: | Size: 318 B |
BIN
res/ICON/4s.ico
Normal file
BIN
res/ORG/ACCESS
Normal file
BIN
res/ORG/ANZEN
Normal file
BIN
res/ORG/BALCONY
Normal file
BIN
res/ORG/BALLOS
Normal file
BIN
res/ORG/BDOWN
Normal file
BIN
res/ORG/CEMETERY
Normal file
BIN
res/ORG/CURLY
Normal file
BIN
res/ORG/DR
Normal file
BIN
res/ORG/ENDING
Normal file
BIN
res/ORG/ESCAPE
Normal file
BIN
res/ORG/FANFALE1
Normal file
BIN
res/ORG/FANFALE2
Normal file
BIN
res/ORG/FANFALE3
Normal file
BIN
res/ORG/FIREEYE
Normal file
BIN
res/ORG/GAMEOVER
Normal file
BIN
res/ORG/GINSUKE
Normal file
BIN
res/ORG/GRAND
Normal file
BIN
res/ORG/GRAVITY
Normal file
BIN
res/ORG/HELL
Normal file
BIN
res/ORG/IRONH
Normal file
BIN
res/ORG/JENKA
Normal file
BIN
res/ORG/JENKA2
Normal file
BIN
res/ORG/KODOU
Normal file
BIN
res/ORG/LASTBT3
Normal file
BIN
res/ORG/LASTBTL
Normal file
BIN
res/ORG/LASTCAVE
Normal file
BIN
res/ORG/MARINE
Normal file
BIN
res/ORG/MAZE
Normal file
BIN
res/ORG/MDOWN2
Normal file
BIN
res/ORG/MURA
Normal file
BIN
res/ORG/OSIDE
Normal file
BIN
res/ORG/PLANT
Normal file
BIN
res/ORG/QUIET
Normal file
BIN
res/ORG/REQUIEM
Normal file
BIN
res/ORG/TOROKO
Normal file
BIN
res/ORG/VIVI
Normal file
BIN
res/ORG/WANPAK2
Normal file
BIN
res/ORG/WANPAKU
Normal file
BIN
res/ORG/WEED
Normal file
BIN
res/ORG/WHITE
Normal file
BIN
res/ORG/XXXX
Normal file
BIN
res/ORG/ZONBIE
Normal file
BIN
res/WAVE/WAVE100
Normal file
71
res/bin2h.cpp
Normal 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;
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|