-
Notifications
You must be signed in to change notification settings - Fork 11
/
rom_config.py
executable file
·326 lines (262 loc) · 7.97 KB
/
rom_config.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""" ~LCD Game Shrinker~
default configuration
This program permits to shrink MAME high resolution artwork and
graphics for protable device running LCD game emulator.
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
"""
__author__ = "bzhxx"
__contact__ = "https://github.com/bzhxx"
__license__ = "GPLv3"
"""
Various parameters for different ROM files
the repository of the original ROM files is composed of:
<rom_name> directory /
- BackgroundNS.png (mandatory)
- <rom name>.svg (mandatory)
- binary program (mandatory)
- melody (optional)
> background_file
This is the background ! BackgroundNS.png.or fanart .png
> segment_file
This is the SVG file where the segments are defined (.svg)
> program_file
the raw binary program file
> melody_file
the raw binary melody file (if it exists)
> border_trim (not used)
used during the rescaling of artwork to keep or remove the borders
border_trim=True : remove the border otherwise keep it
> full name
The name of the generated file at the end
> CPU to emulate
indicates which CPU need to be emulated
from MAME source code or .ini files, hh_sm510.cpp
The follwing values are supported
CPU_TYPE="SM512__\0"
CPU_TYPE="SM511__\0"
CPU_TYPE="SM510__\0"
CPU_TYPE="SM500__\0"
CPU_TYPE="SM5A___\0"
> background dimensions (applied on backgroundNS.png)
> screen dimensions (applied on .svg)
> border dimensions (applied on .svg)
### Parameters from MAME layout file default.lay
# <view name="Background Only (No Shadow)">
background_x=0
background_y=0
background_width=1290
background_height=854
screen_x=35
screen_y=17
screen_width=1221
screen_height=802
> flag_rendering_lcd_inverted = True or False
graphic rendering (multiply)
If false (default case)
by default the background is from the background artwork file
the background and non_white segment pixels are 'RGB multiply".
or
If True ( case "tabletop" or "inverted lcd screen")
by default the background is black
if a segment state is ON, the artwork file and the non_black segment pixels are 'RGB multiply".
> flag_background_jpeg =True or False
JPEG is used to compress the artwork file.
> jpeg_quality=90
typical values : 80 to 95
The following presets are available by default:
``web_low``, ``web_medium``, ``web_high``, ``web_very_high``, ``web_maximum``,
``low``, ``medium``, ``high``, ``maximum``.
> background_resolution = RGB565
The background image resolution can reduced using this feature.
https://github.com/python-pillow/Pillow/blob/master/src/PIL/JpegPresets.py#L71
> keys/buttons mapping
keys/buttons mapping can be found in MAME source file (hh_sm510.cpp)
CPU INPUTS S1..S8, BA, B
GW 8 BUTTONS used for retro-go: 8 bits
K4..K1 : 32 bits
LEFT,RIGHT,UP,DOWN,GAME,SELECT,A,B
> flag_sound
define how to drive the external sound piezo buzzer
#R1 to piezo FLAG_SOUND_R1_PIEZO
#R2 to piezo FLAG_SOUND_R2_PIEZO
#R1&R2 to piezo FLAG_SOUND_R1R2_PIEZO
#R1(+S1) to piezo FLAG_SOUND_R1S1_PIEZO
#S1(+R1) to piezo FLAG_SOUND_S1R1_PIEZO
"""
# WARNING : this file is used to share the ROM parameters along the building processs
# if you want to customize some of parameters for a specific ROM, it's better to create
# or to modify the corresponding script in the custom directory
#######################################################################################
### You can reduce the ROM size by changing the following parameters:
## flag_segments_resolution_bits
## flag_background_jpeg
## jpeg_quality
## To get the highest resolution
'''
flag_segments_resolution_bits = 4
flag_background_jpeg = False
'''
## To get the lowest ROM file size
'''
flag_segments_resolution_bits = 2
flag_background_jpeg = True
jpeg_quality = 75
'''
## To reduce ROM file size (medium configuration)
'''
flag_segments_resolution_bits = 4
flag_background_jpeg = True
jpeg_quality = 90
'''
# Enable shortcut B+TIME and B+GAME to get TIME and ALARM
shortcut_time_alarm = False
# Customized segments resolution is 8bits(8), 4bits(4) or 2bits(2)
flag_segments_resolution_bits = 4
## Set the 2 following seeting to True to get smaller rom files
# select if the background is JPEG compressed (lossly) or compressed within ROM data as RGB565
flag_background_jpeg = False
# For JPEG compressed
jpeg_quality = 90
# Enable to keep aspect ratio, otherwise the display is full screen
keep_aspect_ratio = False
# Enable to rotate display by 90° clock wise
rotate = False
# you can reduce the background resolution
# 1 no reduction RGB565
# 2 (-1 bit) resolution RGB454
# 4 (-2 bit) resolution RGB343
# 8 (-3 bit) resolution RGB232
RGB565 = 1
RGB454 = 2
RGB343 = 4
RGB232 = 8
background_resolution = RGB565
# Defined the LCD deflicker level
# 0 : filter is disabled
# 1 : medium filtering
# 2 : high fltering
flag_lcd_deflicker_level = 2
# ROM files
background_file = "none"
segments_file = "none"
program_file = "none"
melody_file = "none"
# dual screen
segments_top_file = "none"
segments_bottom_file = "none"
segments_left_file = "none"
segments_right_file = "none"
background_top_file = "none"
background_bottom_file = "none"
background_left_file = "none"
background_right_file = "none"
# dual screen ?
dual_screen_vert = False
dual_screen_hor = False
# error indication
found = False
layout_found = False
# Warum user no custom script
# at least keys are undefined
custom_script_notfound = False
mame_rom_dir = "_"
build_dir = "_"
rom_name = "_"
# MAME constructor structure
mame_year = 0
mame_name = 0
mame_parent = 0
mame_comp = 0
mame_machine = 0
mame_input = 0
mame_class = 0
mame_init = 0
mame_company = 0
mame_fullname = "'unknown game'"
mame_flags = 0
CPU_TYPE = "NOCPU__\0"
# background coords from MAME layout
background_x = 0
background_y = 0
background_width = 0
background_height = 0
# screen coords from MAME layout
screen_x = 0
screen_y = 0
screen_width = 0
screen_height = 0
# use to define the right way to proceed the LCD segments blending
# False : LCD segments are black, by default the background is the artwork.
# True : LCD segments are white, by default the background is black.
flag_rendering_lcd_inverted = False
# Enable drop shadow rendering effect
drop_shadow = False
# Crop the black border of jpeg background to reduce a little bit the jpeg file size
crop_jpeg_background_border = True
# Buttons mapping
# up to 8 columns outputs to address 4 inputs (K1..K4)
# S1..S8 or R1..R4
# 2 independants inputs
# BA,B
BTN_SIZE = 10
BTN_DATA = [0]*BTN_SIZE
# RAM address of the time count
# used to get consistent time emulation
ADD_TIME_HOUR_MSB=0
ADD_TIME_HOUR_LSB=0
ADD_TIME_MIN_MSB=0
ADD_TIME_MIN_LSB=0
ADD_TIME_SEC_MSB=0
ADD_TIME_SEC_LSB=0
ADD_TIME_HOUR_MSB_PM_VALUE=0
###################################################
# Buttons mapping according to the host machine (retro-go)
# left | (up << 1) | (right << 2) | (down << 3) |
# (a << 4) | (b << 5) | (time << 6) | (game << 7) |
BTN_LEFT = 0x1
BTN_UP = 0x2
BTN_RIGHT = 0x4
BTN_DOWN = 0x8
BTN_A = 0x10
BTN_B = 0x20
BTN_TIME = 0x40
BTN_GAME = 0x80
BTN_SHORTCUT_B_TIME = 0x0
BTN_SHORTCUT_B_GAME = 0x0
if shortcut_time_alarm:
BTN_SHORTCUT_B_TIME = BTN_B + BTN_TIME
BTN_SHORTCUT_B_GAME = BTN_B + BTN_GAME
# SM5A buttons according to R1..R4
R1 = 0
R2 = 1
R3 = 2
R4 = 3
# SM510 buttons S1..S9
S1 = 0
S2 = 1
S3 = 2
S4 = 3
S5 = 4
S6 = 5
S7 = 6
S8 = 7
# Direct input BA & B
BA = 8
B = 9
# Piezo buzzer output configuration
FLAG_SOUND_R1_PIEZO = 1
FLAG_SOUND_R2_PIEZO = 2
FLAG_SOUND_R1R2_PIEZO = 3
FLAG_SOUND_R1S1_PIEZO = 4
FLAG_SOUND_S1R1_PIEZO = 5
flag_sound = FLAG_SOUND_R1_PIEZO