Imported anagramarama-0.2.tar.gz v0.2
authorPat Thoyts <patthoyts@users.sourceforge.net>
Tue, 15 Jun 2010 19:57:37 +0000 (20:57 +0100)
committerPat Thoyts <patthoyts@users.sourceforge.net>
Tue, 15 Jun 2010 19:57:37 +0000 (20:57 +0100)
images/.xvpics/background.bmp [deleted file]
makefile
makefile.BEOS [new file with mode: 0644]
src/ag.c
src/sound.c [deleted file]
src/sound.h [deleted file]
src/sprite.h
wordlist.txt

diff --git a/images/.xvpics/background.bmp b/images/.xvpics/background.bmp
deleted file mode 100755 (executable)
index 24ea5c6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-P7 332
-#IMGINFO:800x600 RGB (1440054 bytes)
-#END_OF_COMMENTS
-80 60 255
-o\8foo\8foo\8foo\8foo\8bsk\93\9a\97\97\97\97\97\96\97\97\97\97º\9b¾\9bº\9a¿\9aº¿\9aº\9fº¾\9bº\9eº\9fºº\9fº\9a¿º\9e»\9a¾»\9a¾\9bº\9b\96\9b·\9b\96\97\93s\93o\93\93s\93so\8foRRooo\8foo\8fon\8fo\97\97\97\97\96\97\97\97\97\9a·\9b\9a»\9a»\9eº\9b¾º\9b¾\9a¿º\9a¿\9aº¾\9b¾\9a»¾\9a»\9eº¿\9aº\9fº\9e\8eu\97mrr\96nqons\93monNnoSôøô\94OõÔøô3´²V·s\97\9a\93\9b\97\97\97\96\9b¾\9b\96VRµV\96\96u\9b\95{\9aº{\9a\9avzvw\95z\9b°v»¾\9a¿\9a¾º¾\9ai»¶¶ÿ\91\97¶ÿ)Ú\8esÖmÿ¶ÛoRõ°øôO\99ð\96ø2µôRØôôô¶ÔS\95µvwôÔøøôøµôôørøø\90ÖøÔÔôøøõøq¶ðø~»½»¾\9eº¿\99n\99\92q\96\96\9bm\97\91\9arj\8ennoRõøôø\907ô°øsøøÔ±øôõÔøqôøô3øôµøÐøvôÔøRøôÕvÔôvôôø±øq\96ÔøR¿\9eº¾º\9e»¾¾\9a¾º\9f½\93\96\96º\93\9a\96\96³r\92sovôøÐôøµøðÔ\96ÔôôWøôøôRµôøøÔôøôøõøÔôøô\96øQ\9bÔôørøøôôø´²øôz¾»\9eº¾¾\9a¿º\9e¾º¾\9b¹ßÛ¿ÛÞ»ÛߺÛsooQ\95rRSRRw\92w\97r\97\95ôøÔôµrøÔôÕÔ±VV\9a\9b\9a\9a\9a»\9dvzÝ\9a\94s\99\91±u\91RyºV\99Þ¾¾\9a¾º¾\9fº¾\9a¾¾»\9e¶Þß߻ڿÛß»Ú\9bo\8foo\8fo\93\97\97s\97\96\97·\9b\9am\96\9e»\9a\9bº\9b\9aº\9bº\9fº¾¾½º¾½Þ½¾½Ý¾½Þ½¾Ý½ºÜ¾Ý¾Ý½¾Ù½¿\9eº¾\9a¿½»\9eº\96º\96º\96\96\97\96\96\96\96o\8foo\8fo\97\97\93\97\92\9b\97\97\9e»\96\9a\9bº\9f\9a»\9aº\9bº\9fݺ¾½¾½¾Þ½½¾Ý¾½ÙݽÝÙ½ÜÚ¼Ýپݽݾ½º¾¾º\9e¿º¾\9aºßÞÛ¾ßÛ»ßÚ¿·o\8fo\8fwm\92Ni\92Lj\91rl\92\92\91\92r\91\9fº\9b\9a»½¾½Þ¾½¾½Ù¾ÜÙݽÝÙ¼ÞØݽÙÝØݹÝØÝÙ¾½Ý½Þ½½»¾\9a¾¿µ¿ßÞßÚß»ßÚ¿·o\8fs\97\93\91¶·µÛ\92\92¶¶¶I\91n\91·\95\9bº\9b¾\9a¾Þ½¾½¾Ù½ÝÝؾÜÙ½ÝÙݼÚÜÙÝؽÙÜÙÙÝؽ޽ݽ¾Ù½Þ\9eº\9a\96\99·\95\9a\96\9a\92\96\97\95\93\97s\97·»»×»Ú¿ÛßÚ¿ÛߺßßÚ¿ÛßÚÞßÞÞßÞÞþÞÚýßÝþÞúÞÞþÚÞýÞúÞÞúÝÿÙÞþÞúÝßÞþÞÞÞÛÞº¾\9b½¿º\9eº¿\9a»\9a\97\93\97\97\93¿×»Ú»ß»ßÚß»ÞÛ¿ÛÞß»þ¾ÿÞÞßÝÛýßÝÿÝÚþÞÞþÙúúÙúýÚúÞùÞþÚþÞÙþÞúÞÞþÞÞÞÞÛ¾º¾¾º\9e¾»\9d»º\9b\97\93\97\97\93¿×»Ú¿Ûß»ÞÛ¿ÚßÛ¿ÚßÛÞÞßÞÞÞþÞÞÞúÞÞþÞùÚùúÚýöùúÕúúùÚùúùÚþÞùÞÞúÞþÞÞÞÞ»¹¿½¾\9a¾¾»¾\9eº\97\93\97\97\93¿×»Þ»ÛߺßÛ¿ÚßÛ¿ÚßÞÞßÞþÞÞÞúÞÞþÞÞùúÚùúùÖùöùöõöùöùöùÚùúÞþÙþÚþÝûÝßÝ»¾º½¿\9d»½¿½»\9e\97\93\97\97\93¿×»Þ»ÛߺßÛ¿ÚßÛ¿ÚßÞÞßýßÝßþÞÚýÞúÙúúùöùÖùöõõúõöùöõöùöõþÖýÞúÞùÞþÚþÞº¾\9a¾¾¾¾º¾¾\9eº\97\93\97\97\93¿×»Þ»ÛߺßÛ¿ÚßÛ¿ÞÞßÚþÞÞÞþÞÞúÞùÚþõúõúÕúõöùöõúõöõúõöùöõúÝúÞþÙÿÙÞþÞº½»½¿\9d»½¿½»½\97\93\97\97\93¿×ºßÛ¿ÛºßÛß¾ÛßÚßÞÞÞÞþÞßÝûÝþÚùúÙöùöùúõöõúõöõúõöÙöõöùöùöùÞúÞýÚþÞÞÖ½¾¾\9eº¾¾¾º¾¾\97\93\97\97\93¿×¾Ûß»ÛÞ»ßÛ¾ÛÞßÞßÞþÞÞÚþÞÞÞùþÚõúõúùöõúõöÕúõöõúõöùöõöùöùöÙþÚýÞúÞþº¼Ú¾\9e¾º¾¾¾º\9e\97\93\97\97\93¿×¾Ûß»ÞÛ»ßÛ¾ßÚßÞÞþÞÞÞþÞÚÿÝúÙúùúõúÕöõúõöùöõöùöõöùöõúõöùöÙúúÝþÚþ޵ݽ¿½»½¿\9d»½¿\97\93\97\97\93¿ÚÛ¿Û»ÞÛ¿ÛßÚÞßÞßÞÞÞþÞÚÞþÞùÞöùúÙöõúõöõúõöùöõöùöõöùöõúõöõÚùúýÚÞúÞٽݺ¾¾\9eº¾¾¾º\97\93\97\97s\97º\9b\9a·\9b\9a»\9a\9b»½º¾¾½¾Ý½Ý¹Ý¾ÜÙÔøÐõðÔìðìðìðìððìðìððìðìðìððìðìðÔ°n²\91\97l²½Ù½¾¾¾º¾¾¾\9a\97\93\97\97s\96\92r\91r\96»\9a\9b\97º¾¾½¿½½Þ¹Ý½Ý½ÙØùÐôðÔððìðìððìðìðìððìðÌððìðìðìððô±L\8d\92lm\95ÝÙ½Þ\9e¾º¾¾¾º\97\93\97\97\91Ûm·q»\9bº\9b\9a¾¾º½¿Ü¾Ý½¾ØÞØÙØôÐðôÐððìðìðìððìðìððìðìðìððìðìðÔÙØùØÙؾܾܺ¾¾¾¾\9a¾¾\97\93\97\97sljHmNm\96v\93u\97\95\99\96\99\96\99\95¹\99µ\99\94µ°µÐ°¬Ð¬¬Ì̬ȬĮ̬̬̀Ì̬̬ÌȬ̬̬Ð\94µ´°µ´\99Ù½Þ¾\9e¾º¾¾¾º\97\93\97\97\97ÿÿÛÿÿÿÞÿÿÿßûÿÿÿßÿþÿÿÿÿßþÿÿÿúÿÿÿúÿÿÿúÿÿûÿþûÿÿþûÿÿúßÿûþÿÿûþÿÿÿþÿÿ¶½Ù¾¾½¿\9d»½¿¹\97\93\97s»ûÿßÿÿÿßþÿûßÿÿÿÿßÿþÿÿÿÿßþÿÿûÿþÿÿûþÿûÿþÿûÿþûÿÿÞûÿÿúÿÿûþÿÿûþÿÿÿÿþßÖ½¹¿½Tß\99¿½¿¹\93\97s\97·ÿßÿÿÿßûÿþßÿÿÿÿßÿÿÿþÿßÿÿûþÿÿÿþÿûÿþÿûßÿúÿÿûþÿÿûþÿûÿþûÿÿþûÿÿþÿÿßÿþ·¸0\9a\18º½¿½»\9d¿\93w\93\97·ÿßÿûÿßÿÿÿÞÿÿûßÿÿÿÿþßÿÿÿÿþÿÿÿÿÚÿÿÿúÿÿÿúÿÿûþÿûÿþÿûÿþûÿÿþûÿßÿþÿÿÿÿµ\9a\18\18u¾¾½»\9d¿º\93w\93\93\9bÿûÿÿßÿÿÿßÿúÿßÿÿÿÿÿßþÿÿÿÿÿÞÿÿûÿþÿÿÿúÿÿûþÿÿûþÿûÿþûÿÿÞûÿÿþÿÿûÿþÿßÿÖ\9eP¾¾¹¾¾¾¾º\9f\93w\93\93\97ÿÿÿÿßÿÿÿÛþÿÿßÿÿÿÿßÿþÿÿÿÿÿÞÿûÿÿþÿÿûþÿÿûþÿÿûþÿÛÿþûÿÿþûÿÿþÿÿÿÿÞÿÿÿ¶¾¹¿½¾¾½º¾\9fº\93w\93\93\97ÿÿÿÿßÿÿûßÿþÿßÿÿÿÿßÿþÿÿÿÿÿÞûÿÿÿþÿÿûþÿÿûþÿßûþÿûÿþûÿÿþÿÿûÿþÿßÿÿþÿÿ¶¾ºp\8d¾¾½¿½\9bº\93w\93\93\97ÿÿûßÿÿÿÿßÿÿûßþÿÿßÿÿÿÿþÿßÿÿÿþÿÿÿûþßÿÿþûÿÿþÿÿûþÿÿÿÿÚÿÿÿþÿÿÿûþÿßÿÿºº\95àà\99¾¾¾º\9bº\93w\93\93\97ÿûÿßÿÿÿßÿÿûÿßþÿÿßÿÿÿÿþßÿÿÿÿþÿûßÿþÿÿÿþûÿÿÿþÿûÿÞÿÿÿþûÿÿÿþÿÿßÿþÿÿÿ¶¾làà\96¾½»\9e»\9a\93w\93\93\93\92\91w±r\92\96\92\92\92\96\91\93\95\92\96\92µ\92\96\91\96\92µ\96\91\96\92µ\92\95²\95\91²\95\92µ\91²\91±\96±\91²\95\91²\95±\92\95²\95\92µ\96\91\96\92µ\92r½¾\99\92½¿\9a»\9eº\9b\93w\93\93\93w\93\93\9a·\9b\97\9a\97\9b\9b\9bº\9b\9a¾º¾¾¾¾½Ù¾½¾Ý¾½¾ÝÙÜÙØÙÜÙØÙÔøÕØÙØÝÙÜÙ½ØÞ½Ù¾¾½¾¾½¿½º¾¾½»\9e»\9eº\9b\93\93w\93\93\93rnM\97rn\96r\97\9a·\9b\96\9b»\9a¾º\9e¾¾º¾½Þ½¾½Þ½¾½Þ¹½Þ½ÝؽÙÙÜÙÝØݹÝØݺ½Þ¾½¾¾½¾¾¾¹¾¾¾º\9fº¾\9bº\9e\93\97\93w\93\93\93\96\8dÛq¶n¶\97º\97\9b\97\9a·\9b\9d»½¿½»½¿\9dÞ¹¾Ý¾½¾Ý¾½½Þ½¾Ý¾¹ÜÙÝÙܺ½Þ½¾¾½¾¾Ý¾¾½»½¾¾\9eº»\9eº\9fº\96\97\93\97\93w\93\93\93MnnmOq\8ev\96\9b·\9b\96\9b\97º\97\9eº¾¾¾º¾\9e¾Ý¾¹Þ½¾½Þ½½¾Ý¾½Þ½¾Ù¼Ù¾¾Ý¾¾½¾½¾Þ½¾¾º½¾¾¾\9bº\9e»¾\9a»\96s\97\97\93w\93\93\93w\93\93\93w\93\9b\97\9a\97\9b·\9a\97\9b\96»\97\9a¾¾¾º\9e¾¾ºÝ¾½¾Ý¾½¾Ý½¾Ý¾½¾½Ú¾½¾¾½¾Ý¾¾½¾¾½¾º¾¾¾\9a»¾\9a»\9eº\97\93\97s\97k\93s\93\93\97s\93\93\97s\92\9b·\9b\96\9b\97\9a·\9b\97\9a\97»\96\9bº¾\9e¾º¾¾¾½Þ½½¾Ù¾½¾Ý¾¾½¾¾½Þ½¾¾½¾ºÝ¾¾½¾¾¾º\9e»\9a¾»\9eº\97\93w\97\93\96\97kkk\97\93s\97\93\93r\97\93\93\9b\97\9a·\9b\96\9b\97º\97\9b\97\9a\97»\96\9fº¾½»½¿½¾½¾Ý¾½º¾½Þ¾½¾½¾¾Ý¾¾½¾¾½º¾½¿º\9b¾\9a¿º\9a¿\96\97\93\97w\93\96\97kkko\8fw\93\92\93w\93\93\93\97\97\9a\97\9b\9b\97\9b\96»\97\9a\97\9b\97º\97\9b½»\9eº¾¾º¾¾½¾¾½¾Ý¾¾½¾¾¹Þ¾½¾¾¾\9a¾º¿\9a¾\9bº¾\9bº\9e\93\97\97\93\97\96s\97\97kkkokj\93\97\93s\93\97\93s\93\97\9a·\9b\96\9b\97»\96\9b\97\9a·\9b\96\9b\97\9bº\9b½»¾\9eº¿\99¿º¾\9eº¿º\9e¾º\9e»¾¾\9a¾º\9fº¾\9bº\9e»º\9e»\9a\97\97\93\96\97\93\97w\93\97kkkokjk\93\93s\97\93\93s\97\93\96\9b·\9b\96\9b\97º\97\9b\96\9b·\9b\96\9b\97\9a·\9b\9a¾»\9eº¾¾\9a¿º¾\9eº¾\9b¾¾º\9eº¿\9a¾»\9a¾\9bº\9a»\97\9a\93\97\97s\97\93\97\97\92\97\97\93kkkokjkk\93\93\97s\93\93\97s\93\96\97\9b·\9a\97\9b\96»\97\9a\97\9b·\9a\97\9b\96\9b·\9b\9aº¿\9d»¾º\9e¿¹\9fº¾º\9e»¾\9b\96\97\97\9b\92\9b\97·w·v·s\97\97\93\97\97\92w\97\93\97\93kkkokjkk\8bw\93\93s\93\97\93s\92\9b»\97\9a\97\9b\9b\97\9b\96»\97\9a\97\9b\96»\97\9b\96\9bº»\9d¿º¾\9a¿º\9eº\9b\97\96\97\97\97\97\97¶w·{³z·w\93\97\97\93\97\92\97\97s\97\97\93\97kkkokjkkk\8bos\93\97\93r\93\93\97\97\9b\96\9b·\9a\97\9b\97\9a·\9b\96\9b\97º\97\9b\97\9a·\97\9b\96\97\97\97\96\97\97\9b\93\9b\96\97\97\97\97\96\97\97\97\97·v·w\97\97\93\97\96\93\97\93w\97\93\97\97\92kkkokjkkk\8bO\8bs\93\8fv\93\93s\97\93\9b\9b\97\9a\97»\97\9a\97\97\9b\96\97\97\97\97\97\96·w·w¶w·w»\93\9a\97\97\97\97\96\97\97\97\97\97\96\97\97\97\97\93\97v\93\97\97\93\97\97\93\97v\93\97kkkokjkkk\8bO\8bjs\93o\93\93s\93\97\93\9b\96\97\97\97\97\97\96\97\97\97\97\96\97\97\97\97\9b\92\9b·w·v·w·w·\96\97\97\97\97\9a\93\9b\97\97\97\96\93\97w\93\97\97\93\97\96\93\97w\93\97\93o\93kkkokjkkk\8bO\8bjkoo\93\93s\8fs\93\93\97\97\96\97\97\97\97\97\96\9b\93\9b\97\96\97\97\97\97\97\96\97\97\97\97\96\97»s»w¶w·w·\96\97\97\97w\93\97\96\93\97\97\93\97w\93\97\92\93o\93o\8fkkkokjkkk\8bO\8bjkkks\93\93s\93\8fs\93s\93\93s¶w·w»sºw·\97\97\96\97\97\97\97\97\96\97\97\97\9b\92\9b\97\97\97\97\96\97\97\97\97\97\92\97\97\93w\97\93\97\97\92o\93o\93o\8fs\8fkkkokjkkk\8bO\8bjkkkok\93s\93\8fs\93s\93\93o\92s\93\93s·w·z³{·\97\97\96\97\97\97\97\96\97\97\97\97\97\9a\93\9b\97\97\96\97\93\97\93\97w\93\97\96\93o\93o\93o\8fs\8fo\93okkkokjkkk\8bO\8bjkkkok\93o\93s\93\93s\8fs\92\93s\93\8fs\93s\97\97\97\96\97\97\97\97\97¶w·w·v·w·\9b\93\9a\97\97\97s\97\97\92\97\93\97\97s\8fo\93o\8fs\8fs\8fo\93okkkokjkkk\8bO\8bjkkkokkj\93s\93\93s\8fs\93\93s\93\8fs\93s\93\93o\93s\93\97\93\96\97\97\9b\93\9a\97\97\97\97\97\96\97\97\97\97\93\97\96\93s\93s\8fo\93o\8fs\8fs\8fo\93o\93okkkokjkkk\8bO\8bjkkkokkjk\93s\93\93s\8fs\93\93s\93o\93\93s\93\93o\93s\93\93s\8fs\93\93s\92\97\97\97\97\97\96\97\97\93\97s\8fs\8fs\8fo\93o\93o\8fs\8fs\8eo\93okkkkokjkkk\8bO\8bjkkkokkjkko\93\93s\93\8fs\93s\93\93o\93s\93\93s\8fs\93\93s\93\8es\93s\93\93o\93s\93\93o\93o\93o\8fs\8fso\8fs\8fs\8fo\93o\93o\8fnGgkgkjK\87Kkjkkkkkjkkk\8fK\8bjko\93s\8fs\93\93s\93o\93\93s\93\93o\93s\93\93s\8fs\93\93s\93o\92\93o\93o\93o\8fso\93o\8fs\8fs\8fo\93o\8fs\8fskfkGjkgkjK\87KkjkgkjkgkkJkgkkjgkok\8fno\93s\93\93o\93\93s\93s\8f\93s\93s\93\8fs\93o\93o\93o\8fs\8fo\93os\8eo\93o\93o\8fs\8fs\8fokfGkfkgkgkjK\87KkjkgkjkgkkJkgkkjgkkjkgK\8bJgkkkjgkkkjoo\8bso\8fo\93o\8fs\8fs\8fos\8fs\8fn\93o\93o\8fs\8fo\93GjgkGfkgj
\ No newline at end of file
index a473217e9a2c75e6ac2244aeb9cf9d2e11f75146..82cf0771ec3ad95d732debcf412a418f5e26232f 100755 (executable)
--- a/makefile
+++ b/makefile
@@ -1,8 +1,6 @@
-CFLAGS=-Wall `sdl-config --libs --cflags` -lSDL_mixer
-CFLAGS2=-Wall
-CC=cc
-
-LIBS=
+LFLAGS=-Wall -funroll-loops -fomit-frame-pointer -pipe -O9
+CFLAGS=-Wall `sdl-config --cflags --libs` -funroll-loops -fomit-frame-pointer -pipe -O9 -lSDL_mixer
+CC=gcc
 
 C_FILES=src/dlb.c src/linked.c src/sprite.c src/ag.c
 OBJ_FILES=src/dlb.o src/linked.o src/sprite.o src/ag.o
@@ -14,13 +12,16 @@ ag: $(OBJ_FILES)
        $(CC) $(CFLAGS) -o $(OUT_FILE) $(OBJ_FILES)
 
 src/dlb.o: src/dlb.c
-       $(CC) $(CFLAGS2) -c -o $@ $^
+       $(CC) $(LFLAGS) -c -o $@ $^
 
 src/linked.o: src/linked.c
-       $(CC) $(CFLAGS2) -c -o $@ $^
+       $(CC) $(LFLAGS) -c -o $@ $^
        
 src/sprite.o: src/sprite.c
-       $(CC) $(CFLAGS2) -c -o $@ $^
+       $(CC) $(LFLAGS) -c -o $@ $^
 
 src/ag.o: src/ag.c
-       $(CC) $(CFLAGS2) -c -o $@ $^
+       $(CC) $(LFLAGS) -c -o $@ $^
+
+clean:
+       rm -f src/*.o
diff --git a/makefile.BEOS b/makefile.BEOS
new file mode 100644 (file)
index 0000000..f013c71
--- /dev/null
@@ -0,0 +1,27 @@
+LFLAGS=`sdl-config --libs` -lSDL_mixer -Wl, -s, -x
+CFLAGS=-Wall `sdl-config --cflags` -funroll-loops -fomit-frame-pointer -pipe -O9
+CC=gcc
+
+C_FILES=src/dlb.c src/linked.c src/sprite.c src/ag.c
+OBJ_FILES=src/dlb.o src/linked.o src/sprite.o src/ag.o
+OUT_FILE=ag
+
+all:ag
+
+ag: $(OBJ_FILES)
+       $(CC) $(LFLAGS) -o $(OUT_FILE) $(OBJ_FILES)
+
+src/dlb.o: src/dlb.c
+       $(CC) $(CFLAGS) -c -o $@ $^
+
+src/linked.o: src/linked.c
+       $(CC) $(CFLAGS) -c -o $@ $^
+
+src/sprite.o: src/sprite.c
+       $(CC) $(CFLAGS) -c -o $@ $^
+
+src/ag.o: src/ag.c
+       $(CC) $(CFLAGS) -c -o $@ $^
+
+clean:
+       rm -f src/*.o $(OUT_FILE)
index ca5f9438e5a065bcf05a341dd35516aa9f470699..0e2ca8e20be70af87a67a54a7a3a7f1e73ea1fcf 100755 (executable)
--- a/src/ag.c
+++ b/src/ag.c
@@ -20,6 +20,40 @@ Contact Details: colm@coralquest.com
                 12 Weston Terrace, West Kilbride, KA23 9JX.  Scotland.
 */
 
+
+/***********************************************************
+Contributors
+
+Colm Gallagher  : Concept and initial programming
+Alan Grier      : Graphics
+THomas Plunkett : Audio
+Shard           : BEOS Port and bugfixes
+Adolfo          : Bugfix for Linux Red-Hat version 7.3
+
+************************************************************
+version                who             changes
+-------------------------------------------------------------------
+0.1            Colm            initial Linux & Windows revisions
+
+0.2            Shard           Bugfix: buffer overrun in clearWord
+                               function corrupted memory.  Strange
+                               thing is it crashed BEOS, but not
+                               Linux or Windows - guess they handle
+                               memory differently or BEOS is much
+                               better at detecting exceptions
+
+0.3            Shard           added BEOS port (new makefile)
+
+0.4            Adolfo          Bugfix: oops!  in the checkGuess
+                               function, I tried to initialise
+                               test[] using a variable  as if I was
+                               using vb6 !  Have changed this to a 
+                               static buffer and all is now well.
+
+0.5            Colm            Added keyboard input
+
+***********************************************************/
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -43,7 +77,6 @@ int startNewGame = 0;
 int solvePuzzle = 0;
 int shuffleRemaining = 0;
 int clearGuess = 0;
-//int winGame = 0;
 
 int gameStart = 0;
 int gameTime = 0;
@@ -73,15 +106,25 @@ struct sprite* scoreSprite = NULL;
 // audio vars
 Uint32 audio_len;
 Uint8 *audio_pos;
-
 struct sound{
        char* name;
        Mix_Chunk *audio_chunk;
        struct sound* next;
 };
-
 struct sound* soundCache = NULL;
-/*******************************************************************************/
+
+
+
+
+/***********************************************************
+synopsis: walk the module level soundCache until the required
+         name is found.  when found, return the audio data
+         if name is not found, return NULL instead.
+
+inputs:   name - the unique id string of the required sound
+
+outputs:  returns a chunk of audio or NULL if not found
+***********************************************************/
 Mix_Chunk* getSound(char* name){
 
 struct sound* currentSound = soundCache;
@@ -98,7 +141,19 @@ struct sound* currentSound = soundCache;
        return NULL;
 }
 
-/*******************************************************************************/
+
+
+
+/***********************************************************
+synopsis: push a sound onto the soundCache
+
+inputs:   soundCache - pointer to the head of the soundCache
+         name - unique id string for the sound, this is used
+                to later play the sound
+         filename - the filename of the WAV file
+
+outputs:  n/a
+***********************************************************/
 void pushSound(struct sound** soundCache, char* name, char* filename){
 
 struct sound* thisSound = NULL;
@@ -114,7 +169,19 @@ struct sound* thisSound = NULL;
        *soundCache = thisSound;
 }
 
-/*******************************************************************************/
+
+
+
+/***********************************************************
+synopsis: push all the game sounds onto the soundCache
+         linked list.  Not that soundCache is passed into
+         pushSound by reference, so that the head pointer
+         can be updated
+
+inputs:   pointer to the soundCache
+
+outputs:  n/a
+***********************************************************/
 void bufferSounds(struct sound** soundCache){
 
        pushSound(&(*soundCache),"click-answer", "audio/click-answer.wav");
@@ -129,7 +196,17 @@ void bufferSounds(struct sound** soundCache){
 
 }
 
-/*******************************************************************************/
+
+
+
+/***********************************************************
+synopsis: free all of the data in the audio buffer
+         the audio buffer is a module variable
+
+inputs:   n/a
+
+outputs:  n/a
+***********************************************************/
 void clearSoundBuffer(){
 
 struct sound* currentSound = soundCache, *previousSound = NULL;
@@ -144,9 +221,19 @@ struct sound* currentSound = soundCache, *previousSound = NULL;
        }
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: determine the next blank space in a string 
+         blanks are indicated by pound £ not space
+         
+inputs:   pointer the string to check
+
+outputs:  returns position of next blank (1 is first character)
+         or 0 if no blanks found
+***********************************************************/
 int nextBlank(char* string){
-// determine the next blank space in a string - blanks are indicated by pound £ not space
 
 int i;
 int found=0;
@@ -165,9 +252,18 @@ int found=0;
        }
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: shift a string of characters 1 character to the left
+          truncating the leftmost character
+
+inputs:   pointer to string to shift
+
+outputs:  pointer to the shifted string
+***********************************************************/
 char* shiftLeftKill(char* string){
-// shift a string of characters 1 character to the left
 
 int i;
 char start;
@@ -190,10 +286,19 @@ int len;
        free(newString);
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: shift a string of characters 1 character to the left
+         move the first character to the end of the string
+         so it wraps around
+
+inputs:   pointer to string to shift
+
+outputs:  pointer to the shifted string
+***********************************************************/
 char* shiftLeft(char* string){
-// shift a string of characters 1 character to the left
-// move the first character to the end of the string
 
 int i;
 char start;
@@ -217,11 +322,22 @@ int len;
        free(newString);
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: Generate all possible combinations of the root word
+         the initial letter is fixed, so to work out all
+         anagrams of a word, prefix with space.
+
+inputs:   head - pointer to the answers list
+         dlbHead - pointer to the dictionary
+         guess - pointer to the current guess
+         remain - pointer to the remaining letters
+
+outputs:  all parameters are in/out
+***********************************************************/
 void ag(struct node** head, struct dlb_node* dlbHead, char** guess, char** remain){
-// generate all possible combinations of the root word
-// the initial letter is fixed (hence the space character
-// at the end of the possible list)
 
 char*  newGuess;
 char*  newRemain;
@@ -242,8 +358,6 @@ int    totalLen=0, guessLen=0, remainLen=0, i;
        newGuess[guessLen+1] = '\0';
        newRemain[remainLen-1] = '\0';
 
-//     printf("%s\n", newGuess);
-
        if(strlen(newGuess) > 3){
                if (dlb_lookup(dlbHead,shiftLeftKill(newGuess))){
                        push(&(*head), shiftLeftKill(newGuess));
@@ -265,7 +379,16 @@ int    totalLen=0, guessLen=0, remainLen=0, i;
        free(newRemain);
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: update all of the answers to "found"
+
+inputs:   head - pointer to the answers linked list
+
+outputs:  n/a
+***********************************************************/
 void solveIt(struct node* head){
 
 struct node* current = head;
@@ -276,7 +399,19 @@ struct node* current = head;
        }
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: load the named image to position x,y onto the
+         required surface
+
+inputs:  file - the filename to load (.BMP)
+        screen - the SDL_Surface to display the image
+        x,y - the top left postion
+
+outputs:  n/a
+***********************************************************/
 void ShowBMP(char *file, SDL_Surface *screen, int x, int y){
        SDL_Surface *image;
        SDL_Rect dest;
@@ -301,74 +436,26 @@ void ShowBMP(char *file, SDL_Surface *screen, int x, int y){
        SDL_BlitSurface(image, NULL, screen, &dest);
 
        /* Update the changed portion of the screen */
-       //SDL_UpdateRects(screen, 1, &dest);
        SDL_FreeSurface(image);
 }
 
-/***********************************************************/
-/*void displayAnswerBoxes(struct node* head, SDL_Surface* screen){
-// for each letter to each answer in the nodelist,
-// display a neat little box to fill in later
 
-struct node* current = head;
-SDL_Rect outerrect, innerrect;
-int i;
 
-char imagePath[] = "images/small-£.bmp";
-int twoOnALine = 0;
 
-       // width and height are always the same
-       outerrect.w = 17;
-       outerrect.h = 17;
-       outerrect.x = 70;
-       outerrect.y = 380;
+/***********************************************************
+synopsis: for each letter to each answer in the nodelist,
+         display a neat little box.  If the answer has
+         been found display the letter for each box.
+         if the answer was guessed (as opposed to set found
+         by solveIt), display a white background, otherwise
+         display a blue background.
 
-        while (current != NULL){
+inputs:   head - pointer to the answers linked list
+         screen - pointer to the SDL_Surface to update
 
-               // update the x for each letter
-               for (i=0;i<current->length;i++){
-                       SDL_FillRect(screen, &outerrect,0);
-                       innerrect.w = outerrect.w - 2;
-                       innerrect.h = outerrect.h - 2;
-                       innerrect.x = outerrect.x + 1;
-                       innerrect.y = outerrect.y + 1;
-
-                       if (current->guessed){
-                               SDL_FillRect(screen, &innerrect,SDL_MapRGB(screen->format,255,255,255));
-                       }
-                       else{
-                               SDL_FillRect(screen, &innerrect,SDL_MapRGB(screen->format,217,220,255));
-                       }
-
-                       if (current->found){
-                               imagePath[13] = current->anagram[i];
-                               ShowBMP(imagePath, screen,  innerrect.x+2, innerrect.y );
-                       }
-
-                       outerrect.x += 18;
-               }
-
-               if ( twoOnALine<4 ){
-                       // shift x along to show the next word
-                       outerrect.x += (8-current->length) * 18;
-                       twoOnALine++;
-               }
-               else{
-                       // reset the x, ready for the next line
-                       outerrect.x = 70;
-                       twoOnALine = 0;
-                       // update the y for each word
-                       outerrect.y += 19;
-               }
-               current=current->next;
-       }
-       SDL_Flip(screen);
-}
-*/
-/***********************************************************/
+outputs:  n/a
+***********************************************************/
 void displayAnswerBoxes(struct node* head, SDL_Surface* screen){
-// for each letter to each answer in the nodelist,
-// display a neat little box to fill in later
 
 struct node* current = head;
 SDL_Rect outerrect, innerrect, letterBankRect;
@@ -377,7 +464,6 @@ int numWords = 0;
 int acrossOffset = 70;
 int numLetters = 0;
 int listLetters = 0;
-//char imagePath[] = "images/small-£.bmp";
 
        // width and height are always the same
        outerrect.w = 16;
@@ -416,10 +502,7 @@ int listLetters = 0;
 
                        if (current->found){
                                innerrect.x+=2;
-//                             innerrect.y-=1;
                                letterBankRect.x = 10 * ((int)current->anagram[i] - 97);
-                               //imagePath[13] = current->anagram[i];
-                               //ShowBMP(imagePath, screen,  innerrect.x+2, innerrect.y );
                                SDL_SetColorKey(smallLetterBank, SDL_SRCCOLORKEY, SDL_MapRGB(smallLetterBank->format,255,0,255));
                                SDL_BlitSurface(smallLetterBank, &letterBankRect, screen, &innerrect);
                        }
@@ -445,19 +528,36 @@ int listLetters = 0;
 
                current=current->next;
        }
-//     SDL_Flip(screen);
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: walk the linked list of answers checking
+         for our guess.  If the guess exists, mark it as
+         found and guessed.
+         if it's the longest word play the foundbig 
+         sound otherwise play the got word sound.
+         If the word has already been found, play the
+         duplicate sound.
+         If it cannot be found, play the badword sound
+
+inputs:   answer - the string that we're checking
+         head - pointer to the linked list of answers
+
+outputs:  n/a
+***********************************************************/
 void checkGuess(char* answer, struct node* head){
 // check the guess against the answers
 struct node* current = head;
 int i, len;
 int foundWord = 0;
+char test[7];
 
        len = nextBlank(answer) -1;
        if (len<0) len=7;
-       char test[len];
+//     char test[len];                 //bugfix by Adolfo - what was I thinking!  and why does it only fail on RH 7.3??
        for (i=0; i<len; i++){
                test[i] = answer[i];
        }
@@ -505,11 +605,27 @@ int foundWord = 0;
        }
 }
 
-/***********************************************************/
+/***********************************************************
+synopsis: determine the next blank space in a string 
+          blanks are indicated by pound £ not space.
+         When a blank is found, move the chosen letter
+         from one box to the other.
+         i.e. If we're using the ANSWER box,
+         move the chosen letter from the SHUFFLE box 
+         to the ANSWER box and move a SPACE back to the
+         SHUFFLE box. and if we're using the SHUFFLE box
+         move the chosen letter from ANSWER to SHUFFLE
+         and move a SPACE into ANSWER.
+
+inputs:   box - the ANSWER or SHUFFLE box
+         *index - pointer to the letter we're interested in
+
+outputs:  retval : the coords of the next blank position
+          *index : pointer to the new position were interested in
+***********************************************************/
 int nextBlankPosition(int box, int* index){
-// determine the next blank space in a string - blanks are indicated by pound £ not space
 
-int i;
+int i=0;
 
        switch(box){
                case ANSWER:
@@ -539,7 +655,103 @@ int i;
 
        return i * (GAME_LETTER_WIDTH+GAME_LETTER_SPACE)+BOX_START_X;
 }
-/***********************************************************/
+
+
+
+
+/***********************************************************
+synopsis: handle the keyboard events
+         BACKSPACE & ESCAPE - clear letters
+         RETURN - check guess
+         SPACE - shuffle
+         a-z - select the first instance of that letter
+               in the shuffle box and move to the answer box
+
+inputs: event - the key that has been pressed
+       node - the top of the answers list
+       letters - the letter sprites
+
+outputs:  n/a
+***********************************************************/
+void handleKeyboardEvent(SDL_Event *event, struct node* head, struct sprite** letters){
+
+struct sprite* current = *letters;
+char keyedLetter;
+
+       keyedLetter = event->key.keysym.sym;
+
+       if (!gamePaused){
+
+               switch(keyedLetter){
+
+                       case SDLK_BACKSPACE: case SDLK_ESCAPE:
+                               // clear has been pressed
+                               clearGuess = 1;
+                               break;
+
+                       case SDLK_RETURN:
+                               //enter has been pressed
+                               checkGuess(answer, head);
+                               break;
+                       case ' ':
+                               // shuffle has been pressed
+                               shuffleRemaining = 1;
+                               Mix_PlayChannel(-1, getSound("shuffle"),0);
+                               break;
+                       default:
+                               // loop round until we find the first instance of the selected letter in SHUFFLE
+                               while (current!=NULL&&current->box!=CONTROLS){
+                                       if (current->box == SHUFFLE){
+                                               if (current->letter == keyedLetter){
+                                                       current->toX = nextBlankPosition(ANSWER, &current->index);
+                                                       current->toY = ANSWER_BOX_Y;
+                                                       current->box = ANSWER;
+                                                       Mix_PlayChannel(-1, getSound("click-shuffle"), 0);
+                                                       break;  //while
+                                               }
+                                       }
+                                       current=current->next;
+                               }
+
+               }
+
+       }
+}
+
+
+
+
+/***********************************************************
+synopsis: checks where the mouse click occurred - if it's in
+         a defined hotspot then perform the appropriate action
+
+         Hotspot               Action
+         -----------------------------------------------------
+         A letter              set the new x,y of the letter
+                               and play the appropriate sound
+
+         ClearGuess            set the clearGuess flag
+
+         checkGuess            pass the current answer to the
+                               checkGuess routine
+
+         solvePuzzle           set the solvePuzzle flag
+
+         shuffle               set the shuffle flag and
+                               play the appropriate sound
+
+         newGame               set the newGame flag
+
+         quitGame              set the quitGame flag
+
+inputs:  button - mouse button that has ben clicked
+         x, y - the x,y coords of the mouse
+        screen - the SDL_Surface to display the image
+        head - pointer to the top of the answers list
+        letters - pointer to the letters sprites
+
+outputs:  n/a
+***********************************************************/
 void clickDetect(int button, int x, int y, SDL_Surface *screen, struct node* head, struct sprite** letters){
 
 struct sprite* current = *letters;
@@ -600,7 +812,16 @@ struct sprite* current = *letters;
        }
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: move all letters from answer to shuffle
+
+inputs:  letters - the letter sprites
+
+outputs:  n/a
+***********************************************************/
 int clearWord(struct sprite** letters){
 
 struct sprite* current = *letters;
@@ -608,7 +829,8 @@ struct sprite* orderedLetters[7];
 int i;
 int count = 0;
 
-       for (i=0;i<=7;i++){
+       //for (i=0;i<=7;i++){           // bug fixed by Shard - killed BEOSr, but not linux or windows!
+       for (i=0;i<7;i++){
                orderedLetters[i] = NULL;
        }
 
@@ -623,14 +845,24 @@ int count = 0;
                current=current->next;
        }
 
-       for (i=0;i<=7;i++){
+       for (i=0;i<7;i++){
                if(orderedLetters[i] != NULL)
                        orderedLetters[i]->toX = nextBlankPosition(SHUFFLE, &orderedLetters[i]->index);
        }
 
        return count;
 }
-/***********************************************************/
+
+
+
+
+/***********************************************************
+synopsis: display the score graphic
+
+inputs: screen - the SDL_Surface to display the image
+
+outputs: n/a
+***********************************************************/
 void updateScore(SDL_Surface* screen){
 // we'll display the total Score, this is the game score
 
@@ -661,7 +893,17 @@ SDL_Rect fromrect, torect, blankRect;
                SDL_BlitSurface(numberBank, &fromrect, scoreSprite->sprite, &torect);
        }
 }
-/***********************************************************/
+
+
+
+
+/***********************************************************
+synopsis: displays the graphical representation of time
+
+inputs: screen - the SDL_Surface to display the image
+
+outputs: n/a
+***********************************************************/
 void updateTime(SDL_Surface* screen){
 
 // the time is x seconds  minus the number of seconds of game time
@@ -715,16 +957,28 @@ SDL_Rect fromrect, torect, blankRect;
                Mix_PlayChannel(-1, getSound("clock-tick"), 0);
        }
 }
-/***********************************************************/
+
+
+
+
+/***********************************************************
+synopsis: spin the word file to a random location and then
+         loop until a 7 or 8 letter word is found
+         this is quite a weak way to get a random word
+         considering we've got a nice dbl Dictionary to
+         hand - but it works for now.
+
+inputs: n/a
+
+outputs: a random word
+***********************************************************/
 char* getRandomWord(){
-// spin the word file to a random location and then
-// loop until a 7 or 8 letter word is found
 
 FILE* wordlist;
 int filelocation;
 int i;
 char* wordFromList = malloc(sizeof(char) * 50);
-int len;
+int len=0;
 int done = 0;
 
        filelocation = rand()%10000;
@@ -771,12 +1025,19 @@ int done = 0;
        wordFromList[len+1] = '\0';
 
        return wordFromList;
-       free(wordFromList);
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: swap 2 characters in a string
+
+inputs: from, to - the characters to swap
+
+outputs: the swapped string
+***********************************************************/
 char* swapChars(int from, int to, char* string){
-// swap 2 characters in a string
 
 char swap;
 
@@ -788,10 +1049,18 @@ char swap;
 
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: working backwards in the string,
+         find the first non space character
+
+inputs: a string to check
+
+outputs: the position of the character
+***********************************************************/
 int revFirstNonSpace(char* thisWord){
-// working backwards in the string,
-// find the first non space character
 int i;
 
        for (i = strlen(thisWord) ; i>0; i--){
@@ -803,9 +1072,17 @@ int i;
        return 0;
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: replace characters randomly
+
+inputs: string to randomise (in/out)
+
+outputs: n/a
+***********************************************************/
 void shuffleWord(char** thisWord){
-// replace characters randomly
 
 int numSwaps;
 int from, to;
@@ -822,27 +1099,20 @@ int len;
                strcpy(*thisWord, swapChars(from, to, *thisWord));
        }
 
-       // move all the spaces to the end
-//     strcpy(buffer, *thisWord);
-//     for (i=0;i<strlen(buffer);i++){
-//             if(buffer[i] == SPACE_CHAR){
-//                     from = i;
-//                     to = revFirstNonSpace(buffer);
-//                     if (to == 0) break;     // no spaces
-//                     to--;
-//                     if (from < to){
-//                             letter = buffer[i+1];
-//                             buffer[i+1] = buffer[i];
-//                             buffer[i] = letter;
-//                     }
-//             }
-//     }
-//     strcpy(*thisWord, buffer);
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: returns the index of a specific letter in a string
+
+inputs: string - the string to check
+        letter - the letter to return
+
+outputs: the index of the letter
+***********************************************************/
 int whereinstr(char* string, char letter){
-// returns the index of a specific letter in a string
 int i, len;
 
        len=strlen(string);
@@ -855,11 +1125,20 @@ int i, len;
 
        return 0;
 }
-       
-/***********************************************************/
+
+
+
+
+/***********************************************************
+synopsis: same as shuffle word, but also tell the letter 
+         sprites where to move to
+
+inputs: thisWord - the string to shuffle (in/out)
+        letters - the letter sprites
+
+outputs: n/a
+***********************************************************/
 void shuffleAvailableLetters(char** thisWord, struct sprite** letters){
-// same as shuffle word, but also tell the letter sprites where
-// to move to
 
 struct sprite *thisLetter = *letters;
 int from, to;
@@ -909,26 +1188,19 @@ int numSwaps;
        free(shuffleChars);
        free(shufflePos);
 }
-/***********************************************************/
-/*void* updateClock(void *arg){
 
-int timeNow;
-       while((gameTime < AVAILABLE_TIME) && !stopTheClock){
-               timeNow = time(0) - gameStart;
-               if (timeNow!=gameTime){
-                       gameTime = timeNow;
-                       updateTimeDisplay = 1;          
-                       //sleep(1);
-               }
-       }
-       stopTheClock = 1;
-       solvePuzzle = 1;
-       return NULL;
-}
-*/
-/********************************************************************/
+
+
+
+/***********************************************************
+synopsis: build letter string into linked list of letter graphics
+
+inputs: letters - letter sprites head node (in/out)
+       screen - the SDL_Surface to display the image
+
+outputs: n/a
+***********************************************************/
 void buildLetters(struct sprite** letters, SDL_Surface* screen){
-// build letter string into linked list of letter graphics
 
 struct sprite *thisLetter = NULL, *previousLetter = NULL;
 int i;
@@ -976,6 +1248,7 @@ int index = 0;
                        SDL_BlitSurface(letterBank, &blankRect, thisLetter->replace, NULL);
                        thisLetter->x = rand()%799;//i * (GAME_LETTER_WIDTH + GAME_LETTER_SPACE) + BOX_START_X;
                        thisLetter->y = rand()%599;//SHUFFLE_BOX_Y;
+                       thisLetter->letter = shuffle[i];
                        thisLetter->h = thisLetter->sprite->h;
                        thisLetter->w = thisLetter->sprite->w;
                        thisLetter->toX = i * (GAME_LETTER_WIDTH + GAME_LETTER_SPACE) + BOX_START_X;
@@ -998,10 +1271,20 @@ int index = 0;
        }
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: add the clock to the sprites
+         keep a module reference to it for quick and easy update
+         this sets the clock to a fixed 5:00 start
+
+inputs: letters - letter sprites head node (in/out)
+       screen - the SDL_Surface to display the image
+
+outputs: n/a
+***********************************************************/
 void addClock(struct sprite** letters, SDL_Surface* screen){
-// add the clock to the sprites
-// keep a module reference to it for quick and easy update
 
 struct sprite *thisLetter = NULL, *previousLetter = NULL, *current = *letters;
 int i;
@@ -1093,10 +1376,19 @@ int index = 0;
        clockSprite = thisLetter;
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: add the Score to the sprites
+          keep a module reference to it for quick and easy update
+
+inputs: letters - letter sprites head node (in/out)
+       screen - the SDL_Surface to display the image
+
+outputs: n/a
+***********************************************************/
 void addScore(struct sprite** letters, SDL_Surface* screen){
-// add the Score to the sprites
-// keep a module reference to it for quick and easy update
 
 struct sprite *thisLetter = NULL, *previousLetter = NULL, *current = *letters;
 SDL_Rect fromrect, torect, blankRect;
@@ -1167,12 +1459,28 @@ int i;
        previousLetter->next = thisLetter;
        scoreSprite = thisLetter;
 }
-/***********************************************************/
+
+
+
+
+/***********************************************************
+synopsis: do all of the initialisation for a new game:
+          build the screen
+         get a random word and generate anagrams
+         (must get less than 66 anagrams to display on screen)
+         initialise all the game control flags
+
+inputs: head - first node in the answers list (in/out)
+        dblHead - first node in the dictionary list
+       screen - the SDL_Surface to display the image
+       letters - first node in the letter sprites (in/out)
+
+outputs: n/a
+***********************************************************/
 void newGame(struct node** head, struct dlb_node* dlbHead, SDL_Surface* screen, struct sprite** letters){
 
 char* guess;
 char* remain;
-//pthread_t clock;
 int happy = 0;   // we don't want any more than ones with 66 answers - that's all we can show...
 int i;
 
@@ -1213,13 +1521,11 @@ int i;
 
        remain[7] = '\0';
 
-//     printf("%s,%i\n", remain, bigWordLen);
        remain[bigWordLen]='\0';
 
        shuffleWord(&remain);
        strcpy(shuffle, remain);
 
-//     printf("shuffle:%s\n", shuffle);
        free(guess);
        free(remain);
 
@@ -1244,10 +1550,42 @@ int i;
        gameTime = 0;
        stopTheClock = 0;
 
-       // create the clock loop on a new thread
-       //pthread_create(&clock, NULL, updateClock, NULL);
 }
-/***********************************************************/
+
+
+
+
+/***********************************************************
+synopsis: a big while loop that runs the full length of the
+         game, checks the game events and responds
+         accordingly
+
+         event         action
+         -------------------------------------------------
+         winGame       stop the clock and solve puzzle
+         timeRemaining update the clock tick
+         timeUp        stop the clock and solve puzzle
+         solvePuzzle   trigger solve puzzle and stop clock
+         updateAnswers trigger update answers
+         startNew      trigger start new
+         updateScore   trigger update score
+         shuffle       trigger shuffle
+         clear         trigger clear answer
+         quit          end loop
+         poll events   check for keyboard/mouse and quit
+
+         finally, move the sprites -this is always called
+         so the sprites are always considered to be moving
+         no "move sprites" event exists - sprites x&y just
+         needs to be updated and they will always be moved
+
+inputs: head - first node in the answers list (in/out)
+        dblHead - first node in the dictionary list
+       screen - the SDL_Surface to display the image
+       letters - first node in the letter sprites (in/out)
+
+outputs: n/a
+***********************************************************/
 void gameLoop(struct node** head, struct dlb_node* dlbHead, SDL_Surface* screen, struct sprite** letters){
 
 int done=0;
@@ -1351,19 +1689,33 @@ int timeNow;
                {
                        switch (event.type) {
                                case SDL_MOUSEBUTTONDOWN:
-//                     printf("shuffle: %s\n", shuffle);
-//                     printf("guess:   %s\n", answer);
                                        clickDetect(event.button.button, event.button.x, event.button.y, screen, *head, &(*letters));
                                        break;
-                               case SDL_QUIT:
+
+                               case SDL_KEYUP:
+                                       handleKeyboardEvent(&event, *head, &(*letters));
+                                        break;
+                                case SDL_QUIT:
                                        done=1;
                        }
-               }
+                }
                moveSprites(&screen, &(*letters), letterSpeed);
-       }
+        }
 }
 
-/***********************************************************/
+
+
+
+/***********************************************************
+synopsis: initialise graphics and sound, build the dictionary
+          cache the images and start the game loop
+         when the game is done tidy up
+
+inputs: argc - argument count
+        argv - arguments
+
+outputs: retval  0 = success   1 = failure
+***********************************************************/
 int main(int argc, char *argv[]){
 
 struct node* head = NULL;
@@ -1404,9 +1756,6 @@ struct sprite* letters = NULL;
 
        bufferSounds(&soundCache);
 
-       // create the audio handler on a new thread
-       //pthread_create(&audio, NULL, handleSounds, NULL);
-
        // create dictionary
        createDLBTree(&dlbHead);
 
diff --git a/src/sound.c b/src/sound.c
deleted file mode 100755 (executable)
index 01d9bad..0000000
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
-Anagramarama - A word game.  Like anagrams?  You'll love anagramarama!
-Copyright (C) 2003  Colm Gallagher
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Contact Details: colm@coralquest.com
-                12 Weston Terrace, West Kilbride, KA23 9JX.  Scotland.
-*/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <SDL/SDL.h>
-#include <pthread.h>
-
-struct sound{
-       char* name;
-       SDL_AudioSpec spec;
-       Uint8 *audio_chunk;
-       Uint32 audio_len;
-       Uint8 *audio_pos;
-       struct sound* next;
-};
-
-struct soundQueue{
-       char* name;
-       struct soundQueue* next;
-};
-
-//Uint32 audio_len;
-//Uint8 *audio_pos;
-
-//struct sound* soundCache = NULL;
-//struct soundQueue* sounds = NULL;
-
-/*******************************************************************************/
-//void fill_audio(void *udata, Uint8 *stream, int len){
-// The audio function callback takes the following parameters:
-//   stream:  A pointer to the audio buffer to be filled
-//   len:     The length (in bytes) of the audio buffer
-
-       /* Only play if we have data left */
-//     if ( audio_len == 0 )
-//             return;
-
-       /* Mix as much data as possible */
-//     len = ( len > audio_len ? audio_len : len );
-//     SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME);
-//     audio_pos += len;
-//     audio_len -= len;
-//}
-
-/*******************************************************************************/
-void pushSound(struct sound** soundCache, char* name, char* filename){
-
-struct sound* thisSound = NULL;
-
-       thisSound = malloc(sizeof(struct sound));
-       thisSound->name = malloc(sizeof(name)*strlen(name));
-       strcpy(thisSound->name, name);
-       /* Set the audio format */
-       thisSound->spec.freq = 22050;
-       thisSound->spec.format = AUDIO_S16;
-       thisSound->spec.channels = 2;    /* 1 = mono, 2 = stereo */
-       thisSound->spec.samples = 1024;  /* Good low-latency value for callback */
-       thisSound->spec.callback = NULL; // null for now - we'll set the local ref in the play routine
-       thisSound->spec.userdata = NULL;
-       thisSound->next = *soundCache;
-
-       if (!strcmp(name, "playArea")){
-               // create a big area to mix and play the audio in
-//             thisSound->audio_len = malloc(sizeof(Uint32));
-               thisSound->audio_len = 8152;
-               thisSound->audio_chunk = malloc(sizeof(Uint8)*thisSound->audio_len);
-       }
-       else{
-               // Attempt to load a sample
-               if (!SDL_LoadWAV(filename, &thisSound->spec, &thisSound->audio_chunk, &thisSound->audio_len)){
-                       SDL_CloseAudio();
-                       fprintf(stderr, "Error: %s", SDL_GetError());
-                       return;
-               }
-       }
-
-       *soundCache = thisSound;
-}
-
-/*******************************************************************************/
-void bufferSounds(struct sound** soundCache){
-
-       pushSound(&(*soundCache),"click", "audio/click.wav");
-       pushSound(&(*soundCache),"click2", "audio/click2.wav");
-       pushSound(&(*soundCache),"found", "audio/found.wav");
-       pushSound(&(*soundCache),"playArea", "");
-}
-
-/*******************************************************************************/
-void clearSoundBuffer(struct sound** soundCache){
-
-struct sound* currentSound = *soundCache, *previousSound = NULL;
-
-       printf("top\n");
-
-       while (currentSound!=NULL){
-
-               printf("in top\n");
-
-               SDL_FreeWAV(currentSound->audio_chunk);
-               free(currentSound->name);
-               previousSound = currentSound;
-               currentSound = currentSound->next;
-               free(previousSound);
-
-               printf("in botton\n");
-       }
-
-       printf("bottom\n");
-}
-
-/*******************************************************************************/
-//void playSound(struct sound* soundCache, char* name){
-
-//struct sound* currentSound = soundCache;
-
-//     while (currentSound!=NULL){
-//             if (!strcmp(currentSound->name, name)){
-//                     printf("current sound is : %s\n", currentSound->name);
-//                     audio_pos = currentSound->audio_chunk;
-//                     audio_len = currentSound->audio_len;
-                       /* Open the audio device, forcing the desired format */
-//                     currentSound->spec.callback = fill_audio;
-//                     if ( SDL_OpenAudio(&currentSound->spec, NULL) < 0 ) {
-//                             fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
-//                             return;
-//                     }
-
-                       // Unpause the audio
-//                             SDL_PauseAudio(0);
-
-                       /* Wait for sound to complete */
-//                     while ( audio_len > 0 ) {
-//                             SDL_Delay(100);         /* Sleep 1/10 second */
-//                     }
-
-//                     SDL_CloseAudio();
-//                     break;
-
-//             }
-//             currentSound = currentSound->next;
-//     }
-//}
-
-/*******************************************************************************/
-void pushSoundQueue(struct soundQueue** sounds, char* name){
-
-struct soundQueue* current = *sounds;
-struct soundQueue* previous = NULL;
-
-
-       // get the tail - won't ever be very many, so not too lossy
-       // and saves handling a tail pointer
-       while (current != NULL){
-               previous = current;
-               current = current->next;
-       }
-       
-       current = NULL;
-       // OK a bit nasty - i'm reusing current here, i only
-       // used it above for running through the list
-
-       current = malloc(sizeof(struct soundQueue));
-       current->name = malloc(sizeof(char)*strlen(name));
-       strcpy(current->name,name);
-       current->next = NULL;
-
-
-       // join up the queue
-       if (previous == NULL)
-               // first time only, the head is previous
-               *sounds = current;
-       else
-               previous->next = current;
-
-}
-
-/*******************************************************************************/
-void popSoundQueue(struct soundQueue** sounds, char* name){
-
-struct soundQueue* oldHead = *sounds;
-
-       *sounds = oldHead->next;
-
-       free(oldHead->name);
-       free(oldHead);
-}
-
-/*******************************************************************************/
-//int doneSounds = 0;
-//int audioThreadOpen = 0;
-//void* handleSounds(void *arg){
-
-//char* name;
-
-//     audioThreadOpen = 1;
-
-       // if we're currently playing a sound or have none to handle - just leave
-//     while(!doneSounds){
-
-//             if(SDL_GetAudioStatus() == SDL_AUDIO_STOPPED && sounds != NULL){
-                       // get next sound off the queue and then pop it
-//                     name = malloc(sizeof(char)*strlen(sounds->name));
-//                     strcpy(name, sounds->name);
-//                     popSoundQueue(&sounds, name);
-//                     printf("sound: %s\n", name);
-//                     playSound(soundCache, name);
-
-//                     free(name);
-//             }
-//     }
-//     audioThreadOpen = 0;
-//     return 0;
-//}
-
-/*******************************************************************************/
-/*int main(int argc, char** argv){
-
-SDL_Surface* screen = NULL;
-SDL_Event event;
-Uint8* key;
-
-pthread_t audio;
-
-       if (SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0){
-               fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
-               exit(1);
-       }
-
-       screen=SDL_SetVideoMode(640,480,8,0);
-
-       atexit(SDL_Quit);
-
-       soundCache=NULL;
-       soundCache = malloc(sizeof(struct sound));
-       bufferSounds(&soundCache);
-
-       //sounds = malloc(sizeof(struct soundQueue));
-       pushSoundQueue(&sounds, "click");
-       pushSoundQueue(&sounds, "click2");
-       pushSoundQueue(&sounds, "click");
-       pushSoundQueue(&sounds, "click2");
-       pushSoundQueue(&sounds, "click2");
-       pushSoundQueue(&sounds, "found");
-
-       // create the audio handler on a new thread
-       pthread_create(&audio, NULL, handleSounds, NULL);
-
-//     playSound(soundCache, "click");
-//     playSound(soundCache, "click2");
-//     playSound(soundCache, "found");
-
-       do{
-               key = SDL_GetKeyState(NULL);
-               if(SDL_PollEvent(&event))
-                               if(event.type == SDL_QUIT)
-                                       break;
-       }
-       while (!key[SDLK_ESCAPE]);
-
-       doneSounds=1;
-       while (audioThreadOpen){
-               SDL_Delay(500);
-       }
-       
-       clearSoundBuffer(&soundCache);
-       return 0;
-}*/
diff --git a/src/sound.h b/src/sound.h
deleted file mode 100755 (executable)
index 6c700f5..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-Anagramarama - A word game.  Like anagrams?  You'll love anagramarama!
-Copyright (C) 2003  Colm Gallagher
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-Contact Details: colm@coralquest.com
-                12 Weston Terrace, West Kilbride, KA23 9JX.  Scotland.
-*/
-
-struct sound{
-       char* name;
-       SDL_AudioSpec spec;
-       Uint8 *audio_chunk;
-       Uint32 audio_len;
-       Uint8 *audio_pos;
-       struct sound* next;
-};
-
-struct soundQueue{
-       char* name;
-       struct soundQueue* next;
-};
-
-//void fill_audio(void *udata, Uint8 *stream, int len);
-void pushSound(struct sound** soundCache, char* name, char* filename);
-void bufferSounds(struct sound** soundCache);
-void clearSoundBuffer();
-void playSound(struct sound* soundCache, char* name);
-void pushSoundQueue(struct soundQueue** sounds, char* name);
-void popSoundQueue(struct soundQueue** sounds, char* name);
-void* handleSounds(void *arg);
index e72d64d18838db6f829c0aa6ea9ed1ed9156c4ff..c54c2c115b6965113163319cd21d12a5aad06f1c 100755 (executable)
@@ -32,6 +32,7 @@ Contact Details: colm@coralquest.com
 struct sprite{
        SDL_Surface* sprite;
        SDL_Surface* replace;
+       char letter;
        int x,y,w,h;
        int toX, toY;
        struct sprite* next;
index b8980f0387868d667db1396e1590f14709335db3..d314cb91fe23eceb28c2f913719a9b719339553b 100755 (executable)
@@ -10124,6 +10124,7 @@ negator
 neglect
 neigh
 neither
+neon
 nephew
 nephews
 nerve