Multi cores/roms "attract mode" with Linux bash script

Kernel, Main, Utilities & Applications, Miscellaneous Devices.
Airbag
Posts: 22
Joined: Wed Jun 10, 2020 2:46 pm
Has thanked: 5 times
Been thanked: 2 times

Multi cores/roms "attract mode" with Linux bash script

Unread post by Airbag »

Hello,

I'm trying to make a bash script that launches differents cores / rom i1 by 1 with a timer.

Something like that :

Code: Select all

#!/bin/bash
/media/fat/MiSTer /media/fat/_Arcade/cores/jtcps1_20201010.rbf "/media/fat/_Arcade/_Unofficial/_CPS1/Street Fighter II'  Hyper Fighting -World 921209-.mra"
sleep 100
killall MiSTer
/media/fat/MiSTer /media/fat/_Arcade/cores/jtcps1_20201010.rbf "/media/fat/_Arcade/_Unofficial/_CPS1/Street Fighter Zero -CPS Changer, Japan 951020-.mra"
sleep 100
killall MiSTer

# etc
It could be semi-automated for a whole folder of roms :

Code: Select all

for i in `ls`; 
do ... ; 
done
But first things first : I can't even launch a single core + rom with command line. I only just get the "static" screen + the core menu.
I guess I miss a "run/start" parameter in the commandline ?

Any idea ? Thanks !
zakk4223
Posts: 289
Joined: Sun May 24, 2020 10:55 pm
Been thanked: 120 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by zakk4223 »

That won't work. Main mister doesn't load the RBF into the FPGA on launch, it does that on selection of the menu entry, then "restarts" itself with those arguments so it knows to setup whatever is required for that core.

Basically when you select a core/mra in the menu, main mister does this:
- Figure out the RBF path (from the MRA, or just directly)
- Load the RBF into the FPGA
- exec("/media/fat/MiSTer") with the rbf and mra arguments.

Unfortunately there's no quick and easy way to load a core from the command line. I know there were a few people working on something like that, I think via a unix socket. I'm not sure where that effort went and if any of it ever ended up in the mainline repo.
Airbag
Posts: 22
Joined: Wed Jun 10, 2020 2:46 pm
Has thanked: 5 times
Been thanked: 2 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Airbag »

Thanks for the reply ! I'm not sure if I'm still skilled enough to deal with sockets in C, but I could try.
zakk4223 wrote: Wed Nov 18, 2020 5:47 am I know there were a few people working on something like that, I think via a unix socket.
Do you have any links about this ? I can't find anything on the forum.
User avatar
Xzarian
Posts: 34
Joined: Sun May 24, 2020 11:35 pm
Been thanked: 2 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Xzarian »

I wanted to bump this thread as I'm trying to figure out a way to do this as well.

I did find this script which apparently loads a nes game every 5 minutes, so it sounds like it should be possible, although I haven't tried the script myself.

I recently finished an arcade MiSTer build so I thought it would be awesome, especially now MiSTercade is on per-order, to be able to have some type of attract mode.
"MiSTer is not a garbage can with random functions used by 1-2 people."
-Sorgelig
Airbag
Posts: 22
Joined: Wed Jun 10, 2020 2:46 pm
Has thanked: 5 times
Been thanked: 2 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Airbag »

Nice find ! I'm gonna try it.
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

I'm using the arcade version of this. Works very well. Biggest issue is many arcade cores have dip switch defaults set to disable sound in the attract / demo mode.
netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Mellified wrote: Tue Mar 23, 2021 6:21 pm I'm using the arcade version of this. Works very well. Biggest issue is many arcade cores have dip switch defaults set to disable sound in the attract / demo mode.
Hi Mellified, can you point us to the arcade version of the script? I'd love to check it out
Xbytez
Site Admin
Posts: 479
Joined: Wed May 20, 2020 3:36 pm
Has thanked: 227 times
Been thanked: 805 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Xbytez »

netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Xbytez wrote: Tue Mar 23, 2021 9:42 pm See here:

https://github.com/mrchrisster/mister-arcade-attract
Thanks! :D
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

netbeui wrote: Wed Mar 24, 2021 2:40 am
Xbytez wrote: Tue Mar 23, 2021 9:42 pm See here:

