-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathpop-fe-psp.py
executable file
·602 lines (528 loc) · 24.8 KB
/
pop-fe-psp.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
#!/usr/bin/python3
#!/usr/bin/env python
import argparse
import os
import pathlib
import pygubu
import re
import shutil
import struct
import subprocess
import tkinter as tk
import tkinter.ttk as ttk
import zipfile
have_pytube = False
try:
import pytubefix as pytube
have_pytube = True
except:
True
from PIL import Image
from bchunk import bchunk
import importlib
from gamedb import games, libcrypt, themes
try:
import popfe
except:
popfe = importlib.import_module("pop-fe")
from cue import parse_ccd, ccd2cue, write_cue
verbose = False
temp_files = []
PROJECT_PATH = pathlib.Path(__file__).parent
PROJECT_UI = PROJECT_PATH / "pop-fe-psp.ui"
EMPTY_CONFIG = bytes([
0x70,0x00,0x07,0x06,0x00,0x00,0x06,0x06,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF
])
class FinishedDialog(tk.Toplevel):
def __init__(self, root):
tk.Toplevel.__init__(self, root)
label = tk.Label(self, text="Finished creating EBOOT")
label.pack(fill="both", expand=True, padx=20, pady=20)
button = tk.Button(self, text="Continue", command=self.destroy)
button.pack(side="bottom")
class PopFePs3App:
def __init__(self, master=None):
self.myrect = None
self.cue_file_orig = None
self.cue_files = None
self.cu2_files = None
self.img_files = None
self.disc_ids = None
self.md5_sums = None
self.real_disc_ids = None
self.icon0 = None
self.icon0_tk = None
self.pic0 = None
self.pic0_tk = None
self.pic1 = None
self.pic1_tk = None
self.pkgdir = None
self.watermark = 'on'
self.nopstitleimg = 'off'
self.cdda = 'off'
self.pic0_disabled = 'off'
self.pic1_disabled = 'off'
self.snd0_disabled = 'off'
self.configs = []
self.subdir='pop-fe-psp-work/'
self.master = master
self.builder = builder = pygubu.Builder()
builder.add_resource_path(PROJECT_PATH)
builder.add_from_file(PROJECT_UI)
self.mainwindow = builder.get_object("top_frame", master)
callbacks = {
'on_icon0_clicked': self.on_icon0_clicked,
'on_pic0_clicked': self.on_pic0_clicked,
'on_pic0_disabled': self.on_pic0_disabled,
'on_pic1_disabled': self.on_pic1_disabled,
'on_snd0_disabled': self.on_snd0_disabled,
'on_pic1_clicked': self.on_pic1_clicked,
'on_path_changed': self.on_path_changed,
'on_dir_changed': self.on_dir_changed,
'on_watermark': self.on_watermark,
'on_nopstitleimg': self.on_nopstitleimg,
'on_youtube_audio': self.on_youtube_audio,
'on_create_eboot': self.on_create_eboot,
'on_reset': self.on_reset,
'on_cdda': self.on_cdda,
'on_theme_selected': self.on_theme_selected,
'on_force_ntsc': self.on_force_ntsc,
}
builder.connect_callbacks(callbacks)
self._theme = ''
o = ['']
for theme in themes:
o.append(theme)
self.builder.get_object('theme', self.master).configure(values=o)
self.init_data()
def __del__(self):
global temp_files
print('Delete temporary files') if verbose else None
for f in temp_files:
print('Deleting temp/dir file', f) if verbose else None
try:
os.unlink(f)
except:
try:
os.rmdir(f)
except:
True
temp_files = []
def init_data(self):
global temp_files
if temp_files:
for f in temp_files:
try:
os.unlink(f)
except:
try:
os.rmdir(f)
except:
True
temp_files = []
temp_files.append(self.subdir)
shutil.rmtree(self.subdir, ignore_errors=True)
os.mkdir(self.subdir)
self.cue_files = []
self.cu2_files = []
self.img_files = []
self.disc_ids = []
self.md5_sums = []
self.real_disc_ids = []
self.icon0 = None
self.icon0_tk = None
self.pic0 = None
self.pic0_tk = None
self.pic1 = None
self.pic1_tk = None
self.preview_tk = None
self.configs = []
self.builder.get_variable('nopstitleimg_variable').set(self.nopstitleimg)
self.builder.get_variable('watermark_variable').set(self.watermark)
self.builder.get_variable('cdda_variable').set(self.cdda)
for idx in range(1,6):
self.builder.get_object('discid%d' % (idx), self.master).config(state='disabled')
self.builder.get_object('disc' + str(idx), self.master).config(filetypes=[('Image files', ['.cue', '.ccd', '.img', '.zip', '.chd']), ('All Files', ['*.*', '*'])])
self.builder.get_variable('disc%d_variable' % (idx)).set('')
self.builder.get_variable('discid%d_variable' % (idx)).set('')
self.builder.get_object('disc' + str(idx), self.master).config(state='disabled')
self.builder.get_object('disc1', self.master).config(state='normal')
self.builder.get_object('create_button', self.master).config(state='disabled')
self.builder.get_object('youtube_button', self.master).config(state='disabled')
self.builder.get_variable('title_variable').set('')
self.builder.get_variable('snd0_variable').set('')
self.builder.get_object('snd0', self.master).config(filetypes=[('Audio files', ['.wav']), ('All Files', ['*.*', '*'])])
self.builder.get_variable('logo_variable').set('')
self.builder.get_object('logo', self.master).config(filetypes=[('Audio files', ['.png', '.PNG']), ('All Files', ['*.*', '*'])])
self.builder.get_object('manual', self.master).config(filetypes=[('All Files', ['*.*', '*'])])
self.builder.get_variable('manual_variable').set('')
def on_theme_selected(self, event):
self.master.config(cursor='watch')
self._theme = self.builder.get_object('theme', self.master).get()
self.update_assets()
self.master.config(cursor='')
def update_assets(self):
if not self.disc_ids:
return
if not self.cue_file_orig:
return
disc_id = self.disc_ids[0]
game = popfe.get_game_from_gamelist(disc_id)
if self.snd0_disabled == 'off':
snd0 = None
print('Fetching SND0') if verbose else None
if self._theme != '':
snd0 = popfe.get_snd0_from_theme(self._theme, disc_id, 'pop-fe-psp-work')
if snd0:
temp_files.append(snd0)
if not snd0 and disc_id in games and 'snd0' in games[disc_id]:
snd0 = games[disc_id]['snd0']
if snd0:
self.builder.get_variable('snd0_variable').set(snd0)
print('Fetching ICON0') if verbose else None
self.icon0 = None
if self._theme != '':
print('Get icon0 from theme')
self.icon0 = popfe.get_image_from_theme(self._theme, disc_id, 'pop-fe-psp-work', 'ICON0.PNG')
if not self.icon0:
self.icon0 = popfe.get_image_from_theme(self._theme, disc_id, 'pop-fe-psp-work', 'ICON0.png')
if self.icon0:
self.icon0 = self.icon0.crop(self.icon0.getbbox())
if not self.icon0:
self.icon0 = popfe.get_icon0_from_game(disc_id, game, self.cue_file_orig, self.subdir + 'ICON0.PNG', psn_frame_size=((80,80),(62,62)))
if self.icon0:
temp_files.append(self.subdir + 'ICON0.PNG')
self.icon0.resize((80,80), Image.Resampling.HAMMING).save(self.subdir + 'ICON0.PNG')
self.icon0_tk = tk.PhotoImage(file = self.subdir + 'ICON0.PNG')
c = self.builder.get_object('icon0_canvas', self.master)
c.create_image(0, 0, image=self.icon0_tk, anchor='nw')
print('Fetching PIC0') if verbose else None
self.pic0 = None
if self._theme != '':
self.pic0 = popfe.get_image_from_theme(self._theme, disc_id, 'pop-fe-psp-work', 'PIC0.PNG')
if not self.pic0:
self.pic0 = popfe.get_image_from_theme(self._theme, disc_id, 'pop-fe-psp-work', 'PIC0.png')
if not self.pic0:
self.pic0 = popfe.get_pic0_from_game(disc_id, game, self.cue_file_orig)
if self.pic0:
temp_files.append(self.subdir + 'PIC0.PNG')
self.pic0.resize((128,80), Image.Resampling.HAMMING).save(self.subdir + 'PIC0.PNG')
self.pic0_tk = tk.PhotoImage(file = self.subdir + 'PIC0.PNG')
c = self.builder.get_object('pic0_canvas', self.master)
c.create_image(0, 0, image=self.pic0_tk, anchor='nw')
print('Fetching PIC1') if verbose else None
self.pic1 = None
if self._theme != '':
self.pic1 = popfe.get_image_from_theme(self._theme, disc_id, 'pop-fe-psp-work', 'PIC1.PNG')
if not self.pic1:
self.pic1 = popfe.get_image_from_theme(self._theme, disc_id, 'pop-fe-psp-work', 'PIC1.png')
if not self.pic1:
self.pic1 = popfe.get_pic1_from_game(disc_id, game, self.cue_file_orig)
if self.pic1:
temp_files.append(self.subdir + 'PIC1.PNG')
self.pic1.resize((128,80), Image.Resampling.HAMMING).save(self.subdir + 'PIC1.PNG')
self.pic1_tk = tk.PhotoImage(file = self.subdir + 'PIC1.PNG')
c = self.builder.get_object('pic1_canvas', self.master)
c.create_image(0, 0, image=self.pic1_tk, anchor='nw')
self.update_preview()
def on_path_changed(self, event):
cue_file = event.widget.cget('path')
img_file = None
if not len(cue_file):
return
self.master.config(cursor='watch')
self.master.update()
self.cue_file_orig = cue_file
print('Processing', cue_file) if verbose else None
disc = event.widget.cget('title')
print('Disc', disc) if verbose else None
idx = int(disc[1])
cue_file , real_cue_file, img_file = popfe.process_disk_file(cue_file, idx, temp_files, subdir=self.subdir)
self.cue_file_orig = real_cue_file
print('Scanning for Game ID') if verbose else None
tmp = self.subdir + 'TMP01.iso'
disc_id, md5 = popfe.get_disc_id(cue_file, self.cue_file_orig, tmp)
print('ID', disc_id)
temp_files.append(tmp)
self.builder.get_variable('disci%s_variable' % (disc)).set(disc_id)
self.img_files.append(img_file)
self.disc_ids.append(disc_id)
self.md5_sums.append(md5)
self.real_disc_ids.append(disc_id)
self.cue_files.append(cue_file)
self.configs.append(None)
if disc_id in games and 'psp-use-cdda' in games[disc_id]:
self.cdda = 'on'
self.builder.get_variable('cdda_variable').set(self.cdda)
if disc_id in games and 'pspconfig' in games[disc_id]:
print('Found an external config for', disc_id)
with open(games[disc_id]['pspconfig'], 'rb') as f:
self.configs[-1] = f.read()
try:
os.stat(self.cue_file_orig[:-3]+'pspconfig').st_size
print('Found an external config ', self.cue_file_orig[:-3]+'pspconfig')
with open(self.cue_file_orig[:-3]+'pspconfig', 'rb') as f:
self.configs[-1] = f.read()
print('Read external config ', self.cue_file_orig[:-3]+'pspconfig')
except:
True
if disc == 'd1':
self.builder.get_object('discid1', self.master).config(state='normal')
self.builder.get_variable('title_variable').set(popfe.get_title_from_game(disc_id))
self.update_assets()
self.builder.get_object('disc1', self.master).config(state='disabled')
self.builder.get_object('disc2', self.master).config(state='normal')
self.builder.get_object('youtube_button', self.master).config(state='normal')
self.builder.get_object('create_button', self.master).config(state='normal')
self.update_preview()
elif disc == 'd2':
self.builder.get_object('discid2', self.master).config(state='normal')
self.builder.get_object('disc2', self.master).config(state='disabled')
self.builder.get_object('disc3', self.master).config(state='normal')
elif disc == 'd3':
self.builder.get_object('discid3', self.master).config(state='normal')
self.builder.get_object('disc3', self.master).config(state='disabled')
self.builder.get_object('disc4', self.master).config(state='normal')
elif disc == 'd4':
self.builder.get_object('discid4', self.master).config(state='normal')
self.builder.get_object('disc4', self.master).config(state='disabled')
self.builder.get_object('disc5', self.master).config(state='normal')
elif disc == 'd5':
self.builder.get_object('discid5', self.master).config(state='normal')
self.builder.get_object('disc5', self.master).config(state='disabled')
print('Finished processing disc') if verbose else None
self.master.config(cursor='')
def update_preview(self):
def has_transparency(img):
if img.info.get("transparency", None) is not None:
return True
if img.mode == "P":
transparent = img.info.get("transparency", -1)
for _, index in img.getcolors():
if index == transparent:
return True
elif img.mode == "RGBA":
extrema = img.getextrema()
if extrema[3][0] < 255:
return True
return False
if self.pic0_disabled == 'on':
_pic0 = None
else:
_pic0 = self.pic0
if self.pic1_disabled == 'on':
_pic1 = Image.new('RGBA', (1920, 1080), (0,0,0))
_pic1.putalpha(0)
else:
_pic1 = self.pic1
if _pic0 and self.pic0.mode == 'P':
_pic0 = _pic0.convert(mode='RGBA')
c = self.builder.get_object('preview_canvas', self.master)
if _pic1:
p1 = _pic1.resize((382,216), Image.Resampling.HAMMING)
else:
p1 = Image.new('RGBA', (382,216), (0,0,0))
if _pic0:
p0 = _pic0.resize((int(p1.size[0] * 0.55) , int(p1.size[1] * 0.58)), Image.Resampling.HAMMING)
if has_transparency(p0):
Image.Image.paste(p1, p0, box=(148,79), mask=p0)
else:
Image.Image.paste(p1, p0, box=(148,79))
if self.icon0:
i0 = self.icon0.resize((int(p1.size[1] * 0.25) , int(p1.size[1] * 0.25)), Image.Resampling.HAMMING)
if has_transparency(i0):
Image.Image.paste(p1, i0, box=(36,81), mask=i0)
else:
Image.Image.paste(p1, i0, box=(36,81))
temp_files.append(self.subdir + 'PREVIEW.PNG')
p1.save(self.subdir + 'PREVIEW.PNG')
self.preview_tk = tk.PhotoImage(file = self.subdir + 'PREVIEW.PNG')
c = self.builder.get_object('preview_canvas', self.master)
c.create_image(0, 0, image=self.preview_tk, anchor='nw')
def on_nopstitleimg(self):
self.nopstitleimg = self.builder.get_variable('nopstitleimg_variable').get()
def on_watermark(self):
self.watermark = self.builder.get_variable('watermark_variable').get()
def on_icon0_clicked(self, event):
filetypes = [
('Image files', ['.png', '.PNG', '.jpg', '.JPG']),
('All Files', ['*.*', '*'])]
path = tk.filedialog.askopenfilename(title='Select image for ICON0',filetypes=filetypes)
try:
os.stat(path)
self.icon0 = Image.open(path)
except:
return
temp_files.append(self.subdir + 'ICON0.PNG')
self.icon0.resize((80,80), Image.Resampling.HAMMING).save(self.subdir + 'ICON0.PNG')
self.icon0_tk = tk.PhotoImage(file = self.subdir + 'ICON0.PNG')
c = self.builder.get_object('icon0_canvas', self.master)
c.create_image(0, 0, image=self.icon0_tk, anchor='nw')
self.update_preview()
def on_pic0_disabled(self):
self.pic0_disabled = self.builder.get_variable('pic0_disabled_variable').get()
self.update_preview()
def on_pic1_disabled(self):
self.pic1_disabled = self.builder.get_variable('pic1_disabled_variable').get()
self.update_preview()
def on_snd0_disabled(self):
self.snd0_disabled = self.builder.get_variable('snd0_disabled_variable').get()
def on_pic0_clicked(self, event):
filetypes = [
('Image files', ['.png', '.PNG', '.jpg', '.JPG']),
('All Files', ['*.*', '*'])]
path = tk.filedialog.askopenfilename(title='Select image for PIC0',filetypes=filetypes)
try:
os.stat(path)
self.pic0 = Image.open(path)
except:
return
temp_files.append(self.subdir + 'PIC0.PNG')
self.pic1.resize((128,80), Image.Resampling.HAMMING).save(self.subdir + 'PIC0.PNG')
self.pic0_tk = tk.PhotoImage(file = self.subdir + 'PIC0.PNG')
c = self.builder.get_object('pic0_canvas', self.master)
c.create_image(0, 0, image=self.pic0_tk, anchor='nw')
self.update_preview()
def on_pic1_clicked(self, event):
filetypes = [
('Image files', ['.png', '.PNG', '.jpg', '.JPG']),
('All Files', ['*.*', '*'])]
path = tk.filedialog.askopenfilename(title='Select image for PIC1',filetypes=filetypes)
try:
os.stat(path)
self.pic1 = Image.open(path)
except:
return
temp_files.append(self.subdir + 'PIC1.PNG')
self.pic1.resize((128,80), Image.Resampling.HAMMING).save(self.subdir + 'PIC1.PNG')
self.pic1_tk = tk.PhotoImage(file = self.subdir + 'PIC1.PNG')
c = self.builder.get_object('pic1_canvas', self.master)
c.create_image(0, 0, image=self.pic1_tk, anchor='nw')
self.update_preview()
def on_dir_changed(self, event):
self.pkgdir = event.widget.cget('path')
def on_youtube_audio(self):
if not have_pytube:
return
self.master.config(cursor='watch')
a = pytube.contrib.search.Search(self.builder.get_variable('title_variable').get() + ' ps1 ost')
if a:
self.builder.get_variable('snd0_variable').set('https://www.youtube.com/watch?v=' + a.results[0].video_id)
self.master.config(cursor='')
def on_create_eboot(self):
pkgdir = self.builder.get_variable('pkgdir_variable').get()
disc_id = self.real_disc_ids[0]
title = self.builder.get_variable('title_variable').get()
print('Creating EBOOT')
print('DISC', disc_id)
print('TITLE', title)
disc_ids = []
for idx in range(len(self.cue_files)):
d = self.builder.get_variable('discid%d_variable' % (idx + 1)).get()
disc_ids.append(d)
resolution = 1
subchannels = []
for idx in range(len(self.cue_files)):
if self.real_disc_ids[idx] in libcrypt:
subchannels.append(popfe.generate_subchannels(libcrypt[self.real_disc_ids[idx]]['magic_word']))
else:
subchannels.append(None)
if disc_id[:3] == 'SLE' or disc_id[:3] == 'SCE':
print('SLES/SCES PAL game. Default resolution set to 2 (640x512)') if verbose else None
resolution = 2
self.master.config(cursor='watch')
self.master.update()
snd0 = self.builder.get_variable('snd0_variable').get()
if snd0[:24] == 'https://www.youtube.com/':
snd0 = popfe.get_snd0_from_link(snd0, subdir=self.subdir)
if snd0:
temp_files.append(snd0)
manual = self.builder.get_variable('manual_variable').get()
if manual and len(manual):
manual = popfe.create_manual(manual, self.disc_ids[0], subdir=self.subdir)
else:
manual = None
ebootdir = self.pkgdir if self.pkgdir else '.'
#
# Apply all PPF fixes we might need
#
self.cue_files, self.img_files = popfe.apply_ppf_fixes(self.real_disc_ids, self.cue_files, self.img_files, self.md5_sums, self.subdir, tag="psp")
# Apply libcrypt
self.cue_files, self.img_files = popfe.patch_libcrypt(self.real_disc_ids, self.cue_files, self.img_files, subdir=self.subdir)
self.cu2_files = popfe.generate_cu2_files(self.cue_files, self.img_files, self.subdir)
aea_files, extra_data_tracks = popfe.generate_aea_files(self.cue_files, self.img_files, self.subdir)
if extra_data_tracks:
self.cdda = 'on'
if self.builder.get_variable('force_ntsc_variable').get() == 'on':
for i in range(len(self.configs)):
if not self.configs[i]:
# skip the revision header
self.configs[i] = EMPTY_CONFIG[:]
self.configs[i] = bytearray(self.configs[i])
# Set NTSC bit in configs
if len(self.configs[i]) > 0x0b:
self.configs[i][0x0b] |= 0x10
if len(self.configs[i]) > 0x8f:
self.configs[i][0x8f] |= 0x10
if self.cdda == 'on':
for i in range(len(self.configs)):
if not self.configs[i]:
# skip the revision header
self.configs[i] = EMPTY_CONFIG[:]
self.configs[i] = bytearray(self.configs[i])
# Set CDDA bit in configs
if len(self.configs[i]) > 0x09:
self.configs[i][0x09] |= 0x20 # same effect as cdda_enabler
if len(self.configs[i]) > 0x8d:
self.configs[i][0x8d] |= 0x20 # same effect as cdda_enabler
logo = None
if self.builder.get_variable('logo_variable').get():
logo = Image.open(self.builder.get_variable('logo_variable').get())
popfe.create_psp(ebootdir, disc_ids, title,
self.icon0,
self.pic0 if self.pic0_disabled =='off' else None,
self.pic1 if self.pic1_disabled =='off' else None,
self.cue_files, self.cu2_files, self.img_files, [],
aea_files, subdir=self.subdir, snd0=snd0,
no_pstitleimg=True if self.nopstitleimg=='on' else False,
watermark=True if self.watermark=='on' else False,
subchannels=subchannels, manual=manual,
configs=self.configs,
use_cdda=True if self.cdda=='on' else False,
logo=logo)
self.master.config(cursor='')
d = FinishedDialog(self.master)
self.master.wait_window(d)
self.init_data()
def on_reset(self):
self.init_data()
def on_cdda(self):
self.cdda = self.builder.get_variable('cdda_variable').get()
def on_force_ntsc(self):
True
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-v', action='store_true', help='Verbose')
args = parser.parse_args()
if args.v:
verbose = True
root = tk.Tk()
app = PopFePs3App(root)
root.title('pop-fe PSP')
root.mainloop()