mame-catver-filter: filter mame roms by category
[clinton/scratch.git] / mame-catver-filter / catver.lisp
1 ;;; Simple program to parse catver.ini
2 ;;; (http://www.progettosnaps.net/catver/) and filter the results.
3 ;;; 2019 Clinton Ebadi <clinton@unknownlamer.org>
4 ;;; CC0 To the extent possible under law, Clinton Ebadi has waived all
5 ;;; copyright and related or neighboring rights to MAME Category
6 ;;; Filter.
7
8 (quicklisp:quickload '(:parser.ini :cl-ppcre :alexandria :arnesi))
9
10 (import '(alexandria:read-file-into-string))
11
12 ;; fixme: parser.ini doesn't handle DOS line endings so file has to be
13 ;; converted to unix line endings. manually open the stream instead
14 ;; after I remember how external formats work again.
15
16 ;; fixme: since I'm using an ad-hoc parser and put zero effort into this, you have to edit catver.ini and extract just the [Category] section
17 (defparameter *catver-source* (pathname "/home/clinton/src/repos/local/scratch/mame-catver-filter/pS_CatVer_230/catver-only.ini"))
18
19 ;; parser.ini barfed on catver (ate all ram and then died...)
20 ;; (defparameter *parsed-catver*
21 ;; (let ((parser.ini:*value-terminating-whitespace-expression* #\Newline))
22 ;; (parser.ini:parse *catver-source* 'list)))
23
24 (defparameter *catver-hash* (make-hash-table :test 'equal))
25
26 (with-open-file (catver-stream *catver-source* )
27 (arnesi:awhile (read-line catver-stream nil nil)
28 (cl-ppcre:register-groups-bind (game category)
29 ("([^=]+)=([^=]+)" arnesi:it)
30 (format t "KEY ~A VALUE ~A~%" game category)
31 (setf (gethash category *catver-hash*) (cons game (gethash category *catver-hash*))))))
32
33 (defun print-cats ()
34 (format t "(")
35 (maphash (lambda (key value)
36 (format t "~S~%" key))
37 *catver-hash*)
38 (format t ")"))
39
40 (defun filter-games (categories)
41 (mapcan (lambda (cat) (gethash cat *catver-hash*)) categories))
42
43 (defun dump-games (filename categories)
44 (with-open-file (outf filename :direction :output :if-exists :error)
45 (mapc (lambda (x) (format outf "~A~%" x)) (filter-games categories))))
46
47
48 ;; 2020-11-19: might want to review these for new categories, haven't checked since mame 0.214
49 (defparameter *filtered-cats*
50 '("Maze / Shooter Small"
51 "Sports / Football"
52 "Sports / Soccer"
53 "Driving / Truck Guide"
54 "Shooter / Flying Vertical"
55 "Sports / Basketball"
56 "Sports / Baseball"
57 "Driving / 1st Person"
58 "Shooter / Gun"
59 "Sports / Wrestling"
60 "Shooter / Field"
61 "Sports / Tennis"
62 "Shooter / Flying Horizontal"
63 "Puzzle / Match"
64 "Casino / Misc."
65 "Driving / Motorbike"
66 "Maze / Collect"
67 "Fighter / 2.5D"
68 "Sports / Skateboarding"
69 "Shooter / Misc. Horizontal"
70 "Sports / Track & Field"
71 "Sports / Pool"
72 "Computer / Training Board"
73 "Shooter / Gallery"
74 "Shooter / Flying (chase view)"
75 "Platform / Run Jump"
76 "Sports / Volleyball"
77 "Driving / Race 1st Person"
78 "Fighter / Versus"
79 "Platform / Shooter Scrolling"
80 "Maze / Change Surface"
81 "Driving / Race (chase view)"
82 "Shooter / Misc. Vertical"
83 "Puzzle / Sliding"
84 "Shooter / Flying 1st Person"
85 "Driving / Plane"
86 "Sports / Fishing"
87 "Platform / Fighter Scrolling"
88 "Sports / Golf"
89 "Platform / Run, Jump & Scrolling"
90 "Shooter / 1st Person"
91 "Maze / Shooter Large"
92 "Shooter / 3rd Person"
93 "Sports / Bowling"
94 "Shooter / Misc."
95 "Sports / Skiing"
96 "Shooter / Walking"
97 "Sports / Darts"
98 "Sports / Hockey"
99 "Maze / Outline"
100 "Driving / Race Track"
101 "Climbing / Tree - Plant"
102 "Driving / Misc."
103 "Shooter / Flying"
104 "Shooter / Driving (chase view)"
105 "Driving / Boat"
106 "Puzzle / Drop"
107 "Puzzle / Misc."
108 "Sports / Misc."
109 "Platform / Fighter"
110 "Fighter / 2D"
111 "Driving / Race (chase view) Bike"
112 "Ball & Paddle / Breakout"
113 "Sports / Horse Racing"
114 "Sports / Armwrestling"
115 "Sports / Boxing"
116 "Fighter / 3D"
117 "Shooter / Driving"
118 "Shooter / Versus"
119 "Shooter / Driving Vertical"
120 "Fighter / Vertical"
121 "Driving / Race"
122 "Rhythm / Dance"
123 "Maze / Surround"
124 "Misc. / Toy Cars"
125 "Puzzle / Maze"
126 "Platform / Shooter"
127 "Maze / Escape"
128 "Shooter / Driving Diagonal"
129 "Ball & Paddle / Pong"
130 "Maze / Collect & Put"
131 "Rhythm / Instruments"
132 "Fighter / Misc."
133 "Maze / Digging"
134 "Maze / Blocks"
135 "Maze / Cross"
136 "Shooter / Driving Horizontal"
137 "Fighter / Field"
138 "Sports / Bull Fighting"
139 "Shooter / Driving 1st Person"
140 "Maze / Ladders"
141 "Puzzle / Reconstruction"
142 "Maze / Driving"
143 "Maze / Defeat Enemies"
144 "Ball & Paddle / Jump and Touch"
145 "Climbing / Building"
146 "Puzzle / Outline"
147 "Driving / Race Bike"
148 "Shooter / Command"
149 "Sports / Sumo"
150 "Fighter / Compilation"
151 "Rhythm / Misc."
152 "Driving / Demolition Derby"
153 "Maze / Paint"
154 "Sports / Rugby Football"
155 "Fighter / Driving Vertical"
156 "Fighter / Versus Co-op"
157 "Maze / Fighter"
158 "Misc. / Prediction"
159 "Fighter / Asian 3D"
160 "Maze / Move and Sort"
161 "Sports / Hang Gliding"
162 "Maze / Integrate"
163 "Shooter / Flying Diagonal"
164 "Platform / Maze"
165 "Sports / Horseshoes"
166 "Sports / Handball"
167 "Maze / Ball Guide"
168 "Misc. / Reflex"
169 "Driving / Motorbike (Motocross)"
170 "Driving / Guide and Collect"
171 "Sports / Volley - Soccer"
172 "Misc. / Versus"
173 "Tabletop / Othello - Reversi"
174 "Driving / Landing"
175 "Music / Drum Machine"
176 "Maze / Marble Madness"
177 "Shooter / Submarine"
178 "Maze / Misc."
179 "Sports / Dodgeball"
180 "Shooter / Motorbike"
181 "Sports / Ping Pong"
182 "Misc. / Hot-air Balloon"
183 "Driving / Guide and Shoot"
184 "Sports / SkyDiving"
185 "Climbing / Mountain - Wall"
186 "Shooter / Underwater"
187 "Sports / Shuffleboard"
188 "Ball & Paddle / Misc."
189 "Sports / Swimming"
190 "Maze / Run Jump"
191 "Driving / Catch"
192 "Sports / Gun"))
193
194 ;; for reference
195 (defparameter *all-cats*
196 '("Maze / Shooter Small"
197 "System / Device"
198 "Slot Machine / Video Slot"
199 "Sports / Football"
200 "Sports / Soccer"
201 "Game Console / Home Videogame"
202 "Electromechanical / Misc."
203 "Driving / Truck Guide"
204 "Shooter / Flying Vertical"
205 "MultiGame / Compilation"
206 "Sports / Basketball"
207 "Tabletop / Multi-Games"
208 "Sports / Baseball"
209 "Electromechanical / Pinball"
210 "Music / JukeBox"
211 "Driving / 1st Person"
212 "Shooter / Gun"
213 "Computer / Workstation - Server"
214 "Computer / Business - Terminal"
215 "Sports / Wrestling"
216 "System / BIOS"
217 "Puzzle / Match * Mature *"
218 "Shooter / Field"
219 "Casino / Cards"
220 "Misc. / Clock"
221 "Sports / Tennis"
222 "Shooter / Flying Horizontal"
223 "Puzzle / Match"
224 "Tabletop / Mahjong * Mature *"
225 "Casino / Misc."
226 "Driving / Motorbike"
227 "Maze / Collect"
228 "Fighter / 2.5D"
229 "Computer / Single Board"
230 "Utilities / EPROM Programmer"
231 "Sports / Skateboarding"
232 "Handheld / Electronic Game"
233 "Tabletop / Cards"
234 "Shooter / Misc. Horizontal"
235 "Sports / Track & Field"
236 "Sports / Pool"
237 "Misc. / Print Club"
238 "Computer / Training Board"
239 "Shooter / Gallery"
240 "Computer / Home System"
241 "Computer / Portable Digital Teletype"
242 "Quiz / Questions in Japanese"
243 "Shooter / Flying (chase view)"
244 "Platform / Run Jump"
245 "Tabletop / Hanafuda * Mature *"
246 "Computer / Construction Kit"
247 "Slot Machine / Reels"
248 "Board Game / Chess Machine"
249 "Computer / Misc."
250 "Sports / Volleyball"
251 "Driving / Race 1st Person"
252 "Utilities / Modem"
253 "Fighter / Versus"
254 "Casino / Multiplay"
255 "Platform / Shooter Scrolling"
256 "Maze / Change Surface"
257 "Driving / Race (chase view)"
258 "Slot Machine / Video Slot * Mature *"
259 "Shooter / Misc. Vertical"
260 "Coin Pusher / Misc."
261 "Puzzle / Sliding"
262 "Calculator / Pocket Computer"
263 "Computer / Development System"
264 "Tabletop / Mahjong"
265 "Shooter / Flying 1st Person"
266 "Driving / Plane"
267 "Sports / Fishing"
268 "Platform / Fighter Scrolling"
269 "Computer / Microcomputer"
270 "Sports / Golf"
271 "Music / Synthesizer"
272 "Platform / Run, Jump & Scrolling"
273 "Medal Game / Action"
274 "Misc. / Pinball"
275 "Shooter / 1st Person"
276 "Maze / Shooter Large"
277 "Shooter / 3rd Person"
278 "Sports / Bowling"
279 "Shooter / Misc."
280 "Misc. / Toy Robot"
281 "Sports / Skiing"
282 "Misc. / Multiplay"
283 "Shooter / Walking"
284 "Utilities / Test"
285 "Sports / Darts"
286 "Sports / Hockey"
287 "Maze / Outline"
288 "Telephone / Car Phone"
289 "Driving / Race Track"
290 "Climbing / Tree - Plant"
291 "Misc. / Catch"
292 "Whac-A-Mole / Hammer"
293 "Electromechanical / Redemption"
294 "Misc. / Bank-teller Terminal"
295 "Driving / Misc."
296 "Computer / Punched Car"
297 "Shooter / Flying"
298 "Shooter / Driving (chase view)"
299 "Driving / Boat"
300 "Puzzle / Drop"
301 "Puzzle / Misc."
302 "Misc. / Coin Pusher"
303 "Sports / Misc."
304 "Platform / Fighter"
305 "Fighter / 2D"
306 "Tabletop / Misc."
307 "Misc. / Electronic Board Game"
308 "Driving / Race (chase view) Bike"
309 "Ball & Paddle / Breakout"
310 "Sports / Horse Racing"
311 "Sports / Armwrestling"
312 "Misc. / Laser Disk Simulator"
313 "Sports / Boxing"
314 "Computer / Word-processing Machine"
315 "Fighter / 3D"
316 "Shooter / Driving"
317 "Calculator / Astrological Computer"
318 "Misc. / Teletype"
319 "Shooter / Versus"
320 "Shooter / Driving Vertical"
321 "Fighter / Vertical"
322 "Handheld / Pocket Device - Pad - PDA"
323 "Casino / Bingo"
324 "Puzzle / Toss"
325 "Casino / Racing"
326 "Electromechanical / Reels"
327 "Driving / Race"
328 "Board Game / Backgammon"
329 "Rhythm / Dance"
330 "Handheld / Plug n' Play TV Game"
331 "Misc. / Document Processors"
332 "Maze / Surround"
333 "Puzzle / Drop * Mature *"
334 "Board Game / Bridge Machine"
335 "Quiz / Questions in English"
336 "Misc. / Toy Cars"
337 "Multiplay / Mini-Games"
338 "Puzzle / Maze"
339 "Platform / Shooter"
340 "Maze / Escape"
341 "Casino / Lottery"
342 "Quiz / Questions in English * Mature *"
343 "Sports / Pool * Mature *"
344 "Medal Game / Bingo"
345 "Medal Game / Casino"
346 "MultiGame / Mini-Games"
347 "Handheld / Home Videogame Console"
348 "Platform / Run Jump * Mature *"
349 "Fighter / Versus * Mature *"
350 "Shooter / Driving Diagonal"
351 "Ball & Paddle / Breakout * Mature *"
352 "Ball & Paddle / Pong"
353 "Maze / Collect & Put"
354 "Rhythm / Instruments"
355 "Fighter / Misc."
356 "Misc. / Spank * Mature *"
357 "Maze / Digging"
358 "Maze / Blocks"
359 "Misc. / Device Programmer"
360 "Misc. / Cash Counter"
361 "Maze / Cross"
362 "Shooter / Driving Horizontal"
363 "Electromechanical / Bingo"
364 "Fighter / Field"
365 "Computer / Laptop - Notebook - Portable"
366 "Sports / Multiplay"
367 "Misc. / Unknown"
368 "Puzzle / Toss * Mature *"
369 "Sports / Bull Fighting"
370 "Shooter / Driving 1st Person"
371 "Casino / Cards * Mature *"
372 "Maze / Ladders"
373 "Misc. / Electronic Typewriter"
374 "Puzzle / Reconstruction"
375 "Misc. / Redemption"
376 "Maze / Driving"
377 "Handheld / Child Computer"
378 "Maze / Defeat Enemies"
379 "Ball & Paddle / Jump and Touch"
380 "Computer / Cablenet Controller"
381 "Climbing / Building"
382 "Utilities / Update"
383 "Puzzle / Outline"
384 "Computer / Child Computer"
385 "Medical Equipment / Visual Field Screener"
386 "Casino / Unknown"
387 "Board Game / Checker Machine"
388 "Misc. / Fingerprint Reader"
389 "Driving / Race Bike"
390 "Music / Audio Sequencer"
391 "Misc. / Jump and Bounce"
392 "Casino / Roulette"
393 "Shooter / Command"
394 "Sports / Sumo"
395 "Casino / Misc. * Mature *"
396 "Fighter / Compilation"
397 "Rhythm / Misc."
398 "Driving / Demolition Derby"
399 "Whac-A-Mole / Shooter"
400 "Maze / Paint"
401 "Sports / Rugby Football"
402 "Tabletop / Multiplay"
403 "Fighter / Driving Vertical"
404 "Fighter / Versus Co-op"
405 "Board Game / Dame Machine"
406 "Puzzle / Outline * Mature *"
407 "Maze / Fighter"
408 "Misc. / Satellite Receiver"
409 "Tabletop / Othello - Reversi * Mature *"
410 "Misc. / Speech Synthesizer"
411 "Misc. / Prediction"
412 "Electromechanical / Utilities"
413 "Printer / Matrix Printer"
414 "Misc. / EPROM Programmer"
415 "Misc. / Engine Control Unit"
416 "Shooter / Gallery * Mature *"
417 "Fighter / Asian 3D"
418 "Medal Game / Timing"
419 "Sports / Cards"
420 "Game Console / Fitness Game"
421 "Maze / Move and Sort"
422 "Computer Graphic Workstation / Broadcast Television"
423 "Quiz / Questions in Korean"
424 "Medal Game / Adventure"
425 "Misc. / Graphics Display Controller"
426 "Driving / Ambulance Guide"
427 "Misc. / Dartboard"
428 "Misc. / Electronic Game"
429 "Misc. / Wavetables Generator"
430 "Misc. / Car Voice Alert"
431 "Music / Instruments"
432 "Shooter / Flying * Mature *"
433 "Sports / Hang Gliding"
434 "Tabletop / Hanafuda"
435 "Puzzle / Reconstruction * Mature *"
436 "Quiz / Questions in Italian"
437 "Driving / FireTruck Guide"
438 "Utilities / Arcade System"
439 "Maze / Integrate"
440 "Whac-A-Mole / Fighter"
441 "Quiz / Questions in German"
442 "Maze / Collect * Mature *"
443 "Shooter / Flying Diagonal"
444 "Misc. / Pinball * Mature *"
445 "Tabletop / Match * Mature *"
446 "Misc. / Mini-Games"
447 "Medal Game / Horse Racing"
448 "Board Game / Cards"
449 "Tabletop / Renju"
450 "Platform / Maze"
451 "Utilities / Network Processor"
452 "Misc. / Similar Bowling Game"
453 "Whac-A-Mole / Gun"
454 "Tabletop / Go"
455 "Utilities / Redemption Board"
456 "Sports / Horseshoes"
457 "Misc. / Digital MultiMeter (DMM)"
458 "Computer / Pocket PC"
459 "Misc. / Drum Machine"
460 "Sports / Handball"
461 "Quiz / Questions in Japanese * Mature *"
462 "Telephone / ComputerPhone"
463 "Misc. / Dog Sitter"
464 "Telephone / Mobile Phone - Smartphone"
465 "Maze / Ball Guide"
466 "Misc. / Reflex"
467 "Casino / Horse Racing"
468 "Driving / Motorbike (Motocross)"
469 "Misc. / Gambling Board"
470 "Driving / Guide and Collect"
471 "Tabletop / Shougi"
472 "Misc. / Educational Game"
473 "Sports / Volley - Soccer"
474 "Misc. / Versus"
475 "Tabletop / Othello - Reversi"
476 "Fighter / Multiplay"
477 "Misc. / Response Time"
478 "Printer / Handbook"
479 "Misc. / DVD Reader-Writer"
480 "Driving / Landing"
481 "Maze / Escape * Mature *"
482 "Printer / Laser Printer"
483 "Misc. / In Circuit Emulator"
484 "Game Console / Home Videogame Console Expansion"
485 "MultiGame / Gambling"
486 "MultiGame / Gambling Board"
487 "Music / Drum Machine"
488 "Maze / Marble Madness"
489 "Quiz / Questions in Spanish"
490 "MultiGame / Compilation * Mature *"
491 "Printer / 3D Printer"
492 "Shooter / Submarine"
493 "Medical Equipment / ECG Unit"
494 "Computer / Video Production"
495 "Misc. / Time-Access Control TerminalTime and access control terminal"
496 "Maze / Misc."
497 "Printer / Thermal Printer"
498 "Multiplay / Compilation"
499 "Music / Tone Generator"
500 "Sports / Dodgeball"
501 "Calculator / Math Game Learning"
502 "Shooter / Motorbike"
503 "Medal Game / Versus"
504 "Utilities / Test ROM"
505 "Printer / Barcode Printer"
506 "Misc. / Pachinko"
507 "Puzzle / Paint * Mature *"
508 "Puzzle / Misc. * Mature *"
509 "Medal Game / Driving"
510 "Misc. / Virtual Environment"
511 "Sports / Ping Pong"
512 "Medal Game / Compilation"
513 "Misc. / VTR Control"
514 "Misc. / Hot-air Balloon"
515 "Misc. / Shoot Photos"
516 "Puzzle / Sliding * Mature *"
517 "Maze / Blocks * Mature *"
518 "Quiz / Questions in Chinese"
519 "Driving / Guide and Shoot"
520 "Sports / SkyDiving"
521 "Climbing / Mountain - Wall"
522 "Shooter / Outline * Mature *"
523 "Multiplay / Cards"
524 "Quiz / Questions in French"
525 "Puzzle / Cards"
526 "Misc. / Portable Media Player"
527 "Utilities / Weight Scale"
528 "Electromechanical / Change Money"
529 "Misc. / Graphic Tablet"
530 "Shooter / Flying Horizontal * Mature *"
531 "Misc. / Robot Control"
532 "Shooter / Underwater"
533 "Sports / Shuffleboard"
534 "Misc. / Temperature Controller"
535 "Misc. / Laserdisc Simulator"
536 "Casino / Multi-Games"
537 "Ball & Paddle / Misc."
538 "Utilities / Arcade Switcher"
539 "Shooter / Flying Vertical * Mature *"
540 "Calculator / Talking Calculator"
541 "Computer / Educational Game"
542 "Misc. / DVD Player"
543 "Maze / Digging * Mature *"
544 "Whac-A-Mole / Footsteps"
545 "Handheld / E-Book Reading"
546 "Multiplay / Misc. * Mature *"
547 "Sports / Swimming"
548 "Computer / Milling"
549 "Misc. / Order"
550 "Misc. / Dot-Matrix Display"
551 "Medal Game / Cards"
552 "Music / MIDI Player"
553 "Maze / Run Jump"
554 "Utilities / Electronic Digital Thermostat"
555 "Utilities / TV Test Pattern Generator"
556 "Misc. / Credit Card Terminal"
557 "Multiplay / Mini-Games * Mature *"
558 "Music / Player"
559 "Misc. / Laserdisc Player"
560 "Driving / Catch"
561 "Sports / Gun"
562 "Computer / Programming Machine"
563 "Medal Game / Dance"
564 "Handheld / Handpuppet Toy"))