From c1e9a550adde3e488e2484eb23426ed64292a6b5 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 13 Mar 2019 15:46:51 +0000 Subject: [PATCH 01/21] Fix: Don't use register modifier. --- src/path.cpp | 8 ++++---- src/path.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/path.cpp b/src/path.cpp index a1fdd6cf..a9c5703e 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -26,7 +26,7 @@ static char *stpcopy(char *dest, const char *src, unsigned maxlen) return dest + strlen(dest); } -void fnmerge(register char *pathP, const char *driveP, +void fnmerge(char *pathP, const char *driveP, const char *dirP, const char *nameP, const char *extP) { char *origpathP = pathP; @@ -54,9 +54,9 @@ void fnmerge(register char *pathP, const char *driveP, int fnsplit(const char *pathP, char *driveP, char *dirP, char *nameP, char *extP) { - register char *pB; - register int Wrk; - int Ret; + char *pB; + int Wrk; + int Ret; char buf[ MAXPATH+2 ]; diff --git a/src/path.h b/src/path.h index 38cdccfa..33bca74e 100644 --- a/src/path.h +++ b/src/path.h @@ -17,7 +17,7 @@ #define MAXFILE 1024 #define MAXEXT 32 -void fnmerge(register char *pathP, const char *driveP, +void fnmerge(char *pathP, const char *driveP, const char *dirP, const char *nameP, const char *extP); int fnsplit(const char *pathP, char *driveP, char *dirP, char *nameP, char *extP); From 2f1b9eb073ca5c241c0c89acd9d39e0a99203b26 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 13 Mar 2019 15:48:06 +0000 Subject: [PATCH 02/21] Remove: Autogenerated file. --- src/ttdpal.h | 558 --------------------------------------------------- 1 file changed, 558 deletions(-) delete mode 100644 src/ttdpal.h diff --git a/src/ttdpal.h b/src/ttdpal.h deleted file mode 100644 index 2f6737aa..00000000 --- a/src/ttdpal.h +++ /dev/null @@ -1,558 +0,0 @@ -// Autogenerated file. DO NOT EDIT! -// Edit Makefile.setup, pals/*.bcp, or pal2c.pl instead. - -#define NUM_PALS 8 - -extern U8 defaultpalettes[NUM_PALS][256*3]; - -#define PAL_ttd_norm 0 -#define PAL_ttw_norm 1 -#define PAL_ttd_cand 2 -#define PAL_ttw_cand 3 -#define PAL_tt1_norm 4 -#define PAL_tt1_mars 5 -#define PAL_ttw_pb_pal1 6 -#define PAL_ttw_pb_pal2 7 - -#ifdef DEFINE_PALS - - U8 defaultpalettes[NUM_PALS][256*3] = { -// PAL_ttd_norm - { - 0, 0,255, 16, 16, 16, 32, 32, 32, 48, 48, 48, // 0-3 - 64, 64, 64, 80, 80, 80, 100,100,100, 116,116,116, // 4-7 - 132,132,132, 148,148,148, 168,168,168, 184,184,184, // 8-11 - 200,200,200, 216,216,216, 232,232,232, 252,252,252, // 12-15 - 52, 60, 72, 68, 76, 92, 88, 96,112, 108,116,132, // 16-19 - 132,140,152, 156,160,172, 176,184,196, 204,208,220, // 20-23 - 48, 44, 4, 64, 60, 12, 80, 76, 20, 96, 92, 28, // 24-27 - 120,120, 64, 148,148,100, 176,176,132, 204,204,168, // 28-31 - 72, 44, 4, 88, 60, 20, 104, 80, 44, 124,104, 72, // 32-35 - 152,132, 92, 184,160,120, 212,188,148, 244,220,176, // 36-39 - 64, 0, 4, 88, 4, 16, 112, 16, 32, 136, 32, 52, // 40-43 - 160, 56, 76, 188, 84,108, 204,104,124, 220,132,144, // 44-47 - 236,156,164, 252,188,192, 252,208, 0, 252,232, 60, // 48-51 - 252,252,128, 76, 40, 0, 96, 60, 8, 116, 88, 28, // 52-55 - 136,116, 56, 156,136, 80, 176,156,108, 196,180,136, // 56-59 - 68, 24, 0, 96, 44, 4, 128, 68, 8, 156, 96, 16, // 60-63 - 184,120, 24, 212,156, 32, 232,184, 16, 252,212, 0, // 64-67 - 252,248,128, 252,252,192, 32, 4, 0, 64, 20, 8, // 68-71 - 84, 28, 16, 108, 44, 28, 128, 56, 40, 148, 72, 56, // 72-75 - 168, 92, 76, 184,108, 88, 196,128,108, 212,148,128, // 76-79 - 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, // 80-83 - 64,112, 12, 84,132, 20, 104,148, 28, 128,168, 44, // 84-87 - 28, 52, 24, 44, 68, 32, 60, 88, 48, 80,104, 60, // 88-91 - 104,124, 76, 128,148, 92, 152,176,108, 180,204,124, // 92-95 - 16, 52, 24, 32, 72, 44, 56, 96, 72, 76,116, 88, // 96-99 - 96,136,108, 120,164,136, 152,192,168, 184,220,200, // 100-103 - 32, 24, 0, 56, 28, 0, 72, 40, 4, 88, 52, 12, // 104-107 - 104, 64, 24, 124, 84, 44, 140,108, 64, 160,128, 88, // 108-111 - 76, 40, 16, 96, 52, 24, 116, 68, 40, 136, 84, 56, // 112-115 - 164, 96, 64, 184,112, 80, 204,128, 96, 212,148,112, // 116-119 - 224,168,128, 236,188,148, 80, 28, 4, 100, 40, 20, // 120-123 - 120, 56, 40, 140, 76, 64, 160,100, 96, 184,136,136, // 124-127 - 36, 40, 68, 48, 52, 84, 64, 64,100, 80, 80,116, // 128-131 - 100,100,136, 132,132,164, 172,172,192, 212,212,224, // 132-135 - 40, 20,112, 64, 44,144, 88, 64,172, 104, 76,196, // 136-139 - 120, 88,224, 140,104,252, 160,136,252, 188,168,252, // 140-143 - 0, 24,108, 0, 36,132, 0, 52,160, 0, 72,184, // 144-147 - 0, 96,212, 24,120,220, 56,144,232, 88,168,240, // 148-151 - 128,196,252, 188,224,252, 16, 64, 96, 24, 80,108, // 152-155 - 40, 96,120, 52,112,132, 80,140,160, 116,172,192, // 156-159 - 156,204,220, 204,240,252, 172, 52, 52, 212, 52, 52, // 160-163 - 252, 52, 52, 252,100, 88, 252,144,124, 252,184,160, // 164-167 - 252,216,200, 252,244,236, 72, 20,112, 92, 44,140, // 168-171 - 112, 68,168, 140,100,196, 168,136,224, 200,176,248, // 172-175 - 208,184,255, 232,208,252, 60, 0, 0, 92, 0, 0, // 176-179 - 128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, // 180-183 - 252, 0, 0, 252, 80, 0, 252,108, 0, 252,136, 0, // 184-187 - 252,164, 0, 252,192, 0, 252,220, 0, 252,252, 0, // 188-191 - 204,136, 8, 228,144, 4, 252,156, 0, 252,176, 48, // 192-195 - 252,196,100, 252,216,152, 8, 24, 88, 12, 36,104, // 196-199 - 20, 52,124, 28, 68,140, 40, 92,164, 56,120,188, // 200-203 - 72,152,216, 100,172,224, 92,156, 52, 108,176, 64, // 204-207 - 124,200, 76, 144,224, 92, 224,244,252, 200,236,248, // 208-211 - 180,220,236, 132,188,216, 88,152,172, 244, 0,244, // 212-215 - 245, 0,245, 246, 0,246, 247, 0,247, 248, 0,248, // 216-219 - 249, 0,249, 250, 0,250, 251, 0,251, 252, 0,252, // 220-223 - 253, 0,253, 254, 0,254, 255, 0,255, 76, 24, 8, // 224-227 - 108, 44, 24, 144, 72, 52, 176,108, 84, 210,146,126, // 228-231 - 252, 60, 0, 252, 84, 0, 252,104, 0, 252,124, 0, // 232-235 - 252,148, 0, 252,172, 0, 252,196, 0, 64, 0, 0, // 236-239 - 255, 0, 0, 48, 48, 0, 64, 64, 0, 80, 80, 0, // 240-243 - 255,255, 0, 32, 68,112, 36, 72,116, 40, 76,120, // 244-247 - 44, 80,124, 48, 84,128, 72,100,144, 100,132,168, // 248-251 - 216,244,252, 96,128,164, 68, 96,140, 255,255,255, // 252-255 - }, -// PAL_ttw_norm - { - 0, 0,255, 238, 0,238, 239, 0,239, 240, 0,240, // 0-3 - 241, 0,241, 242, 0,242, 243, 0,243, 244, 0,244, // 4-7 - 245, 0,245, 246, 0,246, 168,168,168, 184,184,184, // 8-11 - 200,200,200, 216,216,216, 232,232,232, 252,252,252, // 12-15 - 52, 60, 72, 68, 76, 92, 88, 96,112, 108,116,132, // 16-19 - 132,140,152, 156,160,172, 176,184,196, 204,208,220, // 20-23 - 48, 44, 4, 64, 60, 12, 80, 76, 20, 96, 92, 28, // 24-27 - 120,120, 64, 148,148,100, 176,176,132, 204,204,168, // 28-31 - 100,100,100, 116,116,116, 104, 80, 44, 124,104, 72, // 32-35 - 152,132, 92, 184,160,120, 212,188,148, 244,220,176, // 36-39 - 132,132,132, 88, 4, 16, 112, 16, 32, 136, 32, 52, // 40-43 - 160, 56, 76, 188, 84,108, 204,104,124, 220,132,144, // 44-47 - 236,156,164, 252,188,192, 252,208, 0, 252,232, 60, // 48-51 - 252,252,128, 76, 40, 0, 96, 60, 8, 116, 88, 28, // 52-55 - 136,116, 56, 156,136, 80, 176,156,108, 196,180,136, // 56-59 - 68, 24, 0, 96, 44, 4, 128, 68, 8, 156, 96, 16, // 60-63 - 184,120, 24, 212,156, 32, 232,184, 16, 252,212, 0, // 64-67 - 252,248,128, 252,252,192, 32, 4, 0, 64, 20, 8, // 68-71 - 84, 28, 16, 108, 44, 28, 128, 56, 40, 148, 72, 56, // 72-75 - 168, 92, 76, 184,108, 88, 196,128,108, 212,148,128, // 76-79 - 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, // 80-83 - 64,112, 12, 84,132, 20, 104,148, 28, 128,168, 44, // 84-87 - 64, 64, 64, 44, 68, 32, 60, 88, 48, 80,104, 60, // 88-91 - 104,124, 76, 128,148, 92, 152,176,108, 180,204,124, // 92-95 - 16, 52, 24, 32, 72, 44, 56, 96, 72, 76,116, 88, // 96-99 - 96,136,108, 120,164,136, 152,192,168, 184,220,200, // 100-103 - 32, 24, 0, 56, 28, 0, 80, 80, 80, 88, 52, 12, // 104-107 - 104, 64, 24, 124, 84, 44, 140,108, 64, 160,128, 88, // 108-111 - 76, 40, 16, 96, 52, 24, 116, 68, 40, 136, 84, 56, // 112-115 - 164, 96, 64, 184,112, 80, 204,128, 96, 212,148,112, // 116-119 - 224,168,128, 236,188,148, 80, 28, 4, 100, 40, 20, // 120-123 - 120, 56, 40, 140, 76, 64, 160,100, 96, 184,136,136, // 124-127 - 36, 40, 68, 48, 52, 84, 64, 64,100, 80, 80,116, // 128-131 - 100,100,136, 132,132,164, 172,172,192, 212,212,224, // 132-135 - 48, 48, 48, 64, 44,144, 88, 64,172, 104, 76,196, // 136-139 - 120, 88,224, 140,104,252, 160,136,252, 188,168,252, // 140-143 - 0, 24,108, 0, 36,132, 0, 52,160, 0, 72,184, // 144-147 - 0, 96,212, 24,120,220, 56,144,232, 88,168,240, // 148-151 - 128,196,252, 188,224,252, 16, 64, 96, 24, 80,108, // 152-155 - 40, 96,120, 52,112,132, 80,140,160, 116,172,192, // 156-159 - 156,204,220, 204,240,252, 172, 52, 52, 212, 52, 52, // 160-163 - 252, 52, 52, 252,100, 88, 252,144,124, 252,184,160, // 164-167 - 252,216,200, 252,244,236, 72, 20,112, 92, 44,140, // 168-171 - 112, 68,168, 140,100,196, 168,136,224, 200,176,248, // 172-175 - 208,184,255, 232,208,252, 60, 0, 0, 92, 0, 0, // 176-179 - 128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, // 180-183 - 252, 0, 0, 252, 80, 0, 252,108, 0, 252,136, 0, // 184-187 - 252,164, 0, 252,192, 0, 252,220, 0, 252,252, 0, // 188-191 - 204,136, 8, 228,144, 4, 252,156, 0, 252,176, 48, // 192-195 - 252,196,100, 252,216,152, 8, 24, 88, 12, 36,104, // 196-199 - 20, 52,124, 28, 68,140, 40, 92,164, 56,120,188, // 200-203 - 72,152,216, 100,172,224, 92,156, 52, 108,176, 64, // 204-207 - 124,200, 76, 144,224, 92, 224,244,252, 200,236,248, // 208-211 - 180,220,236, 132,188,216, 88,152,172, 16, 16, 16, // 212-215 - 32, 32, 32, 32, 68,112, 36, 72,116, 40, 76,120, // 216-219 - 44, 80,124, 48, 84,128, 72,100,144, 100,132,168, // 220-223 - 216,244,252, 96,128,164, 68, 96,140, 76, 24, 8, // 224-227 - 108, 44, 24, 144, 72, 52, 176,108, 84, 210,146,126, // 228-231 - 252, 60, 0, 252, 84, 0, 252,104, 0, 252,124, 0, // 232-235 - 252,148, 0, 252,172, 0, 252,196, 0, 64, 0, 0, // 236-239 - 255, 0, 0, 48, 48, 0, 64, 64, 0, 80, 80, 0, // 240-243 - 255,255, 0, 148,148,148, 247, 0,247, 248, 0,248, // 244-247 - 249, 0,249, 250, 0,250, 251, 0,251, 252, 0,252, // 248-251 - 253, 0,253, 254, 0,254, 255, 0,255, 255,255,255, // 252-255 - }, -// PAL_ttd_cand - { - 0, 0,255, 16, 16, 16, 32, 32, 32, 48, 48, 48, // 0-3 - 64, 64, 64, 80, 80, 80, 100,100,100, 116,116,116, // 4-7 - 132,132,132, 148,148,148, 168,168,168, 184,184,184, // 8-11 - 200,200,200, 216,216,216, 232,232,232, 252,252,252, // 12-15 - 52, 60, 72, 68, 76, 92, 88, 96,112, 108,116,132, // 16-19 - 132,140,152, 156,160,172, 176,184,196, 204,208,220, // 20-23 - 48, 44, 4, 64, 60, 12, 80, 76, 20, 96, 92, 28, // 24-27 - 120,120, 64, 148,148,100, 176,176,132, 204,204,168, // 28-31 - 72, 44, 4, 88, 60, 20, 104, 80, 44, 124,104, 72, // 32-35 - 152,132, 92, 184,160,120, 212,188,148, 244,220,176, // 36-39 - 64, 0, 4, 88, 4, 16, 112, 16, 32, 136, 32, 52, // 40-43 - 160, 56, 76, 188, 84,108, 204,104,124, 220,132,144, // 44-47 - 236,156,164, 252,188,192, 252,208, 0, 252,232, 60, // 48-51 - 252,252,128, 76, 40, 0, 96, 60, 8, 116, 88, 28, // 52-55 - 136,116, 56, 156,136, 80, 176,156,108, 196,180,136, // 56-59 - 68, 24, 0, 96, 44, 4, 128, 68, 8, 156, 96, 16, // 60-63 - 184,120, 24, 212,156, 32, 232,184, 16, 252,212, 0, // 64-67 - 252,248,128, 252,252,192, 32, 4, 0, 64, 20, 8, // 68-71 - 84, 28, 16, 108, 44, 28, 128, 56, 40, 148, 72, 56, // 72-75 - 168, 92, 76, 184,108, 88, 196,128,108, 212,148,128, // 76-79 - 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, // 80-83 - 64,112, 12, 84,132, 20, 104,148, 28, 128,168, 44, // 84-87 - 28, 52, 24, 44, 68, 32, 60, 88, 48, 80,104, 60, // 88-91 - 104,124, 76, 128,148, 92, 152,176,108, 180,204,124, // 92-95 - 16, 52, 24, 32, 72, 44, 56, 96, 72, 76,116, 88, // 96-99 - 96,136,108, 120,164,136, 152,192,168, 184,220,200, // 100-103 - 32, 24, 0, 56, 28, 0, 72, 40, 4, 88, 52, 12, // 104-107 - 104, 64, 24, 124, 84, 44, 140,108, 64, 160,128, 88, // 108-111 - 76, 40, 16, 96, 52, 24, 116, 68, 40, 136, 84, 56, // 112-115 - 164, 96, 64, 184,112, 80, 204,128, 96, 212,148,112, // 116-119 - 224,168,128, 236,188,148, 80, 28, 4, 100, 40, 20, // 120-123 - 120, 56, 40, 140, 76, 64, 160,100, 96, 184,136,136, // 124-127 - 36, 40, 68, 48, 52, 84, 64, 64,100, 80, 80,116, // 128-131 - 100,100,136, 132,132,164, 172,172,192, 212,212,224, // 132-135 - 40, 20,112, 64, 44,144, 88, 64,172, 104, 76,196, // 136-139 - 120, 88,224, 140,104,252, 160,136,252, 188,168,252, // 140-143 - 0, 24,108, 0, 36,132, 0, 52,160, 0, 72,184, // 144-147 - 0, 96,212, 24,120,220, 56,144,232, 88,168,240, // 148-151 - 128,196,252, 188,224,252, 16, 64, 96, 24, 80,108, // 152-155 - 40, 96,120, 52,112,132, 80,140,160, 116,172,192, // 156-159 - 156,204,220, 204,240,252, 172, 52, 52, 212, 52, 52, // 160-163 - 252, 52, 52, 252,100, 88, 252,144,124, 252,184,160, // 164-167 - 252,216,200, 252,244,236, 72, 20,112, 92, 44,140, // 168-171 - 112, 68,168, 140,100,196, 168,136,224, 200,176,248, // 172-175 - 208,184,255, 232,208,252, 60, 0, 0, 92, 0, 0, // 176-179 - 128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, // 180-183 - 252, 0, 0, 252, 80, 0, 252,108, 0, 252,136, 0, // 184-187 - 252,164, 0, 252,192, 0, 252,220, 0, 252,252, 0, // 188-191 - 204,136, 8, 228,144, 4, 252,156, 0, 252,176, 48, // 192-195 - 252,196,100, 252,216,152, 8, 24, 88, 12, 36,104, // 196-199 - 20, 52,124, 28, 68,140, 40, 92,164, 56,120,188, // 200-203 - 72,152,216, 100,172,224, 92,156, 52, 108,176, 64, // 204-207 - 124,200, 76, 144,224, 92, 224,244,252, 200,236,248, // 208-211 - 180,220,236, 132,188,216, 88,152,172, 244, 0,244, // 212-215 - 245, 0,245, 246, 0,246, 247, 0,247, 248, 0,248, // 216-219 - 249, 0,249, 250, 0,250, 251, 0,251, 252, 0,252, // 220-223 - 253, 0,253, 254, 0,254, 255, 0,255, 76, 24, 8, // 224-227 - 108, 44, 24, 144, 72, 52, 176,108, 84, 210,146,126, // 228-231 - 252, 60, 0, 252, 84, 0, 252,104, 0, 252,124, 0, // 232-235 - 252,148, 0, 252,172, 0, 252,196, 0, 64, 0, 0, // 236-239 - 255, 0, 0, 48, 48, 0, 64, 64, 0, 80, 80, 0, // 240-243 - 255,255, 0, 28,108,124, 32,112,128, 36,116,132, // 244-247 - 40,120,136, 44,124,140, 92,164,184, 116,180,196, // 248-251 - 216,244,252, 112,176,192, 88,160,180, 255,255,255, // 252-255 - }, -// PAL_ttw_cand - { - 0, 0,255, 238, 0,238, 239, 0,239, 240, 0,240, // 0-3 - 241, 0,241, 242, 0,242, 243, 0,243, 244, 0,244, // 4-7 - 245, 0,245, 246, 0,246, 168,168,168, 184,184,184, // 8-11 - 200,200,200, 216,216,216, 232,232,232, 252,252,252, // 12-15 - 52, 60, 72, 68, 76, 92, 88, 96,112, 108,116,132, // 16-19 - 132,140,152, 156,160,172, 176,184,196, 204,208,220, // 20-23 - 48, 44, 4, 64, 60, 12, 80, 76, 20, 96, 92, 28, // 24-27 - 120,120, 64, 148,148,100, 176,176,132, 204,204,168, // 28-31 - 100,100,100, 116,116,116, 104, 80, 44, 124,104, 72, // 32-35 - 152,132, 92, 184,160,120, 212,188,148, 244,220,176, // 36-39 - 132,132,132, 88, 4, 16, 112, 16, 32, 136, 32, 52, // 40-43 - 160, 56, 76, 188, 84,108, 204,104,124, 220,132,144, // 44-47 - 236,156,164, 252,188,192, 252,208, 0, 252,232, 60, // 48-51 - 252,252,128, 76, 40, 0, 96, 60, 8, 116, 88, 28, // 52-55 - 136,116, 56, 156,136, 80, 176,156,108, 196,180,136, // 56-59 - 68, 24, 0, 96, 44, 4, 128, 68, 8, 156, 96, 16, // 60-63 - 184,120, 24, 212,156, 32, 232,184, 16, 252,212, 0, // 64-67 - 252,248,128, 252,252,192, 32, 4, 0, 64, 20, 8, // 68-71 - 84, 28, 16, 108, 44, 28, 128, 56, 40, 148, 72, 56, // 72-75 - 168, 92, 76, 184,108, 88, 196,128,108, 212,148,128, // 76-79 - 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, // 80-83 - 64,112, 12, 84,132, 20, 104,148, 28, 128,168, 44, // 84-87 - 64, 64, 64, 44, 68, 32, 60, 88, 48, 80,104, 60, // 88-91 - 104,124, 76, 128,148, 92, 152,176,108, 180,204,124, // 92-95 - 16, 52, 24, 32, 72, 44, 56, 96, 72, 76,116, 88, // 96-99 - 96,136,108, 120,164,136, 152,192,168, 184,220,200, // 100-103 - 32, 24, 0, 56, 28, 0, 80, 80, 80, 88, 52, 12, // 104-107 - 104, 64, 24, 124, 84, 44, 140,108, 64, 160,128, 88, // 108-111 - 76, 40, 16, 96, 52, 24, 116, 68, 40, 136, 84, 56, // 112-115 - 164, 96, 64, 184,112, 80, 204,128, 96, 212,148,112, // 116-119 - 224,168,128, 236,188,148, 80, 28, 4, 100, 40, 20, // 120-123 - 120, 56, 40, 140, 76, 64, 160,100, 96, 184,136,136, // 124-127 - 36, 40, 68, 48, 52, 84, 64, 64,100, 80, 80,116, // 128-131 - 100,100,136, 132,132,164, 172,172,192, 212,212,224, // 132-135 - 48, 48, 48, 64, 44,144, 88, 64,172, 104, 76,196, // 136-139 - 120, 88,224, 140,104,252, 160,136,252, 188,168,252, // 140-143 - 0, 24,108, 0, 36,132, 0, 52,160, 0, 72,184, // 144-147 - 0, 96,212, 24,120,220, 56,144,232, 88,168,240, // 148-151 - 128,196,252, 188,224,252, 16, 64, 96, 24, 80,108, // 152-155 - 40, 96,120, 52,112,132, 80,140,160, 116,172,192, // 156-159 - 156,204,220, 204,240,252, 172, 52, 52, 212, 52, 52, // 160-163 - 252, 52, 52, 252,100, 88, 252,144,124, 252,184,160, // 164-167 - 252,216,200, 252,244,236, 72, 20,112, 92, 44,140, // 168-171 - 112, 68,168, 140,100,196, 168,136,224, 200,176,248, // 172-175 - 208,184,255, 232,208,252, 60, 0, 0, 92, 0, 0, // 176-179 - 128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, // 180-183 - 252, 0, 0, 252, 80, 0, 252,108, 0, 252,136, 0, // 184-187 - 252,164, 0, 252,192, 0, 252,220, 0, 252,252, 0, // 188-191 - 204,136, 8, 228,144, 4, 252,156, 0, 252,176, 48, // 192-195 - 252,196,100, 252,216,152, 8, 24, 88, 12, 36,104, // 196-199 - 20, 52,124, 28, 68,140, 40, 92,164, 56,120,188, // 200-203 - 72,152,216, 100,172,224, 92,156, 52, 108,176, 64, // 204-207 - 124,200, 76, 144,224, 92, 224,244,252, 200,236,248, // 208-211 - 180,220,236, 132,188,216, 88,152,172, 16, 16, 16, // 212-215 - 32, 32, 32, 28,108,124, 32,112,128, 36,116,132, // 216-219 - 40,120,136, 44,124,140, 92,164,184, 116,180,196, // 220-223 - 216,244,252, 112,176,192, 88,160,180, 76, 24, 8, // 224-227 - 108, 44, 24, 144, 72, 52, 176,108, 84, 210,146,126, // 228-231 - 252, 60, 0, 252, 84, 0, 252,104, 0, 252,124, 0, // 232-235 - 252,148, 0, 252,172, 0, 252,196, 0, 64, 0, 0, // 236-239 - 255, 0, 0, 48, 48, 0, 64, 64, 0, 80, 80, 0, // 240-243 - 255,255, 0, 148,148,148, 247, 0,247, 248, 0,248, // 244-247 - 249, 0,249, 250, 0,250, 251, 0,251, 252, 0,252, // 248-251 - 253, 0,253, 254, 0,254, 255, 0,255, 255,255,255, // 252-255 - }, -// PAL_tt1_norm - { - 0, 0,255, 16, 16, 16, 32, 32, 32, 48, 48, 48, // 0-3 - 68, 68, 68, 84, 84, 84, 100,100,100, 116,116,116, // 4-7 - 136,136,136, 152,152,152, 168,168,168, 184,184,184, // 8-11 - 204,204,204, 220,220,220, 236,236,236, 252,252,252, // 12-15 - 204,204,168, 184,184,152, 168,168,116, 152,152,100, // 16-19 - 136,136, 84, 100,100, 68, 84, 84, 48, 68, 68, 32, // 20-23 - 48, 48, 16, 252,220,116, 252,204, 68, 252,184, 32, // 24-27 - 220,152, 48, 184,132, 48, 148,120, 52, 116,100, 48, // 28-31 - 100, 84, 48, 84, 68, 32, 68, 48, 16, 0, 0, 44, // 32-35 - 4, 12, 68, 8, 24, 88, 12, 36,104, 20, 52,124, // 36-39 - 28, 68,140, 40, 92,164, 56,120,188, 72,152,216, // 40-43 - 100,172,224, 132,196,236, 168,216,244, 204,236,252, // 44-47 - 48, 0, 0, 80, 0, 0, 108, 4, 4, 136, 12, 12, // 48-51 - 164, 20, 20, 196, 32, 32, 224, 44, 44, 252, 56, 56, // 52-55 - 84, 32, 0, 100, 48, 0, 132, 64, 0, 168, 80, 0, // 56-59 - 200, 96, 0, 236,152, 0, 236,184, 68, 252,236,136, // 60-63 - 124,140, 60, 116,128, 48, 104,116, 36, 96,104, 28, // 64-67 - 84, 92, 20, 76, 80, 12, 68, 72, 4, 56, 60, 0, // 68-71 - 48, 48, 0, 252, 60, 0, 252, 96, 0, 252,128, 0, // 72-75 - 252,164, 0, 252,196, 0, 48, 16, 0, 68, 32, 0, // 76-79 - 100, 48, 16, 116, 68, 32, 136, 84, 32, 168,100, 48, // 80-83 - 184,116, 48, 220,136, 68, 236,152, 84, 236,168,100, // 84-87 - 252,184,116, 252,204,136, 108, 92, 92, 132, 88, 88, // 88-91 - 148, 80, 80, 164, 64, 64, 40, 16, 92, 64, 48,136, // 92-95 - 88, 64,172, 112, 84,212, 140,100,252, 160,140,252, // 96-99 - 204,192,180, 184,172,152, 164,148,132, 144,132,112, // 100-103 - 120,100, 76, 96, 72, 48, 68, 48, 24, 44, 28, 12, // 104-107 - 56, 44, 12, 56, 64, 32, 64, 48, 0, 100, 68, 28, // 108-111 - 84, 68, 0, 116,184,160, 88,160,124, 64,136, 92, // 112-115 - 44,116, 60, 24, 92, 32, 12, 72, 12, 0, 52, 0, // 116-119 - 116,116, 84, 168,152,100, 220,204,136, 252,236,168, // 120-123 - 116,100, 84, 152,136,116, 204,184,168, 252,220,204, // 124-127 - 200,132,108, 192,120, 96, 176,100, 80, 168, 88, 68, // 128-131 - 148, 68, 52, 132, 48, 36, 116, 32, 20, 100, 28, 12, // 132-135 - 68, 12, 0, 32, 16, 0, 112,140, 24, 80,124, 16, // 136-139 - 56,108, 12, 36, 96, 4, 40, 84, 16, 36, 72, 0, // 140-143 - 36, 64, 0, 136, 96, 60, 124, 84, 44, 112, 68, 32, // 144-147 - 100, 56, 20, 88, 44, 12, 72, 36, 4, 56, 24, 0, // 148-151 - 16, 16, 48, 32, 32, 68, 48, 48,100, 68, 72,120, // 152-155 - 92, 96,140, 120,120,164, 152,152,184, 168,168,204, // 156-159 - 180,196,116, 168,184, 84, 148,168, 84, 128,156, 80, // 160-163 - 112,140, 80, 96,124, 76, 72,100, 60, 52, 76, 48, // 164-167 - 32, 48, 32, 200,116, 32, 176,100, 24, 156, 84, 16, // 168-171 - 132, 72, 12, 112, 56, 4, 88, 40, 0, 68, 28, 0, // 172-175 - 252,252,180, 252,100,100, 148,204,168, 180,208,128, // 176-179 - 236,188,148, 228,172,132, 220,160,120, 212,144,108, // 180-183 - 204,128, 96, 196,116, 84, 184,104, 72, 168, 96, 64, // 184-187 - 148, 84, 52, 128, 76, 40, 112, 64, 32, 92, 52, 20, // 188-191 - 180,124,112, 172,104,100, 164, 88, 84, 132, 72, 68, // 192-195 - 104, 48, 48, 80, 32, 32, 241, 0,241, 242, 0,242, // 196-199 - 243, 0,243, 244, 0,244, 245, 0,245, 246, 0,246, // 200-203 - 247, 0,247, 248, 0,248, 249, 0,249, 250, 0,250, // 204-207 - 198,132,108, 190,120, 96, 174,100, 80, 166, 88, 68, // 208-211 - 146, 68, 52, 130, 48, 36, 114, 32, 20, 98, 28, 12, // 212-215 - 66, 12, 0, 30, 16, 0, 251, 0,251, 252, 0,252, // 216-219 - 253, 0,253, 254, 0,254, 255, 0,255, 0,188, 80, // 220-223 - 4,188, 92, 122,124,124, 142,144,144, 162,164,164, // 224-227 - 182,184,184, 202,204,204, 222,224,224, 242,244,244, // 228-231 - 32, 68,112, 255, 60, 0, 255, 84, 0, 255,108, 0, // 232-235 - 255,132, 0, 255,156, 0, 255,180, 0, 255,204, 0, // 236-239 - 50, 50, 0, 64, 64, 0, 78, 78, 0, 255,255, 0, // 240-243 - 72,100,144, 100,132,168, 216,244,252, 96,128,164, // 244-247 - 68, 96,140, 64, 0, 0, 255, 0, 0, 36, 72,116, // 248-251 - 40, 76,120, 44, 80,124, 48, 84,128, 255,255,255, // 252-255 - }, -// PAL_tt1_mars - { - 0, 0,255, 16, 16, 16, 32, 32, 32, 48, 48, 48, // 0-3 - 68, 68, 68, 84, 84, 84, 100,100,100, 116,116,116, // 4-7 - 136,136,136, 152,152,152, 168,168,168, 184,184,184, // 8-11 - 204,204,204, 220,220,220, 236,236,236, 252,252,252, // 12-15 - 204,204,168, 184,184,152, 168,168,116, 152,152,100, // 16-19 - 136,136, 84, 100,100, 68, 84, 84, 48, 68, 68, 32, // 20-23 - 48, 48, 16, 252,220,116, 252,204, 68, 252,184, 32, // 24-27 - 220,152, 48, 184,132, 48, 148,120, 52, 116,100, 48, // 28-31 - 100, 84, 48, 84, 68, 32, 68, 48, 16, 0, 0, 44, // 32-35 - 4, 12, 68, 8, 24, 88, 12, 36,104, 20, 52,124, // 36-39 - 28, 68,140, 40, 92,164, 56,120,188, 72,152,216, // 40-43 - 100,172,224, 132,196,236, 168,216,244, 204,236,252, // 44-47 - 48, 0, 0, 80, 0, 0, 108, 4, 4, 136, 12, 12, // 48-51 - 164, 20, 20, 196, 32, 32, 224, 44, 44, 252, 56, 56, // 52-55 - 84, 32, 0, 100, 48, 0, 132, 64, 0, 168, 80, 0, // 56-59 - 200, 96, 0, 236,152, 0, 236,184, 68, 252,236,136, // 60-63 - 124,140, 60, 116,128, 48, 104,116, 36, 96,104, 28, // 64-67 - 84, 92, 20, 76, 80, 12, 68, 72, 4, 56, 60, 0, // 68-71 - 48, 48, 0, 252, 60, 0, 252, 96, 0, 252,128, 0, // 72-75 - 252,164, 0, 252,196, 0, 48, 16, 0, 68, 32, 0, // 76-79 - 100, 48, 16, 116, 68, 32, 136, 84, 32, 168,100, 48, // 80-83 - 184,116, 48, 220,136, 68, 236,152, 84, 236,168,100, // 84-87 - 252,184,116, 252,204,136, 108, 92, 92, 132, 88, 88, // 88-91 - 148, 80, 80, 164, 64, 64, 40, 16, 92, 64, 48,136, // 92-95 - 88, 64,172, 112, 84,212, 140,100,252, 160,140,252, // 96-99 - 204,192,180, 184,172,152, 164,148,132, 144,132,112, // 100-103 - 120,100, 76, 96, 72, 48, 68, 48, 24, 44, 28, 12, // 104-107 - 56, 44, 12, 56, 64, 32, 64, 48, 0, 100, 68, 28, // 108-111 - 84, 68, 0, 116,184,160, 88,160,124, 64,136, 92, // 112-115 - 44,116, 60, 24, 92, 32, 12, 72, 12, 0, 52, 0, // 116-119 - 116,116, 84, 168,152,100, 220,204,136, 252,236,168, // 120-123 - 116,100, 84, 152,136,116, 204,184,168, 252,220,204, // 124-127 - 200,132,108, 192,120, 96, 176,100, 80, 168, 88, 68, // 128-131 - 148, 68, 52, 132, 48, 36, 116, 32, 20, 100, 28, 12, // 132-135 - 68, 12, 0, 32, 16, 0, 112,140, 24, 80,124, 16, // 136-139 - 56,108, 12, 36, 96, 4, 40, 84, 16, 36, 72, 0, // 140-143 - 36, 64, 0, 136, 96, 60, 124, 84, 44, 112, 68, 32, // 144-147 - 100, 56, 20, 88, 44, 12, 72, 36, 4, 56, 24, 0, // 148-151 - 16, 16, 48, 32, 32, 68, 48, 48,100, 68, 72,120, // 152-155 - 92, 96,140, 120,120,164, 152,152,184, 168,168,204, // 156-159 - 180,196,116, 168,184, 84, 148,168, 84, 128,156, 80, // 160-163 - 112,140, 80, 96,124, 76, 72,100, 60, 52, 76, 48, // 164-167 - 32, 48, 32, 200,116, 32, 176,100, 24, 156, 84, 16, // 168-171 - 132, 72, 12, 112, 56, 4, 88, 40, 0, 68, 28, 0, // 172-175 - 252,252,180, 252,100,100, 148,204,168, 180,208,128, // 176-179 - 236,188,148, 228,172,132, 220,160,120, 212,144,108, // 180-183 - 204,128, 96, 196,116, 84, 184,104, 72, 168, 96, 64, // 184-187 - 148, 84, 52, 128, 76, 40, 112, 64, 32, 92, 52, 20, // 188-191 - 180,124,112, 172,104,100, 164, 88, 84, 132, 72, 68, // 192-195 - 104, 48, 48, 80, 32, 32, 241, 0,241, 242, 0,242, // 196-199 - 243, 0,243, 244, 0,244, 245, 0,245, 246, 0,246, // 200-203 - 247, 0,247, 248, 0,248, 249, 0,249, 250, 0,250, // 204-207 - 198,132,108, 190,120, 96, 174,100, 80, 166, 88, 68, // 208-211 - 146, 68, 52, 130, 48, 36, 114, 32, 20, 98, 28, 12, // 212-215 - 66, 12, 0, 30, 16, 0, 251, 0,251, 252, 0,252, // 216-219 - 253, 0,253, 254, 0,254, 255, 0,255, 0,188, 80, // 220-223 - 4,188, 92, 122,124,124, 142,144,144, 162,164,164, // 224-227 - 182,184,184, 202,204,204, 222,224,224, 242,244,244, // 228-231 - 116, 0, 0, 255, 60, 0, 255, 84, 0, 255,108, 0, // 232-235 - 255,132, 0, 255,156, 0, 255,180, 0, 255,204, 0, // 236-239 - 50, 50, 0, 64, 64, 0, 78, 78, 0, 255,255, 0, // 240-243 - 156, 40, 12, 200, 76, 68, 228,112,108, 208, 84, 76, // 244-247 - 164, 48, 20, 64, 0, 0, 255, 0, 0, 124, 4, 0, // 248-251 - 136, 16, 4, 148, 28, 8, 160, 44, 16, 255,255,255, // 252-255 - }, -// PAL_ttw_pb_pal1 - { - 0, 0,255, 238, 0,238, 239, 0,239, 240, 0,240, // 0-3 - 241, 0,241, 242, 0,242, 243, 0,243, 244, 0,244, // 4-7 - 245, 0,245, 246, 0,246, 168,168,168, 184,184,184, // 8-11 - 200,200,200, 216,216,216, 232,232,232, 252,252,252, // 12-15 - 52, 60, 72, 68, 76, 92, 88, 96,112, 108,116,132, // 16-19 - 132,140,152, 156,160,172, 176,184,196, 204,208,220, // 20-23 - 48, 44, 4, 64, 60, 12, 80, 76, 20, 96, 92, 28, // 24-27 - 120,120, 64, 148,148,100, 176,176,132, 204,204,168, // 28-31 - 100,100,100, 116,116,116, 104, 80, 44, 124,104, 72, // 32-35 - 152,132, 92, 184,160,120, 212,188,148, 244,220,176, // 36-39 - 132,132,132, 88, 4, 16, 112, 16, 32, 136, 32, 52, // 40-43 - 160, 56, 76, 188, 84,108, 204,104,124, 220,132,144, // 44-47 - 236,156,164, 252,188,192, 252,208, 0, 252,232, 60, // 48-51 - 252,252,128, 76, 40, 0, 96, 60, 8, 116, 88, 28, // 52-55 - 136,116, 56, 156,136, 80, 176,156,108, 196,180,136, // 56-59 - 68, 24, 0, 96, 44, 4, 128, 68, 8, 156, 96, 16, // 60-63 - 184,120, 24, 212,156, 32, 232,184, 16, 252,212, 0, // 64-67 - 252,248,128, 252,252,192, 32, 4, 0, 64, 20, 8, // 68-71 - 84, 28, 16, 108, 44, 28, 128, 56, 40, 148, 72, 56, // 72-75 - 168, 92, 76, 184,108, 88, 196,128,108, 212,148,128, // 76-79 - 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, // 80-83 - 64,112, 12, 84,132, 20, 104,148, 28, 128,168, 44, // 84-87 - 64, 64, 64, 44, 68, 32, 60, 88, 48, 80,104, 60, // 88-91 - 104,124, 76, 128,148, 92, 152,176,108, 180,204,124, // 92-95 - 16, 52, 24, 32, 72, 44, 56, 96, 72, 76,116, 88, // 96-99 - 96,136,108, 120,164,136, 152,192,168, 184,220,200, // 100-103 - 32, 24, 0, 56, 28, 0, 80, 80, 80, 88, 52, 12, // 104-107 - 104, 64, 24, 124, 84, 44, 140,108, 64, 160,128, 88, // 108-111 - 76, 40, 16, 96, 52, 24, 116, 68, 40, 136, 84, 56, // 112-115 - 164, 96, 64, 184,112, 80, 204,128, 96, 212,148,112, // 116-119 - 224,168,128, 236,188,148, 80, 28, 4, 100, 40, 20, // 120-123 - 120, 56, 40, 140, 76, 64, 160,100, 96, 184,136,136, // 124-127 - 36, 40, 68, 48, 52, 84, 64, 64,100, 80, 80,116, // 128-131 - 100,100,136, 132,132,164, 172,172,192, 212,212,224, // 132-135 - 48, 48, 48, 64, 44,144, 88, 64,172, 104, 76,196, // 136-139 - 120, 88,224, 140,104,252, 160,136,252, 188,168,252, // 140-143 - 0, 24,108, 0, 36,132, 0, 52,160, 0, 72,184, // 144-147 - 0, 96,212, 24,120,220, 56,144,232, 88,168,240, // 148-151 - 128,196,252, 188,224,252, 16, 64, 96, 24, 80,108, // 152-155 - 40, 96,120, 52,112,132, 80,140,160, 116,172,192, // 156-159 - 156,204,220, 204,240,252, 172, 52, 52, 212, 52, 52, // 160-163 - 252, 52, 52, 252,100, 88, 252,144,124, 252,184,160, // 164-167 - 252,216,200, 252,244,236, 72, 20,112, 92, 44,140, // 168-171 - 112, 68,168, 140,100,196, 168,136,224, 200,176,248, // 172-175 - 208,184,255, 232,208,252, 60, 0, 0, 92, 0, 0, // 176-179 - 128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, // 180-183 - 252, 0, 0, 252, 80, 0, 252,108, 0, 252,136, 0, // 184-187 - 252,164, 0, 252,192, 0, 252,220, 0, 252,252, 0, // 188-191 - 204,136, 8, 228,144, 4, 252,156, 0, 252,176, 48, // 192-195 - 252,196,100, 252,216,152, 8, 24, 88, 12, 36,104, // 196-199 - 20, 52,124, 28, 68,140, 40, 92,164, 56,120,188, // 200-203 - 72,152,216, 100,172,224, 92,156, 52, 108,176, 64, // 204-207 - 124,200, 76, 144,224, 92, 224,244,252, 200,236,248, // 208-211 - 180,220,236, 132,188,216, 88,152,172, 16, 16, 16, // 212-215 - 32, 32, 32, 32, 68,112, 36, 72,116, 40, 76,120, // 216-219 - 44, 80,124, 48, 84,128, 72,100,144, 100,132,168, // 220-223 - 216,244,252, 96,128,164, 68, 96,140, 255, 0,255, // 224-227 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 228-231 - 252, 60, 0, 252, 84, 0, 252,104, 0, 252,124, 0, // 232-235 - 252,148, 0, 252,172, 0, 252,196, 0, 64, 0, 0, // 236-239 - 255, 0, 0, 255, 0,255, 255, 0,255, 255, 0,255, // 240-243 - 255, 0,255, 148,148,148, 247, 0,247, 248, 0,248, // 244-247 - 249, 0,249, 250, 0,250, 251, 0,251, 252, 0,252, // 248-251 - 253, 0,253, 254, 0,254, 255, 0,255, 255,255,255, // 252-255 - }, -// PAL_ttw_pb_pal2 - { - 0, 0,255, 238, 0,238, 239, 0,239, 240, 0,240, // 0-3 - 241, 0,241, 242, 0,242, 243, 0,243, 244, 0,244, // 4-7 - 245, 0,245, 246, 0,246, 168,168,168, 184,184,184, // 8-11 - 200,200,200, 216,216,216, 232,232,232, 252,252,252, // 12-15 - 52, 60, 72, 68, 76, 92, 88, 96,112, 108,116,132, // 16-19 - 132,140,152, 156,160,172, 176,184,196, 204,208,220, // 20-23 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 24-27 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 28-31 - 100,100,100, 116,116,116, 255, 0,255, 255, 0,255, // 32-35 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 36-39 - 132,132,132, 255, 0,255, 255, 0,255, 255, 0,255, // 40-43 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 44-47 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 48-51 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 52-55 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 56-59 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 60-63 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 64-67 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 68-71 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 72-75 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 76-79 - 8, 52, 0, 16, 64, 0, 32, 80, 4, 48, 96, 4, // 80-83 - 64,112, 12, 84,132, 20, 104,148, 28, 128,168, 44, // 84-87 - 64, 64, 64, 255, 0,255, 255, 0,255, 255, 0,255, // 88-91 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 92-95 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 96-99 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 100-103 - 32, 24, 0, 56, 28, 0, 80, 80, 80, 255, 0,255, // 104-107 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 108-111 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 112-115 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 116-119 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 120-123 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 124-127 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 128-131 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 132-135 - 48, 48, 48, 255, 0,255, 255, 0,255, 255, 0,255, // 136-139 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 140-143 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 144-147 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 148-151 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 152-155 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 156-159 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 160-163 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 164-167 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 168-171 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 172-175 - 255, 0,255, 255, 0,255, 60, 0, 0, 92, 0, 0, // 176-179 - 128, 0, 0, 160, 0, 0, 196, 0, 0, 224, 0, 0, // 180-183 - 252, 0, 0, 252, 80, 0, 252,108, 0, 252,136, 0, // 184-187 - 252,164, 0, 252,192, 0, 252,220, 0, 252,252, 0, // 188-191 - 204,136, 8, 228,144, 4, 252,156, 0, 252,176, 48, // 192-195 - 252,196,100, 252,216,152, 8, 24, 88, 12, 36,104, // 196-199 - 20, 52,124, 28, 68,140, 40, 92,164, 56,120,188, // 200-203 - 72,152,216, 100,172,224, 255, 0,255, 255, 0,255, // 204-207 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 208-211 - 255, 0,255, 255, 0,255, 255, 0,255, 16, 16, 16, // 212-215 - 32, 32, 32, 255, 0,255, 255, 0,255, 255, 0,255, // 216-219 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 220-223 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 224-227 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 228-231 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 232-235 - 255, 0,255, 255, 0,255, 255, 0,255, 255, 0,255, // 236-239 - 255, 0, 0, 255, 0,255, 255, 0,255, 255, 0,255, // 240-243 - 255, 0,255, 148,148,148, 247, 0,247, 248, 0,248, // 244-247 - 249, 0,249, 250, 0,250, 251, 0,251, 252, 0,252, // 248-251 - 253, 0,253, 254, 0,254, 255, 0,255, 255, 0,255, // 252-255 - }, - }; - -#endif // DEFINE_PALS From 39ba5a5bd5003a7212be36e4f9a1e82116bb7b03 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 13 Mar 2019 15:48:49 +0000 Subject: [PATCH 03/21] Change: Use cstdint types --- src/typesize.h | 66 ++++++++++++-------------------------------------- 1 file changed, 15 insertions(+), 51 deletions(-) diff --git a/src/typesize.h b/src/typesize.h index caad13c7..66ca36ba 100644 --- a/src/typesize.h +++ b/src/typesize.h @@ -1,8 +1,6 @@ #ifndef _TYPESIZE_H #define _TYPESIZE_H -#include "endian.h" - /*****************************************\ * * * TYPESIZE.H - Defines variable types * @@ -21,9 +19,21 @@ * * \*****************************************/ -#define maketype(type,size) \ - typedef signed type S ## size; \ - typedef unsigned type U ## size; +#include + +#define HAVE_BYTES +#define HAVE_SHORTS +#define HAVE_LONGS +#define HAVE_LONGLONGS + +typedef int8_t S8; +typedef uint8_t U8; +typedef int16_t S16; +typedef uint16_t U16; +typedef int32_t S32; +typedef uint32_t U32; +typedef int64_t S64; +typedef uint64_t U64; #ifndef _MSC_VER #define strnicmp strncasecmp @@ -32,56 +42,10 @@ #ifdef __BORLANDC__ -# define HAVE_BYTES -# define HAVE_SHORTS -# define HAVE_LONGS - - maketype(char,8) - maketype(short,16) - maketype(long,32) - // disable warnings for "condition is always false" and "unreachable code" #pragma warn -ccc #pragma warn -rch -#elif WIN32 - -# define HAVE_BYTES -# define HAVE_SHORTS -# define HAVE_LONGS -# define HAVE_LONGLONGS - - maketype(char,8) - maketype(short int,16) - maketype(long int,32) - maketype(long long,64) - -#elif GCC32 - -# define HAVE_BYTES -# define HAVE_SHORTS -# define HAVE_LONGS -# define HAVE_LONGLONGS - - maketype(char,8) - maketype(short int,16) - maketype(int,32) - maketype(long long,64) - -#elif GCC64 - -# define HAVE_BYTES -# define HAVE_SHORTS -# define HAVE_LONGS -# define HAVE_LONGLONGS - - maketype(char,8) - maketype(short int,16) - maketype(int,32) - maketype(long int,64) - -#else -# error Unknown variables sizes, please define. #endif #ifdef _MSC_VER From d0db325fd5e4f1ac024ca9e4717cdde5bcea6478 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 13 Mar 2019 15:49:01 +0000 Subject: [PATCH 04/21] Change: Always include path.h --- src/grfcomm.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/grfcomm.cpp b/src/grfcomm.cpp index e165df36..ca75cf93 100644 --- a/src/grfcomm.cpp +++ b/src/grfcomm.cpp @@ -22,9 +22,7 @@ #include "error.h" //#include "sprites.h" -#if defined(WIN32) || defined(GCC32) || defined(GCC64) -# include "path.h" -#endif +#include "path.h" #include "grfcomm.h" From 5e91d0db1447d533bb6c2add88cd1910ff625992 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 13 Mar 2019 15:50:08 +0000 Subject: [PATCH 05/21] Change: Switch to CMake --- CMakeLists.txt | 137 ++++++++++++++++++++++ Makefile | 258 ------------------------------------------ Makefile.local.sample | 46 -------- findversion.sh | 103 ----------------- version.def | 11 -- 5 files changed, 137 insertions(+), 418 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 Makefile delete mode 100644 Makefile.local.sample delete mode 100755 findversion.sh delete mode 100644 version.def diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..9d3d7966 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,137 @@ +cmake_minimum_required(VERSION 3.5) + +project(grfcodec) + +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED) +set(CMAKE_CXX_EXTENSIONS NO) + +find_package(Git REQUIRED) +execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=M + OUTPUT_VARIABLE GIT_VERSION + RESULT_VARIABLE GIT_DESCRIBE_RESULT + ERROR_VARIABLE GIT_DESCRIBE_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND ${GIT_EXECUTABLE} show -s --pretty=%cd --date=short HEAD + OUTPUT_VARIABLE GIT_DATE + RESULT_VARIABLE GIT_SHOW_RESULT + ERROR_VARIABLE GIT_SHOW_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +find_package(PNG) + +include(TestBigEndian) +TEST_BIG_ENDIAN(IS_BIG_ENDIAN) +if (IS_BIG_ENDIAN) + add_definitions(-DGRFCODEC_BIG_ENDIAN=1) +else (IS_BIG_ENDIAN) + add_definitions(-DGRFCODEC_LITTLE_ENDIAN=1) +endif (IS_BIG_ENDIAN) + +add_definitions(-DYEARS="2019") +add_definitions(-DVERSION="${GIT_VERSION}\ \(${GIT_DATE}\)") + +set(GENERATED_BINARY_DIR ${CMAKE_BINARY_DIR}/generated) + +set(PALETTE_SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/tt1_mars.bcp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/tt1_norm.bcp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/ttd_cand.bcp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/ttd_norm.bcp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/ttw_cand.bcp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/ttw_norm.bcp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/ttw_pb_pal1.bcp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/ttw_pb_pal2.bcp +) + +add_custom_command(OUTPUT ${GENERATED_BINARY_DIR}/ttdpal.h + COMMAND ${CMAKE_COMMAND} -E make_directory ${GENERATED_BINARY_DIR} + COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.pl ${PALETTE_SOURCE_FILES} > ${GENERATED_BINARY_DIR}/ttdpal.h + DEPENDS ${PALETTE_SOURCE_FILES} +) +add_custom_target(palettes_header + DEPENDS ${GENERATED_BINARY_DIR}/ttdpal.h +) +add_library(PALETTES + INTERFACE +) +target_include_directories(PALETTES + INTERFACE + ${GENERATED_BINARY_DIR} +) +add_dependencies(PALETTES + palettes_header +) + +set(GRFID_SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/src/grfid.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/md5.cpp +) +add_executable(grfid ${GRFID_SOURCE_FILES}) + +set(GRFSTRIP_SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/src/grfstrip.cpp +) +add_executable(grfstrip ${GRFSTRIP_SOURCE_FILES}) + +set(NFORENUM_SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/src/act0.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/act123_classes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/act123.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/act14.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/act5.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/act6.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/act79D.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/actB.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/actF.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/command.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/data.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/globals.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/help.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/IDs.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/inject.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/language_mgr.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/mapescapes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/message_mgr.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/messages.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/nforenum.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pseudo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pseudo_seq.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/rangedint.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/sanity.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/strings.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/utf8.cpp +) +add_executable(nforenum ${NFORENUM_SOURCE_FILES}) +add_dependencies(nforenum PALETTES) +target_link_libraries(nforenum PALETTES) + +set(GRFCODEC_SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/src/error.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/file.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/globals.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/grfcodec.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/grfcomm.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/info.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/mapescapes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/path.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pcxfile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pcxsprit.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/pngsprit.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/readinfo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/sprites.cpp +) +add_executable(grfcodec ${GRFCODEC_SOURCE_FILES}) +add_dependencies(grfcodec PALETTES) +target_link_libraries(grfcodec PALETTES) +if(PNG_FOUND) + set_target_properties(grfcodec PROPERTIES COMPILE_FLAGS -DWITH_PNG) + target_link_libraries(grfcodec ${PNG_LIBRARY}) +endif(PNG_FOUND) + + diff --git a/Makefile b/Makefile deleted file mode 100644 index 8bac9e34..00000000 --- a/Makefile +++ /dev/null @@ -1,258 +0,0 @@ -# ========================================================= -# Makefile for the GRF development tools -# -# Don't put any local configuration in here -# Change Makefile.local instead, it'll be -# preserved when updating the sources -# ========================================================= - -PACKAGE_NAME = grfcodec - --include Makefile.local - -# Gnu compiler settings -SHELL ?= /bin/sh -CXX ?= g++ -STRIP ?= -UPX ?= -AWK ?= awk -SRCZIP_FLAGS ?= -9 -SRCZIP ?= gzip -LIBPNG_CONFIG?= libpng-config - -# OS detection: Cygwin vs Linux -ISCYGWIN ?= $(shell [ ! -d /cygdrive/ ]; echo $$?) -MACHINE ?= $(shell $(CXX) -dumpmachine || echo '??' ) - -# OS dependent variables -EXE ?= $(shell ( [ \( $(ISCYGWIN) -eq 1 \) -o \( "$(MACHINE)" = "mingw32" \) ] ) && echo .exe) -GRFCODEC ?= grfcodec$(EXE) -GRFID ?= grfid$(EXE) -GRFSTRIP ?= grfstrip$(EXE) -NFORENUM ?= nforenum$(EXE) -ENDIAN_CHECK ?= endian_check$(EXE) - -TYPESIZE ?= GCC32 - -ifndef V -V=0 # verbose build default off -endif - -ifndef FLAGS -FLAGS = -O2 -FLAGS += -D$(TYPESIZE) -D_FORTIFY_SOURCE=2 -fstack-protector -FLAGS += -Wall -Wextra -Wno-format-nonliteral - -ifeq ($(DEBUG),1) -FLAGS += -DDEBUG -endif - -ifneq (,$(findstring mingw32,$(MACHINE))) -FLAGS += -DMINGW -endif - -# Sadly enough fmemopen is -ifneq ($(shell echo "#include " | $(CXX) -E -x c++ - | grep fmemopen | wc -l | sed "s/ *//"),0) -ifndef NO_FMEMOPEN -FLAGS += -DWITH_FMEMOPEN -endif -endif - -ifeq ($(shell uname),Darwin) -FLAGS += -isystem/opt/local/include -endif - -# GCC 4.5.0 has an optimisation bug that influences GRFCodec. -# As such we disable optimisation when GCC 4.5.0 is detected. -# The issue has been fixed in GCC 4.5.1 -ifneq ($(shell $(CXX) -v 2>&1 | grep "4\.5\.0" || true),) -FLAGS += -O0 -endif - -# Complication of png support in grfcodec -ifneq ($(shell $(LIBPNG_CONFIG) --version 2>/dev/null),) -WITH_PNG = 0 -FLAGS += -DWITH_PNG $(shell $(LIBPNG_CONFIG) --cflags) -endif -endif - -MY_CXXFLAGS ?= $(FLAGS) $(CXXFLAGS) - -# ======================================================================= -# setup verbose/non-verbose make process -# ======================================================================= - -# _E = prefix for the echo [TYPE] TARGET -# _C = prefix for the actual command(s) -# _I = indentation for sub-make -# _Q = number of 'q's for UPX -# _S = sub-makes silent? -ifeq (${V},1) - # verbose, set _C = nothing (print command), _E = comment (don't echo) - _C= - _E=@\# - _Q=-qq - _S= -else - # not verbose, _C = @ (suppress cmd line), _E = @echo (echo type&target) - _C=@ - _E:=@echo ${_I} - _Q=-qqq - _S=-s -endif - -# increase indentation level for sub-makes -_I := ${_I}" " -export _I - -# standard compilation commands should be of the form -# target: prerequisites -# ${_E} [CMD] $@ -# ${_C}${CMD} ...arguments... -# -# non-standard commands (those not invoked by make all/dos/win) should -# use the regular syntax (without the ${_E} line and without the ${_C} prefix) -# because they'll be only used for testing special conditions -# -# ======================================================================= - -# sources to be compiled and linked -GRFCODECSRC=grfcomm.cpp pcxfile.cpp sprites.cpp pcxsprit.cpp pngsprit.cpp \ - info.cpp globals.cpp mapescapes.cpp error.cpp path.cpp readinfo.cpp \ - file.cpp grfcodec.cpp - -GRFIDSRC=grfid.cpp md5.cpp - -GRFSTRIPSRC=grfstrip.cpp - -NFORENUMSRC=IDs.cpp act0.cpp act123.cpp act123_classes.cpp act5.cpp act6.cpp \ - act79D.cpp actB.cpp actF.cpp act14.cpp command.cpp data.cpp globals.cpp \ - inject.cpp messages.cpp pseudo.cpp rangedint.cpp nforenum.cpp sanity.cpp \ - strings.cpp utf8.cpp help.cpp message_mgr.cpp language_mgr.cpp \ - mapescapes.cpp pseudo_seq.cpp - -PALORDER = ttd_norm&ttw_norm&ttd_cand&ttw_cand&tt1_norm&tt1_mars&ttw_pb_pal1&ttw_pb_pal2 -PAL_FILES = pals/$(subst &,.bcp pals/,$(PALORDER)).bcp - -# default targets -all: $(GRFCODEC) $(GRFID) $(GRFSTRIP) $(NFORENUM) - -remake: - $(_E) [CLEAN] - $(_C)$(MAKE) ${_S} clean - $(_E) [REBUILD] - $(_C)$(MAKE) src/version.h src/endian.h - $(_C)$(MAKE) ${_S} all - -$(GRFCODEC): $(GRFCODECSRC:%.cpp=objs/%.o) - $(_E) [LD] $@ -ifdef WITH_PNG - $(_C)$(CXX) -o $@ $(MY_CXXFLAGS) $^ $(LDOPT) $(shell $(LIBPNG_CONFIG) --ldflags) -else - $(_C)$(CXX) -o $@ $(MY_CXXFLAGS) $^ $(LDOPT) -endif - -$(GRFID): $(GRFIDSRC:%.cpp=objs/%.o) - $(_E) [LD] $@ - $(_C)$(CXX) -o $@ $(MY_CXXFLAGS) $^ $(LDOPT) - -$(GRFSTRIP): $(GRFSTRIPSRC:%.cpp=objs/%.o) - $(_E) [LD] $@ - $(_C)$(CXX) -o $@ $(MY_CXXFLAGS) $^ $(LDOPT) - -$(NFORENUM): $(NFORENUMSRC:%.cpp=objs/%.o) - $(_E) [LD] $@ - $(_C)$(CXX) -o $@ $(MY_CXXFLAGS) $^ $(LDOPT) - - -clean: - $(_C)rm -rf objs $(GRFCODEC) $(GRFID) $(GRFSTRIP) $(NFORENUM) bundle bundles grfcodec-* src/endian.h - -mrproper: clean - $(_C)rm -f src/version.h - $(_C)touch -ct 9901010000 ttdpal.h # don't delete it, so we don't confuse version control, but force it to be remade - -distclean: mrproper - $(_C)rm -rf Makefile.local - -FORCE: - -include version.def - -src/version.h: FORCE - @echo // Autogenerated by make. Do not edit. Edit version.def or the Makefile instead. > $@.tmp - @echo "#define VERSION \"$(VERSIONSTR)\"" >> $@.tmp - @echo "#define YEARS \"2004-$(YEAR)\"" >> $@.tmp - @(diff $@.tmp $@ > /dev/null 2>&1 && rm -f $@.tmp) || (rm -f $@ ; mv $@.tmp $@) - -objs/$(ENDIAN_CHECK): src/endian_check.cpp - $(_C) mkdir -p objs - $(_E) [LD] $@ - $(_C)$(CXX) -o $@ $(MY_CXXFLAGS) src/endian_check.cpp $(LDOPT) - -src/endian.h: objs/$(ENDIAN_CHECK) - $(_E) [ENDIAN] Determining endianness - $(_C)objs/$(ENDIAN_CHECK) $(ENDIAN_PARAMS) > src/endian.h || { rm src/endian.h; exit 1; } - -FORCE: -%_r: FORCE - $(_E) [REBUILD] $(@:%_r=%) - $(_C)rm -f $(@:%_r=%) - $(_C)$(MAKE) ${_S} $(@:%_r=%) -ifneq ($(STRIP),) - $(_E) [STRIP] $(@:%_r=%) - $(_C)$(STRIP) $(@:%_r=%) -endif -ifneq ($(UPX),) - $(_E) [UPX] $(@:%_r=%) - $(_C)$(UPX) $(_Q) --best $(@:%_r=%) -endif - -.NOTPARALLEL release: FORCE $(GRFCODEC)_r $(GRFID)_r $(GRFSTRIP)_r $(NFORENUM)_r - -src/ttdpal.h: $(PAL_FILES:%=src/%) src/pal2c.pl - $(_E) [PERL] $@ - $(_C)perl src/pal2c.pl $(PAL_FILES:%=src/%) > $@ - - -# Gnu compiler rules - -objs/%.o : src/%.cpp Makefile - $(_E) [CPP] $@ - $(_C)$(CXX) -c -o $@ $(MY_CXXFLAGS) -MMD -MF $@.d -MT $@ $< - -% : objs/%.o Makefile - $(_E) [LD] $@ - $(_C)$(CXX) -o $@ $(MY_CXXFLAGS) $^ $(LDOPT) - $(_C)$(CP_TO_EXE) - -# same as above but optimized for size not speed -objs/%.os : src/%.cpp Makefile - $(_E) [CPP] $@ - $(_C)$(CXX) -c -o $@ $(MY_CXXFLAGS) -Os -MMD -MF $@.d -MT $@ $< - -% :: objs/%.os Makefile - $(_E) [LD] $@ - $(_C)$(CXX) -o $@ $(MY_CXXFLAGS) $^ $(LDOPT) - -# On some installations a version.h exists in /usr/include. This one is then -# found by the dependency tracker and thus the dependencies do not contain -# a reference to version.h, so it isn't generated and compilation fails. -objs/grfcodec.o: src/version.h -objs/grfid.o: src/version.h -objs/grfstrip.o: src/version.h -objs/message_mgr.o: src/version.h -objs/messages.o: src/version.h - -objs/%.o.d: src/%.cpp Makefile src/endian.h - $(_E) [CPP DEP] $@ - $(_C)$(CXX) $(MY_CXXFLAGS) -DMAKEDEP -MM -MG src/$*.cpp -MF $@ - -ifndef NO_MAKEFILE_DEP --include $(GRFCODECSRC:%.cpp=objs/%.o.d) --include $(GRFIDSRC:%.cpp=objs/%.o.d) --include $(GRFSTRIPSRC:%.cpp=objs/%.o.d) --include $(NFORENUMSRC:%.cpp=objs/%.o.d) -endif - -include Makefile.bundle diff --git a/Makefile.local.sample b/Makefile.local.sample deleted file mode 100644 index f013bc06..00000000 --- a/Makefile.local.sample +++ /dev/null @@ -1,46 +0,0 @@ -# ========================================================= -# Local Makefile settings for the GRF development tools -# ========================================================= - -# Copy this file to Makefile.local (if make didn't do it for you) -# and edit to modify the settings - -# If the boost folder auto-detection fails, set your boost include folder here. -# If boost can be found in your standard include search paths, setting this to -# any non-empty value will cause make to assume that boost is present. -#BOOST_INCLUDE = - -# Gnu compiler settings -#SHELL = /bin/sh -#CXX = g++ -#STRIP = strip -#UPX = upx -#AWK = awk -#SRCZIP_FLAGS = -9 -#SRCZIP = gzip - -# use 386 instructions but optimize for pentium II/III -#MY_CXXFLAGS = -g -DWIN32 -O1 $(BOOST_INCLUDE) -Wall -Wno-uninitialized $(CXXFLAGS) -#LDOPT = -g -Wl,--subsystem,console -luser32 -lgdi32 -lwinmm -lcomdlg32 -lcomctl32 -#LDOPT = -Wl,--subsystem,console,-s -#LDOPT += -Wl,-Map,$(@:%=%.map) # to make map files - -# for profiling -#MY_CXXFLAGS += -pg -#LDOPT += -pg - -# to pass the right 'type' sizes to typesize.h -#TYPESIZE = GCC32 -#TYPESIZE = GCC64 -#TYPESIZE = WIN32 - -# Use one of the following to force big endian or little endian. -# You might need to clean before it takes effect. -#ENDIAN_PARAMS = BE -#ENDIAN_PARAMS = LE - -# Several options to influence the installation of documentation -#DO_NOT_INSTALL_DOCS = 1 -#DO_NOT_INSTALL_CHANGELOG = 1 -#DO_NOT_INSTALL_LICENSE = 1 -#DO_NOT_INSTALL_MAN = 1 diff --git a/findversion.sh b/findversion.sh deleted file mode 100755 index 85f160b5..00000000 --- a/findversion.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/sh - -# $Id: findversion.sh 16462 2009-05-29 21:24:51Z rubidium $ - -# Arguments given? Show help text. -if [ "$#" != "0" ]; then - cat <\t\t\t -REV - a string describing what version of the code the current checkout is - based on. The exact format of this string depends on the version - control system in use, but it tries to identify the revision used as - close as possible (using the svn revision number or hg/git hash). - This also includes an indication of whether the checkout was - modified and which branch was checked out. This value is not - guaranteed to be sortable, but is mainly meant for identifying the - revision and user display. - - If no revision identifier could be found, this is left empty. -REV_NR - the revision number of the svn revision this checkout is based on. - This can be used to determine which functionality is present in this - checkout. For trunk svn checkouts and hg/git branches based upon it, - this number should be accurate. For svn branch checkouts, this - number is mostly meaningless, at least when comparing with the - REV_NR from other branches or trunk. - - This number should be sortable. Within a given branch or trunk, a - higher number means a newer version. However, when using git or hg, - this number will not increase on new commits. - - If no revision number could be found, this is left empty. -MODIFIED - Whether (the src directory of) this checkout is modified or not. A - value of 0 means not modified, a value of 2 means it was modified. - Modification is determined in relation to the commit identified by - REV, so not in relation to the svn revision identified by REV_NR. - - A value of 1 means that the modified status is unknown, because this - is not an svn/git/hg checkout for example. - -CLEAN_REV - the same as REV but without branch name - -By setting the AWK environment variable, a caller can determine which -version of "awk" is used. If nothing is set, this script defaults to -"awk". -EOF -exit 1; -fi - -# Allow awk to be provided by the caller. -if [ -z "$AWK" ]; then - AWK=awk -fi - -# Find out some dirs -cd `dirname "$0"` -ROOT_DIR=`pwd` -SRC_DIR=`pwd` - -# Determine if we are using a modified version -# Assume the dir is not modified -MODIFIED="0" -if [ -d "$ROOT_DIR/.hg" ]; then - # We are a hg checkout - if [ -n "`hg status | grep -v '^?'`" ]; then - MODIFIED="2" - fi - REV_NR=`LC_ALL=C hg id -n | cut -d+ -f1` - if [ -n "`hg id -t | grep -v tip`" ]; then - REV=`hg id -t | grep -v tip` - BRANCH="" - else - REV=r$REV_NR - BRANCH=`hg branch | sed 's@^default$@@'` - fi -elif [ -f "$ROOT_DIR/.ottdrev" ]; then - # We are an exported source bundle - cat $ROOT_DIR/.ottdrev - exit -else - # We don't know - MODIFIED="1" - BRANCH="" - REV="" - REV_NR="" -fi - -if [ "$MODIFIED" -eq "2" ]; then - REV="${REV}M" -fi - -CLEAN_REV=${REV} - -if [ -n "$BRANCH" ]; then - REV="${REV}-$BRANCH" -fi - -echo "$REV $REV_NR $MODIFIED $CLEAN_REV" diff --git a/version.def b/version.def deleted file mode 100644 index 5f52dc41..00000000 --- a/version.def +++ /dev/null @@ -1,11 +0,0 @@ -# Current year -YEAR = 2013 - -ifdef REVISION -VERSIONSTR := r$(REVISION) -else -VERSIONS := $(shell AWK="$(AWK)" "./findversion.sh") -REV := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ') -VER := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ') -VERSIONSTR := $(shell [ "`echo "$(VERSIONS)" | cut -c 1`" = 'r' ] && echo "trunk $(VER)" && exit; echo "$(VER) r$(REV)") -endif From 816d4b27932145ffc64866b067a3d3e007c6540c Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Wed, 13 Mar 2019 16:09:22 +0000 Subject: [PATCH 06/21] Fix: leftover endian.h --- src/md5.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/md5.h b/src/md5.h index 90b646b8..3baa4dcd 100644 --- a/src/md5.h +++ b/src/md5.h @@ -47,8 +47,6 @@ 1999-05-03 lpd Original version. */ -#include "endian.h" - #ifndef md5_INCLUDED # define md5_INCLUDED From c4153011e919cbaf6375582cc4f1aeca02d98886 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Thu, 14 Mar 2019 07:56:54 +0000 Subject: [PATCH 07/21] Change: generate version.h instead of using parameter defines --- CMakeLists.txt | 70 ++++++++++++++++++++++-------------------- generate_version.cmake | 18 +++++++++++ src/version.h.in | 4 +++ 3 files changed, 59 insertions(+), 33 deletions(-) create mode 100644 generate_version.cmake create mode 100644 src/version.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d3d7966..106f1542 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,21 +7,35 @@ set(CMAKE_CXX_STANDARD_REQUIRED) set(CMAKE_CXX_EXTENSIONS NO) find_package(Git REQUIRED) -execute_process( - COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=M - OUTPUT_VARIABLE GIT_VERSION - RESULT_VARIABLE GIT_DESCRIBE_RESULT - ERROR_VARIABLE GIT_DESCRIBE_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE -) -execute_process( - COMMAND ${GIT_EXECUTABLE} show -s --pretty=%cd --date=short HEAD - OUTPUT_VARIABLE GIT_DATE - RESULT_VARIABLE GIT_SHOW_RESULT - ERROR_VARIABLE GIT_SHOW_ERROR - OUTPUT_STRIP_TRAILING_WHITESPACE +set(GENERATED_BINARY_DIR "${CMAKE_BINARY_DIR}/generated") +include_directories("${GENERATED_BINARY_DIR}") + +add_custom_command(OUTPUT "{$GENERATED_BINARY_DIR}/version.h" + COMMAND ${CMAKE_COMMAND} + -D GIT_EXECUTABLE=${GIT_EXECUTABLE} + -D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in + -D OUTPUT_FILE=${GENERATED_BINARY_DIR}/version.h + -P ${CMAKE_CURRENT_SOURCE_DIR}/generate_version.cmake + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in" ) +add_custom_target(version_header DEPENDS "${GENERATED_BINARY_DIR}/version.h") + +#execute_process( +# COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=M +# OUTPUT_VARIABLE GIT_VERSION +# RESULT_VARIABLE GIT_DESCRIBE_RESULT +# ERROR_VARIABLE GIT_DESCRIBE_ERROR +# OUTPUT_STRIP_TRAILING_WHITESPACE +#) + +#execute_process( +# COMMAND ${GIT_EXECUTABLE} show -s --pretty=%cd --date=short HEAD +# OUTPUT_VARIABLE GIT_DATE +# RESULT_VARIABLE GIT_SHOW_RESULT +# ERROR_VARIABLE GIT_SHOW_ERROR +# OUTPUT_STRIP_TRAILING_WHITESPACE +#) find_package(PNG) @@ -33,10 +47,9 @@ else (IS_BIG_ENDIAN) add_definitions(-DGRFCODEC_LITTLE_ENDIAN=1) endif (IS_BIG_ENDIAN) -add_definitions(-DYEARS="2019") -add_definitions(-DVERSION="${GIT_VERSION}\ \(${GIT_DATE}\)") +#add_definitions(-DYEARS="2019") +#add_definitions(-DVERSION="${GIT_VERSION}\ \(${GIT_DATE}\)") -set(GENERATED_BINARY_DIR ${CMAKE_BINARY_DIR}/generated) set(PALETTE_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/tt1_mars.bcp @@ -54,30 +67,23 @@ add_custom_command(OUTPUT ${GENERATED_BINARY_DIR}/ttdpal.h COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.pl ${PALETTE_SOURCE_FILES} > ${GENERATED_BINARY_DIR}/ttdpal.h DEPENDS ${PALETTE_SOURCE_FILES} ) -add_custom_target(palettes_header - DEPENDS ${GENERATED_BINARY_DIR}/ttdpal.h -) -add_library(PALETTES - INTERFACE -) -target_include_directories(PALETTES - INTERFACE - ${GENERATED_BINARY_DIR} -) -add_dependencies(PALETTES - palettes_header -) +add_custom_target(palettes_header DEPENDS ${GENERATED_BINARY_DIR}/ttdpal.h) +#add_library(PALETTES INTERFACE) +#target_include_directories(PALETTES INTERFACE ${GENERATED_BINARY_DIR}) +#add_dependencies(PALETTES palettes_header) set(GRFID_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/grfid.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/md5.cpp ) add_executable(grfid ${GRFID_SOURCE_FILES}) +add_dependencies(grfid version_header) set(GRFSTRIP_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/grfstrip.cpp ) add_executable(grfstrip ${GRFSTRIP_SOURCE_FILES}) +add_dependencies(grfstrip version_header) set(NFORENUM_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/act0.cpp @@ -108,8 +114,7 @@ set(NFORENUM_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/utf8.cpp ) add_executable(nforenum ${NFORENUM_SOURCE_FILES}) -add_dependencies(nforenum PALETTES) -target_link_libraries(nforenum PALETTES) +add_dependencies(nforenum palettes_header version_header) set(GRFCODEC_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/error.cpp @@ -127,8 +132,7 @@ set(GRFCODEC_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/sprites.cpp ) add_executable(grfcodec ${GRFCODEC_SOURCE_FILES}) -add_dependencies(grfcodec PALETTES) -target_link_libraries(grfcodec PALETTES) +add_dependencies(grfcodec palettes_header version_header) if(PNG_FOUND) set_target_properties(grfcodec PROPERTIES COMPILE_FLAGS -DWITH_PNG) target_link_libraries(grfcodec ${PNG_LIBRARY}) diff --git a/generate_version.cmake b/generate_version.cmake new file mode 100644 index 00000000..f4188708 --- /dev/null +++ b/generate_version.cmake @@ -0,0 +1,18 @@ +execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=M + OUTPUT_VARIABLE GIT_VERSION + RESULT_VARIABLE GIT_DESCRIBE_RESULT + ERROR_VARIABLE GIT_DESCRIBE_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +execute_process( + COMMAND ${GIT_EXECUTABLE} show -s --pretty=%cd --date=short HEAD + OUTPUT_VARIABLE GIT_DATE + RESULT_VARIABLE GIT_SHOW_RESULT + ERROR_VARIABLE GIT_SHOW_ERROR + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +configure_file(${INPUT_FILE} ${OUTPUT_FILE}) + diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 00000000..93191db9 --- /dev/null +++ b/src/version.h.in @@ -0,0 +1,4 @@ + + +#define VERSION "${GIT_VERSION}" +#define YEARS "${GIT_DATE}" From cb884c17e2c6acc1d978dd1d945c4f98959f5b4a Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 16 Mar 2019 14:49:54 +0000 Subject: [PATCH 08/21] Remove: comments --- CMakeLists.txt | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 106f1542..9f3471be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,22 +21,6 @@ add_custom_command(OUTPUT "{$GENERATED_BINARY_DIR}/version.h" ) add_custom_target(version_header DEPENDS "${GENERATED_BINARY_DIR}/version.h") -#execute_process( -# COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=M -# OUTPUT_VARIABLE GIT_VERSION -# RESULT_VARIABLE GIT_DESCRIBE_RESULT -# ERROR_VARIABLE GIT_DESCRIBE_ERROR -# OUTPUT_STRIP_TRAILING_WHITESPACE -#) - -#execute_process( -# COMMAND ${GIT_EXECUTABLE} show -s --pretty=%cd --date=short HEAD -# OUTPUT_VARIABLE GIT_DATE -# RESULT_VARIABLE GIT_SHOW_RESULT -# ERROR_VARIABLE GIT_SHOW_ERROR -# OUTPUT_STRIP_TRAILING_WHITESPACE -#) - find_package(PNG) include(TestBigEndian) @@ -47,10 +31,6 @@ else (IS_BIG_ENDIAN) add_definitions(-DGRFCODEC_LITTLE_ENDIAN=1) endif (IS_BIG_ENDIAN) -#add_definitions(-DYEARS="2019") -#add_definitions(-DVERSION="${GIT_VERSION}\ \(${GIT_DATE}\)") - - set(PALETTE_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/tt1_mars.bcp ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/tt1_norm.bcp @@ -68,9 +48,6 @@ add_custom_command(OUTPUT ${GENERATED_BINARY_DIR}/ttdpal.h DEPENDS ${PALETTE_SOURCE_FILES} ) add_custom_target(palettes_header DEPENDS ${GENERATED_BINARY_DIR}/ttdpal.h) -#add_library(PALETTES INTERFACE) -#target_include_directories(PALETTES INTERFACE ${GENERATED_BINARY_DIR}) -#add_dependencies(PALETTES palettes_header) set(GRFID_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/grfid.cpp From 93e1a21e15f02a43b71f28fe9b053e1723f38d6e Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Tue, 9 Apr 2019 06:58:40 +0100 Subject: [PATCH 09/21] Change: else()/endif() cleanup --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f3471be..cf79bab0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,11 +25,11 @@ find_package(PNG) include(TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) -if (IS_BIG_ENDIAN) +if(IS_BIG_ENDIAN) add_definitions(-DGRFCODEC_BIG_ENDIAN=1) -else (IS_BIG_ENDIAN) +else() add_definitions(-DGRFCODEC_LITTLE_ENDIAN=1) -endif (IS_BIG_ENDIAN) +endif() set(PALETTE_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/tt1_mars.bcp @@ -113,6 +113,6 @@ add_dependencies(grfcodec palettes_header version_header) if(PNG_FOUND) set_target_properties(grfcodec PROPERTIES COMPILE_FLAGS -DWITH_PNG) target_link_libraries(grfcodec ${PNG_LIBRARY}) -endif(PNG_FOUND) +endif() From b98235b3f74c6a497f3a47ccb5d371803f95c869 Mon Sep 17 00:00:00 2001 From: glx Date: Mon, 18 Mar 2019 21:45:25 +0100 Subject: [PATCH 10/21] Fix: typo --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf79bab0..2647e56e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ find_package(Git REQUIRED) set(GENERATED_BINARY_DIR "${CMAKE_BINARY_DIR}/generated") include_directories("${GENERATED_BINARY_DIR}") -add_custom_command(OUTPUT "{$GENERATED_BINARY_DIR}/version.h" +add_custom_command(OUTPUT "${GENERATED_BINARY_DIR}/version.h" COMMAND ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} -D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in From fe9b196832859d7bf073fce3a573dfb34a3f94cf Mon Sep 17 00:00:00 2001 From: glx Date: Mon, 18 Mar 2019 21:45:02 +0100 Subject: [PATCH 11/21] Fix: incorrect compiler defines --- src/grfcodec.cpp | 4 ++-- src/grfcomm.cpp | 2 +- src/grfid.cpp | 2 +- src/grfstrip.cpp | 2 +- src/nforenum.cpp | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/grfcodec.cpp b/src/grfcodec.cpp index 82ee9805..83502005 100644 --- a/src/grfcodec.cpp +++ b/src/grfcodec.cpp @@ -24,7 +24,7 @@ #include #include -#ifdef MINGW +#ifdef __MINGW32__ #include #define mkdir(a,b) mkdir(a) #define isatty _isatty @@ -923,7 +923,7 @@ int main(int argc, char **argv) checksizes(); -#ifdef WIN32 +#ifdef _WIN32 // debugint(); #endif diff --git a/src/grfcomm.cpp b/src/grfcomm.cpp index ca75cf93..9e57ace4 100644 --- a/src/grfcomm.cpp +++ b/src/grfcomm.cpp @@ -10,7 +10,7 @@ #include #include #include -#ifdef MINGW +#ifdef __MINGW32__ # include # define mkdir(a,b) mkdir(a) #elif defined(_MSC_VER) diff --git a/src/grfid.cpp b/src/grfid.cpp index c7fd883e..d582050a 100644 --- a/src/grfid.cpp +++ b/src/grfid.cpp @@ -12,7 +12,7 @@ #include "md5.h" -#ifndef WIN32 +#ifndef _WIN32 #include #else #include diff --git a/src/grfstrip.cpp b/src/grfstrip.cpp index 47ba0220..3cb6c56f 100644 --- a/src/grfstrip.cpp +++ b/src/grfstrip.cpp @@ -12,7 +12,7 @@ #include "md5.h" -#ifndef WIN32 +#ifndef _WIN32 #include #else #include diff --git a/src/nforenum.cpp b/src/nforenum.cpp index 5987fc61..fa85a510 100644 --- a/src/nforenum.cpp +++ b/src/nforenum.cpp @@ -35,7 +35,7 @@ #include #include -#ifdef MINGW +#ifdef __MINGW32__ #include #define isatty _isatty #elif defined(_MSC_VER) From ddf2cbc2ce4c52f82f743582a03b87604bd8387d Mon Sep 17 00:00:00 2001 From: glx Date: Tue, 26 Nov 2019 19:34:54 +0100 Subject: [PATCH 12/21] Change: replace perl with cmake to generate ttdpal.h --- CMakeLists.txt | 10 ++++++++-- src/pal2c.cmake | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ src/pal2c.pl | 50 ------------------------------------------------ src/ttdpal.h.in | 15 +++++++++++++++ 4 files changed, 74 insertions(+), 52 deletions(-) create mode 100644 src/pal2c.cmake delete mode 100755 src/pal2c.pl create mode 100644 src/ttdpal.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 2647e56e..813ae10b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,9 +43,15 @@ set(PALETTE_SOURCE_FILES ) add_custom_command(OUTPUT ${GENERATED_BINARY_DIR}/ttdpal.h - COMMAND ${CMAKE_COMMAND} -E make_directory ${GENERATED_BINARY_DIR} - COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.pl ${PALETTE_SOURCE_FILES} > ${GENERATED_BINARY_DIR}/ttdpal.h + COMMAND ${CMAKE_COMMAND} + -D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/src/ttdpal.h.in + -D OUTPUT_FILE=${GENERATED_BINARY_DIR}/ttdpal.h + -P ${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.cmake + -- + ${PALETTE_SOURCE_FILES} DEPENDS ${PALETTE_SOURCE_FILES} + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/ttdpal.h.in" + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.cmake ) add_custom_target(palettes_header DEPENDS ${GENERATED_BINARY_DIR}/ttdpal.h) diff --git a/src/pal2c.cmake b/src/pal2c.cmake new file mode 100644 index 00000000..eedb459d --- /dev/null +++ b/src/pal2c.cmake @@ -0,0 +1,51 @@ +cmake_minimum_required(VERSION 3.5) + +set(ARGC 1) +set(ARG_READ NO) + +# Read all the arguments given to CMake; we are looking for -- and everything +# that follows. Those are our palette files. +while(ARGC LESS CMAKE_ARGC) + set(ARG ${CMAKE_ARGV${ARGC}}) + + if(ARG_READ) + list(APPEND PALETTE_FILES "${ARG}") + endif() + + if(ARG STREQUAL "--") + set(ARG_READ YES) + endif() + + math(EXPR ARGC "${ARGC} + 1") +endwhile() + +set(PALNUM 0) +foreach(PALFILE IN LISTS PALETTE_FILES) + get_filename_component(PAL ${PALFILE} NAME_WE) + string(APPEND DEFINES "#define PAL_${PAL} ${PALNUM}\n") + math(EXPR PALNUM "${PALNUM} + 1") + string(APPEND PALETTES "// PAL_${PAL}\n {\n") + + set(COUNT 0) + string(LENGTH "${PALETTE}" LEN) + math(EXPR LEN "${LEN} / 6") + while(COUNT LESS 256) + math(EXPR OFFSET "${COUNT} * 3") + file(READ ${PALFILE} PALETTE OFFSET ${OFFSET} LIMIT 3 HEX) + string(REGEX REPLACE "(..)" "0x\\1," PALETTE ${PALETTE}) + math(EXPR COUNT "${COUNT} + 1") + math(EXPR MOD "${COUNT} % 4") + if(MOD EQUAL 1) + string(APPEND PALETTES "\t") + endif() + string(APPEND PALETTES "${PALETTE} ") + if(MOD EQUAL 0) + math(EXPR FROM "${COUNT} - 4") + math(EXPR TO "${COUNT} - 1") + string(APPEND PALETTES "\t// ${FROM}-${TO}\n") + endif() + endwhile() + string(APPEND PALETTES " },\n") +endforeach() + +configure_file(${INPUT_FILE} ${OUTPUT_FILE}) diff --git a/src/pal2c.pl b/src/pal2c.pl deleted file mode 100755 index 1f9acdc3..00000000 --- a/src/pal2c.pl +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use File::Basename; - -my @files = map glob, @ARGV; - -print "// Autogenerated file. DO NOT EDIT!\n"; -print "// Edit Makefile.setup, pals/*.bcp, or pal2c.pl instead.\n\n"; -print "#define NUM_PALS ".@files."\n\n"; - -print "extern U8 defaultpalettes[NUM_PALS][256*3];\n\n"; - -my $palind = 0; - -for (@files) { - $_ = basename $_; - s/\..*//; - print "#define PAL_$_ $palind\n"; - $palind++; -} - -print "\n#ifdef DEFINE_PALS\n\n"; -print " U8 defaultpalettes[NUM_PALS][256*3] = {\n"; - -@files = map glob, @ARGV; - -for (@files) { - open FILE, "<$_" or die "Can't open $_: $!"; - binmode FILE; - local $/ = \3; # read three bytes at a time - $.=0; - - $_ = basename $_; - s/\..*//; - print "// PAL_$_\n"; - - print " {\n"; - - while () { - s/(.)/sprintf "%3d,",ord $1/ge; - print "\t" if $. % 4 == 1 ; - print "$_ "; - printf "\t// %d-%d\n", $.-4, $.-1 if $. % 4 == 0; - } - close FILE; - print " },\n"; -} -printf(" };\n"); -print "\n#endif // DEFINE_PALS\n" diff --git a/src/ttdpal.h.in b/src/ttdpal.h.in new file mode 100644 index 00000000..1d2cbfa5 --- /dev/null +++ b/src/ttdpal.h.in @@ -0,0 +1,15 @@ +// Autogenerated file. DO NOT EDIT! +// Edit ttdpal.h.in, pals/*.bcp, or pal2c.cmake instead. + +#define NUM_PALS ${PALNUM} + +extern U8 defaultpalettes[NUM_PALS][256*3]; + +${DEFINES} +#ifdef DEFINE_PALS + + U8 defaultpalettes[NUM_PALS][256*3] = { +${PALETTES} + }; + +#endif // DEFINE_PALS From 5e3398c820e2e2ed401376906ad05035b8caf395 Mon Sep 17 00:00:00 2001 From: glx Date: Wed, 27 Nov 2019 23:48:11 +0100 Subject: [PATCH 13/21] Change: force static linking for MinGW builds --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 813ae10b..717204a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,14 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED) set(CMAKE_CXX_EXTENSIONS NO) +if(MINGW) + # Force searching static libs, so the executables can run outside MinGW environment + set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") + + # Force static linking, so the executables can run outside MinGW environment + link_libraries(-static -static-libgcc -static-libstdc++) +endif() + find_package(Git REQUIRED) set(GENERATED_BINARY_DIR "${CMAKE_BINARY_DIR}/generated") @@ -101,7 +109,7 @@ add_dependencies(nforenum palettes_header version_header) set(GRFCODEC_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/error.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/file.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/file.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/globals.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/grfcodec.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/grfcomm.cpp @@ -118,7 +126,5 @@ add_executable(grfcodec ${GRFCODEC_SOURCE_FILES}) add_dependencies(grfcodec palettes_header version_header) if(PNG_FOUND) set_target_properties(grfcodec PROPERTIES COMPILE_FLAGS -DWITH_PNG) - target_link_libraries(grfcodec ${PNG_LIBRARY}) + target_link_libraries(grfcodec PNG::PNG) endif() - - From acc98abba02d44c4a848b312d1a8b735fb77c114 Mon Sep 17 00:00:00 2001 From: glx Date: Thu, 28 Nov 2019 19:30:38 +0100 Subject: [PATCH 14/21] Revert 8d065f6: our own getopt is needed for MSVC --- src/msvc/getopt.cpp | 646 ++++++++++++++++++++++++++++++++++++++++++++ src/msvc/getopt.h | 114 ++++++++ 2 files changed, 760 insertions(+) create mode 100644 src/msvc/getopt.cpp create mode 100644 src/msvc/getopt.h diff --git a/src/msvc/getopt.cpp b/src/msvc/getopt.cpp new file mode 100644 index 00000000..d8984552 --- /dev/null +++ b/src/msvc/getopt.cpp @@ -0,0 +1,646 @@ +/* Getopt for GNU. + NOTE: getopt is now part of the C library, so if you don't know what + "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu + before changing it! + + Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +/* Portions of this file not necessary to NFORenum's purposes have been + removed by Dale McCoy, at various times between 2004 and 2009. */ + + +#include +#include +#include + + +#ifndef __STDC__ +#define const +#endif + +/* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a + long-named option. Because this is not POSIX.2 compliant, it is + being phased out. */ +#undef GETOPT_COMPAT + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable POSIXLY_CORRECT disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include "getopt.h" + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = 0; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +int optind = 0; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + POSIXLY_CORRECT is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable POSIXLY_CORRECT, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return EOF with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +#ifdef __GNU_LIBRARY__ +#include +#define my_index strchr +#define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) +#else + +/* Avoid depending on library functions or files + whose names are inconsistent. */ + +/*char *getenv ();*/ + +static char *my_index (const char *string, int chr) +{ + while (*string) + { + if (*string == chr) + return (char *) string; + string++; + } + return 0; +} + +static void my_bcopy (char *from, char *to, int size) +{ + int i; + for (i = 0; i < size; i++) + to[i] = from[i]; +} +#endif /* GNU C library. */ + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +static void exchange (char **argv) +{ + int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); + char **temp = (char **) malloc (nonopts_size); + + /* Interchange the two blocks of data in ARGV. */ + + my_bcopy ((char *)&argv[first_nonopt], (char *)temp, + nonopts_size); + my_bcopy ((char *)&argv[last_nonopt], (char *)&argv[first_nonopt], + (optind - last_nonopt) * sizeof (char *)); + my_bcopy ((char *)temp, (char *)&argv[first_nonopt + optind - last_nonopt], + nonopts_size); + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns `EOF'. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '!' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '!'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `--' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + if the `flag' field is zero. + + The elements of ARGV aren't really const, because we permute them. + But we pretend they're const in the prototype to be compatible + with other systems. + + LONGOPTS is a vector of `struct option' terminated by an + element containing a name which is zero. + + LONGIND returns the index in LONGOPT of the long-named option found. + It is only valid when a long-named option has been found by the most + recent call. + + If LONG_ONLY is nonzero, '-' as well as '--' can introduce + long-named options. */ + +int _getopt_internal (int argc, char *const *argv, const char *optstring, + const struct option *longopts, int *longind, int long_only) +{ + int option_index; + + optarg = 0; + + /* Initialize the internal data when the first call is made. + Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + if (optind == 0) + { + first_nonopt = last_nonopt = optind = 1; + + nextchar = NULL; + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (getenv ("POSIXLY_CORRECT") != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + } + + if (nextchar == NULL || *nextchar == '\0') + { + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Now skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc + && (argv[optind][0] != '-' || argv[optind][1] == '\0') +#ifdef GETOPT_COMPAT + && (longopts == NULL + || argv[optind][0] != '+' || argv[optind][1] == '\0') +#endif /* GETOPT_COMPAT */ + ) + optind++; + last_nonopt = optind; + } + + /* Special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange ((char **) argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return EOF; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if ((argv[optind][0] != '-' || argv[optind][1] == '\0') +#ifdef GETOPT_COMPAT + && (longopts == NULL + || argv[optind][0] != '+' || argv[optind][1] == '\0') +#endif /* GETOPT_COMPAT */ + ) + { + if (ordering == REQUIRE_ORDER) + return EOF; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Start decoding its characters. */ + + nextchar = (argv[optind] + 1 + + (longopts != NULL && argv[optind][1] == '-')); + } + + if (longopts != NULL + && ((argv[optind][0] == '-' + && (argv[optind][1] == '-' || long_only)) +#ifdef GETOPT_COMPAT + || argv[optind][0] == '+' +#endif /* GETOPT_COMPAT */ + )) + { + const struct option *p; + char *s = nextchar; + int exact = 0; + int ambig = 0; + const struct option *pfound = NULL; + int indfound = 0; + + while (*s && *s != '=') + s++; + + /* Test all options for either exact match or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; + p++, option_index++) + if (!strncmp (p->name, nextchar, s - nextchar)) + { + if (s - nextchar == (signed int) strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == NULL) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + if (opterr) + fprintf (stderr, "%s: option `%s' is ambiguous\n", + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '!'; + } + + if (pfound != NULL) + { + option_index = indfound; + optind++; + if (*s) + { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = s + 1; + else + { + if (opterr) + { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf (stderr, + "%s: option `--%s' doesn't allow an argument\n", + argv[0], pfound->name); + else + /* +option or -option */ + fprintf (stderr, + "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[optind - 1][0], pfound->name); + } + nextchar += strlen (nextchar); + return '!'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + if (opterr) + fprintf (stderr, "%s: option `%s' requires an argument\n", + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return '!'; + } + } + nextchar += strlen (nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' +#ifdef GETOPT_COMPAT + || argv[optind][0] == '+' +#endif /* GETOPT_COMPAT */ + || my_index (optstring, *nextchar) == NULL) + { + if (opterr) + { + if (argv[optind][1] == '-') + /* --option */ + fprintf (stderr, "%s: unrecognized option `--%s'\n", + argv[0], nextchar); + else + /* +option or -option */ + fprintf (stderr, "%s: unrecognized option `%c%s'\n", + argv[0], argv[optind][0], nextchar); + } + nextchar = (char *) ""; + optind++; + return '!'; + } + } + + /* Look at and handle the next option-character. */ + + { + char c = *nextchar++; + const char *temp = my_index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL || c == ':') + { + if (opterr) + { + if (c < 040 || c >= 0177) + fprintf (stderr, "%s: unrecognized option, character code 0%o\n", + argv[0], c); + else + fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); + } + return '!'; + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') + { + optarg = nextchar; + optind++; + } + else + optarg = 0; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr) + fprintf (stderr, "%s: option `-%c' requires an argument\n", + argv[0], c); + c = '!'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } +} + +int getopt (int argc, char *const *argv, const char *optstring) +{ + return _getopt_internal (argc, argv, optstring, + (const struct option *) 0, + (int *) 0, + 0); +} + +int +getopt_long (int argc, char *const *argv, const char *options, + const struct option *long_options, int *opt_index) +{ + return _getopt_internal (argc, argv, options, long_options, opt_index, 0); +} + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == EOF) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/src/msvc/getopt.h b/src/msvc/getopt.h new file mode 100644 index 00000000..f1600b64 --- /dev/null +++ b/src/msvc/getopt.h @@ -0,0 +1,114 @@ +/* Declarations for getopt. + Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU Library General Public License as published + by the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifndef _GETOPT_H +#define _GETOPT_H 1 +#define __GETOPT_H__ + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Describe the long-named options requested by the application. + The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector + of `struct option' terminated by an element containing a name which is + zero. + + The field `has_arg' is: + no_argument (or 0) if the option does not take an argument, + required_argument (or 1) if the option requires an argument, + optional_argument (or 2) if the option takes an optional argument. + + If the field `flag' is not NULL, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ +#if __STDC__ + const char *name; +#else + char *name; +#endif + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; +}; + +/* Names for the values of the `has_arg' field of `struct option'. */ + +enum _argtype +{ + no_argument, + required_argument, + optional_argument +}; + +#if __STDC__ || __BORLANDC__ || _MSC_VER +extern int getopt (int argc, char *const *argv, const char *shortopts); +extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind); + +/* Internal only. Users should not call this directly. */ +extern int _getopt_internal (int argc, char *const *argv, + const char *shortopts, + const struct option *longopts, int *longind, + int long_only); +#else /* not __STDC__ */ +extern int getopt (); +extern int getopt_long (); +extern int getopt_long_only (); + +extern int _getopt_internal (); +#endif /* not __STDC__ */ + +#endif /* _GETOPT_H */ From 8f9c2ecc5f31676af1b3bdb771b55cdda43cc700 Mon Sep 17 00:00:00 2001 From: glx Date: Fri, 29 Nov 2019 01:11:46 +0100 Subject: [PATCH 15/21] Fix: missing include for std::min and std::max --- src/act123_classes.cpp | 1 + src/act6.cpp | 1 + src/grfcodec.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/src/act123_classes.cpp b/src/act123_classes.cpp index 38140ddd..ec08ef30 100644 --- a/src/act123_classes.cpp +++ b/src/act123_classes.cpp @@ -22,6 +22,7 @@ #include #include #include +#include using namespace std; diff --git a/src/act6.cpp b/src/act6.cpp index e615b7c2..362714c3 100644 --- a/src/act6.cpp +++ b/src/act6.cpp @@ -21,6 +21,7 @@ #include #include +#include using namespace std; diff --git a/src/grfcodec.cpp b/src/grfcodec.cpp index 83502005..a45f6b22 100644 --- a/src/grfcodec.cpp +++ b/src/grfcodec.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef __MINGW32__ #include From 3c2cf6d7d78780de4c2a392019495c59dd700f88 Mon Sep 17 00:00:00 2001 From: glx Date: Fri, 29 Nov 2019 01:12:45 +0100 Subject: [PATCH 16/21] Fix: name conflict with std::data (c++17) --- src/data.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/data.cpp b/src/data.cpp index 333f9083..dc9ddab0 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -1046,7 +1046,7 @@ struct dat{ #undef DATA #undef DATA_FILE #undef END_DATA -#define DATA() static const dat data[]={ +#define DATA() static const dat datafiles[]={ #define DATA_FILE(name)\ {(char*)_dat##name,"/.nforenum/" #name ".dat",sizeof(_dat##name)-1},\ @@ -1126,11 +1126,11 @@ FILE*tryopen(const char*name,const char*mode,bool allownull=false){ } FILE*_myfopen(files file, bool write){ - FILE*pFile=tryopen(data[file].name,"rb",true); + FILE*pFile=tryopen(datafiles[file].name,"rb",true); if(pFile){ - if(fgetc(pFile)==data[file].data[0]&&fgetc(pFile)>=data[file].data[1]){ + if(fgetc(pFile)==datafiles[file].data[0]&&fgetc(pFile)>=datafiles[file].data[1]){ if(file>datfeat && (uint)fgetc(pFile)(data[file].data), data[file].len, "rb"); + pFile = fmemopen(const_cast(datafiles[file].data), datafiles[file].len, "rb"); if (pFile == NULL) { - IssueMessage(0, DATAFILE_ERROR, OPEN, data[file].name + 1, ERRNO, errno); + IssueMessage(0, DATAFILE_ERROR, OPEN, datafiles[file].name + 1, ERRNO, errno); perror(NULL); assert(false); exit(EDATA); @@ -1152,19 +1152,19 @@ FILE*_myfopen(files file, bool write){ (void)write; #endif /* WITH_FMEMOPEN */ { - pFile = tryopen(data[file].name,"wb"); - if (fwrite(data[file].data, 1, data[file].len, pFile) != data[file].len) { - IssueMessage(0, DATAFILE_ERROR, WRITE, data[file].name + 1, -1); + pFile = tryopen(datafiles[file].name,"wb"); + if (fwrite(datafiles[file].data, 1, datafiles[file].len, pFile) != datafiles[file].len) { + IssueMessage(0, DATAFILE_ERROR, WRITE, datafiles[file].name + 1, -1); assert(false); exit(EDATA); } fclose(pFile); - pFile = tryopen(data[file].name,"rb"); + pFile = tryopen(datafiles[file].name,"rb"); } fgetc(pFile); fgetc(pFile); if(file>datfeat && (uint)fgetc(pFile) Date: Fri, 29 Nov 2019 01:14:44 +0100 Subject: [PATCH 17/21] Add: compilation with MSVC --- CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++++ src/msvc/getopt.h | 4 ++-- src/sanity_defines.h | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 717204a5..6396b8da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,29 @@ if(MINGW) link_libraries(-static -static-libgcc -static-libstdc++) endif() +if(MSVC) + # Switch to MT (static) instead of MD (dynamic) binary + + # For MSVC two generators are available + # - a command line generator (Ninja) using CMAKE_BUILD_TYPE to specify the + # configuration of the build tree + # - an IDE generator (Visual Studio) using CMAKE_CONFIGURATION_TYPES to + # specify all configurations that will be available in the generated solution + list(APPEND MSVC_CONFIGS "${CMAKE_BUILD_TYPE}" "${CMAKE_CONFIGURATION_TYPES}") + + # Set usage of static runtime for all configurations + foreach(MSVC_CONFIG ${MSVC_CONFIGS}) + string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS) + string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}") + endforeach() + + # Disable deprecation warnings + add_compile_options(/wd4996) + + # Add includes for our own getopt + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/msvc) +endif() + find_package(Git REQUIRED) set(GENERATED_BINARY_DIR "${CMAKE_BINARY_DIR}/generated") @@ -30,6 +53,7 @@ add_custom_command(OUTPUT "${GENERATED_BINARY_DIR}/version.h" add_custom_target(version_header DEPENDS "${GENERATED_BINARY_DIR}/version.h") find_package(PNG) +find_package(Boost REQUIRED) include(TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) @@ -106,6 +130,7 @@ set(NFORENUM_SOURCE_FILES ) add_executable(nforenum ${NFORENUM_SOURCE_FILES}) add_dependencies(nforenum palettes_header version_header) +target_link_libraries(nforenum Boost::boost) set(GRFCODEC_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/error.cpp @@ -124,7 +149,16 @@ set(GRFCODEC_SOURCE_FILES ) add_executable(grfcodec ${GRFCODEC_SOURCE_FILES}) add_dependencies(grfcodec palettes_header version_header) +target_link_libraries(grfcodec Boost::boost) if(PNG_FOUND) set_target_properties(grfcodec PROPERTIES COMPILE_FLAGS -DWITH_PNG) target_link_libraries(grfcodec PNG::PNG) endif() + +if(MSVC) + # use our own getopt to nforenum + target_sources(nforenum PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/msvc/getopt.cpp) + + # use our own getopt to grfcodec + target_sources(grfcodec PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/msvc/getopt.cpp) +endif() diff --git a/src/msvc/getopt.h b/src/msvc/getopt.h index f1600b64..d24a3f44 100644 --- a/src/msvc/getopt.h +++ b/src/msvc/getopt.h @@ -91,8 +91,8 @@ enum _argtype }; #if __STDC__ || __BORLANDC__ || _MSC_VER -extern int getopt (int argc, char *const *argv, const char *shortopts); -extern int getopt_long (int argc, char *const *argv, const char *shortopts, +extern "C" int getopt (int argc, char *const *argv, const char *shortopts); +extern "C" int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, const char *shortopts, diff --git a/src/sanity_defines.h b/src/sanity_defines.h index 174f25c8..d094f215 100644 --- a/src/sanity_defines.h +++ b/src/sanity_defines.h @@ -90,6 +90,6 @@ class apWrapper{ }; #define WrapAp(v)\ apWrapper ap;\ - va_start(ap,v); + va_start((va_list&)ap,v); #endif//_RENUM_SANITY_DEFS_H_INCLUDED_ From ba8a4b4368e9d11cbd8eaafbb9c7a5bddf4c7920 Mon Sep 17 00:00:00 2001 From: glx Date: Fri, 29 Nov 2019 01:15:02 +0100 Subject: [PATCH 18/21] Fix: MSVC warnings --- src/grfid.cpp | 6 +++--- src/grfstrip.cpp | 4 ++-- src/pseudo.cpp | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/grfid.cpp b/src/grfid.cpp index d582050a..bc024c30 100644 --- a/src/grfid.cpp +++ b/src/grfid.cpp @@ -19,7 +19,7 @@ #define PROT_READ 0 #define MAP_PRIVATE 0 /* Lets fake mmap for Windows, please! */ -void *mmap (void * /*ptr*/, long size, long /*prot*/, long /*type*/, long handle, long /*arg*/) { +void *mmap (void * /*ptr*/, size_t size, long /*prot*/, long /*type*/, long handle, long /*arg*/) { char *mem = (char*)malloc(size + 1); mem[size] = 0; FILE *in = fdopen(handle, "rb"); @@ -31,7 +31,7 @@ void *mmap (void * /*ptr*/, long size, long /*prot*/, long /*type*/, long handle fclose(in); return mem; } -long munmap (void *ptr, long /*size*/) { +long munmap (void *ptr, size_t /*size*/) { free(ptr); return 0; } @@ -194,7 +194,7 @@ const char *GetMD5(const char *filename, md5_state_t *md5) if (read_length > _file_length) return "Invalid sprite location offset"; } - md5_append(md5, _file_buffer, read_length); + md5_append(md5, _file_buffer, (int)read_length); munmap(_file_buffer, _file_length); fclose(f); diff --git a/src/grfstrip.cpp b/src/grfstrip.cpp index 3cb6c56f..240c7d81 100644 --- a/src/grfstrip.cpp +++ b/src/grfstrip.cpp @@ -19,7 +19,7 @@ #define PROT_READ 0 #define MAP_PRIVATE 0 /* Lets fake mmap for Windows, please! */ -void *mmap (void * /*ptr*/, long size, long /*prot*/, long /*type*/, long handle, long /*arg*/) { +void *mmap (void * /*ptr*/, size_t size, long /*prot*/, long /*type*/, long handle, long /*arg*/) { char *mem = (char*)malloc(size + 1); mem[size] = 0; FILE *in = fdopen(handle, "rb"); @@ -31,7 +31,7 @@ void *mmap (void * /*ptr*/, long size, long /*prot*/, long /*type*/, long handle fclose(in); return mem; } -long munmap (void *ptr, long /*size*/) { +long munmap (void *ptr, size_t /*size*/) { free(ptr); return 0; } diff --git a/src/pseudo.cpp b/src/pseudo.cpp index ea62c851..05feaf3d 100644 --- a/src/pseudo.cpp +++ b/src/pseudo.cpp @@ -790,13 +790,14 @@ uint PseudoSprite::ReadValue(istream& in, width w) { IssueMessage(0, INVALID_EXTENSION); return 0; } - int val, err = 0, s = in.tellg(); + int val, err = 0; + size_t s = in.tellg(); val = DoCalc(in.ignore(),err); if (err>0) return 0; // Replace the original RPN with value - int e = in.tellg(), + size_t e = in.tellg(), p = orig.find(((istringstream&)in).str().substr(s, e - s)); orig.erase(p, e - s); ostringstream Val; From aa942577c07ba5fa0ac2177b239ed5bb036b3aec Mon Sep 17 00:00:00 2001 From: glx Date: Fri, 29 Nov 2019 03:59:02 +0100 Subject: [PATCH 19/21] Change: use a CMakeLists.txt file per directory --- CMakeLists.txt | 120 +++++++++++++--------------------------- src/CMakeLists.txt | 65 ++++++++++++++++++++++ src/msvc/CMakeLists.txt | 11 ++++ 3 files changed, 114 insertions(+), 82 deletions(-) create mode 100644 src/CMakeLists.txt create mode 100644 src/msvc/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6396b8da..78aa4604 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,29 +32,14 @@ if(MSVC) # Disable deprecation warnings add_compile_options(/wd4996) - - # Add includes for our own getopt - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/msvc) endif() -find_package(Git REQUIRED) - -set(GENERATED_BINARY_DIR "${CMAKE_BINARY_DIR}/generated") -include_directories("${GENERATED_BINARY_DIR}") - -add_custom_command(OUTPUT "${GENERATED_BINARY_DIR}/version.h" - COMMAND ${CMAKE_COMMAND} - -D GIT_EXECUTABLE=${GIT_EXECUTABLE} - -D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in - -D OUTPUT_FILE=${GENERATED_BINARY_DIR}/version.h - -P ${CMAKE_CURRENT_SOURCE_DIR}/generate_version.cmake - DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in" -) -add_custom_target(version_header DEPENDS "${GENERATED_BINARY_DIR}/version.h") +find_package(Git REQUIRED) find_package(PNG) find_package(Boost REQUIRED) + include(TestBigEndian) TEST_BIG_ENDIAN(IS_BIG_ENDIAN) if(IS_BIG_ENDIAN) @@ -63,6 +48,24 @@ else() add_definitions(-DGRFCODEC_LITTLE_ENDIAN=1) endif() + +# Prepare generated dir +set(GENERATED_BINARY_DIR "${CMAKE_BINARY_DIR}/generated") +include_directories("${GENERATED_BINARY_DIR}") + +# Target to generate version.h +add_custom_target(version_header + COMMAND ${CMAKE_COMMAND} + -D GIT_EXECUTABLE=${GIT_EXECUTABLE} + -D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in + -D OUTPUT_FILE=${GENERATED_BINARY_DIR}/version.h + -P "${CMAKE_CURRENT_SOURCE_DIR}/generate_version.cmake" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in" + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generate_version.cmake" + BYPRODUCTS "${GENERATED_BINARY_DIR}/version.h" +) + +# Target to generate ttpal.h set(PALETTE_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/tt1_mars.bcp ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/tt1_norm.bcp @@ -73,81 +76,38 @@ set(PALETTE_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/ttw_pb_pal1.bcp ${CMAKE_CURRENT_SOURCE_DIR}/src/pals/ttw_pb_pal2.bcp ) - -add_custom_command(OUTPUT ${GENERATED_BINARY_DIR}/ttdpal.h +add_custom_target(palettes_header COMMAND ${CMAKE_COMMAND} -D INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/src/ttdpal.h.in -D OUTPUT_FILE=${GENERATED_BINARY_DIR}/ttdpal.h - -P ${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.cmake + -P "${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.cmake" -- ${PALETTE_SOURCE_FILES} DEPENDS ${PALETTE_SOURCE_FILES} DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/ttdpal.h.in" - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.cmake + DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/pal2c.cmake" + BYPRODUCTS "${GENERATED_BINARY_DIR}/ttdpal.h" ) -add_custom_target(palettes_header DEPENDS ${GENERATED_BINARY_DIR}/ttdpal.h) -set(GRFID_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/src/grfid.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/md5.cpp -) -add_executable(grfid ${GRFID_SOURCE_FILES}) + +# Create grfid +add_executable(grfid) add_dependencies(grfid version_header) -set(GRFSTRIP_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/src/grfstrip.cpp -) -add_executable(grfstrip ${GRFSTRIP_SOURCE_FILES}) + +# Create grfstrip +add_executable(grfstrip) add_dependencies(grfstrip version_header) -set(NFORENUM_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/src/act0.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/act123_classes.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/act123.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/act14.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/act5.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/act6.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/act79D.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/actB.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/actF.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/command.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/data.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/globals.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/help.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/IDs.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/inject.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/language_mgr.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/mapescapes.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/message_mgr.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/messages.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/nforenum.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/pseudo.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/pseudo_seq.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/rangedint.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/sanity.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/strings.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/utf8.cpp -) -add_executable(nforenum ${NFORENUM_SOURCE_FILES}) + +# Create nforenum +add_executable(nforenum) add_dependencies(nforenum palettes_header version_header) target_link_libraries(nforenum Boost::boost) -set(GRFCODEC_SOURCE_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/src/error.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/file.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/globals.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/grfcodec.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/grfcomm.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/info.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/mapescapes.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/path.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/pcxfile.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/pcxsprit.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/pngsprit.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/readinfo.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/src/sprites.cpp -) -add_executable(grfcodec ${GRFCODEC_SOURCE_FILES}) + +# Create grfcodec +add_executable(grfcodec) add_dependencies(grfcodec palettes_header version_header) target_link_libraries(grfcodec Boost::boost) if(PNG_FOUND) @@ -155,10 +115,6 @@ if(PNG_FOUND) target_link_libraries(grfcodec PNG::PNG) endif() -if(MSVC) - # use our own getopt to nforenum - target_sources(nforenum PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/msvc/getopt.cpp) - # use our own getopt to grfcodec - target_sources(grfcodec PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/msvc/getopt.cpp) -endif() +# Add source files +add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 00000000..d8f31500 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,65 @@ +cmake_minimum_required(VERSION 3.5) + +add_subdirectory(msvc) + + +# Add files for grfid +target_sources(grfid PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/grfid.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/md5.cpp +) + + +# Add files for grfstrip +target_sources(grfstrip PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/grfstrip.cpp +) + + +# Add files for grfcodec +target_sources(grfcodec PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/error.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/file.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/globals.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/grfcodec.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/grfcomm.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/info.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mapescapes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/path.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/pcxfile.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/pcxsprit.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/pngsprit.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/readinfo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sprites.cpp +) + + +# Add files for nforenum +target_sources(nforenum PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/act0.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/act123_classes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/act123.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/act14.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/act5.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/act6.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/act79D.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/actB.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/actF.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/command.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/data.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/globals.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/help.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/IDs.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/inject.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/language_mgr.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/mapescapes.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/message_mgr.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/messages.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/nforenum.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/pseudo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/pseudo_seq.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rangedint.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/sanity.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/strings.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/utf8.cpp +) diff --git a/src/msvc/CMakeLists.txt b/src/msvc/CMakeLists.txt new file mode 100644 index 00000000..bda61cfc --- /dev/null +++ b/src/msvc/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.5) + +if(MSVC) + # Add our own getopt to grfcodec + target_sources(grfcodec PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/getopt.cpp) + target_include_directories(grfcodec PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + + # Add our own getopt to nforenum + target_sources(nforenum PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/getopt.cpp) + target_include_directories(nforenum PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +endif() From 7eb50163e678c1347891a5a7cf28c4de3d4add80 Mon Sep 17 00:00:00 2001 From: glx22 Date: Wed, 4 Nov 2020 16:53:31 +0100 Subject: [PATCH 20/21] Fix: restore compile flags --- CMakeLists.txt | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 78aa4604..08f8277f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,8 +30,29 @@ if(MSVC) string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}") endforeach() - # Disable deprecation warnings - add_compile_options(/wd4996) + add_compile_options( + /wd4996 # Disable deprecation warnings + /W3 + ) +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") + add_compile_options( + -Wall + -Wextra + -Wno-format-nonliteral + ) +endif() + + +# Add some -D flags for Debug builds. We cannot use add_definitions(), because +# it does not appear to support the $<> tags. +add_compile_options( + "$<$:-D_DEBUG>" + "$<$>:-D_FORTIFY_SOURCE=2>" # FORTIFY_SOURCE should only be used in non-debug builds (requires -O1+) +) +if(MINGW) + add_link_options( + "$<$>:-fstack-protector>" # Prevent undefined references when _FORTIFY_SOURCE > 0 + ) endif() From 26f62254699dc6e069dfc74727ec2d57cb991b05 Mon Sep 17 00:00:00 2001 From: glx22 Date: Tue, 15 Dec 2020 16:21:40 +0100 Subject: [PATCH 21/21] Fix: restore fmemopen detection --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f8277f..1450d7c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,6 +70,13 @@ else() endif() +include(CheckCXXSymbolExists) +check_cxx_symbol_exists("fmemopen" "cstdio" HAS_FMEMOPEN) +if(HAS_FMEMOPEN) + add_definitions(-DWITH_FMEMOPEN) +endif() + + # Prepare generated dir set(GENERATED_BINARY_DIR "${CMAKE_BINARY_DIR}/generated") include_directories("${GENERATED_BINARY_DIR}")