From 1fc2c0f2b2854be04375f0e8ffb6648ba4f45769 Mon Sep 17 00:00:00 2001 From: michaelangel007 Date: Wed, 31 Dec 2014 17:57:57 -0800 Subject: [PATCH] Remove most of the old unused Video rendering functions --- source/Applewin.cpp | 5 +- source/Video.cpp | 1263 +------------------------------------------ source/Video.h | 2 - 3 files changed, 5 insertions(+), 1265 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index 4348e7e5..03ea0cbd 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -953,10 +953,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) DiskInitialize(); LogFileOutput("Init: DiskInitialize()\n"); - CreateColorMixMap(); // For tv emulation mode - LogFileOutput("Init: CreateColorMixMap()\n"); - - int nError = 0; // TODO: Show error MsgBox if we get a DiskInsert error + int nError = 0; // TODO: Show error MsgBox if we get a DiskInsert error if (szImageName_drive1) { nError = DoDiskInsert(DRIVE_1, szImageName_drive1); diff --git a/source/Video.cpp b/source/Video.cpp index 82a37383..043e8634 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -119,23 +119,13 @@ enum Color_Palette_Index_e , HGR_PINK // MONOCHROME - // NOTE: 50% is assumed to come after 100% luminance !!! See: V_CreateLookup_MonoHiRes() - // User customizable , MONOCHROME_CUSTOM // 100% luminance , MONOCHROME_CUSTOM_50 // 50% luminance - // Pre-set "Monochromes" , MONOCHROME_AMBER -// , MONOCHROME_AMBER_50 // BUG - something trashing our palette entry !!! , MONOCHROME_GREEN -// , MONOCHROME_GREEN_50 // BUG - something trashing our palette entry !!! - , DEBUG_COLORS_START , DEBUG_COLORS_END = DEBUG_COLORS_START + NUM_DEBUG_COLORS -// DD Full Screen Palette ?!?! -// , LOGO_COLORS_START -// , LOGO_COLORS_END = LOGO_COLORS_START + 128 - , NUM_COLOR_PALETTE // The last 10 are the DEFAULT Windows colors (as it reserves 20 colors) @@ -316,17 +306,8 @@ static bool bVideoScannerNTSC = true; // NTSC video scanning (or PAL) // Prototypes (Private) _____________________________________________ - void V_CreateLookup_DoubleHires (); - void V_CreateLookup_Hires (); // Old "Full-Pixel" support only: STANDARD, TEXT_OPTIMIZED, TVEMU - void V_CreateLookup_HiResHalfPixel_Authentic (); // New "Half_Pixel" support: STANDARD, TEXT_OPTIMIZED - void V_CreateLookup_HiresHalfShiftDim(); void V_CreateLookup_Lores (); - void V_CreateLookup_Text (HDC dc); -// Monochrome Full-Pixel Support - void V_CreateLookup_MonoDoubleHiRes (); - void V_CreateLookup_MonoHiRes (); - void V_CreateLookup_MonoLoRes (); - void V_CreateLookup_MonoText (HDC dc); + // Monochrome Half-Pixel Support void V_CreateLookup_MonoHiResHalfPixel_Real (); @@ -354,77 +335,6 @@ static bool bVideoScannerNTSC = true; // NTSC video scanning (or PAL) @param sy Src Y // =========================================================================== */ -static inline void CopySource8(int dx, int dy, int w, int h, int sx, int sy) -{ - LPBYTE pDst = g_aFrameBufferOffset[ dy ] + dx; - LPBYTE pSrc = g_aSourceStartofLine[ sy ] + sx; - int nBytes; - - while (h--) - { - nBytes = w; - - // If not multiple of 3 bytes, copy first 3 bytes, so the next copy is 4-byte aligned. - while (nBytes & 3) - { - --nBytes; - if (g_uHalfScanLines && !(h & 1)) - *(pDst+nBytes) = 0; // 50% Half Scan Line clears every odd scanline (and SHIFT+PrintScreen saves only the even rows) - else - *(pDst+nBytes) = *(pSrc+nBytes); - } - - // Copy 4 bytes at a time - while (nBytes) - { - nBytes -= 4; - if (g_uHalfScanLines && !(h & 1)) - *(LPDWORD)(pDst+nBytes) = 0; // 50% Half Scan Line clears every odd scanline (and SHIFT+PrintScreen saves only the even rows) - else - *(LPDWORD)(pDst+nBytes) = *(LPDWORD)(pSrc+nBytes); - } - - pDst -= g_nFrameBufferPitch; - pSrc -= SRCOFFS_TOTAL; - } -} - -static void CopySource(int dx, int dy, int w, int h, int sx, int sy) -{ - if (!g_bIsFullScreen || !GetFullScreen32Bit()) - { - CopySource8(dx,dy,w,h,sx,sy); - return; - } - - UINT32* pDst = (UINT32*) (g_aFrameBufferOffset[ dy ] + dx*sizeof(UINT32)); - LPBYTE pSrc = g_aSourceStartofLine[ sy ] + sx; - int nBytes; - - while (h--) - { - nBytes = w; - while (nBytes) - { - --nBytes; - if (g_uHalfScanLines && !(h & 1)) - { - // 50% Half Scan Line clears every odd scanline (and SHIFT+PrintScreen saves only the even rows) - *(pDst+nBytes) = 0; - } - else - { - const RGBQUAD& rRGB = g_pFramebufferinfo->bmiColors[ *(pSrc+nBytes) ]; - const UINT32 rgb = (((UINT32)rRGB.rgbRed)<<16) | (((UINT32)rRGB.rgbGreen)<<8) | ((UINT32)rRGB.rgbBlue); - *(pDst+nBytes) = rgb; - } - } - - pDst -= g_nFrameBufferPitch / sizeof(UINT32); - pSrc -= SRCOFFS_TOTAL; - } -} - //=========================================================================== void CreateFrameOffsetTable (LPBYTE addr, LONG pitch) { @@ -490,12 +400,6 @@ int GetMonochromeIndex() //=========================================================================== void V_CreateIdentityPalette () { - if (g_hPalette) - { - DeleteObject(g_hPalette); - } - g_hPalette = (HPALETTE)0; - SETFRAMECOLOR(BLACK, 0x00,0x00,0x00); // 0 SETFRAMECOLOR(DARK_RED, 0x80,0x00,0x00); // 1 // not used SETFRAMECOLOR(DARK_GREEN, 0x00,0x80,0x00); // 2 // not used @@ -546,7 +450,6 @@ void V_CreateIdentityPalette () , ((GetBValue(monochrome)/2) & 0xFF) ); - // SEE: V_CreateLookup_MonoText SETFRAMECOLOR( MONOCHROME_AMBER , 0xFF,0x80,0x01); // Used for Monochrome Hi-Res graphics not text! SETFRAMECOLOR( MONOCHROME_GREEN , 0x00,0xC0,0x01); // Used for Monochrome Hi-Res graphics not text! // BUG PALETTE COLLAPSE: WTF?? Soon as we set 0xFF,0xFF,0xFF we lose text colors?!?! @@ -563,422 +466,9 @@ void V_CreateIdentityPalette () SETFRAMECOLOR(MAGENTA, 0xC7,0x34,0xFF); // FD Linards Tweaked 0xFF,0x00,0xFF -> 0xC7,0x34,0xFF SETFRAMECOLOR(CYAN, 0x00,0xFF,0xFF); // FE SETFRAMECOLOR(WHITE, 0xFF,0xFF,0xFF); // FF - - // IF WE ARE IN A PALETTIZED VIDEO MODE, CREATE AN IDENTITY PALETTE - HWND window = GetDesktopWindow(); - HDC dc = GetDC(window); - - // int GetDeviceCaps( HDC, nIndex ); - int colors = GetDeviceCaps(dc,SIZEPALETTE); // 16/24/32bpp = 0 - int system = GetDeviceCaps(dc,NUMCOLORS); // 16/24/32bpp = -1 +} #if 0 - // DD Full Screen Palette - // Full Screen Debug Colors - BYTE *pTmp; - - pTmp = ((BYTE*)g_pFramebufferinfo) + sizeof(BITMAPINFOHEADER); - pTmp += (DEBUG_COLORS_START * 4); - Debug_UpdatePalette( pTmp ); - - // GET THE PALETTE ENTRIES OF THE LOGO - RGBQUAD aLogoPalette[256]; - ZeroMemory(aLogoPalette,sizeof(aLogoPalette)); - if (g_hLogoBitmap) - { - BYTE *pSrc = NULL; - BITMAP bmp; - PBITMAPINFO pbmi; -// WORD cClrBits; - // Retrieve the bitmap color format, width, and height. - if (GetObject(g_hLogoBitmap, sizeof(BITMAP), (LPSTR)&bmp)) - { - pSrc = (BYTE*) pbmi->bmiColors; - - // Logo uses 128 colors - pTmp = ((BYTE*)g_pFramebufferinfo) + sizeof(BITMAPINFOHEADER); - pTmp += (LOGO_COLORS_START * 4); - int iPal = 0; - for( iPal = 0; iPal < 128; iPal++ ) - { - *pTmp++ = *pSrc++; - *pTmp++ = *pSrc++; - *pTmp++ = *pSrc++; - *pTmp++ = *pSrc++; - } - } - } -#endif - - int bRasterPalette = (GetDeviceCaps(dc,RASTERCAPS) & RC_PALETTE); - if (bRasterPalette && (colors <= 256)) - { - // GET THE PALETTE ENTRIES OF THE LOGO - RGBQUAD aLogoPalette[256]; - ZeroMemory(aLogoPalette,sizeof(aLogoPalette)); - if (g_hLogoBitmap) { - HDC memdc = CreateCompatibleDC(dc); - SelectObject(memdc,g_hLogoBitmap); - GetDIBColorTable(memdc,0,colors,aLogoPalette); - DeleteDC(memdc); - } - - // CREATE A PALETTE ENTRY ARRAY - LOGPALETTE *paldata = (LOGPALETTE *)VirtualAlloc( - NULL, - sizeof(LOGPALETTE) + 256*sizeof(PALETTEENTRY), - MEM_COMMIT, - PAGE_READWRITE - ); - - paldata->palVersion = 0x300; - paldata->palNumEntries = colors; - GetSystemPaletteEntries(dc,0,colors,paldata->palPalEntry); - - // FILL IN THE PALETTE ENTRIES - int paletteindex = 0; - int logoindex = 0; - int halftoneindex = 0; - - // COPY THE SYSTEM PALETTE ENTRIES AT THE BEGINNING OF THE PALETTE - for (; paletteindex < system/2; paletteindex++) - paldata->palPalEntry[paletteindex].peFlags = 0; - - // FILL IN THE MIDDLE PORTION OF THE PALETTE WITH OUR OWN COLORS - for (int ourindex = DEEP_RED; ourindex <= NUM_COLOR_PALETTE; ourindex++) { - paldata->palPalEntry[paletteindex].peRed = g_pFramebufferinfo->bmiColors[ourindex].rgbRed; - paldata->palPalEntry[paletteindex].peGreen = g_pFramebufferinfo->bmiColors[ourindex].rgbGreen; - paldata->palPalEntry[paletteindex].peBlue = g_pFramebufferinfo->bmiColors[ourindex].rgbBlue; - paldata->palPalEntry[paletteindex].peFlags = PC_NOCOLLAPSE; - paletteindex++; - } - - for (; paletteindex < colors-system/2; paletteindex++) { - - // IF THIS PALETTE ENTRY IS NEEDED FOR THE LOGO, COPY IN THE LOGO COLOR - if (aLogoPalette[logoindex].rgbRed && - aLogoPalette[logoindex].rgbGreen && - aLogoPalette[logoindex].rgbBlue) - { - paldata->palPalEntry[paletteindex].peRed = aLogoPalette[logoindex].rgbRed; - paldata->palPalEntry[paletteindex].peGreen = aLogoPalette[logoindex].rgbGreen; - paldata->palPalEntry[paletteindex].peBlue = aLogoPalette[logoindex].rgbBlue; - } - - // OTHERWISE, ADD A HALFTONING COLOR, SO THAT OTHER APPLICATIONS - // RUNNING IN THE BACKGROUND WILL HAVE SOME REASONABLE COLORS TO USE - else - { - static BYTE halftonetable[6] = {32,64,96,160,192,224}; - paldata->palPalEntry[paletteindex].peRed = halftonetable[halftoneindex % 6]; - paldata->palPalEntry[paletteindex].peGreen = halftonetable[halftoneindex/6 % 6]; - paldata->palPalEntry[paletteindex].peBlue = halftonetable[halftoneindex/36 % 6]; - ++halftoneindex; - } - - ++logoindex; - paldata->palPalEntry[paletteindex].peFlags = PC_NOCOLLAPSE; - } - - // COPY THE SYSTEM PALETTE ENTRIES AT THE END OF THE PALETTE - for (; paletteindex < colors; paletteindex++) - paldata->palPalEntry[paletteindex].peFlags = 0; - - // FILL THE FRAME BUFFER TABLE WITH COLORS FROM OUR PALETTE - for (int iPal = 0; iPal < colors; iPal++) { - g_pFramebufferinfo->bmiColors[ iPal ].rgbRed = paldata->palPalEntry[ iPal ].peRed; - g_pFramebufferinfo->bmiColors[ iPal ].rgbGreen = paldata->palPalEntry[ iPal ].peGreen; - g_pFramebufferinfo->bmiColors[ iPal ].rgbBlue = paldata->palPalEntry[ iPal ].peBlue; - } - - // CREATE THE PALETTE - g_hPalette = CreatePalette(paldata); - VirtualFree(paldata,0,MEM_RELEASE); - } - - ReleaseDC(window,dc); -} - -//=========================================================================== -void V_CreateDIBSections () -{ - CopyMemory(g_pSourceHeader->bmiColors,g_pFramebufferinfo->bmiColors,256*sizeof(RGBQUAD)); - - // CREATE THE DEVICE CONTEXT - HWND window = GetDesktopWindow(); - HDC dc = GetDC(window); - if (g_hDeviceDC) - { - DeleteDC(g_hDeviceDC); - } - g_hDeviceDC = CreateCompatibleDC(dc); - - // CREATE THE FRAME BUFFER DIB SECTION - if (g_hDeviceBitmap) - DeleteObject(g_hDeviceBitmap); - g_hDeviceBitmap = CreateDIBSection( - dc, - g_pFramebufferinfo, - DIB_RGB_COLORS, - (LPVOID *)&g_pFramebufferbits,0,0 - ); - SelectObject(g_hDeviceDC,g_hDeviceBitmap); - - // CREATE THE SOURCE IMAGE DIB SECTION - HDC sourcedc = CreateCompatibleDC(dc); - ReleaseDC(window,dc); - if (g_hSourceBitmap) - DeleteObject(g_hSourceBitmap); - - g_hSourceBitmap = CreateDIBSection( - sourcedc, - g_pSourceHeader, - DIB_RGB_COLORS, - (LPVOID *)&g_pSourcePixels,0,0 - ); - SelectObject(sourcedc,g_hSourceBitmap); - - // CREATE THE OFFSET TABLE FOR EACH SCAN LINE IN THE SOURCE IMAGE - for (int y = 0; y < MAX_SOURCE_Y; y++) - g_aSourceStartofLine[ y ] = g_pSourcePixels + SRCOFFS_TOTAL*((MAX_SOURCE_Y-1) - y); - - // DRAW THE SOURCE IMAGE INTO THE SOURCE BIT BUFFER - ZeroMemory(g_pSourcePixels,SRCOFFS_TOTAL*512); // 32 bytes/pixel * 16 colors = 512 bytes/row - - // First monochrome mode is seperate from others - if ((g_eVideoType >= VT_COLOR_STANDARD) && (g_eVideoType < VT_MONO_AMBER)) - { - V_CreateLookup_Text(sourcedc); - V_CreateLookup_Lores(); - - if ( g_eVideoType == VT_COLOR_TVEMU ) - V_CreateLookup_Hires(); - else -#if HALF_DIM_SUPPORT - V_CreateLookup_HiresHalfShiftDim(); -#else - V_CreateLookup_HiResHalfPixel_Authentic(); -#endif - V_CreateLookup_DoubleHires(); - } - else - { - V_CreateLookup_MonoText(sourcedc); - V_CreateLookup_MonoLoRes(); - - switch (g_eVideoType) - { - case VT_MONO_AMBER : /* intentional fall-thru */ - case VT_MONO_GREEN : /* intentional fall-thru */ - case VT_MONO_WHITE : /* intentional fall-thru */ - case VT_MONO_HALFPIXEL_REAL : V_CreateLookup_MonoHiResHalfPixel_Real() ; break; - default: V_CreateLookup_MonoHiRes(); break; - } - V_CreateLookup_MonoDoubleHiRes(); - } - DeleteDC(sourcedc); -} - -//=========================================================================== -void V_CreateLookup_DoubleHires () -{ -#define OFFSET 3 -#define SIZE 10 - - for (int column = 0; column < 256; column++) { - int coloffs = SIZE * column; - for (unsigned byteval = 0; byteval < 256; byteval++) { - int color[SIZE]; - ZeroMemory(color,sizeof(color)); - unsigned pattern = MAKEWORD(byteval,column); - int pixel; - for (pixel = 1; pixel < 15; pixel++) { - if (pattern & (1 << pixel)) { - int pixelcolor = 1 << ((pixel-OFFSET) & 3); - if ((pixel >= OFFSET+2) && (pixel < SIZE+OFFSET+2) && (pattern & (0x7 << (pixel-4)))) - color[pixel-(OFFSET+2)] |= pixelcolor; - if ((pixel >= OFFSET+1) && (pixel < SIZE+OFFSET+1) && (pattern & (0xF << (pixel-4)))) - color[pixel-(OFFSET+1)] |= pixelcolor; - if ((pixel >= OFFSET+0) && (pixel < SIZE+OFFSET+0)) - color[pixel-(OFFSET+0)] |= pixelcolor; - if ((pixel >= OFFSET-1) && (pixel < SIZE+OFFSET-1) && (pattern & (0xF << (pixel+1)))) - color[pixel-(OFFSET-1)] |= pixelcolor; - if ((pixel >= OFFSET-2) && (pixel < SIZE+OFFSET-2) && (pattern & (0x7 << (pixel+2)))) - color[pixel-(OFFSET-2)] |= pixelcolor; - } - } - - if (g_eVideoType == VT_COLOR_TEXT_OPTIMIZED) - { - // Activate for fringe reduction on white HGR text - drawback: loss of color mix patterns in HGR Video Mode. - for (pixel = 0; pixel < 13; pixel++) - { - if ((pattern & (0xF << pixel)) == (unsigned)(0xF << pixel)) - for (int pos = pixel; pos < pixel + 4; pos++) - if (pos >= OFFSET && pos < SIZE+OFFSET) - color[pos-OFFSET] = 15; - } - } - - int y = byteval << 1; - for (int x = 0; x < SIZE; x++) { - SETSOURCEPIXEL(SRCOFFS_DHIRES+coloffs+x,y ,DoubleHiresPalIndex[ color[x] ]); - SETSOURCEPIXEL(SRCOFFS_DHIRES+coloffs+x,y+1,DoubleHiresPalIndex[ color[x] ]); - } - } - } -#undef SIZE -#undef OFFSET -} - -//=========================================================================== -void V_CreateLookup_Hires () -{ - int iMonochrome = GetMonochromeIndex(); - - // BYTE colorval[6] = {MAGENTA,BLUE,GREEN,ORANGE,BLACK,WHITE}; - // BYTE colorval[6] = {HGR_VIOLET,HGR_BLUE,HGR_GREEN,HGR_ORANGE,HGR_BLACK,HGR_WHITE}; - for (int iColumn = 0; iColumn < 16; iColumn++) - { - int coloffs = iColumn << 5; - - for (unsigned iByte = 0; iByte < 256; iByte++) - { - int aPixels[11]; - - aPixels[ 0] = iColumn & 4; - aPixels[ 1] = iColumn & 8; - aPixels[ 9] = iColumn & 1; - aPixels[10] = iColumn & 2; - - int nBitMask = 1; - int iPixel; - for (iPixel = 2; iPixel < 9; iPixel++) { - aPixels[iPixel] = ((iByte & nBitMask) != 0); - nBitMask <<= 1; - } - - int hibit = ((iByte & 0x80) != 0); - int x = 0; - int y = iByte << 1; - - while (x < 28) - { - int adj = (x >= 14) << 1; - int odd = (x >= 14); - - for (iPixel = 2; iPixel < 9; iPixel++) - { - int color = CM_Black; - if (aPixels[iPixel]) - { - if (aPixels[iPixel-1] || aPixels[iPixel+1]) - color = CM_White; - else - color = ((odd ^ (iPixel&1)) << 1) | hibit; - } - else if (aPixels[iPixel-1] && aPixels[iPixel+1]) - { - // Activate fringe reduction on white HGR text - drawback: loss of color mix patterns in HGR video mode. - // VT_COLOR_STANDARD = Fill in colors in between white pixels - // VT_COLOR_TVEMU = Fill in colors in between white pixels (Post Processing will mix/merge colors) - // VT_COLOR_TEXT_OPTIMIZED --> !(aPixels[iPixel-2] && aPixels[iPixel+2]) = Don't fill in colors in between white - if ((g_eVideoType == VT_COLOR_TVEMU) || !(aPixels[iPixel-2] && aPixels[iPixel+2]) ) - color = ((odd ^ !(iPixel&1)) << 1) | hibit; // No white HGR text optimization - } - - //if (g_eVideoType == VT_MONO_AUTHENTIC) { - // int nMonoColor = (color != CM_Black) ? iMonochrome : BLACK; - // SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y , nMonoColor); // buggy - // SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y , nMonoColor); // buggy - // SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1,BLACK); // BL - // SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1,BLACK); // BR - //} else - { - // Colors - Top/Bottom Left/Right - // cTL cTR - // cBL cBR - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y ,HiresToPalIndex[color]); // cTL - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y ,HiresToPalIndex[color]); // cTR - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1,HiresToPalIndex[color]); // cBL - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1,HiresToPalIndex[color]); // cBR - } - x += 2; - } - } - } - } -} - - -//=========================================================================== -void V_CreateLookup_Lores () -{ - for (int color = 0; color < 16; color++) - for (int x = 0; x < 16; x++) - for (int y = 0; y < 16; y++) - SETSOURCEPIXEL(SRCOFFS_LORES+x,(color << 4)+y,LoresResColors[color]); -} - - -//=========================================================================== -void V_CreateLookup_MonoDoubleHiRes () -{ - int iMonochrome = GetMonochromeIndex(); - - for (int column = 0; column < 256; column++) - { - int coloffs = 10 * column; - for (unsigned byteval = 0; byteval < 256; byteval++) - { - unsigned pattern = MAKEWORD(byteval,column); - int y = byteval << 1; - for (int x = 0; x < 10; x++) - { - BYTE colorval = pattern & (1 << (x+3)) ? iMonochrome : BLACK; - -#if 0 - if (g_eVideoType == VT_MONO_AUTHENTIC) - { - SETSOURCEPIXEL(SRCOFFS_DHIRES+coloffs+x,y ,colorval); - SETSOURCEPIXEL(SRCOFFS_DHIRES+coloffs+x,y+1,BLACK); - } - else -#endif - { - SETSOURCEPIXEL(SRCOFFS_DHIRES+coloffs+x,y ,colorval); - SETSOURCEPIXEL(SRCOFFS_DHIRES+coloffs+x,y+1,colorval); - } - } - } - } -} - -//=========================================================================== -void V_CreateLookup_MonoHiRes () -{ - const int iMonochrome = GetMonochromeIndex(); - - for (int column = 0; column < 512; column += 16) - { - for (int y = 0; y < 512; y += 2) // optimization: Byte=0..FF, Row=Byte*2 - { - unsigned val = (y >> 1); // iByte = (y / 2) - for (int x = 0; x < 16; x += 2) // 8 pixels - { - BYTE colorval = (val & 1) ? iMonochrome : BLACK; - val >>= 1; - SETSOURCEPIXEL(SRCOFFS_HIRES+column+x ,y ,colorval); - SETSOURCEPIXEL(SRCOFFS_HIRES+column+x+1,y ,colorval); - { - SETSOURCEPIXEL(SRCOFFS_HIRES+column+x ,y+1,colorval); - SETSOURCEPIXEL(SRCOFFS_HIRES+column+x+1,y+1,colorval); - } - } - } - } -} - //=========================================================================== void V_CreateLookup_HiResHalfPixel_Authentic () // Colors are solid (100% coverage) { @@ -1043,26 +533,7 @@ Legend: // Fixup missing pixels that normally have been scan-line shifted -- Apple "half-pixel" -- but cross 14-pixel boundaries. if( hibit ) { - if ( aPixels[1] ) // preceeding pixel on? -#if 0 // Optimization: Doesn't seem to matter if we ignore the 2 pixels of the next byte - for (iPixel = 0; iPixel < 9; iPixel++) // NOTE: You MUST start with the preceding 2 pixels !!! - if (aPixels[iPixel]) // pixel on -#endif - { - if (aPixels[2] || aPixels[0]) // White if pixel from previous byte and first pixel of this byte is on - { - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y , HGR_WHITE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y+1, HGR_WHITE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y , HGR_WHITE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y+1, HGR_WHITE ); - } else { // Optimization: odd = (iPixel & 1); if (!odd) case is same as if(odd) !!! // Reference: Gumball - Gumball Machine - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y , HGR_ORANGE ); // left half of orange pixels - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y+1, HGR_ORANGE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y , HGR_BLUE ); // right half of blue pixels 4, 11, 18, ... - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y+1, HGR_BLUE ); - } - } -#if HALF_PIXEL_SOLID + // Test Patterns // 81 blue // 2000:D5 AA D5 AA -> 2001:AA D5 should not have black gap, should be blue @@ -1076,8 +547,6 @@ Legend: // 29D0:C0 90 88 -> Blue black orange // Game: Ultima 4 -- Ultima 4 Logo - bottom half of screen has a "mini-game" / demo -- far right has tree and blue border // 2176:2A AB green black_gap white blue_border // Should have black gap between green and white - else if ( aPixels[0] ) // prev prev pixel on - { // Game: Gumball // 218E:AA 97 => 2000: A9 87 orange_white // Should have no gap between orange and white // 229A:AB A9 87 -> 2000: 00 A9 87 white orange black blue_white // Should have no gap between blue and white @@ -1092,134 +561,20 @@ Legend: if ( aPixels[2] ) #if HALF_PIXEL_BLEED // No Half-Pixel Bleed - if ( aPixels[3] ) { SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y , DARK_BLUE ); // Gumball: 229A: AB A9 87 - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y+1, DARK_BLUE ); SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y , BROWN ); // half luminance red Elite: 2444: BB F7 SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y+1, BROWN ); // half luminance red Gumball: 218E: AA 97 - } else { SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y , HGR_BLUE ); // 2000:D5 AA D5 - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y+1, HGR_BLUE ); SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y , HGR_ORANGE ); // 2000: AA D5 - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y+1, HGR_ORANGE ); - } #else - if ((g_eVideoType == VT_COLOR_STANDARD) || ( !aPixels[3] )) - { // "Text optimized" IF this pixel on, and adjacent right pixel off, then colorize first half-pixel of this byte +// "Text optimized" IF this pixel on, and adjacent right pixel off, then colorize first half-pixel of this byte SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y , HGR_BLUE ); // 2000:D5 AA D5 - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+0 ,y+1, HGR_BLUE ); SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y , HGR_ORANGE ); // 2000: AA D5 - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+16,y+1, HGR_ORANGE ); - } #endif // HALF_PIXEL_BLEED - } -#endif // HALF_PIXEL_SOLID - } - x += hibit; - - while (x < 28) - { - int adj = (x >= 14) << 1; // Adjust start of 7 last pixels to be 16-byte aligned! - int odd = (x >= 14); - for (iPixel = 2; iPixel < 9; iPixel++) - { - int color = CM_Black; - if (aPixels[iPixel]) // pixel on - { - color = CM_White; - if (aPixels[iPixel-1] || aPixels[iPixel+1]) // adjacent pixels are always white - color = CM_White; - else - color = ((odd ^ (iPixel&1)) << 1) | hibit; // map raw color to our hi-res colors - } -#if HALF_PIXEL_SOLID - else if (aPixels[iPixel-1] && aPixels[iPixel+1]) // IF prev_pixel && next_pixel THEN - { - // Activate fringe reduction on white HGR text - drawback: loss of color mix patterns in HGR video mode. - if ( - (g_eVideoType == VT_COLOR_STANDARD) // Fill in colors in between white pixels - || (g_eVideoType == VT_COLOR_TVEMU) // Fill in colors in between white pixels (Post Processing will mix/merge colors) - || !(aPixels[iPixel-2] && aPixels[iPixel+2]) ) // VT_COLOR_TEXT_OPTIMIZED -> Don't fill in colors in between white - { // Test Pattern: Ultima 4 Logo - Castle // 3AC8: 36 5B 6D 36 - color = ((odd ^ !(iPixel&1)) << 1) | hibit; // No white HGR text optimization - } - } -#endif - // Colors - Top/Bottom Left/Right - // cTL cTR - // cBL cBR - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+adj ,y ,HiresToPalIndex[color]); // cTL - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+adj+1,y ,HiresToPalIndex[color]); // cTR - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+adj ,y+1,HiresToPalIndex[color]); // cBL - SETSOURCEPIXEL(SRCOFFS_HIRES+offsetx+x+adj+1,y+1,HiresToPalIndex[color]); // cBR - x += 2; - } - } - } - } } -//=========================================================================== -void V_CreateLookup_HiresHalfShiftDim () -{ - // BYTE colorval[6] = {HGR_MAGENTA,HGR_BLUE,HGR_GREEN,HGR_RED,HGR_BLACK,HGR_WHITE}; - for (int iColumn = 0; iColumn < 16; iColumn++) - { - int coloffs = iColumn << 5; - - for (unsigned iByte = 0; iByte < 256; iByte++) - { - int aPixels[11]; - - aPixels[ 0] = iColumn & 4; - aPixels[ 1] = iColumn & 8; - aPixels[ 9] = iColumn & 1; - aPixels[10] = iColumn & 2; - - int nBitMask = 1; - int iPixel; - for (iPixel = 2; iPixel < 9; iPixel++) { - aPixels[iPixel] = ((iByte & nBitMask) != 0); - nBitMask <<= 1; - } - - int hibit = ((iByte & 0x80) != 0); - int x = 0; - int y = iByte << 1; - - while (x < 28) - { - int adj = (x >= 14) << 1; - int odd = (x >= 14); - - for (iPixel = 2; iPixel < 9; iPixel++) - { - int color = CM_Black; - if (aPixels[iPixel]) - { - if (aPixels[iPixel-1] || aPixels[iPixel+1]) - { - color = CM_White; - } - else - color = ((odd ^ (iPixel&1)) << 1) | hibit; - } - else if (aPixels[iPixel-1] && aPixels[iPixel+1]) - { - /* - activate for fringe reduction on white hgr text - - drawback: loss of color mix patterns in HGR mode. - select g_eVideoType by index exclusion - */ - if ( - (g_eVideoType == VT_COLOR_STANDARD) // Fill in colors in between white pixels - || (g_eVideoType == VT_COLOR_TVEMU) // Fill in colors in between white pixels (Post Processing will mix/merge colors) - || !(aPixels[iPixel-2] && aPixels[iPixel+2]) ) // VT_COLOR_TEXT_OPTIMIZED -> Don't fill in colors in between white - color = ((odd ^ !(iPixel&1)) << 1) | hibit; - } - /* Address Binary -> Displayed 2000:01 0---0001 -> 1 0 0 0 column 1 @@ -1237,120 +592,8 @@ void V_CreateLookup_HiresHalfShiftDim () @reference: see Beagle Bro's Disk: "Silicon Salad", File: DOUBLE HI-RES Fortunately double-hires is supported via pixel doubling, so we can do half-pixel shifts ;-) */ - switch (color) - { - case CM_Violet: - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y , HGR_VIOLET ); // HiresToPalIndex - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y , DARK_MAGENTA ); // HiresDimmedIndex - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1, HGR_VIOLET ); // HiresToPalIndex - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1, DARK_MAGENTA ); // HiresDimmedIndex - break; - - case CM_Blue : - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y , HGR_BLUE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+2,y , DARK_BLUE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1, HGR_BLUE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+2,y+1, DARK_BLUE ); - // Prevent column gaps - if (hibit) - { - if (iPixel <= 2) - { - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y , DARK_BLUE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1, DARK_BLUE ); - } - } - break; - - case CM_Green : - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y , HGR_GREEN ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y , DARK_GREEN ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1, HGR_GREEN ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1, DARK_GREEN ); - break; - - case CM_Orange: - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y , HGR_ORANGE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+2,y , BROWN ); // DARK_RED is a bit "too" red - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1, HGR_ORANGE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+2,y+1, BROWN ); // DARK_RED is a bit "too" red - // Prevent column gaps - if (hibit) - { - if (iPixel <= 2) - { - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y , BROWN ); // DARK_RED is a bit "too" red - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1, BROWN ); // DARK_RED is a bit "too" red - } - } - break; - - case CM_Black : - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y , HGR_BLACK ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y , HGR_BLACK ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1, HGR_BLACK ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1, HGR_BLACK ); - break; - - case CM_White : - // Don't dither / half-shift white, since DROL cutscene looks bad :( - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y , HGR_WHITE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y , HGR_WHITE ); - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1, HGR_WHITE ); // LIGHT_GRAY <- for that half scan-line look - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj+1,y+1, HGR_WHITE ); // LIGHT_GRAY <- for that half scan-line look - // Prevent column gaps - if (hibit) - { - if (iPixel <= 2) - { - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y , HGR_WHITE ); // LIGHT_GRAY HGR_GREY1 - SETSOURCEPIXEL(SRCOFFS_HIRES+coloffs+x+adj ,y+1, HGR_WHITE ); // LIGHT_GRAY HGR_GREY1 - } - } - break; - default: - break; - } - x += 2; - } - } - } - } -} - -//=========================================================================== -void V_CreateLookup_MonoHiResHalfPixel_Real () -{ - int iMono = GetMonochromeIndex(); - - for (int iColumn = 0; iColumn < 16; iColumn++) - { - int offset = iColumn << 5; // every column is 32 bytes wide - - for (unsigned iByte = 0; iByte < 256; iByte++) - { - int aPixels[11]; // c2 c1 b7 b6 b5 b4 b3 b2 b1 b0 c8 c4 - - aPixels[ 0] = iColumn & 4; - aPixels[ 1] = iColumn & 8; - aPixels[ 9] = iColumn & 1; - aPixels[10] = iColumn & 2; - - int nBitMask = 1; - int iPixel; - for (iPixel = 2; iPixel < 9; iPixel++) - { - aPixels[iPixel] = ((iByte & nBitMask) != 0); - nBitMask <<= 1; - } - - int hibit = (iByte >> 7) & 1; // ((iByte & 0x80) != 0); - int x = 0; - int y = iByte << 1; // Fixup missing pixels that normally have been scan-line shifted -- Apple "half-pixel" -- but cross 14-pixel boundaries. - if( hibit ) - { /* Test Cases // Games Archon Logo @@ -1365,66 +608,7 @@ void V_CreateLookup_MonoHiResHalfPixel_Real () 2000:D0 80 00 2800:80 D0 00 */ - if ( aPixels[1] ) // preceeding pixel on? - { - SETSOURCEPIXEL(SRCOFFS_HIRES+offset+x ,y ,iMono); // first 7 HGR_BLUE - SETSOURCEPIXEL(SRCOFFS_HIRES+offset+x ,y+1,iMono); // first 7 - - SETSOURCEPIXEL(SRCOFFS_HIRES+offset+x+16,y ,iMono); // second 7 HGR_ORANGE - SETSOURCEPIXEL(SRCOFFS_HIRES+offset+x+16,y+1,iMono); // second 7 - } - } - - while (x < 28) - { - int adj = (x >= 14) << 1; // Adjust start of 7 last pixels to be 16-byte aligned! - int odd = (x >= 14); - - for (iPixel = 2; iPixel < 9; iPixel++) - { - int color = aPixels[iPixel] ? iMono : HGR_BLACK; - - // Colors - Top/Bottom Left/Right - SETSOURCEPIXEL(SRCOFFS_HIRES+offset+x+adj +hibit,y ,color); // TL - SETSOURCEPIXEL(SRCOFFS_HIRES+offset+x+adj+1+hibit,y ,color); // BL - SETSOURCEPIXEL(SRCOFFS_HIRES+offset+x+adj +hibit,y+1,color); // BL - SETSOURCEPIXEL(SRCOFFS_HIRES+offset+x+adj+1+hibit,y+1,color); // BR - x += 2; - } - } - } - } -} - -//=========================================================================== -void V_CreateLookup_MonoLoRes () { - int iMonochrome = GetMonochromeIndex(); - - for (int color = 0; color < 16; color++) - { - for (int x = 0; x < 16; x++) - { - for (int y = 0; y < 16; y++) - { - BYTE colorval = (color >> (x & 3) & 1) ? iMonochrome : BLACK; -#if 0 - if (g_eVideoType == VT_MONO_AUTHENTIC) - { - if (y & 1) - SETSOURCEPIXEL(SRCOFFS_LORES+x,(color << 4)+y,BLACK); - else - SETSOURCEPIXEL(SRCOFFS_LORES+x,(color << 4)+y,colorval); - } - else #endif - { - SETSOURCEPIXEL(SRCOFFS_LORES+x,(color << 4)+y,colorval); - } - } - } - } -} - // google: CreateDIBPatternBrushPt // http://209.85.141.104/search?q=cache:mB3htrQGW8kJ:bookfire.net/wince/wince-programming-ms-press2/source/prowice/ch02e.htm @@ -1510,32 +694,6 @@ static void CreateLookup_TextCommon(HDC hDstDC, DWORD rop) DeleteObject(hCharBitmap[i]); } -static void V_CreateLookup_Text(HDC hDstDC) -{ - CreateLookup_TextCommon(hDstDC, SRCCOPY); -} - -static void V_CreateLookup_MonoText(HDC hDstDC) -{ - HBRUSH hBrush; - switch (g_eVideoType) - { - case VT_MONO_AMBER: hBrush = CreateSolidBrush(RGB(0xFF,0x80,0x00)); break; - case VT_MONO_GREEN: hBrush = CreateSolidBrush(RGB(0x00,0xC0,0x00)); break; - case VT_MONO_WHITE: hBrush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF)); break; - default : hBrush = CreateSolidBrush(monochrome); break; - } - - SelectObject(hDstDC, hBrush); - - // NB. MERGECOPY (not SRCCOPY) to merge the src with the colour of the dst's selected brush - CreateLookup_TextCommon(hDstDC, MERGECOPY); - - SelectObject(hDstDC,GetStockObject(NULL_BRUSH)); - DeleteObject(hBrush); -} - - //=========================================================================== void SetLastDrawnImage () { @@ -1563,127 +721,6 @@ static inline int GetOriginal2EOffset(BYTE ch) return !IsOriginal2E() || !g_nAltCharSetOffset || (ch<0x40) || (ch>0x5F) ? 0 : -g_nAltCharSetOffset; } -bool Update40ColCell (int x, int y, int xpixel, int ypixel, int offset) -{ - BYTE ch = *(g_pTextBank0+offset); - bool bCharChanged = (ch != *(vidlastmem+offset+0x400) || g_VideoForceFullRedraw); - - // FLASHing chars: - // - FLASHing if:Alt Char Set is OFF && 0x40<=char<=0x7F - // - The inverse of this char is located at: char+0x40 - bool bCharFlashing = (g_nAltCharSetOffset == 0) && (ch >= 0x40) && (ch <= 0x7F); - - if(bCharChanged || (bCharFlashing && g_bTextFlashFlag)) - { - bool bInvert = bCharFlashing ? g_bTextFlashState : false; - - CopySource(xpixel,ypixel, - APPLE_FONT_WIDTH, APPLE_FONT_HEIGHT, - (IS_APPLE2 ? SRCOFFS_IIPLUS : SRCOFFS_40COL) + ((ch & 0x0F) << 4), - (ch & 0xF0) + g_nAltCharSetOffset + GetOriginal2EOffset(ch) + (bInvert ? 0x40 : 0x00)); - - return true; - } - - return false; -} - -inline bool _Update80ColumnCell( BYTE c, const int xPixel, const int yPixel, bool bCharFlashing ) -{ - bool bInvert = bCharFlashing ? g_bTextFlashState : false; - - CopySource( - xPixel, yPixel, - (APPLE_FONT_WIDTH / 2), APPLE_FONT_HEIGHT, - SRCOFFS_80COL + ((c & 0x0F) << 3), - (c & 0xF0) + g_nAltCharSetOffset + GetOriginal2EOffset(c) + (bInvert ? 0x40 : 0x00)); - - return true; -} - -//=========================================================================== -bool Update80ColCell (int x, int y, int xpixel, int ypixel, int offset) -{ - bool bDirty = false; - -#if FLASH_80_COL - BYTE c1 = *(g_pTextBank1 + offset); // aux - BYTE c0 = *(g_pTextBank0 + offset); // main - - bool bC1Changed = (c1 != *(vidlastmem + offset + 0) || g_VideoForceFullRedraw); - bool bC0Changed = (c0 != *(vidlastmem + offset + 0x400) || g_VideoForceFullRedraw); - - bool bC1Flashing = (g_nAltCharSetOffset == 0) && (c1 >= 0x40) && (c1 <= 0x7F); - bool bC0Flashing = (g_nAltCharSetOffset == 0) && (c0 >= 0x40) && (c0 <= 0x7F); - - if (bC1Changed || (bC1Flashing && g_bTextFlashFlag)) - bDirty = _Update80ColumnCell( c1, xpixel, ypixel, bC1Flashing ); - - if (bC0Changed || (bC0Flashing && g_bTextFlashFlag)) - bDirty |= _Update80ColumnCell( c0, xpixel + 7, ypixel, bC0Flashing ); - -#else - BYTE auxval = *(g_pTextBank1 + offset); // aux - BYTE mainval = *(g_pTextBank0 + offset); // main - - if ((auxval != *(vidlastmem+offset)) || - (mainval != *(vidlastmem+offset+0x400)) || - g_VideoForceFullRedraw) - { - CopySource(xpixel,ypixel, - (APPLE_FONT_WIDTH / 2), APPLE_FONT_HEIGHT, - SRCOFFS_80COL + ((auxval & 15)<<3), - ((auxval>>4)<<4) + g_nAltCharSetOffset); - - CopySource(xpixel+7,ypixel, - (APPLE_FONT_WIDTH / 2), APPLE_FONT_HEIGHT, - SRCOFFS_80COL + ((mainval & 15)<<3), - ((mainval>>4)<<4) + g_nAltCharSetOffset ); - - bDirty = true; - } -#endif - - return bDirty; -} - -//=========================================================================== -bool UpdateDHiResCell (int x, int y, int xpixel, int ypixel, int offset) -{ - bool bDirty = false; - int yoffset = 0; - while (yoffset < 0x2000) { - BYTE byteval1 = (x > 0) ? *(g_pHiresBank0+offset+yoffset-1) : 0; - BYTE byteval2 = *(g_pHiresBank1 +offset+yoffset); - BYTE byteval3 = *(g_pHiresBank0+offset+yoffset); - BYTE byteval4 = (x < 39) ? *(g_pHiresBank1 +offset+yoffset+1) : 0; - if ((byteval2 != *(vidlastmem+offset+yoffset)) || - (byteval3 != *(vidlastmem+offset+yoffset+0x2000)) || - ((x > 0) && ((byteval1 & 0x70) != (*(vidlastmem+offset+yoffset+0x1FFF) & 0x70))) || - ((x < 39) && ((byteval4 & 0x07) != (*(vidlastmem+offset+yoffset+ 1) & 0x07))) || - g_VideoForceFullRedraw) { - DWORD dwordval = (byteval1 & 0x70) | ((byteval2 & 0x7F) << 7) | - ((byteval3 & 0x7F) << 14) | ((byteval4 & 0x07) << 21); -#define PIXEL 0 -#define COLOR ((xpixel + PIXEL) & 3) -#define VALUE (dwordval >> (4 + PIXEL - COLOR)) - CopySource(xpixel+PIXEL,ypixel+(yoffset >> 9),7,2, - SRCOFFS_DHIRES+10*HIBYTE(VALUE)+COLOR,LOBYTE(VALUE)<<1); -#undef PIXEL -#define PIXEL 7 - CopySource(xpixel+PIXEL,ypixel+(yoffset >> 9),7,2, - SRCOFFS_DHIRES+10*HIBYTE(VALUE)+COLOR,LOBYTE(VALUE)<<1); -#undef PIXEL -#undef COLOR -#undef VALUE - bDirty = true; - } - yoffset += 0x400; - } - - return bDirty; -} - /* Color Reference Tests: @@ -1699,300 +736,8 @@ Color Reference Tests: */ //=========================================================================== -BYTE MixColors(BYTE c1, BYTE c2) -{ - // For tv emulation HGR Video Mode - #define COMBINATION(c1,c2,ref1,ref2) (((c1)==(ref1)&&(c2)==(ref2)) || ((c1)==(ref2)&&(c2)==(ref1))) - - if (c1 == c2) - return c1; - if (COMBINATION(c1,c2,HGR_BLUE,HGR_ORANGE)) - return HGR_GREY1; - else if (COMBINATION(c1,c2,HGR_GREEN,HGR_VIOLET)) - return HGR_GREY2; - else if (COMBINATION(c1,c2,HGR_ORANGE,HGR_GREEN)) - return HGR_YELLOW; - else if (COMBINATION(c1,c2,HGR_BLUE,HGR_GREEN)) - return HGR_AQUA; - else if (COMBINATION(c1,c2,HGR_BLUE,HGR_VIOLET)) - return HGR_PURPLE; - else if (COMBINATION(c1,c2,HGR_ORANGE,HGR_VIOLET)) - return HGR_PINK; - else - return MONOCHROME_CUSTOM; // visible failure indicator - -#undef COMBINATION -} - - -//=========================================================================== -void CreateColorMixMap() -{ - // For tv emulation HGR Video Mode - #define FROM_NEIGHBOUR 0x00 - - int t,m,b; - BYTE cTop, cMid, cBot; - WORD mixTop, mixBot; - -#define MIX_THRESHOLD 0x12 // bottom 2 HGR colors - - for (t=0; t<6; t++) - for (m=0; m<6; m++) - for (b=0; b<6; b++) { - cTop = t | 0x10; - cMid = m | 0x10; - cBot = b | 0x10; - if (cMid < MIX_THRESHOLD) { - mixTop = mixBot = cMid; - } else { - if (cTop < MIX_THRESHOLD) { - mixTop = FROM_NEIGHBOUR; - } else { - mixTop = MixColors(cMid,cTop); - } - if (cBot < MIX_THRESHOLD) { - mixBot = FROM_NEIGHBOUR; - } else { - mixBot = MixColors(cMid,cBot); - } - if (mixTop == FROM_NEIGHBOUR && mixBot != FROM_NEIGHBOUR) { - mixTop = mixBot; - } else if (mixBot == FROM_NEIGHBOUR && mixTop != FROM_NEIGHBOUR) { - mixBot = mixTop; - } else if (mixBot == FROM_NEIGHBOUR && mixTop == FROM_NEIGHBOUR) { - mixBot = mixTop = cMid; - } - } - colormixmap[t][m][b] = (mixTop << 8) | mixBot; - } -#undef FROM_NEIGHBOUR -} - -//=========================================================================== -void __stdcall MixColorsVertical(int matx, int maty) -{ - // For tv emulation HGR Video Mode - - WORD twoHalfPixel; - int bot1idx, bot2idx; - - if (SW_MIXED && maty > 159) { - if (maty < 161) { - bot1idx = hgrpixelmatrix[matx][maty+1] & 0x0F; - bot2idx = 0; - } else { - bot1idx = bot2idx = 0; - } - } else { - bot1idx = hgrpixelmatrix[matx][maty+1] & 0x0F; - bot2idx = hgrpixelmatrix[matx][maty+2] & 0x0F; - } - - twoHalfPixel = colormixmap[hgrpixelmatrix[matx][maty-2] & 0x0F] - [hgrpixelmatrix[matx][maty-1] & 0x0F] - [hgrpixelmatrix[matx][maty ] & 0x0F]; - colormixbuffer[0] = (twoHalfPixel & 0xFF00) >> 8; - colormixbuffer[1] = twoHalfPixel & 0x00FF; - - twoHalfPixel = colormixmap[hgrpixelmatrix[matx][maty-1] & 0x0F] - [hgrpixelmatrix[matx][maty ] & 0x0F] - [bot1idx]; - colormixbuffer[2] = (twoHalfPixel & 0xFF00) >> 8; - colormixbuffer[3] = twoHalfPixel & 0x00FF; - - twoHalfPixel = colormixmap[hgrpixelmatrix[matx][maty ] & 0x0F] - [bot1idx] - [bot2idx]; - colormixbuffer[4] = (twoHalfPixel & 0xFF00) >> 8; - colormixbuffer[5] = twoHalfPixel & 0x00FF; -} - -//=========================================================================== - -static inline void __stdcall CopyMixedSource8(int x, int y, int sourcex, int sourcey) -{ - // For tv emulation HGR Video Mode - - const BYTE* const currsourceptr = g_aSourceStartofLine[sourcey]+sourcex; - BYTE* const currdestptr = g_aFrameBufferOffset[y*2] + (x*2); - - const int matx = x; - const int maty = HGR_MATRIX_YOFFSET + y; - const int hgrlinesabove = (y > 0) ? 1 : 0; - const int hgrlinesbelow = SW_MIXED ? ((y < 159)? 1:0) : ((y < 191)? 1:0); - const int istart = 2 - (hgrlinesabove*2); - const int iend = 3 + (hgrlinesbelow*2); - - // transfer 7 pixels (i.e. the visible part of an apple hgr-byte) from row to pixelmatrix - for (int count = 0, bufxoffset = 0; count < 7; count++, bufxoffset += 2) - { - hgrpixelmatrix[matx+count][maty] = *(currsourceptr+bufxoffset); - - // color mixing between adjacent scanlines at current x position - MixColorsVertical(matx+count, maty); - - // transfer up to 6 mixed (half-)pixels of current column to framebuffer - BYTE* currptr = currdestptr+bufxoffset; - if (hgrlinesabove) - currptr += g_nFrameBufferPitch * 2; - - for (int i = istart; i <= iend; currptr -= g_nFrameBufferPitch, i++) - { - if (g_uHalfScanLines && (i & 1)) - *currptr = *(currptr+1) = 0; // 50% Half Scan Line clears every odd scanline (and SHIFT+PrintScreen saves only the even rows) - else - *currptr = *(currptr+1) = colormixbuffer[i]; - } - } -} - -// For tv emulation HGR Video Mode -static void __stdcall CopyMixedSource(int x, int y, int sourcex, int sourcey) -{ - if (!g_bIsFullScreen || !GetFullScreen32Bit()) - { - CopyMixedSource8(x,y,sourcex,sourcey); - return; - } - - const BYTE* const currsourceptr = g_aSourceStartofLine[sourcey]+sourcex; - UINT32* const currdestptr = (UINT32*) (g_aFrameBufferOffset[ y*2 ] + (x*2)*sizeof(UINT32)); - - const int matx = x; - const int maty = HGR_MATRIX_YOFFSET + y; - const int hgrlinesabove = (y > 0) ? 1 : 0; - const int hgrlinesbelow = SW_MIXED ? ((y < 159)? 1:0) : ((y < 191)? 1:0); - const int istart = 2 - (hgrlinesabove*2); - const int iend = 3 + (hgrlinesbelow*2); - - // transfer 7 pixels (i.e. the visible part of an apple hgr-byte) from row to pixelmatrix - for (int count = 0, bufxoffset = 0; count < 7; count++, bufxoffset += 2) - { - hgrpixelmatrix[matx+count][maty] = *(currsourceptr+bufxoffset); - - // color mixing between adjacent scanlines at current x position - MixColorsVertical(matx+count, maty); - - // transfer up to 6 mixed (half-)pixels of current column to framebuffer - UINT32* currptr = currdestptr+bufxoffset; - if (hgrlinesabove) - currptr += (g_nFrameBufferPitch / sizeof(UINT32)) * 2; - - for (int i = istart; i <= iend; currptr -= g_nFrameBufferPitch/sizeof(UINT32), i++) - { - if (g_uHalfScanLines && (i & 1)) - { - // 50% Half Scan Line clears every odd scanline (and SHIFT+PrintScreen saves only the even rows) - *currptr = *(currptr+1) = 0; - } - else - { - const RGBQUAD& rRGB = g_pFramebufferinfo->bmiColors[ colormixbuffer[i] ]; - const UINT32 rgb = (((UINT32)rRGB.rgbRed)<<16) | (((UINT32)rRGB.rgbGreen)<<8) | ((UINT32)rRGB.rgbBlue); - *currptr = *(currptr+1) = rgb; - } - } - } -} - -//=========================================================================== -bool UpdateHiResCell (int x, int y, int xpixel, int ypixel, int offset) -{ - bool bDirty = false; - int yoffset = 0; - while (yoffset < 0x2000) - { -#if 0 // TRACE_VIDEO - static char sText[ 256 ]; - sprintf(sText, "x: %3d y: %3d xpix: %3d ypix: %3d offset: %04X \n" - , x, y, xpixel, ypixel, offset, yoffset - ); - OutputDebugString("sText"); -#endif - - BYTE byteval1 = (x > 0) ? *(g_pHiresBank0+offset+yoffset-1) : 0; - BYTE byteval2 = *(g_pHiresBank0+offset+yoffset ); - BYTE byteval3 = (x < 39) ? *(g_pHiresBank0+offset+yoffset+1) : 0; - if ((byteval2 != *(vidlastmem+offset+yoffset+0x2000)) || - ((x > 0) && ((byteval1 & 0x60) != (*(vidlastmem+offset+yoffset+0x1FFF) & 0x60))) || - ((x < 39) && ((byteval3 & 0x03) != (*(vidlastmem+offset+yoffset+0x2001) & 0x03))) || - g_VideoForceFullRedraw) - { -#define COLOFFS (((byteval1 & 0x60) << 2) | \ - ((byteval3 & 0x03) << 5)) - if (g_eVideoType == VT_COLOR_TVEMU) - { - CopyMixedSource( - xpixel >> 1, (ypixel+(yoffset >> 9)) >> 1, - SRCOFFS_HIRES+COLOFFS+((x & 1) << 4), (((int)byteval2) << 1) - ); - } - else - { - CopySource( - xpixel,ypixel+(yoffset >> 9), - 14,2, // 2x upscale: 280x192 -> 560x384 - SRCOFFS_HIRES+COLOFFS+((x & 1) << 4), (((int)byteval2) << 1) - ); - } -#undef COLOFFS - bDirty = true; - } - yoffset += 0x400; - } - - return bDirty; -} - -//=========================================================================== -bool UpdateLoResCell (int x, int y, int xpixel, int ypixel, int offset) -{ - BYTE val = *(g_pTextBank0+offset); - if ((val != *(vidlastmem+offset+0x400)) || g_VideoForceFullRedraw) - { - CopySource(xpixel,ypixel, - 14,8, - SRCOFFS_LORES+((x & 1) << 1),((val & 0xF) << 4)); - CopySource(xpixel,ypixel+8, - 14,8, - SRCOFFS_LORES+((x & 1) << 1),(val & 0xF0)); - return true; - } - - return false; -} - -//=========================================================================== - #define ROL_NIB(x) ( (((x)<<1)&0xF) | (((x)>>3)&1) ) -bool UpdateDLoResCell (int x, int y, int xpixel, int ypixel, int offset) -{ - BYTE auxval = *(g_pTextBank1 + offset); - BYTE mainval = *(g_pTextBank0 + offset); - - if ( (auxval != *(vidlastmem+offset)) || - (mainval != *(vidlastmem+offset+0x400)) || - g_VideoForceFullRedraw - ) - { - const BYTE auxval_h = auxval >> 4; - const BYTE auxval_l = auxval & 0xF; - auxval = (ROL_NIB(auxval_h)<<4) | ROL_NIB(auxval_l); // Fix Bug #14879 - - CopySource( xpixel,ypixel , 7,8,SRCOFFS_LORES+((x & 1) << 1),((auxval & 0xF) << 4)); - CopySource( xpixel,ypixel+8, 7,8,SRCOFFS_LORES+((x & 1) << 1),(auxval & 0xF0)); - // - CopySource( xpixel+7,ypixel , 7,8, SRCOFFS_LORES+((x & 1) << 1),((mainval & 0xF) << 4)); - CopySource( xpixel+7,ypixel+8, 7,8, SRCOFFS_LORES+((x & 1) << 1),(mainval & 0xF0)); - return true; - } - - return false; -} - - // // ----- ALL GLOBALLY ACCESSIBLE FUNCTIONS ARE BELOW THIS LINE ----- // diff --git a/source/Video.h b/source/Video.h index c5293287..467cca14 100644 --- a/source/Video.h +++ b/source/Video.h @@ -67,8 +67,6 @@ typedef bool (*VideoUpdateFuncPtr_t)(int,int,int,int,int); // Prototypes _______________________________________________________ -void CreateColorMixMap(); - BOOL VideoApparentlyDirty (); void VideoBenchmark (); void VideoChooseMonochromeColor (); // FIXME: Should be moved to PageConfig and call VideoSetMonochromeColor()