-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
668 lines (612 loc) · 25.4 KB
/
main.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
# Original OS for PicoBoy by HalloSpaceBoy
# INIT IMPORTS
from micropython import const
from PicoGameBoy import PicoGameBoy
from time import sleep
from array import array
from os import rename, listdir, remove
from sys import exit
from machine import reset, ADC
from Functions import Functions
# INIT VARS
BLACK = PicoGameBoy.color(0,0,0)
WHITE = PicoGameBoy.color(255,255,255)
pgb = PicoGameBoy()
vpin = ADC(29)
games=listdir("/games")
loop=0
gamenum=len(games)-1
title=0
pastpercentage=[]
pastpercent=101
# INITIALIZATIONS
# LOAD CONFIGS
bootlogo=True
try:
x=open("/noboot", "r")
x.close()
remove("/noboot")
bootlogo=False
try:
with open("gameselection.conf", "r") as r:
title=int(r.read())
except:
"config nonexistent"
except:
bootlogo=True
try:
with open("language.conf") as r:
language=int(r.read())
if language>4:
raise
except:
language=0
try:
with open("/animated.conf") as r:
if r.read()=="True":
animated=True
else:
animated=False
except:
animated=True
try:
with open("SIP.conf") as r:
SIP=r.read()
if SIP=="True":
SIP=True
else:
SIP=False
except:
SIP=True
with open("Main Text.csv") as w:
data=w.read().split("\n")[language]
data=data.split(", ")
ng=data[0]
s=data[1]
ni=data[2].split("/")
dum=data[3].split("/")
gfs=data[4].split("/")
ic=data[5].split("/")
del data
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))
if gamenum==-1:
gamenum=0
games=["No Games"]
try:
with open("background.conf","r") as r:
data=r.read()
try:
bindex=int(data)
bgimage=False
bgcolor=bgcolors[bindex]
except:
bgimage=True
bindex=8
bgcolor=(69,69,69)
bgcolor565=PicoGameBoy.color(69,69,69)
bgimagefile=data[:]
except:
bindex=8
bgimage=False
if bindex>len(bgcolors)-1:
bindex=8
bgcolor=bgcolors[bindex]
bgcolor565=PicoGameBoy.color(*bgcolor)
arrowright=array('h',[0,0,0,20,20,10])
arrowleft=array('h',[0,0,0,20,-20,10])
arrowrightbg=array('h',[0,0,0,30,30,15])
arrowleftbg=array('h',[0,0,0,30,-30,15])
c1=array('h',[0,0,0,5,5,0])
c2=array('h',[0,0,0,-5,5,0])
c3=array('h',[0,0,0,5,-5,0])
c4=array('h',[0,0,0,-5,-5,0])
if not bgimage:
if sum(bgcolor)<765: #426
tcolor=1
else:
tcolor=0
else:
tcolor=1
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)
# INIT OFFLOADED FUNCTIONS
Functions=Functions(pgb, ttcolor, ottcolor, ic)
# LOAD BACKGROUND
if bgimage:
try:
with open(bgimagefile, "r") as r:
r.read()
imagedata=Functions.getimagedata(bgimagefile)
except:
bindex=8
bgimage=False
# RENDER BOOT LOGO
if bootlogo:
pgb.fill(BLACK)
Functions.readchunk("logo.pbimg",88,50,64,64,False)
Functions.readchunk("logo-text.pbimg",69,150,102,15,False)
pgb.show_screen()
pgb.sound(98)
sleep(0.2)
pgb.sound(0)
pgb.sound(185)
sleep(0.2)
pgb.sound(0)
pgb.sound(164)
sleep(0.2)
pgb.sound(0)
sleep(0.9)
# BEGIN RENDERING HOME SCREEN
if bgimage:
Functions.draw_image(imagedata)
if bgimage:
pgb.fill_rect(15,15,208,30,bgcolor565)
pgb.fill_rect(15,10,208,5,bgcolor565)
pgb.fill_rect(15,45,208,5,bgcolor565)
pgb.fill_rect(10,15,5,30,bgcolor565)
pgb.fill_rect(223,15,5,30,bgcolor565)
pgb.poly(10,10,array('h',[5,5,0,5,5,0]),bgcolor565,True)
pgb.poly(222,10,array('h',[0,5,5,5,0,0]),bgcolor565,True)
pgb.poly(10,49,array('h',[0,-5,5,0,5,-5]),bgcolor565,True)
pgb.poly(222,49,array('h',[0,0,0,-5,5,-5]),bgcolor565,True)
else:
pgb.fill(PicoGameBoy.color(*bgcolor))
Functions.readchunk_mask("picoboy-color.pbimg",0,0,240,60)
# INIT RENDERING FUNTIONS
# RECORD AND RENDER BATTERY PERCENTAGE
def draw_battery():
global pastpercentage
global pastpercent
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)))
battx=9
batty=183
pgb.rect(battx,batty,20,40,ttcolor)
pgb.fill_rect(battx+5,batty-4,10,5,ttcolor)
if percentage>100:
pgb.create_text("U",battx+6, batty+7,ttcolor)
pgb.create_text("S",battx+6, batty+17,ttcolor)
pgb.create_text("B",battx+6, batty+27,ttcolor)
pgb.create_text("USB",battx+10-int(len(str(percentage))/2 * 8), batty+44, ttcolor)
else:
h=int(38*(percentage/100))
pgb.fill_rect(battx+1,batty+1+(38-h),18,h,ttcolor)
pgb.create_text(str(percentage)+"%",battx+10-int(len(str(percentage)+"%")/2 * 8), batty+43, ttcolor)
# RENDER BATTERY OUTLINE (For custom bgs)
def draw_battery_backing():
battx=9
batty=183
pgb.fill_rect(battx-2,batty-4,24,55,bgcolor565)
pgb.fill_rect(battx-5-2,batty-4,5,55,bgcolor565)
pgb.fill_rect(battx+20+2,batty-4,5,55,bgcolor565)
pgb.fill_rect(battx-2,batty-9,24,5,bgcolor565)
pgb.fill_rect(battx-2,batty+51,24,5,bgcolor565)
pgb.poly(battx-5-2,batty-9,array('h',[5,5,0,5,5,0]),bgcolor565,True)
pgb.poly(battx+19+2,batty-9,array('h',[0,5,5,5,0,0]),bgcolor565,True)
pgb.poly(battx-5-2,batty+55,array('h',[0,-5,5,0,5,-5]),bgcolor565,True)
pgb.poly(battx+19+2,batty+55,array('h',[0,0,0,-5,5,-5]),bgcolor565,True)
# RENDER OS MAIN SCREEN INSTANCE
def render(f=True, j=False):
if bgimage:
Functions.draw_image(imagedata,7)
else:
pgb.fill_rect(0,65,240,140,bgcolor565)
pgb.fill_rect(int(120)- int(len(games[title])/2 * 8)-5,65,int(len(games[title]) * 8)+10,140,bgcolor565)
pgb.fill_rect(55,65,130,140,bgcolor565)
#Text rect
pgb.fill_rect(int(120)- int(len(games[title])/2 * 8)-10,65,5,140,bgcolor565)
pgb.fill_rect(int(120)+ int(len(games[title])/2 * 8)+5,65,5,140,bgcolor565)
pgb.fill_rect(int(120)- int(len(games[title])/2 * 8)-5,60,int(len(games[title]) * 8)+10,5,bgcolor565)
pgb.fill_rect(int(120)- int(len(games[title])/2 * 8)-5,205,int(len(games[title]) * 8)+10,5,bgcolor565)
pgb.poly(int(120)- int(len(games[title])/2 * 8)-10,60,array('h',[5,5,0,5,5,0]),bgcolor565,True)
pgb.poly(120+int(int(len(games[title]) * 8)/2)+5,60,array('h',[0,5,5,5,0,0]),bgcolor565,True)
pgb.poly(int(120)- int(len(games[title])/2 * 8)-10,209,array('h',[0,-5,5,0,5,-5]),bgcolor565,True)
pgb.poly(120+int(int(len(games[title]) * 8)/2)+5,209,array('h',[0,0,0,-5,5,-5]),bgcolor565,True)
#App rect
pgb.fill_rect(50,65,5,140,bgcolor565)
pgb.fill_rect(185,65,5,140,bgcolor565)
pgb.fill_rect(55,60,130,5,bgcolor565)
pgb.fill_rect(55,205,130,5,bgcolor565)
pgb.poly(50,60,array('h',[5,5,0,5,5,0]),bgcolor565,True)
pgb.poly(184,60,array('h',[0,5,5,5,0,0]),bgcolor565,True)
pgb.poly(50,209,array('h',[0,-5,5,0,5,-5]),bgcolor565,True)
pgb.poly(184,209,array('h',[0,0,0,-5,5,-5]),bgcolor565,True)
pos=[]
for i in range(title):
pos.append(".")
pos.append("0")
for i in range((gamenum+1)-(title+1)):
pos.append(".")
pgb.fill_rect(int(120)- int(len("".join(pos)+"S")/2 * 8)-5,225,int(len("".join(pos)+"S") * 8)+10,10,bgcolor565)
#Pos rect
pgb.fill_rect(int(120)- int(len("".join(pos)+"S")/2 * 8)-10,225,5,10,bgcolor565)
pgb.fill_rect(int(120)+ int(len("".join(pos)+"S")/2 * 8)+5,225,5,10,bgcolor565)
pgb.fill_rect(int(120)- int(len("".join(pos)+"S")/2 * 8)-5,220,int(len("".join(pos)+"S") * 8)+10,5,bgcolor565)
pgb.fill_rect(int(120)- int(len("".join(pos)+"S")/2 * 8)-5,235,int(len("".join(pos)+"S") * 8)+10,5,bgcolor565)
pgb.poly(int(120)- int(len("".join(pos)+"S")/2 * 8)-10,220,array('h',[5,5,0,5,5,0]),bgcolor565,True)
pgb.poly(120+int(int(len("".join(pos)+"S") * 8)/2)+4,220,array('h',[0,5,5,5,0,0]),bgcolor565,True)
pgb.poly(int(120)- int(len("".join(pos)+"S")/2 * 8)-10,240,array('h',[0,-5,5,0,5,-5]),bgcolor565,True)
pgb.poly(120+int(int(len("".join(pos)+"S") * 8)/2)+4,240,array('h',[0,0,0,-5,5,-5]),bgcolor565,True)
##########
if j:
return
pgb.create_text("".join(pos)+"S", x=-1, y=228,color=ttcolor)
if not games==["No Games"]:
pgb.create_text(games[title],-1,65,ttcolor)
else:
pgb.create_text(ng,-1,65,ttcolor)
try:
if not games==["No Games"]:
Functions.readchunk(games[title]+"/"+games[title]+" (Title Image).pbimg",60,80,120,120)
else:
Functions.readchunk(games[title]+".pbimg",60,80,120,120)
except:
pgb.fill_rect(60,80,120,120,ttcolor)
for g,h in enumerate(ni):
pgb.create_text(h,-1,int(140-((len(ni)/2)*12))+(g*12),ottcolor)
sleep(0.015)
if title==0:
pgb.poly(197,125,arrowrightbg,bgcolor565,True)
pgb.poly(200,130,arrowright,ttcolor,True)
else:
pgb.poly(197,125,arrowrightbg,bgcolor565,True)
pgb.poly(43,125,arrowleftbg,bgcolor565,True)
pgb.poly(200,130,arrowright,ttcolor,True)
pgb.poly(40,130,arrowleft,ttcolor,True)
pgb.poly(60,80,c1,bgcolor565,True)
pgb.poly(60,200,c2,bgcolor565,True)
pgb.poly(180,80,c3,bgcolor565,True)
pgb.poly(180,200,c4,bgcolor565,True)
if f:
pgb.show()
# MAIN OS OPERATIONS
# RENDER HOME SCREEN
if title<=gamenum :
render()
onsett=False
else:
onsett=True
# BEGIN HOMESCREEN MAINLOOP
while True:
# MEM TEST
#print(mem_free())
if pgb.button_left() and title>0 and not onsett:
if animated and not bgimage:
incr=20
draw_battery_backing()
for i in range(12): #3 is good
i+=1
pgb.fill_rect(0,78,240,130,bgcolor565)
try:
Functions.readchunk(games[title-1]+"/"+games[title-1]+" (Title Image).pbimg",-180+(i*incr),81,120,120)
except:
pgb.fill_rect(-180+(i*incr),81,120,120,ttcolor)
for g,h in enumerate(ni):
pgb.create_text(h,((120-(len(h)*4))-240)+(i*incr),int(140-((len(ni)/2)*12))+(g*12),ottcolor)
sleep(0.015)
try:
Functions.readchunk(games[title]+"/"+games[title]+" (Title Image).pbimg",60+(i*incr),80,120,120)
except:
pgb.fill_rect(60+(i*incr),80,120,120,ttcolor)
for g,h in enumerate(ni):
pgb.create_text(h,(120-(len(h)*4))+(i*incr),int(140-((len(ni)/2)*12))+(g*12),ottcolor)
sleep(0.015)
pgb.poly(60+(i*incr),80,c1,bgcolor565,True)
pgb.poly(60+(i*incr),200,c2,bgcolor565,True)
pgb.poly(180+(i*incr),80,c3,bgcolor565,True)
pgb.poly(180+(i*incr),200,c4,bgcolor565,True)
pgb.poly(-180+(i*incr),80,c1,bgcolor565,True)
pgb.poly(-180+(i*incr),200,c2,bgcolor565,True)
pgb.poly(-60+(i*incr),80,c3,bgcolor565,True)
pgb.poly(-60+(i*incr),200,c4,bgcolor565,True)
pgb.show()
elif not bgimage:
sleep(0.1)
if not bgimage:
pgb.fill_rect(0,78,240,130,bgcolor565)
title-=1
render(False)
draw_battery_backing()
draw_battery()
pgb.show()
if pgb.button_right() and title<gamenum and not onsett:
if animated and not bgimage:
incr=20
draw_battery_backing()
for i in range(12):
i+=1
pgb.fill_rect(0,80,240,130,bgcolor565)
try:
Functions.readchunk(games[title]+"/"+games[title]+" (Title Image).pbimg",60-(i*incr),81,120,120)
except:
pgb.fill_rect(60-(i*incr),80,120,120,ttcolor)
for g,h in enumerate(ni):
pgb.create_text(h,(120-(len(h)*4))-(i*incr),int(140-((len(ni)/2)*12))+(g*12),ottcolor)
sleep(0.015)
try:
Functions.readchunk(games[title+1]+"/"+games[title+1]+" (Title Image).pbimg",300-(i*incr),80,120,120)
except:
pgb.fill_rect(300-(i*incr),80,120,120,ttcolor)
for g,h in enumerate(ni):
pgb.create_text(h,240+(120-(len(h)*4))-(i*incr),int(140-((len(ni)/2)*12))+(g*12),ottcolor)
sleep(0.015)
pgb.poly(60-(i*incr),80,c1,bgcolor565,True)
pgb.poly(60-(i*incr),200,c2,bgcolor565,True)
pgb.poly(180-(i*incr),80,c3,bgcolor565,True)
pgb.poly(180-(i*incr),200,c4,bgcolor565,True)
pgb.poly(300-(i*incr),80,c1,bgcolor565,True)
pgb.poly(300-(i*incr),200,c2,bgcolor565,True)
pgb.poly(420-(i*incr),80,c3,bgcolor565,True)
pgb.poly(420-(i*incr),200,c4,bgcolor565,True)
pgb.show()
elif not bgimage:
sleep(0.1)
if not bgimage:
pgb.fill_rect(0,80,240,130,bgcolor565)
title+=1
render(False)
draw_battery_backing()
draw_battery()
pgb.show()
if (pgb.button_right() and title==gamenum) or onsett:
if onsett:
title-=1
if animated and not onsett and not bgimage:
incr=20
draw_battery_backing()
for i in range(12):
i+=1
pgb.fill_rect(0,80,240,130,bgcolor565)
try:
if not games==["No Games"]:
Functions.readchunk(games[title]+"/"+games[title]+" (Title Image).pbimg",60-(i*incr),81,120,120)
else:
Functions.readchunk("No Games.pbimg",60-(i*incr),81,120,120)
except:
pgb.fill_rect(60-(i*incr),81,120,120,ttcolor)
for g,h in enumerate(ni):
pgb.create_text(h,(120-(len(h)*4))-(i*incr),int(140-((len(ni)/2)*12))+(g*12),ottcolor)
sleep(0.015)
Functions.readchunk("settings.pbimg",300-(i*incr),80,120,120)
pgb.poly(60-(i*incr),80,c1,bgcolor565,True)
pgb.poly(60-(i*incr),200,c2,bgcolor565,True)
pgb.poly(180-(i*incr),80,c3,bgcolor565,True)
pgb.poly(180-(i*incr),200,c4,bgcolor565,True)
pgb.poly(300-(i*incr),80,c1,bgcolor565,True)
pgb.poly(300-(i*incr),200,c2,bgcolor565,True)
pgb.poly(420-(i*incr),80,c3,bgcolor565,True)
pgb.poly(420-(i*incr),200,c4,bgcolor565,True)
pgb.show()
elif not bgimage:
sleep(0.1)
if not bgimage:
pgb.fill_rect(0,78,240,130,bgcolor565)
onsett=False
render(j=True)
pos=""
for g in games:
pos+="."
pgb.create_text(pos+"0", x=-1, y=228,color=ttcolor)
pgb.create_text(s,-1,65,ttcolor)
Functions.readchunk("settings.pbimg",60,80,120,120)
pgb.poly(43,125,arrowleftbg,bgcolor565,True)
pgb.poly(40,130,arrowleft,ttcolor,True)
pgb.poly(60,80,c1,bgcolor565,True)
pgb.poly(60,200,c2,bgcolor565,True)
pgb.poly(180,80,c3,bgcolor565,True)
pgb.poly(180,200,c4,bgcolor565,True)
draw_battery_backing()
draw_battery()
pgb.show()
while True:
draw_battery()
pgb.show()
draw_battery_backing()
if pgb.button_A() or pgb.button_start():
with open("gameselection.conf", "w") as w:
w.write(str(title+1))
rename("./main.py", "./title.py")
rename("settings.py", "./main.py")
pgb.fill(PicoGameBoy.color(0,0,0))
pgb.show()
reset()
break
if pgb.button_select() and pgb.button_B() and pgb.button_down():
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)
Functions.readchunk_mask("Data Upload Mode.pbimg", 72,90,100,100,cmask=PicoGameBoy.color(31,17,9))
pgb.show()
exit()
if pgb.button_left():
if animated and not bgimage:
incr=20
draw_battery_backing()
for i in range(12): #3 is good
i+=1
pgb.fill_rect(0,80,240,130,bgcolor565)
try:
if not games==["No Games"]:
Functions.readchunk(games[title]+"/"+games[title]+" (Title Image).pbimg",-180+(i*incr),81,120,120)
else:
Functions.readchunk(games[title]+".pbimg",-180+(i*incr),81,120,120)
except:
pgb.fill_rect(-180+(i*incr),81,120,120,ttcolor)
for g,h in enumerate(ni):
pgb.create_text(h,((120-(len(h)*4 ))-240)+(i*incr),int(140-((len(ni)/2)*12))+(g*12),ottcolor)
sleep(0.015)
Functions.readchunk("settings.pbimg",60+(i*incr),80,120,120)
pgb.poly(60+(i*incr),80,c1,bgcolor565,True)
pgb.poly(60+(i*incr),200,c2,bgcolor565,True)
pgb.poly(180+(i*incr),80,c3,bgcolor565,True)
pgb.poly(180+(i*incr),200,c4,bgcolor565,True)
pgb.poly(-180+(i*incr),80,c1,bgcolor565,True)
pgb.poly(-180+(i*incr),200,c2,bgcolor565,True)
pgb.poly(-60+(i*incr),80,c3,bgcolor565,True)
pgb.poly(-60+(i*incr),200,c4,bgcolor565,True)
pgb.show()
elif not bgimage:
sleep(0.1)
render(False)
draw_battery_backing()
draw_battery()
pgb.show()
break
if title>gamenum:
title=gamenum
elif title<0:
title=0
if pgb.button_select() and pgb.button_B() and pgb.button_down():
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)
Functions.readchunk_mask("Data Upload Mode.pbimg", 72,90,100,100,cmask=PicoGameBoy.color(31,17,9))
pgb.show()
try:
remove("/out.bin")
except:
""
with open("/out.bin", "ab") as w:
for i in range(240):
data=pgb.sbuffer[i*480:i*480+480]
w.write(data)
break
draw_battery()
pgb.show()
draw_battery_backing()
if (pgb.button_A() or pgb.button_start()) and not games==["No Games"]:
if SIP:
go=False
else:
go=True
check=0
check1=0
check2=0
if SIP:
try:
x=open("./"+games[title]+"/"+games[title]+".py")
checktitle=games[title].lower().replace("/","").replace("\"","").replace("\'","").replace(" ","").lower()
while True:
try:
f10=x.readline(100).replace("/","").replace("\"","").replace("\'","").replace(" ","").lower().split("#")
if len(f10)>1 and len(f10[0])==0:
f10="CHECK"
else:
f10=f10[0]
if "rename(title.py,main.py)" in f10:
check+=1
if "rename(main.py,"+checktitle+checktitle+".py)" in f10:
check+=1
if "rename" in f10 and "fromosimport" in f10:
check+=1
if "os.rename(title.py,main.py)" in f10:
check1+=1
if "os.rename(main.py,"+checktitle+checktitle+".py)" in f10:
check1+=1
if "importos" in f10:
check1+=1
if ("=picoboysdk("+checktitle in f10 and ")" in f10) or ("=picoboysdk(namespace="+checktitle in f10 and ")" in f10):
check2+=1
if "frompicoboysdkimportpicoboysdk" in f10:
check2+=1
if check>2:
break
if check1>2:
break
if check2>1:
break
if f10=="":
raise
except:
raise
x.close()
go=True
except:
sleep(0.1)
pgb.fill_rect(10,90,220,24+(len(gfs)*12),PicoGameBoy.color(50,50,50))
for i,f in enumerate(gfs):
pgb.create_text(f, -1,105+(i*12),PicoGameBoy.color(255,255,255))
pgb.show()
while True:
pgb.show()
if pgb.any_button():
pgb.fill_rect(10,90,220,100,bgcolor565)
try:
Functions.readchunk(games[title]+"/"+games[title]+" (Title Image).pbimg",60,80,120,120)
except:
pgb.fill_rect(60,80,120,120,ttcolor)
pgb.create_text("No Image",-1,140,ottcolor)
sleep(0.1)
if title==0:
pgb.poly(200,130,arrowright,ttcolor,True)
else:
pgb.poly(200,130,arrowright,ttcolor,True)
pgb.poly(40,130,arrowleft,ttcolor,True)
pgb.poly(60,80,c1,bgcolor565,True)
pgb.poly(60,200,c2,bgcolor565,True)
pgb.poly(180,80,c3,bgcolor565,True)
pgb.poly(180,200,c4,bgcolor565,True)
sleep(0.1)
break
if go:
with open("gameselection.conf", "w") as w:
w.write(str(title))
rename("./main.py", "./title.py")
rename("./"+games[title]+"/"+games[title]+".py", "./main.py")
pgb.fill(PicoGameBoy.color(0,0,0))
pgb.show()
reset()
break