Microsoft Small Basic

Program Listing: CLP327
GraphicsWindow.Title = "Chessboard" ' Copyright (c) 2012 Nonki Takahashi"
InitBoard()
For j = 8 To 1 Step - 1
y = pos["y0"] + (8 - j) * size
For i = 1 To 8
x = pos["x0"] + (i - 1) * size
GraphicsWindow.BrushColor = color[Math.Remainder((i + j), 2)]
GraphicsWindow.FillRectangle(x, y, size, size)
p = board[j][Text.GetSubText("abcdefgh", i, 1)]
If p <> "" Then
GraphicsWindow.BrushColor = color[Text.GetSubText(p, 1, 1)]
GraphicsWindow.DrawText(x, y - size * 0.1, Text.GetCharacter(pieces[Text.GetSubText(p, 2, 1)]))
EndIF
EndFor
EndFor
Sub InitBoard
GraphicsWindow.BackgroundColor = "#003300"
pos = "x0=120;y0=30;" ' left, top
board = "8=a\=BR\;b\=BN\;c\=BB\;d\=BQ\;e\=BK\;f\=BB\;g\=BN\;h\=BR\;;7=a\=BP\;b\=BP\;c\=BP\;d\=BP\;e\=BP\;f\=BP\;g\=BP\;h\=BP\;;2=a\=WP\;b\=WP\;c\=WP\;d\=WP\;e\=WP\;f\=WP\;g\=WP\;h\=WP\;;1=a\=WR\;b\=WN\;c\=WB\;d\=WQ\;e\=WK\;f\=WB\;g\=WN\;h\=WR\;;"
color = "W=white;B=black;0=SaddleBrown;1=BurlyWood;"
size = 48 ' font height and square size
GraphicsWindow.FontSize = size
pieces = "P=9823;N=9822;B=9821;R=9820;Q=9819;K=9818;" ' chessmen
EndSub