Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,127 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HODJNPODJ_MANKALA_BGEN_H
#define HODJNPODJ_MANKALA_BGEN_H
#include "bagel/afxwin.h"
//include "bdbg.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
//define JX_DEBUG
#define JXENTER(NAME)
#define JXELEAVE(NAME)
#define RETURN return
// the following are machine-independent definitions of the
// largest positive signed and and unsigned integers and longs
#define MAXPOSINT ((int)(((unsigned int)-1) >> 1))
#define MAXPOSLONG ((long)(((unsigned long)-1L) >> 1))
#define MAXUINT ((unsigned int)-1)
#define MAXULONG ((unsigned long)-1L)
#define MINNEGINT (-MAXPOSINT-1)
#define MINNEGLONG (-MAXPOSLONG-1)
#define DIMENSION(a) (sizeof(a) / sizeof(a[0]))
#define UPPERBOUND(a) (DIMENSION(a) - 1)
typedef char *XPSTR;
// RGB colors
#define RGBCOLOR_RED RGB(255, 0, 0)
#define RGBCOLOR_GREEN RGB( 0, 255, 0)
#define RGBCOLOR_BLUE RGB( 0, 0, 255)
#define RGBCOLOR_YELLOW RGB(255, 255, 0)
#define RGBCOLOR_MAGENTA RGB(255, 0, 255)
#define RGBCOLOR_CYAN RGB( 0, 255, 255)
#define RGBCOLOR_BLACK RGB( 0, 0, 0)
#define RGBCOLOR_GREY RGB(128, 128, 128)
#define RGBCOLOR_BROWN RGB(128, 128, 0)
#define RGBCOLOR_PURPLE RGB(128, 0, 128)
#define RGBCOLOR_AQUA RGB( 0, 128, 128)
#define RGBCOLOR_WHITE RGB(255, 255, 255)
// mouse button click types
#define CLICK_UMOVE 1
#define CLICK_LDOWN 2
#define CLICK_LMOVE 3
#define CLICK_LUP 4
#define CLICK_LDOUBLE 5
#define CLICK_RDOWN 6
#define CLICK_RMOVE 7
#define CLICK_RUP 8
#define CLICK_RDOUBLE 9
// ASCII characters
#define CCHBOF 1 /* beginning of file char (control A) */
#define CCHBKS 8 /* backspace */
#define CCHTAB 9 /* tab */
#define CCHLF 10 /* line feed - '\n' - newline */
#define CCHFF 12 /* form feed */
#define CCHCR 13 /* carriage return */
#define CCHLF 10 /* line feed */
#define CCHEOF 26 /* end of file char (control Z) */
#define CCHESC 27 /* escape */
#define CCHBL 32 /* blank */
#define CCHDIG(n) 48+n /* 48-57 */ /* digits 0-9 */
#define CCHTXL 32 /* first text character */
#define CCHTXH 127 /* last text character */
#define CCHUND 95 /* underline */
#define CCHLPR '(' /* left paren */
#define CCHRPR ')' /* right paren */
#define CCHQUO '"' /* quote */
#define CCHAPO '\'' /* apostrophe (single quote) */
#define CCHLCB '{' /* left curly bracket */
#define CCHRCB '}' /* right curly bracket */
#define CCHCOL ':'
#define CCHDOT '.'
#define CCHCTL(let) (let-'A'+1) /* control chars: A-Z */
/* old scan codes -- add 1000 to scan code from IBM PC keyboard */
#define SCANMIN 1000 /* minimum scan code */
#define SCANF(dig) (1058+dig) /* function keys: 1059-1068 */
#define SCANSF(dig) (1083+dig) /* shift function keys: 1084-1093 */
#define SCANCF(dig) (1093+dig) /* control function keys: 1094-1103 */
#define SCANAF(dig) (1103+dig) /* alt function keys: 1104-1113 */
// code to be used with Windows virtual key codes
#define CCH_ALTKEY 0x100
#define CCH_CTRLKEY 0x200
#define CCH_SHFTKEY 0x400
#define ALTKEY(ch) ((ch)+CCH_ALTKEY)
#define CTRLKEY(ch) ((ch)+CCH_CTRLKEY)
#define SHFTKEY(ch) ((ch)+CCH_SHFTKEY)
inline bool EQV(bool b1, bool b2) {
return (b1 != 0) == (b2 != 0);
}
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel
#endif

View File

@@ -0,0 +1,155 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
#include "bagel/hodjnpodj/mankala/bgenut.h"
#include "bagel/hodjnpodj/hodjnpodj.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
///DEFS bgenut.h
//* CGenUtil::RandomInteger -- find random integer in specified range
int CGenUtil::RandomInteger(int iLow, int iHigh)
// iLow, iHigh -- range
// returns: integer which is ge iLow and le iHigh.
{
JXENTER(CGenUtil::RandomInteger) ;
int iRetval = 0; // integer return value
// for first call, initialize the random number generator
if (!m_bRandomInit) {
//srand((unsigned) time(&tTime)), m_bRandomInit = true ;
// Note: since brand() returns a value uniform in [0, 2^15-1], the
// following method, though simple, gives a slight preference
// to lower numbers. Might be worth fixing sometime.
if (iLow < iHigh) // if there's a valid range
iRetval = iLow + (brand() % (iHigh - iLow + 1)) ; // compute value
else // invalid args
iRetval = iLow ;
}
JXELEAVE(CGenUtil::RandomInteger) ;
return iRetval;
}
//* CGenUtil::RandomEvent -- return true with specified probability
bool CGenUtil::RandomEvent(int iNum, int iDenom)
// iNum / iDenom -- numerator and denominator of probability
// returns: true with probability iNum / iDenom, false otherwise
{
JXENTER(CGenUtil::RandomEvent) ;
//int iError = 0 ;
bool bRetval ; // return value
bRetval = (iNum >= 1 + (brand() % iDenom)) ;
JXELEAVE(CGenUtil::RandomEvent) ;
return bRetval;
}
//* CGenUtil::RandomPermutation -- generate a random permutation
// Generates a permutation of size iSize of the
// integers from 0 to (iNum-1)
void CGenUtil::RandomPermutation(int iNum,
int iSize, int *xpIntOut)
// iNum -- number of numbers in permutation
// iSize -- size of output array
// xpIntOut -- pointer to output array (size is iSize)
{
//int iError = 0 ;
int *xpInt ; // array pointer variable
int iI, iJ, iK ; // loop variables
int iRanVal ; // random value to make a choice
bool bDup ; // duplicate found flag
JXENTER(CGenUtil::RandomPermutation) ;
if (iSize > iNum) // can't handle more array than # of numbers
iSize = iNum ;
for (iI = 0 ; iI < iSize ; ++iI) { // count numbers
iRanVal = RandomInteger(0, iNum - iI - 1) ;
// get random number in interval
for (iJ = 0 ; iJ < iNum && iRanVal >= 0 ; ++iJ) {
bDup = false ; // not a duplicate yet
for (xpInt = xpIntOut, iK = 0 ; iK < iI ; ++iK, ++xpInt)
if (*xpInt == iJ)
bDup = true ;
if (!bDup && iRanVal-- == 0) // if not a duplicate
// and we've counted down the random integer
*xpInt = iJ ; // store into array
}
}
JXELEAVE(CGenUtil::RandomPermutation) ;
}
//* CGenUtil::NormalizeCRect --
bool CGenUtil::NormalizeCRect(CRect& cRect)
// cRect -- rectangle to be normalized
// returns: true if error, false otherwise
{
JXENTER(CGenUtil::NormalizeCRect) ;
int iError = 0 ; // error code
int iSwap ;
if ((iSwap = cRect.left) > cRect.right)
cRect.left = cRect.right, cRect.right = iSwap ;
if ((iSwap = cRect.top) > cRect.bottom)
cRect.top = cRect.bottom, cRect.bottom = iSwap ;
// cleanup:
JXELEAVE(CGenUtil::NormalizeCRect) ;
RETURN(iError != 0) ;
}
//* CGenUtil::RandomSelection -- random selection of integer array
void CGenUtil::RandomSelection(int *xpiArray, int iNum,
int iSize)
// xpiArray (input/output) -- array of integers to make selection from
// iNum -- number of numbers in array
// iSize -- number of integers in desired selection
{
JXENTER(CGenUtil::RandomSelection) ;
int *xpiPermutation = new int[iSize] ;
int iK ;
RandomPermutation(iNum, iSize, xpiPermutation) ;
for (iK = 0 ; iK < iSize ; ++iK)
xpiPermutation[iK] = xpiArray[xpiPermutation[iK]] ;
for (iK = 0 ; iK < iSize ; ++iK)
xpiArray[iK] = xpiPermutation[iK] ;
if (xpiPermutation)
delete [] xpiPermutation ;
JXELEAVE(CGenUtil::RandomSelection) ;
}
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel

