summaryrefslogtreecommitdiff
path: root/apps/plugins/xrick/system/sysmenu_rockbox.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/xrick/system/sysmenu_rockbox.c')
-rw-r--r--apps/plugins/xrick/system/sysmenu_rockbox.c200
1 files changed, 200 insertions, 0 deletions
diff --git a/apps/plugins/xrick/system/sysmenu_rockbox.c b/apps/plugins/xrick/system/sysmenu_rockbox.c
new file mode 100644
index 0000000000..fb80881749
--- /dev/null
+++ b/apps/plugins/xrick/system/sysmenu_rockbox.c
@@ -0,0 +1,200 @@
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Port of xrick, a Rick Dangerous clone, to Rockbox.
11 * See http://www.bigorno.net/xrick/
12 *
13 * Copyright (C) 2008-2014 Pierluigi Vicinanza
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ****************************************************************************/
24
25#include "xrick/system/sysmenu_rockbox.h"
26
27#include "xrick/config.h"
28#include "xrick/control.h"
29#include "xrick/draw.h"
30#include "xrick/game.h"
31#include "xrick/system/system.h"
32#include "xrick/system/syssnd_rockbox.h"
33
34#include "plugin.h"
35#ifndef HAVE_LCD_COLOR
36#include "lib/grey.h"
37#endif
38
39#ifdef HAVE_LCD_COLOR
40static fb_data *lcd_fb=NULL;
41#endif
42
43#ifdef ENABLE_CHEATS
44/*
45 * Cheat settings menu
46 */
47static char * sysmenu_cheatItemText(int selected_item, void *data, char *buffer, size_t buffer_len)
48{
49 (void)selected_item;
50 cheat_t cheat = (cheat_t)data;
51 (void)buffer;
52 (void)buffer_len;
53 char * messages[] =
54 {
55 "Disable Unlimited Lives/Ammo Mode",
56 "Enable Unlimited Lives/Ammo Mode",
57 "Disable Never Die Mode",
58 "Enable Never Die Mode",
59 "Disable Expose Mode",
60 "Enable Expose Mode"
61 };
62
63 switch (cheat)
64 {
65 case Cheat_UNLIMITED_ALL:
66 {
67 return game_cheat1? messages[0] : messages[1];
68 }
69 case Cheat_NEVER_DIE:
70 {
71 return game_cheat2? messages[2] : messages[3];
72 }
73 case Cheat_EXPOSE:
74 {
75 return game_cheat3? messages[4] : messages[5];
76 }
77 default: break;
78 }
79 return "";
80}
81
82/*
83 * Callback invoked by cheat menu item
84 */
85static int sysmenu_doToggleCheat(void *param)
86{
87 cheat_t cheat = (cheat_t)param;
88 game_toggleCheat(cheat);
89 return 0;
90}
91
92MENUITEM_FUNCTION_DYNTEXT(sysmenu_unlimitedAllItem, MENU_FUNC_USEPARAM, sysmenu_doToggleCheat,
93 sysmenu_cheatItemText, NULL, (void *)Cheat_UNLIMITED_ALL,
94 NULL, Icon_NOICON);
95
96MENUITEM_FUNCTION_DYNTEXT(sysmenu_neverDieItem, MENU_FUNC_USEPARAM, sysmenu_doToggleCheat,
97 sysmenu_cheatItemText, NULL, (void *)Cheat_NEVER_DIE,
98 NULL, Icon_NOICON);
99
100MENUITEM_FUNCTION_DYNTEXT(sysmenu_exposeItem, MENU_FUNC_USEPARAM, sysmenu_doToggleCheat,
101 sysmenu_cheatItemText, NULL, (void *)Cheat_EXPOSE,
102 NULL, Icon_NOICON);
103
104MAKE_MENU(sysmenu_cheatItems, "Cheat Settings", NULL, Icon_NOICON,
105 &sysmenu_unlimitedAllItem, &sysmenu_neverDieItem, &sysmenu_exposeItem);
106
107#endif /* ENABLE_CHEATS */
108
109/*
110 * Display main menu
111 */
112void sysmenu_exec(void)
113{
114 int result;
115 bool done;
116
117 enum
118 {
119 Menu_RESUME,
120 Menu_RESTART,
121#ifdef ENABLE_CHEATS
122 Menu_CHEAT_SETTINGS,
123#endif
124 Menu_QUIT
125 };
126
127 MENUITEM_STRINGLIST(sysmenu_mainItems, "xrick Menu", NULL,
128 "Resume Game",
129 "Restart Game",
130#ifdef ENABLE_CHEATS
131 "Cheat Settings",
132#endif
133 ID2P(LANG_MENU_QUIT));
134
135#ifdef ENABLE_SOUND
136 syssnd_pauseAll(true);
137#endif
138
139#ifndef HAVE_LCD_COLOR
140 grey_show(false);
141#endif
142
143 done = false;
144 do
145 {
146 rb->button_clear_queue();
147
148 result = rb->do_menu(&sysmenu_mainItems, NULL, NULL, false);
149 switch(result)
150 {
151 case Menu_RESUME:
152 {
153 done = true;
154 break;
155 }
156 case Menu_RESTART:
157 {
158 control_set(Control_END);
159 done = true;
160 break;
161 }
162#ifdef ENABLE_CHEATS
163 case Menu_CHEAT_SETTINGS:
164 {
165 rb->do_menu(&sysmenu_cheatItems, NULL, NULL, false);
166 break;
167 }
168#endif
169 case Menu_QUIT:
170 {
171 control_set(Control_EXIT);
172 done = true;
173 break;
174 }
175 default: break;
176 }
177 } while (!done);
178
179#ifdef HAVE_LCD_COLOR
180 if (!(control_test(Control_EXIT)))
181 {
182 if(!lcd_fb)
183 {
184 struct viewport *vp_main = rb->lcd_set_viewport(NULL);
185 lcd_fb = vp_main->buffer->fb_ptr;
186 }
187 rb->memset(lcd_fb, 0, sizeof(fb_data) * LCD_WIDTH * LCD_HEIGHT);
188 sysvid_update(&draw_SCREENRECT);
189 rb->lcd_update();
190 }
191#else
192 grey_show(true);
193#endif
194
195#ifdef ENABLE_SOUND
196 syssnd_pauseAll(false);
197#endif
198}
199
200/* eof */