void MakeBlendBiXlat(unsigned char* pBiXlat, int partsFirst, int partsSecond) { int i, j; if (!pBiXlat || partsFirst <= 0 || partsSecond <= 0) return; for (i = 0; i < NUM_COLORS; i++) { Color pe1 = colors[i]; for (j = 0; j < NUM_COLORS; j++) { Color pe2 = colors[j]; Color pe; pe.red = (pe1.red*partsFirst + pe2.red*partsSecond) / (partsFirst+partsSecond); pe.green = (pe1.green*partsFirst + pe2.green*partsSecond) / (partsFirst+partsSecond); pe.blue = (pe1.blue*partsFirst + pe2.blue*partsSecond) / (partsFirst+partsSecond); pBiXlat[(i<<8)|(j)] = GetClosestPaletteIndex(pe.red, pe.blue, pe.green); } } }
/* * MakeLightPalettes: Precompute palettes for varying light levels. * colors is used as the base palette. */ void MakeLightPalettes(void) { int i, j; int red, green, blue; float factor; /* Fraction of full brightness in a particular palette */ for (i=0; i < LIGHT_LEVELS; i++) { /* Quadratic dependence so that there are more palettes close to full brightness */ #if 1 factor = 1 - ((float) LIGHT_LEVELS - i) / LIGHT_LEVELS * ((float) LIGHT_LEVELS - i) / LIGHT_LEVELS; #else factor = ((float) LIGHT_LEVELS - i) / LIGHT_LEVELS * ((float) LIGHT_LEVELS - i) / LIGHT_LEVELS; #endif for (j=0; j < NUM_COLORS; j++) { light_palettes[i][j] = j; if (_nevermap[j]) continue; red = min((int) (colors[j].red * factor), 255); blue = min((int) (colors[j].blue * factor), 255); green = min((int) (colors[j].green * factor), 255); light_palettes[i][j] = GetClosestPaletteIndex(red, blue, green); } } // Make inverted effect palette for (j=0; j < NUM_COLORS; j++) { light_palettes[PALETTE_INVERT][j] = j; if (_nevermap[i]) continue; red = 255 - colors[j].red; blue = 255 - colors[j].blue; green = 255 - colors[j].green; light_palettes[PALETTE_INVERT][j] = GetClosestPaletteIndex(red, blue, green); } }
/* * BoardBitmapsLoad: Load piece bitmaps. */ void BoardBitmapsLoad(void) { int i, j; for (i=0; i < 2; i++) for (j = 0; j < NUM_PIECES; j++) { if (!GetBitmapResourceInfo(hInst, piece_bitmaps[i][j].id, &piece_bitmaps[i][j].bmap)) debug(("Unable to load bitmap for chess piece %d, color %d\n", j, i)); } // Compute palette index select_index = GetClosestPaletteIndex(RGB(252, 156, 0)); }
/* * InventoryBoxCreate: Create the inventory list box. */ void InventoryBoxCreate(HWND hParent) { BITMAPINFOHEADER *ptr; LOGBRUSH logbrush; hwndInvDialog = CreateDialog(hInst, MAKEINTRESOURCE(IDD_INVENTORY), hParent, InventoryDialogProc); hwndInv = CreateWindow("button", NULL, WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 0, 0, 0, 0, hwndInvDialog, (HMENU) IDC_INVENTORY, hInst, NULL); lpfnDefProc = SubclassWindow(hwndInv, InventoryProc); hwndInvScroll = CreateWindow("scrollbar", NULL, WS_CHILD | SBS_VERT, 0, 0, 100, 100, /* Make sure scrollbar drawn ok */ hwndInvDialog, (HMENU) IDC_INVSCROLL, hInst, NULL); inventory_scrollbar_width = GetSystemMetrics(SM_CXVSCROLL); num_items = 0; top_row = 0; cursor_row = cursor_col = -1; items = NULL; capture = False; // Get bitmaps for cursor and in-use highlight ptr = GetBitmapResource(hInst, IDB_INVCURSOR); if (ptr == NULL) cursor_bits = NULL; else cursor_bits = ((BYTE *) ptr) + sizeof(BITMAPINFOHEADER) + NUM_COLORS * sizeof(RGBQUAD); ptr = GetBitmapResource(hInst, IDB_INVINUSE); if (ptr == NULL) inuse_bits = NULL; else inuse_bits = ((BYTE *) ptr) + sizeof(BITMAPINFOHEADER) + NUM_COLORS * sizeof(RGBQUAD); ptr = GetBitmapResource(hInst, IDB_SELFTRGT); if (ptr == NULL) selftrgt_bits = NULL; else selftrgt_bits = ((BYTE *) ptr) + sizeof(BITMAPINFOHEADER) + NUM_COLORS * sizeof(RGBQUAD); if (!GetBitmapResourceInfo(hInst, IDB_INVBKGND, &inventory_bkgnd)) debug(("InventoryBoxCreate couldn't load inventory background bitmap\n")); // ajw begin... // hbmpScrollBack = GetHBitmapFromResource( hInst, IDB_INVBKGND ); // if( !hbmpScrollBack ) // debug(("InventoryBoxCreate couldn't create hbmpScrollBack\n")); if( !( ptr = GetBitmapResource( hInst, IDB_INVBKGND ) ) ) debug(("InventoryBoxCreate couldn't load inventory scroll bar texture bitmap\n")); // logbrush.lbStyle = BS_DIBPATTERN; // logbrush.lbColor = DIB_RGB_COLORS; // logbrush.lbHatch = hbmpScrollBack; logbrush.lbStyle = BS_DIBPATTERNPT; logbrush.lbColor = DIB_RGB_COLORS; logbrush.lbHatch = (long)ptr; hbrushScrollBack = CreateBrushIndirect( &logbrush ); // ajw end... // Compute background palette index inventory_bg_index = GetClosestPaletteIndex(RGB(84, 40, 0)); InventoryResetFont(); InventoryChangeColor(); InventoryDisplayScrollbar(); }