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