Mercurial > hg > index.fcgi > lj > lj046-2players
diff src/gbaopt.c @ 0:c84446dfb3f5
initial add
author | paulo@localhost |
---|---|
date | Fri, 13 Mar 2009 00:39:12 -0700 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/gbaopt.c Fri Mar 13 00:39:12 2009 -0700 1.3 @@ -0,0 +1,123 @@ 1.4 +/* 1.5 + 1.6 +options for gba port of lockjaw 1.7 + 1.8 +*/ 1.9 + 1.10 +#include <stdio.h> 1.11 +#include <string.h> 1.12 +#include "options.h" 1.13 +#include "ljlocale.h" 1.14 +#include "ljplay.h" 1.15 +#include "gbamenus.h" 1.16 + 1.17 +#ifdef ARM9 1.18 +#include "ljds.h" 1.19 +#else 1.20 +#include "ljgba.h" 1.21 +#endif 1.22 + 1.23 +#define optionsMenu commonOptionsMenu 1.24 + 1.25 +unsigned char customPrefs[OPTIONS_MENU_LEN]; 1.26 + 1.27 +void unpackOptions(LJView *v, const unsigned char *prefs) { 1.28 + unpackCommonOptions(v, prefs); 1.29 +} 1.30 + 1.31 +static const char optionsHelpText[] = 1.32 +"\020\021 page \026\027 move \025\024 change Start:play"; 1.33 + 1.34 +void optionsWinInit(void) { 1.35 + ljmenu_init(); 1.36 + ljmenu_cls(); 1.37 + ljmenu_propPanelDrawHelp(optionsHelpText, 1.38 + NULL); 1.39 +} 1.40 + 1.41 +static void optionsClearRow(int y, int hilite) { 1.42 + ljmenu_propPanelDrawRow("", "", y, hilite); 1.43 +} 1.44 + 1.45 +static char hiliteBlinkPhase = 1; 1.46 + 1.47 +void optionsDrawRow(const unsigned char *prefs, 1.48 + int y, int line, int value, int hilite) { 1.49 + char txt[OPTIONS_VALUE_LEN]; 1.50 + const char *nameText; 1.51 + const char *valueDesc = NULL; 1.52 + char altNameText[8]; 1.53 + const char *valueOverride = isDisabledOption(prefs, line); 1.54 + 1.55 + { 1.56 + nameText = ljGetFourCCName(optionsMenu[line].name); 1.57 + if (!nameText) { 1.58 + strncpy(altNameText, optionsMenu[line].name.c, 4); 1.59 + altNameText[4] = 0; 1.60 + nameText = altNameText; 1.61 + } 1.62 + } 1.63 + 1.64 + // Format value 1.65 + if (valueOverride) { 1.66 + strcpy(txt, "overridden"); 1.67 + valueDesc = valueOverride; 1.68 + } else { 1.69 + valueDesc = getOptionsValueStr(txt, line, value); 1.70 + } 1.71 + 1.72 + ljmenu_propPanelDrawRow(nameText, txt, y, hilite); 1.73 + 1.74 + if (hilite & 1) { 1.75 + hiliteBlinkPhase = 0; 1.76 + const char *descText = ljGetFourCCDesc(optionsMenu[line].name); 1.77 + ljmenu_propPanelDrawDesc(descText ? descText : "", 1.78 + valueDesc ? valueDesc : ""); 1.79 + } 1.80 +} 1.81 + 1.82 +static const char *const optionsPageShortNames[7] = { 1.83 + "Game", "Well", "Move", "Line", "Ctrl", "Drop", "Disp" 1.84 +}; 1.85 + 1.86 +void optionsDrawPage(int page, const unsigned char *prefs) { 1.87 + int nPages = 0; 1.88 + for (; optionsPages[nPages].name; ++nPages) { } 1.89 + 1.90 + // draw page title 1.91 + ljmenu_setTitle("LOCKJAW > Options", optionsPages[page].name); 1.92 + 1.93 + // draw all tabs 1.94 + ljmenu_beginTabs(4); 1.95 + for (int p = 0; p < 7; ++p) { 1.96 + ljmenu_addTab(optionsPageShortNames[p], p == page); 1.97 + } 1.98 + ljmenu_endTabs(); 1.99 + 1.100 + for (int i = optionsPages[page].start; 1.101 + i < optionsPages[page + 1].start; ++i) { 1.102 + optionsDrawRow(prefs, i - optionsPages[page].start, 1.103 + i, prefs[i], 0); 1.104 + } 1.105 + for (int y = optionsPages[page + 1].start - optionsPages[page].start; 1.106 + y < 7; ++y) { 1.107 + optionsClearRow(y, 0); 1.108 + } 1.109 +} 1.110 + 1.111 +void optionsIdle(void) { 1.112 + vsync(); 1.113 + ljmenu_setHilitePalette(++hiliteBlinkPhase); 1.114 +} 1.115 + 1.116 +#if 0 1.117 +typedef u16 hicolor_t; 1.118 + 1.119 +__attribute__((aligned(4))) 1.120 +const hicolor_t gbaOptionsPalette[8] = 1.121 +{ 1.122 + RGB5(31,31,31), RGB5(20,20,20), RGB5( 0, 0, 0), RGB5( 0, 0, 0), 1.123 + RGB5(31,31,23), RGB5(20,20,15), RGB5( 0, 0, 0), RGB5( 0, 0, 0) 1.124 +}; 1.125 +#endif 1.126 +