shithub: cstory

Download patch

ref: 1f3728c177741b5cdf9a0fbebb47968374fdc839
parent: c00262bcd83657b1f8b06a47d4777ab2145ef3a9
author: Clownacy <Clownacy@users.noreply.github.com>
date: Mon Sep 2 19:32:19 EDT 2019

Restore the new resource file system

--- a/Makefile
+++ b/Makefile
@@ -116,6 +116,7 @@
 	src/Organya \
 	src/PixTone \
 	src/Profile \
+	src/Resource \
 	src/SelStage \
 	src/Shoot \
 	src/Sound \
@@ -125,6 +126,76 @@
 	src/Triangle \
 	src/ValueView
 
+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 \
+	CURSOR/CURSOR_IKA.bmp \
+	CURSOR/CURSOR_NORMAL.bmp \
+	ORG/Access.org \
+	ORG/Anzen.org \
+	ORG/Balcony.org \
+	ORG/Ballos.org \
+	ORG/BreakDown.org \
+	ORG/Cemetery.org \
+	ORG/Curly.org \
+	ORG/Dr.org \
+	ORG/Ending.org \
+	ORG/Escape.org \
+	ORG/Fanfale1.org \
+	ORG/Fanfale2.org \
+	ORG/Fanfale3.org \
+	ORG/FireEye.org \
+	ORG/Gameover.org \
+	ORG/Ginsuke.org \
+	ORG/Grand.org \
+	ORG/Gravity.org \
+	ORG/Hell.org \
+	ORG/ironH.org \
+	ORG/Jenka.org \
+	ORG/Jenka2.org \
+	ORG/Kodou.org \
+	ORG/LastBtl3.org \
+	ORG/LastBtl.org \
+	ORG/LastCave.org \
+	ORG/Marine.org \
+	ORG/Maze.org \
+	ORG/MDown2.org \
+	ORG/Mura.org \
+	ORG/Oside.org \
+	ORG/Plant.org \
+	ORG/quiet.org \
+	ORG/Requiem.org \
+	ORG/Toroko.org \
+	ORG/Vivi.org \
+	ORG/Wanpak2.org \
+	ORG/Wanpaku.org \
+	ORG/Weed.org \
+	ORG/White.org \
+	ORG/XXXX.org \
+	ORG/Zonbie.org \
+	WAVE/Wave.dat
+
+ifeq ($(JAPANESE), 1)
+	RESOURCES += BITMAP/pixel_jp.bmp
+else
+	RESOURCES += BITMAP/pixel.bmp
+endif
+
 ifeq ($(RENDERER), OpenGL3)
 	SOURCES += src/Backends/Rendering/OpenGL3
 	CXXFLAGS += `pkg-config glew --cflags`
@@ -173,6 +244,21 @@
 	@mkdir -p $(@D)
 	@echo Compiling $<
 	@$(CXX) $(CXXFLAGS) $< -o $@ -c
+
+obj/$(FILENAME)/Resource.o: src/Resource.cpp $(addprefix src/Resource/, $(addsuffix .h, $(RESOURCES)))
+	@mkdir -p $(@D)
+	@echo Compiling $<
+	@$(CXX) $(CXXFLAGS) $< -o $@ -c
+
+src/Resource/%.h: $(ASSETS_DIRECTORY)/resources/% obj/bin2h
+	@mkdir -p $(@D)
+	@echo Converting $<
+	@obj/bin2h $< $@
+
+obj/bin2h: bin2h/bin2h.c
+	@mkdir -p $(@D)
+	@echo Compiling $^
+	@$(NATIVECC) -O3 -s -std=c90 -Wall -Wextra -pedantic $^ -o $@
 
 include $(wildcard $(DEPENDENCIES))
 
