AmigaPorts / ACE

Amiga C Engine
Mozilla Public License 2.0
155 stars 26 forks source link

Wong palette when GLOBAL CLUT is used with 2 vports with different BBP #94

Open Ozzyboshi opened 5 years ago

Ozzyboshi commented 5 years ago

The issue occurs when I create a new View with TAG_VIEW_GLOBAL_CLUT equal 1. If you declare 2 different vPorts and the second vPort has more BPP than the first, the exceeding colors set in the palette are ignored.

For example

// New view
s_pViewRealPlay = viewCreate(0,TAG_VIEW_GLOBAL_CLUT, 1,TAG_END);

// First vPort with BPP = 2 ( only 4 colors)
s_pVpScoreRealPlay = vPortCreate(0,TAG_VPORT_VIEW, s_pViewRealPlay,TAG_VPORT_BPP, 2,TAG_VPORT_HEIGHT, 32,TAG_END);

// Second vPort with BPP = 4 (16 colors)
  s_pVpMainRealPlay = vPortCreate(0,TAG_VPORT_VIEW, s_pViewRealPlay,TAG_VPORT_BPP, 4,TAG_END);

// Now, according to the DOCS, the following palette should be shared between the 2 VPorts

// The first 4 palette colors are OK
s_pVpScoreRealPlay->pPalette[0] = 0x0000; 
  s_pVpScoreRealPlay->pPalette[1] = 0x0F00; 
  s_pVpScoreRealPlay->pPalette[2] = 0x00F0; 
  s_pVpScoreRealPlay->pPalette[3] = 0x000F;

// These are ignored but according to the docs they should not be
  s_pVpScoreRealPlay->pPalette[4] = 0x019; 
  s_pVpScoreRealPlay->pPalette[5] = 0x0B66;
  s_pVpScoreRealPlay->pPalette[6] = 0x0CCC;
  s_pVpScoreRealPlay->pPalette[7] = 0x0620;
  s_pVpScoreRealPlay->pPalette[8] = 0x955;
  s_pVpScoreRealPlay->pPalette[9] = 0x0FA8;
  s_pVpScoreRealPlay->pPalette[10] = 0x0E0A;
  s_pVpScoreRealPlay->pPalette[11] = 0x0F99;
  s_pVpScoreRealPlay->pPalette[12] = 0x0F88; 
  s_pVpScoreRealPlay->pPalette[13] = 0x0EAA;
  s_pVpScoreRealPlay->pPalette[14] = 0x0004;
  s_pVpScoreRealPlay->pPalette[15] = 0x078A;

I noticed that the array s_pMainBufferRealPlay->pBack->Planes has been allocated enough to host 4 bitplanes, but oddly there is no way to display colors stored in the last 12 slots of the palette, my impression is that the last 2 bitplanes are simply ignored even if they are allocated.For example if I store the value 1 for a specific pixel in all bitplanes, the resulting color is the one stored at position 3 and not 15.