Huh, looks promising!
No, those palettes are not allocated! m90_pal1 and m90_pal2 are just pointers which by default are pointed to palette (that is, the default palette), so unless you override them to point to a different location (a 16 byte palette), you will modify the default palette (so you will see no apparent effect). I set it up this way so it is possible to use some tricks relating to how you allocate the palettes. Such as if you want to set up a game screen of different palette between a top and bottom status bar, you only point m90_pal1 elsewhere (the game screen's palette).
If you don't use all the colors, you can also devise memory saving tricks. For example if you want to split the 2bpp region in two while adding text rows on the bottom, you could point m90_pal1 to palette - 4, and use the default palette's index 8 - 11 to color the bottom half of the 2bpp region, while you use a different palette for m90_pal2 to color the text rows (if you have only 8 colors or less in your tileset, you could do this all with the default palette).
Of course just to test, first try allocating 2 palettes of 16 bytes each and point m90_pal1 and m90_pal2 to these to see how they work.
A little bit of Mode 9 insanity
-
- Posts: 73
- Joined: Tue Mar 05, 2013 7:29 pm
Re: A little bit of Mode 9 insanity
when i try to define them I get errors.
With that one, I get conflicting types for m90_pal1 and m90_pal2. Palette works as expected.
With this code, I can compile, but get the erroneous colors.
Code: Select all
extern unsigned char palette[];
extern unsigned char m90_pal1[];
extern unsigned char m90_pal2[];
Code: Select all
extern unsigned char palette[];
extern unsigned char* m90_pal1;
extern unsigned char* m90_pal2;
Re: A little bit of Mode 9 insanity
No, don't re-define them! They are simply pointers. You point them to the palette you need. So like:Or to revert how it is by default:Or if you want to be tricky and use colors 8 - 11 of the default palette for a 2bpp region:
Code: Select all
unsigned char mypalette[16];
...
m90_pal1 = &mypalette[0];
Code: Select all
m90_pal1 = &palette[0];
Code: Select all
m90_pal1 = (&palette[0]) - 4U;
-
- Posts: 73
- Joined: Tue Mar 05, 2013 7:29 pm
Re: A little bit of Mode 9 insanity
Sorry about that. I learned C++ a long time ago, actually mostly C. And only use it for fun projects like this nowadays. That fixed my issues. Thanks
Re: A little bit of Mode 9 insanity
No problem, its just plain old C. All that matters that it works at last, keep going, and use it well!
Re: A little bit of Mode 9 insanity
So... Should this go into the master repo as it is now?
https://github.com/Jubatian/uzebox/tree/mode90
A bit of reminder:
Mode 90: 4 cycles / pixels, 6 pixels / tile, arbitrary tile height, up to 16 colors using a RAM palette, 2 optional palette splits, 112 bytes / tile.
Mode 92: 4 cycles / pixels, 6 pixels / tile, 8 pixels tile height, up to 16 colors using a RAM palette, 2 optional palette splits, 112 bytes / tile, optional double or quad scanned 12 cycles / pixel 2bpp graphics mode on the upper half, configurable split.
Original Mode 9: It also has a 3 cycles / pixels submode, so Mode 90 doesn't supersede it entirely.
https://github.com/Jubatian/uzebox/tree/mode90
A bit of reminder:
Mode 90: 4 cycles / pixels, 6 pixels / tile, arbitrary tile height, up to 16 colors using a RAM palette, 2 optional palette splits, 112 bytes / tile.
Mode 92: 4 cycles / pixels, 6 pixels / tile, 8 pixels tile height, up to 16 colors using a RAM palette, 2 optional palette splits, 112 bytes / tile, optional double or quad scanned 12 cycles / pixel 2bpp graphics mode on the upper half, configurable split.
Original Mode 9: It also has a 3 cycles / pixels submode, so Mode 90 doesn't supersede it entirely.
Re: A little bit of Mode 9 insanity
Yes, please commit to the master repo. Basic usage info on the wiki would also be great, but could be done later also.
Re: A little bit of Mode 9 insanity
Added, merged, I also included the mode in the wiki, no much documentation, but hopefully enough for a start.