-
Notifications
You must be signed in to change notification settings - Fork 4
/
settings.py
778 lines (754 loc) · 33.8 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
from micropython import const
from framebuf import FrameBuffer,RGB565
from PicoGameBoy import PicoGameBoy
from time import sleep
from random import randint
import array
import os
import sys
from random import randint
import machine
from math import ceil
try:
os.rename("/main.py", "/settings.py")
os.rename("/title.py", "/main.py")
except:
""
pgb = PicoGameBoy()
runcheck=False
black=PicoGameBoy.color(0,0,0)
white=PicoGameBoy.color(255,255,255)
opt=0
sleep(0.2)
try:
with open("background.conf","r") as r:
bindex=int(r.read())
except:
bindex=8
bgcolors=(
(215, 0, 0),
(227, 160, 5),
(220, 213, 0),
(0, 205, 0),
(0, 0, 205),
(141, 2, 171),
(227, 52, 189),
(161, 161, 161),
(69, 69, 69),
(0,0,0),
(255,255,255))
bgcolor=bgcolors[bindex]
bgcolor565=PicoGameBoy.color(*bgcolor)
if sum(bgcolor)<765:
tcolor=1
else:
tcolor=0
if tcolor==0:
ottcolor=PicoGameBoy.color(255,255,255)
else:
ottcolor=PicoGameBoy.color(0,0,0)
ttcolor=PicoGameBoy.color(255,255,255)
if tcolor==0:
ttcolor=PicoGameBoy.color(0,0,0)
try:
with open("animated.conf") as r:
if r.read()=="True":
animated=True
else:
animated=False
except:
animated=True
try:
with open("VERSION") as r:
version=r.read()
except:
version="NULL"
selectcolor=PicoGameBoy.color(127,127,127)
if tcolor==0:
selectcolor=PicoGameBoy.color(200,200,200)
try:
with open("language.conf") as r:
language=int(r.read())
if language>4:
raise
except:
language=0
with open("Main Text.csv") as w:
data=w.read().split("\n")[language]
data=data.split(", ")
dum=data[3].split("/")
del data
def readchunk_mask( filename,x2,y2,w,h,cmask=57351):
with open(filename,"rb") as r:
for x in range(h):
tempfb=FrameBuffer(bytearray(r.read(2*w)),w,1,RGB565)
pgb.blit(tempfb,x2,y2+x,cmask)
del tempfb
def stats():
pgb.fill(bgcolor565)
if language==0:
pgb.create_text("OS Stats",-1,10,ttcolor)
noptions=["OS Version: ", "MicroPy Version: ", "Storage Free: ", "Games: ","Libraries: ","Battery: "]
pgb.create_text("Press B to exit",-1,220,ttcolor)
elif language==1:
pgb.create_text("OS Estadistica",-1,10,ttcolor)
noptions=["OS Version: ", "MicroPy Version: ", "Espacio Libre: ", "Juegos: ","Bibliotecas: ","Bateria: "]
pgb.create_text("Presione B para salir",-1,220,ttcolor)
elif language==2:
pgb.create_text("OS Statistiques",-1,10,ttcolor)
noptions=["OS Version: ", "MicroPy Version: ", "Espace Libre: ", "Jeux: ","Bibliotheques: ","Batterie: "]
pgb.create_text("Appuyez sur B pour quitter",-1,220,ttcolor)
elif language==3:
pgb.create_text("OS Statistiken",-1,10,ttcolor)
noptions=["OS Version: ", "MicroPy Version: ", "Freiraum: ", "Spiele: ","Bibliotheken: ","Batterie: "]
pgb.create_text("Drucken Sie B, um den",-1,210,ttcolor)
pgb.create_text("Vorgang zu beenden",-1,220,ttcolor)
elif language==4:
pgb.create_text("OS Statistiche",-1,10,ttcolor)
noptions=["OS Versione: ", "MicroPy Versione: ", "Spazio Libero: ", "Giochi: ","Librerie: ","Batteria: "]
pgb.create_text("Premi B per uscire",-1,220,ttcolor)
while True:
pgb.fill_rect(0,25,240,180,bgcolor565)
for i,option in enumerate(noptions):
pgb.rect(10,35+i*30,220,20,white)
pgb.rect(11,36+i*30,118,18,black)
if i==0:
option=option+str(version)
elif i==1:
mversion=str(sys.implementation.version)
mversion="V"+mversion.replace(")","").replace("(","").replace(", \'\'","").replace(", ",".")
option=option+mversion
elif i==2:
stat=os.statvfs('/')
amntfree=stat[0] * stat[3]
storage=str(ceil(int(amntfree)/1000)-5)+"kb"
option=option+storage
elif i==3:
amt=len(os.listdir("/games/"))
option=option+str(amt)
elif i==4:
amt=len(os.listdir("/libs/"))
option=option+str(amt)
elif i==5:
adc_reading = vpin.read_u16()
adc_voltage = (adc_reading * 3.3) / 65535
vsys_voltage = adc_voltage * 12
console=0
if vsys_voltage>10:
vsys_voltage = adc_voltage * 3
percentage=int(int(((round(vsys_voltage,3)-1.9)/2.7)*100))
console=1
else:
percentage=int(int(((round(vsys_voltage,3)-1.9)/1)*100))
console=0
if console==0:
if percentage>100 and percentage<125:
percentage=100
if percentage<130:
pastpercentage.append(percentage)
if len(pastpercentage)>200:
pastpercentage.pop(0)
percentage=int(int(sum(pastpercentage)/len(pastpercentage)))
elif console==1:
if percentage>100 and percentage<110:
percentage=100
if percentage<110:
pastpercentage.append(percentage)
if len(pastpercentage)>200:
pastpercentage.pop(0)
percentage=int(int(sum(pastpercentage)/len(pastpercentage)))
if percentage>100:
option=option+"USB"
else:
option=option+str(percentage)+"%"
pgb.create_text(option,(120- int(len(option)/2 * 8)),42+i*30,ttcolor)
pgb.show()
if pgb.button_B():
sleep(0.2)
break
def languages():
global language
opti=language
sleep(.1)
while True:
pgb.fill(bgcolor565)
if language==0:
pgb.create_text("Settings",-1,10,ttcolor)
elif language==1:
pgb.create_text("Ajustes",-1,10,ttcolor)
elif language==2:
pgb.create_text("Parametres",-1,10,ttcolor)
elif language==3:
pgb.create_text("Einstellungen",-1,10,ttcolor)
elif language==4:
pgb.create_text("Impostazioni",-1,10,ttcolor)
pgb.create_text("PicoBoy "+version,10,225,ttcolor)
options=["English", "Espanol", "Francais", "Deutsch", "Italiano"]
for i,option in enumerate(options):
pgb.rect(10,25+i*30,220,20,white)
pgb.rect(11,26+i*30,218,18,black)
if i==opti:
pgb.fill_rect(12,27+i*30,216,16,selectcolor)
pgb.create_text(option,-1,32+i*30,ttcolor)
if pgb.button_up() and opti>0:
opti-=1
pgb.show()
sleep(0.1)
if pgb.button_down() and opti<len(options)-1:
opti+=1
pgb.show()
sleep(0.1)
if pgb.button_A():
language=opti
with open("language.conf", "w") as w:
w.write(str(opti))
with open("Main Text.csv") as w:
global dum
data=w.read().split("\n")[language]
data=data.split(", ")
dum=data[3].split("/")
del data
sleep(0.1)
return
pgb.show()
def background():
global bgcolor565
global bgcolor
global white
global black
global tcolor
global ttcolor
global runcheck
global ottcolor
global selectcolor
global bindex
opt=0
while True:
pgb.fill(bgcolor565)
if language==0:
pgb.create_text("Settings",-1,10,ttcolor)
elif language==1:
pgb.create_text("Ajustes",-1,10,ttcolor)
elif language==2:
pgb.create_text("Parametres",-1,10,ttcolor)
elif language==3:
pgb.create_text("Einstellungen",-1,10,ttcolor)
elif language==4:
pgb.create_text("Impostazioni",-1,10,ttcolor)
pgb.create_text("PicoBoy "+version,10,225,ttcolor)
if language==0:
options=["Drawing Background","Color Background", "Exit"]
elif language==1:
options=["Tema de dibujo","Tema de color","Salir"]
elif language==2:
options=["Fond de dessin", "Fond de couleur", "Quitter"]
elif language==3:
options=["Hintergrund zeichnen", "Hintergrundfarbe", "Beenden"]
elif language==4:
options=["Sfondo disegno","Colore sfondo", "Esci"]
for i,option in enumerate(options):
pgb.rect(10,25+i*30,220,20,white)
pgb.rect(11,26+i*30,218,18,black)
if i==opt:
pgb.fill_rect(12,27+i*30,216,16,selectcolor)
pgb.create_text(option,-1,32+i*30,ttcolor)
if pgb.button_up() and opt>0:
opt-=1
pgb.show()
sleep(0.1)
if pgb.button_down() and opt<len(options)-1:
opt+=1
pgb.show()
sleep(0.1)
if pgb.button_A():
if opt==1:
sleep(0.2)
while True:
pgb.fill(bgcolor565)
if language==0:
pgb.create_text("Choose a background color",-1,-1,ttcolor)
pgb.create_text("using the left and right",-1,125,ttcolor)
pgb.create_text("buttons.",-1,140,ttcolor)
pgb.create_text("Press A to exit",-1,220,ttcolor)
elif language==1:
pgb.create_text("Elige un color de tema",-1,-1,ttcolor)
pgb.create_text("Usando la izquierda y",-1,125,ttcolor)
pgb.create_text("la derecha botones.",-1,140,ttcolor)
pgb.create_text("Presione A para salir",-1,220,ttcolor)
elif language==2:
pgb.create_text("Choisissez une couleur de",-1,-1,ttcolor)
pgb.create_text("fond en utilisant la gauche ",-1,125,ttcolor)
pgb.create_text("et la droite boutons.",-1,140,ttcolor)
pgb.create_text("Appuyez sur A pour quitter",-1,220,ttcolor)
elif language==3:
pgb.create_text("Wahlen Sie eine Hintergrund",-1,-1,ttcolor)
pgb.create_text("farbe umit der linken und",-1,125,ttcolor)
pgb.create_text("rechten tasten.",-1,137,ttcolor)
pgb.create_text("Drucken Sie A, um den",-1,210,ttcolor)
pgb.create_text("Vorgang zu beenden",-1,220,ttcolor)
elif language==4:
pgb.create_text("Scegli un colore di sfondo",-1,-1,ttcolor)
pgb.create_text("usando sinistra e destra",-1,125,ttcolor)
pgb.create_text("pulsanti.",-1,140,ttcolor)
pgb.create_text("Premi A per uscire",-1,220,ttcolor)
if runcheck:
runcheck=False
if pgb.button_A():
return
if pgb.button_B():
sleep(0.2)
break
if pgb.button_left() and bindex>0:
bindex-=1
runcheck=True
if pgb.button_right() and bindex<len(bgcolors)-1:
bindex+=1
runcheck=True
pgb.show()
if runcheck:
bgcolor=bgcolors[bindex]
bgcolor565=PicoGameBoy.color(*bgcolor)
if sum(bgcolor)<765:
tcolor=1
else:
tcolor=0
ttcolor=PicoGameBoy.color(255,255,255)
if tcolor==0:
ttcolor=PicoGameBoy.color(0,0,0)
with open("background.conf","w") as w:
w.write(str(bindex))
if tcolor==0:
ottcolor=white
else:
ottcolor=black
selectcolor=PicoGameBoy.color(127,127,127)
if tcolor==0:
selectcolor=PicoGameBoy.color(200,200,200)
pgb.fill(bgcolor565)
if language==0:
pgb.create_text("Choose a background color",-1,-1,ttcolor)
pgb.create_text("using the left and right",-1,125,ttcolor)
pgb.create_text("buttons.",-1,140,ttcolor)
pgb.create_text("Press A to exit",-1,220,ttcolor)
elif language==1:
pgb.create_text("Elige un color de tema",-1,-1,ttcolor)
pgb.create_text("Usando la izquierda y",-1,125,ttcolor)
pgb.create_text("la derecha botones.",-1,140,ttcolor)
pgb.create_text("Presione A para salir",-1,220,ttcolor)
elif language==2:
pgb.create_text("Choisissez une couleur de",-1,-1,ttcolor)
pgb.create_text("fond en utilisant la gauche ",-1,125,ttcolor)
pgb.create_text("et la droite boutons.",-1,140,ttcolor)
pgb.create_text("Appuyez sur A pour quitter",-1,220,ttcolor)
elif language==3:
pgb.create_text("Wahlen Sie eine Hintergrund",-1,-1,ttcolor)
pgb.create_text("farbe umit der linken und",-1,125,ttcolor)
pgb.create_text("rechten tasten.",-1,137,ttcolor)
pgb.create_text("Drucken Sie A, um den",-1,210,ttcolor)
pgb.create_text("Vorgang zu beenden",-1,220,ttcolor)
elif language==4:
pgb.create_text("Scegli un colore di sfondo",-1,-1,ttcolor)
pgb.create_text("usando sinistra e destra",-1,125,ttcolor)
pgb.create_text("pulsanti.",-1,140,ttcolor)
pgb.create_text("Premi A per uscire",-1,220,ttcolor)
pgb.show()
sleep(0.2)
if opt==0:
sleep(0.2)
bgs=os.listdir("/bglist")
page=0
while True:
pgb.fill(bgcolor565)
options=[]
for x in range(4):
try:
options.append(bgs[x+(page*4)])
except:
"End of list"
if language==0:
options.append("Exit")
pgb.create_text("Choose a background",-1,10,ttcolor)
elif language==1:
options.append("Salida")
pgb.create_text("Elige un tema",-1,10,ttcolor)
elif language==2:
options.append("Quitter")
pgb.create_text("Choisissez un fond",-1,10,ttcolor)
elif language==3:
options.append("Ausfahrt")
pgb.create_text("Wahlen Sie einen Hintergrund",-1,10,ttcolor)
elif language==4:
options.append("Uscita")
pgb.create_text("Scegli uno sfondo",-1,10,ttcolor)
for i,option in enumerate(options):
pgb.rect(10,25+i*30,220,20,white)
pgb.rect(11,26+i*30,218,18,black)
if i==opt:
pgb.fill_rect(12,27+i*30,216,16,selectcolor)
pgb.create_text(option,-1,32+i*30,ttcolor)
if language==0:
pgb.create_text(f"Page {page+1}/{int((len(bgs)-1)/4)+1}",-1,172,ttcolor)
pgb.create_text("Use the left/right buttons",-1,190,ttcolor)
pgb.create_text("to scroll your backgrounds",-1,200,ttcolor)
pgb.create_text("Drawing backgrounds won't",-1,215,ttcolor)
pgb.create_text("show in the settings menu.",-1,225,ttcolor)
elif language==1:
pgb.create_text(f"Pagina {page+1}/{int((len(bgs)-1)/4)+1}",-1,172,ttcolor)
pgb.create_text("Usa los botones izquierda y",-1,190,ttcolor)
pgb.create_text("derecha navegar sus temas",-1,200,ttcolor)
pgb.create_text("Dibujar temas no mostrar",-1,215,ttcolor)
pgb.create_text("en el menu de configuracion.",-1,225,ttcolor)
elif language==2:
pgb.create_text(f"Page {page+1}/{int((len(bgs)-1)/4)+1}",-1,172,ttcolor)
pgb.create_text("User les boutons gauch et",-1,187,ttcolor)
pgb.create_text("droit faire defiler vos fonds",-1,197,ttcolor)
pgb.create_text("Les fonds de dessin ne seront",-1,210,ttcolor)
pgb.create_text("pas montrer dans le menu",-1,220,ttcolor)
pgb.create_text("des parametres.",-1,230,ttcolor)
elif language==3:
pgb.create_text(f"Seite {page+1}/{int((len(bgs)-1)/4)+1}",-1,169,ttcolor)
pgb.create_text("Nutzung Sie die Links/Rechts",-1,180,ttcolor)
pgb.create_text("Tasten um Ihre Hintergrunde",-1,190,ttcolor)
pgb.create_text("zu scrollen.",-1,200,ttcolor)
pgb.create_text("Bildhintergrund werden im",-1,210,ttcolor)
pgb.create_text("Einstellungsmenu nicht",-1,220,ttcolor)
pgb.create_text("angezeigt",-1,230,ttcolor)
elif language==4:
pgb.create_text(f"Pagina {page+1}/{int((len(bgs)-1)/4)+1}",-1,172,ttcolor)
pgb.create_text("Uso i pulsanti sinistra e",-1,185,ttcolor)
pgb.create_text("destra per scorrere sfondi",-1,195,ttcolor)
pgb.create_text("Disegnare gli sfondi no",-1,208,ttcolor)
pgb.create_text("mostrare nel menu delle",-1,218,ttcolor)
pgb.create_text("impostazioni.",-1,228,ttcolor)
if pgb.button_up() and opt>0:
opt-=1
pgb.show()
sleep(0.1)
if pgb.button_down() and opt<len(options)-1:
opt+=1
pgb.show()
sleep(0.1)
if pgb.button_left():
sleep(0.2)
if page==0:
page=int((len(bgs)-1)/4)
else:
page-=1
if pgb.button_right():
sleep(0.2)
if page==int((len(bgs)-1)/4):
page=0
else:
page+=1
if pgb.button_A():
if opt==len(options)-1:
return
else:
with open("background.conf","w") as w:
w.write(f"/backgrounds/{bgs[opt+(page*4)]}.pbd")
bgcolor=bgcolors[8]
bindex=8
bgcolor565=PicoGameBoy.color(*bgcolor)
if sum(bgcolor)<426:
tcolor=1
else:
tcolor=0
ttcolor=PicoGameBoy.color(255,255,255)
if tcolor==0:
ttcolor=PicoGameBoy.color(0,0,0)
if tcolor==0:
ottcolor=white
else:
ottcolor=black
sleep(0.2)
return
if pgb.button_B():
sleep(0.2)
break
pgb.show()
if opt==2:
return
if pgb.button_B():
return
pgb.show()
scrollpos=0
max_on_screen=6
vpin=machine.ADC(29)
pastpercentage=[]
while True:
pgb.fill(bgcolor565)
if language==0:
pgb.create_text("Settings",-1,10,ttcolor)
elif language==1:
pgb.create_text("Ajustes",-1,10,ttcolor)
elif language==2:
pgb.create_text("Parametres",-1,10,ttcolor)
elif language==3:
pgb.create_text("Einstellungen",-1,10,ttcolor)
elif language==4:
pgb.create_text("Impostazioni",-1,10,ttcolor)
adc_reading = vpin.read_u16()
adc_voltage = (adc_reading * 3.3) / 65535
vsys_voltage = adc_voltage * 12
console=0
if vsys_voltage>10:
vsys_voltage = adc_voltage * 3
percentage=int(int(((round(vsys_voltage,3)-1.9)/2.7)*100))
console=1
else:
percentage=int(int(((round(vsys_voltage,3)-1.9)/1)*100))
console=0
if console==0:
if percentage>100 and percentage<125:
percentage=100
if percentage<130:
pastpercentage.append(percentage)
if len(pastpercentage)>200:
pastpercentage.pop(0)
percentage=int(int(sum(pastpercentage)/len(pastpercentage)))
elif console==1:
if percentage>100 and percentage<110:
percentage=100
if percentage<110:
pastpercentage.append(percentage)
if len(pastpercentage)>200:
pastpercentage.pop(0)
percentage=int(int(sum(pastpercentage)/len(pastpercentage)))
pgb.create_text("PicoBoy "+version,10,225,ttcolor)
if percentage>100:
pgb.create_text("USB",100,225, ttcolor)
else:
pgb.create_text(str(percentage)+"%",100,225,ttcolor)
if language==0:
if animated:
ani="True"
else:
ani="False"
options=["Change Brightness", "Change Volume", "Change Background", "Data Upload Mode", "Animation: "+ani, "Language", "OS Stats", "Exit"]
elif language==1:
if animated:
ani="Cierto"
else:
ani="Falso"
options=["Cambiar brillo", "Cambiar volumen", "Cambiar tema", "Modo de carga de datos", "Animacion: "+ani, "Idioma", "OS Estadistica", "Salir"]
elif language==2:
if animated:
ani="Vrai"
else:
ani="Faux"
options=["Modifier la luminosite", "Modifier le volume", "Modifier l'fond", "Mode donnees", "Animation: "+ani, "Langue", "OS Statistiques", "Quitter"]
elif language==3:
if animated:
ani="Wahr"
else:
ani="Falsch"
options=["Helligkeit andern", "Lautstarke andern", "Hintergrund andern", "Daten-Upload-Modus", "Animation: "+ani, "Sprache", "OS Statistiken", "Beenden"]
elif language==4:
if animated:
ani="Vero"
else:
ani="Falso"
options=["Cambia luminosita", "Cambia volume", "Cambia sfondo", "Modalita dati", "Animazione: "+ani, "Lingua", "OS Statistiche", "Esci"]
if tcolor==0:
ottcolor=white
else:
ottcolor=black
pgb.fill_rect(215,20,20, 180,selectcolor)
pgb.fill_rect(220,25+(scrollpos*30),10, int(max_on_screen/len(options)* 145),ttcolor)
noptions=options[0+scrollpos:max_on_screen+scrollpos]
for i,option in enumerate(noptions):
pgb.rect(10,25+i*30,200,20,white)
pgb.rect(11,26+i*30,198,18,black)
if i==opt:
pgb.fill_rect(12,27+i*30,196,16,selectcolor)
pgb.create_text(option,(120- int(len(option)/2 * 8))-10,32+i*30,ttcolor)
if pgb.button_up():
if opt>0:
opt-=1
elif opt==0 and scrollpos>0:
scrollpos-=1
pgb.show()
sleep(0.1)
if pgb.button_down():
if opt<len(noptions)-1:
opt+=1
elif opt==len(noptions)-1 and opt+scrollpos<len(options)-1:
scrollpos+=1
pgb.show()
sleep(0.1)
if pgb.button_A():
if opt+scrollpos==0:
sleep(0.2)
while True:
pgb.fill(bgcolor565)
pgb.rect(20,110,200,20,ttcolor)
brightness=pgb.bl.duty_u16()-10000
width=int((brightness/55000)*198)
percentage=int((brightness/55000)*100)
pgb.fill_rect(21,111,width,18,ttcolor)
pgb.create_text(str(percentage)+"%",-1,95,ttcolor)
if language==0:
pgb.create_text("Use the left and right",-1,140,ttcolor)
pgb.create_text("buttons to change the",-1,150,ttcolor)
pgb.create_text("brightness.",-1,160,ttcolor)
pgb.create_text("Press A to exit.",-1,220,ttcolor)
elif language==1:
pgb.create_text("Usa la izquierda y la derecha",-1,140,ttcolor)
pgb.create_text("botones para cambiar el",-1,150,ttcolor)
pgb.create_text("brillo.",-1,160,ttcolor)
pgb.create_text("Presione A para salir.",-1,220,ttcolor)
elif language==2:
pgb.create_text("User la gauche et la droite",-1,140,ttcolor)
pgb.create_text("boutons pour modifier le",-1,150,ttcolor)
pgb.create_text("luminosite.",-1,160,ttcolor)
pgb.create_text("Appuyez sur A pour quitter.",-1,220,ttcolor)
elif language==3:
pgb.create_text("Benutzen Sie links und rechts",-1,140,ttcolor)
pgb.create_text("Tasten zum Andern der",-1,150,ttcolor)
pgb.create_text("Helligkeit.",-1,160,ttcolor)
pgb.create_text("Drucken Sie A, um den",-1,210,ttcolor)
pgb.create_text("Vorgang zu beenden.",-1,220,ttcolor)
elif language==4:
pgb.create_text("Usa la sinistra e la destra",-1,140,ttcolor)
pgb.create_text("pulsanti per modificare il",-1,150,ttcolor)
pgb.create_text("luminosita.",-1,160,ttcolor)
pgb.create_text("Premi A per uscire.",-1,220,ttcolor)
if pgb.button_left():
pgb.decrease_brightness()
pgb.fill_rect(0,95,240,40,bgcolor565)
pgb.rect(20,110,200,20,ttcolor)
brightness=pgb.bl.duty_u16()-10000
width=int((brightness/55000)*198)
percentage=int((brightness/55000)*100)
pgb.fill_rect(21,111,width,18,ttcolor)
pgb.create_text(str(percentage)+"%",-1,95,ttcolor)
pgb.show()
sleep(0.0825)
if pgb.button_right():
pgb.increase_brightness()
pgb.fill_rect(0,95,240,40,bgcolor565)
pgb.rect(20,110,200,20,ttcolor)
brightness=pgb.bl.duty_u16()-10000
width=int((brightness/55000)*198)
percentage=int((brightness/55000)*100)
pgb.fill_rect(21,111,width,18,ttcolor)
pgb.create_text(str(percentage)+"%",-1,95,ttcolor)
pgb.show()
sleep(0.0825)
if pgb.button_A() or pgb.button_B():
sleep(0.2)
break
pgb.show()
if opt+scrollpos==1:
sleep(0.2)
while True:
pgb.fill(bgcolor565)
pgb.rect(20,110,200,20,ttcolor)
volume=pgb.vol
width=int(((volume-pgb.vol_min)/(pgb.vol_max-pgb.vol_min))*198)
percentage=int(((volume-pgb.vol_min)/(pgb.vol_max-pgb.vol_min))*100)
pgb.fill_rect(21,111,width,18,ttcolor)
pgb.create_text(str(percentage)+"%",-1,95,ttcolor)
pgb.create_text(str(percentage)+"%",-1,95,ttcolor)
if language==0:
pgb.create_text("Use the left and right",-1,140,ttcolor)
pgb.create_text("buttons to change the",-1,150,ttcolor)
pgb.create_text("volume.",-1,160,ttcolor)
pgb.create_text("Press A to exit.",-1,220,ttcolor)
elif language==1:
pgb.create_text("Usa la izquierda y la derecha",-1,140,ttcolor)
pgb.create_text("botones para cambiar el",-1,150,ttcolor)
pgb.create_text("volumen.",-1,160,ttcolor)
pgb.create_text("Presione A para salir.",-1,220,ttcolor)
elif language==2:
pgb.create_text("User la gauche et la droite",-1,140,ttcolor)
pgb.create_text("boutons pour modifier le",-1,150,ttcolor)
pgb.create_text("volume.",-1,160,ttcolor)
pgb.create_text("Appuyez sur A pour quitter.",-1,220,ttcolor)
elif language==3:
pgb.create_text("Benutzen Sie links und rechts",-1,140,ttcolor)
pgb.create_text("Tasten zum Andern der",-1,150,ttcolor)
pgb.create_text("Volumen.",-1,160,ttcolor)
pgb.create_text("Drucken Sie A, um den",-1,210,ttcolor)
pgb.create_text("Vorgang zu beenden.",-1,220,ttcolor)
elif language==4:
pgb.create_text("Usa la sinistra e la destra",-1,140,ttcolor)
pgb.create_text("pulsanti per modificare il",-1,150,ttcolor)
pgb.create_text("volume.",-1,160,ttcolor)
pgb.create_text("Premi A per uscire.",-1,220,ttcolor)
if pgb.button_left():
pgb.decrease_vol()
pgb.fill_rect(0,95,240,40,bgcolor565)
pgb.rect(20,110,200,20,ttcolor)
volume=pgb.vol
width=int(((volume-pgb.vol_min)/(pgb.vol_max-pgb.vol_min))*198)
percentage=int(((volume-pgb.vol_min)/(pgb.vol_max-pgb.vol_min))*100)
pgb.fill_rect(21,111,width,18,ttcolor)
pgb.create_text(str(percentage)+"%",-1,95,ttcolor)
pgb.show()
pgb.sound(200)
sleep(0.0825)
pgb.sound(0)
if pgb.button_right():
pgb.increase_vol()
pgb.fill_rect(0,95,240,40,bgcolor565)
pgb.rect(20,110,200,20,ttcolor)
volume=pgb.vol
width=int(((volume-pgb.vol_min)/(pgb.vol_max-pgb.vol_min))*198)
percentage=int(((volume-pgb.vol_min)/(pgb.vol_max-pgb.vol_min))*100)
pgb.fill_rect(21,111,width,18,ttcolor)
pgb.create_text(str(percentage)+"%",-1,95,ttcolor)
pgb.show()
pgb.sound(200)
sleep(0.0825)
pgb.sound(0)
if pgb.button_A() or pgb.button_B():
sleep(0.2)
break
pgb.show()
if opt+scrollpos==2:
sleep(0.2)
pgb.show()
background()
sleep(0.2)
if opt+scrollpos==3:
pgb.fill(bgcolor565)
pgb.create_text(dum[0],-1,20,ttcolor)
pgb.create_text(dum[1],-1, 45,ttcolor)
pgb.create_text(dum[2],-1,57,ttcolor)
pgb.create_text(dum[3],-1,69,ttcolor)
pgb.create_text(dum[4],-1,81,ttcolor)
pgb.create_text(dum[5],-1,200,ttcolor)
pgb.create_text(dum[6],-1,212,ttcolor)
pgb.create_text(dum[7],-1,224,ttcolor)
readchunk_mask("Data Upload Mode.pbimg", 72,90,100,100,cmask=PicoGameBoy.color(31,17,9))
pgb.show()
sys.exit()
if opt+scrollpos==4:
if animated:
animated=False
else:
animated=True
with open("animated.conf", "w") as w:
w.write(str(animated))
sleep(0.1)
if opt+scrollpos==5:
sleep(0.1)
languages()
if opt+scrollpos==6:
stats()
if opt+scrollpos==7:
homebootstop=open("/noboot", "w")
homebootstop.close()
pgb.fill(PicoGameBoy.color(0,0,0))
pgb.show()
machine.reset()
break
if pgb.button_Home():
homebootstop=open("/noboot", "w")
homebootstop.close()
pgb.fill(PicoGameBoy.color(0,0,0))
pgb.show()
machine.reset()
break
pgb.show()