Named Colours Test

Other misc things
Post Reply
User avatar
RobertK
Well known member
Posts: 405
Joined: Mon Feb 26, 2018 12:58 pm

Named Colours Test

Post by RobertK »

I wrote a little test program to check the colour mapping on all targets:

Code: Select all

/*
NamedColoursTest.c
Compile with
zcc +pv2000 -create-app -o nct_PV2000 NamedColoursTest.c
zcc +x1 -pragma-redirect:fputc_cons=fputc_cons_generic -create-app -o nct_X1 NamedColoursTest.c
zcc +coleco -create-app -o nct_Coleco NamedColoursTest.ccons_generic NamedColoursTest.c _font_lynx.asm -pragma-redirect:CRT_FONT=_fontLynx -o nctlynx
etc.
*/
// #pragma define CLIB_EXIT_STACK_SIZE=0

// Colour names from enum "colors" in conio.h:
static char* ColourNames[] = {"BLACK", "BLUE", "GREEN", "CYAN", "RED", "MAGENTA", "BROWN", "LIGHTGRAY", "DARKGRAY",
               "LIGHTBLUE", "LIGHTGREEN", "LIGHTCYAN", "LIGHTRED", "LIGHTMAGENTA", "YELLOW", "WHITE"};
#include <conio.h>

#if defined(__TIKI100__) || defined(__MC1000__) || defined(__PC6001__) // || defined(__VZ200__)
        #include <sys/ioctl.h>                // required for switching the screen mode
#endif

#if defined(__MC1000__) || defined(__PC6001__)
        #define SCREEN_MODE 2
#elif defined(__TIKI100__) // || defined(__VZ200__)
        #define SCREEN_MODE 3
#endif

        
void main()
{
        int i;
        
        #if defined(SCREEN_MODE)
                int mode;
                mode = SCREEN_MODE;
                console_ioctl(IOCTL_GENCON_SET_MODE, &mode);        
        #endif
        
        // Clear the screen
        printf("%c",12);
        printf("\x0c");  // the "\x0c" (0x0c character) resets the cursor position to the top left corner
        
        printf("Named Colours Test\n\n");
        
        for(i=BLACK; i<=WHITE; i++)
        {
                gotoxy(0,2+i);
                textbackground(BLACK);
                textcolor(i);
                printf("%s",ColourNames[i]);

                gotoxy(14,2+i);
                textbackground(i);
                textcolor(WHITE);
                printf("%s",ColourNames[i]);
        }        
        
        #if defined(__PV1000__) || defined(__COLECO__) || defined(__PACMAN__) || defined(__Z80TVGAME__) || defined(__GAMEBOY__) || defined(__MYVISION__)
                // On systems without keyboard, wait five seconds
                msleep(5000);
        #else
                fgetc_cons();        // wait for keypress          
        #endif
}
Compile it with this batch file, where I have hopefully included all colour-capable target. Sorry for the inconsistent output file names.

Code: Select all

setlocal
rem Set your z88dk root path here
set z88root=C:\Misc\z88dk\

set path=%PATH%;%z88root%bin\
set zcccfg=%z88root%lib\config\
set z80_ozfiles=%z88root%lib\

