Hi everyone!
I have managed to get the CPC version of my little "universal" 8-bit game CROSS CHASE to work decently
(still no sound and no fancy graphics)
https://github.com/Fabrizio-Caruso/CROSS-CHASE/releases/tag/MERGED (https://github.com/Fabrizio-Caruso/CROSS-CHASE/releases/tag/MERGED)
I am using mode 1 (four color 320x200) and coding in C with Z88DK and CPCRSLIB.
I have not been able to figure out how to use colors other than the standard four blue, cyan, red and yellow.
I would like to use a different set of four colors.
Should I use cpc_SetColour? How?
I could not find any manual? I am only guessing from the examples but I have not been able to choose the colors.
Fabrizio
This is what I found on this archive site (http://archive.is/599Wa#selection-12327.0-12685.39):
Quote
Screen
Mode Selection
cpc_SetMode(mode) //Hardware routine. It requires disabling the Standard jump of the interruption.
cpc_SetModo(mode) // firmware routine
Ink change:
cpc_SetColour(ink number, hardware colour) //Hardware routine. It requires disabling the Standard jump of the interruption.
//firmware:
cpc_SetBorder(colour)
cpc_SetInk(ink number, colour)
cpc_GetScrAddress(x,y) //returns the x,y coordinates screen address. For example: cpc_ScrAdress(0,0) -> &C000
//Rotation routines
cpc_RLI(screen rectangle origin, width, height)
cpc_RRI(screen rectangle origin, width, height)
So what you need is cpc_SetInk "ink number" can be anything from 0-3 in mode 1 followed by any of the 27 colours (0-26). That is the same as an INK command in BASIC, which uses Firmware. Though if you're program isn't using Firmware cpc_SetColour() I suspect is getting it direct from the Hardware. In that situation the Colours are ordered differently and can range between 0 & 32.
Thanks!
I do not understand what the purpose of disabling the Firmware routines is. What is the advantage?
I am currently keeping the firmware active because my game is also doing other stuff which is implemented with firmware (conio.h in Z88DK) but I
may get of any firmware dependency if it is a good thing.
Fabrizio
Quote from: Fabrizio on 10:12, 03 October 17
Thanks!
I do not understand what the purpose of disabling the Firmware routines is. What is the advantage?
I am currently keeping the firmware active because my game is also doing other stuff which is implemented with firmware (conio.h in Z88DK) but I
may get of any firmware dependency if it is a good thing.
Fabrizio
The firmware takes up a little bit of memory in RAM, which to some maybe an useful area to have their own specific routines for their particular game, I guess this is more apparent when something like C language is used since it may incorporate many well written routines. The firmware is old and while there are some useful routines, others are very slow. Other advantages I think I read the firmware uses some of the Alternate Register Set, so disable the firmware, Alternate Registers can be used. I try not to do that on advice from an Assembly book, though that Assembly book has many examples which use Firmware. I guess you just have to think of it as the original Library circa 1984/5 and while part of it maybe in RAM, the routines are written on ROM, so nobody (I don't think), has tried to reprogram for improvement type project.
If I use
cpc_SetModo(1);
cpc_SetInk(0,4);
cpc_SetInk(1,5);
cpc_SetInk(2,6);
cpc_SetInk(3,7);
I get a blue screen and nothing happens (frozen?)
I wonder whether cpcrslib is buggy...
Is there some other way to select colors in mode 1? Do I need to use assembly?
I am using Firmware (I have done nothing to disable it) and only cpc_setMode(1) does not produce a crash/freeze...
You shouldn't have to use Assembly, that would defeat the purpose of CPCRSLIB. I can only presume that if cpc_setMode(1) works and that's meant to be hardware based perhaps it's being reworked? So maybe cpc_SetColour() will work perhaps?
cpc_setMode(1) does not break anything but it probably has no effect. Z88DK starts in mode 1 by default.
cpc_setColour has no effect, either
So I need to find a way to set colors... Is is really complicated?
Just a guess.
If interrupts (and firmware) is still enabled, it would probably overwrite your gate array changes (mode and colour settings) each frame.
To test you could try something like:
__asm__("di");
cpc_SetModo(1);
cpc_SetInk(0,4);
cpc_SetInk(1,5);
cpc_SetInk(2,6);
cpc_SetInk(3,7);
while(1);
And see if that works.
#asm
di
#endasm
cpc_SetModo(1);
cpc_SetInk(0,4);
cpc_SetInk(1,5);
cpc_SetInk(2,6);
cpc_SetInk(3,7);
while(1);
will do nothing other than freezing my game with a blue (standard color) screen.
I remember when i used CPCRSLIB, i have to rebuild the lib (it was the cpcrslib for SDCC), the provided lib was crashing my program.
In the directory cpcrslib_z88dk\cpcrslib, i think you have to launch make.bat, it will recompile all sources into a new library.
Of course. I am rebuilding the lib because otherwise it would not even compile.
Remark: I am using the Z88DK version, which maybe partially broken.
Did you have any luck with the inline asm using the firmware scr_set_ink call?
As I wrote, it freezes the game with a blue screen (same blue as the standard blue I want to get rid of).
Fabrizio
Quote from: Fabrizio on 12:24, 04 October 17
As I wrote, it freezes the game with a blue screen (same blue as the standard blue I want to get rid of).
Fabrizio
Unfortunately I don't have the answers you're after, though I know @arnoldemu (http://www.cpcwiki.eu/forum/index.php?action=profile;u=122) used Z88DK with CPCRSLIB to code Blue Angel 69 otherwise @Alcoholics Anonymous (http://www.cpcwiki.eu/forum/index.php?action=profile;u=1116) is probably the person you need to contact.
I have a library to set the colours using the firmware. I will find the code and post it here.