2013年6月6日 星期四

Android development, Eclipse

Download from http://www.eclipse.org/downloads/ , eclipse-mobile-jnmo-SR1-win32.zip(144MB).

Download from http://developer.android.com/sdk/index.html , adt-bundle-wondows-x86-20130522.zip (426MB).

2013年5月17日 星期五

CodeProject articles of "Windows Multimedia wave APIs"

1. [MUST READ]
Playing .WAV files using the Windows Multi-Media Library By Toby Opferman 26 Mar 2004
>>>Excellent introduction of WAV File Format, and Windows Multi-Media extensions library -- WINMM.DLL.

2. [MUST READ]
Voice Recording/Playing back using simple classes By A. Riazi, Shafiee, 17 Apr 2005
>>>Contains primary class CVoiceBase, CVoiceRecording, and CVoicePlaying.
>>>See its Comments and Discussions, by erben, 17 Jan '11, the project (recordAudio) in "Record&play synchronous" is a wonderful code sample !


3. [MUST READ]
Simple audio recording program By Saneesh, 12 Jul 2007
>>>Contains project "soundRec", good example of: waveInGetNumDevs, waveInGetDevCaps, mmioOpen, mmioClose, MMIOINFO, mmioFOURCC, mmioCreateChunk, mmioWrite, mmioAscend, waveInPrepareHeader, waveInAddBuffer, waveInStart, waveInStop, waveInUnprepareHeader, waveInOpen, waveInClose, and waveInGetErrorText.

4.
CWave - A Simple C++ Class to Manipulate WAV Files By darkoman, 26 Sep 2008
>>>Contains a graphical illustration of .wav file format

2012年7月15日 星期日

My Chinese Chess website

It comes true !

My Chinese Chess website has already started in January of 2012.

It is just for testing. It is in Traditional Chinese only.

http://www.icuhk.com/cchess40/home.php

2011年7月5日 星期二

XML parsing -- "Ajax on Java" , O'reilly

Refer to Example 4-5.

function callback() {
if( req.readyState==4 ) {
if( req.status==200 ) {
if( window.XMLHttpRequest ) {
nonMSPopulate();
}
else if( window.ActiveXObject ) {
msPopulate();
}
}
}
clear();
}

function nonMSPopulate() {
xmlDoc = document.implementation.createDocument("","",null);
var resp = req.responseText;
var parser = new DOMParser();
var dom = parser.parseFromString(resp,"text/xml");

decVal = dom.getElementsByTagName("decimal");
var decimal = document.getElementById("decimal");
decimal.value = decVal[0].childNodes[0].nodeValue;
}

function msPopulate() {
var resp = req.responseText;
var xmlDoc = new ActiveObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xml.loadXML(resp);

nodes = xmlDoc.documentElement.childNodes;

dec = xmlDoc.getElementByTagName("decimal");
var decimal = document.getElementById("decimal");
decimal.value = dec[0].firstChild.data;
}

2011年7月3日 星期日

XMLHttpRequest -- "Ajax on Java" of O'Reilly

Refer to "Ajax on Java" of O'Reilly, example 2-1, index.html.

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<script languge="JavaScript" src="ajax.js"></script>
...
</head>
<body onload="focusIn()">
...
<input type="text" id="key" name="key" onkeyup="converToDecimal();">
...
<input type="text" id="keypressed" readonly>
...
<input type="text" id="decimal" readonly>
...
</body>
</html>


Refer to "Ajax on Java" of O'Reilly, example 2-2, ajax.js.

var req;


function convertToDecimal() {
var key = document.getElementById("key");
var keypressed = document.getElementById("keypressed");
var url = "/ajaxdecimalcodeconverter/response.php?key=" + escape(key.value);
if( window.XMLHttpRequest ) {
req = new XMLHttpRequest(); //for Mozilla, Firefox, Safari
}
else if( window.ActiveXObject ) {
req = new ActiveXObject("Microsoft.XMLHTTP"); //for IE
}
req.open("Get",url,true);
req.onreadystatechange = callback;
req.send(null);
}


function callback() {
if( req.readyState==4 ) {
if( req.status==200 ) {
var decimal = document.getElementById("decimal");
decimal.value= req.responseText;
}
}
clear();
}


function clear() {
var key = document.getElementById("key");
key.value = "";
}


function focusIn() {
document.getElementById("key").focus();
}

2011年4月22日 星期五

ChessStatus Class

This is the partial PHP 5 ChessStatus class

class ChessStatus {
 ...
 public $ROWS = array(); //10 rows on the chess board
 public $ALLOWEDCOLOR = 0;
 public $MOVENUMBER = 1;

 public $redReachableCells = array();

 public $redAllowedCells = array();

 public $greenReachableCells = array();
 public $greenAllowedCells = array();

 ...
 function __construct()
 {
  for( $n=0; $n<=9; $n++ )
  { $this->ROWS[$n] = '+++++++++';
  }
 }
 ...
}


The most important member is $ROWS, $ALLOWEDCOLOR and $MOVENUMBER are respectively the  description of chessboard layout ,which side to play and the move number to be.

2011年4月14日 星期四

FEN format

FEN format is a text string representation of a chess placement. Strange or reasonable! Chinese Chess is very similar to International Chess. The International Chess format can directly adopt.

Example: "rnbakabnr//1c5c/p1p1p1p1p///P1P1P1P1P/1C5C//RNBAKABNR w - - 0 1/x04"

Edit the FEN string:

Press this button to place the chesses ->


Click the first line and press down arrow on keyboard to animate the move (It's true, Google BLOG can do things like that !):


Here is the brief explanation:

"KRNCABP" (white side) are same as "帥車馬包仕相兵" (red side). These Chinese characters are just my personal favourite!

"krncabp" (black side) are same as "將車馬炮士象卒" (green side)

The rows are delimited by '/', there are at most 10 rows on the chessboard. The numeric between the chess letters are the number of spaces. Any unrecognised letters are treated as 1, i.e. a space.

The letter followed ('w' in the example) is the side to move. 'w', 'W', 'r' or 'R' means red to move. 'b', 'B', 'g', or 'G' means green to move.

The last numeric (1 in the example) is the move number. The other letters('- - 0') are not used, just in compliant with the original FEN format.

I added the new feature like '/x04' in the example to denote the last picked chess, the first digit is the row number(0 means the topmost row) the last digit is the position counted from the left(0 means leftmost). This new feature is optional.