--- a/msvc2003/CSE2.rc
+++ b/msvc2003/CSE2.rc
@@ -58,86 +58,6 @@
     END
 END
 
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Bitmap
-//
-
-CREDIT01                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit01.bmp"
-CREDIT02                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit02.bmp"
-CREDIT03                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit03.bmp"
-CREDIT04                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit04.bmp"
-CREDIT05                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit05.bmp"
-CREDIT06                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit06.bmp"
-CREDIT07                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit07.bmp"
-CREDIT08                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit08.bmp"
-CREDIT09                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit09.bmp"
-CREDIT10                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit10.bmp"
-CREDIT11                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit11.bmp"
-CREDIT12                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit12.bmp"
-CREDIT14                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit14.bmp"
-CREDIT15                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit15.bmp"
-CREDIT16                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit16.bmp"
-CREDIT17                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit17.bmp"
-CREDIT18                BITMAP                  "..\\assets\\resources\\BITMAP\\Credit18.bmp"
-PIXEL                   BITMAP                  "..\\assets\\resources\\BITMAP\\pixel.bmp"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// ORG
-//
-
-ACCESS                  ORG                     "..\\assets\\resources\\ORG\\Access.org"
-ANZEN                   ORG                     "..\\assets\\resources\\ORG\\Anzen.org"
-BALCONY                 ORG                     "..\\assets\\resources\\ORG\\Balcony.org"
-BALLOS                  ORG                     "..\\assets\\resources\\ORG\\Ballos.org"
-BDOWN                   ORG                     "..\\assets\\resources\\ORG\\BreakDown.org"
-CEMETERY                ORG                     "..\\assets\\resources\\ORG\\Cemetery.org"
-CURLY                   ORG                     "..\\assets\\resources\\ORG\\Curly.org"
-DR                      ORG                     "..\\assets\\resources\\ORG\\Dr.org"
-ENDING                  ORG                     "..\\assets\\resources\\ORG\\Ending.org"
-ESCAPE                  ORG                     "..\\assets\\resources\\ORG\\Escape.org"
-FANFALE1                ORG                     "..\\assets\\resources\\ORG\\Fanfale1.org"
-FANFALE2                ORG                     "..\\assets\\resources\\ORG\\Fanfale2.org"
-FANFALE3                ORG                     "..\\assets\\resources\\ORG\\Fanfale3.org"
-FIREEYE                 ORG                     "..\\assets\\resources\\ORG\\FireEye.org"
-GAMEOVER                ORG                     "..\\assets\\resources\\ORG\\Gameover.org"
-GINSUKE                 ORG                     "..\\assets\\resources\\ORG\\Ginsuke.org"
-GRAND                   ORG                     "..\\assets\\resources\\ORG\\Grand.org"
-GRAVITY                 ORG                     "..\\assets\\resources\\ORG\\Gravity.org"
-HELL                    ORG                     "..\\assets\\resources\\ORG\\Hell.org"
-IRONH                   ORG                     "..\\assets\\resources\\ORG\\ironH.org"
-JENKA                   ORG                     "..\\assets\\resources\\ORG\\Jenka.org"
-JENKA2                  ORG                     "..\\assets\\resources\\ORG\\Jenka2.org"
-KODOU                   ORG                     "..\\assets\\resources\\ORG\\Kodou.org"
-LASTBTL                 ORG                     "..\\assets\\resources\\ORG\\LastBtl.org"
-LASTBT3                 ORG                     "..\\assets\\resources\\ORG\\LastBtl3.org"
-LASTCAVE                ORG                     "..\\assets\\resources\\ORG\\LastCave.org"
-MARINE                  ORG                     "..\\assets\\resources\\ORG\\Marine.org"
-MAZE                    ORG                     "..\\assets\\resources\\ORG\\Maze.org"
-MDOWN2                  ORG                     "..\\assets\\resources\\ORG\\MDown2.org"
-OSIDE                   ORG                     "..\\assets\\resources\\ORG\\Oside.org"
-MURA                    ORG                     "..\\assets\\resources\\ORG\\Mura.org"
-PLANT                   ORG                     "..\\assets\\resources\\ORG\\Plant.org"
-QUIET                   ORG                     "..\\assets\\resources\\ORG\\quiet.org"
-REQUIEM                 ORG                     "..\\assets\\resources\\ORG\\Requiem.org"
-TOROKO                  ORG                     "..\\assets\\resources\\ORG\\Toroko.org"
-VIVI                    ORG                     "..\\assets\\resources\\ORG\\Vivi.org"
-WANPAK2                 ORG                     "..\\assets\\resources\\ORG\\Wanpak2.org"
-WANPAKU                 ORG                     "..\\assets\\resources\\ORG\\Wanpaku.org"
-WEED                    ORG                     "..\\assets\\resources\\ORG\\Weed.org"
-WHITE                   ORG                     "..\\assets\\resources\\ORG\\White.org"
-XXXX                    ORG                     "..\\assets\\resources\\ORG\\XXXX.org"
-ZONBIE                  ORG                     "..\\assets\\resources\\ORG\\Zonbie.org"
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// WAVE
-//
-
-WAVE100                 WAVE                    "..\\assets\\resources\\WAVE\\Wave.dat"
-
 CURSOR_IKA CURSOR "..\\assets\\resources\\CURSOR\\CURSOR_IKA.cur"
 
 CURSOR_NORMAL CURSOR "..\\assets\\resources\\CURSOR\\CURSOR_NORMAL.cur"
