63
63
bool INIT = false;
64
64
bool SAVED = false;
65
65
bool forceConsoleReset ;
66
+
67
+ int32_t VOLUME = 0 ;
68
+ int32_t BRIGHTNESS = 0 ;
69
+ const int32_t BRIGHTNESS_COUNT = 10 ;
70
+ const int32_t BRIGHTNESS_LEVELS [10 ] = {10 ,20 ,30 ,40 ,50 ,60 ,70 ,80 ,90 ,100 };
66
71
//}#pragma endregion Globals
67
72
68
73
//{#pragma region Structs
79
84
int action ;
80
85
int offset ;
81
86
} STATES ;
82
- STATES WITHSAVE [6 ] = {
87
+ STATES WITHSAVE [5 ] = {
83
88
{"Resume Game" ,0 , 0 },
84
89
{"Restart Game" ,1 , 10 },
85
90
{"Reload Game" ,2 , 5 },
86
91
{"Overwrite Game" ,4 , 25 },
87
- {"Delete Save" ,5 , 15 },
88
- {"Exit Game" ,6 , 20 }
92
+ {"Delete Save" ,5 , 15 }
89
93
};
90
- STATES WITHOUTSAVE [4 ] = {
94
+ STATES WITHOUTSAVE [3 ] = {
91
95
{"Resume Game" ,0 , 0 },
92
96
{"Restart Game" ,1 , 10 },
93
- {"Save Game" ,3 , 25 },
94
- {"Exit Game" ,6 , 20 }
97
+ {"Save Game" ,3 , 25 }
95
98
};
99
+ STATES EXTRAS [3 ] = {
100
+ {"Volume" ,8 , 45 },
101
+ {"Brightness" ,9 , 50 },
102
+ {"Quit Game" ,6 , 20 }
103
+ };
96
104
STATES STATE ;
97
105
98
106
// THEME
@@ -140,43 +148,62 @@ const uint16_t FONT_5x7[7][250] = {
140
148
{65535 ,0 ,0 ,0 ,65535 ,65535 ,65535 ,65535 ,65535 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,65535 ,65535 ,65535 ,65535 ,0 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,0 ,0 ,0 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,65535 ,0 ,0 ,0 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,0 ,65535 ,65535 ,0 ,0 ,65535 ,0 ,0 ,0 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,0 ,0 ,0 ,65535 ,65535 ,0 ,0 ,0 ,65535 ,0 ,65535 ,65535 ,65535 ,0 ,65535 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,65535 ,65535 ,0 ,0 ,0 ,65535 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,0 ,65535 ,0 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,0 ,65535 ,0 ,0 ,0 ,65535 ,0 ,65535 ,0 ,65535 ,0 ,0 ,0 ,65535 ,0 ,0 ,65535 ,0 ,0 ,65535 ,65535 ,65535 ,65535 ,65535 ,0 ,65535 ,65535 ,65535 ,0 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,65535 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,0 ,0 ,0 ,65535 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,65535 ,0 ,0 ,0 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,0 ,65535 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,0 ,65535 ,0 ,0 ,0 ,0 ,65535 ,0 ,0 ,0 ,0 ,65535 ,0 ,0 ,65535 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,65535 ,0 ,0 ,65535 ,0 ,0 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,65535 ,65535 ,65535 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 },
141
149
};
142
150
143
- const uint16_t icons [35 ][5 ] = {
144
- {0 ,65535 ,65535 ,0 ,0 },
145
- {0 ,65535 ,65535 ,65535 ,0 },
146
- {0 ,65535 ,65535 ,65535 ,65535 },
147
- {0 ,65535 ,65535 ,65535 ,0 },
148
- {0 ,65535 ,65535 ,0 ,0 },
149
- {65535 ,0 ,65535 ,0 ,0 },
150
- {65535 ,0 ,65535 ,65535 ,0 },
151
- {65535 ,0 ,65535 ,65535 ,65535 },
152
- {65535 ,0 ,65535 ,65535 ,0 },
153
- {65535 ,0 ,65535 ,0 ,0 },
154
- {0 ,65535 ,65535 ,0 ,65535 },
155
- {65535 ,0 ,0 ,65535 ,65535 },
156
- {65535 ,0 ,0 ,0 ,65535 },
157
- {65535 ,65535 ,0 ,0 ,65535 },
158
- {65535 ,0 ,65535 ,65535 ,0 },
159
- {0 ,65535 ,65535 ,65535 ,0 },
160
- {65535 ,0 ,65535 ,0 ,65535 },
161
- {65535 ,65535 ,0 ,65535 ,65535 },
162
- {65535 ,0 ,65535 ,0 ,65535 },
163
- {0 ,65535 ,65535 ,65535 ,0 },
164
- {65535 ,0 ,0 ,0 ,65535 },
165
- {0 ,65535 ,0 ,65535 ,0 },
166
- {0 ,0 ,65535 ,0 ,0 },
167
- {0 ,65535 ,0 ,65535 ,0 },
168
- {65535 ,0 ,0 ,0 ,65535 },
169
- {0 ,0 ,0 ,0 ,0 },
170
- {0 ,0 ,0 ,0 ,65535 },
171
- {0 ,0 ,0 ,65535 ,0 },
172
- {65535 ,0 ,65535 ,0 ,0 },
173
- {0 ,65535 ,0 ,0 ,0 },
174
- {0 ,65535 ,65535 ,65535 ,0 },
175
- {65535 ,0 ,65535 ,0 ,65535 },
176
- {65535 ,0 ,65535 ,65535 ,65535 },
177
- {65535 ,0 ,0 ,0 ,65535 },
178
- {0 ,65535 ,65535 ,65535 ,0 },
179
-
151
+ const uint16_t icons [55 ][5 ] = {
152
+ {0 ,65535 ,65535 ,0 ,0 },
153
+ {0 ,65535 ,65535 ,65535 ,0 },
154
+ {0 ,65535 ,65535 ,65535 ,65535 },
155
+ {0 ,65535 ,65535 ,65535 ,0 },
156
+ {0 ,65535 ,65535 ,0 ,0 },
157
+ {65535 ,0 ,65535 ,0 ,0 },
158
+ {65535 ,0 ,65535 ,65535 ,0 },
159
+ {65535 ,0 ,65535 ,65535 ,65535 },
160
+ {65535 ,0 ,65535 ,65535 ,0 },
161
+ {65535 ,0 ,65535 ,0 ,0 },
162
+ {0 ,65535 ,65535 ,0 ,65535 },
163
+ {65535 ,0 ,0 ,65535 ,65535 },
164
+ {65535 ,0 ,0 ,0 ,65535 },
165
+ {65535 ,65535 ,0 ,0 ,65535 },
166
+ {65535 ,0 ,65535 ,65535 ,0 },
167
+ {0 ,65535 ,65535 ,65535 ,0 },
168
+ {65535 ,0 ,65535 ,0 ,65535 },
169
+ {65535 ,65535 ,0 ,65535 ,65535 },
170
+ {65535 ,0 ,65535 ,0 ,65535 },
171
+ {0 ,65535 ,65535 ,65535 ,0 },
172
+ {65535 ,0 ,0 ,0 ,65535 },
173
+ {0 ,65535 ,0 ,65535 ,0 },
174
+ {0 ,0 ,65535 ,0 ,0 },
175
+ {0 ,65535 ,0 ,65535 ,0 },
176
+ {65535 ,0 ,0 ,0 ,65535 },
177
+ {0 ,0 ,0 ,0 ,0 },
178
+ {0 ,0 ,0 ,0 ,65535 },
179
+ {0 ,0 ,0 ,65535 ,0 },
180
+ {65535 ,0 ,65535 ,0 ,0 },
181
+ {0 ,65535 ,0 ,0 ,0 },
182
+ {0 ,65535 ,65535 ,65535 ,0 },
183
+ {65535 ,0 ,65535 ,0 ,65535 },
184
+ {65535 ,0 ,65535 ,65535 ,65535 },
185
+ {65535 ,0 ,0 ,0 ,65535 },
186
+ {0 ,65535 ,65535 ,65535 ,0 },
187
+ {0 ,65535 ,0 ,65535 ,0 },
188
+ {65535 ,65535 ,65535 ,65535 ,65535 },
189
+ {65535 ,65535 ,65535 ,65535 ,65535 },
190
+ {0 ,65535 ,65535 ,65535 ,0 },
191
+ {0 ,0 ,65535 ,0 ,0 },
192
+ {0 ,65535 ,0 ,65535 ,0 },
193
+ {65535 ,0 ,65535 ,0 ,65535 },
194
+ {65535 ,0 ,0 ,0 ,65535 },
195
+ {0 ,65535 ,0 ,65535 ,0 },
196
+ {0 ,0 ,65535 ,0 ,0 },
197
+ {0 ,0 ,0 ,65535 ,0 },
198
+ {0 ,65535 ,0 ,0 ,65535 },
199
+ {0 ,0 ,65535 ,0 ,65535 },
200
+ {0 ,65535 ,0 ,0 ,65535 },
201
+ {0 ,0 ,0 ,65535 ,0 },
202
+ {65535 ,0 ,0 ,0 ,65535 },
203
+ {0 ,0 ,65535 ,0 ,0 },
204
+ {0 ,65535 ,0 ,65535 ,0 },
205
+ {0 ,0 ,65535 ,0 ,0 },
206
+ {65535 ,0 ,0 ,0 ,65535 },
180
207
};
181
208
182
209
const uint16_t logo [12 ][64 ] = {
@@ -404,42 +431,102 @@ const uint16_t FONT_5x7[7][250] = {
404
431
usleep (15000 );
405
432
}
406
433
}
434
+ }
435
+
436
+ void hud_bar (int x , int y , int percent , bool active ) {
437
+ int w , h ;
438
+
439
+ int i = 0 ;
440
+ for (h = 0 ; h < 7 ; h ++ ) {
441
+ for (w = 0 ; w < 100 ; w ++ ) {
442
+ buffer [i ] = (w + h )%2 == 0 ? GUI .fg : GUI .bg ;
443
+ i ++ ;
444
+ }
445
+ }
446
+ ili9341_write_frame_rectangleLE (x , y , 100 , 7 , buffer );
447
+
448
+ if (percent > 0 ) {
449
+ i = 0 ;
450
+ for (h = 0 ; h < 7 ; h ++ ) {
451
+ for (w = 0 ; w < percent ; w ++ ) {
452
+ buffer [i ] = active ? GUI .hl : GUI .fg ;
453
+ i ++ ;
454
+ }
455
+ }
456
+ ili9341_write_frame_rectangleLE (x , y , percent , 7 , buffer );
457
+ }
407
458
}
408
459
460
+ void hud_volume () {
461
+ // y=176;
462
+ int32_t VOLUME = odroid_settings_Volume_get ();
463
+ int LIMIT = OPTIONS - 3 ;
464
+ bool active = OPTION == LIMIT ? true : false;
465
+ hud_bar ((SCREEN .w - 120 ), 176 , VOLUME * 12.5 , active );
466
+ }
467
+
468
+ void hud_brightness () {
469
+ // y=176;
470
+ int LIMIT = OPTIONS - 2 ;
471
+ bool active = OPTION == LIMIT ? true : false;
472
+ BRIGHTNESS = odroid_settings_Backlight_get ();
473
+
474
+ hud_bar ((SCREEN .w - 120 ), 196 , (BRIGHTNESS_COUNT * BRIGHTNESS )+ BRIGHTNESS + 1 , active );
475
+ }
476
+
409
477
void hud_options () {
410
478
x = 16 ;
411
479
y = 28 ;
412
480
w = 5 ;
413
481
h = 5 ;
414
482
i = 0 ;
415
483
int n ;
416
- if (OPTIONS == 6 ) {
417
- for (n = 0 ; n < OPTIONS ; n ++ ) {
484
+ if (OPTIONS == 8 ) {
485
+ for (n = 0 ; n < 5 ; n ++ ) {
418
486
STATE = WITHSAVE [n ];
419
487
y += 20 ;
420
488
for (int r = 0 ; r < 5 ; r ++ ){for (int c = 0 ; c < 5 ; c ++ ) {
421
489
buffer [i ] = icons [r + STATE .offset ][c ] == WHITE ? OPTION == n ? GUI .hl : GUI .fg : GUI .bg ;i ++ ;
422
490
}}
423
- if (n == OPTIONS - 1 ) {y = 216 ;}
424
491
ili9341_write_frame_rectangleLE (x , y , w , h , buffer );
425
492
hud_text (x + 10 ,y ,STATE .label ,false,OPTION == n ?true:false);
426
493
i = 0 ;
427
494
}
428
- STATE = WITHSAVE [OPTION ];
429
495
} else {
430
- for (n = 0 ; n < OPTIONS ; n ++ ) {
496
+ for (n = 0 ; n < 3 ; n ++ ) {
431
497
STATE = WITHOUTSAVE [n ];
432
498
y += 20 ;
433
499
for (int r = 0 ; r < 5 ; r ++ ){for (int c = 0 ; c < 5 ; c ++ ) {
434
500
buffer [i ] = icons [r + STATE .offset ][c ] == WHITE ? OPTION == n ? GUI .hl : GUI .fg : GUI .bg ;i ++ ;
435
501
}}
436
- if (n == OPTIONS - 1 ) {y = 216 ;}
437
502
ili9341_write_frame_rectangleLE (x , y , w , h , buffer );
438
503
hud_text (x + 10 ,y ,STATE .label ,false,OPTION == n ?true:false);
439
504
i = 0 ;
440
505
}
441
- STATE = WITHOUTSAVE [OPTION ];
442
506
}
507
+
508
+ y = 156 ;
509
+ for (n = 0 ; n < 3 ; n ++ ) {
510
+ STATE = EXTRAS [n ];
511
+ y += 20 ;
512
+ for (int r = 0 ; r < 5 ; r ++ ){for (int c = 0 ; c < 5 ; c ++ ) {
513
+ buffer [i ] = icons [r + STATE .offset ][c ] == WHITE ? OPTION == (n + OPTIONS - 3 ) ? GUI .hl : GUI .fg : GUI .bg ;i ++ ;
514
+ }}
515
+ ili9341_write_frame_rectangleLE (x , y , w , h , buffer );
516
+ hud_text (x + 10 ,y ,STATE .label ,false,OPTION == (n + OPTIONS - 3 )?true:false);
517
+ i = 0 ;
518
+ }
519
+
520
+ int LIMIT = OPTIONS - 3 ;
521
+ if (OPTION < LIMIT ) {
522
+ STATE = OPTIONS == 8 ? WITHSAVE [OPTION ] : WITHOUTSAVE [OPTION ];
523
+ } else {
524
+ STATE = EXTRAS [OPTION - LIMIT ];
525
+ }
526
+ printf ("\n**********\n%s - %d:%d\n**********\n" , STATE .label , OPTION , LIMIT );
527
+
528
+ hud_volume ();
529
+ hud_brightness ();
443
530
}
444
531
//}#pragma endregion Display
445
532
@@ -450,10 +537,10 @@ const uint16_t FONT_5x7[7][250] = {
450
537
buffer = (uint16_t * )malloc (size );
451
538
if (!buffer ) abort ();
452
539
OPTION = 0 ;
453
- OPTIONS = SAVED ? 6 : 4 ;
540
+ OPTIONS = SAVED ? 8 : 6 ;
454
541
hud_theme ();
455
542
GUI = THEMES [USER ];
456
- STATE = OPTIONS == 6 ? WITHSAVE [OPTION ] : WITHOUTSAVE [OPTION ];
543
+ STATE = OPTIONS == 8 ? WITHSAVE [OPTION ] : WITHOUTSAVE [OPTION ];
457
544
INIT = true;
458
545
}
459
546
}
@@ -468,9 +555,9 @@ const uint16_t FONT_5x7[7][250] = {
468
555
469
556
//{#pragma region Menu
470
557
void hud_menu (void ) {
471
- int volume = odroid_audio_volume_get ();
558
+ VOLUME = odroid_audio_volume_get ();
472
559
#ifdef CONFIG_LCD_DRIVER_CHIP_RETRO_ESP32
473
- volume = 8 ;
560
+ // volume = 8;
474
561
#endif
475
562
odroid_audio_terminate ();
476
563
hud_init ();
@@ -501,6 +588,49 @@ const uint16_t FONT_5x7[7][250] = {
501
588
usleep (200000 );
502
589
//debounce(ODROID_INPUT_DOWN);
503
590
}
591
+ /*
592
+ LEFT
593
+ */
594
+ if (gamepad .values [ODROID_INPUT_LEFT ]) {
595
+ if (OPTION == OPTIONS - 3 ) {
596
+ if (VOLUME > 0 ) {
597
+ VOLUME -- ;
598
+ odroid_settings_Volume_set (VOLUME );
599
+ hud_options ();
600
+ usleep (200000 );
601
+ }
602
+ }
603
+ if (OPTION == OPTIONS - 3 + 1 ) {
604
+ if (BRIGHTNESS > 0 ) {
605
+ BRIGHTNESS -- ;
606
+ odroid_settings_Backlight_set (BRIGHTNESS );
607
+ hud_options ();
608
+ usleep (200000 );
609
+ }
610
+ }
611
+ }
612
+
613
+ /*
614
+ RIGHT
615
+ */
616
+ if (gamepad .values [ODROID_INPUT_RIGHT ]) {
617
+ if (OPTION == OPTIONS - 3 ) {
618
+ if (VOLUME < 8 ) {
619
+ VOLUME ++ ;
620
+ odroid_settings_Volume_set (VOLUME );
621
+ hud_options ();
622
+ usleep (200000 );
623
+ }
624
+ }
625
+ if (OPTION == OPTIONS - 3 + 1 ) {
626
+ if (BRIGHTNESS < (BRIGHTNESS_COUNT - 1 )) {
627
+ BRIGHTNESS ++ ;
628
+ odroid_settings_Backlight_set (BRIGHTNESS );
629
+ hud_options ();
630
+ usleep (200000 );
631
+ }
632
+ }
633
+ }
504
634
/*
505
635
BUTTON B
506
636
*/
@@ -513,7 +643,7 @@ const uint16_t FONT_5x7[7][250] = {
513
643
BUTTON A
514
644
*/
515
645
if (gamepad .values [ODROID_INPUT_A ]) {
516
- odroid_audio_volume_set (volume );
646
+ odroid_audio_volume_set (VOLUME );
517
647
hud_debug (STATE .label );
518
648
ACTION = STATE .action ;
519
649
switch (ACTION ) {
0 commit comments