18
18
#include "base/utils.h"
19
19
#include "io/path.h"
20
20
#include "framebuf/colour.h"
21
+ #include "framebuf/palettes.h"
21
22
#include "framebuf/pixelfmt.h"
22
23
23
24
#include "framebuf/bmfont.h"
24
25
25
26
/* ----------------------------------------------------------------------- */
26
27
27
- /* PICO-8 palette */
28
-
29
- #define palette_BLACK (0)
30
- #define palette_DARK_BLUE (1)
31
- #define palette_DARK_PURPLE (2)
32
- #define palette_DARK_GREEN (3)
33
- #define palette_BROWN (4)
34
- #define palette_DARK_GREY (5)
35
- #define palette_LIGHT_GREY (6)
36
- #define palette_WHITE (7)
37
- #define palette_RED (8)
38
- #define palette_ORANGE (9)
39
- #define palette_YELLOW (10)
40
- #define palette_GREEN (11)
41
- #define palette_BLUE (12)
42
- #define palette_LAVENDER (13)
43
- #define palette_PINK (14)
44
- #define palette_LIGHT_PEACH (15)
45
-
46
- /* ----------------------------------------------------------------------- */
47
-
48
28
#ifdef USE_SDL
49
29
50
30
#include <SDL.h>
@@ -312,7 +292,7 @@ static result_t bmfont_clipping_test(bmfontteststate_t *state)
312
292
int fontwidth , fontheight ;
313
293
int i ;
314
294
315
- bitmap_clear (& state -> bm , state -> palette [palette_DARK_GREEN ]);
295
+ bitmap_clear (& state -> bm , state -> palette [palette_PICO8_DARK_GREEN ]);
316
296
317
297
bmfont_get_info (bmfonts [font ].bmfont , & fontwidth , & fontheight );
318
298
@@ -335,15 +315,15 @@ static result_t bmfont_clipping_test(bmfontteststate_t *state)
335
315
pos .x = centres [i ].x - stringwidth / 2 + 1 ;
336
316
pos .y = centres [i ].y - fontheight / 2 + 1 ;
337
317
338
- bg = transparent ? state -> transparent : state -> palette [palette_GREEN ];
318
+ bg = transparent ? state -> transparent : state -> palette [palette_PICO8_GREEN ];
339
319
340
320
if (transparent )
341
321
{
342
322
rc = bmfont_draw (bmfonts [font ].bmfont ,
343
323
& state -> scr ,
344
324
lorem_ipsum ,
345
325
nchars ,
346
- state -> palette [palette_BLACK ],
326
+ state -> palette [palette_PICO8_BLACK ],
347
327
bg ,
348
328
& pos ,
349
329
NULL /*endpos*/ );
@@ -358,7 +338,7 @@ static result_t bmfont_clipping_test(bmfontteststate_t *state)
358
338
& state -> scr ,
359
339
lorem_ipsum ,
360
340
nchars ,
361
- state -> palette [palette_WHITE ],
341
+ state -> palette [palette_PICO8_WHITE ],
362
342
bg ,
363
343
& pos ,
364
344
NULL /*endpos*/ );
@@ -395,7 +375,7 @@ static result_t bmfont_layout_test(bmfontteststate_t *state)
395
375
point_t origin = {0 ,0 };
396
376
char leafname [256 ];
397
377
398
- bitmap_clear (& state -> bm , state -> palette [palette_DARK_GREEN ]);
378
+ bitmap_clear (& state -> bm , state -> palette [palette_PICO8_DARK_GREEN ]);
399
379
400
380
bmfont_get_info (bmfont , & glyphwidth , & glyphheight );
401
381
@@ -443,13 +423,13 @@ static result_t bmfont_layout_test(bmfontteststate_t *state)
443
423
newline = 1 ;
444
424
}
445
425
446
- bg = transparent ? state -> transparent : state -> palette [palette_GREEN ];
426
+ bg = transparent ? state -> transparent : state -> palette [palette_PICO8_GREEN ];
447
427
448
428
rc = bmfont_draw (bmfont ,
449
429
& state -> scr ,
450
430
string ,
451
431
friendly_break ,
452
- state -> palette [palette_WHITE ],
432
+ state -> palette [palette_PICO8_WHITE ],
453
433
bg ,
454
434
& origin ,
455
435
& endpos );
@@ -579,8 +559,8 @@ static result_t bmfont_interactive_test(bmfontteststate_t *state)
579
559
quit = 1 ;
580
560
#endif
581
561
582
- colour_t fg = state -> palette [palette_DARK_BLUE ];
583
- colour_t bg = transparency ? state -> transparent : state -> palette [palette_LIGHT_PEACH ];
562
+ colour_t fg = state -> palette [palette_PICO8_DARK_BLUE ];
563
+ colour_t bg = transparency ? state -> transparent : state -> palette [palette_PICO8_LIGHT_PEACH ];
584
564
585
565
if (!dontclear )
586
566
{
@@ -698,26 +678,6 @@ static result_t bmfont_interactive_test(bmfontteststate_t *state)
698
678
return result_TEST_PASSED ;
699
679
}
700
680
701
- static void define_pico8_palette (colour_t palette [16 ])
702
- {
703
- palette [palette_BLACK ] = colour_rgb (0x00 , 0x00 , 0x00 );
704
- palette [palette_DARK_BLUE ] = colour_rgb (0x1D , 0x2B , 0x53 );
705
- palette [palette_DARK_PURPLE ] = colour_rgb (0x7E , 0x25 , 0x53 );
706
- palette [palette_DARK_GREEN ] = colour_rgb (0x00 , 0x87 , 0x51 );
707
- palette [palette_BROWN ] = colour_rgb (0xAB , 0x52 , 0x36 );
708
- palette [palette_DARK_GREY ] = colour_rgb (0x5F , 0x57 , 0x4F );
709
- palette [palette_LIGHT_GREY ] = colour_rgb (0xC2 , 0xC3 , 0xC7 );
710
- palette [palette_WHITE ] = colour_rgb (0xFF , 0xF1 , 0xE8 );
711
- palette [palette_RED ] = colour_rgb (0xFF , 0x00 , 0x4D );
712
- palette [palette_ORANGE ] = colour_rgb (0xFF , 0xA3 , 0x00 );
713
- palette [palette_YELLOW ] = colour_rgb (0xFF , 0xEC , 0x27 );
714
- palette [palette_GREEN ] = colour_rgb (0x00 , 0xE4 , 0x36 );
715
- palette [palette_BLUE ] = colour_rgb (0x29 , 0xAD , 0xFF );
716
- palette [palette_LAVENDER ] = colour_rgb (0x83 , 0x76 , 0x9C );
717
- palette [palette_PINK ] = colour_rgb (0xFF , 0x77 , 0xA8 );
718
- palette [palette_LIGHT_PEACH ] = colour_rgb (0xFF , 0xCC , 0xAA );
719
- }
720
-
721
681
result_t bmfont_test_one_format (const char * resources ,
722
682
int scr_width ,
723
683
int scr_height ,
@@ -728,7 +688,6 @@ result_t bmfont_test_one_format(const char *resources,
728
688
state .scr_width = scr_width ;
729
689
state .scr_height = scr_height ;
730
690
731
-
732
691
const int scr_rowbytes = (state .scr_width << pixelfmt_log2bpp (scr_fmt )) / 8 ;
733
692
734
693
define_pico8_palette (& state .palette [0 ]);
0 commit comments