--- a/src/Draw.cpp
+++ b/src/Draw.cpp
@@ -13,6 +13,7 @@
 #include "Ending.h"
 #include "Generic.h"
 #include "MapName.h"
+#include "Resource.h"
 #include "Tags.h"
 #include "TextScr.h"
 
@@ -211,26 +212,13 @@
 	if (surf[surf_no] != NULL)
 		return FALSE;
 
-	HRSRC hrscr = FindResourceA(NULL, name, RT_BITMAP);
+	size_t size;
+	const unsigned char *data = FindResource(name, "BITMAP", &size);
 
-	if (hrscr == NULL)
+	if (data == NULL)
 		return FALSE;
 
-	size_t size = SizeofResource(NULL, hrscr);
-	const unsigned char *data = (unsigned char*)LockResource(LoadResource(NULL, hrscr));
-
-	// The bitmap we get from LockResource is incomplete, so we need to restore its missing header here
-	unsigned char *bmp_buffer = (unsigned char*)malloc(size + 0xE);
-
-	if (bmp_buffer == NULL)
-		return FALSE;
-
-	const unsigned char bmp_header[0xE] = {0x42, 0x4D, 0x76, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00};
-
-	memcpy(bmp_buffer, bmp_header, 0xE);
-	memcpy(bmp_buffer + 0xE, data, size);
-
-	SDL_RWops *fp = SDL_RWFromConstMem(bmp_buffer, size + 0xE);
+	SDL_RWops *fp = SDL_RWFromConstMem(data, size);
 	SDL_Surface *surface = SDL_LoadBMP_RW(fp, 1);
 
 	surf[surf_no] = Backend_CreateSurface(surface->w * magnification, surface->h * magnification);
@@ -321,26 +309,10 @@
 	if (surf_no >= SURFACE_ID_MAX)
 		return FALSE;
 
-	HRSRC hrscr = FindResourceA(NULL, name, RT_BITMAP);
+	size_t size;
+	const unsigned char *data = FindResource(name, "BITMAP", &size);
 
-	if (hrscr == NULL)
-		return FALSE;
-
-	size_t size = SizeofResource(NULL, hrscr);
-	const unsigned char *data = (unsigned char*)LockResource(LoadResource(NULL, hrscr));
-
-	// The bitmap we get from LockResource is incomplete, so we need to restore its missing header here
-	unsigned char *bmp_buffer = (unsigned char*)malloc(size + 0xE);
-
-	if (bmp_buffer == NULL)
-		return FALSE;
-
-	const unsigned char bmp_header[0xE] = {0x42, 0x4D, 0x76, 0x4B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00};
-
-	memcpy(bmp_buffer, bmp_header, 0xE);
-	memcpy(bmp_buffer + 0xE, data, size);
-
-	SDL_RWops *fp = SDL_RWFromConstMem(bmp_buffer, size + 0xE);
+	SDL_RWops *fp = SDL_RWFromConstMem(data, size);
 	SDL_Surface *surface = SDL_LoadBMP_RW(fp, 1);
 
 	if (!ScaleAndUploadSurface(surface, surf_no))
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -14,6 +14,7 @@
 
 #include "WindowsWrapper.h"
 
