;ELC   
;;; Compiled by rms@psilocin.ai.mit.edu on Tue Jun 16 12:47:10 1998
;;; from file /gd/gnu/emacs/lisp/play/tetris.el
;;; in Emacs version 20.2.95.2
;;; with bytecomp version 2.46
;;; with all optimizations.

;;; This file uses dynamic docstrings, first added in Emacs 19.29.
(if (and (boundp 'emacs-version)
	 (< (aref emacs-version (1- (length emacs-version))) ?A)
	 (or (and (boundp 'epoch::version) epoch::version)
	     (string-lessp emacs-version "19.29")))
    (error "`tetris.el' was compiled for Emacs 19.29 or later"))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(require 'gamegrid)
#@42 Non-nil means use glyphs when available.
(defvar tetris-use-glyphs t (#$ . 625))
#@41 Non-nil means use color when available.
(defvar tetris-use-color t (#$ . 712))
#@53 Non-nil means draw a border even when using glyphs.
(defvar tetris-draw-border-with-glyphs t (#$ . 797))
#@53 The default time taken for a shape to drop one row.
(defvar tetris-default-tick-period 0.3 (#$ . 908))
#@263 Function run whenever the Tetris score changes
Called with two arguments: (SHAPES ROWS)
SHAPES is the number of shapes which have been dropped
ROWS is the number of rows which have been completed

If the return value is a number, it is used as the timer period.
(defvar tetris-update-speed-function 'tetris-default-update-speed-function (#$ . 1018))
#@32 Hook run upon starting Tetris.
(defvar tetris-mode-hook nil (#$ . 1374))
#@75 Vector of colors of the various shapes in text mode
Element 0 is ignored.
(defvar tetris-tty-colors [nil "blue" "white" "yellow" "magenta" "cyan" "green" "red"] (#$ . 1453))
#@62 Vector of colors of the various shapes
Element 0 is ignored.
(defvar tetris-x-colors [nil [0 0 1] [0.7 0 1] [1 1 0] [1 0 1] [0 1 1] [0 1 0] [1 0 0]] (#$ . 1633))
#@30 Name used for Tetris buffer.
(defvar tetris-buffer-name "*Tetris*" (#$ . 1801))
#@34 Width of used portion of buffer.
(defvar tetris-buffer-width 30 (#$ . 1887))
#@35 Height of used portion of buffer.
(defvar tetris-buffer-height 22 (#$ . 1970))
#@24 Width of playing area.
(defvar tetris-width 10 (#$ . 2055))
#@25 Height of playing area.
(defvar tetris-height 20 (#$ . 2121))
#@41 X position of top left of playing area.
(defvar tetris-top-left-x 3 (#$ . 2189))
#@41 Y position of top left of playing area.
(defvar tetris-top-left-y 1 (#$ . 2276))
#@27 X position of next shape.
(defvar tetris-next-x (byte-code "\211\\\302\\	\\\207" [tetris-top-left-x tetris-width 0] 2) (#$ . 2363))
#@27 Y position of next shape.
(defvar tetris-next-y tetris-top-left-y (#$ . 2502))
#@22 X position of score.
(defvar tetris-score-x tetris-next-x (#$ . 2587))
#@22 Y position of score.
(defvar tetris-score-y (+ tetris-next-y 6) (#$ . 2664))
#@31 File for holding high scores.
(defvar tetris-score-file "/tmp/tetris-scores" (#$ . 2747))
(byte-code "\306\300!\204 \307\300	B\306\302!\204 \310\302	B\306\303!\204  \311\303	B\306\304!\204, \312\304	B\313\305	B\314\315	B\316\317	B\320\321	B\322\323	B\324\325	B\306\207" [tetris-border-options current-load-list tetris-blank-options tetris-cell-options tetris-space-options tetris-shapes boundp (((glyph colorize) (t 43)) ((color-x color-x) (mono-x grid-x) (t nil)) (((glyph color-x) [0.5 0.5 0.5]) (t nil))) (((glyph colorize) (t 32)) ((color-x color-x) (mono-x grid-x) (color-tty color-tty) (t nil)) (((glyph color-x) [0 0 0]) (color-tty "black") (t nil))) (((glyph colorize) (emacs-tty 79) (t 32)) ((color-x color-x) (mono-x mono-x) (color-tty color-tty) (mono-tty mono-tty) (t nil))) (((t 32)) nil nil) [[[[1 1 0 0] [1 1 0 0] [1 1 0 0] [1 1 0 0]] [[1 1 0 0] [1 1 0 0] [1 1 0 0] [1 1 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]] [[[2 2 2 0] [0 2 0 0] [2 0 0 0] [2 2 0 0]] [[0 0 2 0] [0 2 0 0] [2 2 2 0] [2 0 0 0]] [[0 0 0 0] [2 2 0 0] [0 0 0 0] [2 0 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]] [[[3 3 3 0] [3 3 0 0] [0 0 3 0] [3 0 0 0]] [[3 0 0 0] [0 3 0 0] [3 3 3 0] [3 0 0 0]] [[0 0 0 0] [0 3 0 0] [0 0 0 0] [3 3 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]] [[[4 4 0 0] [0 4 0 0] [4 4 0 0] [0 4 0 0]] [[0 4 4 0] [4 4 0 0] [0 4 4 0] [4 4 0 0]] [[0 0 0 0] [4 0 0 0] [0 0 0 0] [4 0 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]] [[[0 5 5 0] [5 0 0 0] [0 5 5 0] [5 0 0 0]] [[5 5 0 0] [5 5 0 0] [5 5 0 0] [5 5 0 0]] [[0 0 0 0] [0 5 0 0] [0 0 0 0] [0 5 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]] [[[0 6 0 0] [6 0 0 0] [6 6 6 0] [0 6 0 0]] [[6 6 6 0] [6 6 0 0] [0 6 0 0] [6 6 0 0]] [[0 0 0 0] [6 0 0 0] [0 0 0 0] [0 6 0 0]] [[0 0 0 0] [0 0 0 0] [0 0 0 0] [0 0 0 0]]] [[[7 7 7 7] [7 0 0 0] [7 7 7 7] [7 0 0 0]] [[0 0 0 0] [7 0 0 0] [0 0 0 0] [7 0 0 0]] [[0 0 0 0] [7 0 0 0] [0 0 0 0] [7 0 0 0]] [[0 0 0 0] [7 0 0 0] [0 0 0 0] [7 0 0 0]]]] [[6 6 6 6] [6 7 6 7] [6 7 6 7] [6 7 6 7] [6 7 6 7] [5 5 6 5] [5 8 5 8]] tetris-shape-scores [[2 2] [3 2] [3 2] [3 2] [3 2] [3 2] [4 1]] tetris-shape-dimensions 0 tetris-blank 8 tetris-border 9 tetris-space] 2)
(defalias 'tetris-default-update-speed-function #[(shapes rows) "\301\302\\\245\207" [rows 20.0 50.0] 3])
(byte-code "\306\300!\204 \307\300	B\306\302!\204 \307\302	B\306\303!\204  \307\303	B\306\304!\204, \307\304	B\306\305!\2048 \307\305	B\306\310!\204E \307\310	B\306\311!\204R \307	\311	B\306\312!\204_ \307\n\312	B\306\313!\204l \314\313	B\315\300!\210\315\302!\210\315\303!\210\315\304!\210\315\305!\210\315\310!\210\315\311!\210\315\312!\210\315\313!\210\306\316!\204\237 \317\316!\316	B\320\321\322#\210\320\323\324#\210\320\325\326#\210\320\327\330#\210\320\331\332#\210\320\333\334#\210\320\335\336#\210\320\337\340#\210\306\341!\204\346 \317\341!!\341	B\320!\321\322#\207" [tetris-shape current-load-list tetris-rot tetris-next-shape tetris-n-shapes tetris-n-rows boundp 0 tetris-score tetris-pos-x tetris-pos-y tetris-paused nil make-variable-buffer-local tetris-mode-map make-sparse-keymap define-key "n" tetris-start-game "q" tetris-end-game "p" tetris-pause-game " " tetris-move-bottom [left] tetris-move-left [right] tetris-move-right [up] tetris-rotate-prev [down] tetris-rotate-next tetris-null-map] 4)
(defalias 'tetris-display-options #[nil "\306\307\310\"\311\311\312X\203\\ 	\211\nU\203 \202S 	\313Y\203: 	\314X\203: \315\f\316	HD\317	HD\320BBC\"\202S 	U\203F \202S 	U\203R \202S \321I\210	T\211\202 ))\207" [options c tetris-blank tetris-blank-options tetris-cell-options tetris-x-colors make-vector 256 nil 0 255 1 7 append (glyph color-x) color-tty ((t nil)) (nil nil nil) tetris-tty-colors tetris-border tetris-border-options tetris-space tetris-space-options] 9])
(defalias 'tetris-get-tick-period #[nil "\304\300!\205 	\n\"\211\247\205 )\207" [tetris-update-speed-function tetris-n-shapes tetris-n-rows period boundp] 4])
(defalias 'tetris-get-shape-cell #[(x y) "	H\nHH\fH\207" [tetris-shapes tetris-shape y tetris-rot x] 2])
(defalias 'tetris-shape-width #[nil "	H\n\303\246H\207" [tetris-shape-dimensions tetris-shape tetris-rot 2] 3])
(defalias 'tetris-shape-height #[nil "	H\303\n\304\246ZH\207" [tetris-shape-dimensions tetris-shape tetris-rot 1 2] 4])
(defalias 'tetris-draw-score #[nil "\306\307\310\"\307\311	\"\307\312\n\"#\313\313\314X\203P \fH\211G\313SX\203H \315\\\f\\H#\210T\211\202) ,\fT\211\202 *\316\207" [tetris-n-shapes tetris-n-rows tetris-score strings y string vector format "Shapes: %05d" "Rows:   %05d" "Score:  %05d" 0 2 gamegrid-set-cell nil len x #1=#:G48807 tetris-score-x tetris-score-y] 7])
(defalias 'tetris-update-score #[nil "\301 \210\302 \211\205 \303!)\207" [period tetris-draw-score tetris-get-tick-period gamegrid-set-timer] 3])
(defalias 'tetris-new-shape #[nil "\306\307\310!\311 Z\312\245\306\313 \203 \314 \210\202 \315 \210\316 \210\317 \207" [tetris-next-shape tetris-shape tetris-rot tetris-width tetris-pos-x tetris-pos-y 0 random 7 tetris-shape-width 2 tetris-test-shape tetris-end-game tetris-draw-shape tetris-draw-next-shape tetris-update-score] 2])
(defalias 'tetris-draw-next-shape #[nil "\306\306\307X\2032 \306\306\307X\203* \310\n	\\\\\f\306\311	\"*#\210	T\211\202 )T\211\202 )\312\207" [y x tetris-next-x tetris-next-y tetris-next-shape tetris-rot 0 3 gamegrid-set-cell tetris-get-shape-cell nil tetris-shape] 8])
(defalias 'tetris-draw-shape #[nil "\306\307 S	X\203E \306\310 S\nX\203= \311\n\"\211U\2045 \312\f\\\n\\\\\\\f#\210)\nT\211\202 *T\211\202 *\313\207" [y #1=#:G48808 x #2=#:G48809 c tetris-blank 0 tetris-shape-height tetris-shape-width tetris-get-shape-cell gamegrid-set-cell nil tetris-top-left-x tetris-pos-x tetris-top-left-y tetris-pos-y] 6])
(defalias 'tetris-erase-shape #[nil "\306\307 S	X\203N \306\310 S\nX\203F \311\n\"\f\\\n\\\f\\\\\211U\204> \312#\210+\nT\211\202 *T\211\202 *\313\207" [y #1=#:G48810 x #2=#:G48811 tetris-top-left-x tetris-pos-x 0 tetris-shape-height tetris-shape-width tetris-get-shape-cell gamegrid-set-cell nil tetris-top-left-y tetris-pos-y py px c tetris-blank] 6])
(defalias 'tetris-test-shape #[nil "\306\307\310 S	\nX\203p \307\311 S\fX\203h \204a \312	\"\f\\	\\\\\\U?\205_ Y\206_ Y\206_ \313\"U?-T\211\202 *	T\211\202	 *)\207" [hit y #1=#:G48812 x #2=#:G48813 c nil 0 tetris-shape-height tetris-shape-width tetris-get-shape-cell gamegrid-get-cell tetris-pos-x xx tetris-pos-y yy tetris-top-left-x px tetris-top-left-y py tetris-blank tetris-width tetris-height] 5])
(defalias 'tetris-full-row #[(y) "\306\307\nS	X\203% \310\f	\\\n\\\"U\203 \311	T\211\202 *)\207" [full x tetris-width #1=#:G48814 tetris-top-left-x tetris-top-left-y t 0 gamegrid-get-cell nil y tetris-blank] 5])
(defalias 'tetris-shift-row #[(y) "\306U\203& \306\nS	X\203# \307\f	\\\\#\210	T\211\202\f *\310\207\306\nS\f	\fX\203R \311\f	\\\\\312\\\"\307\f	\\\\#\210)	T\211\202- *\310\207" [y x tetris-width #1=#:G48815 tetris-top-left-x tetris-top-left-y 0 gamegrid-set-cell nil gamegrid-get-cell -1 tetris-blank #2=#:G48816 c] 5])
(defalias 'tetris-shift-down #[nil "\305	S\nX\203/ \306!\203( T\211\305Y\203' \307\f!\210\fS\211\202 )T\211\202 *\310\207" [y0 tetris-height #1=#:G48817 tetris-n-rows y 0 tetris-full-row tetris-shift-row nil] 4])
(defalias 'tetris-draw-border-p #[nil "\302=?\206 	\207" [gamegrid-display-mode tetris-draw-border-with-glyphs glyph] 2])
(defalias 'tetris-init-buffer #[nil "\306	\n#\210\307\310 \203H \311\fX\203G \311X\203? \312\\\f\\#\210T\211\202\" *\fT\211\202 *\313S\fX\203\204 \313SX\203| \312\\\f\\#\210T\211\202_ *\fT\211\202O *\310 \205\274 \311\311\314X\203\272 \311\311\314X\203\262 \312\\\f\\#\210T\211\202\226 )\fT\211\202\215 )\307)\207" [tetris-buffer-width tetris-buffer-height tetris-space buffer-read-only y tetris-height gamegrid-init-buffer nil tetris-draw-border-p -1 gamegrid-set-cell 0 4 #1=#:G48818 x tetris-width #2=#:G48820 tetris-top-left-x tetris-top-left-y tetris-border #3=#:G48819 #4=#:G48821 tetris-blank tetris-next-x tetris-next-y] 6])
(defalias 'tetris-reset-game #[nil "\306 \210\307 \210\310\311!\312\312\312\312\312\312\312\313\314 \207" [tetris-next-shape tetris-shape tetris-rot tetris-pos-x tetris-pos-y tetris-n-shapes gamegrid-kill-timer tetris-init-buffer random 7 0 nil tetris-new-shape tetris-n-rows tetris-score tetris-paused] 2])
(defalias 'tetris-shape-done #[nil "\305 \210T	\nH\fH\\\306 \210\307 \207" [tetris-n-shapes tetris-score tetris-shape-scores tetris-shape tetris-rot tetris-shift-down tetris-update-score tetris-new-shape] 3])
#@79 Called on each clock tick.
Drops the shape one square, testing for collision.
(defalias 'tetris-update-game #[(tetris-buffer) "?\205' p	=\205' \304\305 \210T\306 \211\203 S\307 \210\n\205& \310 )\207" [tetris-paused tetris-buffer hit tetris-pos-y nil tetris-erase-shape tetris-test-shape tetris-draw-shape tetris-shape-done] 3 (#$ . 11684)])
#@51 Drops the shape to the bottom of the playing area
(defalias 'tetris-move-bottom #[nil "\302\303 \210\204 	T\304 \211\203	 	S\305 \210\306 )\207" [hit tetris-pos-y nil tetris-erase-shape tetris-test-shape tetris-draw-shape tetris-shape-done] 2 (#$ . 12040) nil])
#@40 Moves the shape one square to the left
(defalias 'tetris-move-left #[nil "\301U?\205 \302 \210S\303 \203 T\304 \207" [tetris-pos-x 0 tetris-erase-shape tetris-test-shape tetris-draw-shape] 2 (#$ . 12314) nil])
#@41 Moves the shape one square to the right
(defalias 'tetris-move-right #[nil "\302 \\	U?\205 \303 \210T\304 \203 S\305 \207" [tetris-pos-x tetris-width tetris-shape-width tetris-erase-shape tetris-test-shape tetris-draw-shape] 2 (#$ . 12537) nil])
#@29 Rotates the shape clockwise
(defalias 'tetris-rotate-prev #[nil "\301 \210T\302\246\303 \203 \304\\\302\246\305 \207" [tetris-rot tetris-erase-shape 4 tetris-test-shape 3 tetris-draw-shape] 2 (#$ . 12796) nil])
#@33 Rotates the shape anticlockwise
(defalias 'tetris-rotate-next #[nil "\301 \210\302\\\303\246\304 \203 T\303\246\305 \207" [tetris-rot tetris-erase-shape 3 4 tetris-test-shape tetris-draw-shape] 2 (#$ . 13018) nil])
#@29 Terminates the current game
(defalias 'tetris-end-game #[nil "\303 \210\304!\210\305	\n\"\207" [tetris-null-map tetris-score-file tetris-score gamegrid-kill-timer use-local-map gamegrid-add-score] 3 (#$ . 13244) nil])
#@29 Starts a new game of Tetris
(defalias 'tetris-start-game #[nil "\303 \210\304!\210\305 \206 	\306\n\307\")\207" [tetris-mode-map tetris-default-tick-period period tetris-reset-game use-local-map tetris-get-tick-period gamegrid-start-timer tetris-update-game] 3 (#$ . 13469) nil])
#@38 Pauses (or resumes) the current game
(defalias 'tetris-pause-game #[nil "?\301\205	 \302!\207" [tetris-paused message "Game paused (press p to resume)"] 2 (#$ . 13758) nil])
(defalias 'tetris-active-p #[nil "\301 =\207" [tetris-mode-map current-local-map] 2])
(put 'tetris-mode 'mode-class 'special)
#@77 A mode for playing Tetris.

tetris-mode keybindings:
   \{tetris-mode-map}

(defalias 'tetris-mode #[nil "\306 \210\307\310!\210\311\310\312\313\314$\210\315!\210\316\317\320\f\321\322 !\210\323\324!\207" [tetris-null-map major-mode mode-name mode-popup-menu tetris-use-glyphs gamegrid-use-glyphs kill-all-local-variables make-local-hook kill-buffer-hook add-hook gamegrid-kill-timer nil t use-local-map tetris-mode "Tetris" ("Tetris Commands" ["Start new game" tetris-start-game] ["End game" tetris-end-game (tetris-active-p)] ["Pause" tetris-pause-game (and (tetris-active-p) (not tetris-paused))] ["Resume" tetris-pause-game (and (tetris-active-p) tetris-paused)]) gamegrid-init tetris-display-options run-hooks tetris-mode-hook tetris-use-color gamegrid-use-color] 5 (#$ . 14068)])
#@687 Play the Tetris game.
Shapes drop from the top of the screen, and the user has to move and
rotate the shape to fit in with those at the bottom of the screen so
as to form complete rows.

tetris-mode keybindings:
   \<tetris-mode-map>
\[tetris-start-game]	Starts a new game of Tetris
\[tetris-end-game]	Terminates the current game
\[tetris-pause-game]	Pauses (or resumes) the current game
\[tetris-move-left]	Moves the shape one square to the left
\[tetris-move-right]	Moves the shape one square to the right
\[tetris-rotate-prev]	Rotates the shape clockwise
\[tetris-rotate-next]	Rotates the shape anticlockwise
\[tetris-move-bottom]	Drops the shape to the bottom of the playing area


(defalias 'tetris #[nil "\301!\210\302 \210\303 \210\304 \207" [tetris-buffer-name switch-to-buffer gamegrid-kill-timer tetris-mode tetris-start-game] 2 (#$ . 14870) nil])
(provide 'tetris)