zcc +alphatro -create-app NamedColoursTest.c -o nct_alphatronic
zcc +aquarius -pragma-redirect:fputc_cons=fputc_cons_generic -create-app NamedColoursTest.c -o nct_aquarius
zcc +cpm -subtype=bic -pragma-redirect:fputc_cons=fputc_cons_generic -o NCTBIC.COM NamedColoursTest.c -create-app -D__BIC__
zcc +coleco -create-app -o nct_Coleco NamedColoursTest.ccons_generic NamedColoursTest.c _font_lynx.asm -pragma-redirect:CRT_FONT=_fontLynx -o nctlynx
zcc +cpc -lndos -subtype=dsk -pragma-redirect:fputc_cons=fputc_cons_generic -create-app -o nctcpc NamedColoursTest.c
zcc +cpm -subtype=einstein -pragma-redirect:fputc_cons=fputc_cons_generic -o NCTEINST.COM NamedColoursTest.c -create-app -D__EINSTEIN__
zcc +cpm -subtype=excali64 -pragma-redirect:fputc_cons=fputc_cons_generic -create-app -o nctexcali64 NamedColoursTest.c -D__EXCALIBUR64__
zcc +fp1100 -create-app -o nct_FP1100 NamedColoursTest.c
zcc +kc -lndos -pragma-redirect:fputc_cons=fputc_cons_generic -create-app NamedColoursTest.c -o nct_KC85_2-5
zcc +laser500 NamedColoursTest.c -o nctlaser500 -create-app -Cz--audio
zcc +lynx -create-app -pragma-redirect:fputc_cons=fputc_cons_generic NamedColoursTest.c -o nctlynx
zcc +mc1000 -pragma-redirect:fputc_cons=fputc_cons_generic -pragma-redirect:CRT_FONT=_font_8x8_bbc_system -create-app -Cz--audio NamedColoursTest.c -o nct_mc1000
zcc +mtx -pragma-redirect:fputc_cons=fputc_cons_generic -create-app NamedColoursTest.c -o nct_MemotechMTX500.o
zcc +cpm -subtype=microbee -pragma-redirect:fputc_cons=fputc_cons_generic -create-app -o nctmicrobee NamedColoursTest.c -D__BEE__
zcc +msx -create-app -lndos NamedColoursTest.c -o nctmsx -pragma-need=ansiterminal -pragma-define:ansifont=7359 -pragma-define:ansifont_is_packed=0 -pragma-define:ansicolumns=32 
zcc +multi8 -pragma-redirect:CRT_FONT=_font_8x8_bbc_system -create-app -o nct_multi8 NamedColoursTest.c
zcc +myvision -create-app -o nct_MyVision NamedColoursTest.c
zcc +mz -pragma-redirect:fputc_cons=fputc_cons_generic -create-app NamedColoursTest.c -o nctmz
zcc +mz2500 -create-app -o nctmz2500 NamedColoursTest.c
zcc +p2000 -clib=ansi -o nct_p2000 -create-app NamedColoursTest.c
zcc +pasopia7 -create-app NamedColoursTest.c -o nct_pasopia7
zcc +pc6001 -subtype=rom -create-app -o nct_pc6001Mk2 NamedColoursTest.c
zcc +pc88 -pragma-redirect:fputc_cons=fputc_cons_generic -create-app -Cz--audio -o nct_pc8001 NamedColoursTest.c
zcc +pencil2 -create-app -o nct_Pencil2 NamedColoursTest.c
zcc +pv1000 -o nct_pv1000 -create-app NamedColoursTest.c 
zcc +pv2000 -create-app -o nct_PV2000 NamedColoursTest.c
zcc +rx78 -o nct_rx78 -create-app NamedColoursTest.c 
zcc +sam -clib=ansi -o nct_SamCoupe.bin NamedColoursTest.c
zcc +sc3000 -subtype=rom -create-app -o nct_sc3000.sc NamedColoursTest.c
zcc +cpm -subtype=smc777 -pragma-redirect:fputc_cons=fputc_cons_generic -o NCTSMC.COM NamedColoursTest.c -create-app -D__SMC777__
zcc +m5 -create-app -o nct_sordm5 NamedColoursTest.c
zcc +spc1000 -create-app -o nctspc1000 NamedColoursTest.c
zcc +super80 -create-app -o nct_super80v NamedColoursTest.c
zcc +super80 -create-app -clib=vduem -o nct_super80m NamedColoursTest.c -D__SUPER80_VDUEM__
zcc +svi -pragma-redirect:fputc_cons=fputc_cons_generic -create-app -o nctsvi NamedColoursTest.c
zcc +cpm -subtype=tiki100 -ltiki100 -create-app -pragma-redirect:fputc_cons=fputc_cons_generic -o NCTTIKI.COM NamedColoursTest.c
zcc +vg5k -pragma-redirect:fputc_cons=fputc_cons_generic -o nct_vg5000 -create-app NamedColoursTest.c
zcc +vz -pragma-redirect:fputc_cons=fputc_cons_generic -o nct_vz200.vz -create-app NamedColoursTest.c
zcc +z9001 -pragma-redirect:fputc_cons=fputc_cons_generic -o nct_z9001 -create-app NamedColoursTest.c
zcc +zx -lndos -create-app -o nct_ZXSpectrum NamedColoursTest.c
zcc +x1 -pragma-redirect:fputc_cons=fputc_cons_generic -create-app -o nct_X1 NamedColoursTest.c