+#include "Resource.h"
 #include "Sound.h"
 
 #define PANDUMMY 0xFF
@@ -358,20 +359,17 @@
 
 BOOL InitWaveData100(void)
 {
-	HRSRC hrscr;
-	DWORD *lpdword;	// リソースのアドレス (Resource address)
+	const DWORD *lpdword;	// リソースのアドレス (Resource address)
 
 	if (lpDS == NULL)
 		return FALSE;
 
 	// リソースの検索 (Search for resources)
-	hrscr = FindResourceA(NULL, "WAVE100", "WAVE");
+	lpdword = (DWORD*)FindResource("WAVE100", "WAVE", NULL);
 
-	if (hrscr == NULL)
+	if (lpdword == NULL)
 		return FALSE;
 
-	// リソースのアドレスを取得 (Get resource address)
-	lpdword = (DWORD*)LockResource(LoadResource(NULL, hrscr));
 	memcpy(wave_data, lpdword, 100 * 0x100);
 
 	return TRUE;
@@ -607,11 +605,9 @@
 	char pass_check[6];
 	char ver = 0;
 
-	HRSRC hrscr = FindResourceA(NULL, path, "ORG");
-	if (hrscr == NULL)
+	const unsigned char *p = FindResource(path, "ORG", NULL);
+	if (p == NULL)
 		return FALSE;
-
-	unsigned char *p = (unsigned char*)LockResource(LoadResource(0, hrscr));
 
 	memcpy(&pass_check[0], p, 6);
 	p += 6;
--- /dev/null
+++ b/src/Resource.cpp
@@ -1,0 +1,166 @@
+#include "Resource.h"
+
+#include <stddef.h>
+#include <string.h>
+
+#include "Resource/ORG/Access.org.h"
+#include "Resource/ORG/Anzen.org.h"
+#include "Resource/ORG/Balcony.org.h"
+#include "Resource/ORG/Ballos.org.h"
+#include "Resource/ORG/BreakDown.org.h"
+#include "Resource/ORG/Cemetery.org.h"
+#include "Resource/ORG/Curly.org.h"
+#include "Resource/ORG/Dr.org.h"
+#include "Resource/ORG/Ending.org.h"
+#include "Resource/ORG/Escape.org.h"
+#include "Resource/ORG/Fanfale1.org.h"
+#include "Resource/ORG/Fanfale2.org.h"
+#include "Resource/ORG/Fanfale3.org.h"
+#include "Resource/ORG/FireEye.org.h"
+#include "Resource/ORG/Gameover.org.h"
+#include "Resource/ORG/Ginsuke.org.h"
+#include "Resource/ORG/Grand.org.h"
+#include "Resource/ORG/Gravity.org.h"
+#include "Resource/ORG/Hell.org.h"
+#include "Resource/ORG/ironH.org.h"
+#include "Resource/ORG/Jenka.org.h"
+#include "Resource/ORG/Jenka2.org.h"
+#include "Resource/ORG/Kodou.org.h"
+#include "Resource/ORG/LastBtl3.org.h"
+#include "Resource/ORG/LastBtl.org.h"
+#include "Resource/ORG/LastCave.org.h"
+#include "Resource/ORG/Marine.org.h"
+#include "Resource/ORG/Maze.org.h"
+#include "Resource/ORG/MDown2.org.h"
+#include "Resource/ORG/Mura.org.h"
+#include "Resource/ORG/Oside.org.h"
+#include "Resource/ORG/Plant.org.h"
+#include "Resource/ORG/quiet.org.h"
+#include "Resource/ORG/Requiem.org.h"
+#include "Resource/ORG/Toroko.org.h"
+#include "Resource/ORG/Vivi.org.h"
+#include "Resource/ORG/Wanpak2.org.h"
+#include "Resource/ORG/Wanpaku.org.h"
+#include "Resource/ORG/Weed.org.h"
+#include "Resource/ORG/White.org.h"
+#include "Resource/ORG/XXXX.org.h"
+#include "Resource/ORG/Zonbie.org.h"
+#include "Resource/WAVE/Wave.dat.h"
+#include "Resource/BITMAP/Credit01.bmp.h"
+#include "Resource/BITMAP/Credit02.bmp.h"
+#include "Resource/BITMAP/Credit03.bmp.h"
+#include "Resource/BITMAP/Credit04.bmp.h"
+#include "Resource/BITMAP/Credit05.bmp.h"
+#include "Resource/BITMAP/Credit06.bmp.h"
+#include "Resource/BITMAP/Credit07.bmp.h"
+#include "Resource/BITMAP/Credit08.bmp.h"
+#include "Resource/BITMAP/Credit09.bmp.h"
+#include "Resource/BITMAP/Credit10.bmp.h"
+#include "Resource/BITMAP/Credit11.bmp.h"
+#include "Resource/BITMAP/Credit12.bmp.h"
+#include "Resource/BITMAP/Credit14.bmp.h"
+#include "Resource/BITMAP/Credit15.bmp.h"
+#include "Resource/BITMAP/Credit16.bmp.h"
+#include "Resource/BITMAP/Credit17.bmp.h"
+#include "Resource/BITMAP/Credit18.bmp.h"
+#ifdef JAPANESE
+#include "Resource/BITMAP/pixel_jp.bmp.h"
+#else
+#include "Resource/BITMAP/pixel.bmp.h"
+#endif
+
+static const struct
+{
+	const char *type;
+	const char *name;
+	const unsigned char *data;
+	size_t size;
+} resources[] = {
+	{"ORG", "ACCESS", rAccess, sizeof(rAccess)},
+	{"ORG", "ANZEN", rAnzen, sizeof(rAnzen)},
+	{"ORG", "BALCONY", rBalcony, sizeof(rBalcony)},
+	{"ORG", "BALLOS", rBallos, sizeof(rBallos)},
+	{"ORG", "BDOWN", rBreakDown, sizeof(rBreakDown)},
+	{"ORG", "CEMETERY", rCemetery, sizeof(rCemetery)},
+#ifdef NONPORTABLE
+	{"ORG", "Curly", rCurly, sizeof(rCurly)},
+#else
+	{"ORG", "CURLY", rCurly, sizeof(rCurly)},
+#endif
+	{"ORG", "DR", rDr, sizeof(rDr)},
+	{"ORG", "ENDING", rEnding, sizeof(rEnding)},
+	{"ORG", "ESCAPE", rEscape, sizeof(rEscape)},
+	{"ORG", "FANFALE1", rFanfale1, sizeof(rFanfale1)},
+	{"ORG", "FANFALE2", rFanfale2, sizeof(rFanfale2)},
+	{"ORG", "FANFALE3", rFanfale3, sizeof(rFanfale3)},
+	{"ORG", "FIREEYE", rFireEye, sizeof(rFireEye)},
+	{"ORG", "GAMEOVER", rGameover, sizeof(rGameover)},
+	{"ORG", "GINSUKE", rGinsuke, sizeof(rGinsuke)},
+	{"ORG", "GRAND", rGrand, sizeof(rGrand)},
+	{"ORG", "GRAVITY", rGravity, sizeof(rGravity)},
+	{"ORG", "HELL", rHell, sizeof(rHell)},
+	{"ORG", "IRONH", rironH, sizeof(rironH)},
+	{"ORG", "JENKA", rJenka, sizeof(rJenka)},
+	{"ORG", "JENKA2", rJenka2, sizeof(rJenka2)},
+	{"ORG", "KODOU", rKodou, sizeof(rKodou)},
+	{"ORG", "LASTBT3", rLastBtl3, sizeof(rLastBtl3)},
+	{"ORG", "LASTBTL", rLastBtl, sizeof(rLastBtl)},
+	{"ORG", "LASTCAVE", rLastCave, sizeof(rLastCave)},
+	{"ORG", "MARINE", rMarine, sizeof(rMarine)},
+	{"ORG", "MAZE", rMaze, sizeof(rMaze)},
+	{"ORG", "MDOWN2", rMDown2, sizeof(rMDown2)},
+	{"ORG", "MURA", rMura, sizeof(rMura)},
+	{"ORG", "OSIDE", rOside, sizeof(rOside)},
+	{"ORG", "PLANT", rPlant, sizeof(rPlant)},
+	{"ORG", "QUIET", rquiet, sizeof(rquiet)},
+	{"ORG", "REQUIEM", rRequiem, sizeof(rRequiem)},
+	{"ORG", "TOROKO", rToroko, sizeof(rToroko)},
+	{"ORG", "VIVI", rVivi, sizeof(rVivi)},
+	{"ORG", "WANPAK2", rWanpak2, sizeof(rWanpak2)},
+	{"ORG", "WANPAKU", rWanpaku, sizeof(rWanpaku)},
+	{"ORG", "WEED", rWeed, sizeof(rWeed)},
+	{"ORG", "WHITE", rWhite, sizeof(rWhite)},
+	{"ORG", "XXXX", rXXXX, sizeof(rXXXX)},
+	{"ORG", "ZONBIE", rZonbie, sizeof(rZonbie)},
+
+	{"WAVE", "WAVE100", rWave, sizeof(rWave)},
+
+	{"BITMAP", "CREDIT01", rCredit01, sizeof(rCredit01)},
+	{"BITMAP", "CREDIT02", rCredit02, sizeof(rCredit02)},
+	{"BITMAP", "CREDIT03", rCredit03, sizeof(rCredit03)},
+	{"BITMAP", "CREDIT04", rCredit04, sizeof(rCredit04)},
+	{"BITMAP", "CREDIT05", rCredit05, sizeof(rCredit05)},
+	{"BITMAP", "CREDIT06", rCredit06, sizeof(rCredit06)},
+	{"BITMAP", "CREDIT07", rCredit07, sizeof(rCredit07)},
+	{"BITMAP", "CREDIT08", rCredit08, sizeof(rCredit08)},
+	{"BITMAP", "CREDIT09", rCredit09, sizeof(rCredit09)},
+	{"BITMAP", "CREDIT10", rCredit10, sizeof(rCredit10)},
+	{"BITMAP", "CREDIT11", rCredit11, sizeof(rCredit11)},
+	{"BITMAP", "CREDIT12", rCredit12, sizeof(rCredit12)},
+	{"BITMAP", "CREDIT14", rCredit14, sizeof(rCredit14)},
+	{"BITMAP", "CREDIT15", rCredit15, sizeof(rCredit15)},
+	{"BITMAP", "CREDIT16", rCredit16, sizeof(rCredit16)},
+	{"BITMAP", "CREDIT17", rCredit17, sizeof(rCredit17)},
+	{"BITMAP", "CREDIT18", rCredit18, sizeof(rCredit18)},
+#ifdef JAPANESE
+	{"BITMAP", "PIXEL", rpixel_jp, sizeof(rpixel_jp)},
+#else
+	{"BITMAP", "PIXEL", rpixel, sizeof(rpixel)},
+#endif
+};
+
+const unsigned char* FindResource(const char *name, const char *type, size_t *size)
+{
+	for (unsigned int i = 0; i < sizeof(resources) / sizeof(resources[0]); ++i)
+	{
+		if (!strcmp(name, resources[i].name) && !strcmp(type, resources[i].type))
+		{
+			if (size)
+				*size = resources[i].size;
+
+			return resources[i].data;
+		}
+	}
+
+	return NULL;
+}
--- /dev/null
+++ b/src/Resource.h
@@ -1,0 +1,5 @@
+#pragma once
+
+#include <stddef.h>
+
+const unsigned char* FindResource(const char *name, const char *type, size_t *size);
--