-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
2720 lines (2242 loc) · 94 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// I got lazy and stopped commenting after the tileset window
// I'll finish the rest later
// Still too lazy to comment, I'll do it next time
// Also, the "c" in "0.1c" stands for "color" ;)
// Man, I really need to stop being so lazy
// This time, the "d" in "0.1d" stands for "data"
#include "imgui.h"
#include "imgui_internal.h"
#include "imgui_impl_glfw.h"
#include "imgui_impl_opengl3.h"
#include "imguifs.h"
#include <stdio.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include <string.h>
#include <math.h>
// DMG pixel modes
#define WHITE 0xFF
#define LGREY 0x80
#define DGREY 0x40
#define BLACK 0x00
// Palette modes
#define PAL_GREY 0
#define PAL_RED 1
#define PAL_GREEN 2
#define PAL_BLUE 3
#define PAL_YELLOW 4
#define PAL_BROWN 5
#define PAL_ROOF 6
#define PAL_MSG 7
// Palette types
#define PAL_MORNING 0
#define PAL_DAY 1
#define PAL_NIGHT 2
#define PAL_DUNGEON 3
#define PAL_DARK_CAVE 4
#define PAL_BUILDING 5
// DMG colors
#define COL_WHITE 255, 255, 255
#define COL_LGREY 128, 128, 128
#define COL_DGREY 64, 64, 64
#define COL_BLACK 0, 0, 0
// Palette colors
#define COL_GREY 172.0f/255.0f, 172.0f/255.0f, 172.0f/255.0f
#define COL_RED 255.0f/255.0f, 156.0f/255.0f, 197.0f/255.0f
#define COL_GREEN 98.0f/255.0f, 205.0f/255.0f, 8.0f/255.0f
#define COL_BLUE 65.0f/255.0f, 98.0f/255.0f, 255.0f/255.0f
#define COL_YELLOW 255.0f/255.0f, 255.0f/255.0f, 57.0f/255.0f
#define COL_BROWN 197.0f/255.0f, 148.0f/255.0f, 57.0f/255.0f
#define COL_ROOF 255.0f/255.0f, 41.0f/255.0f, 173.0f/255.0f
#define COL_MSG 255.0f/255.0f, 255.0f/255.0f, 255.0f/255.0f
// Editing modes
#define TILE_EDIT 0
#define CELL_EDIT 1
#define MAP_EDIT 2
// Output formats
#define FMT_INTSYS 0 // db 069h
#define FMT_REDNEX 1 // db $69
#define FMT_BINARY 2 // 0x69
// Tileset drawing modes
#define TOOL_PIXEL 0
#define TOOL_FILL 1
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
#include <GL/gl3w.h> // Initialize with gl3wInit()
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
#include <GL/glew.h> // Initialize with glewInit()
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
#include <glad/glad.h> // Initialize with gladLoadGL()
#else
#include IMGUI_IMPL_OPENGL_LOADER_CUSTOM
#endif
#include <GLFW/glfw3.h>
#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(IMGUI_DISABLE_WIN32_FUNCTIONS)
#pragma comment(lib, "legacy_stdio_definitions")
#endif
// Undo and redo history buffers
ImVector<unsigned char[16][16][64]> undo_history;
ImVector<unsigned char[16][16][64]> redo_history;
/**
* Replaces instances of the contiguous target color with the chosen color.
* Functions similarly to the "Fill" tool in MS Paint, Photoshop, etc.
*
* NOTE:
* This is only a per-tile fill.
* Tiles other than the one clicked will NOT be affected.
*
* @param tile - Tile currently being edited
* @param x - X coordinate of the pixel to fill
* @param y - Y coordinate of the pixel to fill
* @param target_color - Color to be replaced
* @param new_color - Color to replace with
*
* @return void - Just fills pixels, no return needed
*/
static void fill_color(unsigned char* tile, int x, int y, unsigned int target_color, unsigned int new_color)
{
unsigned int cur_pixel = *(tile + (y * 8) + x);
// Don't replace the same color or non-targeted colors
if (cur_pixel == new_color) return;
else if (cur_pixel != target_color) return;
else *(tile + (y * 8) + x) = new_color;
// Recursively replace pixels in each direction relative to the current pixel
if (y - 1 >= 0) fill_color(tile, x, y - 1, target_color, new_color);
if (y + 1 <= 7) fill_color(tile, x, y + 1, target_color, new_color);
if (x - 1 >= 0) fill_color(tile, x - 1, y, target_color, new_color);
if (x + 1 <= 7) fill_color(tile, x + 1, y, target_color, new_color);
}
/**
* Fetches the tile at the specified tileset coordinates.
* Places the tile at the specified output data coordinates.
*
* @param in_data - Tileset data
* @param in_width - Width of the tileset
* @param in_x - X coordinate of the tile
* @param in_y - Y coordinate of the tile
* @param out_data - Output data to write to
* @param out_width - Width of the output data
* @param out_x - X coordinate to place the tile
* @param out_y - Y coordinate to place the tile
* @param bpp - The bit-per-pixel count (Default: 0)
*
* @return void - Nope, nothin'
*/
static void get_tile(unsigned char* in_data, int in_width, int in_x, int in_y, unsigned char* out_data, int out_width, int out_x, int out_y, int bpp = 1)
{
int pixel_x, pixel_y;
int i = 0;
int k = 0;
for (pixel_y = 0; pixel_y < 8; pixel_y++)
{
for (pixel_x = 0; pixel_x < 8 * bpp; pixel_x += bpp)
{
k = 0;
int base_x = (out_x * 8 * bpp) + pixel_x;
int base_y = ((out_y * 8) + pixel_y) * out_width * 8 * bpp;
int pix_idx = (in_y * in_width * 64 * bpp) + (in_x * 64 * bpp);
for (int z = 0; z < bpp; z++)
*(out_data + base_y + base_x + k++) = *(in_data + pix_idx + i++);
}
}
}
/**
* Processes compressed tile data and returns the decompressed output.
*
* @param data - Compressed tile data
* @param filesize - Size of the compressed data
*
* @return char* - A pointer to the decompressed data
*/
char* decompress_tiles(char* data, int filesize)
{
int out_filesize = 128 * ceil(filesize / 128) * 8;
char* out_data = (char*)IM_ALLOC(out_filesize);
memset(out_data, BLACK, out_filesize);
char* begin = out_data;
int i = 0;
// Loop through the entire file
while (i < out_filesize)
{
// Loop through each vertical byte pair
for (int y = 0; y < 8; y++)
{
unsigned char low_byte = data[y * 2];
unsigned char high_byte = data[(y * 2) + 1];
// Loop through each bit
for (int x = 0; x < 8; x++)
{
char bit = 7 - x;
char index = (((high_byte >> bit) & 1) << 1) | ((low_byte >> bit) & 1);
if (index == 0) out_data[i++] = WHITE;
else if (index == 1) out_data[i++] = LGREY;
else if (index == 2) out_data[i++] = DGREY;
else if (index == 3) out_data[i++] = BLACK;
}
}
data += 16;
}
out_data = begin;
return out_data;
}
/**
* Compresses raw tile data.
*
* @param data - Raw tile data
* @param filesize - Size of the raw tile data
*
* @return char* - A pointer to the compressed data
*/
char* compress_tiles(unsigned char* data, int filesize)
{
int out_filesize = filesize / 4;
char* out_data = (char*)IM_ALLOC(out_filesize);
memset(out_data, BLACK, out_filesize);
char* begin = out_data;
int i = 0;
// Loop through the entire file
while (i < out_filesize)
{
// Loop through each vertical byte pair
for (int y = 0; y < 8; y++)
{
unsigned char low_byte = 0;
unsigned char high_byte = 0;
for (int x = 0; x < 8; x++)
{
char bit = 7 - x;
unsigned char cur_pixel = ~(data[x]);
low_byte |= (cur_pixel >> 7) << bit;
high_byte |= ((cur_pixel >> 6) & 1) << bit;
}
out_data[i++] = high_byte;
out_data[i++] = low_byte;
data += 8;
}
}
out_data = begin;
return out_data;
}
/**
* Parses an assembly file or a binary file.
*
* @param filename - Full path of the file to be parsed
* @param filesize - Any int* value since it will be overwritten
*
* @return char* - A pointer to the parsed data
*/
char* parse_file(const char* filename, int* filesize)
{
unsigned int arr_pos = 0; // Current position in conversion array
long cur_byte = 0; // Temporary conversion variable
char* cur_pos; // Temporary strtol marker
bool plaintext = false; // Test for the type of file
size_t file_size = 0;
char* file_data = (char*)ImFileLoadToMemory(filename, "rb", &file_size);
if (!file_data)
return NULL;
// Set passed filesize value to 0
*filesize = 0;
// Set buffer and buffer end marker
char* buf = (char*)IM_ALLOC(file_size + 1);
char* buf_end = buf + file_size;
memcpy(buf, file_data, file_size);
buf[file_size] = 0;
// Data conversion array
char* output_data = (char*)IM_ALLOC(file_size + 1);
memset(output_data, BLACK, file_size);
char* line_end = NULL;
for (char* line = buf; line < buf_end; line = line_end + 1)
{
// Skip new lines markers, then find end of the line
while (*line == '\n' || *line == '\r')
line++;
line_end = line;
while (line_end < buf_end && *line_end != '\n' && *line_end != '\r')
line_end++;
line_end[0] = 0;
/*
Match the following data patterns:
db 001h,023h,045h
db $01,$23,$45
*/
// Skip spaces and tabs
//
// [ ]db 001h,023h,045h
//
while (line[0] == '\t' || line[0] == ' ')
line++;
// Skip line if line starts with a comment
if (line[0] == ';')
continue;
// Check if line starts with "db" and a space/tab
//
// [db ]001h,023h,045h
//
if ((line[0] == 'd' || line[0] == 'D') && (line[1] == 'b' || line[1] == 'B') && (line[2] == ' ' || line[2] == '\t'))
{
// Skip past the "db" part
line += 2;
// Loop through each byte until the end of line
while (line_end > line)
{
// Skip spaces and tabs
//
// db[ ]001h,023h,045h
//
while (line[0] == '\t' || line[0] == ' ') line++;
// Skip the '$' char if present
//
// db 001h,023h,045h
// db [$]01,$23,$45
//
if (line[0] == '$') line++;
// Get the current byte
//
// db [001]h,023h,045h
// db $[01],$23,$45
//
cur_pos = line_end;
cur_byte = strtol(line, &cur_pos, 16);
// Add it to the converted array and increase byte counter
if (line != cur_pos)
{
output_data[arr_pos++] = (unsigned char)cur_byte;
*filesize = *filesize + 1;
}
// Seek forward to next byte or end of line
while (line[0] != ',' && line[0] != '\n' && line[0] != '\r')
line++;
// Skip ',' char if present
//
// db 001h[,]023h,045h
// db $01[,]$23,$45
//
if (line[0] == ',') line++;
// this is probably a plaintext file
plaintext = true;
}
}
}
IM_FREE(buf);
// The file was probably a binary file
if (!plaintext)
{
*filesize = file_size;
IM_FREE(output_data);
return file_data;
}
// Return the processed plaintext data
else
{
IM_FREE(file_data);
return output_data;
}
}
/**
* Saves data to a file.
*
* @param data - Data to be saved
* @param filename - Full path of the file to be saved
* @param filesize - Size of the data to be written
* @param format - Format to write the data in
*
* @return void - It'll work guys, trust me
*/
static void save_file(unsigned char* data, const char* filename, int filesize, int format)
{
int i = 0;
int x = 0;
FILE* f;
if (format == FMT_BINARY)
{
f = ImFileOpen(filename, "wb");
} else {
f = ImFileOpen(filename, "w");
}
// Not sure if the compiler takes care of this, but I'll optimize the loop anyway
switch(format)
{
/*
* Intelligent Systems format:
* db 069h
*/
case FMT_INTSYS:
// Loop through all data
while (i < filesize)
{
// Define each 8-byte line
fprintf(f, "\tdb\t");
for (x = 0; x < 7; x++)
{
fprintf(f, "0%02xh,", data[i++]);
if (i == filesize) break;
}
fprintf(f, "0%02xh\n", data[i++]);
}
break;
/*
* Rednex GB Dev System format:
* db $69
*/
case FMT_REDNEX:
// Loop through all data
while (i < filesize)
{
// Define each 8-byte line
fprintf(f, "\tdb\t");
for (x = 0; x < 7; x++)
{
fprintf(f, "$%02x,", data[i++]);
if (i == filesize) break;
}
fprintf(f, "$%02x\n", data[i++]);
}
break;
/*
* Binary format:
* Literally just binary data
*/
case FMT_BINARY:
fwrite(data, 1, filesize, f);
break;
default:
break;
}
fclose(f);
}
static void glfw_error_callback(int error, const char* description)
{
fprintf(stderr, "Glfw Error %d: %s\n", error, description);
}
int main(int, char**)
{
// Setup window
glfwSetErrorCallback(glfw_error_callback);
if (!glfwInit())
return 1;
// Limit framerate
glfwWindowHint(GLFW_REFRESH_RATE, 60);
// Decide GL+GLSL versions
#if __APPLE__
// GL 3.2 + GLSL 150
const char* glsl_version = "#version 150";
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // Required on Mac
#else
// GL 3.0 + GLSL 130
const char* glsl_version = "#version 130";
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
//glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // 3.2+ only
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); // 3.0+ only
#endif
// Create window with graphics context
GLFWwindow* window = glfwCreateWindow(1280, 720, "Test Gen I/II Map Editing Program", NULL, NULL);
if (window == NULL)
return 1;
glfwMakeContextCurrent(window);
glfwSwapInterval(1); // Enable vsync
// Initialize OpenGL loader
#if defined(IMGUI_IMPL_OPENGL_LOADER_GL3W)
bool err = gl3wInit() != 0;
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLEW)
bool err = glewInit() != GLEW_OK;
#elif defined(IMGUI_IMPL_OPENGL_LOADER_GLAD)
bool err = gladLoadGL() == 0;
#else
bool err = false; // If you use IMGUI_IMPL_OPENGL_LOADER_CUSTOM, your loader is likely to requires some form of initialization.
#endif
if (err)
{
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
return 1;
}
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
// Setup Dear ImGui style
ImGui::StyleColorsDark();
// Setup Platform/Renderer bindings
ImGui_ImplGlfw_InitForOpenGL(window, true);
ImGui_ImplOpenGL3_Init(glsl_version);
/*---------------------- display data ---------------------------*/
bool show_tileset_window = false;
bool show_palette_window = false;
bool show_cell_window = false;
bool show_map_window = false;
unsigned char tile_zoom = 1;
unsigned char cell_zoom = 1;
unsigned char map_zoom = 1;
unsigned int frame_count = 0;
const ImU8 u8_one = 1;
float zoom_btn_size = 0.0f;
ImGuiButtonFlags zoom_btn_flags = ImGuiButtonFlags_Repeat | ImGuiButtonFlags_DontClosePopups;
/*---------------------- window data ----------------------------*/
ImVec2 mouse_pos;
ImVec2 win_pos;
ImVec2 cur_pos;
ImGuiStyle& style = ImGui::GetStyle();
GLint rgb_mask[] = {GL_RED, GL_RED, GL_RED, GL_ONE};
unsigned int edit_mode = TILE_EDIT;
bool auto_resize = true;
ImGuiWindowFlags window_flags = ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_HorizontalScrollbar;
/*---------------------- texture data ---------------------------*/
GLuint color_textures[4];
GLuint tile_textures[8192];
GLuint palette_textures[8192];
/*---------------------- color data -----------------------------*/
unsigned int current_color = BLACK;
unsigned char colors[] = { WHITE, LGREY, DGREY, BLACK };
// Create the initial 4 textures for the buttons
for (int i = 0; i < 4; i++)
{
glGenTextures(1, &color_textures[i]);
glBindTexture(GL_TEXTURE_2D, color_textures[i]);
// GL_NEAREST = Nearest Neighbor = disable anti-aliasing
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// Convert GL_RED mask to a greyscale image
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, rgb_mask);
// Get them pixels bruh
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, 1, 1, 0, GL_RED, GL_UNSIGNED_BYTE, colors+i);
}
/*---------------------- tileset data ---------------------------*/
bool first_tileset = true;
bool regen_tileset = true;
int tileset_width = 16;
int tileset_height = 8;
unsigned char* tileset_data;
unsigned char tiles[16][16][64];
int current_tool = TOOL_PIXEL;
/*---------------------- palette data ---------------------------*/
bool first_palette = true;
bool regen_palette = true;
bool use_palette = false;
ImVec4 pal_colors[] = {
ImVec4(COL_GREY, 1.0f),
ImVec4(COL_RED, 1.0f),
ImVec4(COL_GREEN, 1.0f),
ImVec4(COL_BLUE, 1.0f),
ImVec4(COL_YELLOW, 1.0f),
ImVec4(COL_BROWN, 1.0f),
ImVec4(COL_ROOF, 1.0f),
ImVec4(COL_MSG, 1.0f)
};
unsigned char palette_morning[] = {
// Grey
230, 255, 131,
172, 172, 172,
106, 106, 106,
57, 57, 57,
// Red
230, 255, 131,
255, 156, 197,
246, 82, 49,
57, 57, 57,
// Green
180, 255, 82,
98, 205, 8,
41, 115, 0,
57, 57, 57,
// Blue
255, 255, 255,
65, 98, 255,
8, 32, 255,
57, 57, 57,
// Yellow
230, 255, 131,
255, 255, 57,
255, 131, 8,
57, 57, 57,
// Brown
230, 255, 131,
197, 148, 57,
164, 123, 24,
57, 57, 57,
// Roof
230, 255, 131,
123, 255, 255,
41, 139, 255,
57, 57, 57,
// Msg
255, 255, 131,
255, 255, 131,
115, 74, 0,
0, 0, 0
};
unsigned char palette_day[] = {
// Grey
222, 255, 222,
172, 172, 172,
106, 106, 106,
57, 57, 57,
// Red
222, 255, 222,
255, 156, 197,
246, 82, 49,
57, 57, 57,
// Green
180, 255, 82,
98, 205, 8,
41, 115, 0,
57, 57, 57,
// Blue
255, 255, 255,
65, 98, 255,
8, 32, 255,
57, 57, 57,
// Yellow
222, 255, 222,
255, 255, 57,
255, 131, 8,
57, 57, 57,
// Brown
222, 255, 222,
197, 148, 57,
164, 123, 24,
57, 57, 57,
// Roof
222, 255, 222,
123, 255, 255,
41, 139, 255,
57, 57, 57,
// Msg
255, 255, 131,
255, 255, 131,
115, 74, 0,
0, 0, 0
};
unsigned char palette_night[] = {
// Grey
123, 115, 197,
90, 90, 156,
57, 57, 98,
0, 0, 0,
// Red
123, 115, 197,
115, 57, 139,
106, 0, 65,
0, 0, 0,
// Green
123, 115, 197,
65, 106, 156,
0, 90, 106,
0, 0, 0,
// Blue
123, 115, 197,
41, 41, 139,
24, 24, 82,
0, 0, 0,
// Yellow
246, 246, 90,
131, 115, 148,
131, 115, 82,
0, 0, 0,
// Brown
123, 115, 197,
98, 74, 123,
65, 32, 41,
0, 0, 0,
// Roof
123, 115, 197,
106, 98, 189,
90, 74, 164,
0, 0, 0,
// Msg
255, 255, 131,
255, 255, 131,
115, 74, 0,
0, 0, 0
};
unsigned char palette_dark_cave[] = {
// Grey
8, 8, 16,
0, 0, 0,
0, 0, 0,
0, 0, 0,
// Red
8, 8, 16,
0, 0, 0,
0, 0, 0,
0, 0, 0,
// Green
8, 8, 16,
0, 0, 0,
0, 0, 0,
0, 0, 0,
// Blue
8, 8, 16,
0, 0, 0,
0, 0, 0,
0, 0, 0,
// Yellow
246, 246, 90,
0, 0, 0,
0, 0, 0,
0, 0, 0,
// Brown
8, 8, 16,
0, 0, 0,
0, 0, 0,
0, 0, 0,
// Roof
8, 8, 16,
0, 0, 0,
0, 0, 0,
0, 0, 0,
// Msg
255, 255, 131,
255, 255, 131,
115, 74, 0,
0, 0, 0
};
unsigned char palette_building[] = {
// Grey
246, 230, 213,
156, 156, 156,
106, 106, 106,
57, 57, 57,
// Red
246, 230, 213,
255, 156, 197,
246, 82, 49,
57, 57, 57,
// Green
148, 197, 74,
123, 164, 8,
74, 106, 0,
57, 57, 57,
// Blue
246, 230, 213,
123, 131, 255,
74, 74, 255,
57, 57, 57,
// Yellow
246, 230, 213,
255, 255, 57,
255, 131, 8,
57, 57, 57,
// Brown
213, 197, 139,
172, 139, 57,
131, 106, 24,
57, 57, 57,
// Roof
246, 230, 213,
139, 156, 255,
115, 131, 255,
57, 57, 57,
// Msg
255, 255, 131,
255, 255, 131,
115, 74, 0,
0, 0, 0
};
unsigned char palette_water[] = {
189, 189, 255,
148, 156, 255,
106, 98, 255,
57, 57, 57,
123, 106, 222,
82, 74, 164,
32, 24, 148,
0, 0, 0
};
unsigned char palette_roof[] = {
// Unused
172, 172, 172,
90, 90, 90,
172, 172, 172,
90, 90, 90,
// Olivine City
115, 139, 255,
57, 90, 123,
74, 74, 139,
41, 57, 106,
// Mahogany Town
98, 156, 0,
49, 82, 0,
49, 74, 57,
32, 41, 49,
// Dungeon
172, 172, 172,
90, 90, 90,
172, 172, 172,
139, 65, 57,
// Ecruteak City
255, 156, 0,
222, 82, 41,
123, 57, 16,
90, 32, 16,
// Blackthorn City
90, 82, 131,
41, 49, 57,
24, 32, 65,
0, 0, 0,
// Cinnabar Island
255, 82, 0,
148, 49, 0,
148, 41, 74,
139, 65, 57,
// Cerulean City
139, 222, 255,
41, 123, 255,
57, 65, 180,
57, 57, 131,
// Azalea Town
180, 164, 82,
139, 115, 24,
90, 90, 41,
82, 74, 57,
// Lake of Rage
255, 65, 32,
74, 74, 65,
148, 41, 74,
74, 74, 65,
// Violet City
197, 115, 255,
106, 57, 172,
98, 24, 148,
74, 24, 123,
// Goldenrod City
205, 205, 0,
164, 139, 65,
98, 98, 0,
82, 74, 41,
// Vermilion City
222, 189, 8,
189, 90, 0,
123, 90, 8,
90, 82, 8,
// Pallet Town
222, 230, 255,
139, 156, 180,
115, 115, 148,
82, 74, 106,
// Pewter City
156, 156, 131,
82, 98, 123,
74, 74, 90,
32, 41, 57,
// Route 4
115, 139, 255,
57, 90, 123,
74, 106, 156,
57, 57, 131,
// Indigo Plateau
172, 172, 172,
106, 106, 106,
90, 90, 156,
57, 57, 98,