Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Checkers for Pocket PC using a Recursive Min-Max Tree

, 19 Jun 2008 CPOL
Checkers/Draughts game for Pocket PC, using the recursive Min-Max tree to calculate moves, coded with C# over the .NET Compact Framework
checkers20_cab.zip
GamesPackage
GamesPackage.csdproj
GamesPackage.csdproj.user
GamesPackage.csproj.user
GamesPackage.resharperoptions
GamesPackage.suo
SoundPPCLibrary
SoundPPCLibrary.csdproj
SoundPPCLibrary.csdproj.user
SoundPPCLibrary.csproj.user
SoundPPCLibrary.resharperoptions
SoundPPCLibrary.suo
BoardEngine
BoardEngine.csdproj
BoardEngine.csdproj.user
BoardEngine.csproj.user
Checkers
001_select_checker_0.wav
002_select_destination_0.wav
003_player_move_0.wav
004_eat_a_player_0.wav
005_end_of_the_board_0.wav
006_game_over_0.wav
007_win_game_0.wav
CHECKER.ico
Checkers.csdproj
Checkers.csdproj.user
Checkers.csproj.user
Checkers.resharper.user
Checkers.resharperoptions
Checkers.suo
checkersico.ico
Thumbs.db
checkers_source.zip
Checkers.csdproj
Checkers.csdproj.user
Checkers.csproj.user
checkersico.ico
001_select_checker_0.wav
002_select_destination_0.wav
003_player_move_0.wav
004_eat_a_player_0.wav
005_end_of_the_board_0.wav
006_game_over_0.wav
007_win_game_0.wav
CHECKER.ico
using System;
using System.Reflection;
using System.Runtime.InteropServices;

//*********************************************
namespace SoundPPCLibray
{
	public abstract class MyWaveOut
	{
		#region Constants

		public const uint	WAVE_MAPPER = unchecked((uint)(-1));
		public const uint	CALLBACK_WINDOW  = 0x10000;
		public const int	MM_WOM_OPEN = 0x3BB;
		public const int	MM_WOM_CLOSE = 0x3BC;
		public const int	MM_WOM_DONE = 0x3BD;
		public const uint	WAVE_FORMAT_PCM = 1;
		
		public const int	WF_OFFSET_FORMATTAG = 20;
		public const int	WF_OFFSET_CHANNELS = 22;
		public const int	WF_OFFSET_SAMPLESPERSEC = 24;
		public const int	WF_OFFSET_AVGBYTESPERSEC = 28;
		public const int	WF_OFFSET_BLOCKALIGN = 32;
		public const int	WF_OFFSET_BITSPERSAMPLE = 34;
		public const int	WF_OFFSET_DATA = 44;
		
		public static uint	SizeofWAVEHDR = (uint)Marshal.SizeOf(typeof(MyWAVEHDR));
		
		public const int	WHDR_DONE       = 0x00000001;  
		public const int	WHDR_PREPARED   = 0x00000002;  
		public const int	WHDR_BEGINLOOP  = 0x00000004;  
		public const int	WHDR_ENDLOOP    = 0x00000008;  
		public const int	WHDR_INQUEUE    = 0x00000010;  

		private const int WAVERR_BASE = 32;
		private const int MMSYSERR_BASE = 0;


		#endregion

		#region public class MyWAVEFORMATEX
		[StructLayout(LayoutKind.Sequential)]
		public class MyWAVEFORMATEX
		{
			public ushort wFormatTag;
			public ushort nChannels;
			public uint nSamplesPerSec;
			public uint nAvgBytesPerSec;
			public ushort nBlockAlign;
			public ushort wBitsPerSample;
			// public ushort cbSize; -- not used for PCM data
		}
		#endregion

		#region public class MyWAVEHDR
		[StructLayout(LayoutKind.Sequential)]
		public class MyWAVEHDR
		{
			public IntPtr lpData;
			public uint dwBufferLength;
			public uint dwBytesRecorded;
			public uint dwUser;
			public uint dwFlags;
			public uint dwLoops;
			public IntPtr lpNext;
			public uint reserved;
		}
		#endregion

		#region public enum myMMSYSERR : int
		public enum myMMSYSERR : int
		{
			NOERROR = 0,
			ERROR = (MMSYSERR_BASE + 1),
			BADDEVICEID = (MMSYSERR_BASE + 2),
			NOTENABLED = (MMSYSERR_BASE + 3),
			ALLOCATED = (MMSYSERR_BASE + 4),
			INVALHANDLE = (MMSYSERR_BASE + 5),
			NODRIVER = (MMSYSERR_BASE + 6),
			NOMEM = (MMSYSERR_BASE + 7),
			NOTSUPPORTED = (MMSYSERR_BASE + 8),
			BADERRNUM = (MMSYSERR_BASE + 9),
			INVALFLAG = (MMSYSERR_BASE + 10),
			INVALPARAM = (MMSYSERR_BASE + 11),
			HANDLEBUSY = (MMSYSERR_BASE + 12),
			INVALIDALIAS = (MMSYSERR_BASE + 13),
			BADDB = (MMSYSERR_BASE + 14),
			KEYNOTFOUND = (MMSYSERR_BASE + 15),
			READERROR = (MMSYSERR_BASE + 16),
			WRITEERROR = (MMSYSERR_BASE + 17),
			DELETEERROR = (MMSYSERR_BASE + 18),
			VALNOTFOUND = (MMSYSERR_BASE + 19),
			NODRIVERCB = (MMSYSERR_BASE + 20),
			LASTERROR = (MMSYSERR_BASE + 20),

			WAVERR_BADFORMAT = (WAVERR_BASE + 0),   
			WAVERR_STILLPLAYING = (WAVERR_BASE + 1),    
			WAVERR_UNPREPARED = (WAVERR_BASE + 2),    
			WAVERR_SYNC = (WAVERR_BASE + 3),    
			WAVERR_LASTERROR = (WAVERR_BASE + 3),    
		}
		#endregion

		#region Marshaling

		[DllImport ("coredll.dll")]
		public static extern myMMSYSERR waveOutOpen(ref IntPtr phwi,
			uint uDeviceID, MyWAVEFORMATEX pwfx, IntPtr dwCallback,
			uint dwInstance, uint fdwOpen);

		[DllImport ("coredll.dll")]
		public static extern myMMSYSERR waveOutPrepareHeader(IntPtr hwo,
			IntPtr /*WAVEHDR*/ pwh, uint cbwh);

		[DllImport ("coredll.dll")]
		public static extern myMMSYSERR waveOutWrite(IntPtr hwo,
			IntPtr /*WAVEHDR*/ pwh, uint cbwh);

		[DllImport ("coredll.dll")]
		public static extern myMMSYSERR waveOutUnprepareHeader(IntPtr
			hwo, IntPtr /*WAVEHDR*/ pwh, uint cbwh);

		[DllImport ("coredll.dll")]
		public static extern myMMSYSERR waveOutClose(IntPtr hwo);

		[DllImport ("coredll.dll")]
		public static extern myMMSYSERR waveOutReset(IntPtr hwo); 

		//[DllImport ("coredll.dll")]
		//public static extern MMSYSERR waveOutGetErrorText(uint mmrError,
		//	out string pszText, uint cchText); 

		#endregion

	} 
} 

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Leonardo Paneque
Team Leader
United States United States
Leonardo loves to code with C# and thinks .NET platforms rocks.
He has a Master degree in Computer Sciences and likes to share code and ideas.
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 20 Jun 2008
Article Copyright 2008 by Leonardo Paneque
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid