1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007-2009 Joshua Simmons <mud at majidejima dot com>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 /* Enable this to run test mode. (see the end of util.c) */
34 /* Colors of various things. The colors on mono bitmap targets is fixed
35 based on the background/foreground color. */
37 #define BOARD_COLOR LCD_RGBPACK(184,136,72)
38 #define WHITE_COLOR LCD_RGBPACK(255,255,255)
39 #define BLACK_COLOR LCD_RGBPACK(0,0,0)
40 #define LINE_COLOR LCD_RGBPACK(0,0,0)
41 #define BACKGROUND_COLOR LCD_RGBPACK(41,104,74)
42 #define CURSOR_COLOR LCD_RGBPACK(222,0,0)
43 #define MARK_COLOR LCD_RGBPACK(0,0,255)
44 #elif LCD_DEPTH > 1 /* grayscale */
45 #define BOARD_COLOR LCD_LIGHTGRAY
46 #define WHITE_COLOR LCD_WHITE
47 #define BLACK_COLOR LCD_BLACK
48 #define LINE_COLOR LCD_BLACK
49 #define BACKGROUND_COLOR LCD_DARKGRAY
50 #define CURSOR_COLOR LCD_DARKGRAY
51 #define MARK_COLOR LCD_DARKGRAY
55 #ifdef HAVE_TOUCHSCREEN
56 #define GBN_BUTTON_UP BUTTON_TOPMIDDLE
57 #define GBN_BUTTON_DOWN BUTTON_BOTTOMMIDDLE
58 #define GBN_BUTTON_LEFT BUTTON_MIDLEFT
59 #define GBN_BUTTON_RIGHT BUTTON_MIDRIGHT
60 #define GBN_BUTTON_RETREAT BUTTON_BOTTOMLEFT
61 #define GBN_BUTTON_ADVANCE BUTTON_BOTTOMRIGHT
62 #define GBN_BUTTON_MENU BUTTON_TOPLEFT
63 #define GBN_BUTTON_PLAY BUTTON_CENTER | BUTTON_REL
64 #define GBN_BUTTON_CONTEXT BUTTON_CENTER | BUTTON_REPEAT
65 #define GBN_BUTTON_NEXT_VAR BUTTON_TOPRIGHT
67 #elif (CONFIG_KEYPAD == IPOD_1G2G_PAD) \
68 || (CONFIG_KEYPAD == IPOD_3G_PAD) \
69 || (CONFIG_KEYPAD == IPOD_4G_PAD)
70 #define GBN_BUTTON_UP BUTTON_MENU
71 #define GBN_BUTTON_DOWN BUTTON_PLAY
72 #define GBN_BUTTON_LEFT BUTTON_LEFT
73 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
74 #define GBN_BUTTON_RETREAT BUTTON_SCROLL_BACK
75 #define GBN_BUTTON_ADVANCE BUTTON_SCROLL_FWD
76 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
77 #define GBN_BUTTON_MENU BUTTON_SELECT | BUTTON_REPEAT
81 #elif (CONFIG_KEYPAD == SANSA_E200_PAD)
82 #define GBN_BUTTON_UP BUTTON_UP
83 #define GBN_BUTTON_DOWN BUTTON_DOWN
84 #define GBN_BUTTON_LEFT BUTTON_LEFT
85 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
86 #define GBN_BUTTON_RETREAT BUTTON_SCROLL_BACK
87 #define GBN_BUTTON_ADVANCE BUTTON_SCROLL_FWD
88 #define GBN_BUTTON_MENU BUTTON_POWER
89 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
90 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
91 #define GBN_BUTTON_NEXT_VAR BUTTON_REC
93 #elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
94 #define GBN_BUTTON_UP BUTTON_UP
95 #define GBN_BUTTON_DOWN BUTTON_DOWN
96 #define GBN_BUTTON_LEFT BUTTON_LEFT
97 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
98 #define GBN_BUTTON_RETREAT BUTTON_SCROLL_BACK
99 #define GBN_BUTTON_ADVANCE BUTTON_SCROLL_FWD
100 #define GBN_BUTTON_MENU (BUTTON_HOME|BUTTON_REPEAT)
101 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
102 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
105 #elif (CONFIG_KEYPAD == SANSA_C200_PAD)
106 #define GBN_BUTTON_UP BUTTON_UP
107 #define GBN_BUTTON_DOWN BUTTON_DOWN
108 #define GBN_BUTTON_LEFT BUTTON_LEFT
109 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
110 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
111 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
112 #define GBN_BUTTON_MENU BUTTON_POWER
113 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
114 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
115 #define GBN_BUTTON_NEXT_VAR BUTTON_REC
117 #elif (CONFIG_KEYPAD == SANSA_CLIP_PAD)
118 #define GBN_BUTTON_UP BUTTON_UP
119 #define GBN_BUTTON_DOWN BUTTON_DOWN
120 #define GBN_BUTTON_LEFT BUTTON_LEFT
121 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
122 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
123 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
124 #define GBN_BUTTON_MENU BUTTON_POWER
125 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
126 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
127 #define GBN_BUTTON_NEXT_VAR BUTTON_HOME
129 #elif (CONFIG_KEYPAD == SANSA_M200_PAD)
130 #define GBN_BUTTON_UP BUTTON_UP
131 #define GBN_BUTTON_DOWN BUTTON_DOWN
132 #define GBN_BUTTON_LEFT BUTTON_LEFT
133 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
134 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
135 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
136 #define GBN_BUTTON_MENU BUTTON_POWER
137 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
138 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
141 #elif (CONFIG_KEYPAD == CREATIVEZVM_PAD) \
142 || (CONFIG_KEYPAD == CREATIVEZV_PAD)
143 #define GBN_BUTTON_UP BUTTON_UP
144 #define GBN_BUTTON_DOWN BUTTON_DOWN
145 #define GBN_BUTTON_LEFT BUTTON_LEFT
146 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
147 #define GBN_BUTTON_RETREAT BUTTON_BACK
148 #define GBN_BUTTON_ADVANCE BUTTON_CUSTOM
149 #define GBN_BUTTON_MENU BUTTON_MENU
150 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
151 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
152 #define GBN_BUTTON_NEXT_VAR BUTTON_PLAY
154 #elif (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD)
155 #define GBN_BUTTON_UP BUTTON_UP
156 #define GBN_BUTTON_DOWN BUTTON_DOWN
157 #define GBN_BUTTON_LEFT BUTTON_LEFT
158 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
159 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
160 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
161 #define GBN_BUTTON_MENU BUTTON_MENU
162 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
163 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
164 #define GBN_BUTTON_NEXT_VAR BUTTON_VIEW
166 #elif (CONFIG_KEYPAD == PHILIPS_HDD6330_PAD)
167 #define GBN_BUTTON_UP BUTTON_UP
168 #define GBN_BUTTON_DOWN BUTTON_DOWN
169 #define GBN_BUTTON_LEFT BUTTON_LEFT
170 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
171 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
172 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
173 #define GBN_BUTTON_MENU BUTTON_MENU
174 #define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
175 #define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
176 #define GBN_BUTTON_NEXT_VAR BUTTON_NEXT
178 #elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
179 #define GBN_BUTTON_UP BUTTON_UP
180 #define GBN_BUTTON_DOWN BUTTON_DOWN
181 #define GBN_BUTTON_LEFT BUTTON_PREV
182 #define GBN_BUTTON_RIGHT BUTTON_NEXT
183 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
184 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
185 #define GBN_BUTTON_MENU BUTTON_MENU
186 #define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
187 #define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
188 #define GBN_BUTTON_NEXT_VAR BUTTON_RIGHT
190 #elif (CONFIG_KEYPAD == GIGABEAT_PAD)
191 #define GBN_BUTTON_UP BUTTON_UP
192 #define GBN_BUTTON_DOWN BUTTON_DOWN
193 #define GBN_BUTTON_LEFT BUTTON_LEFT
194 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
195 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
196 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
197 #define GBN_BUTTON_MENU BUTTON_MENU
198 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
199 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
200 #define GBN_BUTTON_NEXT_VAR BUTTON_A
202 #elif (CONFIG_KEYPAD == GIGABEAT_S_PAD)
203 #define GBN_BUTTON_UP BUTTON_UP
204 #define GBN_BUTTON_DOWN BUTTON_DOWN
205 #define GBN_BUTTON_LEFT BUTTON_LEFT
206 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
207 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
208 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
209 #define GBN_BUTTON_MENU BUTTON_MENU
210 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
211 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
212 #define GBN_BUTTON_NEXT_VAR BUTTON_PLAY
214 #elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
215 #define GBN_BUTTON_UP BUTTON_SCROLL_UP
216 #define GBN_BUTTON_DOWN BUTTON_SCROLL_DOWN
217 #define GBN_BUTTON_LEFT BUTTON_LEFT
218 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
219 #define GBN_BUTTON_RETREAT BUTTON_FF
220 #define GBN_BUTTON_ADVANCE BUTTON_REW
221 #define GBN_BUTTON_MENU BUTTON_POWER
222 #define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
223 #define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
226 #elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
227 (CONFIG_KEYPAD == IRIVER_H300_PAD)
228 #define GBN_BUTTON_UP BUTTON_UP
229 #define GBN_BUTTON_DOWN BUTTON_DOWN
230 #define GBN_BUTTON_LEFT BUTTON_LEFT
231 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
232 #define GBN_BUTTON_RETREAT BUTTON_OFF
233 #define GBN_BUTTON_ADVANCE BUTTON_ON
234 #define GBN_BUTTON_MENU BUTTON_MODE
235 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
236 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
237 #define GBN_BUTTON_NEXT_VAR BUTTON_REC
239 #elif (CONFIG_KEYPAD == MROBE100_PAD)
240 #define GBN_BUTTON_UP BUTTON_UP
241 #define GBN_BUTTON_DOWN BUTTON_DOWN
242 #define GBN_BUTTON_LEFT BUTTON_LEFT
243 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
244 #define GBN_BUTTON_RETREAT BUTTON_MENU
245 #define GBN_BUTTON_ADVANCE BUTTON_PLAY
246 #define GBN_BUTTON_MENU BUTTON_DISPLAY
247 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
248 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
249 #define GBN_BUTTON_NEXT_VAR BUTTON_POWER
251 #elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
252 #define GBN_BUTTON_UP BUTTON_UP
253 #define GBN_BUTTON_DOWN BUTTON_DOWN
254 #define GBN_BUTTON_LEFT BUTTON_LEFT
255 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
256 #define GBN_BUTTON_RETREAT BUTTON_PLAY
257 #define GBN_BUTTON_ADVANCE BUTTON_REC
258 #define GBN_BUTTON_MENU BUTTON_POWER
259 #define GBN_BUTTON_PLAY BUTTON_SELECT | BUTTON_REL
260 #define GBN_BUTTON_CONTEXT BUTTON_SELECT | BUTTON_REPEAT
263 #elif (CONFIG_KEYPAD == IAUDIO_M3_PAD)
264 /* TODO: these are basically complete guesses, I have no manual to go by */
265 #define GBN_BUTTON_UP BUTTON_RC_VOL_UP
266 #define GBN_BUTTON_DOWN BUTTON_RC_VOL_DOWN
267 #define GBN_BUTTON_LEFT BUTTON_RC_REW
268 #define GBN_BUTTON_RIGHT BUTTON_RC_FF
269 #define GBN_BUTTON_RETREAT BUTTON_VOL_DOWN
270 #define GBN_BUTTON_ADVANCE BUTTON_VOL_UP
271 #define GBN_BUTTON_MENU BUTTON_MODE
272 #define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
273 #define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
276 #elif (CONFIG_KEYPAD == RECORDER_PAD)
277 #define GBN_BUTTON_UP BUTTON_UP
278 #define GBN_BUTTON_DOWN BUTTON_DOWN
279 #define GBN_BUTTON_LEFT BUTTON_LEFT
280 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
281 #define GBN_BUTTON_RETREAT BUTTON_F1
282 #define GBN_BUTTON_ADVANCE BUTTON_F3
283 #define GBN_BUTTON_MENU BUTTON_F2
284 #define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_REL
285 #define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_REPEAT
286 #define GBN_BUTTON_NEXT_VAR BUTTON_ON
288 #elif (CONFIG_KEYPAD == ONDIO_PAD)
289 #define GBN_BUTTON_UP BUTTON_UP
290 #define GBN_BUTTON_DOWN BUTTON_DOWN
291 #define GBN_BUTTON_LEFT BUTTON_LEFT
292 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
293 #define GBN_BUTTON_MENU BUTTON_MENU | BUTTON_REPEAT
294 #define GBN_BUTTON_PLAY BUTTON_MENU | BUTTON_REL
295 #define GBN_BUTTON_NAV_MODE BUTTON_OFF
297 #elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD)
298 #define GBN_BUTTON_UP BUTTON_UP
299 #define GBN_BUTTON_DOWN BUTTON_DOWN
300 #define GBN_BUTTON_LEFT BUTTON_LEFT
301 #define GBN_BUTTON_RIGHT BUTTON_RIGHT
302 #define GBN_BUTTON_RETREAT BUTTON_REW
303 #define GBN_BUTTON_ADVANCE BUTTON_FFWD
304 #define GBN_BUTTON_MENU BUTTON_PLAY | BUTTON_LEFT
305 #define GBN_BUTTON_PLAY BUTTON_PLAY | BUTTON_RIGHT
306 #define GBN_BUTTON_CONTEXT BUTTON_PLAY | BUTTON_DOWN
307 #define GBN_BUTTON_NEXT_VAR BUTTON_PLAY | BUTTON_UP
309 /* No advance/retreat */
312 #elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
313 #define GBN_BUTTON_UP BUTTON_UP
314 #define GBN_BUTTON_DOWN BUTTON_DOWN
315 #define GBN_BUTTON_LEFT BUTTON_PREV
316 #define GBN_BUTTON_RIGHT BUTTON_NEXT
317 #define GBN_BUTTON_RETREAT (BUTTON_OK | BUTTON_PREV)
318 #define GBN_BUTTON_ADVANCE (BUTTON_OK | BUTTON_NEXT)
319 #define GBN_BUTTON_MENU BUTTON_MENU
320 #define GBN_BUTTON_PLAY BUTTON_PLAY
321 #define GBN_BUTTON_CONTEXT BUTTON_OK
322 #define GBN_BUTTON_NEXT_VAR BUTTON_CANCEL
324 #elif (CONFIG_KEYPAD == MPIO_HD200_PAD)
325 #define GBN_BUTTON_UP BUTTON_REW
326 #define GBN_BUTTON_DOWN BUTTON_FF
327 #define GBN_BUTTON_LEFT BUTTON_VOL_DOWN
328 #define GBN_BUTTON_RIGHT BUTTON_VOL_UP
329 #define GBN_BUTTON_RETREAT BUTTON_REC
330 #define GBN_BUTTON_ADVANCE BUTTON_PLAY
331 #define GBN_BUTTON_PLAY BUTTON_FUNC | BUTTON_REL
332 #define GBN_BUTTON_MENU BUTTON_FUNC | BUTTON_REPEAT
334 #elif (CONFIG_KEYPAD == MPIO_HD300_PAD)
335 #define GBN_BUTTON_UP BUTTON_UP
336 #define GBN_BUTTON_DOWN BUTTON_DOWN
337 #define GBN_BUTTON_LEFT BUTTON_REW
338 #define GBN_BUTTON_RIGHT BUTTON_FF
339 #define GBN_BUTTON_RETREAT BUTTON_REC
340 #define GBN_BUTTON_ADVANCE BUTTON_PLAY
341 #define GBN_BUTTON_PLAY BUTTON_ENTER
342 #define GBN_BUTTON_MENU BUTTON_MENU
345 #error Unsupported keypad
349 /* The smallest dimension of the LCD */
350 #define LCD_MIN_DIMENSION (LCD_HEIGHT > LCD_WIDTH ? LCD_WIDTH : LCD_HEIGHT)
353 /* Determine if we have a wide screen or a tall screen. This is used to
354 place the board and footer in acceptable locations also, set the
355 LCD_BOARD_SIZE, making sure that we have at least 16 pixels for the
356 "footer" on either the bottom or the right. */
358 #define FOOTER_RESERVE (16)
360 #if (LCD_WIDTH > LCD_HEIGHT)
362 #define GBN_WIDE_SCREEN
364 #define LCD_BOARD_WIDTH (LCD_WIDTH - FOOTER_RESERVE)
365 #define LCD_BOARD_HEIGHT LCD_HEIGHT
369 #define GBN_TALL_SCREEN
371 #define LCD_BOARD_WIDTH LCD_WIDTH
372 #define LCD_BOARD_HEIGHT (LCD_HEIGHT - FOOTER_RESERVE)
374 #endif /* LCD_WIDTH > LCD_HEIGHT */
377 /* The directory we default to for saving crap */
378 #define DEFAULT_SAVE_DIR PLUGIN_GAMES_DIR "/goban"
380 /* The default file we save to */
381 #define DEFAULT_SAVE (DEFAULT_SAVE_DIR "/goban_d.sgf")
383 /* The size of the buffer we store filenames in (1 reserved for '\0') */
384 #define SAVE_FILE_LENGTH 256
386 /* The maximum setting for idle autosave time, in minutes */
387 #define MAX_AUTOSAVE (30)
389 /* On mono targets, draw while stones with a black outline so they are
390 actually visibile instead of being white on white */
392 #define OUTLINE_STONES
395 /* The current play mode */
396 extern enum play_mode_t play_mode
;
398 /* Show comments when redoing onto a move? */
399 extern bool auto_show_comments
;
401 /* A stack used for parsing/outputting as well as some board functions
402 such as counting liberties and filling in/ removing stones */
403 extern struct stack_t parse_stack
;