rem pause
And here are my test results:

=== All ok ===
Alphatronic
BIC
fp1100
KC85 2-5
Lynx
microbee
sam
tiki100 (screen mode 3)
Z9001
ZX Spectrum

=== These systems do not support paper colour? Text colours are ok ===
multi8
MZ2500
smc777
VG5000
X1 (although listed as implemented on the platform page)

=== Mostly correct Mapping ===
Coleco, PV2000, SC3000, m5, pencil2, myvision, einstein, msx (and probably all other TMS9918 systems): red and brown should be swapped IMHO
RX78: "Lightblue" is red
Pasopia 7: textcolor() sets paper colour, and textbackground has no effect. Green and red are swapped, and so are lightgreen and lightred.
Sharp MZ700: Green and red are swapped, and so are lightgreen and lightred.
Laser500: brown and yellow should be swapped

=== Mostly wrong Mapping ===
Aquarius: many colours are mapped incorrectly
cpc: most colours have wrong mapping
excali64: paper colours are ok, but text colours are partially wrong

=== Partial Colour Support ===
SPC-1000 (only green and brown)
mc1000 (only blue, yellow, red and green in screen mode 1)
pc6001 (only blue, yellow, red and green in screen mode 2)

=== No Colour support (no effect at least in default screen mode, colour names are defined) ===
PV1000
p2000
VZ
pc88

=== Untested due to technical problems ===
mtx (screen shows nothing in the Memu emulator)
svi (both MAME and BlueMSX show only a broken screen) - see TMS9918 systems above, probably same result
super80 (m and v models)
User avatar
dom
Well known member
Posts: 2257
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

Oh wow, thank you so much for doing this. Mapping these colours for some machines has been a total pain for me: The ones with RGB3 are easy (bar the typos) but any extra colours and I'm usually guessing.

The mapping is handled by a assembler function conio_map_colour which is called from generic_console_set_ink and generic_console_set_paper. As a result there should be a conio_map_colour function for each target, I know some of them are missing and I think you may have found them!

Aquarius, Pasopia7: These are missing conio_map_colour
CPC: This has a mapping table which I think is correct. It then gets mapped into bit patterns for the various screen modes which is probably where it goes wrong.
Excalibur64: I've got a memory of something really funky with the colour handling on that machine: I've defined two different colour schemes and I've possibly picked the wrong one for the emulator you're running.
Laser500: I'm not sure there is a brown on that machine? I think bright yellow was a left over colour so it ended up there. I'll swap them though.
RX78: That's a typo, consider it fixed.

MC6847 machines: (pc6001, spc1000 etc) - the palette is challenging on these to say the least. The mapping is defined in video/mc6847/colour_map.asm and is best read in conjunction with the data sheet. I have a feeling it works best on the pc6001mk2 though.

TMS9918 machines, I'll take your advice and swap them.

VZ: I think this only has colour for the lores graphics.
User avatar
RobertK
Well known member
Posts: 405
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

Thanks, it's getting better now!

RX78: fixed.

Pasopia 7: fixed. I assume the system does not support paper colour, I haven't tried console_ioctl(IOCTL_GENCON_GET_CAPS, &caps) yet.

TMS9918: much better now. The system's red is not the most beautiful, but I think we are closer to red and brown like that.

Image

Laser 500: much better now, for brown we now have the "muddy" dark-yellow of that machine, while yellow is a clear yellow now.

Aquarius: beautiful, but I think you should change "Lightred" to red instead of yellow.

CPC: still to be done.

Excalibur64: still to be done, text colours beginning from "Darkgray" are wrong (including the important yellow).

Image

MC6847: ok, the available colours are very limited, but the available ones (blue, red, yellow, green) are correctly mapped. I haven't updated my test program to the 4x6-characters for the VZ graphics mode, but as far as I could see from the broken characters, it seems to be working.

Just tell me if there are any more colour-targets that I haven't tested yet.

P.S. I had an unwanted pasted text in my batch file above, the Coleco line should be like this:
zcc +coleco -create-app -o nct_Coleco NamedColoursTest.c
User avatar
dom
Well known member
Posts: 2257
Joined: Sun Jul 15, 2007 10:01 pm

Post by dom »

