News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu

[cpctelera]cpct_px2byte & cpct_clearScreen

Started by Trewdbal, 21:23, 26 January 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Trewdbal

Hi Folks !

I try to fill up the screen with a colour other than black.

My attemps like :

    cpct_clearScreen_f64 (cpct_px2byteM0(9,9));


give screens with patterns.

Moreover, what about filling the screen with a colour in mode 2 ?

Anyway, i'm a bit confused with the arguments of px2byteM0 or px2byteM1. At the beginning of the code, I applied a palette using :

    cpct_fw2hw(palette, 16);
    cpct_setPalette(palette, 16);

After that, does the arguments of cpct_px2byte are the indice of the palette array ? Or directly a color code ?

Thank you for you assistance.

ronaldo

Quote from: Trewdbal on 21:23, 26 January 16
Hi Folks !

I try to fill up the screen with a colour other than black.

My attemps like :

    cpct_clearScreen_f64 (cpct_px2byteM0(9,9));


give screens with patterns.

Moreover, what about filling the screen with a colour in mode 2 ?

Anyway, i'm a bit confused with the arguments of px2byteM0 or px2byteM1. At the beginning of the code, I applied a palette using :

    cpct_fw2hw(palette, 16);
    cpct_setPalette(palette, 16);

After that, does the arguments of cpct_px2byte are the indice of the palette array ? Or directly a color code ?

Thank you for you assistance.

I'll try to answer to all your doubts:

       
  • The arguments of cpct_px2byteM0 function are palette indexes. Documentation says they are firmware colour values, but that is confusing, it should be changed.
  • If you wanted to fill a mode 2 screen, you won't need a px2byte function, as colours in mode 2 are 0 or 1 bit by bit. You could do it directly use something like this: cpct_clearScreen(0b01011010); to fill up the screen with a repeating pattern.
  • Your problem is not due to cpct_px2byteM0 function. Your problem is related to the way you use cpct_clearScreen_f64. This function requires 2 bytes as input, not 1 byte. It uses a 16-bit pattern to fill up the screen. So, if you only input the result of cpct_px2byteM0(9,9), you are giving the value 0x00C3 instead of 0xC3C3 that you should have given to it, if you wanted the same colour on all the pixels. You can solve it this way: u16 pattern = cpct_px2byteM0(9,9); pattern = (pattern << 8) + pattern; cpct_clearScreen(pattern);
Hope this helps. With this doubts, it will be very helpful if you read the documentation paying attention to details, in order to help me know which parts of it are difficult to understand. That will help many people solving your same doubts :).

Trewdbal

Thank you for your speedy assistance. Things are more clear now.

Indeed, the "firmware" value in the doc of cpct_px2byteM0 and cpct_px2byteM1 are confusing at the beginning.

On the cpct_cleanScreen page, maybe an 1-line example showing a call to the function would be helpful (short examples would be helpful on the other pages too, but I understand that's a lot of work...). Moreover, in the src examples provided with CPCTelera, cpct_clearScreen is always used with "0" as argument.

While talking about the doc : on the cpct_memset page, the input parameters are not listed in the right order : it should be array, value, size (instead of array, size, value), to respect the order of the arguments of the function, as well as the convention you applied on the other pages. It's a detail, but I've been tricked while reading the doc too quickly !

ronaldo

@Trewdbal: You're welcome :).

Thank you very much for suggestions to improve documentation. I'm taking notes of all of them to make improvements :).

Another thing you may do, if you have enough time and want to, is directly making modifications to the documentation and sending pull requests. You may do it on github, either by forking the project and sending propper pull requests or by creating them using github's editor. Documentation for function is in code files and gets extracted from them. For instance, if you wanted to modify cpct_memset documentation, you could do it by editing this file: cpct_memset.asm

Thank you very much for collaboration :D.

Powered by SMFPacks Menu Editor Mod