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