View File

@@ -0,0 +1,68 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General public: License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General public: License for more details.
*
* You should have received a copy of the GNU General public: License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HODJNPODJ_MANKALA_BGENUT_H
#define HODJNPODJ_MANKALA_BGENUT_H
#include "bagel/afxwin.h"
#include "bagel/hodjnpodj/mankala/bgen.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
// class CGenUtil -- general utilities
class CGenUtil {
bool m_bRandomInit = 0; // random number seed initialized
public:
CGenUtil() {}
// bgenut.cpp -- Boffo Games general utilities
//- RandomInteger -- find random integer in specified range
public:
int RandomInteger(int iLow, int iHigh) ;
//- RandomEvent -- return true with specified probability
public:
bool RandomEvent(int iNum, int iDenom) ;
//- RandomPermutation -- generate a random permutation
// Generates a permutation of size iSize of the
// integers from 0 to (iNum-1)
public:
void RandomPermutation(int iNum,
int iSize, int *xpIntOut) ;
//- NormalizeCRect --
public:
bool PASCAL NormalizeCRect(CRect& cRect) ;
//- RandomSelection -- random selection of integer array
public:
void RandomSelection(int *xpiArray, int iNum,
int iSize) ;
} ;
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel
#endif

View File

@@ -0,0 +1,87 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
#include "bagel/hodjnpodj/mankala/bgen.h"
#include "bagel/hodjnpodj/mankala/btimeut.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
bool bTimeDelayPassed = true ;
//* CTimeUtil::DelayMs -- delay for specified # of milliseconds
bool CTimeUtil::DelayMs(unsigned int uMs)
// uMs -- number of milliseconds to delay
// returns: true if error, false otherwise
{
JXENTER(CTimeUtil::DelayMs) ;
int iError = 0 ; // error code
unsigned int uTimerId ; // timer id returned by SetTimer
// MSG FAR * lpMsg ; // message area storage
// RETURN(false) ; // ***************
if (!(uTimerId = SetTimer(nullptr, 0, uMs, DelayMsCallback)))
// set timer, and test for success
{
iError = 100 ; // SetTimer failed
goto cleanup ;
}
bTimeDelayPassed = false ; // time hasn't passed yet
while (!bTimeDelayPassed) // loop until flag gets set again
DoPendingEvents() ;
if (!KillTimer(nullptr, uTimerId)) { // kill timer and test success
iError = 101 ; // KillTimer failed
goto cleanup ;
}
cleanup:
JXELEAVE(CTimeUtil::DelayMs) ;
RETURN(iError != 0) ;
}
void CTimeUtil::DelayMsCallback(HWND hWnd, unsigned int uMsg,
uintptr uTimerId, uint32 dwTime) {
JXENTER(::DelayMsCallback) ;
//int iError = 0 ; // error code
bTimeDelayPassed = true ; // elapsed time passed
JXELEAVE(::DelayMsCallback) ;
}
void DoPendingEvents() {
MSG msg;
while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel

View File

@@ -0,0 +1,49 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HODJNPODJ_MANKALA_BTIMEUT_H
#define HODJNPODJ_MANKALA_BTIMEUT_H
#include "bagel/hodjnpodj/mankala/bgen.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
void DoPendingEvents() ;
// class CTimeUtil -- general utilities
class CTimeUtil {
private:
//- DelayMs -- delay for specified # of milliseconds
bool DelayMs(unsigned int uMs) ;
static void DelayMsCallback(HWND /* hWnd */,
unsigned int /* uMsg */, uintptr /* uTimerId */, uint32 /* dwTime */) ;
};
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel
#endif

View File

@@ -0,0 +1,113 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/afxwin.h"
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
#include "bagel/hodjnpodj/globals.h"
#include "bagel/hodjnpodj/mankala/mnk.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
HINSTANCE hDLLInst;
HINSTANCE hExeInst;
extern LPGAMESTRUCT pGameParams;
// global the pointer to the your game's main window
HWND ghParentWnd;
/////////////////////////////////////////////////////////////////////////////
// Public C interface
/*****************************************************************
*
* RunNoVa
*
* FUNCTIONAL DESCRIPTION:
*
* This is the API function for the DLL. It is what the calling app
* calls to invoke poker
*
* FORMAL PARAMETERS:
*
* hParentWnd, lpGameInfo
*
* IMPLICIT INPUT PARAMETERS:
*
* n/a
*
* IMPLICIT OUTPUT PARAMETERS:
*
* n/a
*
* RETURN VALUE:
*
* n/a
*
****************************************************************/
HWND FAR PASCAL RunMank(HWND hParentWnd, LPGAMESTRUCT lpGameInfo) {
CMnkWindow *pMain;
pGameParams = lpGameInfo;
// invoke your game here by creating a pGame for your main window
// look at the InitInstance for your game for this
ghParentWnd = hParentWnd;
#undef _MEM_LEAK_TEST
#ifndef _MEM_LEAK_TEST
if ((pMain = new CMnkWindow) != nullptr) {
pMain->ShowWindow(SW_SHOWNORMAL);
pMain->UpdateWindow();
pMain->Setm_bJustStarted(false);
pMain->SetActiveWindow();
if (!pGameParams->bPlayingMetagame) {
MFC::PostMessage(pMain->m_hWnd, WM_COMMAND, IDC_SCROLL, BN_CLICKED); // Activate the Options dialog
} else { //kick in game by posting mouse messages in the new-game-button area.
MFC::PostMessage(pMain->m_hWnd, WM_LBUTTONDOWN, 0X00, MAKELPARAM(NEWGAME_LOCATION_X + NEWGAME_WIDTH / 2, NEWGAME_LOCATION_Y + NEWGAME_HEIGHT / 2));
MFC::PostMessage(pMain->m_hWnd, WM_LBUTTONUP, 0X00, MAKELPARAM(NEWGAME_LOCATION_X + NEWGAME_WIDTH / 2, NEWGAME_LOCATION_Y + NEWGAME_HEIGHT / 2));
}
}
// these must be set in this function
hDLLInst = (HINSTANCE)GetWindowWord(pMain->m_hWnd, GWW_HINSTANCE);
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
return pMain->m_hWnd; // return the m_hWnd of your main game window
#else
hDLLInst = nullptr;
hExeInst = (HINSTANCE)GetWindowWord(hParentWnd, GWW_HINSTANCE);
return (HWND)nullptr;
#endif
}
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel

View File

@@ -0,0 +1,37 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HODJNPODJ_MANKALA_GAMEDLL_H
#define HODJNPODJ_MANKALA_GAMEDLL_H
#include "bagel/hodjnpodj/hnplibs/gamedll.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
extern HWND FAR PASCAL RunMank(HWND hParentWnd, LPGAMESTRUCT lpGameInfo);
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,564 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HODJNPODJ_MANKALA_MNK_H
#define HODJNPODJ_MANKALA_MNK_H
#include "common/serializer.h"
#include "bagel/hodjnpodj/globals.h"
#include "bagel/hodjnpodj/hnplibs/dibdoc.h"
#include "bagel/hodjnpodj/hnplibs/sprite.h"
#include "bagel/hodjnpodj/hnplibs/bitmaps.h"
#include "bagel/boflib/sound.h"
#include "bagel/hodjnpodj/mankala/bgen.h"
#include "bagel/hodjnpodj/mankala/bgenut.h"
#include "bagel/hodjnpodj/mankala/btimeut.h"
#include "bagel/hodjnpodj/mankala/mnkopt.h"
#include "bagel/hodjnpodj/mankala/resource.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
// DATADIR is directory for *.BMP and other data files
// #define DATADIR ".".\\"
#define DATADIR "art\\"
// const XPSTR MNKSCREEN = DATADIR "mancrab.bmp" ; // bitmap file for screen
const int MAXMOVES = 100 ; // max # moves is 100
const int NUMPITS = 6 ; // # pits each player has
const int NUMPLAYERS = 2 ; // # players
const int TOTALPITS = NUMPLAYERS * NUMPITS ; // total # pits
// (not including home bins)
const int HANDINDEX = -2, HOMEINDEX = -1 ;
const int MAXDISPPIT = 8, MAXDISPHOME = 22, MAXDISPHAND = MAXPOSINT ;
// max # of stones that can be displayed discretely
// values in user dialogs
//const int MINSTONES = 1, MAXSTONES = 12 ;
//const int MINSTRENGTH = 1, MAXSTRENGTH = 5 ;
const int MINSTONES = 3, MAXSTONES = 7 ;
const int MINSTRENGTH = 1, MAXSTRENGTH = 4 ;
const int MAXTABLESTONES = 12 ; // configurations in best win table
const unsigned long MAXCONFIGS = 3000000L ; // # configurations in table
const int BESTWINBITS = 5 ; // # bits per best win table entry
const int TABLEUNDEF = (-16 + 32) ; // value of undefined table entry
const int BESTWINUNDEF = -1000 ; // value of undefined minimax value
// bitmap object types
#define BMT_MAIN 200
#define BMT_STONE 201
#define BMT_PIT 202
#define BMT_LEFTBIN 203
#define BMT_RIGHTBIN 204
#define BMT_SIGN 205
#define BMT_HAND 206
#define BMT_SCROLL 207
// sign bitmap numbers
#define SBT_CRAB 1
#define SBT_MYTURN 2
#define SBT_YOURTURN 3
#define SBT_TIE 4
#define SBT_IWIN 5
#define SBT_YOUWIN 6
#define IDC_SCROLL 419
#define RULES ".\\mankala.txt"
#define RULES_NARRATION ".\\sound\\mankala.wav"
#define IGO3 ".\\sound\\igo3.wav"
#define YOUGO3 ".\\sound\\yougo3.wav"
#define GOAGAIN ".\\sound\\goagain.wav"
#define IGOAGAIN ".\\sound\\igoagain.wav"
#define PICKUP ".\\sound\\pickup.wav"
#define ONESHELL ".\\sound\\oneshell.wav"
#define INK ".\\sound\\ink.wav"
#define BROCHURE ".\\sound\\brochure.wav"
#define ARMCHAIR ".\\sound\\armchair.wav"
#define FISHHOOK ".\\sound\\fishhook.wav"
#define PAILS ".\\sound\\pails.wav"
#define NETSHELL ".\\sound\\netshell.wav"
#define WHEEL ".\\sound\\wheel.wav"
#define HONK ".\\sound\\honk.wav"
#define POP ".\\sound\\pop.wav"
#define INFLATE ".\\sound\\inflate.wav"
#define SOSORRY ".\\sound\\sosorry.wav"
#define FANFARE2 ".\\sound\\fanfare2.wav"
#define MIDI_BCKGND ".\\sound\\mankala.mid"
#define GLOBE_SPRITE ".\\art\\globe2.bmp"
#define CHAIR_SPRITE ".\\art\\chair.bmp"
//inline int OTHERPLAYER(int iPlayer) {return(NUMPLAYERS - 1 - iPlayer) ; }
#define OTHERPLAYER(iPlayer) (NUMPLAYERS - 1 - iPlayer)
#define MAXRECURSION 3
#define MAXMOVES 25
typedef struct {
int iFree[NUMPITS][MAXRECURSION];
int iCapture[NUMPITS][MAXRECURSION];
int iRocksInHomeBin;
int iPitSequence[MAXRECURSION];
int iNumRocks[NUMPITS];
int iNumRocksOpposite[NUMPITS];
signed char cRecursion;
int iParentID;
signed char cMoveID;
int iMoveID;
} MOVE, *PMOVE, *LPMOVE, *NPMOVE;
// CBmpTable -- table of bitmap filenames
class CBmpTable {
public:
int m_iBmpType; // BMT_xxxx
int m_iNumStones; // 0 means "many"
int m_iNumBmps; // number of bmp files for this combo
const char *m_xpszFilenameString; // sprintf string
bool m_bSubNumStones;
bool m_bMasked; // mask white areas of bitmap
} ;
// CBmpObject -- bitmap object
class CBmpObject {
friend class CMnk ;
friend class CMnkWindow ;
CBmpObject *m_xpcNextFree = nullptr; // pointer to next in chain to free
bool m_bChained = false, m_bHeap = false; // on NextFree chain / on heap
CBmpObject *m_xpcNext = nullptr; // pointer to next in chain
bool m_bDummy = false; // dummy object -- no bitmap
bool m_bMasked = false; // mask white areas of bitmap
class CPitWnd *m_xpcPit = nullptr; // ptr to pit, for pit/bin types
bool m_bInit = false; // flag: object is initialized
int m_iBmpType = 0; // BMT_xxxx -- bitmap type
int m_iBmpArg = 0;
int m_iBmpNum = 0;
int m_iStoneNum = 0; // for type BMT_STONE
bool m_bSprite = false; // flag: use sprite, not DIB
CSprite *m_xpcSprite = nullptr; // if this is a sprite, store path
// there rather than in DIB
CDibDoc *m_xpDibDoc = nullptr; // DIB document
HDIB m_lpDib = nullptr; // pointer to bitmap memory
CPoint m_cPosition; // position to paint bitmap
CSize m_cSize; // size of bitmap
} ;
// CMove -- position/move class
class CMove {
friend class CMnk ;
friend class CMnkWindow ;
bool m_bRealMove = false; // this is CMove object for real board position
// number of stones in each pit, prior to sowing
int m_iNumStones[NUMPLAYERS][NUMPITS + 2] = {};
int m_iPlayer = 0; // player on the move
int m_iTotalStones = 0; // total stones in pits (not home bins)
long m_lConfigIndex = 0; // configuration index for position
int m_iValues[NUMPITS] = {}; // value of each move
int m_iBestWinValue = 0; // best value found
int m_iBestMove = 0; // best move
class CPit *m_xpcPit = nullptr; // ptr to pit being sowed
bool m_bFreeTurn = false; // player got free turn
bool m_bCapture = false; // capture occurred
int m_iCapturePit = 0; // # of opponent's pit that got captured
bool m_bHasCapture = false; // has a capture from here
bool m_bHasFree = false; // has free move from here
int m_iNumMoves = 0; // number of legal moves
// methods to zero or copy CMove objects
void Zero() {
m_bRealMove = false;
Common::fill(&m_iNumStones[0][0], &m_iNumStones[0][0] + NUMPLAYERS * (NUMPITS + 2), 0);
m_iPlayer = 0;
m_iTotalStones = 0;
m_lConfigIndex = 0;
Common::fill(m_iValues, m_iValues + NUMPITS, 0);
m_iBestWinValue = 0;
m_iBestMove = 0;
m_xpcPit = nullptr;
m_bFreeTurn = false;
m_bCapture = false;
m_iCapturePit = 0;
m_bHasCapture = false;
m_bHasFree = false;
m_iNumMoves = 0;
}
void Copy(CMove *xpcMove) {
*this = *xpcMove;
m_bRealMove = false;
}
} ;
// CPit -- class for pit (as well as home bin and hand)
class CPit {
friend class CMnk ;
public:
int m_iNumStones = 0, m_iDispStones = 0, m_iDispMax = 0;
int m_iPlayer = 0, m_iPit = 0; // player #, pit #
}; // CPit
// CMnk -- Mankala game class
class CMnk {
private:
friend class CMnkWindow ;
CGenUtil m_cGenUtil ; // general utility object
CTimeUtil m_cTimeUtil ; // time utility object
bool m_bStartGame = false; // just starting game
bool m_bGameOver = false; // game is over
bool m_bGameOverMusicPlayed = false; // music played when game is over
int m_iTableStones = 0; // number of stones in data table
long m_lNumConfigs = 0; // # configs in best win table
long m_lTableSize = 0; // size of best win table
bool m_bInitData = false; // flag: initialize data tables
class CMnkData FAR *m_lpCMnkData = nullptr; // pointer to data tables
CSound *m_pSound = nullptr;
// XPVOID m_cWnd ; // mankala window
// int m_iPlayer ; // Next player: 0=player 1, 1=player 2
int m_iStartStones = 0; // #stones per pit at start
bool m_bComputer[NUMPLAYERS] = {}; // flag: player is
// computer (vs human)
class CPit *m_xpcPits[NUMPLAYERS][NUMPITS + 2] = {};
int m_iMaxDepth[NUMPLAYERS] = {}, m_iCurrentMaxDepth = 0;
// max minimax depth
int m_iCapDepth[NUMPLAYERS] = {}, m_iCurrentCapDepth = 0;
// minimax capture depth
int m_iNumberMoves = 0; // #moves played so far
class CMove m_cCurrentMove; // current position/move
class CMove m_cMoveList[MAXMOVES]; // move list
enum enum_Level {LEV_NONE, LEV_RANDOM,
LEV_LOWEST, LEV_HIGHEST, LEV_EVAL, LEV_MINIMAX
}
m_eLevel[NUMPLAYERS] = {}; // level of computer play
bool m_bDumpPopulate = false,
m_bDumpMoves = false,
m_bDumpTree = false; // dump options
private:
/**
* Read save file with best win table
* @returns true if error, false otherwise
*/
bool ReadTableFile();
/**
* Write out save file with best win table
* @returns true if error, false otherwise
*/
bool WriteTableFile();
public:
// mnklog.cpp -- Mankala game logic
//- InitMankala -- initialize a new game of Mankala
private: bool InitMankala() ;
//- Move -- make a move
private: bool Move(CPit * xpcSowPit, CMove * xpcMove PDFT(nullptr)) ;
//- MoveStone -- move one stone for move
public: bool MoveStone(CMove * xpcMove,
CPit * xpcFromPit, CPit * xpcToPit) ;
//- InitData -- initialize data class object
private: bool InitData(bool bInit PDFT(true)) ;
//- CountConfigurations -- set up Configurations table
bool CountConfigurations() ;
//- PopulateTable -- compute values for best win table
private: bool PopulateTable() ;
//- MapConfiguration -- map a configuration to its integer index,
// store configuration index into Move object
bool MapConfiguration(CMove * xpcMove) ;
//- UnmapConfiguration -- map configuration index back
// to configuration
bool UnmapConfiguration(CMove * xpcMove) ;
//- SearchMove -- search for best move
private: bool SearchMove(CMove * xpcMove, int &iMove) ;
//- Minimax -- find best move from supplied configuration
bool Minimax(CMove * xpcMove, int iDepth PDFT(0)) ;
//- StaticEvaluation -- determine static value of a position
bool StaticEvaluation(CMove * xpcMove) ;
//- CountStones -- count total stones in configuration
bool CountStones(CMove * xpcMove) ;
//- GetBestWinCount -- get position value in best win table
private: bool GetBestWinCount(CMove * xpcMove) ;
//- SetBestWinCount -- set value in best win table
private: bool SetBestWinCount(CMove * xpcMove) ;
//- DumpPosition -- dump contents of CMove object
bool DumpPosition(CMove * xpcMove) ;
//- DumpBestWinTable -- dump fields of best win table
bool DumpBestWinTable(long lLow PDFT(0),
long lHigh PDFT(6 * 24 - 1)) ;
bool AggressiveStaticEvaluation(CMove* xpcMove);
bool DefensiveStaticEvaluation(CMove*);
bool TreeAlgo(CMove*);
} ; // CMnk
// FIVE structure -- used for addressing values in best win array
#pragma pack(1) // byte alignment
struct FIVE {
unsigned char v0: 5, // 0:0-4
v1a: 3, v1b: 2, // 0:5-7, 1:0-1
v2: 5, // 1:2-6
v3a: 1, v3b: 4, // 1:7, 2:0-3
v4a: 4, v4b: 1, // 2:4-7, 3:0
v5: 5, // 3:1-5
v6a: 2, v6b: 3, // 3:6-7, 4:0-2
v7: 5 ; // 4:3-7
// unsigned int v0:5, v1:5, v2:5, v3:5, v4:5, v5:5, v6:5, v7:5 ;
} ;
#pragma pack() // revert to compiler default
// CFileHeader -- file header for data file
class CFileHeader {
friend class CMnk;
char m_szText[80] = {}; // descriptive text
int m_iHeaderSize = 0; // size of header (# bytes)
int m_iVersion = 0; // version number
int m_iTableStones = 0; // # stones in stored best win table
long m_lTableSize = 0; // length of stored best win table
void sync(Common::Serializer &s);
};
// class CMnkData -- mankala data - this class used for move analysis
typedef class FAR CMnkData {
friend class CMnk ;
CFileHeader m_cFileHeader ; // file header for data file
long m_NX[MAXTABLESTONES + 1][TOTALPITS + 1] = {},
m_NA[MAXTABLESTONES + 1][TOTALPITS + 1] = {};
// NX[s,p] contains the number of arrangements of
// exactly s stones into p pits. NA[s,p] contains the
// number of arrangements of s or fewer stones into
// p pits.
HGLOBAL m_hBestWin = nullptr; // Windows handle for best win table
byte *m_hpcBestWin = nullptr; // pointer to array
// of 5 bit values. The subscripts are integers
// 0 <= subscript <= NUMCONFIGS, and the array element
// specifies the number of stones (-15 to +15, with -16
// representing an unknown value) that can be won from
// this configuration with best play.
} class_CMnkData, *HPCMNKDATA;
#define SPRITE_COUNT 15 // maximum sprites to be displayed
#define BUMPER_COUNT 5 // number of bumper sprites to display
#define SPRITE_TIMER 50 // identifier for sprite timer
#define SPRITE_INTERVAL 10 // time interval between sprite updates
#define SPRITE_GENERATE 30 // number of updates per sprite creation
// Button Identifier codes (BIDs)
#define IDC_QUIT 500
#define IDC_OKAY 501
// Button positioning constants
#define QUIT_BUTTON_WIDTH 50
#define QUIT_BUTTON_HEIGHT 20
#define QUIT_BUTTON_OFFSET_X 10
#define QUIT_BUTTON_OFFSET_Y 10
#define OKAY_BUTTON_WIDTH 63
#define OKAY_BUTTON_HEIGHT 39
#define OKAY_BUTTON_OFFSET_X 10
#define OKAY_BUTTON_OFFSET_Y 10
// CPitWnd -- display class for pit (as well as home bin and hand)
class CPitWnd : public CPit {
friend class CMnkWindow ;
CBmpObject *m_xpcStoneChain = nullptr; // chain header for stone displays
CBmpObject m_cBmpObject ; // current bitmap object for pit with stones
};
/////////////////////////////////////////////////////////
// CMnkWindow:
class CMnkWindow : public CFrameWnd, public CMnk {
bool bPlayedGameOnce = false;
bool m_bJustStarted = false; // flag to indicate beginning of game.
bool m_bGameWon = false; // flag to indicate game result.
bool m_bRulesActive = false; // flag to indicate the unfurled status of the rules scroll.
// ...this flag is set only when rules are invoked via the F1 key.
bool m_bScoresDisplayed = false; // to indicate that the Score has been displayed at the end of game,
// ... and should pop up again.
CText *m_pText = nullptr;
CBmpObject m_cBmpMain ; // bitmap object for main window
CPalette *m_xpGamePalette = nullptr, *m_xpOldPalette = nullptr; // game pallet
CBmpObject *m_xpFreeStoneChain = nullptr; // chain of unused stone sprites
CBmpObject *m_xpcBmpFreeChain = nullptr; // chain of objects to be freed
CBmpObject m_cBmpScroll; // options scroll bitmap object
bool m_bInMenu = false; // within options menu
bool m_bPlaySound = false;
char m_szDataDirectory[100] = {}; // directory for data files
CRect m_cMainRect, // screen area spanned by the game window
m_cQuitRect, // window area spanned by the QUIT button
m_cOkayRect ; // window area spanned by the OKAY button
class CPitWnd *m_xpcPits[NUMPLAYERS][NUMPITS + 2] = {};
// pointers to pit classes for pits, home bins,
// and hands
CBmpObject m_cBmpCrab ; // bitmap object for crab with no sign
CBmpObject m_cBmpSign ; // bitmap object for crab sign
int m_iBmpSign = 0; // SBT_xxxx -- which sign crab displays
// mnk.cpp -- Mankala game -- Windows interface
//- CMnkWindow() -- mankala window constructor function
public: CMnkWindow() ;
//- ~CMnkWindow -- Mankala window destructor function
public: ~CMnkWindow() ;
// mnkui.cpp -- Mankala game -- user interface
//- StartGame -- start a new game
private: bool StartGame() ;
//- PaintBitmapObject -- paint bitmap
private: bool PaintBitmapObject(CBmpObject * xpcBmpObject,
int iBmpType PDFT(0), int iBmpArg PDFT(0)) ;
//- InitBitmapObject -- set up DibDoc in bitmap object
private: bool InitBitmapObject(CBmpObject * xpcBmpObject) ;
//- InitBitmapFilename -- set up filename bitmap object
private: bool InitBitmapFilename(CBmpObject * xpcBmpObject) ;
//- SetBitmapCoordinates -- set coordinates of bitmap
private: bool SetBitmapCoordinates(
CBmpObject * xpcBmpObject) ;
//- AcceptClick -- process a mouse click by user
bool AcceptClick(CPoint cClickPoint) ;
//- MoveStoneDisplay -- move a stone from pit to another
public: bool MoveStoneDisplay(CPitWnd * xpcFromPit,
CPitWnd * xpcToPit) ;
//- AdjustPitDisplay -- adjust display of pit when
// number of stones changes
private: bool AdjustPitDisplay(CPitWnd * xpcPit,
bool bForcePaint PDFT(false)) ;
//- PaintScreen -- paint screen for mankala game
private: void PaintScreen() ;
//- ProcessDc -- handle processing of device context
private: bool ProcessDc(bool bAlloc PDFT(true)) ;
//- AllocatePits -- allocate pits (including home bin/hand)
bool AllocatePits() ;
//- SetCrabSign -- to my/your turn
private: bool SetCrabSign(bool bPaint PDFT(true)) ;
//- FreePitResources -- free (optionally delete) all pit
// resources -- stone sprites and pit bitmaps
private: bool FreePitResources(bool bDelete PDFT(false)) ;
//- ClearBitmapObject -- release bitmap object
private: bool ClearBitmapObject(CBmpObject * xpcBmpObject) ;
//- ReleaseResources -- release all resources before term
public: void ReleaseResources() ;
//- DebugDialog -- put up debugging dialog box
private: bool DebugDialog() ;
public: void Setm_bJustStarted(bool U) {
m_bJustStarted = U; //- UserDialog -- put up user dialog box
}
public: bool FAR PASCAL UserDialog() ;
//- OptionsDialog -- call options dialog
private: bool OptionsDialog() ;
//private: bool CALLBACK ResetPitsDlgProc(HWND, unsigned int, WPARAM, LPARAM);
// CMnkWindow();
//
//
// void SplashScreen();
//
// static void ReleaseResources();
// static void FlushInputEvents();
//
//private:
//public:
// static void BuildSprites(CDC *pDC);
// static void ProcessSprites(CDC *pDC);
// static void MoveSprite(CDC *pDC,CSprite *pSprite);
protected:
virtual bool OnCommand(WPARAM wParam, LPARAM lParam) override;
virtual LRESULT OnMCINotify(WPARAM W, LPARAM L);
virtual LRESULT OnMMIONotify(WPARAM W, LPARAM L);
//{{AFX_MSG( CMnkWindow )
afx_msg void OnPaint();
afx_msg void OnLButtonDown(unsigned int, CPoint);
afx_msg void OnLButtonUp(unsigned int, CPoint);
afx_msg void OnLButtonDblClk(unsigned int, CPoint);
afx_msg void OnMButtonDown(unsigned int, CPoint);
afx_msg void OnMButtonUp(unsigned int, CPoint);
afx_msg void OnMButtonDblClk(unsigned int, CPoint);
afx_msg void OnRButtonDown(unsigned int, CPoint);
afx_msg void OnRButtonUp(unsigned int, CPoint);
afx_msg void OnRButtonDblClk(unsigned int, CPoint);
afx_msg void OnMouseMove(unsigned int nFlags, CPoint point);
afx_msg void OnChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
afx_msg void OnSysChar(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
afx_msg void OnTimer(uintptr nIDEvent);
afx_msg void OnClose();
afx_msg void OnKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
afx_msg void OnSysKeyDown(unsigned int nChar, unsigned int nRepCnt, unsigned int nFlags);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
} ;
///////////////////////////////////////////////////////
// CMnkApp:
//
class CMnkApp : public CWinApp {
CMnkWindow *m_xpcMnkWindow ;
public:
bool InitInstance();
int ExitInstance();
} ;
///////////////////////////////////////////////
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,365 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "bagel/hodjnpodj/hnplibs/stdafx.h"
#include "bagel/hodjnpodj/hnplibs/text.h"
#include "bagel/hodjnpodj/mankala/mnk.h"
#include "bagel/hodjnpodj/mankala/mnkopt.h"
#include "bagel/hodjnpodj/hnplibs/button.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
static CColorButton *pOKButton = nullptr; // OKAY button on scroll
static CColorButton *pCancelButton = nullptr; // Cancel button on scroll
CText *m_pShellText = nullptr;
CText *m_pStrengthText = nullptr;
/////////////////////////////////////////////////////////////////////////////
// CMnkOpt dialog
CMnkOpt::CMnkOpt(CWnd* pParent /*=nullptr*/)
: CDialog(CMnkOpt::IDD, pParent) {
//{{AFX_DATA_INIT(CMnkOpt)
m_iLevel0 = -1;
m_iLevel1 = -1;
m_iPlayer0 = -1;
m_iPlayer1 = -1;
m_iStartStones = 0;
m_iTableStones = 0;
m_bInitData = false;
m_iMaxDepth0 = 0;
m_iMaxDepth1 = 0;
m_bDumpMoves = false;
m_bDumpPopulate = false;
m_bDumpTree = false;
m_iCapDepth0 = 0;
m_iCapDepth1 = 0;
//}}AFX_DATA_INIT
}
CMnkOpt::~CMnkOpt() {
}
void CMnkOpt::DoDataExchange(CDataExchange* pDX) {
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMnkOpt)
DDX_Radio(pDX, IDC_ALG_0, m_iLevel0);
DDX_Radio(pDX, IDC_ALG_1, m_iLevel1);
DDX_Radio(pDX, IDC_PLAY_0, m_iPlayer0);
DDX_Radio(pDX, IDC_PLAY_1, m_iPlayer1);
DDX_Text(pDX, IDC_STARTSTONES, m_iStartStones);
DDV_MinMaxInt(pDX, m_iStartStones, 1, 12);
DDX_Text(pDX, IDC_TABLESTONES, m_iTableStones);
DDV_MinMaxInt(pDX, m_iTableStones, 0, 12);
DDX_Check(pDX, IDC_INITDATA, m_bInitData);
DDX_Text(pDX, IDC_MAXDEPTH0, m_iMaxDepth0);
DDV_MinMaxInt(pDX, m_iMaxDepth0, 0, 30);
DDX_Text(pDX, IDC_MAXDEPTH1, m_iMaxDepth1);
DDV_MinMaxInt(pDX, m_iMaxDepth1, 0, 30);
DDX_Check(pDX, IDC_DUMPMOVES, m_bDumpMoves);
DDX_Check(pDX, IDC_DUMPPOP, m_bDumpPopulate);
DDX_Check(pDX, IDC_DUMPTREE, m_bDumpTree);
DDX_Text(pDX, IDC_CAPDEPTH0, m_iCapDepth0);
DDV_MinMaxInt(pDX, m_iCapDepth0, 0, 30);
DDX_Text(pDX, IDC_CAPDEPTH1, m_iCapDepth1);
DDV_MinMaxInt(pDX, m_iCapDepth1, 0, 30);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMnkOpt, CDialog)
//{{AFX_MSG_MAP(CMnkOpt)
// NOTE: the ClassWizard will add message map macros here
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMnkOpt message handlers
/////////////////////////////////////////////////////////////////////////////
// CMnkUsr dialog
CMnkUsr::CMnkUsr(CWnd *xpParent, CPalette *xpPalette, unsigned int nID)
: CBmpDialog(xpParent, xpPalette, nID, ".\\ART\\SSCROLL.BMP") {
//{{AFX_DATA_INIT(CMnkUsr)
m_iUShells = 0;
m_iUStrength = 0;
//}}AFX_DATA_INIT
m_xpGamePalette = xpPalette;
// DoModal();
}
CMnkUsr::~CMnkUsr() {
if (m_pShellText != nullptr)
delete m_pShellText;
if (m_pStrengthText != nullptr)
delete m_pStrengthText;
}
void CMnkUsr::DoDataExchange(CDataExchange* pDX) {
CBmpDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMnkUsr)
// DDX_Text(pDX, IDC_USHELLS, m_iUShells);
// DDV_MinMaxInt(pDX, m_iUShells, 1, 12);
// DDX_Text(pDX, IDC_USTRENGTH, m_iUStrength);
// DDV_MinMaxInt(pDX, m_iUStrength, 1, 5);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMnkUsr, CBmpDialog)
//{{AFX_MSG_MAP(CMnkUsr)
ON_WM_HSCROLL()
ON_WM_PAINT()
// ON_EN_KILLFOCUS(IDC_USHELLS, OnKillfocusUShells)
// ON_EN_KILLFOCUS(IDC_USTRENGTH, OnKillfocusUStrength)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMnkUsr message handlers
bool CMnkUsr::OnInitDialog() {
CBmpDialog::OnInitDialog();
CDC *pDC;
CRect statRect;
pDC = GetDC();
mLevelTable[0] = "CrabCakes";
mLevelTable[1] = "Soft-shell";
mLevelTable[2] = "Tough'n'Chewy";
mLevelTable[3] = "King Crab";
mLevelTable[4] = "Invincible"; /*nish added 08/04/94*/
statRect.SetRect(LEFT_SIDE, 25, LEFT_SIDE + 100, 40);
if ((m_pShellText = new CText()) != nullptr) {
(*m_pShellText).SetupText(pDC, m_xpGamePalette, &statRect, JUSTIFY_LEFT);
}
statRect.SetRect(LEFT_SIDE, 65, LEFT_SIDE + 185, 80);
if ((m_pStrengthText = new CText()) != nullptr) {
(*m_pStrengthText).SetupText(pDC, m_xpGamePalette, &statRect, JUSTIFY_LEFT);
}
m_xpUScrShell = (CScrollBar *)GetDlgItem(IDC_USCRSHELL) ;
m_xpUScrShell->SetScrollRange(MINSTONES, MAXSTONES, true) ;
m_xpUScrShell->SetScrollPos(m_iUShells) ;
m_xpUScrStrength = (CScrollBar *)GetDlgItem(IDC_USCRSTRENGTH) ;
m_xpUScrStrength->SetScrollRange(MINSTRENGTH, MAXSTRENGTH, true) ;
m_xpUScrStrength->SetScrollPos(m_iUStrength) ;
if ((pOKButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
(*pOKButton).SetPalette(m_pPalette); // set the palette to use
(*pOKButton).SetControl(IDOK, this); // tie to the dialog control
}
if ((pCancelButton = new CColorButton) != nullptr) { // build a color QUIT button to let us exit
(*pCancelButton).SetPalette(m_pPalette); // set the palette to use
(*pCancelButton).SetControl(IDCANCEL, this); // tie to the dialog control
}
ReleaseDC(pDC);
return true; // return true unless you set the focus to a control
}
void CMnkUsr::ClearDialogImage() {
if (pOKButton != nullptr) { // release the button
delete pOKButton;
pOKButton = nullptr;
}
if (pCancelButton != nullptr) { // release the button
delete pCancelButton;
pCancelButton = nullptr;
}
ValidateRect(nullptr);
}
bool CMnkUsr::OnCommand(WPARAM wParam, LPARAM lParam) {
/*
* respond to user
*/
if (HIWORD(lParam) == BN_CLICKED) {
switch (wParam) {
case IDOK:
ClearDialogImage();
EndDialog(IDOK);
return false;
case IDCANCEL:
ClearDialogImage();
EndDialog(IDCANCEL);
return false;
default:
break;
}
}
return CBmpDialog::OnCommand(wParam, lParam);
}
void CMnkUsr::OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* xpScrollBar) {
// int iId = xpScrollBar->GetDlgCtrlID() ; // get id of control bar
int iValMin, iValMax, iValCur ; // min, max, current values
xpScrollBar->GetScrollRange(&iValMin, &iValMax) ;
iValCur = xpScrollBar->GetScrollPos() ;
// int *xpiVariable = (iId == IDC_USCRSHELL) ? &m_iUShells
// : (iId == IDC_USCRSTRENGTH) ? &m_iUStrength : nullptr ;
switch (nSBCode) {
case SB_LEFT:
iValCur = iValMin ;
break;
case SB_PAGELEFT:
iValCur -= (iValMax - iValMin) / 3 ;
break;
case SB_LINELEFT:
iValCur-- ;
break;
case SB_RIGHT:
iValCur = iValMax ;
break;
case SB_PAGERIGHT:
iValCur += (iValMax - iValMin) / 3 ;
break;
case SB_LINERIGHT:
iValCur++ ;
break;
case SB_THUMBPOSITION:
case SB_THUMBTRACK:
iValCur = nPos;
break;
default:
break;
}
if (iValCur < iValMin)
iValCur = iValMin ;
if (iValCur > iValMax)
iValCur = iValMax ;
xpScrollBar->SetScrollPos(iValCur);
// if (xpiVariable)
// *xpiVariable = iValCur ;
//UpdateData(false) ;
UpdateScrollbars();
CBmpDialog::OnHScroll(nSBCode, nPos, xpScrollBar);
}
/*****************************************************************
*
* UpdateScrollbars
*
* FUNCTIONAL DESCRIPTION:
*
* Updates data adjusted with scrollbars
*
* FORMAL PARAMETERS:
*
* none
*
* IMPLICIT INPUT PARAMETERS:
*
* CScrollbar pScrollShells, pScrollStrength
*
* IMPLICIT OUTPUT PARAMETERS:
*
* int m_nTime, m_nNumParts, m_nColumns, m_nRows
*
* RETURN VALUE:
*
* void
*
****************************************************************/
void CMnkUsr::UpdateScrollbars() {
int OldValue;
CDC *pDC;
char msg[64];
pDC = GetDC();
OldValue = m_iUShells;
m_iUShells = m_xpUScrShell->GetScrollPos();
if (OldValue != m_iUShells) {
Common::sprintf_s(msg, "Shells per Pit: %d", m_iUShells);
(*m_pShellText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
}
OldValue = m_iUStrength;
m_iUStrength = m_xpUScrStrength->GetScrollPos();
if (OldValue != m_iUStrength) {
Common::sprintf_s(msg, "Crab's Ability: %s", mLevelTable[m_iUStrength - 1].c_str());
(*m_pStrengthText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
}
ReleaseDC(pDC);
}
void CMnkUsr::OnPaint() {
CDC *pDC;
char msg[64];
CBmpDialog::OnPaint();
pDC = GetDC();
Common::sprintf_s(msg, "Shells per Pit: %d", m_iUShells);
(*m_pShellText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
Common::sprintf_s(msg, "Crab's Ability: %s", mLevelTable[m_iUStrength - 1].c_str());
(*m_pStrengthText).DisplayString(pDC, msg, 14, FW_BOLD, OPTIONS_COLOR);
ReleaseDC(pDC);
}
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel

View File

@@ -0,0 +1,124 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HODJNPODJ_MANKALA_MNKOPT_H
#define HODJNPODJ_MANKALA_MNKOPT_H
#include "bagel/hodjnpodj/hnplibs/cbofdlg.h"
#include "bagel/hodjnpodj/hnplibs/cmessbox.h"
#include "bagel/hodjnpodj/hnplibs/mainmenu.h"
#include "bagel/hodjnpodj/hnplibs/rules.h"
#include "bagel/hodjnpodj/mankala/mnk.h"
#include "bagel/hodjnpodj/mankala/resource.h"
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
#define OPTIONS_COLOR RGB(0, 0, 0) // Color of the stats info CText
#define LEFT_SIDE 25
#define NUM_LEVELS 5// (MAXSTRENGTH - MINSTRENGTH + 1) // 5- 1 + 1 = 5
/////////////////////////////////////////////////////////////////////////////
// CMnkOpt dialog
class CMnkOpt : public CDialog {
// Construction
public:
CMnkOpt(CWnd* pParent = nullptr); // standard constructor
~CMnkOpt(); // destructor
// Dialog Data
//{{AFX_DATA(CMnkOpt)
enum { IDD = IDD_MNK_DIALOG };
int m_iLevel0;
int m_iLevel1;
int m_iPlayer0;
int m_iPlayer1;
int m_iStartStones;
int m_iTableStones;
bool m_bInitData;
int m_iMaxDepth0;
int m_iMaxDepth1;
bool m_bDumpMoves;
bool m_bDumpPopulate;
bool m_bDumpTree;
int m_iCapDepth0;
int m_iCapDepth1;
//}}AFX_DATA
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
// Generated message map functions
//{{AFX_MSG(CMnkOpt)
// NOTE: the ClassWizard will add member functions here
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// CMnkUsr dialog
class CMnkUsr : public CBmpDialog {
// Construction
public:
CMnkUsr(CWnd *xpParent = nullptr,
CPalette *xpPalette = nullptr, unsigned int nID = IDD_MNK_USER) ;
~CMnkUsr(); // destructor
CPalette *m_xpGamePalette = nullptr;
CScrollBar *m_xpUScrShell = nullptr, *m_xpUScrStrength = nullptr;
void UpdateScrollbars();
// Dialog Data
//{{AFX_DATA(CMnkUsr)
enum { IDD = IDD_MNK_USER };
int m_iUShells = 0;
int m_iUStrength = 0;
CString mLevelTable [NUM_LEVELS];
//}}AFX_DATA
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
virtual bool OnCommand(WPARAM, LPARAM) override;
void ClearDialogImage();
// Generated message map functions
//{{AFX_MSG(CMnkUsr)
afx_msg void OnHScroll(unsigned int nSBCode, unsigned int nPos, CScrollBar* pScrollBar);
virtual bool OnInitDialog() override;
afx_msg void OnPaint();
// afx_msg void OnKillfocusUShells();
// afx_msg void OnKillfocusUStrength();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,74 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef HODJNPODJ_MANKALA_RESOURCE_H
#define HODJNPODJ_MANKALA_RESOURCE_H
namespace Bagel {
namespace HodjNPodj {
namespace Mankala {
#define IDCANCEL2 3
#define IDRESET 3
#define IDAPPLY 4
#define IDD_MNK_DIALOG 100
#define IDD_MNK_USER 102
#define IDD_RESET_PITS_DLG 103
#define IDC_RADIO1 1001
#define IDC_PLAY_0 1001
#define IDC_RADIO2 1002
#define IDC_RADIO3 1003
#define IDC_PLAY_1 1003
#define IDC_RADIO4 1004
#define IDC_RADIO5 1005
#define IDC_ALG_0 1005
#define IDC_RADIO6 1006
#define IDC_RADIO7 1007
#define IDC_RADIO8 1008
#define IDC_RADIO9 1009
#define IDC_RADIO10 1010
#define IDC_ALG_1 1010
#define IDC_RADIO11 1011
#define IDC_RADIO12 1012
#define IDC_RADIO13 1013
#define IDC_RADIO14 1014
#define IDC_STARTSTONES 1015
#define IDC_USHELLS 1015
#define IDC_SCROLLBAR1 1016
#define IDC_SCROLL_STONES 1016
#define IDC_USCRSTRENGTH 1016
#define IDC_TABLESTONES 1018
#define IDC_INITDATA 1019
#define IDC_MAXDEPTH0 1020
#define IDC_MAXDEPTH1 1021
#define IDC_CAPDEPTH0 1022
#define IDC_DUMPPOP 1023
#define IDC_DUMPMOVES 1024
#define IDC_DUMPTREE 1025
#define IDC_CAPDEPTH1 1026
#define IDC_USTRENGTH 1026
#define IDC_USCRSHELL 1027
} // namespace Mankala
} // namespace HodjNPodj
} // namespace Bagel
#endif