MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / GenerateBaseColors

Function GenerateBaseColors

source/NTSC.cpp:2697–2723  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2695}
2696
2697static void GenerateBaseColors(baseColors_t pBaseNtscColors)
2698{
2699 for (UINT i=0; i<16; i++)
2700 {
2701 g_nColorPhaseNTSC = INITIAL_COLOR_PHASE;
2702 g_nSignalBitsNTSC = 0;
2703
2704 // 12 iterations for colour to "stabilise", then 4 iterations to calc the average
2705 // - after colour "stabilises" then it repeats through 4 phases (with different RGB values for each phase)
2706 uint32_t bits = (i<<12) | (i<<8) | (i<<4) | i; // 16 bits
2707
2708 uint32_t colors[4];
2709 for (UINT j=0; j<16; j++)
2710 {
2711 colors[j&3] = getScanlineColor(bits & 1, g_aHueColorTV[g_nColorPhaseNTSC]);
2712 bits >>= 1;
2713 updateColorPhase();
2714 }
2715
2716 int r = (((colors[0]>>16)&0xff) + ((colors[1]>>16)&0xff) + ((colors[2]>>16)&0xff) + ((colors[3]>>16)&0xff)) / 4;
2717 int g = (((colors[0]>> 8)&0xff) + ((colors[1]>> 8)&0xff) + ((colors[2]>> 8)&0xff) + ((colors[3]>> 8)&0xff)) / 4;
2718 int b = (((colors[0] )&0xff) + ((colors[1] )&0xff) + ((colors[2] )&0xff) + ((colors[3] )&0xff)) / 4;
2719 uint32_t color = ((r<<16) | (g<<8) | b) | ALPHA32_MASK;
2720
2721 (*pBaseNtscColors)[i] = * (bgra_t*) &color;
2722 }
2723}
2724
2725//===========================================================================
2726

Callers 1

NTSC_VideoInitFunction · 0.85

Calls 2

getScanlineColorFunction · 0.85
updateColorPhaseFunction · 0.85

Tested by

no test coverage detected