sverx wrote:You did it??? That's amazing... I'm going to test it on the hardware as soon as possible, it doesn't work with the emulator (at least with no$gba -at least it seems to me-)
Ah yeah, emulators will probably round it down to get 15bpp again. Even NO$GBA does that for some reason.
sverx wrote:did you build 8 color with the different possible combinations of the 3 least significant bit and you 'add' (blend) it to the other image? So the 1st image is exactly the same (16/16) and the other one is what was 'lost' in the 18->15 bit transformation?
Yes, exactly!
silent_code wrote:Do you think blending is done in 24bit?
Not sure, really. Although it's fun to speculate about the hardware, I'm mainly interested in what I can see. Unfortunately it isn't possible to run an 18-bit capture, so I've just been counting greyshades! (On DSLites, the darkest levels are very distinct.)
I'm not certain but I expect it's as simple as possible: (((5bit channel<<1) * (factor 0..16)) + 8) >> 4, with the results summed and clamped. I'm fairly sure the rounding (+8) is in there, due to "centered" spacing of the gradient with low blend factors. By blending various colors at 1/16 it may be possible to test, e.g., whether the downshift occurs before or after the sum.
silent_code wrote:This is indeed a very interesting approach. You should write about it and explaint it a little bit more in depth. :^)
Thanks. :) There really isn't much to explain. Any method of showing two layers should work; all I think is required is the 1A + 1/16B blend.
In my program the normal layer is "A". It has the usual 15 bit pixels. I just used a bitmap for clarity and generality. If you have preconverted artwork, extended palettes should work--that's 4096 "18 bit" colors at half the pixel size. For dark scenes, I'm sure this would still be an improvement.
"B" is the special layer, and the only reason I got fancy is to use the compact 4bpp tilemaps. Of that, 1bpp is ignored, wasting 6K or so. The other 3bpp are the low "RGB" bits, which index 8 matching colors in BG_PALETTE.
From there the process looks like this (*3 channels, for RGB):
1) "A" supplies 5 bit data (range 0..31).
2) Hardware shifts left to get 6 bits (range is now 0..62).
3) Hardware multiplies by 16/16 so "A" is unchanged.
4) "B" supplies 5 bit values of 0 and 8.
5) Hardware shifts these left: now 0 and 16.
6) Hardware multiplies by 1/16: now 0 and 1.
7) Summing combines the two.
Another way to look at it:
- Input: A (5 bit channel), 8*B (low bit)
- Conversion: 2*A * 16/16 + 2*(8*B) * 1/16
- Output: 2*A + B (6 bits)
Btw, I observed this to give the full 64 values. RGB5(31,31,31) seems to display as RGB6(62,62,62), because it takes one more "shade" to saturate the blend.