Colorscrolling - By tikkel

Author :  tikkel

Hello!

I wanted to ask if the META also has hardware special effects.
For example, like game consoles, hardwarescrolling, colorscrolling and various graphics modes.

Especially a colorscrolling would interest me.

Greeting from me

Author :  Martisse

I dont think so. But you can add Arduino components with the backpack. Like LED...

The gamebuino has also led . Go to tutorial section to learn it. Go hereTutorial of led

Author :  Alban

It's just a plain Cortex-M0+ architecture, so no gaming-dedicated hardware, but enough horspower to emulate all these effects to a certain extent.

Some games have already implemented rotations, zooms, palette cycling etc.

Author :  jicehel

Some car races for example  ;) You definitively have to make some simple tuto if you can Alban... It's could be useful...

Author :  Alban

I know, but my code is so ugly I would have to rewrite from scratch to have something worth presenting. It was my first gamebuino project, grew organically, and I got so fed up with the Arduino IDE that I ended up writing code as it came.

My next project, if I manage to complete it, is designed a much better way, and in much better conditions ;-) I plan to document it more seriously.

Author :  jicehel

Maybe you could some very short program to illustrate the technics used (and complement the already existing tuto) Your tutos / examples could be agregated later to do a workshop on doing a race car from scratch. (And then your code could be reorganised in the tuto to have a more academic code) but it's another subject. I just bouncing on this subject as tikkel was talking about one of the technics used


Author :  Steph

Try this!

#include <Gamebuino-Meta.h>

const uint8_t GRADIENT[] = {
16, // frame width
2, // frame height
1, // number of frames
0, // ?.. don’t understand this value
0, // animation speed (0 means no animation)
0x10, // transparent color (any value greater than 0xf is transparent)
1, // indexed color mode
// colormap (2 pixels per byte)
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
0xfe, 0xdc, 0xba, 0x98, 0x76, 0x54, 0x32, 0x10
};

// must have 16 colors
const Color REFERENCE_PALETTE[] = {
(Color)0x47e9, (Color)0x37e6, (Color)0x1fe4, (Color)0x0fe1,
(Color)0x07a0, (Color)0x0700, (Color)0x0661, (Color)0x05c1,
(Color)0x0501, (Color)0x0461, (Color)0x03c1, (Color)0x0320,
(Color)0x0280, (Color)0x01e0, (Color)0x0140, (Color)0x00a0
};

const Image IMAGE(GRADIENT);

Color palette[16];

void setup() {
gb.begin();
}

void loop() {
while (!gb.update());

<span class="hljs-comment">// rotating palette</span>
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">uint8_t</span> i=<span class="hljs-number">0</span>; i&lt;<span class="hljs-number">16</span>; i++) {
    palette[i] = REFERENCE_PALETTE[(gb.frameCount+i)%<span class="hljs-number">16</span>];
}

<span class="hljs-comment">// draw image with new palette</span>
gb.display.setPalette(palette);
gb.display.drawImage(<span class="hljs-number">32</span>, <span class="hljs-number">32</span>, IMAGE);

}



Only works with indexed images... If you want the same effect in full RGB565, you'll have to write the bits in the right place by yourself!

Author :  jicehel

It's one of the technics for simulate quick races movements. It's can been used to make water, lava, lead, grass moving with good use of colors.

Author :  tikkel

OK,

so I have to paint all the effects.
Unfortunately, it is not possible to manipulate the color palette or image memory address directly on the graphics controller registers.

I was hoping to save some CPU time.

Thank you for the tips and the example.

Author :  Alban

Indeed, there's just no graphics controller :-)

Author :  Martisse

What is a graphics controller?

Author :  jicehel

you can manipulate the color of the palette if you use indexed colors

Author :  Alban

A specialized chip with its own memory for graphics rendering, and sometimes facilities for effects (e.g. the famous SNES mode 7)

Author :  Sorunome

The screen controller actually has some hardware effects, such as color inversion. No scrolling, though.

For example. gb.setRotation() also uses screen hardware to rotate the contents

Author :  tikkel

... so I can change a color of the palette afterwards and this change would be visible immediately?

Author :  Steph

Yes, you don't need to redraw the image :-)

Author :  tikkel

Please, what is the default color palette in C++ syntax?

const Color PALETTE[] = {
  (Color)0xffff, // color 0x0 ... ?
Author :  Steph

Image Transcoder gives you the details when you select the indexed mode....

const Color PALETTE[] = {
    (Color)0xffff, // color 0x0
    (Color)0xacd0, // color 0x1
    (Color)0x5268, // color 0x2
    (Color)0x0000, // color 0x3
    (Color)0x9008, // color 0x4
    (Color)0xca30, // color 0x5
    (Color)0xd8e4, // color 0x6
    (Color)0xfd42, // color 0x7
    (Color)0xcc68, // color 0x8
    (Color)0xfeb2, // color 0x9
    (Color)0xf720, // color 0xa
    (Color)0x8668, // color 0xb
    (Color)0x044a, // color 0xc
    (Color)0x0210, // color 0xd
    (Color)0x4439, // color 0xe
    (Color)0x7ddf  // color 0xf
};
Author :  tikkel

Sure? If i use this, all colors are changed. Not the same as without setPalette ...

(I use  DISPLAY_MODE_INDEX_HALFRES)

Author :  Steph

https://gamebuino.com/creations/color-palettes