Page 1 of 1

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

Posted: Mon Apr 03, 2023 7:52 am
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...

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

Posted: Mon Apr 03, 2023 4:56 pm
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.

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

Posted: Tue Apr 04, 2023 3:15 am
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.