I've started to look at remapping the Excalibur palette - it looks like I forgot how to count when remapping some of the colours.

The system colours are (I think):

Code: Select all

 0 -> r=00 g=00 b=00 000000     - black
 1 -> r=ff g=00 b=00 ff0000     - red
 2 -> r=00 g=00 b=ff 0000ff     - blue
 3 -> r=ff g=00 b=ff ff00ff     - magenta
 4 -> r=00 g=ff b=00 00ff00     - green
 5 -> r=ff g=ff b=00 ffff00     - yellow
 6 -> r=00 g=ff b=ff 00ffff     - cyan
 7 -> r=ff g=ff b=ff ffffffa    - white
 8 -> r=d9 g=00 b=00 d90000     - free speech red
 9 -> r=ff g=55 b=26 ff5526     - orange
 a -> r=ff g=00 b=26 ff0026     - torch red
 b -> r=d9 g=55 b=00 d95500     - tawny (red/orange)
 c -> r=26 g=00 b=26 260026     - purple
 d -> r=49 g=ff b=49 49ff49     - pale green
 e -> r=ff g=00 b=90 ff0090     - pink/cerise
 f -> r=26 g=55 b=26 265526     - green
You can see them by compiling with -pragma-define:CLIB_CONIO_NATIVE_COLOUR=1 and iterating over the numbers - or just run your Stroop test :)

I'm currently rewriting the mapping to:

Code: Select all

        defb    $0      ;BLACK -> BLACK
        defb    $2      ;BLUE -> BLUE
        defb    $4      ;GREEN -> GREEN
        defb    $6      ;CYAN -> CYAN
        defb    $1      ;RED -> RED
        defb    $3      ;MAGENTA -> MAGENTA
        defb    $b      ;BROWN -> TAWNY (RED/ORANGE)
        defb    $       ;LIGHTGRAY ->
        defb    $       ;DARKGRAY ->
        defb    $       ;LIGHTBLUE ->
        defb    $d      ;LIGHTGREEN -> PALE GREEN
        defb    $       ;LIGHTCYAN ->
        defb    $e      ;LIGHTRED -> PINK
        defb    $c      ;LIGHTMAGENTA -> PURPLE
        defb    $5      ;YELLOW -> YELLOW
        defb    $7      ;WHITE -> WHITE
The first 6 and last 2 are obvious, but the ones in the middle and the missing ones I'm not too certain what to do - can you help?
User avatar
RobertK
Well known member
Posts: 405
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

You could ask three people and you will get four different answers! ;-)

First an overview of the available colours, 12 - "[dark] purple" (38,0,38) and 15 - "[dark] green" (38,85,38) can hardly be seen on a black background:

Image

Here are my proposals for the colours in the middle:

defb $b ;BROWN -> TAWNY (RED/ORANGE) - ok
defb $ ;LIGHTGRAY -> 15 (a very dark green)
defb $ ;DARKGRAY -> 12 (a very, very dark purple)
defb $ ;LIGHTBLUE -> 2 (blue)
defb $d ;LIGHTGREEN -> PALE GREEN - ok
defb $ ;LIGHTCYAN -> 6 (cyan)
defb $e ;LIGHTRED -> 9 (orange)
defb $c ;LIGHTMAGENTA -> 14 (pink/cerise)

Alternatively, you could change RED to 8 - Free Speech Red (217,0,0) and LIGHTRED to 1 - Red (255,0,0), but I would prefer having the "full red" mapped to RED on systems that do not have the full light & standard colour range.

P.S. The background colours 8 to 15 are currently wrong in this test. Since no mapping is involved here, I expected FG and BG colours to be the same?

P.P.S. Back to the "Named Colours Test": on the Sharp X1, the colours are correctly mapped when using ANSI, but wrong on the Generic Console:
zcc +x1 -clib=ansi -create-app -o nct_X1_ANSI NamedColoursTest.c
zcc +x1 -pragma-redirect:fputc_cons=fputc_cons_generic -create-app -o nct_X1 NamedColoursTest.c

Code: Select all

/*
ExcaliburColoursTest.c
Compile with
zcc +cpm -subtype=excali64 -pragma-redirect:fputc_cons=fputc_cons_generic -pragma-define:CLIB_CONIO_NATIVE_COLOUR=1 -create-app -o exct ExcaliburColoursTest.c -D__EXCALIBUR64__
*/
// #pragma define CLIB_EXIT_STACK_SIZE=0

