view src/gbaopt.c @ 2:80a2761bd3a4

change DS keys (add alt. rotate)
author paulo@localhost
date Mon, 23 Mar 2009 01:19:12 -0700
parents
children
line source
1 /*
3 options for gba port of lockjaw
5 */
7 #include <stdio.h>
8 #include <string.h>
9 #include "options.h"
10 #include "ljlocale.h"
11 #include "ljplay.h"
12 #include "gbamenus.h"
14 #ifdef ARM9
15 #include "ljds.h"
16 #else
17 #include "ljgba.h"
18 #endif
20 #define optionsMenu commonOptionsMenu
22 unsigned char customPrefs[OPTIONS_MENU_LEN];
24 void unpackOptions(LJView *v, const unsigned char *prefs) {
25 unpackCommonOptions(v, prefs);
26 }
28 static const char optionsHelpText[] =
29 "\020\021 page \026\027 move \025\024 change Start:play";
31 void optionsWinInit(void) {
32 ljmenu_init();
33 ljmenu_cls();
34 ljmenu_propPanelDrawHelp(optionsHelpText,
35 NULL);
36 }
38 static void optionsClearRow(int y, int hilite) {
39 ljmenu_propPanelDrawRow("", "", y, hilite);
40 }
42 static char hiliteBlinkPhase = 1;
44 void optionsDrawRow(const unsigned char *prefs,
45 int y, int line, int value, int hilite) {
46 char txt[OPTIONS_VALUE_LEN];
47 const char *nameText;
48 const char *valueDesc = NULL;
49 char altNameText[8];
50 const char *valueOverride = isDisabledOption(prefs, line);
52 {
53 nameText = ljGetFourCCName(optionsMenu[line].name);
54 if (!nameText) {
55 strncpy(altNameText, optionsMenu[line].name.c, 4);
56 altNameText[4] = 0;
57 nameText = altNameText;
58 }
59 }
61 // Format value
62 if (valueOverride) {
63 strcpy(txt, "overridden");
64 valueDesc = valueOverride;
65 } else {
66 valueDesc = getOptionsValueStr(txt, line, value);
67 }
69 ljmenu_propPanelDrawRow(nameText, txt, y, hilite);
71 if (hilite & 1) {
72 hiliteBlinkPhase = 0;
73 const char *descText = ljGetFourCCDesc(optionsMenu[line].name);
74 ljmenu_propPanelDrawDesc(descText ? descText : "",
75 valueDesc ? valueDesc : "");
76 }
77 }
79 static const char *const optionsPageShortNames[7] = {
80 "Game", "Well", "Move", "Line", "Ctrl", "Drop", "Disp"
81 };
83 void optionsDrawPage(int page, const unsigned char *prefs) {
84 int nPages = 0;
85 for (; optionsPages[nPages].name; ++nPages) { }
87 // draw page title
88 ljmenu_setTitle("LOCKJAW > Options", optionsPages[page].name);
90 // draw all tabs
91 ljmenu_beginTabs(4);
92 for (int p = 0; p < 7; ++p) {
93 ljmenu_addTab(optionsPageShortNames[p], p == page);
94 }
95 ljmenu_endTabs();
97 for (int i = optionsPages[page].start;
98 i < optionsPages[page + 1].start; ++i) {
99 optionsDrawRow(prefs, i - optionsPages[page].start,
100 i, prefs[i], 0);
101 }
102 for (int y = optionsPages[page + 1].start - optionsPages[page].start;
103 y < 7; ++y) {
104 optionsClearRow(y, 0);
105 }
106 }
108 void optionsIdle(void) {
109 vsync();
110 ljmenu_setHilitePalette(++hiliteBlinkPhase);
111 }
113 #if 0
114 typedef u16 hicolor_t;
116 __attribute__((aligned(4)))
117 const hicolor_t gbaOptionsPalette[8] =
118 {
119 RGB5(31,31,31), RGB5(20,20,20), RGB5( 0, 0, 0), RGB5( 0, 0, 0),
120 RGB5(31,31,23), RGB5(20,20,15), RGB5( 0, 0, 0), RGB5( 0, 0, 0)
121 };
122 #endif