77#define hex (rrggbb ) rgb((0x##rrggbb)>>24,(0x##rrggbb&0xff00)>>16,(0x##rrggbb&0xff))
88
99// default palette for the standalone player
10- enum { ZX_PLAYER_PALETTE = 14 }; // vivid
10+ enum { ZX_PALETTE_PLAYER = 15 }; // vivid
11+ enum { ZX_PALETTE_EXTERNAL = 26 };
12+ enum { ZX_PALETTE_GRAY = 24 };
1113
1214// first 2-digit number configures ZX_BLOOM
1315const char * ZXPaletteNames [] = {
1416 /*#00*/ "00" "Spectral" ,
17+ "00" "?" ,
1518 /*#01*/ "00" "Modern" ,
1619 /*#02*/ "00" "Reborn" ,
1720 /*#03*/ "00" "Remix\n" ,
@@ -30,12 +33,13 @@ const char *ZXPaletteNames[] = {
3033 /*#16*/ "00" "Sintez2\n" ,
3134 /*#17*/ "40" "CPC" ,
3235 /*#18*/ "00" "EGA" ,
33- /*#19*/ "00" "Gameboy" ,
34- /*#20*/ "20" "PCW" , // best with ZX_BLOOM=20
35- /*#21*/ "90" "Amber" , // best with ZX_BLOOM=90
36- /*#22*/ "20" "Gray" , // best with ZX_BLOOM=20
37- /*#23*/ "20" "Negative\n" , // best with ZX_BLOOM=20
38- /*#24*/ "00" "External" , // must be last entry
36+ /*#19*/ "00" "MSX2" ,
37+ /*#20*/ "00" "Gameboy" ,
38+ /*#21*/ "90" "PCW" , // best with ZX_BLOOM=90
39+ /*#22*/ "90" "Amber" , // best with ZX_BLOOM=90
40+ /*#23*/ "20" "Gray" , // best with ZX_BLOOM=20
41+ /*#24*/ "20" "Negative\n" , // best with ZX_BLOOM=20
42+ /*#25*/ "00" "External" , // must be last entry
3943};
4044
4145rgba ZXPalettes [][64 ] = {
@@ -51,6 +55,15 @@ rgba ZXPalettes[][64] = {
5155 rgb (0x12 ,0x10 ,0x12 ),rgb (0x00 ,0x00 ,0xFF ),rgb (0xFF ,0x00 ,0x00 ),rgb (0xFF ,0x00 ,0xFF ),
5256 rgb (0x00 ,0xFF ,0x00 ),rgb (0x00 ,0xFF ,0xFF ),rgb (0xFF ,0xFF ,0x00 ),rgb (0xFF ,0xFF ,0xFF ),
5357 },
58+ {
59+ // "?"
60+ rgb ( 4 , 12 , 24 ),rgb ( 64 , 12 , 184 ),rgb ( 211 , 61 , 1 ),rgb ( 208 , 0 , 79 ),rgb ( 22 , 165 , 40 ),rgb ( 0 , 191 , 153 ),rgb ( 255 , 180 , 21 ),rgb ( 230 , 200 , 180 ),
61+ rgb ( 4 , 12 , 24 ),rgb ( 83 , 16 , 239 ),rgb ( 255 , 71 , 0 ),rgb ( 255 , 0 , 96 ),rgb ( 11 , 227 , 38 ),rgb ( 26 , 255 , 164 ),rgb ( 255 , 227 , 0 ),rgb ( 255 , 255 , 175 ),
62+
63+ // fantasy15, v1
64+ // rgb(0x04,0x0c,0x18),rgb(0x00,0x00,0xc0),rgb(0xc0,0x00,0x00),rgb(0x9d,0x00,0xd9),rgb(0x00,0xc0,0x00),rgb(0x00,0xc0,0xc0),rgb(0xc8,0xc8,0x00),rgb(0xc0,0xc0,0xc0),
65+ // rgb(0x04,0x0c,0x18),rgb(0x00,0x40,0xff),rgb(0xea,0x06,0x40),rgb(0xff,0x40,0xff),rgb(0x40,0xff,0x00),rgb(0x04,0xff,0xa2),rgb(0xff,0xd8,0x00),rgb(0xff,0xff,0xff),
66+ },
5467 {
5568 // modern, experiment with modern blue-ish 0, reddish 7, also yellowish 15 among other modifs
5669 //rgb( 37, 44, 56),rgb( 0, 82,149),rgb(170, 0, 30),rgb(165, 1, 96),
@@ -270,6 +283,11 @@ rgba ZXPalettes[][64] = {
270283 rgb ( 0 , 0 , 0 ),rgb ( 0 , 0 ,255 ),rgb (255 , 0 , 0 ),rgb (255 , 0 , 85 ),
271284 rgb ( 0 ,255 , 0 ),rgb ( 0 ,255 ,255 ),rgb (255 ,255 , 0 ),rgb (255 ,255 ,255 ),
272285 },
286+ {
287+ // adapted from msx2 values. v9958 3-bit: 0,40,83,116,156,187,225,255
288+ rgb ( 000 , 000 , 000 ),rgb ( 000 , 000 , 156 ),rgb ( 156 , 000 , 000 ),rgb ( 156 , 000 , 156 ),rgb ( 000 , 156 , 000 ),rgb ( 000 , 156 , 156 ),rgb ( 156 , 156 , 000 ),rgb ( 156 , 156 , 156 ),
289+ rgb ( 000 , 000 , 000 ),rgb ( 000 , 000 , 225 ),rgb ( 225 , 000 , 000 ),rgb ( 225 , 000 , 225 ),rgb ( 000 , 225 , 000 ),rgb ( 000 , 225 , 225 ),rgb ( 225 , 225 , 000 ),rgb ( 225 , 225 , 225 ),
290+ },
273291 {
274292 // gameboy. should be 4 shades, but we're doing 8 shades: many games are unplayable otherwise.
275293 rgb ( 35 - 10 , 84 - 10 , 28 - 10 ),rgb ( 35 , 84 , 28 ),rgb ( 59 - 10 ,158 - 10 , 59 - 10 ),rgb ( 59 ,158 , 59 ),rgb (124 - 10 ,186 - 10 , 49 - 10 ),rgb (124 ,186 , 49 ),rgb (174 - 10 ,255 - 10 , 38 - 10 ),rgb (174 ,255 , 38 ),
@@ -335,13 +353,14 @@ rgba ZXPalettes[][64] = {
335353 },
336354};
337355
338- void palette_use (int palette ) {
356+ void palette_use (int palette , int bloom_cfg ) {
339357#if 0
340358 memcpy (& ZXPalettes [palette ][16 ], ZXPalette + 16 , sizeof (rgba ) * (64 - 16 ) );
341359 memcpy (ZXPalette , ZXPalettes [palette ], sizeof (rgba ) * 64 );
342360#else
343361 memcpy (ZXPalette , ZXPalettes [palette ], sizeof (rgba ) * 16 );
344362#endif
363+ if (bloom_cfg ) ZX_BLOOM = atoi (ZXPaletteNames [palette ]);
345364}
346365
347366int pal_loadbin (const void * palette , int size ) {
@@ -404,7 +423,19 @@ int draw_palette(Tigr *app, unsigned* pal16, const char *name) {
404423 if ( lmb ) {
405424 if ( key_pressed (TK_SHIFT ) ) {
406425 ZXBorderColor = i ;
407- } else {
426+ }
427+ else
428+ if ( key_pressed (TK_CONTROL ) ) {
429+ static int swap = -1 ;
430+ if ( swap < 0 ) swap = index ;
431+ else {
432+ unsigned copy = pal16 [swap ];
433+ pal16 [swap ] = pal16 [index ];
434+ pal16 [index ] = copy ;
435+ swap = -1 ;
436+ }
437+ }
438+ else {
408439 byte * entry = (byte * )(& pal16 [index ]);
409440 char * hexcolor = tinyfd_colorChooser (NULL ,NULL ,entry ,entry ); // #hex = pick(title,#hex,in,out)
410441 changed = 1 ;
@@ -446,11 +477,11 @@ int draw_palette(Tigr *app, unsigned* pal16, const char *name) {
446477 ui_at (app , _320 /2 + offx /2 + 16 * 4 ,offy - theFontH + theFontH /2 );
447478 if (ui_click (NULL ,">" )) changed = 1 , ZX_PALETTE = (ZX_PALETTE + 1 ) % countof (ZXPalettes );
448479
449- if ( 0 )
450480 if ( lmb ) {
451- for (int i = 0 ; i < 16 ; ++ i ) {
452- TPixel p = (TPixel ){.rgba = pal16 [i ]};
453- printf ("rgb(%3d,%3d,%3d),%s" , p .r , p .g , p .b , !((i + 1 ) % 8 ) ? "\n" : "" );
481+ if ( name ) printf ("// %s\n" , name );
482+ for (int j = 0 ; j < 16 ; ++ j ) {
483+ TPixel p = (TPixel ){.rgba = pal16 [j ]};
484+ printf ("rgb(%4d,%4d,%4d),%s" , p .r , p .g , p .b , !((j + 1 ) % 8 ) ? "\n" : "" );
454485 }
455486 }
456487
0 commit comments