summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/menu.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/rockboy/menu.c')
-rw-r--r--apps/plugins/rockboy/menu.c106
1 files changed, 52 insertions, 54 deletions
diff --git a/apps/plugins/rockboy/menu.c b/apps/plugins/rockboy/menu.c
index d10e2b6e1a..9821ce9ba2 100644
--- a/apps/plugins/rockboy/menu.c
+++ b/apps/plugins/rockboy/menu.c
@@ -8,7 +8,6 @@
8#include "rockmacros.h" 8#include "rockmacros.h"
9#include "mem.h" 9#include "mem.h"
10#include "save.h" 10#include "save.h"
11#include "lib/oldmenuapi.h"
12#include "rtc-gb.h" 11#include "rtc-gb.h"
13#include "pcm.h" 12#include "pcm.h"
14 13
@@ -85,7 +84,7 @@ static void setupkeys(void)
85 */ 84 */
86int do_user_menu(void) { 85int do_user_menu(void) {
87 bool done=false; 86 bool done=false;
88 int m, ret=0; 87 int selected=0, ret=0;
89 int result; 88 int result;
90 int time = 0; 89 int time = 0;
91 90
@@ -97,20 +96,15 @@ int do_user_menu(void) {
97 while (rb->button_get(false) != BUTTON_NONE) 96 while (rb->button_get(false) != BUTTON_NONE)
98 rb->yield(); 97 rb->yield();
99 98
100 static const struct menu_item items[] = { 99 MENUITEM_STRINGLIST(menu, "Rockboy Menu", NULL,
101 {"Load Game", NULL }, 100 "Load Game", "Save Game",
102 {"Save Game", NULL }, 101 "Options", "Quit");
103 {"Options", NULL },
104 {"Quit", NULL },
105 };
106 102
107 pcm_init(); 103 pcm_init();
108 104
109 m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL);
110
111 while(!done) 105 while(!done)
112 { 106 {
113 result=menu_show(m); 107 result = rb->do_menu(&menu, &selected, NULL, false);
114 108
115 switch (result) 109 switch (result)
116 { 110 {
@@ -133,8 +127,6 @@ int do_user_menu(void) {
133 } 127 }
134 } 128 }
135 129
136 menu_exit(m);
137
138 rb->lcd_setfont(0); /* Reset the font */ 130 rb->lcd_setfont(0); /* Reset the font */
139 rb->lcd_clear_display(); /* Clear display for screen size changes */ 131 rb->lcd_clear_display(); /* Clear display for screen size changes */
140 132
@@ -288,50 +280,65 @@ static void slot_info(char *info_buf, size_t info_bufsiz, size_t slot_id) {
288 } 280 }
289} 281}
290 282
283/*
284 * slot_get_name
285 */
286static char *slot_get_name(int selected_item, void * data,
287 char * buffer, size_t buffer_len)
288{
289 char (*items)[20] = data;
290 (void) buffer;
291 (void) buffer_len;
292 return items[selected_item];
293}
294
295/*
296 * list_action_callback
297 */
298static int list_action_callback(int action, struct gui_synclist *lists)
299{
300 (void) lists;
301 if (action == ACTION_STD_OK)
302 return ACTION_STD_CANCEL;
303 return action;
304}
305
291/* 306/*
292 * do_slot_menu - prompt the user for a load/save memory slot 307 * do_slot_menu - prompt the user for a load/save memory slot
293 */ 308 */
294static void do_slot_menu(bool is_load) { 309static void do_slot_menu(bool is_load) {
295 bool done=false; 310 bool done=false;
296 311 char items[5][20];
297 char buf[5][20];
298
299 int m;
300 int result; 312 int result;
301 int i; 313 int i;
302
303 struct menu_item items[] = {
304 { buf[0] , NULL },
305 { buf[1] , NULL },
306 { buf[2] , NULL },
307 { buf[3] , NULL },
308 { buf[4] , NULL },
309 };
310
311 int num_items = sizeof(items) / sizeof(*items); 314 int num_items = sizeof(items) / sizeof(*items);
315 struct simplelist_info info;
312 316
313 /* create menu items */ 317 /* create menu items */
314 for (i = 0; i < num_items; i++) 318 for (i = 0; i < num_items; i++)
315 slot_info(buf[i], 20, i); 319 slot_info(items[i], 20, i);
316 320
317 m = menu_init(items, num_items, NULL, NULL, NULL, NULL); 321 rb->simplelist_info_init(&info, NULL, num_items, (void *)items);
322 info.get_name = slot_get_name;
323 info.action_callback = list_action_callback;
318 324
319 while(!done) 325 while(!done)
320 { 326 {
321 result=menu_show(m); 327 if(rb->simplelist_show_list(&info))
322 328 break;
329
330 result = info.selection;
323 if (result<num_items && result >= 0 ) 331 if (result<num_items && result >= 0 )
324 done = do_slot(result, is_load); 332 done = do_slot(result, is_load);
325 else 333 else
326 done = true; 334 done = true;
327 } 335 }
328 menu_exit(m);
329} 336}
330 337
331static void do_opt_menu(void) 338static void do_opt_menu(void)
332{ 339{
333 bool done=false; 340 bool done=false;
334 int m; 341 int selected=0;
335 int result; 342 int result;
336 343
337 static const struct opt_items onoff[2] = { 344 static const struct opt_items onoff[2] = {
@@ -379,63 +386,54 @@ static void do_opt_menu(void)
379 }; 386 };
380#endif 387#endif
381 388
382 static const struct menu_item items[] = { 389 MENUITEM_STRINGLIST(menu, "Options", NULL,
383 { "Max Frameskip", NULL }, 390 "Max Frameskip", "Sound", "Stats", "Set Keys (Buggy)",
384 { "Sound" , NULL },
385 { "Stats" , NULL },
386 { "Set Keys (Buggy)", NULL },
387#ifdef HAVE_LCD_COLOR 391#ifdef HAVE_LCD_COLOR
388 { "Screen Size" , NULL }, 392 "Screen Size", "Screen Rotate", "Set Palette",
389 { "Screen Rotate" , NULL },
390 { "Set Palette" , NULL },
391#endif 393#endif
392 }; 394 );
393
394 m = menu_init(items, sizeof(items) / sizeof(*items), NULL, NULL, NULL, NULL);
395 395
396 options.dirty=1; /* Assume that the settings have been changed */ 396 options.dirty=1; /* Assume that the settings have been changed */
397 397
398 while(!done) 398 while(!done)
399 { 399 {
400 400 result = rb->do_menu(&menu, &selected, NULL, false);
401 result=menu_show(m); 401
402
403 switch (result) 402 switch (result)
404 { 403 {
405 case 0: /* Frameskip */ 404 case 0: /* Frameskip */
406 rb->set_option(items[0].desc, &options.maxskip, INT, frameskip, 405 rb->set_option("Max Frameskip", &options.maxskip, INT, frameskip,
407 sizeof(frameskip)/sizeof(*frameskip), NULL ); 406 sizeof(frameskip)/sizeof(*frameskip), NULL );
408 break; 407 break;
409 case 1: /* Sound */ 408 case 1: /* Sound */
410 if(options.sound>1) options.sound=1; 409 if(options.sound>1) options.sound=1;
411 rb->set_option(items[1].desc, &options.sound, INT, onoff, 2, NULL ); 410 rb->set_option("Sound", &options.sound, INT, onoff, 2, NULL );
412 if(options.sound) sound_dirty(); 411 if(options.sound) sound_dirty();
413 break; 412 break;
414 case 2: /* Stats */ 413 case 2: /* Stats */
415 rb->set_option(items[2].desc, &options.showstats, INT, onoff, 2, NULL ); 414 rb->set_option("Stats", &options.showstats, INT, onoff, 2, NULL );
416 break; 415 break;
417 case 3: /* Keys */ 416 case 3: /* Keys */
418 setupkeys(); 417 setupkeys();
419 break; 418 break;
420#ifdef HAVE_LCD_COLOR 419#ifdef HAVE_LCD_COLOR
421 case 4: /* Screen Size */ 420 case 4: /* Screen Size */
422 rb->set_option(items[4].desc, &options.scaling, INT, scaling, 421 rb->set_option("Screen Size", &options.scaling, INT, scaling,
423 sizeof(scaling)/sizeof(*scaling), NULL ); 422 sizeof(scaling)/sizeof(*scaling), NULL );
424 setvidmode(); 423 setvidmode();
425 break; 424 break;
426 case 5: /* Screen rotate */ 425 case 5: /* Screen rotate */
427 rb->set_option(items[5].desc, &options.rotate, INT, onoff, 2, NULL ); 426 rb->set_option("Screen Rotate", &options.rotate, INT, onoff, 2, NULL );
428 setvidmode(); 427 setvidmode();
429 break; 428 break;
430 case 6: /* Palette */ 429 case 6: /* Palette */
431 rb->set_option(items[6].desc, &options.pal, INT, palette, 17, NULL ); 430 rb->set_option("Set Palette", &options.pal, INT, palette, 17, NULL );
432 set_pal(); 431 set_pal();
433 break; 432 break;
434#endif 433#endif
435 default: 434 default:
436 done=true; 435 done=true;
437 break; 436 break;
438 } 437 }
439 } 438 }
440 menu_exit(m);
441} 439}