summaryrefslogtreecommitdiff
path: root/chess-ics1.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-03 02:11:46 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-03 02:11:46 +0000
commitbc1b6e4f3789f4401ac5fe9bb9708459648345b0 (patch)
tree61016ff5f23823fe740c16755ebf800cc6d6bb9b /chess-ics1.el
parentf4e9c77bc700222590ada4799c619152354244f2 (diff)
More work to get engines working.
Diffstat (limited to 'chess-ics1.el')
-rw-r--r--chess-ics1.el74
1 files changed, 74 insertions, 0 deletions
diff --git a/chess-ics1.el b/chess-ics1.el
new file mode 100644
index 0000000..33e0a75
--- /dev/null
+++ b/chess-ics1.el
@@ -0,0 +1,74 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; ICS1 style display
+;;
+;; $Revision$
+
+(require 'chess-display)
+
+;;; Code:
+
+(defun chess-ics1-draw (&optional disppos)
+ "Draw the given POSITION from PERSPECTIVE's point of view.
+PERSPECTIVE is t for white or nil for black."
+ (if (null (get-buffer-window (current-buffer) t))
+ (pop-to-buffer (current-buffer)))
+ (let ((inhibit-redisplay t)
+ (pos (point)))
+ (erase-buffer)
+ (let* ((position (or disppos (chess-display-position nil)))
+ (inverted (null (chess-display-perspective nil)))
+ (rank (if inverted 7 0))
+ (file (if inverted 7 0))
+ beg)
+ (insert "\n +---+---+---+---+---+---+---+---+\n")
+ (while (if inverted (>= rank 0) (< rank 8))
+ (if (/= rank (if inverted 7 0))
+ (insert " +---+---+---+---+---+---+---+---+\n"))
+ (while (if inverted (>= file 0) (< file 8))
+ (let ((piece (chess-pos-piece position
+ (chess-rf-to-index rank file)))
+ begin)
+ (if (= file (if inverted 7 0))
+ (insert (format " %d " (1+ (- 7 rank)))))
+ (insert "| ")
+ (setq begin (1- (point)))
+ (if (and chess-display-use-faces (/= ? piece))
+ (let ((p (char-to-string piece)))
+ (add-text-properties
+ 0 1 (list 'face (if (> piece ?a)
+ 'chess-display-black-face
+ 'chess-display-white-face)) p)
+ (insert p))
+ (insert piece))
+ (insert ? )
+ (add-text-properties begin (point)
+ (list 'chess-coord
+ (chess-rf-to-index rank file))))
+ (setq file (if inverted (1- file) (1+ file))))
+ (insert "|\n")
+ (setq file (if inverted 7 0)
+ rank (if inverted (1- rank) (1+ rank))))
+ (insert " +---+---+---+---+---+---+---+---+\n")
+ (if inverted
+ (insert " h g f e d c b a\n")
+ (insert " a b c d e f g h\n")))
+ (set-buffer-modified-p nil)
+ (goto-char pos)))
+
+(defun chess-ics1-highlight (index &optional mode)
+ (if (null (get-buffer-window (current-buffer) t))
+ (pop-to-buffer (current-buffer)))
+ (let (beg end)
+ (save-excursion
+ (beginning-of-line)
+ (goto-line (+ 2 (chess-index-rank index)))
+ (forward-char (+ 8 (* 4 (chess-index-file index))))
+ (skip-chars-backward "^|")
+ (setq beg (point))
+ (skip-chars-forward "^|")
+ (put-text-property beg (point) 'face 'chess-display-highlight-face))))
+
+(provide 'chess-ics1)
+
+;;; chess-ics1.el ends here