Page 2 of 2

Posted: Mon May 16, 2016 8:11 am
by dom
Take a look at the lib/config/*.cfg files - macros are defined to indicate the platform:

CPC: -DCPC -D__CPC__
MSX: -DMSX -D__MSX__
Spectrum: -DSPECTRUM -D__SPECTRUM__

etc

Posted: Mon May 16, 2016 8:14 am
by baltasarq
Again, many thanks.
If I download the z88dk code tonight, will the fixes you told me be applied?

Posted: Mon May 16, 2016 2:30 pm
by dom
You'll still need to do the #define __MSX_H__ workaround - I've not got round to sorting that one out yet. But everything else is in I think.

Posted: Mon May 16, 2016 9:33 pm
by baltasarq
I downloaded the nightly build, and now certainly the program compiles and runs.
But it is a mess. The conio.h library does not offer abstraction, for example, it does not change the number of columns by default to 70 as it does in the Speccy.
So I put a lot of #ifdef __CPC__, trying to get basic colors, such as blue background and white foreground. But there was no luck, no luck at all. Maybe the game is working, but I simply could not tell.

Maybe you can take a look and see what am I doing wrong:
https://github.com/Baltasarq/Bares

I don't know, maybe the platform is not mature enough and I should give up...

-- baltasar

Posted: Wed May 18, 2016 2:09 pm
by alvin
The cpc target does not have special code to draw characters on screen so the program is stuck with whatever the cpc firmware supplies.

On the cpc you have three display modes: mode 0 is 20x25 with 16 colours, mode 1 40x25 with 4 colours and mode 2 80x25 with 2 colours. By default the firmware puts the cpc in mode 1 with blue background as you've seen. There's no way to get more than 40 columns in that mode. If you want 80 columns you can switch to mode 2 but then you only have one text colour.

I'll have a look at this in the next day or two.

Posted: Wed May 18, 2016 6:27 pm
by baltasarq
I would not really care to have only 40 columns and a couple of colors, provided i could make it work, or visible, or whatever.

Posted: Wed May 18, 2016 6:35 pm
by dom
I've not tried it but it looks like conip is generating ansi sequences. There's an ansi library for the cpc -clib=ansi that may well make things work as expected.

Posted: Wed May 18, 2016 7:25 pm
by baltasarq
Yes, but I'm already compiling with the -clib=ansi switch, and using conio.h. That does not seem to be the problem.
The compiling I'm doing is:

zcc +cpc -O3 -SO3 -create-app -clib=ansi -lm -lndos bares.c cmds.c objs.c locs.c player.c -o bares

Posted: Thu May 19, 2016 6:53 pm
by alvin
Yes the problem will be in how the cpc's version of conio / ansi changes foreground and background colours, which will be different from other targets.

In mode 1 you have four "inks" and each ink's colour is assigned from a pallette of 16 real colours. Of those four inks, one is the background. You can't just change text background colour for a bit of text like you can on other targets because changing the background colour changes the background colour of the entire screen. So if you allowed that you would see some psychedellic flashing. Since we're using the firmware on the cpc to draw text, there is no way to draw the background of text characters in an ink other than the background colour (at least this is my understanding before I do some more reading up). For changing the foreground colour, there should be a way to choose / set three colours from the 4 inks available. How that's done from the set text foreground colour I am not sure. But you do not want to use the same ink for all text printing and then change the value of that ink's colour when a text foreground colour command is met -- that will change the ink colour of all text appearing on screen and not just the next text string printed.

Anyway, baltasarq, I had no trouble seeing the text after changing one of the ink colours from BLUE to RED. I think it was this:

void set_default_colors()
{
textbackground( WHITE );
textcolor( RED );
}

in bares.c. Of course this is not a real solution to the problem but it does allow you to at least see the text.

Posted: Thu May 19, 2016 8:01 pm
by baltasarq
Okay, I've been able to see the text and even play the game. The good news is that it works.
The bad news are that:

- The "help" command needs more space than the 50 columns the Amstrad offers. That's of course can be deal with in both platforms.
- The only colours that work are RED and YELLOW for foreground. Period. The background seems to be always BLUE, no matter what you do.
- This is a big setback: you cannot delete characters when you type your command. Strange chars appear and you have to press ENTER and start again. This does not make the game impossible to use, but it simply does not offer enough quality.

So, maybe a) the conio.h library can be made it to work for amstrad CPC (not probable), or b) I can put some instructions in that put the background in white and the text in black, for example. I would not need not much apart from this. Well, and delete should work.

Posted: Thu May 19, 2016 9:44 pm
by dom
Delete should work in tonights nightly - the CPC firmware returns 127 as the delete key code, but fgets(stdin) expects to have 12 or 8 as the delete key.

To get more columns on the CPC we'd need to write a driver for the CPC that writes directly to the display buffer or switch to a different mode (but then you lose the few colours you've got) - z88dk doesn't change the mode, so switch to mode 2 and see what it looks like in that mode.

Posted: Fri May 20, 2016 10:15 am
by baltasarq
Sorry, Dom, I don't know haw to switch amstrad to mode 2... ?could you post the code? Many thanks.

Posted: Fri May 20, 2016 5:05 pm
by alvin
baltasarq wrote:Sorry, Dom, I don't know haw to switch amstrad to mode 2... ?could you post the code? Many thanks.
I thought there might have been a function in cpc.h to do this but I don't see it.

You should be able to change to mode 2 by inlining this asm first thing in main:

Code: Select all

#asm
EXTERN firmware

ld a,2
call firmware
defw 0xbc0e
#endasm

Posted: Fri May 20, 2016 6:42 pm
by dom
Or just entering mode 2 from basic before calling the program.

Posted: Fri May 20, 2016 7:37 pm
by baltasarq
I sincerely don't want to include asm code that way, because I suspect it could change anytime.
Can you include a function to change to mode 2 (or maybe also to any other mode) in one of these next nightly builds?

Many thanks for your interest, and your efforts.

Posted: Fri May 20, 2016 9:05 pm
by dom
I've added cpc_setmode(int) to cpc.h - should be ready for you tomorrow!

Posted: Fri May 20, 2016 9:26 pm
by baltasarq
Many thanks!
So I only need to add cpc.h and call cpc_setmode( 2 )... is that it?

Kudos!

Posted: Sat May 21, 2016 8:11 pm
by baltasarq
This is fantastic. It just works. You have about 70 columns (nothing to modify in the code), and backspace works.
The only defect is this one:
void set_default_colors()
{
#ifdef __CPC__
textbackground( BLACK );
textcolor( WHITE );
#else
textbackground( WHITE );
textcolor( BLUE );
#endif
}

The only actual colors that work are BLUE and YELLOW. If I put YELLOW as foreground and BLUE as background, then it is seen as the default color set in the Amstrad. If you put the background color as YELLOW, and BLUE as foreground, then the background is still blue, and text is displayed in YELLOW background and BLUE foreground.

I see two possibilities from here: a) leave it as it is, so the adventure will have the default colors the CPC boots with. b) make WHITE and BLACK work, so I can put BLACK background with WHITE foreground, a more orthodox color combination.

Posted: Sun May 22, 2016 9:21 pm
by alvin
I'm still waffling about what to do with this. I think what will happen is we will enumerate the 16 colours in conio.h so that similar colours are close to each other in some sense. Then, eg, for mode 1 on the cpc since there are four colours, we'll divide those 16 colours in conio.h into four regions so that if you choose a colour in the same region, the colour won't actually change. Then there will be platform specific functions to assign colours to the four regions. The cpc has a separate pallette so that those four colours can be assigned from a choice of 16.

Posted: Mon May 23, 2016 7:24 am
by baltasarq
Okay, keep me posted around here, so I can test that advances in colors. Thanks for your efforts!!

Posted: Tue Jun 21, 2016 8:37 pm
by baltasarq
Any news about colors?

Posted: Wed Jun 22, 2016 3:34 pm
by alvin
I will try to find time to finish it up soon.