Don't force double-buffering for sd devices. They apparently are not faster with...
[kugel-rb.git] / apps / plugins / robotfindskitten.c
blob10105319515590c5cb8b1e3ba244a18ff33e97a7
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * robotfindskitten: A Zen simulation
12 * Copyright (C) 1997,2000 Leonard Richardson
13 * leonardr@segfault.org
14 * http://www.crummy.com/devel/
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or EXISTANCE OF KITTEN. See the GNU General
24 * Public License for more details.
26 * http://www.gnu.org/copyleft/gpl.html
28 * Ported to Rockbox 2007 by Jonas Häggqvist
31 #include "plugin.h"
32 #include "lib/pluginlib_actions.h"
34 /* This macros must always be included. Should be placed at the top by
35 convention, although the actual position doesn't matter */
36 PLUGIN_HEADER
38 /*Be sure to change MESSAGES when you change the array, or bad things
39 will happen.*/
41 /*Also, take note that robotfindskitten.c and configure.in
42 currently have the version number hardcoded into them, and they
43 should reflect MESSAGES. */
45 /* Watch out for fenceposts.*/
46 #define MESSAGES (sizeof messages / sizeof (char*))
48 static char* messages[] =
50 "\"I pity the fool who mistakes me for kitten!\", sez Mr. T.",
51 "That's just an old tin can.",
52 "It's an altar to the horse god.",
53 "A box of dancing mechanical pencils. They dance! They sing!",
54 "It's an old Duke Ellington record.",
55 "A box of fumigation pellets.",
56 "A digital clock. It's stuck at 2:17 PM.",
57 "That's just a charred human corpse.",
58 "I don't know what that is, but it's not kitten.",
59 "An empty shopping bag. Paper or plastic?",
60 "Could it be... a big ugly bowling trophy?",
61 "A coat hanger hovers in thin air. Odd.",
62 "Not kitten, just a packet of Kool-Aid(tm).",
63 "A shameless plug for Rockbox: http://www.rockbox.org",
64 "A freshly-baked pumpkin pie.",
65 "A lone, forgotten comma, sits here, sobbing.",
66 "ONE HUNDRED THOUSAND CARPET FIBERS!!!!!",
67 "It's Richard Nixon's nose!",
68 "It's Lucy Ricardo. \"Aaaah, Ricky!\", she says.",
69 "You stumble upon Bill Gates' stand-up act.",
70 "Just an autographed copy of the Kama Sutra.",
71 "It's the Will Rogers Highway. Who was Will Rogers, anyway?",
72 "It's another robot, more advanced in design than you but strangely immobile.",
73 "Leonard Richardson is here, asking people to lick him.",
74 "It's a stupid mask, fashioned after a beagle.",
75 "Your State Farm Insurance(tm) representative!",
76 "It's the local draft board.",
77 "Seven 1/4\" screws and a piece of plastic.",
78 "An 80286 machine.",
79 "One of those stupid \"Homes of the Stars\" maps.",
80 "A signpost saying \"TO KITTEN\". It points in no particular direction.",
81 "A hammock stretched between a tree and a volleyball pole.",
82 "A Texas Instruments of Destruction calculator.",
83 "It's a dark, amphorous blob of matter.",
84 "Just a pincushion.",
85 "Oh hey, you're not Llorean!",
86 "It's a mighty zombie talking about some love and prosperity.",
87 "\"Dear robot, you may have already won our 10 MILLION DOLLAR prize...\"",
88 "It's just an object.",
89 "A mere collection of pixels.",
90 "A badly dented high-hat cymbal lies on its side here.",
91 "A marijuana brownie.",
92 "A plush Chewbacca.",
93 "Daily hunger conditioner from Australasia",
94 "Just some stuff.",
95 "Why are you touching this when you should be finding kitten?",
96 "A glorious fan of peacock feathers.",
97 "It's some compromising photos of Babar the Elephant.",
98 "A copy of the Weekly World News. Watch out for the chambered nautilus!",
99 "It's the proverbial wet blanket.",
100 "A \"Get Out of Jail Free\" card.",
101 "An incredibly expensive \"Mad About You\" collector plate.",
102 "Paul Moyer's necktie.",
103 "A haircut and a real job. Now you know where to get one!",
104 "An automated robot-hater. It frowns disapprovingly at you.",
105 "An automated robot-liker. It smiles at you.",
106 "It's a black hole. Don't fall in!",
107 "It's a Toshiba MK8022GAA hard drive, untested, as-is.",
108 "Just a big brick wall.",
109 "You found kitten! No, just kidding.",
110 "Heart of Darkness brand pistachio nuts.",
111 "A smoking branding iron shaped like a 24-pin connector.",
112 "It's a Java applet.",
113 "An abandoned used-car lot.",
114 "A shameless plug for Crummy: http://www.crummy.com/",
115 "A shameless plug for the UCLA Linux Users Group: http://linux.ucla.edu/",
116 "A can of Spam Lite.",
117 "This is another fine mess you've gotten us into, Stanley.",
118 "It's scenery for \"Waiting for Godot\".",
119 "This grain elevator towers high above you.",
120 "A Mentos wrapper.",
121 "It's the constellation Pisces.",
122 "It's a fly on the wall. Hi, fly!",
123 "This kind of looks like kitten, but it's not.",
124 "It's a banana! Oh, joy!",
125 "A helicopter has crashed here.",
126 "Carlos Tarango stands here, doing his best impression of Pat Smear.",
127 "A patch of mushrooms grows here.",
128 "It's a song by Kraftwerk, all about robots.",
129 "A patch of grape jelly grows here.",
130 "A spindle, and a grindle, and a bucka-wacka-woom!",
131 "A geyser sprays water high into the air.",
132 "A toenail? What good is a toenail?",
133 "You've found the fish! Not that it does you much good in this game.",
134 "A Buttertonsils bar.",
135 "One of the few remaining discoes.",
136 "Ah, the uniform of a Revolutionary-era minuteman.",
137 "A punch bowl, filled with punch and lemon slices.",
138 "It's nothing but a G-thang, baby.",
139 "IT'S ALIVE! AH HA HA HA HA!",
140 "This was no boating accident!",
141 "Wait! This isn't the poker chip! You've been tricked! DAMN YOU, MENDEZ!",
142 "A livery stable! Get your livery!",
143 "It's a perpetual immobility machine.",
144 "\"On this spot in 1962, Henry Winkler was sick.\"",
145 "There's nothing here; it's just an optical illusion.",
146 "The World's Biggest Motzah Ball!",
147 "A tribe of cannibals lives here. They eat Malt-O-Meal for breakfast, you know.",
148 "This appears to be a rather large stack of trashy romance novels.",
149 "Look out! Exclamation points!",
150 "A herd of wild coffee mugs slumbers here.",
151 "It's a limbo bar! How low can you go?",
152 "It's the horizon. Now THAT'S weird.",
153 "A vase full of artificial flowers is stuck to the floor here.",
154 "A large snake bars your way.",
155 "A pair of saloon-style doors swing slowly back and forth here.",
156 "It's an ordinary bust of Beethoven... but why is it painted green?",
157 "It's TV's lovable wisecracking Crow! \"Bite me!\", he says.",
158 "Hey, look, it's war. What is it good for? Absolutely nothing. Say it again.",
159 "It's the amazing self-referential thing that's not kitten.",
160 "A flamboyant feather boa. Now you can dress up like Carol Channing!",
161 "\"Sure hope we get some rain soon,\" says Farmer Joe.",
162 "\"How in heck can I wash my neck if it ain't gonna rain no more?\" asks Farmer Al.",
163 "\"Topsoil's all gone, ma,\" weeps Lil' Greg.",
164 "This is a large brown bear. Oddly enough, it's currently peeing in the woods.",
165 "A team of arctic explorers is camped here.",
166 "This object here appears to be Louis Farrakhan's bow tie.",
167 "This is the world-famous Chain of Jockstraps.",
168 "A trash compactor, compacting away.",
169 "This toaster strudel is riddled with bullet holes!",
170 "A capsaicin molecule.",
171 "It's a hologram of a crashed helicopter.",
172 "This is a television. On screen you see a robot strangely similar to yourself.",
173 "This balogna has a first name, it's R-A-N-C-I-D.",
174 "A salmon hatchery? Look again. It's merely a single salmon.",
175 "It's a rim shot. Ba-da-boom!",
176 "It's creepy and it's kooky, mysterious and spooky. It's also somewhat ooky.",
177 "This is an anagram.",
178 "This object is like an analogy.",
179 "It's a symbol. You see in it a model for all symbols everywhere.",
180 "The object pushes back at you.",
181 "A traffic signal. It appears to have been recently vandalized.",
182 "\"There is no kitten!\" cackles the old crone. You are shocked by her blasphemy.",
183 "This is a Lagrange point. Don't come too close now.",
184 "The dirty old tramp bemoans the loss of his harmonica.",
185 "Look, it's Fanny the Irishman!",
186 "What in blazes is this?",
187 "It's the instruction manual for a previous version of this game.",
188 "A brain cell. Oddly enough, it seems to be functioning.",
189 "Tea and/or crumpets.",
190 "This jukebox has nothing but Cliff Richards albums in it.",
191 "It's a Quaker Oatmeal tube, converted into a drum.",
192 "This is a remote control. Being a robot, you keep a wide berth.",
193 "It's a roll of industrial-strength copper wire.",
194 "Oh boy! Grub! Er, grubs.",
195 "A puddle of mud, where the mudskippers play.",
196 "Plenty of nothing.",
197 "Look at that, it's the Crudmobile.",
198 "Just Walter Mattheau and Jack Lemmon.",
199 "Two crepes, two crepes in a box.",
200 "An autographed copy of \"Primary Colors\", by Anonymous.",
201 "Another rabbit? That's three today!",
202 "It's a segmentation fault. Core dumped, by the way.",
203 "A historical marker showing the actual location of /dev/null.",
204 "Thar's Mobius Dick, the convoluted whale. Arrr!",
205 "It's a charcoal briquette, smoking away.",
206 "A pizza, melting in the sun.",
207 "It's a \"HOME ALONE 2: Lost in New York\" novelty cup.",
208 "A stack of 7 inch floppies wobbles precariously.",
209 "It's nothing but a corrupted floppy. Coaster anyone?",
210 "A section of glowing phosphor cells sings a song of radiation to you.",
211 "This TRS-80 III is eerily silent.",
212 "A toilet bowl occupies this space.",
213 "This peg-leg is stuck in a knothole!",
214 "It's a solitary vacuum tube.",
215 "This corroded robot is clutching a mitten.",
216 "\"Hi, I'm Anson Williams, TV's 'Potsy'.\"",
217 "This subwoofer was blown out in 1974.",
218 "Three half-pennies and a wooden nickel.",
219 "It's the missing chapter to \"A Clockwork Orange\".",
220 "It's a burrito stand flyer. \"Taqueria El Ranchito\".",
221 "This smiling family is happy because they eat LARD.",
222 "Roger Avery, persona un famoso de los Estados Unidos.",
223 "Ne'er but a potted plant.",
224 "A parrot, kipping on its back.",
225 "A forgotten telephone switchboard.",
226 "It's a trio of Swedish hackers. They seem to be busy with that MP3 player.",
227 "A forgotten telephone switchboard operator.",
228 "It's an automated robot-disdainer. It pretends you're not there.",
229 "It's a portable hole. A sign reads: \"Closed for the winter\".",
230 "Just a moldy loaf of bread.",
231 "A little glass tub of Carmex. ($.89) Too bad you have no lips.",
232 "A Swiss-Army knife. All of its appendages are out. (toothpick lost)",
233 "It's a zen simulation, trapped within an ASCII character.",
234 "It's a copy of \"The Rubaiyat of Spike Schudy\".",
235 "It's \"War and Peace\" (unabridged, very small print).",
236 "A willing, ripe tomato bemoans your inability to digest fruit.",
237 "A robot comedian. You feel amused.",
238 "It's KITT, the talking car.",
239 "Here's Pete Peterson. His batteries seem to have long gone dead.",
240 "\"Blup, blup, blup\", says the mud pot.",
241 "More grist for the mill.",
242 "Cory Doctorow's hot air balloon is tethered here.",
243 "Grind 'em up, spit 'em out, they're twigs.",
244 "The boom box cranks out an old Ethel Merman tune.",
245 "It's \"Finding kitten\", published by O'Reilly and Associates.",
246 "Pumpkin pie spice.",
247 "It's the Bass-Matic '76! Mmm, that's good bass!",
248 "\"Lend us a fiver 'til Thursday\", pleas Andy Capp.",
249 "It's a tape of '70s rock. All original hits! All original artists!",
250 "You've found the fabled America Online disk graveyard!",
251 "Empty jewelboxes litter the landscape.",
252 "It's the astounding meta-object.",
253 "Ed McMahon stands here, lost in thought. Seeing you, he bellows, \"YES SIR!\"",
254 "...thingy???",
255 "It's 1000 secrets the government doesn't want you to know!",
256 "The letters O and R.",
257 "A magical... magic thing.",
258 "It's a moment of silence.",
259 "It's Sirhan-Sirhan, looking guilty.",
260 "It's \"Chicken Soup for the Kitten-seeking Soulless Robot.\"",
261 "It is a set of wind-up chatter teeth.",
262 "It is a cloud shaped like an ox.",
263 "You see a snowflake here, melting slowly.",
264 "It's 91 yards of twine.",
265 "It's a big block of ice. Something seems to be frozen inside it.",
266 "Vladimir Lenin's casket rests here.",
267 "It's a copy of \"Zen and The Art of Robot Maintenance\".",
268 "This invisible box contains a pantomime horse.",
269 "A mason jar lies here open. It's label reads: \"do not open!\".",
270 "A train of thought chugs through here.",
271 "This jar of pickles expired in 1957.",
272 "Someone's identity disk lies here.",
273 "\"Yes!\" says the bit.",
274 "\"No!\" says the bit.",
275 "A dodecahedron bars your way.",
276 "Mr. Hooper is here, surfing.",
277 "It's a big smoking fish.",
278 "You have new mail in /var/spool/robot",
279 "Just a monitor with the blue element burnt out.",
280 "A pile of coaxial plumbing lies here.",
281 "It's a rotten old shoe.",
282 "It's a hundred-dollar bill.",
283 "It's a Dvorak keyboard.",
284 "It's Bender, the loveable kleptomaniac robot! \"Bite my shiny metal ass!\"",
285 "It's a cardboard box full of 8-tracks.",
286 "Just a broken hard drive containg the archives of Nerth Pork.",
287 "A broken metronome sits here, it's needle off to one side.",
288 "A sign reads: \"Go home!\"",
289 "A sign reads: \"No robots allowed!\"",
290 "It's the handheld robotfindskitten game, by Tiger.",
291 "This particular monstrosity appears to be ENIAC.",
292 "This is a tasty-looking banana creme pie.",
293 "A wireframe model of a hot dog rotates in space here.",
294 "Just the empty husk of a locust.",
295 "You disturb a murder of crows.",
296 "It's a copy of the robotfindskitten EULA.",
297 "It's Death.",
298 "It's an autographed copy of \"Secondary Colors,\" by Bob Ross.",
299 "It is a marzipan dreadnought that appears to have melted and stuck.",
300 "It's a DVD of \"Crouching Monkey, Hidden Kitten\", region encoded for the moon.",
301 "It's Kieran Hervold. Damn dyslexia!",
302 "A non-descript box of crackers.",
303 "Carbonated Water, High Fructose Corn Syrup, Color, Phosphoric Acid, Flavors, Caffeine.",
304 "\"Move along! Nothing to see here!\"",
305 "It's the embalmed corpse of Vladimir Lenin.",
306 "A coupon for one free steak-fish at your local family diner.",
307 "A set of keys to a 2001 Rolls Royce. Worthless.",
308 "A gravestone stands here. \"Izchak Miller, ascended.\"",
309 "Someone has written \"ad aerarium\" on the ground here.",
310 "A large blue eye floats in midair.",
311 "This appears to be a statue of Perseus.",
312 "There is an opulent throne here.",
313 "It's a squad of Keystone Kops.",
314 "This seems to be junk mail addressed to the finder of the Eye of Larn.",
315 "A wondrous and intricate golden amulet. Too bad you have no neck.",
316 "The swampy ground around you seems to stink with disease.",
317 "An animate blob of acid. Being metallic, you keep well away.",
318 "It's a copy of Knuth with the chapter on kitten-search algorithms torn out.",
319 "A crowd of people, and at the center, a popular misconception.",
320 "It's a blind man. When you touch, he exclaims \"It's a kitten prospecting robot!\"",
321 "It's a lost wallet. It's owner didn't have pets, so you discard it.",
322 "This place is called Antarctica. There is no kitten here.",
323 "It's a mousetrap, baited with soap.",
324 "A book with \"Don't Panic\" in large friendly letters across the cover.",
325 "A compendium of haiku about metals.",
326 "A discredited cosmology, relic of a bygone era.",
327 "A hollow voice says \"Plugh\".",
328 "A knight who says \"Either I am an insane knave, or you will find kitten.\"",
329 "The secret meeting place of the Knights of the Lambda Calculus.",
330 "A neural net -- maybe it's trying to recognize kitten.",
331 "A screwdriver.",
332 "A statue of a girl holding a goose like the one in Gottingen, Germany.",
333 "A tetradrachm dated \"42 B.C.\"",
334 "A voice booms out \"Onward, kitten soldiers...\"",
335 "An eminently forgettable zahir.",
336 "Apparently, it's Edmund Burke.",
337 "For a moment, you feel something in your hands, but it disappears!",
338 "Here is a book about Robert Kennedy.",
339 "Hey, robot, leave those lists alone.",
340 "Ho hum. Another synthetic a posteriori.",
341 "It's Asimov's Laws of Robotics. You feel a strange affinity for them.",
342 "It's Bach's Mass in B-minor!",
343 "It's a bug.",
344 "It's a synthetic a priori truth! Immanuel would be so pleased!",
345 "It's the Tiki Room.",
346 "Just some old play by a Czech playwright, and you can't read Czech.",
347 "Kitten is the letter 'Q'. Oh, wait, maybe not.",
348 "Quidquid Latine dictum sit, kitten non est.",
349 "Sutro Tower is visible at some distance through the fog.",
350 "The Digital Millennium Copyright Act of 1998.",
351 "The United States Court of Appeals for the Federal Circuit.",
352 "The non-kitten item like this but with \"false\" and \"true\" switched is true.",
353 "The non-kitten item like this but with \"true\" and \"false\" switched is false.",
354 "This is the chapter called \"A Map of the Cat?\" from Feynman's autobiography.",
355 "This is the forest primeval.",
356 "Werner's \"Pocket Field Guide to Things That Are Not Kitten\".",
357 "You found nettik, but that's backwards.",
358 "You have found some zinc, but you must not stop here, for you must find kitten.",
359 "\"50 Years Among the Non-Kitten Items\", by Ann Droyd.",
360 "\"Robot may not injure kitten, or, through inaction, ...\"",
361 "\"Address Allocation for Private Internets\" by Yakov Rekhter et al.",
362 "\"Mail Routing and the Domain System\" by Craig Partridge.",
363 "\"The Theory and Practice of Oligarchical Collectivism\" by Emmanuel Goldstein.",
364 "\"201 Kitten Verbs, Fully Conjugated\". You look for \"find\".",
365 "A card shark sits here, practicing his Faro shuffle. He ignores you.",
366 "A copy of DeCSS. They're a dime a dozen these days.",
367 "A demonic voice proclaims \"There is no kitten, only Zuul\". You flee.",
368 "A lotus. You make an interesting pair.",
369 "It's the missing 24 seconds of \"Monty Python and the Holy Grail\".",
370 "A milk carton, with a black and white picture of kitten on the side.",
371 "Any ordinary robot could see from a mile away that this wasn't kitten.",
372 "A stegosaurus, escaped from the stegosaurusfindsrobot game. It finds you.",
373 "Baling wire and chewing gum.",
374 "Chewing gum and baling wire.",
375 "Here is no kitten but only rock, rock and no kitten and the sandy road.",
376 "Hey, I bet you thought this was kitten.",
377 "It is an ancient mariner, and he stoppeth one of three.",
378 "It pleases you to be kind to what appears to be kitten -- but it's not!",
379 "It's a blatant plug for Ogg Vorbis, http://www.vorbis.com/",
380 "It's a business plan for a new startup, kitten.net.",
381 "It's a revised business plan for a new startup, my.kitten.net.",
382 "It's a square.",
383 "It seems to be a copy of \"A Tail of Two Kitties\".",
384 "It's the Donation of Constantine!",
385 "It's this message, nothing more.",
386 "Lysine, an essential amino acid. Well, maybe not for robots.",
387 "No kitten here.",
388 "The score for a Czech composer's \"Kitten-Finding Symphony in C\".",
389 "This looks like Bradley's \"Appearance and Reality\", but it's really not.",
390 "This non-kitten item no verb.",
391 "You feel strangely unfulfilled.",
392 "You hit the non-kitten item. The non-kitten item fails to yowl.",
393 "You suddenly yearn for your distant homeland.",
394 "You've found the snows of yesteryear! So that's where they all went to.",
395 "Approaching. One car. J. Followed by. Two car. M, M. In five. Minutes.",
396 "Free Jon Johansen!",
397 "Free Dmitry Sklyarov!",
398 "One person shouts \"What do we want?\" The crowd answers \"Free Dmitry!\"",
399 "Judith Platt insults librarians.",
400 "This map is not the territory.",
401 "\"Go back to Libraria!\", says Pat Schroeder.",
402 "This is a porcelain kitten-counter. 0, 0, 0, 0, 0...",
403 "An old bootable business card, unfortunately cracked down the middle.",
404 "A kitten sink, for washing kitten (if only kitten liked water).",
405 "A kitten source (to match the kitten sink).",
406 "If it's one thing, it's not another.",
407 "If it's not one thing, it's another.",
408 "A caboodle.",
409 "A grin.",
410 "A hedgehog. It looks like it knows something important.",
411 "You've found... Oh wait, that's just a cat.",
412 "Robot should not be touching that.",
413 "Air Guitar!!! NA na NA na!!",
414 "An aromatherapy candle burns with healing light.",
415 "You find a bright shiny penny.",
416 "It's a free Jon Johansen!",
417 "It's a free Dmitry Sklyarov!",
418 "The rothe hits! The rothe hits!",
419 "It's an Internet chain letter about sodium laureth sulfate.",
420 "Ed Witten sits here, pondering string theory.",
421 "Something is written here in the dust. You read: \"rJbotf ndQkttten\".",
422 "We wish you a merry kitten, and a happy New Year!",
423 "Run away! Run away!",
424 "You can see right through this copy of Brin\'s \"Transparent Society\".",
425 "This copy of \"Steal This Book\" has been stolen from a bookstore.",
426 "It's Roya Naini.",
427 "This kit is the fourteenth in a series of kits named with Roman letters.",
428 "This is the tenth key you've found so far.",
429 "You find a fraud scheme in which loans are used as security for other loans.",
430 "It's the phrase \"and her\", written in ancient Greek.",
431 "It's the author of \"Randomness and Mathematical Proof\".",
432 "It's the crusty exoskeleton of an arthropod!",
433 "It's Emporer Shaddam the 4th's planet!",
434 "It's the triangle leg adjacent to an angle divided by the leg opposite it.",
435 "It's a bottle of nail polish remover.",
436 "You found netkit! Way to go, robot!",
437 "It's the ASCII Floating Head of Seth David Schoen!",
438 "A frosted pink party-cake, half eaten.",
439 "A bitchin' homemade tesla coil.",
440 "Conan O'Brian, sans jawbone.",
441 "It's either a mirror, or another soulless kitten-seeking robot.",
442 "Preoccupation with finding kitten prevents you from investigating further.",
443 "Fonzie sits here, mumbling incoherently about a shark and a pair of waterskis.",
444 "The ghost of your dance instructor, his face a paper-white mask of evil.",
445 "A bag of groceries taken off the shelf before the expiration date.",
446 "A book: Feng Shui, Zen: the art of randomly arranging items that are not kitten.",
447 "This might be the fountain of youth, but you'll never know.",
448 "Tigerbot Hesh.",
449 "Stimutacs.",
450 "A canister of pressurized whipped cream, sans whipped cream.",
451 "The non-kitten item bites!",
452 "A chain hanging from two posts reminds you of the Gateway Arch.",
453 "A mathematician calculates the halting probability of a Turing machine.",
454 "A number of short theatrical productions are indexed 1, 2, 3, ... n.",
455 "A technical university in Australia.",
456 "It is -- I just feel something wonderful is about to happen.",
457 "It's a Cat 5 cable.",
458 "It's a U.S. president.",
459 "It's a piece of cloth used to cover a stage in between performances.",
460 "The ionosphere seems charged with meaning.",
461 "This tomography is like, hella axial, man!",
462 "It's your favorite game -- robotfindscatan!",
463 "Just a man selling an albatross.",
464 "The intermission from a 1930s silent movie.",
465 "It's an inverted billiard ball!",
466 "The spectre of Sherlock Holmes wills you onwards.",
469 #define RFK_VERSION "v1.4142135.406"
471 /* Button definitions stolen from maze.c */
472 #if (CONFIG_KEYPAD == IPOD_4G_PAD) || \
473 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
474 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
475 # undef __PLUGINLIB_ACTIONS_H__
476 # define RFK_QUIT (BUTTON_SELECT | BUTTON_MENU)
477 # define RFK_RIGHT BUTTON_RIGHT
478 # define RFK_LEFT BUTTON_LEFT
479 # define RFK_UP BUTTON_MENU
480 # define RFK_DOWN BUTTON_PLAY
481 # define RFK_RRIGHT (BUTTON_RIGHT | BUTTON_REPEAT)
482 # define RFK_RLEFT (BUTTON_LEFT | BUTTON_REPEAT)
483 # define RFK_RUP (BUTTON_MENU | BUTTON_REPEAT)
484 # define RFK_RDOWN (BUTTON_PLAY | BUTTON_REPEAT)
486 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
487 # undef __PLUGINLIB_ACTIONS_H__
488 # define RFK_QUIT (BUTTON_HOME|BUTTON_REPEAT)
489 # define RFK_RIGHT BUTTON_RIGHT
490 # define RFK_LEFT BUTTON_LEFT
491 # define RFK_UP BUTTON_UP
492 # define RFK_DOWN BUTTON_DOWN
493 # define RFK_RRIGHT (BUTTON_RIGHT | BUTTON_REPEAT)
494 # define RFK_RLEFT (BUTTON_LEFT | BUTTON_REPEAT)
495 # define RFK_RUP (BUTTON_UP | BUTTON_REPEAT)
496 # define RFK_RDOWN (BUTTON_DOWN | BUTTON_REPEAT)
498 #else
499 # define RFK_QUIT PLA_QUIT
500 # define RFK_RIGHT PLA_RIGHT
501 # define RFK_LEFT PLA_LEFT
502 # define RFK_UP PLA_UP
503 # define RFK_DOWN PLA_DOWN
504 # define RFK_RRIGHT PLA_RIGHT_REPEAT
505 # define RFK_RLEFT PLA_LEFT_REPEAT
506 # define RFK_RUP PLA_UP_REPEAT
507 # define RFK_RDOWN PLA_DOWN_REPEAT
509 #endif
510 /*Constants for our internal representation of the screen.*/
511 #define EMPTY -1
512 #define ROBOT 0
513 #define KITTEN 1
515 /* if SYSFONT_WIDTH is 0 (which it is during dependency generation) gcc
516 will abort (div by 0) and this plugin won't get any dependencies
518 #if SYSFONT_WIDTH < 1
519 #define SYSFONT_WIDTH 10
520 #define SYSFONT_HEIGHT 10
521 #endif
523 /*Screen dimensions.*/
524 #define X_MIN 0
525 #define X_MAX ((LCD_WIDTH/SYSFONT_WIDTH) - 1)
526 #define Y_MIN 3
527 #define Y_MAX ((LCD_HEIGHT/SYSFONT_HEIGHT) - 1)
529 /* Colours used */
530 #if LCD_DEPTH >= 16
531 #define NUM_COLORS 6
532 #define ROBOT_COLOR LCD_DARKGRAY
533 const unsigned colors[NUM_COLORS] = {
534 LCD_RGBPACK(255, 255, 0), /* Yellow */
535 LCD_RGBPACK(0, 255, 255), /* Cyan */
536 LCD_RGBPACK(255, 0, 255), /* Purple */
537 LCD_RGBPACK(0, 0, 255), /* Blue */
538 LCD_RGBPACK(255, 0, 0), /* Red */
539 LCD_RGBPACK(0, 255, 0), /* Green */
541 #elif LCD_DEPTH == 2
542 #define NUM_COLORS 3
543 #define ROBOT_COLOR LCD_DARKGRAY
544 const unsigned colors[NUM_COLORS] = {
545 LCD_LIGHTGRAY,
546 LCD_DARKGRAY,
547 LCD_BLACK,
549 #elif LCD_DEPTH == 1
550 #define NUM_COLORS 1
551 #define ROBOT_COLOR 0
552 const unsigned colors[NUM_COLORS] = {
555 #endif /* HAVE_LCD_COLOR */
557 /*Macros for generating numbers in different ranges*/
558 #define randx() (rb->rand() % X_MAX) + 1
559 #define randy() (rb->rand() % (Y_MAX-Y_MIN+1))+Y_MIN /*I'm feeling randy()!*/
560 #define randchar() rb->rand() % (126-'!'+1)+'!';
561 #define randcolor() rb->rand() % NUM_COLORS
562 #define randbold() (rb->rand() % 2 ? true:false)
564 /*Row constants for the animation*/
565 #define ADV_ROW 1
566 #define ANIMATION_MEET (X_MAX/3)*2
567 #define ANIMATION_LENGTH 4
569 /*This struct contains all the information we need to display an object
570 on the screen*/
571 struct screen_object
573 short x;
574 short y;
575 int color;
576 bool bold;
577 char character;
581 *Function definitions
584 /*Initialization and setup functions*/
585 static void initialize_arrays(void);
586 static void initialize_robot(void);
587 static void initialize_kitten(void);
588 static void initialize_bogus(void);
589 static void initialize_screen(void);
590 static void instructions(void);
591 static void finish(int sig);
593 /*Game functions*/
594 static void play_game(void);
595 static void process_input(int);
597 /*Helper functions*/
598 static void pause(void);
599 static int validchar(char);
600 static void play_animation(int);
602 /*Global variables. Bite me, it's fun.*/
603 struct screen_object robot;
604 struct screen_object kitten;
606 #if X_MAX*Y_MAX < 200
607 #define NUM_BOGUS 15
608 #else
609 #define NUM_BOGUS 20
610 #endif
611 struct screen_object bogus[NUM_BOGUS];
612 unsigned short bogus_messages[NUM_BOGUS];
613 bool used_messages[MESSAGES];
615 bool exit_rfk;
617 /* This array contains our internal representation of the screen. The
618 array is bigger than it needs to be, as we don't need to keep track
619 of the first few rows of the screen. But that requires making an
620 offset function and using that everywhere. So not right now. */
621 int screen[X_MAX + 1][Y_MAX + 1];
623 /******************************************************************************
625 * Begin meaty routines that do the dirty work.
627 *****************************************************************************/
629 static void drawchar(int x, int y, char c)
631 char str[2];
632 rb->snprintf(str, sizeof(str), "%c", c);
633 rb->lcd_putsxy(x*SYSFONT_WIDTH, y*SYSFONT_HEIGHT, str);
636 static void draw(struct screen_object o)
638 #if LCD_DEPTH > 1
639 unsigned oldforeground;
640 oldforeground = rb->lcd_get_foreground();
641 rb->lcd_set_foreground(o.color);
642 drawchar(o.x, o.y, o.character);
643 rb->lcd_set_foreground(oldforeground);
644 #else
645 drawchar(o.x, o.y, o.character);
646 #endif
649 static void message(char * str)
651 rb->lcd_puts_scroll(0, ADV_ROW, str);
654 static void refresh(void)
656 rb->lcd_update();
660 *play_game waits in a loop getting input and sending it to process_input
662 static void play_game()
664 int old_x = robot.x;
665 int old_y = robot.y;
666 int input = 0; /* Not sure what a reasonable initial value is */
667 #ifdef __PLUGINLIB_ACTIONS_H__
668 const struct button_mapping *plugin_contexts[] = {generic_directions, generic_actions};
669 #endif
671 while (input != RFK_QUIT && exit_rfk == false)
673 process_input(input);
675 /*Redraw robot, where applicable. We're your station, robot.*/
676 if (!(old_x == robot.x && old_y == robot.y))
678 /*Get rid of the old robot*/
679 drawchar(old_x, old_y, ' ');
680 screen[old_x][old_y] = EMPTY;
682 /*Meet the new robot, same as the old robot.*/
683 draw(robot);
684 refresh();
685 screen[robot.x][robot.y] = ROBOT;
687 old_x = robot.x;
688 old_y = robot.y;
690 #ifdef __PLUGINLIB_ACTIONS_H__
691 input = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, 2);
692 #else
693 input = rb->button_get(true);
694 #endif
696 message("Bye!");
697 refresh();
701 *Given the keyboard input, process_input interprets it in terms of moving,
702 *touching objects, etc.
704 static void process_input(int input)
706 int check_x = robot.x;
707 int check_y = robot.y;
709 switch (input)
711 case RFK_UP:
712 case RFK_RUP:
713 check_y--;
714 break;
715 case RFK_DOWN:
716 case RFK_RDOWN:
717 check_y++;
718 break;
719 case RFK_LEFT:
720 case RFK_RLEFT:
721 check_x--;
722 break;
723 case RFK_RIGHT:
724 case RFK_RRIGHT:
725 check_x++;
726 break;
729 /*Check for going off the edge of the screen.*/
730 if (check_y < Y_MIN || check_y > Y_MAX || check_x < X_MIN || check_x > X_MAX)
732 return; /*Do nothing.*/
736 * Clear textline
737 * disabled because it breaks the scrolling for some reason
739 /* rb->lcd_puts_scroll(0, ADV_ROW, " "); */
741 /*Check for collision*/
742 if (screen[check_x][check_y] != EMPTY)
744 switch (screen[check_x][check_y])
746 case ROBOT:
747 /*We didn't move, or we're stuck in a
748 time warp or something.*/
749 break;
750 case KITTEN: /*Found it!*/
751 play_animation(input);
752 /* Wait for the user to click something */
753 pause();
754 break;
755 default: /*We hit a bogus object; print its message.*/
756 message(messages[bogus_messages[screen[check_x][check_y]-2]]);
757 refresh();
758 break;
760 return;
763 /*Otherwise, move the robot.*/
764 robot.x = check_x;
765 robot.y = check_y;
768 /*finish is called upon signal or progam exit*/
769 static void finish(int sig)
771 (void)sig;
772 exit_rfk = true;
775 /******************************************************************************
777 * Begin helper routines
779 *****************************************************************************/
781 static void pause()
783 int button;
784 rb->lcd_update();
785 do {
786 button = rb->button_get(true);
788 while( ( button == BUTTON_NONE )
789 || ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
792 static int validchar(char a)
794 switch(a)
796 case '#':
797 case ' ':
798 case 127:
799 return 0;
801 return 1;
804 static void play_animation(int input)
806 int counter;
807 struct screen_object left;
808 struct screen_object right;
809 /*The grand cinema scene.*/
810 rb->lcd_puts_scroll(0, ADV_ROW, " ");
812 if (input == RFK_RIGHT || input == RFK_DOWN ||
813 input == RFK_RRIGHT || input == RFK_RDOWN)
815 left = robot;
816 right = kitten;
818 else {
819 left = kitten;
820 right = robot;
822 left.y = ADV_ROW;
823 right.y = ADV_ROW;
824 left.x = ANIMATION_MEET - ANIMATION_LENGTH - 1;
825 right.x = ANIMATION_MEET + ANIMATION_LENGTH;
827 for (counter = ANIMATION_LENGTH; counter > 0; counter--)
829 left.x++;
830 right.x--;
831 /* Clear the previous position (empty the first time) */
832 drawchar(left.x - 1, left.y, ' ');
833 drawchar(right.x + 1, right.y, ' ');
834 draw(left);
835 draw(right);
836 refresh();
837 rb->sleep(HZ);
840 message("You found kitten! Way to go, robot!");
841 refresh();
842 finish(0);
845 /******************************************************************************
847 * Begin initialization routines (called before play begins).
849 *****************************************************************************/
851 static void instructions()
853 #define MARGIN 2
854 int y = MARGIN, space_w, width, height;
855 unsigned short x = MARGIN, i = 0;
856 #define WORDS (sizeof instructions / sizeof (char*))
857 static char* instructions[] = {
858 #if 0
859 /* Not sure if we want to include this? */
860 "robotfindskitten", RFK_VERSION, "", "",
861 "By", "the", "illustrious", "Leonard", "Richardson", "(C)", "1997,", "2000", "",
862 "Written", "originally", "for", "the", "Nerth", "Pork", "robotfindskitten", "contest", "", "",
863 #endif
864 "In", "this", "game", "you", "are", "robot", "(#).", "Your", "job", "is", "to", "find", "kitten.", "This", "task", "is", "complicated", "by", "the", "existence", "of", "various", "things", "which", "are", "not", "kitten.", "Robot", "must", "touch", "items", "to", "determine", "if", "they", "are", "kitten", "or", "not.", "",
865 "The", "game", "ends", "when", "robotfindskitten.", "", "",
866 "Press", "any", "key", "to", "start",
868 rb->lcd_clear_display();
869 rb->lcd_getstringsize(" ", &space_w, &height);
870 for (i = 0; i < WORDS; i++) {
871 rb->lcd_getstringsize(instructions[i], &width, NULL);
872 /* Skip to next line if the current one can't fit the word */
873 if (x + width > LCD_WIDTH - MARGIN) {
874 x = MARGIN;
875 y += height;
877 /* .. or if the word is the empty string */
878 if (rb->strcmp(instructions[i], "") == 0) {
879 x = MARGIN;
880 y += height;
881 continue;
883 /* We filled the screen */
884 if (y + height > LCD_HEIGHT - MARGIN) {
885 y = MARGIN;
886 pause();
887 rb->lcd_clear_display();
889 rb->lcd_putsxy(x, y, instructions[i]);
890 x += width + space_w;
892 pause();
895 static void initialize_arrays()
897 unsigned int counter, counter2;
898 struct screen_object empty;
900 /*Initialize the empty object.*/
901 empty.x = -1;
902 empty.y = -1;
903 #if LCD_DEPTH > 1
904 empty.color = LCD_BLACK;
905 #else
906 empty.color = 0;
907 #endif
908 empty.bold = false;
909 empty.character = ' ';
911 for (counter = 0; counter <= X_MAX; counter++)
913 for (counter2 = 0; counter2 <= Y_MAX; counter2++)
915 screen[counter][counter2] = EMPTY;
919 /*Initialize the other arrays.*/
920 for (counter = 0; counter < MESSAGES; counter++)
922 used_messages[counter] = false;
924 for (counter = 0; counter < NUM_BOGUS; counter++)
926 bogus_messages[counter] = 0;
927 bogus[counter] = empty;
931 /*initialize_robot initializes robot.*/
932 static void initialize_robot()
934 /*Assign a position to the player.*/
935 robot.x = randx();
936 robot.y = randy();
938 robot.character = '#';
939 robot.color = ROBOT_COLOR;
940 robot.bold = false;
941 screen[robot.x][robot.y] = ROBOT;
944 /*initialize kitten, well, initializes kitten.*/
945 static void initialize_kitten()
947 /*Assign the kitten a unique position.*/
948 do {
949 kitten.x = randx();
950 kitten.y = randy();
951 } while (screen[kitten.x][kitten.y] != EMPTY);
953 /*Assign the kitten a character and a color.*/
954 do {
955 kitten.character = randchar();
956 } while (!(validchar(kitten.character)));
957 screen[kitten.x][kitten.y] = KITTEN;
959 kitten.color = colors[randcolor()];
960 kitten.bold = randbold();
963 /*initialize_bogus initializes all non-kitten objects to be used in this run.*/
964 static void initialize_bogus()
966 int counter, index;
967 for (counter = 0; counter < NUM_BOGUS; counter++)
969 /*Give it a color.*/
970 bogus[counter].color = colors[randcolor()];
971 bogus[counter].bold = randbold();
973 /*Give it a character.*/
974 do {
975 bogus[counter].character = randchar();
976 } while (!(validchar(bogus[counter].character)));
978 /*Give it a position.*/
979 do {
980 bogus[counter].x = randx();
981 bogus[counter].y = randy();
982 } while (screen[bogus[counter].x][bogus[counter].y] != EMPTY);
984 screen[bogus[counter].x][bogus[counter].y] = counter+2;
986 /*Find a message for this object.*/
987 do {
988 index = rb->rand() % MESSAGES;
989 } while (used_messages[index] != false);
990 bogus_messages[counter] = index;
991 used_messages[index] = true;
996 /*initialize_screen paints the screen.*/
997 static void initialize_screen()
999 int counter;
1000 char buf[40];
1003 *Print the status portion of the screen.
1005 rb->lcd_clear_display();
1006 rb->lcd_setfont(FONT_SYSFIXED);
1007 rb->snprintf(buf, sizeof(buf), "robotfindskitten %s", RFK_VERSION);
1008 rb->lcd_puts_scroll(0, 0, buf);
1009 refresh();
1011 /*Draw a line across the screen.*/
1012 for (counter = X_MIN; counter <= X_MAX + 1; counter++)
1014 drawchar(counter, ADV_ROW+1, '_');
1018 *Draw all the objects on the playing field.
1020 for (counter = 0; counter < NUM_BOGUS; counter++)
1022 draw(bogus[counter]);
1025 draw(kitten);
1026 draw(robot);
1028 refresh();
1032 /* this is the plugin entry point */
1033 enum plugin_status plugin_start(const void* parameter)
1035 (void)parameter;
1037 exit_rfk = false;
1039 rb->srand(*rb->current_tick);
1041 initialize_arrays();
1044 * Now we initialize the various game objects.
1046 initialize_robot();
1047 initialize_kitten();
1048 initialize_bogus();
1051 * Set up white-on-black screen on color targets
1053 #if LCD_DEPTH >= 16
1054 rb->lcd_set_backdrop(NULL);
1055 rb->lcd_set_foreground(LCD_WHITE);
1056 rb->lcd_set_background(LCD_BLACK);
1057 #endif
1060 * Run the game
1062 instructions();
1064 initialize_screen();
1066 play_game();
1068 rb->lcd_setfont(FONT_UI);
1069 return PLUGIN_OK;