https://github.com/mrchrisster/mister-arcade-attract
Thanks! :D
Note that the default mra.txt file it comes with is missing many games. You may want to run

Code: Select all

ls -N1 /media/fat/_arcade/*.mra | sed 's/\/media\/fat\/_arcade\///' > /media/fat/Scripts/mra.txt
from the terminal to update the list to use all your installed arcade games.
netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Yes I noticed that, I was going to manually add games to the mra.txt file - thanks for the detailed command line!

2 quick questions;

1) Can I create 2 versions of the ArcadeAttractMode-On.sh script? e,g, ArcadeAttractModeVert-On.sh and ArcadeAttractModeHoriz-On.sh. I'd like to split them into one for vertical games and one for horizontal games but want to make sure there are no dependencies on the filename
2) Do I need to run the ArcadeAttractMode-Off.sh before shutting down MiSTer? Or will shutting down the device "reset" the script to off automatically?
netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Hmm the script doesn't seem to be working reliably for me. I created a new mra.txt file using the command line above and I noticed it only switched to another game once. After loading the script and waiting 5 min it switched to another game but then it just stays on that second game indefinitely. So I thought maybe it was getting hung up on one of the filenames in my list of mra's, I tried pruning my mra.txt file down to just a few mra's but still no luck. Any idea what might cause it to only cycle through once and then stop?
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

I edited the time from 5 minutes (300 seconds) to 3 minutes (180) seconds and more recently to 2 minutes (120). I just ran it and saw it change through 4 or 5 games. I suspect the script may choke on certain special characters in mra file names and bomb out. I submitted a couple of issues to the repo with suggestions for improvements.

In the mean time, you can try my version. Note I renamed the files (e.g. "Attract_Arcade_On.sh") so all the attract scripts are together. This is also set to 120 seconds.
Attachments
Attract_Arcade_on.zip
(734 Bytes) Downloaded 177 times
netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Mellified wrote: Wed Mar 24, 2021 9:09 pm I edited the time from 5 minutes (300 seconds) to 3 minutes (180) seconds and more recently to 2 minutes (120). I just ran it and saw it change through 4 or 5 games. I suspect the script may choke on certain special characters in mra file names and bomb out. I submitted a couple of issues to the repo with suggestions for improvements.

In the mean time, you can try my version. Note I renamed the files (e.g. "Attract_Arcade_On.sh") so all the attract scripts are together. This is also set to 120 seconds.
Thanks Mellified! I tried your new script and although it seems more reliable than the old script I see that it reboots MiSTer between each game. I prefer the way the old script doesn't reboot in between games. I tried whittling down my mra.txt file to only a small handful of simple named mra's, eg:

1942.mra
Amidar.mra
Anteater.mra
Arkanoid.mra
Bagman.mra

But even with this simple file the original script eventually stops switching through games. The only "strangeness" I noticed was that there are different versions of Arkanoid in the _Arcade folder. I thought I finally found the culprit and maybe this was the reason the script was failing but even after removing Arkanoid.mra from my mra.txt file and re-running the original script it still eventually stops cycling through games :(

Would you mind updating that original script to make it as reliable as the new script but not reboot MiSTer between games? I'd really appreciate it! :D
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

I ran into a bunch of edge cases with the new reboot-free method of loading cores. I've submitted a PR to mrchrisster in the repo which I think takes care of all the issues I found.

If you want to preview the update it's available here:
https://github.com/mrchrisster/mister-a ... /Mellified
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

The improved version of the Arcade script is available! Testing and feedback appreciated.
netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Mellified wrote: Thu Mar 25, 2021 4:44 pm The improved version of the Arcade script is available! Testing and feedback appreciated.
Flippin. BEAUTIFUL.

Thank you!! :D :D :D
netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Only 1 teeny weeny issue, if you even want to call it that - I noticed you have "Tetris (cocktail set 1).mra" in the horizontal list. On my CRT that game comes up sideways. The regular "Tetris.mra" works fine so I just removed the cocktail one from the text file.

Thanks very much for this script!!
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

Can you reorient "Tetris (cocktail set 1).mra" from the OSD (F12 menu) using dip switches? I'm still going through and adjusting orientations and the sound during attract mode for various cores.
netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Mellified wrote: Thu Mar 25, 2021 6:15 pm Can you reorient "Tetris (cocktail set 1).mra" from the OSD (F12 menu) using dip switches? I'm still going through and adjusting orientations and the sound during attract mode for various cores.
No I checked that already, the option to flip/rotate isn't there like some of the other cores.
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

The script has been updated. It should switch arcade games faster consistently. There are cores that just don't load properly though. Attract mode will recover but if you are using the big list it is sometimes possible to see multiple in a row.

Debug options have been added, accessible via SSH.

https://github.com/mrchrisster/mister-arcade-attract
netbeui
Posts: 152
Joined: Fri Jul 31, 2020 5:04 am
Has thanked: 78 times
Been thanked: 23 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by netbeui »

Thanks for all your work, much appreciated!
User avatar
LamerDeluxe
Top Contributor
Posts: 1239
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 887 times
Been thanked: 284 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by LamerDeluxe »

@Mellified I enjoy seeing arcade cores I forgot about, or didn't play yet, when this script is running. Would it be easy to create a spin-off script that just launches a random arcade game to play?
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

LamerDeluxe wrote: Sat Mar 27, 2021 4:39 pm @Mellified I enjoy seeing arcade cores I forgot about, or didn't play yet, when this script is running. Would it be easy to create a spin-off script that just launches a random arcade game to play?
Oooh, an "I feel lucky arcade" script would be fun! I'll see about it.
User avatar
LamerDeluxe
Top Contributor
Posts: 1239
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 887 times
Been thanked: 284 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by LamerDeluxe »

Mellified wrote: Sun Mar 28, 2021 6:04 pm
LamerDeluxe wrote: Sat Mar 27, 2021 4:39 pm @Mellified I enjoy seeing arcade cores I forgot about, or didn't play yet, when this script is running. Would it be easy to create a spin-off script that just launches a random arcade game to play?
Oooh, an "I feel lucky arcade" script would be fun! I'll see about it.
Great, thanks! I'm looking forward to it.
User avatar
LamerDeluxe
Top Contributor
Posts: 1239
Joined: Sun May 24, 2020 10:25 pm
Has thanked: 887 times
Been thanked: 284 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by LamerDeluxe »

Mellified wrote: Sun Mar 28, 2021 7:17 pm Here it is...
https://github.com/mrchrisster/mister-a ... _Arcade.sh
Wow, that was fast! I'm going to try it.
EDIT: First game it started was DodonPachi :D This script has good taste.
User avatar
Mellified
Posts: 145
Joined: Sat Aug 22, 2020 8:38 pm
Been thanked: 51 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by Mellified »

Alright attract-ive people! We have a pretty big update for y'all!
  • Simply reboot your MiSTer to exit attract mode - no more "off" script! You can reboot (not reset!) from the OSD (F12 menu) or using the power switch.
  • Running "Attract_Arcade.sh" will cycle through all MRAs automatically.
  • If you want to use a custom list of MRAs create "/media/fat/Scripts/Arcade_Attract.txt" with 1 MRA per line, including the MRA extension.
  • Want to cycle only those MRAs for Horizontal and Vertical screens? Look for Arcade_Attract_Horiz.sh and Arcade_Attract_Vert.sh !
We still need to compile a list of vertical cores, so this script hasn't been released yet. Please reach out with your lists!

Get the update here:
https://github.com/mrchrisster/mister-arcade-attract
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by jca »

It would be a good idea to have a variable BASE_PATH="/media/fat" which could be modified by an optional ini file for those having the _Arcade directory on USB.

Edit
And also a list of mras to exclude when running the script for all mras: after using brute force to replace all occurrences of fat by usb0 the script works but at some point the OSD got stuck with the popup "Sending ROM #1" and the progress bar with only one empty square. I sshed into MISTer and ps showed the culprit DoDonPachi (Arrange) which is very picky on my MISTer and does not start everytime.
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Multi cores/roms "attract mode" with Linux bash script

Unread post by jca »

This is not a problem with the script but it is a real annoyance and totally ruins the experience:
When switching cores the screen is sometimes screwed and stay that way until a reboot, usually with power off/on.
It seems that nothing can be done about it, Sorge tried his best but it is due to MISTer trying to make the FPGA do things for which it was not designed to do.
Sad!
Post Reply