// Colour names from enum "colors" in conio.h:
static char* ColourNames[] = {"black", "red", "blue", "magenta", "green", "yellow", "cyan", "white", 
                        "free speech red", "orange", "torch red", 
                        "tawny (red/orange)", "purple", "pale green", "pink/cerise", "green"};
#include <conio.h>

// uncomment these two lines to use 40x25 mode
/*
#include <sys/ioctl.h>                // required for switching the screen mode
#define SCREEN_MODE 1                // 40x25
*/

void main()
{
        int i;
        #if defined(SCREEN_MODE)
                int mode;
                mode = SCREEN_MODE;
                console_ioctl(IOCTL_GENCON_SET_MODE, &mode);        
        #endif

        // Clear the screen
        printf("%c",12);
        printf("\x0c");  // the "\x0c" (0x0c character) resets the cursor position to the top left corner
        
        printf("Excalibur Colours Test\n\n");
        
        for(i=0; i<=15; i++)
        {

                gotoxy(0,2+i);
                textbackground(0);        // black
                textcolor(7);                // white
                printf("%d",i);

                gotoxy(3,2+i);
                textbackground(0);        // black
                textcolor(i);
                printf("%s",ColourNames[i]);

                gotoxy(22,2+i);
                textbackground(i);
                textcolor(7);                // white
                printf("%s",ColourNames[i]);
        }
        
        fgetc_cons();        // wait for keypress          
}
User avatar
RobertK
Well known member
Posts: 405
Joined: Mon Feb 26, 2018 12:58 pm

Post by RobertK »

I have found one more target with mostly wrong mapping: the Colour Genie EG2000.

zcc +trs80 -lndos -create-app -subtype=eg2000disk -o nct_eg2000.bin NamedColoursTest.c

And please don't forget the above mentioned MZ-700 which should be hopefully easy to fix.
User avatar
RobertK
Well known member
Posts: 405
Joined: Mon Feb 26, 2018 12:58 pm

Re:

Post by RobertK »

RobertK wrote: Sun Jan 19, 2020 4:02 pm I have found one more target with mostly wrong mapping: the Colour Genie EG2000.
The EG2000 is still waiting to be fixed...
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 2257
Joined: Sun Jul 15, 2007 10:01 pm

Re: Named Colours Test

Post by dom »

Oh, this is going to be fun....

Take a look here: https://git.m4xw.net/libretro/cores/mam ... e.cpp#L387

So there's different palettes for different regions (round of applause?). Our mapping is based on the EU palette: https://github.com/z88dk/z88dk/blob/mas ... ur.asm#L28

So I wonder if your emulator is configured to use a different palette?
User avatar
RobertK
Well known member
Posts: 405
Joined: Mon Feb 26, 2018 12:58 pm

Re: Named Colours Test

Post by RobertK »

I'm using the Genieous emulator, and indeed: there's a palette setting! The palettes are called "Southern" and "Northern" there, I first thought that southern would be Australia and Northern Japan, but then Northern seems to be PAL = most of Europe.
The MAME source confuses me, the "Southern" palette stands for New Zealand, although to my knowledge NZ had always been using PAL?

Anyway, an option for choosing the desired palette would be nice to have...

I have made a quick Excel hack for visualizing the uncommented NZ colours, and I've tried to give them names. I'm not quite sure about the two cyan colours, they look very similar to me.
You do not have the required permissions to view the files attached to this post.
User avatar
dom
Well known member
Posts: 2257
Joined: Sun Jul 15, 2007 10:01 pm

Re: Named Colours Test

Post by dom »

I've added eg2000_switch_palette_mode(int) to <arch/trs80/eg2000.h> to switch at runtime between the palettes.

I think it might be UHF/VHF modulator differences, but regardless it's weird.
User avatar
RobertK
Well known member
Posts: 405
Joined: Mon Feb 26, 2018 12:58 pm

Re: Named Colours Test

Post by RobertK »

Excellent, thank you! That will help us marketing our software worldwide! ;-)

Please check "Lightred" in the Southern Palette, the rest is fine.

EG2000_SouthernPalette.jpg
You do not have the required permissions to view the files attached to this post.
Post Reply