forked from ThomasTheSpaceFox/SBTCVM-Mark-2
-
Notifications
You must be signed in to change notification settings - Fork 5
/
settings.py
executable file
·317 lines (291 loc) · 11.3 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
#!/usr/bin/env python
import pygame.event
import pygame.key
import pygame.display
import pygame.image
import pygame.mixer
import pygame
import time
import copy
import sys
import os
import subprocess
from pygame.locals import *
import VMSYSTEM.libvmconf as libvmconf
import VMSYSTEM.libvmui as vmui
import VMSYSTEM.libthemeconf as libthemeconf
pygame.display.init()
pygame.font.init()
pygame.display.set_caption(("Settings"), ("Settings"))
windowicon=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX'), 'settings64.png'))
pygame.display.set_icon(windowicon)
screensurf=pygame.display.set_mode((450, 400))
screenx=450
screeny=400
vmui.initui(screensurf, 1)
#image data
sbtcvmbadge=pygame.image.load(os.path.join("VMSYSTEM", "GFX", 'SBTCVMbadge.png')).convert()
#setbg=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'settingsbg2.jpg')).convert()
#swon=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'switchon.png')).convert()
#swoff=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'switchoff.png')).convert()
swn=vmui.makeswitchbtn("ON", "OFF")
swon=swn[0]
swoff=swn[1]
#cpubtn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'cpuspeed.png')).convert()
#mixbtn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'mixrate.png')).convert()
#fskipbtn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'frameskip.png')).convert()
#fvfilemenu=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'fvfilemenu.png')).convert()
fmicon=pygame.image.load(os.path.join("VMSYSTEM", "GFX", 'filemenuicon.png')).convert_alpha()
fvfilemenu=vmui.makemenubtn("FILE", icon=fmicon)
cpubtn=vmui.makemenubtn("CPU SPEED", width=80)
mixbtn=vmui.makemenubtn("MIXER RATE", width=80)
fskipbtn=vmui.makemenubtn("FRAME SKIP", width=80)
#lbtn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'lbtn.png')).convert()
#rbtn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'rbtn.png')).convert()
#saveicn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'save.png')).convert()
#quiticn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'quit.png')).convert()
#reseticn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'reset.png')).convert()
#helpicn=pygame.image.load(os.path.join(os.path.join('VMSYSTEM', 'GFX', "settings"), 'help.png')).convert()
simplefontC = pygame.font.SysFont(None, 28)
simplefontB = pygame.font.SysFont(None, 19)
catfont = pygame.font.SysFont(None, 19)
CPUWAIT=libvmconf.getconf("cpu", "cpuwait")#
stepbystep=int(libvmconf.getconf("cpu", "stepbystep"))#
vmexeclogflg=int(libvmconf.getconf("log", "vmexec"))#
logromexit=int(libvmconf.getconf("log", "romexit"))#
logIOexit=int(libvmconf.getconf("log", "ioexit"))#
tromlogging=int(libvmconf.getconf("log", "tromlogging"))
disablereadouts=int(libvmconf.getconf("video", "disablereadouts"))#
fskip=int(libvmconf.getconf("video", "fskip"))#
ttystyle=int(libvmconf.getconf("video", "ttystyle"))#
#DEFAULTSTREG=libvmconf.getconf("bootup", "DEFAULTSTREG")
mixrate=int(libvmconf.getconf("audio", "mixrate"))#
fm0=vmui.menuitem("Help (F1)", "HELP")
fm1=vmui.menuitem("Save", "SAVE")
fm2=vmui.menuitem("Reset", "RESET")
fm3=vmui.menuitem("Quit", "QUIT")
filemenu=[fm0, fm1, fm2, fm3]
#CPU SPEED PRESETS
#handled as strings here for sake of simplicity.
CPUSLOW="0.001"
CPUNORM="0.0005"
CPUFAST="0.00001"
CPUSUPER="0.000005"
cpu0=vmui.menuitem("Slow", "0.001")
cpu1=vmui.menuitem("Normal", "0.0005")
cpu2=vmui.menuitem("Fast", "0.00001")
cpu3=vmui.menuitem("Super", "0.000005")
cpumenu=[cpu0, cpu1, cpu2, cpu3]
#frameskip selector code
fskiplist=[0, 1, 2, 3, 4, 5, 10, 15, 20, 50, 100]
fskipmenu=list()
for f in fskiplist:
dx=vmui.menuitem(str(f), f)
fskipmenu.extend([dx])
#mixer rate selector code
mixlist=[8000, 11025, 22050, 44100, 48000]
mixmenu=list()
for f in mixlist:
dx=vmui.menuitem(str(f), f)
mixmenu.extend([dx])
qflg=0
scupdate=1
stcolor=libthemeconf.desktext
engtimer=pygame.time.Clock()
while qflg==0:
#time.sleep(0.05)
engtimer.tick(30)
if scupdate==1:
scupdate=0
hudrect=pygame.Rect(0, 0, screenx, 60)
#screensurf.blit(setbg, (0, 0))
screensurf.fill(libthemeconf.deskcolor)
pygame.draw.rect(screensurf, libthemeconf.hudbg, hudrect, 0)
screensurf.blit(sbtcvmbadge, ((screenx-120), 0))
fmx=screensurf.blit(fvfilemenu, (3, 5))
mixx=screensurf.blit(mixbtn, (45, 5))
menulabel=catfont.render(str(mixrate), True, libthemeconf.btntext)
screensurf.blit(menulabel, (45, 5))
fskipx=screensurf.blit(fskipbtn, (127, 5))
menulabel=catfont.render(str(fskip), True, libthemeconf.btntext)
screensurf.blit(menulabel, (127, 5))
cpux=screensurf.blit(cpubtn, (209, 5))
if CPUWAIT==CPUSLOW:
menulabel=catfont.render("Slow", True, libthemeconf.btntext)
elif CPUWAIT==CPUNORM:
menulabel=catfont.render("Normal", True, libthemeconf.btntext)
elif CPUWAIT==CPUFAST:
menulabel=catfont.render("Fast", True, libthemeconf.btntext)
elif CPUWAIT==CPUSUPER:
menulabel=catfont.render("Super", True, libthemeconf.btntext)
else:
menulabel=catfont.render("Other", True, libthemeconf.btntext)
screensurf.blit(menulabel, (209, 5))
menulabel=simplefontB.render("Status Readouts.", True, stcolor)
screensurf.blit(menulabel, (0, 80))
if disablereadouts==0:
disre=screensurf.blit(swon, (0, 100))
else:
disre=screensurf.blit(swoff, (0, 100))
menulabel=simplefontB.render("TTY (virtual text display)", True, stcolor)
screensurf.blit(menulabel, (250, 80))
if ttystyle==0:
ttyx=screensurf.blit(swon, (250, 100))
else:
ttyx=screensurf.blit(swoff, (250, 100))
menulabel=simplefontB.render("Step By Step CPU debug mode.", True, stcolor)
screensurf.blit(menulabel, (0, 150))
if stepbystep==1:
stepx=screensurf.blit(swon, (0, 170))
else:
stepx=screensurf.blit(swoff, (0, 170))
menulabel=simplefontB.render("Log execution process.", True, stcolor)
screensurf.blit(menulabel, (250, 150))
if vmexeclogflg==1:
vmex=screensurf.blit(swon, (250, 170))
else:
vmex=screensurf.blit(swoff, (250, 170))
menulabel=simplefontB.render("Dump IObus on exit.", True, stcolor)
screensurf.blit(menulabel, (0, 220))
if logIOexit==1:
ioex=screensurf.blit(swon, (0, 240))
else:
ioex=screensurf.blit(swoff, (0, 240))
menulabel=simplefontB.render("Dump memory bus on exit.", True, stcolor)
screensurf.blit(menulabel, (250, 220))
if logromexit==1:
romex=screensurf.blit(swon, (250, 240))
else:
romex=screensurf.blit(swoff, (250, 240))
menulabel=simplefontB.render("Log memory bus operations", True, stcolor)
screensurf.blit(menulabel, (0, 290))
if tromlogging==1:
tromx=screensurf.blit(swon, (0, 310))
else:
tromx=screensurf.blit(swoff, (0, 310))
pygame.display.update()
for event in pygame.event.get():
if event.type == QUIT:
qflg=1
break
if event.type == KEYDOWN and event.key == K_F1:
subprocess.Popen(["python", "helpview.py", "settings.xml"])
if event.type == KEYDOWN and event.key == K_F8:
pygame.image.save(screensurf, (os.path.join('CAP', 'SCREENSHOT-settings.png')))
break
if event.type==MOUSEBUTTONDOWN:
if fmx.collidepoint(event.pos)==1 and event.button==1:
menuret=vmui.menuset(filemenu, 3, 45, reclick=0, fontsize=26)
if menuret=="HELP":
subprocess.Popen(["python", "helpview.py", "settings.xml"])
if menuret=="SAVE":
libvmconf.saveconf()
if menuret=="RESET":
libvmconf.resetconf()
CPUWAIT=libvmconf.getconf("cpu", "cpuwait")
stepbystep=int(libvmconf.getconf("cpu", "stepbystep"))
vmexeclogflg=int(libvmconf.getconf("log", "vmexec"))
logromexit=int(libvmconf.getconf("log", "romexit"))
logIOexit=int(libvmconf.getconf("log", "ioexit"))
tromlogging=int(libvmconf.getconf("log", "tromlogging"))
disablereadouts=int(libvmconf.getconf("video", "disablereadouts"))
fskip=int(libvmconf.getconf("video", "fskip"))
ttystyle=int(libvmconf.getconf("video", "ttystyle"))
mixrate=int(libvmconf.getconf("audio", "mixrate"))
#frameskip selector code
print "dxreset"
scupdate=1
if menuret=="QUIT":
qflg=1
break
if mixx.collidepoint(event.pos)==1 and event.button==1:
mixratebak=mixrate
mixrate=vmui.menuset(mixmenu, 45, 45, reclick=0, fontsize=26)
if mixrate==None:
mixrate=mixratebak
libvmconf.setconf("audio", "mixrate", str(mixrate))
scupdate=1
if cpux.collidepoint(event.pos)==1 and event.button==1:
cpubak=CPUWAIT
CPUWAIT=vmui.menuset(cpumenu, 209, 45, reclick=0, fontsize=26)
if CPUWAIT==None:
CPUWAIT=cpubak
libvmconf.setconf("cpu", "cpuwait", str(CPUWAIT))
scupdate=1
if fskipx.collidepoint(event.pos)==1 and event.button==1:
fskipbak=fskip
fskip=vmui.menuset(fskipmenu, 127, 45, reclick=0, fontsize=26)
if fskip==None:
fskip=fskipbak
libvmconf.setconf("video", "fskip", str(fskip))
scupdate=1
#if quitx.collidepoint(event.pos)==1 and event.button==1:
#qflg=1
#break
#if helpx.collidepoint(event.pos)==1 and event.button==1:
#subprocess.Popen(["python", "helpview.py", "settings.xml"])
#if savex.collidepoint(event.pos)==1 and event.button==1:
#libvmconf.saveconf()
#if resetx.collidepoint(event.pos)==1 and event.button==1:
#libvmconf.resetconf()
#CPUWAIT=libvmconf.getconf("cpu", "cpuwait")
#stepbystep=int(libvmconf.getconf("cpu", "stepbystep"))
#vmexeclogflg=int(libvmconf.getconf("log", "vmexec"))
#logromexit=int(libvmconf.getconf("log", "romexit"))
#logIOexit=int(libvmconf.getconf("log", "ioexit"))
#tromlogging=int(libvmconf.getconf("log", "tromlogging"))
#disablereadouts=int(libvmconf.getconf("video", "disablereadouts"))
#fskip=int(libvmconf.getconf("video", "fskip"))
#ttystyle=int(libvmconf.getconf("video", "ttystyle"))
#mixrate=int(libvmconf.getconf("audio", "mixrate"))
##frameskip selector code
#print "dxreset"
if disre.collidepoint(event.pos)==1 and event.button==1:
if disablereadouts==0:
disablereadouts=1
else:
disablereadouts=0
scupdate=1
libvmconf.setconf("video", "disablereadouts", str(disablereadouts))
if ttyx.collidepoint(event.pos)==1 and event.button==1:
if ttystyle==0:
ttystyle=1
else:
ttystyle=0
scupdate=1
libvmconf.setconf("video", "ttystyle", str(ttystyle))
if stepx.collidepoint(event.pos)==1 and event.button==1:
if stepbystep==0:
stepbystep=1
else:
stepbystep=0
scupdate=1
libvmconf.setconf("cpu", "stepbystep", str(stepbystep))
if vmex.collidepoint(event.pos)==1 and event.button==1:
if vmexeclogflg==0:
vmexeclogflg=1
else:
vmexeclogflg=0
scupdate=1
libvmconf.setconf("log", "vmexec", str(vmexeclogflg))
if tromx.collidepoint(event.pos)==1 and event.button==1:
if tromlogging==0:
tromlogging=1
else:
tromlogging=0
scupdate=1
libvmconf.setconf("log", "tromlogging", str(tromlogging))
if romex.collidepoint(event.pos)==1 and event.button==1:
if logromexit==0:
logromexit=1
else:
logromexit=0
scupdate=1
libvmconf.setconf("log", "romexit", str(logromexit))
if ioex.collidepoint(event.pos)==1 and event.button==1:
if logIOexit==0:
logIOexit=1
else:
logIOexit=0
scupdate=1
libvmconf.setconf("log", "ioexit", str(logIOexit))