diff --git a/Makefile b/Makefile index a8b33ca1..2f91fa1b 100644 --- a/Makefile +++ b/Makefile @@ -129,7 +129,8 @@ RESOURCES = \ BITMAP/CREDIT16.bmp \ BITMAP/CREDIT17.bmp \ BITMAP/CREDIT18.bmp \ - ICON/4.bmp \ + CURSOR/CURSOR_IKA.bmp \ + CURSOR/CURSOR_NORMAL.bmp \ ORG/ACCESS \ ORG/ANZEN \ ORG/BALCONY \ @@ -180,8 +181,16 @@ else RESOURCES += BITMAP/PIXEL.bmp endif +ifneq ($(WINDOWS), 1) + RESOURCES += ICON/ICON_MINI.bmp +endif + OBJECTS = $(addprefix obj/$(FILENAME)/, $(addsuffix .o, $(SOURCES))) +ifeq ($(WINDOWS), 1) +OBJECTS += obj/$(FILENAME)/win_icon.o +endif + all: build/$(FILENAME) build/$(FILENAME): $(OBJECTS) @@ -209,5 +218,9 @@ obj/bin2h: res/bin2h.c @echo Compiling $^ @gcc -O3 -s -static $^ -o $@ +obj/$(FILENAME)/win_icon.o: res/ICON/ICON.rc res/ICON/0.ico res/ICON/ICON_MINI.ico + @mkdir -p $(@D) + @windres $< $@ + clean: @rm -rf build obj diff --git a/res/CURSOR/CURSOR_IKA.bmp b/res/CURSOR/CURSOR_IKA.bmp new file mode 100644 index 00000000..6c14d1a2 Binary files /dev/null and b/res/CURSOR/CURSOR_IKA.bmp differ diff --git a/res/CURSOR/CURSOR_IKA.png b/res/CURSOR/CURSOR_IKA.png new file mode 100644 index 00000000..c497cca7 Binary files /dev/null and b/res/CURSOR/CURSOR_IKA.png differ diff --git a/res/CURSOR/CURSOR_NORMAL.bmp b/res/CURSOR/CURSOR_NORMAL.bmp new file mode 100644 index 00000000..702deaf0 Binary files /dev/null and b/res/CURSOR/CURSOR_NORMAL.bmp differ diff --git a/res/CURSOR/CURSOR_NORMAL.png b/res/CURSOR/CURSOR_NORMAL.png new file mode 100644 index 00000000..b708311f Binary files /dev/null and b/res/CURSOR/CURSOR_NORMAL.png differ diff --git a/res/ICON/0.ico b/res/ICON/0.ico new file mode 100644 index 00000000..33fc2aa3 Binary files /dev/null and b/res/ICON/0.ico differ diff --git a/res/ICON/ICON.rc b/res/ICON/ICON.rc new file mode 100644 index 00000000..f6a1f0b3 --- /dev/null +++ b/res/ICON/ICON.rc @@ -0,0 +1,2 @@ +101 ICON "0.ico" +102 ICON "ICON_MINI.ico" diff --git a/res/ICON/4.bmp b/res/ICON/ICON_MINI.bmp similarity index 100% rename from res/ICON/4.bmp rename to res/ICON/ICON_MINI.bmp diff --git a/res/ICON/ICON_MINI.ico b/res/ICON/ICON_MINI.ico new file mode 100644 index 00000000..b540fd2f Binary files /dev/null and b/res/ICON/ICON_MINI.ico differ diff --git a/src/Main.cpp b/src/Main.cpp index 547cb977..326b9a4c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -102,7 +102,13 @@ int main(int argc, char *argv[]) //Get path of the data folder strcpy(gDataPath, gModulePath); memcpy(&gDataPath[strlen(gDataPath)], "/data", 6); //Pixel didn't use a strcat - + +#ifdef WINDOWS + // Set the window icons. See res/ICON/ICON.rc. + SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON, "101"); + SDL_SetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL, "102"); +#endif + //Initialize SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_EVENTS | SDL_INIT_GAMECONTROLLER) >= 0) { @@ -204,7 +210,29 @@ int main(int argc, char *argv[]) } RECT unused_rect = {0, 0, 320, 240}; + + //Load cursor + SDL_RWops *fp = FindResource("CURSOR_NORMAL"); + if (fp) + { + SDL_Surface *cursor_surface = SDL_LoadBMP_RW(fp, 1); + SDL_SetColorKey(cursor_surface, SDL_TRUE, SDL_MapRGB(cursor_surface->format, 0xFF, 0, 0xFF)); // Pink regions are transparent + + SDL_Cursor *cursor = SDL_CreateColorCursor(cursor_surface, 0, 0); // Don't worry, the hotspots are accurate to the original files + + if (cursor) + SDL_SetCursor(cursor); + else + printf("Failed to load cursor"); + + SDL_FreeSurface(cursor_surface); + } + else + { + printf("Failed to load cursor"); + } + //Get window dimensions and colour depth int colourDepth = 16; @@ -263,8 +291,9 @@ int main(int argc, char *argv[]) if (CheckFileExists("fps")) bFps = true; +#ifndef WINDOWS //Load icon - SDL_RWops *fp = FindResource("ICON4"); + SDL_RWops *fp = FindResource("ICON_MINI"); if (fp) { @@ -281,7 +310,8 @@ int main(int argc, char *argv[]) { printf("Failed to load icon"); } - +#endif + //Set rects RECT loading_rect = {0, 0, 64, 8}; RECT clip_rect = {0, 0, gWindowWidth, gWindowHeight}; diff --git a/src/Resource.cpp b/src/Resource.cpp index 1cae74a4..4ab54a9e 100644 --- a/src/Resource.cpp +++ b/src/Resource.cpp @@ -69,7 +69,11 @@ #else #include "Resource/BITMAP/PIXEL.bmp.h" #endif -#include "Resource/ICON/4.bmp.h" +#ifndef WINDOWS +#include "Resource/ICON/ICON_MINI.bmp.h" +#endif +#include "Resource/CURSOR/CURSOR_IKA.bmp.h" +#include "Resource/CURSOR/CURSOR_NORMAL.bmp.h" const unsigned char* GetResource(const char *name, size_t *size) { @@ -389,11 +393,25 @@ const unsigned char* GetResource(const char *name, size_t *size) #endif } +#ifndef WINDOWS //ICON - if (!strcmp(name, "ICON4")) + if (!strcmp(name, "ICON_MINI")) { - *size = sizeof(r4); - return r4; + *size = sizeof(rICON_MINI); + return rICON_MINI; + } +#endif + + //CURSOR + if (!strcmp(name, "CURSOR_NORMAL")) + { + *size = sizeof(rCURSOR_NORMAL); + return rCURSOR_NORMAL; + } + if (!strcmp(name, "CURSOR_IKA")) + { + *size = sizeof(rCURSOR_IKA); + return rCURSOR_IKA; } return NULL; } diff --git a/src/Resource/CURSOR/CURSOR_IKA.bmp.h b/src/Resource/CURSOR/CURSOR_IKA.bmp.h new file mode 100644 index 00000000..6d3a1368 --- /dev/null +++ b/src/Resource/CURSOR/CURSOR_IKA.bmp.h @@ -0,0 +1,45 @@ +#pragma once + +const unsigned char rCURSOR_IKA[0x28E] = { + 0x42, 0x4D, 0x8E, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8E, 0x00, 0x00, 0x00, 0x6C, 0x00, + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x23, 0x2E, 0x00, 0x00, 0x23, 0x2E, 0x00, 0x00, 0x05, 0x00, + 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0x80, 0x80, 0x80, 0x00, 0xC0, 0xC0, 0xC0, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x04, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x04, 0x40, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x03, 0x40, 0x04, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x10, 0x00, 0x30, 0x44, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x03, 0x30, 0x00, 0x34, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x04, 0x44, 0x00, 0x03, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x10, 0x44, 0x44, 0x40, 0x00, 0x00, 0x00, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x01, + 0x11, 0x04, 0x44, 0x04, 0x44, 0x00, 0x03, 0x44, 0x40, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00, + 0x10, 0x34, 0x40, 0x44, 0x44, 0x40, 0x00, 0x34, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x00, 0x34, 0x04, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x40, 0x04, 0x44, 0x44, 0x44, 0x44, 0x40, 0x03, 0x44, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x03, 0x44, 0x44, 0x44, 0x44, 0x44, 0x00, 0x34, 0x40, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x30, 0x44, 0x44, 0x44, 0x40, 0x44, 0x40, 0x00, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x42, 0x04, 0x44, 0x44, 0x04, 0x44, 0x43, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x44, 0x00, 0x44, 0x40, 0x44, 0x42, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x44, 0x40, 0x04, 0x44, 0x44, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x44, 0x44, 0x00, 0x34, 0x30, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x44, 0x44, 0x42, 0x00, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x44, 0x44, 0x44, 0x30, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x04, + 0x44, 0x44, 0x44, 0x44, 0x43, 0x01, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11 +}; diff --git a/src/Resource/CURSOR/CURSOR_NORMAL.bmp.h b/src/Resource/CURSOR/CURSOR_NORMAL.bmp.h new file mode 100644 index 00000000..084f17af --- /dev/null +++ b/src/Resource/CURSOR/CURSOR_NORMAL.bmp.h @@ -0,0 +1,21 @@ +#pragma once + +const unsigned char rCURSOR_NORMAL[0x102] = { + 0x42, 0x4D, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x6C, 0x00, + 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x23, 0x2E, 0x00, 0x00, 0x23, 0x2E, 0x00, 0x00, 0x02, 0x00, + 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x42, 0x47, 0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0xFF, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0xF0, + 0x00, 0x00, 0x10, 0xF0, 0x00, 0x00, 0x19, 0xE0, 0x00, 0x00, 0x1F, 0xE0, 0x00, 0x00, 0x1F, 0xC0, + 0x00, 0x00, 0x1F, 0xFC, 0x00, 0x00, 0x1F, 0xF8, 0x00, 0x00, 0x1F, 0xF0, 0x00, 0x00, 0x1F, 0xE0, + 0x00, 0x00, 0x1F, 0xC0, 0x00, 0x00, 0x1F, 0x80, 0x00, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x1E, 0x00, + 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00 +}; diff --git a/src/Resource/ICON/4.bmp.h b/src/Resource/ICON/ICON_MINI.bmp.h similarity index 97% rename from src/Resource/ICON/4.bmp.h rename to src/Resource/ICON/ICON_MINI.bmp.h index e4a42eb0..0fa84f4d 100644 --- a/src/Resource/ICON/4.bmp.h +++ b/src/Resource/ICON/ICON_MINI.bmp.h @@ -1,6 +1,6 @@ #pragma once -const unsigned char r4[0x11A] = { +const unsigned char rICON_MINI[0x11A] = { 0x42, 0x4D, 0x1A, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9A, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x23, 0x2E, 0x00, 0x00, 0x23, 0x2E, 0x00, 0x00, 0x08, 0x00,