A little bit of Mode 9 insanity

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: A little bit of Mode 9 insanity

Post by Jubatian »

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.
yllawwally
Posts: 73
Joined: Tue Mar 05, 2013 7:29 pm

Re: A little bit of Mode 9 insanity

Post by yllawwally »

when i try to define them I get errors.

Code: Select all

	extern unsigned char palette[];
	extern unsigned char m90_pal1[];
	extern unsigned char m90_pal2[];
With that one, I get conflicting types for m90_pal1 and m90_pal2. Palette works as expected.

Code: Select all

	extern unsigned char palette[];
	extern unsigned char* m90_pal1;
	extern unsigned char* m90_pal2;
With this code, I can compile, but get the erroneous colors.
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: A little bit of Mode 9 insanity

Post by Jubatian »

No, don't re-define them! They are simply pointers. You point them to the palette you need. So like:

Code: Select all

unsigned char mypalette[16];
...
m90_pal1 = &mypalette[0];
Or to revert how it is by default:

Code: Select all

m90_pal1 = &palette[0];
Or if you want to be tricky and use colors 8 - 11 of the default palette for a 2bpp region:

Code: Select all

m90_pal1 = (&palette[0]) - 4U;
yllawwally
Posts: 73
Joined: Tue Mar 05, 2013 7:29 pm

Re: A little bit of Mode 9 insanity

Post by yllawwally »

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
uzem_000.jpg
uzem_000.jpg (39.4 KiB) Viewed 6461 times
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: A little bit of Mode 9 insanity

Post by Jubatian »

No problem, its just plain old C. All that matters that it works at last, keep going, and use it well! ;)
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: A little bit of Mode 9 insanity

Post by Jubatian »

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.
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: A little bit of Mode 9 insanity

Post by uze6666 »

Yes, please commit to the master repo. Basic usage info on the wiki would also be great, but could be done later also.
User avatar
Jubatian
Posts: 1561
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: A little bit of Mode 9 insanity

Post by Jubatian »

Added, merged, I also included the mode in the wiki, no much documentation, but hopefully enough for a start.
Post Reply