+++ /dev/null
-# NetHack 3.6 defaults.nh $NHDT-Date: 1524689357 2018/04/25 20:49:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.32 $
-# Copyright (c) 2006 by Michael Allison
-# NetHack may be freely redistributed. See license for details.
-
-# Sample config file for win32 NetHack
-# A '#' at the beginning of a line means the rest of the line is a comment.
-#
-# Some options MUST be set in this file, other options can be toggled while
-# playing. For a list of options available see the <opthelp.> file.
-#
-# To change the configuration, comment out the unwanted lines, and
-# uncomment the configuration you want.
-#
-# $NHDT-Date: 1524689357 2018/04/25 20:49:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.32 $
-
-# *** OPTIONS ***
-#
-# Use the IBM character set rather than just plain ascii characters
-# for tty window-port.
-OPTIONS=symset:default,roguesymset:default
-
-# Here is a suggested symbol set from Michael Feir,
-# for use by blind NetHack players
-#OPTIONS=symset:NHAccess,roguesymset:NHAccess
-
-# Optional curses port interface
-#OPTIONS=windowtype:curses
-#
-# Keyboard handling
-# Different keyboard handlers can be loaded.
-# Default is nhdefkey.dll but you can override that.
-# Ray Chason's keyboard handler
-# OPTIONS=altkeyhandler:nhraykey.dll
-#
-# NetHack 3.4.0 keyboard handling
-# OPTIONS=altkeyhandler:nh340key.dll
-
-# *** Personal Preferences ***
-# Some options to set personal preferences. Uncomment and change these to
-# suit your personal preference. If several people are to use the same
-# configuration, options like these should not be set.
-#
-#OPTIONS=name:Janet,role:Valkyrie,race:Human,gender:female,align:lawful
-#OPTIONS=dogname:Fido,catname:Morris,fruit:guava
-#OPTIONS=horsename:Silver
-
-# Disable autopickup
-OPTIONS=!autopickup
-
-# When autopickup is on, automatically pick up these types of objects
-#OPTIONS=pickup_types:$"=/!?+
-
-#OPTIONS=packorder:")[%?+/=!(*0_`
-#OPTIONS=scores:10 top/2 around/own
-#OPTIONS=nolegacy,noverbose
-#OPTIONS=menustyle:traditional
-#OPTIONS=perm_invent
-
-
-# Highlight menu lines with different colors. You need to define the colors
-# with MENUCOLOR lines.
-# Toggle menucolor use on or off
-OPTIONS=menucolors
-# Define color used for a certain menu line. Format is
-# MENUCOLOR="regular expression"=color
-# or
-# MENUCOLOR="regular expression"=color&attribute
-# Show all blessed items in green
-MENUCOLOR=" blessed " = green
-# Show all holy water in green
-MENUCOLOR=" holy " = green
-# Show all cursed items in red
-MENUCOLOR=" cursed " = red
-# Show all unholy water in red
-MENUCOLOR=" unholy " = red
-# Show all cursed worn items in orange and underlined
-MENUCOLOR=" cursed .* (being worn)" = orange&underline
-
-
-
-# General options. You might also set "silent" so as not to attract
-# the boss's attention.
-#
-# number_pad option can have an optional value of 0 (off), 1 (on),
-# or 2(on,legacy-mode) which causes 5='g', alt-5='G', alt-0='I'
-OPTIONS=time,noshowexp,number_pad:2,lit_corridor,mouse_support:1
-
-# Make commands that ask for an inventory item pop up a menu
-OPTIONS=force_invmenu
-
-#
-# If you want to get rid of "use #quit to quit..." use:
-OPTIONS=suppress_alert:3.3.1
-#
-# Note: the rest_on_space in the next line may not be
-# appropriate for a beginning NetHack player, since
-# it could result in use of a turn unintentionally.
-# If you're new to NetHack, leave it commented it out.
-#OPTIONS=rest_on_space
-#
-# Set some options to control graphical window-port (these will
-# be safely and silently ignored by the tty port)
-#
-# Map window settings
-# possible map_mode options include: tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|
-# ascii7x12|ascii8x12|ascii16x12|ascii12x16|
-# ascii10x18|fit_to_screen
-OPTIONS=map_mode:tiles,scroll_margin:10
-
-# Message window settings
-#OPTIONS=font_message:Arial,font_size_message:14,align_message:top
-
-# Menu settings
-#OPTIONS=font_menu:Arial,font_size_menu:14
-
-# Text settings
-#OPTIONS=font_text:Courier New,font_size_text:14
-
-# Status window settings
-#OPTIONS=font_status:Courier New,font_size_status:14
-
-# Other
-OPTIONS=hilite_pet,!toptenwin
-#OPTIONS=!splash_screen,player_selection:prompts
-
-# Status/message window colors
-# Possible color options include:
-# six digit hexadecimal RGB color value ("#8F8F8F"), black, red, green, brown,
-# blue, magenta, cyan, gray (or grey), orange, brightgreen, yellow, brightblue,
-# brightmagenta, brightcyan, white, trueblack, purple, silver, maroon, fuchsia,
-# lime, olive, navy, teal, aqua, activeborder, activecaption, appworkspace,
-# background, btnface, btnshadow, btntext, captiontext, graytext, highlight,
-# highlighttext, inactiveborder, inactivecaption, menu, menutext, scrollbar,
-# window, windowframe, windowtext.
-#OPTIONS=windowcolors:status windowtext/window message windowtext/window
-
-# "Nethack mode" colors
-OPTIONS=windowcolors:status white/#000000 message white/#000000 text white/#000000 menu white/#000000 menutext white/#000000
-OPTIONS=vary_msgcount:4
-
-# *** LOCATIONS ***
-# IMPORTANT: If you change any of these locations, the directories they
-# point at must exist. NetHack will not create them for you.
-#
-# HACKDIR is the default location for everything.
-# Note: On Windows HACKDIR defaults to the location
-# of the NetHack.exe or NetHackw.exe file so
-# setting HACKDIR below to override that is
-# not usually necessary or recommended.
-#HACKDIR=c:\games\nethack
-#
-# The location that level files in progress are stored (default=HACKDIR, writeable)
-#LEVELDIR=c:\nethack\levels
-#
-# The location where saved games are kept (default=HACKDIR, writeable)
-#SAVEDIR=c:\nethack\save
-#
-# The location that bones files are kept (default=HACKDIR, writeable)
-#BONESDIR=c:\nethack\save
-#
-# The location that file synchronization locks are stored (default=HACKDIR, writeable)
-#LOCKDIR=c:\nethack\levels
-#
-# The location that a record of game aborts and self-diagnosed game problems
-# is kept (default=HACKDIR, writeable)
-#TROUBLEDIR=c:\nethack\trouble
-
-# Finnish keyboards might need these modifications uncommented.
-# For \, @, $, [, |
-#OPTIONS=subkeyvalue:171/92
-#OPTIONS=subkeyvalue:178/64
-#OPTIONS=subkeyvalue:180/36
-#OPTIONS=subkeyvalue:184/91
-#OPTIONS=subkeyvalue:188/124
-
-#
-# Some versions of Windows allow you to adjust the win32 console port
-# colors using R-G-B settings.
-#
-#OPTIONS=palette:black-0-0-0
-#OPTIONS=palette:red-210-0-0
-#OPTIONS=palette:green-80-200-0
-#OPTIONS=palette:brown-180-100-0
-#OPTIONS=palette:blue-0-0-200
-#OPTIONS=palette:magenta-128-0-128
-#OPTIONS=palette:cyan-50-180-180
-#OPTIONS=palette:gray-192-192-192
-#OPTIONS=palette:dark gray-100-100-100
-#OPTIONS=palette:orange-255-128-0
-#OPTIONS=palette:bright green-0-255-0
-#OPTIONS=palette:yellow-255-255-0
-#OPTIONS=palette:bright blue-100-100-240
-#OPTIONS=palette:bright magenta-255-0-255
-#OPTIONS=palette:bright cyan-0-255-255
-#OPTIONS=palette:white-255-255-255
-
-
-
+++ /dev/null
-#
-# NetHack 3.6 sysconf $NHDT-Date: 1524689357 2018/04/25 20:49:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.22 $
-# Copyright (c) 2015 by Michael Allison
-# NetHack may be freely redistributed. See license for details.
-#
-# Sample sysconf file.
-# The sysconf file is only used if NetHack is compiled with SYSCF defined.
-# This file uses the same syntax as nethack.cf.
-
-# Which users can use WIZARD (debugging) mode (the -D flag).
-# A value of * allows anyone to enter debugging mode.
-WIZARDS=*
-
-# Users allowed to use the ! (shell escape) command or to suspend the game.
-# Uses the same syntax as the WIZARDS option above.
-#SHELLERS=
-
-# Show debugging information originating from these source files.
-# Use '*' for all, or list source files separated by spaces.
-# Only available if game has been compiled with DEBUG.
-#DEBUGFILES=*
-
-# Save end of game dump log to this file.
-# Only available if NetHack was compiled with DUMPLOG
-# Allows following placeholders:
-# %% literal '%'
-# %v version (eg. "3.6.2-0")
-# %u game UID
-# %t game start time, UNIX timestamp format
-# %T current time, UNIX timestamp format
-# %d game start time, YYYYMMDDhhmmss format
-# %D current time, YYYYMMDDhhmmss format
-# %n player name
-# %N first character of player name
-#DUMPLOGFILE=nethack-%n-%d.log
-
-# Number of bones file pools.
-# The pool you belong to is determined at game start. You will
-# load and save bones only from that pool. Generally useful
-# for public servers only.
-# Changing this might make existing bones inaccessible.
-# Disabled by setting to 0, or commenting out.
-#BONES_POOLS=10
-
-# Limit the number of simultaneous games (see also nethack.sh).
-#MAXPLAYERS=10
-
-# If not null, added to string "To get local support, " in the support
-# information help.
-#SUPPORT=call Izchak at extension 42.
-
-# Uncomment the next line to disable the SEDUCE option.
-#SEDUCE=0
-
-# Record (high score) file options.
-# CAUTION: changing these after people have started playing games can
-# lead to lost high scores!
-# Maximum entries for one person.
-#PERSMAX=10
-# Maximum entries in the record file.
-#ENTRYMAX=100
-# Minimum points to get an entry.
-#POINTSMIN=1
-# Determine identity of "person" in the score file with name (0) or
-# numeric (1) user id.
-#PERS_IS_UID=1
-
-# Maximum number of score file entries to use for random statue names
-#MAX_STATUENAME_RANK=10
-
-# *** LOCATIONS ***
-# IMPORTANT: If you change any of these locations, the directories they
-# point at must exist. NetHack will not create them for you.
-#
-# HACKDIR is the default location for everything.
-# Note: On Windows HACKDIR defaults to the location
-# of the NetHack.exe or NetHackw.exe file so
-# setting HACKDIR below to override that is
-# not usually necessary or recommended.
-#HACKDIR=c:\games\nethack
-#
-# The location that users can adjust their config file startup options
-#CONFIGDIR=c:\games\nethack
-#
-# The location that level files in progress are stored (default=HACKDIR, writeable)
-#LEVELDIR=c:\nethack\levels
-#
-# The location where saved games are kept (default=HACKDIR, writeable)
-#SAVEDIR=c:\nethack\save
-#
-# The location that bones files are kept (default=HACKDIR, writeable)
-#BONESDIR=c:\nethack\save
-#
-# The location that file synchronization locks are stored (default=HACKDIR, writeable)
-#LOCKDIR=c:\nethack\levels
-#
-# The location that a record of game aborts and self-diagnosed game problems
-# is kept (default=HACKDIR, writeable)
-#TROUBLEDIR=c:\nethack\trouble
-
-
+++ /dev/null
-/* NetHack 3.6 winhack.c $NHDT-Date: 1449488876 2015/12/07 11:47:56 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.44 $ */
-/* Copyright (C) 2001 by Alex Kompel */
-/* NetHack may be freely redistributed. See license for details. */
-
-// winhack.cpp : Defines the entry point for the application.
-//
-
-#include "win10.h"
-#include <process.h>
-
-#include "winMS.h"
-#include "hack.h"
-#include "dlb.h"
-#include "resource.h"
-#include "mhmain.h"
-#include "mhmap.h"
-
-#if !defined(SAFEPROCS)
-#error You must #define SAFEPROCS to build winhack.c
-#endif
-
-/* Borland and MinGW redefine "boolean" in shlwapi.h,
- so just use the little bit we need */
-typedef struct _DLLVERSIONINFO {
- DWORD cbSize;
- DWORD dwMajorVersion; // Major version
- DWORD dwMinorVersion; // Minor version
- DWORD dwBuildNumber; // Build number
- DWORD dwPlatformID; // DLLVER_PLATFORM_*
-} DLLVERSIONINFO;
-
-//
-// The caller should always GetProcAddress("DllGetVersion"), not
-// implicitly link to it.
-//
-
-typedef HRESULT(CALLBACK *DLLGETVERSIONPROC)(DLLVERSIONINFO *);
-
-/* end of shlwapi.h */
-
-/* Minimal common control library version
-Version _WIN_32IE Platform/IE
-======= ========= ===========
-4.00 0x0200 Microsoft(r) Windows 95/Windows NT 4.0
-4.70 0x0300 Microsoft(r) Internet Explorer 3.x
-4.71 0x0400 Microsoft(r) Internet Explorer 4.0
-4.72 0x0401 Microsoft(r) Internet Explorer 4.01
-...and probably going on infinitely...
-*/
-#define MIN_COMCTLMAJOR 4
-#define MIN_COMCTLMINOR 71
-#define INSTALL_NOTES "http://www.nethack.org/v340/ports/download-win.html#cc"
-/*#define COMCTL_URL
- * "http://www.microsoft.com/msdownload/ieplatform/ie/comctrlx86.asp"*/
-
-extern void FDECL(nethack_exit, (int));
-static TCHAR *_get_cmd_arg(TCHAR *pCmdLine);
-static HRESULT GetComCtlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor);
-BOOL WINAPI
-_nhapply_image_transparent(HDC hDC, int x, int y, int width, int height,
- HDC sourceDC, int s_x, int s_y, int s_width,
- int s_height, UINT cTransparent);
-
-// Global Variables:
-NHWinApp _nethack_app;
-extern int GUILaunched; /* We tell shared startup code in windmain.c
- that the GUI was launched via this */
-
-#ifdef __BORLANDC__
-#define _stricmp(s1, s2) stricmp(s1, s2)
-#define _strdup(s1) strdup(s1)
-#endif
-
-// Foward declarations of functions included in this code module:
-extern boolean FDECL(main, (int, char **));
-static void __cdecl mswin_moveloop(void *);
-
-#define MAX_CMDLINE_PARAM 255
-
-int APIENTRY
-WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
- int nCmdShow)
-{
- INITCOMMONCONTROLSEX InitCtrls;
- int argc;
- char *argv[MAX_CMDLINE_PARAM];
- size_t len;
- TCHAR *p;
- TCHAR wbuf[BUFSZ];
- char buf[BUFSZ];
-
- DWORD major, minor;
- /* OSVERSIONINFO osvi; */
-
- UNREFERENCED_PARAMETER(hPrevInstance);
- UNREFERENCED_PARAMETER(lpCmdLine);
- UNREFERENCED_PARAMETER(nCmdShow);
-
- /*
- * Get a set of valid safe windowport function
- * pointers during early startup initialization.
- *
- * When get_safe_procs is called with 0 as the param,
- * non-functional, but safe function pointers are set
- * for all windowport routines.
- *
- * When get_safe_procs is called with 1 as the param,
- * raw_print, raw_print_bold, and wait_synch, and nhgetch
- * are set to use C stdio routines via stdio_raw_print,
- * stdio_raw_print_bold, stdio_wait_synch, and
- * stdio_nhgetch.
- */
- windowprocs = *get_safe_procs(0);
-
- /*
- * Now we are going to override a couple
- * of the windowprocs functions so that
- * error messages are handled in a suitable
- * way for the graphical version.
- */
- windowprocs.win_raw_print = mswin_raw_print;
- windowprocs.win_raw_print_bold = mswin_raw_print_bold;
- windowprocs.win_wait_synch = mswin_wait_synch;
-
- win10_init();
- sys_early_init();
-
- /* init application structure */
- _nethack_app.hApp = hInstance;
- _nethack_app.hAccelTable =
- LoadAccelerators(hInstance, (LPCTSTR) IDC_NETHACKW);
- _nethack_app.hMainWnd = NULL;
- _nethack_app.hPopupWnd = NULL;
- _nethack_app.bmpTiles = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_TILES));
- if (_nethack_app.bmpTiles == NULL)
- panic("cannot load tiles bitmap");
- _nethack_app.bmpPetMark =
- LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PETMARK));
- if (_nethack_app.bmpPetMark == NULL)
- panic("cannot load pet mark bitmap");
-#ifdef USE_PILEMARK
- _nethack_app.bmpPileMark =
- LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_PILEMARK));
- if (_nethack_app.bmpPileMark == NULL)
- panic("cannot load pile mark bitmap");
-#endif
- _nethack_app.bmpRip = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_RIP));
- if (_nethack_app.bmpRip == NULL)
- panic("cannot load rip bitmap");
- _nethack_app.bmpSplash =
- LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_SPLASH));
- if (_nethack_app.bmpSplash == NULL)
- panic("cannot load splash bitmap");
- _nethack_app.bmpMapTiles = _nethack_app.bmpTiles;
- _nethack_app.mapTile_X = TILE_X;
- _nethack_app.mapTile_Y = TILE_Y;
- _nethack_app.mapTilesPerLine = TILES_PER_LINE;
-
- _nethack_app.bNoHScroll = FALSE;
- _nethack_app.bNoVScroll = FALSE;
- _nethack_app.saved_text = strdup("");
-
- _nethack_app.bAutoLayout = TRUE;
- _nethack_app.bWindowsLocked = TRUE;
-
- _nethack_app.bNoSounds = FALSE;
-
-#if 0 /* GdiTransparentBlt does not render spash bitmap for whatever reason */
- /* use system-provided TransparentBlt for Win2k+ */
- ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
- osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- GetVersionEx(&osvi);
- if (osvi.dwMajorVersion >= 5)
- _nethack_app.lpfnTransparentBlt = GdiTransparentBlt;
- else
-#endif
- _nethack_app.lpfnTransparentBlt = _nhapply_image_transparent;
-
- // init controls
- if (FAILED(GetComCtlVersion(&major, &minor))) {
- char buf[TBUFSZ];
- Sprintf(buf, "Cannot load common control library.\n%s\n%s",
- "For further information, refer to the installation notes at",
- INSTALL_NOTES);
- panic(buf);
- }
- if (major < MIN_COMCTLMAJOR
- || (major == MIN_COMCTLMAJOR && minor < MIN_COMCTLMINOR)) {
- char buf[TBUFSZ];
- Sprintf(buf, "Common control library is outdated.\n%s %d.%d\n%s\n%s",
- "NetHack requires at least version ", MIN_COMCTLMAJOR,
- MIN_COMCTLMINOR,
- "For further information, refer to the installation notes at",
- INSTALL_NOTES);
- panic(buf);
- }
- ZeroMemory(&InitCtrls, sizeof(InitCtrls));
- InitCtrls.dwSize = sizeof(InitCtrls);
- InitCtrls.dwICC = ICC_LISTVIEW_CLASSES;
- InitCommonControlsEx(&InitCtrls);
-
- /* get command line parameters */
- p = _get_cmd_arg(GetCommandLine());
- p = _get_cmd_arg(NULL); /* skip first paramter - command name */
- for (argc = 1; p && argc < MAX_CMDLINE_PARAM; argc++) {
- len = _tcslen(p);
- if (len > 0) {
- argv[argc] = _strdup(NH_W2A(p, buf, BUFSZ));
- } else {
- argv[argc] = "";
- }
- p = _get_cmd_arg(NULL);
- }
- GetModuleFileName(NULL, wbuf, BUFSZ);
- argv[0] = _strdup(NH_W2A(wbuf, buf, BUFSZ));
-
- if (argc == 2) {
- TCHAR *savefile = strdup(argv[1]);
- TCHAR *plname;
- for (p = savefile; *p && *p != '-'; p++)
- ;
- if (*p) {
- /* we found a '-' */
- plname = p + 1;
- for (p = plname; *p && *p != '.'; p++)
- ;
- if (*p) {
- if (strcmp(p + 1, "NetHack-saved-game") == 0) {
- *p = '\0';
- argv[1] = "-u";
- argv[2] = _strdup(plname);
- argc = 3;
- }
- }
- }
- free(savefile);
- }
- GUILaunched = 1;
- /* let main do the argument processing */
- (void) main(argc, argv);
- return 0;
-}
-
-PNHWinApp
-GetNHApp()
-{
- return &_nethack_app;
-}
-
-TCHAR *
-_get_cmd_arg(TCHAR *pCmdLine)
-{
- static TCHAR *pArgs = NULL;
- TCHAR *pRetArg;
- BOOL bQuoted;
-
- if (!pCmdLine && !pArgs)
- return NULL;
- if (!pArgs)
- pArgs = pCmdLine;
-
- /* skip whitespace */
- for (pRetArg = pArgs; *pRetArg && _istspace(*pRetArg);
- pRetArg = CharNext(pRetArg))
- ;
- if (!*pRetArg) {
- pArgs = NULL;
- return NULL;
- }
-
- /* check for quote */
- if (*pRetArg == TEXT('"')) {
- bQuoted = TRUE;
- pRetArg = CharNext(pRetArg);
- pArgs = _tcschr(pRetArg, TEXT('"'));
- } else {
- /* skip to whitespace */
- for (pArgs = pRetArg; *pArgs && !_istspace(*pArgs);
- pArgs = CharNext(pArgs))
- ;
- }
-
- if (pArgs && *pArgs) {
- TCHAR *p;
- p = pArgs;
- pArgs = CharNext(pArgs);
- *p = (TCHAR) 0;
- } else {
- pArgs = NULL;
- }
-
- return pRetArg;
-}
-
-/* Get the version of the Common Control library on this machine.
- Copied from the Microsoft SDK
- */
-HRESULT
-GetComCtlVersion(LPDWORD pdwMajor, LPDWORD pdwMinor)
-{
- HINSTANCE hComCtl;
- HRESULT hr = S_OK;
- DLLGETVERSIONPROC pDllGetVersion;
-
- if (IsBadWritePtr(pdwMajor, sizeof(DWORD))
- || IsBadWritePtr(pdwMinor, sizeof(DWORD)))
- return E_INVALIDARG;
- // load the DLL
- hComCtl = LoadLibrary(TEXT("comctl32.dll"));
- if (!hComCtl)
- return E_FAIL;
-
- /*
- You must get this function explicitly because earlier versions of the DLL
- don't implement this function. That makes the lack of implementation of
- the
- function a version marker in itself.
- */
- pDllGetVersion =
- (DLLGETVERSIONPROC) GetProcAddress(hComCtl, TEXT("DllGetVersion"));
- if (pDllGetVersion) {
- DLLVERSIONINFO dvi;
- ZeroMemory(&dvi, sizeof(dvi));
- dvi.cbSize = sizeof(dvi);
- hr = (*pDllGetVersion)(&dvi);
- if (SUCCEEDED(hr)) {
- *pdwMajor = dvi.dwMajorVersion;
- *pdwMinor = dvi.dwMinorVersion;
- } else {
- hr = E_FAIL;
- }
- } else {
- /*
- If GetProcAddress failed, then the DLL is a version previous to the
- one
- shipped with IE 3.x.
- */
- *pdwMajor = 4;
- *pdwMinor = 0;
- }
- FreeLibrary(hComCtl);
- return hr;
-}
-
-/* apply bitmap pointed by sourceDc transparently over
-bitmap pointed by hDC */
-BOOL WINAPI
-_nhapply_image_transparent(HDC hDC, int x, int y, int width, int height,
- HDC sourceDC, int s_x, int s_y, int s_width,
- int s_height, UINT cTransparent)
-{
- /* Don't use TransparentBlt; According to Microsoft, it contains a memory
- * leak in Window 95/98. */
- HDC hdcMem, hdcBack, hdcObject, hdcSave;
- COLORREF cColor;
- HBITMAP bmAndBack, bmAndObject, bmAndMem, bmSave;
- HBITMAP bmBackOld, bmObjectOld, bmMemOld, bmSaveOld;
-
- /* Create some DCs to hold temporary data. */
- hdcBack = CreateCompatibleDC(hDC);
- hdcObject = CreateCompatibleDC(hDC);
- hdcMem = CreateCompatibleDC(hDC);
- hdcSave = CreateCompatibleDC(hDC);
-
- /* this is bitmap for our pet image */
- bmSave = CreateCompatibleBitmap(hDC, width, height);
-
- /* Monochrome DC */
- bmAndBack = CreateBitmap(width, height, 1, 1, NULL);
- bmAndObject = CreateBitmap(width, height, 1, 1, NULL);
-
- /* resulting bitmap */
- bmAndMem = CreateCompatibleBitmap(hDC, width, height);
-
- /* Each DC must select a bitmap object to store pixel data. */
- bmBackOld = SelectObject(hdcBack, bmAndBack);
- bmObjectOld = SelectObject(hdcObject, bmAndObject);
- bmMemOld = SelectObject(hdcMem, bmAndMem);
- bmSaveOld = SelectObject(hdcSave, bmSave);
-
- /* copy source image because it is going to be overwritten */
- StretchBlt(hdcSave, 0, 0, width, height, sourceDC, s_x, s_y, s_width,
- s_height, SRCCOPY);
-
- /* Set the background color of the source DC to the color.
- contained in the parts of the bitmap that should be transparent */
- cColor = SetBkColor(hdcSave, cTransparent);
-
- /* Create the object mask for the bitmap by performing a BitBlt
- from the source bitmap to a monochrome bitmap. */
- BitBlt(hdcObject, 0, 0, width, height, hdcSave, 0, 0, SRCCOPY);
-
- /* Set the background color of the source DC back to the original
- color. */
- SetBkColor(hdcSave, cColor);
-
- /* Create the inverse of the object mask. */
- BitBlt(hdcBack, 0, 0, width, height, hdcObject, 0, 0, NOTSRCCOPY);
-
- /* Copy background to the resulting image */
- BitBlt(hdcMem, 0, 0, width, height, hDC, x, y, SRCCOPY);
-
- /* Mask out the places where the source image will be placed. */
- BitBlt(hdcMem, 0, 0, width, height, hdcObject, 0, 0, SRCAND);
-
- /* Mask out the transparent colored pixels on the source image. */
- BitBlt(hdcSave, 0, 0, width, height, hdcBack, 0, 0, SRCAND);
-
- /* XOR the source image with the beckground. */
- BitBlt(hdcMem, 0, 0, width, height, hdcSave, 0, 0, SRCPAINT);
-
- /* blt resulting image to the screen */
- BitBlt(hDC, x, y, width, height, hdcMem, 0, 0, SRCCOPY);
-
- /* cleanup */
- DeleteObject(SelectObject(hdcBack, bmBackOld));
- DeleteObject(SelectObject(hdcObject, bmObjectOld));
- DeleteObject(SelectObject(hdcMem, bmMemOld));
- DeleteObject(SelectObject(hdcSave, bmSaveOld));
-
- DeleteDC(hdcMem);
- DeleteDC(hdcBack);
- DeleteDC(hdcObject);
- DeleteDC(hdcSave);
-
- return TRUE;
-}