Feature request: function to assign same colour to all colour table

The RetroNET NABU-LIB z88dk C Library for creating games and software.
Post Reply
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Feature request: function to assign same colour to all colour table

Post by productiondave »

In my game code I import a custom pattern table and then assign the same colour to all the colour table addresses in video ram.

I then use vdp_colorizePattern() to assign specific colours to specific patterns.

The method I'm using to assign the single colour is a for loop in C. I was wondering if this could be a function in NABU-LIB. It would be similar to the clear screen function which writes a 0x00 to all nameTable addresses except you could pass in a hex value to assign the fg and bg colours.

If this function was in NABU-LIB it would simplify the cross compiling work I'm doing for the z80retro. It wouldn't limit the nabu in any way. It might even make that part of the code a wee bit faster.

If you want, I can post the code for the function. Or raise a PR...

Thanks for listening...
User avatar
DJ Sures
Posts: 347
Joined: Tue Mar 28, 2023 8:36 pm
Location: nabu.ca
Contact:

Re: Feature request: function to assign same colour to all colour table

Post by DJ Sures »

i've seen your loop in your game code and thought about that before :). post it and I'll throw it in.
User avatar
productiondave
Posts: 117
Joined: Tue Mar 28, 2023 10:01 pm

Re: Feature request: function to assign same colour to all colour table

Post by productiondave »

Would something like this do the trick?

NABU-LIB.h

Code: Select all

  // **************************************************************************
  // Set the entireColorTable to be the same value.
  // 
  // **************************************************************************
  void vdp_setPatternColor(uint8_t color);
NABU-LIB.c

Code: Select all

 
  // Set all values in the color table to color.
  void vdp_setPatternColor(uint8_t color) {
    vdp_setWriteAddress(_vdpColorTableAddr);
    for (uint16_t i = 0; i < 0x1800; i++) {
      IO_VDPDATA = color;
    }
  }
it pains me to spell colour incorrectly.
Post Reply